Subversion Repositories libSmallPrintf

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line 29... Line 29...
29
        putchar is the only external dependency for this file,
29
        putchar is the only external dependency for this file,
30
        if you have a working putchar, leave it commented out.
30
        if you have a working putchar, leave it commented out.
31
        If not, uncomment the define below and
31
        If not, uncomment the define below and
32
        replace outbyte(c) by your own function call.
32
        replace outbyte(c) by your own function call.
33
*/
33
*/
-
 
34
#if defined SERIAL_UART1 || defined SERIAL_UART2 || defined SERIAL_UART3 || defined SERIAL_UART4
-
 
35
extern void PutCharSerial(char c);
-
 
36
#endif
34
 
37
 
35
static void printchar(char **str, int c)
38
static void printchar(char **str, int c)
36
{
39
{
37
 
40
 
38
        if (str)
41
        if (str)
Line 44... Line 47...
44
        else
47
        else
45
                (void)PutCharSerial(c);
48
                (void)PutCharSerial(c);
46
#endif
49
#endif
47
}
50
}
48
 
51
 
49
#define PAD_RIGHT 1
52
char static const PAD_RIGHT = 1;
50
#define PAD_ZERO 2
53
char static const PAD_ZERO = 2;
51
 
54
 
52
static int prints(char **out, const char *string, int width, int pad)
55
static int prints(char **out, const char *string, int width, int pad)
53
{
56
{
54
        register int pc = 0, padchar = ' ';
57
        register int pc = 0, padchar = ' ';
55
 
58
 
Line 217... Line 220...
217
                                pc += prints(out, scr, width, pad);
220
                                pc += prints(out, scr, width, pad);
218
                                continue;
221
                                continue;
219
                        }
222
                        }
220
                        if (*format == 'n')
223
                        if (*format == 'n')
221
                        { /* convert number printed so far and store in *va_arg( args, int)... */
224
                        { /* convert number printed so far and store in *va_arg( args, int)... */
222
                                int *dp = va_arg(args, int);
225
                                int *dp = (int *)va_arg(args, int);
223
                                *dp = pc;
226
                                *dp = pc;
224
                                continue;
227
                                continue;
225
                        }
228
                        }
226
                }
229
                }
227
                else
230
                else