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

Function print_wstr

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

Print wide string. * * @param str Wide string to be printed. * @param width Width modifier. * @param precision Precision modifier. * @param flags Flags that modify the way the string is printed. * * @return Number of wide characters printed, negative value on failure. */

Source from the content-addressed store, hash-verified

326 * @return Number of wide characters printed, negative value on failure.
327 */
328static int print_wstr(char32_t *str, int width, unsigned int precision,
329 uint32_t flags, printf_spec_t *ps)
330{
331 if (str == NULL)
332 return printf_putstr(nullstr, ps);
333
334 /* Print leading spaces. */
335 size_t strw = wstr_length(str);
336 if ((precision == 0) || (precision > strw))
337 precision = strw;
338
339 /* Left padding */
340 size_t counter = 0;
341 width -= precision;
342 if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
343 while (width-- > 0) {
344 if (printf_putchar(' ', ps) == 1)
345 counter++;
346 }
347 }
348
349 /* Part of @a wstr fitting into the alloted space. */
350 int retval;
351 size_t size = wstr_lsize(str, precision);
352 if ((retval = printf_wputnchars(str, size, ps)) < 0)
353 return -counter;
354
355 counter += retval;
356
357 /* Right padding */
358 while (width-- > 0) {
359 if (printf_putchar(' ', ps) == 1)
360 counter++;
361 }
362
363 return ((int) counter);
364}
365
366/** Print a number in a given base.
367 *

Callers 1

printf_coreFunction · 0.70

Calls 5

printf_putstrFunction · 0.70
printf_putcharFunction · 0.70
printf_wputncharsFunction · 0.70
wstr_lengthFunction · 0.50
wstr_lsizeFunction · 0.50

Tested by

no test coverage detected