Rev 4245 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4245 | Rev 4482 | ||
---|---|---|---|
Line 171... | Line 171... | ||
171 | * @return Number of characters printed, negative value on failure. |
171 | * @return Number of characters printed, negative value on failure. |
172 | * |
172 | * |
173 | */ |
173 | */ |
174 | static int print_char(const char ch, int width, uint32_t flags, printf_spec_t *ps) |
174 | static int print_char(const char ch, int width, uint32_t flags, printf_spec_t *ps) |
175 | { |
175 | { |
176 | count_t counter = 0; |
176 | size_t counter = 0; |
177 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
177 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
178 | while (--width > 0) { |
178 | while (--width > 0) { |
179 | /* |
179 | /* |
180 | * One space is consumed by the character itself, hence |
180 | * One space is consumed by the character itself, hence |
181 | * the predecrement. |
181 | * the predecrement. |
Line 209... | Line 209... | ||
209 | * @return Number of characters printed, negative value on failure. |
209 | * @return Number of characters printed, negative value on failure. |
210 | * |
210 | * |
211 | */ |
211 | */ |
212 | static int print_wchar(const wchar_t ch, int width, uint32_t flags, printf_spec_t *ps) |
212 | static int print_wchar(const wchar_t ch, int width, uint32_t flags, printf_spec_t *ps) |
213 | { |
213 | { |
214 | count_t counter = 0; |
214 | size_t counter = 0; |
215 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
215 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
216 | while (--width > 0) { |
216 | while (--width > 0) { |
217 | /* |
217 | /* |
218 | * One space is consumed by the character itself, hence |
218 | * One space is consumed by the character itself, hence |
219 | * the predecrement. |
219 | * the predecrement. |
Line 252... | Line 252... | ||
252 | { |
252 | { |
253 | if (str == NULL) |
253 | if (str == NULL) |
254 | return printf_putstr(nullstr, ps); |
254 | return printf_putstr(nullstr, ps); |
255 | 255 | ||
256 | /* Print leading spaces. */ |
256 | /* Print leading spaces. */ |
257 | count_t strw = str_length(str); |
257 | size_t strw = str_length(str); |
258 | if (precision == 0) |
258 | if (precision == 0) |
259 | precision = strw; |
259 | precision = strw; |
260 | 260 | ||
261 | /* Left padding */ |
261 | /* Left padding */ |
262 | count_t counter = 0; |
262 | size_t counter = 0; |
263 | width -= precision; |
263 | width -= precision; |
264 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
264 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
265 | while (width-- > 0) { |
265 | while (width-- > 0) { |
266 | if (printf_putchar(' ', ps) == 1) |
266 | if (printf_putchar(' ', ps) == 1) |
267 | counter++; |
267 | counter++; |
Line 308... | Line 308... | ||
308 | size_t strw = wstr_length(str); |
308 | size_t strw = wstr_length(str); |
309 | if (precision == 0) |
309 | if (precision == 0) |
310 | precision = strw; |
310 | precision = strw; |
311 | 311 | ||
312 | /* Left padding */ |
312 | /* Left padding */ |
313 | count_t counter = 0; |
313 | size_t counter = 0; |
314 | width -= precision; |
314 | width -= precision; |
315 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
315 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
316 | while (width-- > 0) { |
316 | while (width-- > 0) { |
317 | if (printf_putchar(' ', ps) == 1) |
317 | if (printf_putchar(' ', ps) == 1) |
318 | counter++; |
318 | counter++; |
Line 430... | Line 430... | ||
430 | /* Print the whole number, not only a part */ |
430 | /* Print the whole number, not only a part */ |
431 | precision = number_size; |
431 | precision = number_size; |
432 | } |
432 | } |
433 | 433 | ||
434 | width -= precision + size - number_size; |
434 | width -= precision + size - number_size; |
435 | count_t counter = 0; |
435 | size_t counter = 0; |
436 | 436 | ||
437 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
437 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
438 | while (width-- > 0) { |
438 | while (width-- > 0) { |
439 | if (printf_putchar(' ', ps) == 1) |
439 | if (printf_putchar(' ', ps) == 1) |
440 | counter++; |
440 | counter++; |
Line 593... | Line 593... | ||
593 | { |
593 | { |
594 | size_t i; /* Index of the currently processed character from fmt */ |
594 | size_t i; /* Index of the currently processed character from fmt */ |
595 | size_t nxt = 0; /* Index of the next character from fmt */ |
595 | size_t nxt = 0; /* Index of the next character from fmt */ |
596 | size_t j = 0; /* Index to the first not printed nonformating character */ |
596 | size_t j = 0; /* Index to the first not printed nonformating character */ |
597 | 597 | ||
598 | count_t counter = 0; /* Number of characters printed */ |
598 | size_t counter = 0; /* Number of characters printed */ |
599 | int retval; /* Return values from nested functions */ |
599 | int retval; /* Return values from nested functions */ |
600 | 600 | ||
601 | while (true) { |
601 | while (true) { |
602 | i = nxt; |
602 | i = nxt; |
603 | wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT); |
603 | wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT); |