* Print one formatted character. * * @param c Character to print. * @param width Width modifier. * @param flags Flags that change the way the character is printed. * @param ps Output methods spec for different printf clones. * @return Number of characters printed, negative value on failure. */
| 144 | * @return Number of characters printed, negative value on failure. |
| 145 | */ |
| 146 | static int print_char(char c, int width, uint64_t flags, struct printf_spec *ps) |
| 147 | { |
| 148 | int retval; |
| 149 | int counter = 1; |
| 150 | |
| 151 | if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) { |
| 152 | if ((retval = print_spaces(width - 1, ps)) < 0) |
| 153 | return retval; |
| 154 | else |
| 155 | counter += retval; |
| 156 | } |
| 157 | |
| 158 | if ((retval = printf_putchar(c, ps)) < 0) |
| 159 | return retval; |
| 160 | |
| 161 | if (flags & __PRINTF_FLAG_LEFTALIGNED) { |
| 162 | if ((retval = print_spaces(width - 1, ps)) < 0) |
| 163 | return retval; |
| 164 | else |
| 165 | counter += retval; |
| 166 | } |
| 167 | |
| 168 | return counter; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Print string. |
no test coverage detected