Rev 4348 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4348 | Rev 4691 | ||
---|---|---|---|
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 299... | Line 299... | ||
299 | uint32_t flags, printf_spec_t *ps) |
299 | uint32_t flags, printf_spec_t *ps) |
300 | { |
300 | { |
301 | if (str == NULL) |
301 | if (str == NULL) |
302 | return printf_putstr(nullstr, ps); |
302 | return printf_putstr(nullstr, ps); |
303 | 303 | ||
304 | if (*str == U_BOM) |
- | |
305 | str++; |
- | |
306 | - | ||
307 | /* Print leading spaces. */ |
304 | /* Print leading spaces. */ |
308 | size_t strw = wstr_length(str); |
305 | size_t strw = wstr_length(str); |
309 | if (precision == 0) |
306 | if (precision == 0) |
310 | precision = strw; |
307 | precision = strw; |
311 | 308 | ||
312 | /* Left padding */ |
309 | /* Left padding */ |
313 | count_t counter = 0; |
310 | size_t counter = 0; |
314 | width -= precision; |
311 | width -= precision; |
315 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
312 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
316 | while (width-- > 0) { |
313 | while (width-- > 0) { |
317 | if (printf_putchar(' ', ps) == 1) |
314 | if (printf_putchar(' ', ps) == 1) |
318 | counter++; |
315 | counter++; |
Line 430... | Line 427... | ||
430 | /* Print the whole number, not only a part */ |
427 | /* Print the whole number, not only a part */ |
431 | precision = number_size; |
428 | precision = number_size; |
432 | } |
429 | } |
433 | 430 | ||
434 | width -= precision + size - number_size; |
431 | width -= precision + size - number_size; |
435 | count_t counter = 0; |
432 | size_t counter = 0; |
436 | 433 | ||
437 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
434 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
438 | while (width-- > 0) { |
435 | while (width-- > 0) { |
439 | if (printf_putchar(' ', ps) == 1) |
436 | if (printf_putchar(' ', ps) == 1) |
440 | counter++; |
437 | counter++; |
Line 593... | Line 590... | ||
593 | { |
590 | { |
594 | size_t i; /* Index of the currently processed character from fmt */ |
591 | size_t i; /* Index of the currently processed character from fmt */ |
595 | size_t nxt = 0; /* Index of the next character from fmt */ |
592 | size_t nxt = 0; /* Index of the next character from fmt */ |
596 | size_t j = 0; /* Index to the first not printed nonformating character */ |
593 | size_t j = 0; /* Index to the first not printed nonformating character */ |
597 | 594 | ||
598 | count_t counter = 0; /* Number of characters printed */ |
595 | size_t counter = 0; /* Number of characters printed */ |
599 | int retval; /* Return values from nested functions */ |
596 | int retval; /* Return values from nested functions */ |
600 | 597 | ||
601 | while (true) { |
598 | while (true) { |
602 | i = nxt; |
599 | i = nxt; |
603 | wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT); |
600 | wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT); |