MCPcopy Create free account
hub / github.com/HelenOS/helenos / print_char

Function print_char

kernel/generic/src/printf/printf_core.c:204–231  ·  view source on GitHub ↗

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. * */

Source from the content-addressed store, hash-verified

202 *
203 */
204static 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 *

Callers 1

printf_coreFunction · 0.70

Calls 1

printf_putcharFunction · 0.70

Tested by

no test coverage detected