| 99 | } |
| 100 | |
| 101 | int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), const char *fmt, va_list args, |
| 102 | void *data) |
| 103 | { |
| 104 | int len; |
| 105 | unsigned long long num; |
| 106 | int i, base; |
| 107 | const char *s; |
| 108 | |
| 109 | int flags; /* flags to number() */ |
| 110 | |
| 111 | int field_width; /* width of output field */ |
| 112 | int precision; /* min. # of digits for integers; max |
| 113 | number of chars for from string */ |
| 114 | int qualifier; /* 'h', 'H', 'l', 'L', 'z', or 'j' for integer fields */ |
| 115 | |
| 116 | int count; |
| 117 | |
| 118 | for (count = 0; *fmt; ++fmt) { |
| 119 | if (*fmt != '%') { |
| 120 | call_tx(*fmt), count++; |
| 121 | continue; |
| 122 | } |
| 123 | |
| 124 | /* process flags */ |
| 125 | flags = 0; |
| 126 | repeat: |
| 127 | ++fmt; /* this also skips first '%' */ |
| 128 | switch (*fmt) { |
| 129 | case '-': flags |= LEFT; goto repeat; |
| 130 | case '+': flags |= PLUS; goto repeat; |
| 131 | case ' ': flags |= SPACE; goto repeat; |
| 132 | case '#': flags |= SPECIAL; goto repeat; |
| 133 | case '0': flags |= ZEROPAD; goto repeat; |
| 134 | } |
| 135 | |
| 136 | /* get field width */ |
| 137 | field_width = -1; |
| 138 | if (isdigit(*fmt)) { |
| 139 | field_width = skip_atoi((char **)&fmt); |
| 140 | } else if (*fmt == '*') { |
| 141 | ++fmt; |
| 142 | /* it's the next argument */ |
| 143 | field_width = va_arg(args, int); |
| 144 | if (field_width < 0) { |
| 145 | field_width = -field_width; |
| 146 | flags |= LEFT; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /* get the precision */ |
| 151 | precision = -1; |
| 152 | if (*fmt == '.') { |
| 153 | ++fmt; |
| 154 | if (isdigit(*fmt)) { |
| 155 | precision = skip_atoi((char **)&fmt); |
| 156 | } else if (*fmt == '*') { |
| 157 | ++fmt; |
| 158 | /* it's the next argument */ |
no test coverage detected