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