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