source: buchla-68k/iolib/sprintf.c@ d21fc6f

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
Line 
1/*
2 =============================================================================
3 sprintf.c -- sprintf function
4 Version 2 -- 1987-06-11 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10static int8_t *buff;
11static int16_t spsub(int16_t c);
12
13/*
14 =============================================================================
15 sprintf(str, fmt, args) -- format args into str according to fmt
16 =============================================================================
17*/
18
19int32_t sprintf(int8_t *str, int8_t *fmt, ...)
20{
21 register int32_t count;
22 va_list aptr;
23
24 buff = str;
25 va_start(aptr, fmt);
26 count = dofmt_(spsub, fmt, aptr);
27 va_end(aptr);
28 *buff = '\0';
29 return(count);
30}
31
32/*
33 =============================================================================
34 spsub(c) - put c into the output string
35 =============================================================================
36*/
37
38static int16_t spsub(int16_t c)
39{
40 return((*buff++ = c) & 0xFF);
41}
Note: See TracBrowser for help on using the repository browser.