Last change
on this file since 9519422 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Use standard integer types.
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | /*
|
---|
2 | =============================================================================
|
---|
3 | sprintf.c -- sprintf function
|
---|
4 | Version 2 -- 1987-06-11 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "stdarg.h"
|
---|
9 |
|
---|
10 | extern int32_t dofmt_(int16_t (*putsub)(), int8_t *format, va_list args);
|
---|
11 |
|
---|
12 | static int8_t *buff;
|
---|
13 | static int16_t spsub(int8_t c);
|
---|
14 |
|
---|
15 | /*
|
---|
16 | =============================================================================
|
---|
17 | sprintf(str, fmt, args) -- format args into str according to fmt
|
---|
18 | =============================================================================
|
---|
19 | */
|
---|
20 |
|
---|
21 | int32_t sprintf(int8_t *str, int8_t *fmt, ...)
|
---|
22 | {
|
---|
23 | register int32_t count;
|
---|
24 | va_list aptr;
|
---|
25 |
|
---|
26 | buff = str;
|
---|
27 | va_start(aptr, fmt);
|
---|
28 | count = dofmt_(spsub, fmt, aptr);
|
---|
29 | va_end(aptr);
|
---|
30 | *buff = '\0';
|
---|
31 | return(count);
|
---|
32 | }
|
---|
33 |
|
---|
34 | /*
|
---|
35 | =============================================================================
|
---|
36 | spsub(c) - put c into the output string
|
---|
37 | =============================================================================
|
---|
38 | */
|
---|
39 |
|
---|
40 | static int16_t spsub(int8_t c)
|
---|
41 | {
|
---|
42 | return((*buff++ = c) & 0xFF);
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.