Print one formatted wide 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. * */
| 240 | * |
| 241 | */ |
| 242 | static int print_wchar(const char32_t ch, int width, uint32_t flags, printf_spec_t *ps) |
| 243 | { |
| 244 | size_t counter = 0; |
| 245 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
| 246 | while (--width > 0) { |
| 247 | /* |
| 248 | * One space is consumed by the character itself, hence |
| 249 | * the predecrement. |
| 250 | */ |
| 251 | if (printf_putchar(' ', ps) > 0) |
| 252 | counter++; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | if (printf_putuchar(ch, ps) > 0) |
| 257 | counter++; |
| 258 | |
| 259 | while (--width > 0) { |
| 260 | /* |
| 261 | * One space is consumed by the character itself, hence |
| 262 | * the predecrement. |
| 263 | */ |
| 264 | if (printf_putchar(' ', ps) > 0) |
| 265 | counter++; |
| 266 | } |
| 267 | |
| 268 | return (int) (counter); |
| 269 | } |
| 270 | |
| 271 | /** Print string. |
| 272 | * |
no test coverage detected