Subversion Repositories HelenOS

Rev

Rev 4234 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4234 Rev 4245
Line 246... Line 246...
246
 * @param flags     Flags that modify the way the string is printed.
246
 * @param flags     Flags that modify the way the string is printed.
247
 *
247
 *
248
 * @return Number of characters printed, negative value on failure.
248
 * @return Number of characters printed, negative value on failure.
249
 */
249
 */
250
static int print_str(char *str, int width, unsigned int precision,
250
static int print_str(char *str, int width, unsigned int precision,
251
    uint32_t flags, printf_spec_t *ps)
251
    uint32_t flags, printf_spec_t *ps)
252
{
252
{
253
    if (str == NULL)
253
    if (str == NULL)
254
        return printf_putstr(nullstr, ps);
254
        return printf_putstr(nullstr, ps);
255
 
255
 
256
    /* Print leading spaces. */
256
    /* Print leading spaces. */
Line 294... Line 294...
294
 * @param flags     Flags that modify the way the string is printed.
294
 * @param flags     Flags that modify the way the string is printed.
295
 *
295
 *
296
 * @return Number of wide characters printed, negative value on failure.
296
 * @return Number of wide characters printed, negative value on failure.
297
 */
297
 */
298
static int print_wstr(wchar_t *str, int width, unsigned int precision,
298
static int print_wstr(wchar_t *str, int width, unsigned int precision,
299
    uint32_t flags, printf_spec_t *ps)
299
    uint32_t flags, printf_spec_t *ps)
300
{
300
{
301
    if (str == NULL)
301
    if (str == NULL)
302
        return printf_putstr(nullstr, ps);
302
        return printf_putstr(nullstr, ps);
-
 
303
   
-
 
304
    if (*str == U_BOM)
-
 
305
        str++;
303
 
306
   
304
    /* Print leading spaces. */
307
    /* Print leading spaces. */
305
    size_t strw = wstr_length(str);
308
    size_t strw = wstr_length(str);
306
    if (precision == 0)
309
    if (precision == 0)
307
        precision = strw;
310
        precision = strw;
308
 
311
   
309
    /* Left padding */
312
    /* Left padding */
310
    count_t counter = 0;
313
    count_t counter = 0;
311
    width -= precision;
314
    width -= precision;
312
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
315
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
313
        while (width-- > 0) {
316
        while (width-- > 0) {
314
            if (printf_putchar(' ', ps) == 1)
317
            if (printf_putchar(' ', ps) == 1)
315
                counter++;
318
                counter++;
316
        }
319
        }
317
    }
320
    }
318
 
321
   
319
    /* Part of @a wstr fitting into the alloted space. */
322
    /* Part of @a wstr fitting into the alloted space. */
320
    int retval;
323
    int retval;
321
    size_t size = wstr_lsize(str, precision);
324
    size_t size = wstr_lsize(str, precision);
322
    if ((retval = printf_wputnchars(str, size, ps)) < 0)
325
    if ((retval = printf_wputnchars(str, size, ps)) < 0)
323
        return -counter;
326
        return -counter;
324
 
327
   
325
    counter += retval;
328
    counter += retval;
326
 
329
   
327
    /* Right padding */
330
    /* Right padding */
328
    while (width-- > 0) {
331
    while (width-- > 0) {
329
        if (printf_putchar(' ', ps) == 1)
332
        if (printf_putchar(' ', ps) == 1)
330
            counter++;
333
            counter++;
331
    }
334
    }