Subversion Repositories HelenOS

Rev

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

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