annotate gsm-fw/lldbg/doprnt.c @ 940:0fb9b7f2ef87

gsm-fw/services/ffs/drv.c: Intel single bank flash driver hooked in
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sat, 31 Oct 2015 23:39:41 +0000
parents f5affe83ba2d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
865
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /* the guts of printf - this implementation came from 4.3BSD-Tahoe */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <sys/types.h>
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <ctype.h>
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <stdarg.h>
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 extern void lldbg_putchar();
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #define PUTC lldbg_putchar
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 #define ARG() \
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 _ulong = flags&LONGINT ? va_arg(argp, long) : va_arg(argp, int);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 #define BUF 12
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 #define todigit(c) ((c) - '0')
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 #define tochar(n) ((n) + '0')
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 #define LONGINT 0x01 /* long integer */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19 #define LONGDBL 0x02 /* long double; unimplemented */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 #define SHORTINT 0x04 /* short integer */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 #define ALT 0x08 /* alternate form */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 #define LADJUST 0x10 /* left adjustment */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 #define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 #define HEXPREFIX 0x40 /* add 0x or 0X prefix */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 lldbg_doprnt(fmt0, argp, outfunc, outfunc_param)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 u_char *fmt0;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 va_list argp;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 void (*outfunc)();
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 void *outfunc_param;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 register u_char *fmt; /* format string */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 register int ch; /* character from fmt */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 register int cnt; /* return value accumulator */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 register int n; /* random handy integer */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 register char *t; /* buffer pointer */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 u_long _ulong; /* integer arguments %[diouxX] */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 int base; /* base for [diouxX] conversion */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 int dprec; /* decimal precision in [diouxX] */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 int fieldsz; /* field size expanded by sign, etc */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 int flags; /* flags as above */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 int prec; /* precision from format (%.3d), or -1 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 int realsz; /* field size expanded by decimal precision */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 int size; /* size of converted field or string */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 int width; /* width from format (%8d), or 0 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 char sign; /* sign prefix (' ', '+', '-', or \0) */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 char softsign; /* temporary negative sign for floats */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 char *digs; /* digits for [diouxX] conversion */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 fmt = fmt0;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 digs = "0123456789abcdef";
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 for (cnt = 0;; ++fmt) {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 for (; (ch = *fmt) && ch != '%'; ++cnt, ++fmt)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 PUTC(ch);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 if (!ch)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 return (cnt);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 flags = 0; dprec = 0; width = 0;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 prec = -1;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 sign = '\0';
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 rflag: switch (*++fmt) {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 case ' ':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 * ``If the space and + flags both appear, the space
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 * flag will be ignored.''
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 * -- ANSI X3J11
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 if (!sign)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 sign = ' ';
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 case '#':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 flags |= ALT;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 case '*':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 * ``A negative field width argument is taken as a
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 * - flag followed by a positive field width.''
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 * -- ANSI X3J11
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 * They don't exclude field widths read from args.
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 if ((width = va_arg(argp, int)) >= 0)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 width = -width;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 /* FALLTHROUGH */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 case '-':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 flags |= LADJUST;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90 case '+':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
91 sign = '+';
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
92 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
93 case '.':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
94 if (*++fmt == '*')
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
95 n = va_arg(argp, int);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
96 else {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
97 n = 0;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
98 while (isascii(*fmt) && isdigit(*fmt))
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
99 n = 10 * n + todigit(*fmt++);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
100 --fmt;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
101 }
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
102 prec = n < 0 ? -1 : n;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
103 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
104 case '0':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
105 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
106 * ``Note that 0 is taken as a flag, not as the
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
107 * beginning of a field width.''
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
108 * -- ANSI X3J11
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
109 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
110 flags |= ZEROPAD;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
111 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
112 case '1': case '2': case '3': case '4':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
113 case '5': case '6': case '7': case '8': case '9':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
114 n = 0;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
115 do {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
116 n = 10 * n + todigit(*fmt);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
117 } while (isascii(*++fmt) && isdigit(*fmt));
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
118 width = n;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
119 --fmt;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
120 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
121 case 'L':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
122 flags |= LONGDBL;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
123 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
124 case 'h':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
125 flags |= SHORTINT;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
126 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
127 case 'l':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
128 flags |= LONGINT;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
129 goto rflag;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
130 case 'c':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
131 *(t = buf) = va_arg(argp, int);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
132 size = 1;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
133 sign = '\0';
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
134 goto pforw;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
135 case 'D':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
136 flags |= LONGINT;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
137 /*FALLTHROUGH*/
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
138 case 'd':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
139 case 'i':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
140 ARG();
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
141 if ((long)_ulong < 0) {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
142 _ulong = -_ulong;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
143 sign = '-';
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
144 }
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
145 base = 10;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
146 goto number;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
147 case 'n':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
148 if (flags & LONGINT)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
149 *va_arg(argp, long *) = cnt;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
150 else if (flags & SHORTINT)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
151 *va_arg(argp, short *) = cnt;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
152 else
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
153 *va_arg(argp, int *) = cnt;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
154 break;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
155 case 'O':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
156 flags |= LONGINT;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
157 /*FALLTHROUGH*/
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
158 case 'o':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
159 ARG();
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
160 base = 8;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
161 goto nosign;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
162 case 'p':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
163 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
164 * ``The argument shall be a pointer to void. The
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
165 * value of the pointer is converted to a sequence
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
166 * of printable characters, in an implementation-
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
167 * defined manner.''
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
168 * -- ANSI X3J11
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
169 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
170 /* NOSTRICT */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
171 _ulong = (u_long)va_arg(argp, void *);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
172 base = 16;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
173 goto nosign;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
174 case 's':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
175 if (!(t = va_arg(argp, char *)))
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
176 t = "(null)";
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
177 if (prec >= 0) {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
178 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
179 * can't use strlen; can only look for the
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
180 * NUL in the first `prec' characters, and
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
181 * strlen() will go further.
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
182 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
183 char *p;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
184
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
185 for (p = t, size = 0; size < prec; p++, size++)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
186 if (*p == '\0')
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
187 break;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
188 } else
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
189 size = strlen(t);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
190 sign = '\0';
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
191 goto pforw;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
192 case 'U':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
193 flags |= LONGINT;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
194 /*FALLTHROUGH*/
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
195 case 'u':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
196 ARG();
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
197 base = 10;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
198 goto nosign;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
199 case 'X':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
200 digs = "0123456789ABCDEF";
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
201 /* FALLTHROUGH */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
202 case 'x':
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
203 ARG();
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
204 base = 16;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
205 /* leading 0x/X only if non-zero */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
206 if (flags & ALT && _ulong != 0)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
207 flags |= HEXPREFIX;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
208
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
209 /* unsigned conversions */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
210 nosign: sign = '\0';
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
211 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
212 * ``... diouXx conversions ... if a precision is
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
213 * specified, the 0 flag will be ignored.''
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
214 * -- ANSI X3J11
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
215 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
216 number: if ((dprec = prec) >= 0)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
217 flags &= ~ZEROPAD;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
218
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
219 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
220 * ``The result of converting a zero value with an
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
221 * explicit precision of zero is no characters.''
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
222 * -- ANSI X3J11
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
223 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
224 t = buf + BUF;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
225 if (_ulong != 0 || prec != 0) {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
226 do {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
227 *--t = digs[_ulong % base];
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
228 _ulong /= base;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
229 } while (_ulong);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
230 digs = "0123456789abcdef";
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
231 if (flags & ALT && base == 8 && *t != '0')
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
232 *--t = '0'; /* octal leading 0 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
233 }
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
234 size = buf + BUF - t;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
235
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
236 pforw:
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
237 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
238 * All reasonable formats wind up here. At this point,
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
239 * `t' points to a string which (if not flags&LADJUST)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
240 * should be padded out to `width' places. If
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
241 * flags&ZEROPAD, it should first be prefixed by any
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
242 * sign or other prefix; otherwise, it should be blank
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
243 * padded before the prefix is emitted. After any
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
244 * left-hand padding and prefixing, emit zeroes
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
245 * required by a decimal [diouxX] precision, then print
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
246 * the string proper, then emit zeroes required by any
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
247 * leftover floating precision; finally, if LADJUST,
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
248 * pad with blanks.
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
249 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
250
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
251 /*
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
252 * compute actual size, so we know how much to pad
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
253 * fieldsz excludes decimal prec; realsz includes it
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
254 */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
255 fieldsz = size;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
256 if (sign)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
257 fieldsz++;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
258 if (flags & HEXPREFIX)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
259 fieldsz += 2;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
260 realsz = dprec > fieldsz ? dprec : fieldsz;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
261
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
262 /* right-adjusting blank padding */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
263 if ((flags & (LADJUST|ZEROPAD)) == 0 && width)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
264 for (n = realsz; n < width; n++)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
265 PUTC(' ');
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
266 /* prefix */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
267 if (sign)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
268 PUTC(sign);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
269 if (flags & HEXPREFIX) {
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
270 PUTC('0');
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
271 PUTC((char)*fmt);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
272 }
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
273 /* right-adjusting zero padding */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
274 if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
275 for (n = realsz; n < width; n++)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
276 PUTC('0');
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
277 /* leading zeroes from decimal precision */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
278 for (n = fieldsz; n < dprec; n++)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
279 PUTC('0');
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
280
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
281 for (n = size; --n >= 0; )
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
282 PUTC(*t++);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
283 /* left-adjusting padding (always blank) */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
284 if (flags & LADJUST)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
285 for (n = realsz; n < width; n++)
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
286 PUTC(' ');
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
287 /* finally, adjust cnt */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
288 cnt += width > realsz ? width : realsz;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
289 break;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
290 case '\0': /* "%?" prints ?, unless ? is NULL */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
291 return (cnt);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
292 default:
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
293 PUTC((char)*fmt);
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
294 cnt++;
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
295 }
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
296 }
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
297 /* NOTREACHED */
f5affe83ba2d lldbg hack (poor girl's substitute for JTAG) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
298 }