Print one formatted ASCII character. * * @param ch Character to print. * @param width Width modifier. * @param flags Flags that change the way the character is printed. * * @return Number of characters printed, negative value on failure. * */
| 202 | * |
| 203 | */ |
| 204 | static int print_char(const char ch, int width, uint32_t flags, printf_spec_t *ps) |
| 205 | { |
| 206 | size_t counter = 0; |
| 207 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
| 208 | while (--width > 0) { |
| 209 | /* |
| 210 | * One space is consumed by the character itself, hence |
| 211 | * the predecrement. |
| 212 | */ |
| 213 | if (printf_putchar(' ', ps) > 0) |
| 214 | counter++; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if (printf_putchar(ch, ps) > 0) |
| 219 | counter++; |
| 220 | |
| 221 | while (--width > 0) { |
| 222 | /* |
| 223 | * One space is consumed by the character itself, hence |
| 224 | * the predecrement. |
| 225 | */ |
| 226 | if (printf_putchar(' ', ps) > 0) |
| 227 | counter++; |
| 228 | } |
| 229 | |
| 230 | return (int) (counter); |
| 231 | } |
| 232 | |
| 233 | /** Print one formatted wide character. |
| 234 | * |
no test coverage detected