Subversion Repositories HelenOS

Rev

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

Rev 4347 Rev 4348
Line 79... Line 79...
79
} qualifier_t;
79
} qualifier_t;
80
 
80
 
81
static char nullstr[] = "(NULL)";
81
static char nullstr[] = "(NULL)";
82
static char digits_small[] = "0123456789abcdef";
82
static char digits_small[] = "0123456789abcdef";
83
static char digits_big[] = "0123456789ABCDEF";
83
static char digits_big[] = "0123456789ABCDEF";
-
 
84
static char invalch = U_SPECIAL;
84
 
85
 
85
/** Print one or more UTF-8 characters without adding newline.
86
/** Print one or more characters without adding newline.
86
 *
87
 *
87
 * @param buf  Buffer holding UTF-8 characters with size of
88
 * @param buf  Buffer holding characters with size of
88
 *             at least size bytes. NULL is not allowed!
89
 *             at least size bytes. NULL is not allowed!
89
 * @param size Size of the buffer in bytes.
90
 * @param size Size of the buffer in bytes.
90
 * @param ps   Output method and its data.
91
 * @param ps   Output method and its data.
91
 *
92
 *
92
 * @return Number of UTF-8 characters printed.
93
 * @return Number of characters printed.
93
 *
94
 *
94
 */
95
 */
95
static int printf_putnchars_utf8(const char *buf, size_t size,
96
static int printf_putnchars(const char *buf, size_t size,
96
    printf_spec_t *ps)
97
    printf_spec_t *ps)
97
{
98
{
98
    return ps->write_utf8((void *) buf, size, ps->data);
99
    return ps->str_write((void *) buf, size, ps->data);
99
}
100
}
100
 
101
 
101
/** Print one or more UTF-32 characters without adding newline.
102
/** Print one or more wide characters without adding newline.
102
 *
103
 *
103
 * @param buf  Buffer holding UTF-32 characters with size of
104
 * @param buf  Buffer holding wide characters with size of
104
 *             at least size bytes. NULL is not allowed!
105
 *             at least size bytes. NULL is not allowed!
105
 * @param size Size of the buffer in bytes.
106
 * @param size Size of the buffer in bytes.
106
 * @param ps   Output method and its data.
107
 * @param ps   Output method and its data.
107
 *
108
 *
108
 * @return Number of UTF-32 characters printed.
109
 * @return Number of wide characters printed.
109
 *
110
 *
110
 */
111
 */
111
static int printf_putnchars_utf32(const wchar_t *buf, size_t size,
112
static int printf_wputnchars(const wchar_t *buf, size_t size,
112
    printf_spec_t *ps)
113
    printf_spec_t *ps)
113
{
114
{
114
    return ps->write_utf32((void *) buf, size, ps->data);
115
    return ps->wstr_write((void *) buf, size, ps->data);
115
}
116
}
116
 
117
 
117
/** Print UTF-8 string without adding a newline.
118
/** Print string without adding a newline.
118
 *
119
 *
119
 * @param str UTF-8 string to print.
120
 * @param str String to print.
120
 * @param ps  Write function specification and support data.
121
 * @param ps  Write function specification and support data.
121
 *
122
 *
122
 * @return Number of UTF-8 characters printed.
123
 * @return Number of characters printed.
123
 *
124
 *
124
 */
125
 */
125
static int printf_putstr(const char *str, printf_spec_t *ps)
126
static int printf_putstr(const char *str, printf_spec_t *ps)
126
{
127
{
127
    if (str == NULL)
128
    if (str == NULL)
128
        return printf_putnchars_utf8(nullstr, strlen(nullstr), ps);
129
        return printf_putnchars(nullstr, str_size(nullstr), ps);
129
   
130
   
130
    return ps->write_utf8((void *) str, strlen(str), ps->data);
131
    return ps->str_write((void *) str, str_size(str), ps->data);
131
}
132
}
132
 
133
 
133
/** Print one ASCII character.
134
/** Print one ASCII character.
134
 *
135
 *
135
 * @param c  ASCII character to be printed.
136
 * @param c  ASCII character to be printed.
Line 139... Line 140...
139
 *
140
 *
140
 */
141
 */
141
static int printf_putchar(const char ch, printf_spec_t *ps)
142
static int printf_putchar(const char ch, printf_spec_t *ps)
142
{
143
{
143
    if (!ascii_check(ch))
144
    if (!ascii_check(ch))
144
        return ps->write_utf8((void *) &invalch, 1, ps->data);
145
        return ps->str_write((void *) &invalch, 1, ps->data);
145
   
146
   
146
    return ps->write_utf8(&ch, 1, ps->data);
147
    return ps->str_write(&ch, 1, ps->data);
147
}
148
}
148
 
149
 
149
/** Print one UTF-32 character.
150
/** Print one wide character.
150
 *
151
 *
151
 * @param c  UTF-32 character to be printed.
152
 * @param c  Wide character to be printed.
152
 * @param ps Output method.
153
 * @param ps Output method.
153
 *
154
 *
154
 * @return Number of characters printed.
155
 * @return Number of characters printed.
155
 *
156
 *
156
 */
157
 */
157
static int printf_putwchar(const wchar_t ch, printf_spec_t *ps)
158
static int printf_putwchar(const wchar_t ch, printf_spec_t *ps)
158
{
159
{
159
    if (!unicode_check(ch))
160
    if (!chr_check(ch))
160
        return ps->write_utf8((void *) &invalch, 1, ps->data);
161
        return ps->str_write((void *) &invalch, 1, ps->data);
161
   
162
   
162
    return ps->write_utf32(&ch, sizeof(wchar_t), ps->data);
163
    return ps->wstr_write(&ch, sizeof(wchar_t), ps->data);
163
}
164
}
164
 
165
 
165
/** Print one formatted ASCII character.
166
/** Print one formatted ASCII character.
166
 *
167
 *
167
 * @param ch    Character to print.
168
 * @param ch    Character to print.
Line 198... Line 199...
198
    }
199
    }
199
   
200
   
200
    return (int) (counter + 1);
201
    return (int) (counter + 1);
201
}
202
}
202
 
203
 
203
/** Print one formatted UTF-32 character.
204
/** Print one formatted wide character.
204
 *
205
 *
205
 * @param ch    Character to print.
206
 * @param ch    Character to print.
206
 * @param width Width modifier.
207
 * @param width Width modifier.
207
 * @param flags Flags that change the way the character is printed.
208
 * @param flags Flags that change the way the character is printed.
208
 *
209
 *
Line 236... Line 237...
236
    }
237
    }
237
   
238
   
238
    return (int) (counter + 1);
239
    return (int) (counter + 1);
239
}
240
}
240
 
241
 
241
/** Print UTF-8 string.
242
/** Print string.
242
 *
243
 *
243
 * @param str       UTF-8 string to be printed.
244
 * @param str       String to be printed.
244
 * @param width     Width modifier.
245
 * @param width     Width modifier.
245
 * @param precision Precision modifier.
246
 * @param precision Precision modifier.
246
 * @param flags     Flags that modify the way the string is printed.
247
 * @param flags     Flags that modify the way the string is printed.
247
 *
248
 *
248
 * @return Number of UTF-8 characters printed, negative value on failure.
249
 * @return Number of characters printed, negative value on failure.
249
 */
250
 */
250
static int print_utf8(char *str, int width, unsigned int precision,
251
static int print_str(char *str, int width, unsigned int precision,
251
    uint32_t flags, printf_spec_t *ps)
252
    uint32_t flags, printf_spec_t *ps)
252
{
253
{
253
    if (str == NULL)
254
    if (str == NULL)
254
        return printf_putstr(nullstr, ps);
255
        return printf_putstr(nullstr, ps);
255
   
256
 
256
    /* Print leading spaces */
257
    /* Print leading spaces. */
257
    size_t size = strlen_utf8(str);
258
    count_t strw = str_length(str);
258
    if (precision == 0)
259
    if (precision == 0)
259
        precision = size;
260
        precision = strw;
260
   
261
 
-
 
262
    /* Left padding */
261
    count_t counter = 0;
263
    count_t counter = 0;
262
    width -= precision;
264
    width -= precision;
263
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
265
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
264
        while (width-- > 0) {
266
        while (width-- > 0) {
265
            if (printf_putchar(' ', ps) == 1)
267
            if (printf_putchar(' ', ps) == 1)
266
                counter++;
268
                counter++;
267
        }
269
        }
268
    }
270
    }
269
   
271
 
-
 
272
    /* Part of @a str fitting into the alloted space. */
270
    int retval;
273
    int retval;
271
    size_t bytes = utf8_count_bytes(str, min(size, precision));
274
    size_t size = str_lsize(str, precision);
272
    if ((retval = printf_putnchars_utf8(str, bytes, ps)) < 0)
275
    if ((retval = printf_putnchars(str, size, ps)) < 0)
273
        return -counter;
276
        return -counter;
274
   
277
 
275
    counter += retval;
278
    counter += retval;
276
   
279
 
-
 
280
    /* Right padding */
277
    while (width-- > 0) {
281
    while (width-- > 0) {
278
        if (printf_putchar(' ', ps) == 1)
282
        if (printf_putchar(' ', ps) == 1)
279
            counter++;
283
            counter++;
280
    }
284
    }
281
   
285
 
282
    return ((int) counter);
286
    return ((int) counter);
-
 
287
 
283
}
288
}
284
 
289
 
285
/** Print UTF-32 string.
290
/** Print wide string.
286
 *
291
 *
287
 * @param str       UTF-32 string to be printed.
292
 * @param str       Wide string to be printed.
288
 * @param width     Width modifier.
293
 * @param width     Width modifier.
289
 * @param precision Precision modifier.
294
 * @param precision Precision modifier.
290
 * @param flags     Flags that modify the way the string is printed.
295
 * @param flags     Flags that modify the way the string is printed.
291
 *
296
 *
292
 * @return Number of UTF-32 characters printed, negative value on failure.
297
 * @return Number of wide characters printed, negative value on failure.
293
 */
298
 */
294
static int print_utf32(wchar_t *str, int width, unsigned int precision,
299
static int print_wstr(wchar_t *str, int width, unsigned int precision,
295
    uint32_t flags, printf_spec_t *ps)
300
    uint32_t flags, printf_spec_t *ps)
296
{
301
{
297
    if (str == NULL)
302
    if (str == NULL)
298
        return printf_putstr(nullstr, ps);
303
        return printf_putstr(nullstr, ps);
299
   
304
   
-
 
305
    if (*str == U_BOM)
-
 
306
        str++;
-
 
307
   
300
    /* Print leading spaces */
308
    /* Print leading spaces. */
301
    size_t size = strlen_utf32(str);
309
    size_t strw = wstr_length(str);
302
    if (precision == 0)
310
    if (precision == 0)
303
        precision = size;
311
        precision = strw;
304
   
312
   
-
 
313
    /* Left padding */
305
    count_t counter = 0;
314
    count_t counter = 0;
306
    width -= precision;
315
    width -= precision;
307
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
316
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
308
        while (width-- > 0) {
317
        while (width-- > 0) {
309
            if (printf_putchar(' ', ps) == 1)
318
            if (printf_putchar(' ', ps) == 1)
310
                counter++;
319
                counter++;
311
        }
320
        }
312
    }
321
    }
313
   
322
   
-
 
323
    /* Part of @a wstr fitting into the alloted space. */
314
    int retval;
324
    int retval;
315
    size_t bytes = min(size, precision) * sizeof(wchar_t);
325
    size_t size = wstr_lsize(str, precision);
316
    if ((retval = printf_putnchars_utf32(str, bytes, ps)) < 0)
326
    if ((retval = printf_wputnchars(str, size, ps)) < 0)
317
        return -counter;
327
        return -counter;
318
   
328
   
319
    counter += retval;
329
    counter += retval;
320
   
330
   
-
 
331
    /* Right padding */
321
    while (width-- > 0) {
332
    while (width-- > 0) {
322
        if (printf_putchar(' ', ps) == 1)
333
        if (printf_putchar(' ', ps) == 1)
323
            counter++;
334
            counter++;
324
    }
335
    }
325
   
336
 
326
    return ((int) counter);
337
    return ((int) counter);
327
}
338
}
328
 
339
 
329
/** Print a number in a given base.
340
/** Print a number in a given base.
330
 *
341
 *
Line 535... Line 546...
535
 * TYPE:@n
546
 * TYPE:@n
536
 *  - "hh" Signed or unsigned char.@n
547
 *  - "hh" Signed or unsigned char.@n
537
 *  - "h"  Signed or unsigned short.@n
548
 *  - "h"  Signed or unsigned short.@n
538
 *  - ""   Signed or unsigned int (default value).@n
549
 *  - ""   Signed or unsigned int (default value).@n
539
 *  - "l"  Signed or unsigned long int.@n
550
 *  - "l"  Signed or unsigned long int.@n
540
 *         If conversion is "c", the character is wchar_t (UTF-32).@n
551
 *         If conversion is "c", the character is wchar_t (wide character).@n
541
 *         If conversion is "s", the string is wchar_t * (UTF-32).@n
552
 *         If conversion is "s", the string is wchar_t * (wide string).@n
542
 *  - "ll" Signed or unsigned long long int.@n
553
 *  - "ll" Signed or unsigned long long int.@n
543
 *
554
 *
544
 * CONVERSION:@n
555
 * CONVERSION:@n
545
 *  - % Print percentile character itself.
556
 *  - % Print percentile character itself.
546
 *
557
 *
547
 *  - c Print single character. The character is expected to be plain
558
 *  - c Print single character. The character is expected to be plain
548
 *      ASCII (e.g. only values 0 .. 127 are valid).@n
559
 *      ASCII (e.g. only values 0 .. 127 are valid).@n
549
 *      If type is "l", then the character is expected to be UTF-32
560
 *      If type is "l", then the character is expected to be wide character
550
 *      (e.g. values 0 .. 0x10ffff are valid).
561
 *      (e.g. values 0 .. 0x10ffff are valid).
551
 *
562
 *
552
 *  - s Print zero terminated string. If a NULL value is passed as
563
 *  - s Print zero terminated string. If a NULL value is passed as
553
 *      value, "(NULL)" is printed instead.@n
564
 *      value, "(NULL)" is printed instead.@n
554
 *      The string is expected to be correctly encoded UTF-8 (or plain
-
 
555
 *      ASCII, which is a subset of UTF-8).@n
-
 
556
 *      If type is "l", then the string is expected to be correctly
565
 *      If type is "l", then the string is expected to be wide string.
557
 *      encoded UTF-32.
-
 
558
 *
566
 *
559
 *  - P, p Print value of a pointer. Void * value is expected and it is
567
 *  - P, p Print value of a pointer. Void * value is expected and it is
560
 *         printed in hexadecimal notation with prefix (as with \%#X / \%#x
568
 *         printed in hexadecimal notation with prefix (as with \%#X / \%#x
561
 *         for 32-bit or \%#X / \%#x for 64-bit long pointers).
569
 *         for 32-bit or \%#X / \%#x for 64-bit long pointers).
562
 *
570
 *
Line 572... Line 580...
572
 *  - u Print unsigned decimal number.
580
 *  - u Print unsigned decimal number.
573
 *
581
 *
574
 *  - X, x Print hexadecimal number with upper- or lower-case. Prefix is
582
 *  - X, x Print hexadecimal number with upper- or lower-case. Prefix is
575
 *         not printed by default.
583
 *         not printed by default.
576
 *
584
 *
577
 * All other characters from fmt except the formatting directives are printed in
585
 * All other characters from fmt except the formatting directives are printed
578
 * verbatim.
586
 * verbatim.
579
 *
587
 *
580
 * @param fmt Formatting NULL terminated string (UTF-8 or plain ASCII).
588
 * @param fmt Format NULL-terminated string.
581
 *
589
 *
582
 * @return Number of UTF-8 characters printed, negative value on failure.
590
 * @return Number of characters printed, negative value on failure.
583
 *
591
 *
584
 */
592
 */
585
int printf_core(const char *fmt, printf_spec_t *ps, va_list ap)
593
int printf_core(const char *fmt, printf_spec_t *ps, va_list ap)
586
{
594
{
587
    index_t i = 0;  /* Index of the currently processed character from fmt */
595
    size_t i;        /* Index of the currently processed character from fmt */
-
 
596
    size_t nxt = 0;  /* Index of the next character from fmt */
588
    index_t j = 0;  /* Index to the first not printed nonformating character */
597
    size_t j = 0;    /* Index to the first not printed nonformating character */
589
   
598
   
590
    wchar_t uc;           /* Current UTF-32 character decoded from fmt */
-
 
591
    count_t counter = 0;  /* Number of UTF-8 characters printed */
599
    count_t counter = 0;  /* Number of characters printed */
592
    int retval;           /* Return values from nested functions */
600
    int retval;           /* Return values from nested functions */
593
   
601
   
-
 
602
    while (true) {
-
 
603
        i = nxt;
594
    while ((uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT)) != 0) {
604
        wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
-
 
605
       
-
 
606
        if (uc == 0)
-
 
607
            break;
-
 
608
       
595
        /* Control character */
609
        /* Control character */
596
        if (uc == '%') {
610
        if (uc == '%') {
597
            /* Print common characters if any processed */
611
            /* Print common characters if any processed */
598
            if (i > j) {
612
            if (i > j) {
599
                if ((retval = printf_putnchars_utf8(&fmt[j], i - j, ps)) < 0) {
613
                if ((retval = printf_putnchars(&fmt[j], i - j, ps)) < 0) {
600
                    /* Error */
614
                    /* Error */
601
                    counter = -counter;
615
                    counter = -counter;
602
                    goto out;
616
                    goto out;
603
                }
617
                }
604
                counter += retval;
618
                counter += retval;
Line 609... Line 623...
609
            /* Parse modifiers */
623
            /* Parse modifiers */
610
            uint32_t flags = 0;
624
            uint32_t flags = 0;
611
            bool end = false;
625
            bool end = false;
612
           
626
           
613
            do {
627
            do {
614
                i++;
628
                i = nxt;
615
                uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
629
                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
616
                switch (uc) {
630
                switch (uc) {
617
                case '#':
631
                case '#':
618
                    flags |= __PRINTF_FLAG_PREFIX;
632
                    flags |= __PRINTF_FLAG_PREFIX;
619
                    break;
633
                    break;
620
                case '-':
634
                case '-':
Line 635... Line 649...
635
            } while (!end);
649
            } while (!end);
636
           
650
           
637
            /* Width & '*' operator */
651
            /* Width & '*' operator */
638
            int width = 0;
652
            int width = 0;
639
            if (isdigit(uc)) {
653
            if (isdigit(uc)) {
640
                while ((uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT)) != 0) {
-
 
641
                    if (!isdigit(uc))
654
                while (true) {
642
                        break;
-
 
643
                   
-
 
644
                    width *= 10;
655
                    width *= 10;
645
                    width += uc - '0';
656
                    width += uc - '0';
646
                    i++;
657
                   
-
 
658
                    i = nxt;
-
 
659
                    uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
-
 
660
                    if (uc == 0)
-
 
661
                        break;
-
 
662
                    if (!isdigit(uc))
-
 
663
                        break;
647
                }
664
                }
648
            } else if (uc == '*') {
665
            } else if (uc == '*') {
649
                /* Get width value from argument list */
666
                /* Get width value from argument list */
650
                i++;
667
                i = nxt;
651
                uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
668
                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
652
                width = (int) va_arg(ap, int);
669
                width = (int) va_arg(ap, int);
653
                if (width < 0) {
670
                if (width < 0) {
654
                    /* Negative width sets '-' flag */
671
                    /* Negative width sets '-' flag */
655
                    width *= -1;
672
                    width *= -1;
656
                    flags |= __PRINTF_FLAG_LEFTALIGNED;
673
                    flags |= __PRINTF_FLAG_LEFTALIGNED;
Line 658... Line 675...
658
            }
675
            }
659
           
676
           
660
            /* Precision and '*' operator */
677
            /* Precision and '*' operator */
661
            int precision = 0;
678
            int precision = 0;
662
            if (uc == '.') {
679
            if (uc == '.') {
663
                i++;
680
                i = nxt;
664
                uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
681
                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
665
                if (isdigit(uc)) {
682
                if (isdigit(uc)) {
666
                    while ((uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT)) != 0) {
-
 
667
                        if (!isdigit(uc))
683
                    while (true) {
668
                            break;
-
 
669
                       
-
 
670
                        precision *= 10;
684
                        precision *= 10;
671
                        precision += uc - '0';
685
                        precision += uc - '0';
672
                        i++;
686
                       
-
 
687
                        i = nxt;
-
 
688
                        uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
-
 
689
                        if (uc == 0)
-
 
690
                            break;
-
 
691
                        if (!isdigit(uc))
-
 
692
                            break;
673
                    }
693
                    }
674
                } else if (fmt[i] == '*') {
694
                } else if (uc == '*') {
675
                    /* Get precision value from the argument list */
695
                    /* Get precision value from the argument list */
676
                    i++;
696
                    i = nxt;
677
                    uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
697
                    uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
678
                    precision = (int) va_arg(ap, int);
698
                    precision = (int) va_arg(ap, int);
679
                    if (precision < 0) {
699
                    if (precision < 0) {
680
                        /* Ignore negative precision */
700
                        /* Ignore negative precision */
681
                        precision = 0;
701
                        precision = 0;
682
                    }
702
                    }
Line 690... Line 710...
690
             *        t ptrdiff_t - ISO C 99
710
             *        t ptrdiff_t - ISO C 99
691
             */
711
             */
692
            case 'h':
712
            case 'h':
693
                /* Char or short */
713
                /* Char or short */
694
                qualifier = PrintfQualifierShort;
714
                qualifier = PrintfQualifierShort;
695
                i++;
715
                i = nxt;
696
                uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
716
                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
697
                if (uc == 'h') {
717
                if (uc == 'h') {
698
                    i++;
718
                    i = nxt;
699
                    uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
719
                    uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
700
                    qualifier = PrintfQualifierByte;
720
                    qualifier = PrintfQualifierByte;
701
                }
721
                }
702
                break;
722
                break;
703
            case 'l':
723
            case 'l':
704
                /* Long or long long */
724
                /* Long or long long */
705
                qualifier = PrintfQualifierLong;
725
                qualifier = PrintfQualifierLong;
706
                i++;
726
                i = nxt;
707
                uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
727
                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
708
                if (uc == 'l') {
728
                if (uc == 'l') {
709
                    i++;
729
                    i = nxt;
710
                    uc = utf8_decode(fmt, &i, UTF8_NO_LIMIT);
730
                    uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
711
                    qualifier = PrintfQualifierLongLong;
731
                    qualifier = PrintfQualifierLongLong;
712
                }
732
                }
713
                break;
733
                break;
714
            default:
734
            default:
715
                /* Default type */
735
                /* Default type */
Line 722... Line 742...
722
            /*
742
            /*
723
             * String and character conversions.
743
             * String and character conversions.
724
             */
744
             */
725
            case 's':
745
            case 's':
726
                if (qualifier == PrintfQualifierLong)
746
                if (qualifier == PrintfQualifierLong)
727
                    retval = print_utf32(va_arg(ap, wchar_t *), width, precision, flags, ps);
747
                    retval = print_wstr(va_arg(ap, wchar_t *), width, precision, flags, ps);
728
                else
748
                else
729
                    retval = print_utf8(va_arg(ap, char *), width, precision, flags, ps);
749
                    retval = print_str(va_arg(ap, char *), width, precision, flags, ps);
730
               
750
               
731
                if (retval < 0) {
751
                if (retval < 0) {
732
                    counter = -counter;
752
                    counter = -counter;
733
                    goto out;
753
                    goto out;
734
                }
754
                }
735
               
755
               
736
                counter += retval;
756
                counter += retval;
737
                j = i + 1;
757
                j = nxt;
738
                goto next_char;
758
                goto next_char;
739
            case 'c':
759
            case 'c':
740
                if (qualifier == PrintfQualifierLong)
760
                if (qualifier == PrintfQualifierLong)
741
                    retval = print_wchar(va_arg(ap, wchar_t), width, flags, ps);
761
                    retval = print_wchar(va_arg(ap, wchar_t), width, flags, ps);
742
                else
762
                else
Line 746... Line 766...
746
                    counter = -counter;
766
                    counter = -counter;
747
                    goto out;
767
                    goto out;
748
                };
768
                };
749
               
769
               
750
                counter += retval;
770
                counter += retval;
751
                j = i + 1;
771
                j = nxt;
752
                goto next_char;
772
                goto next_char;
753
           
773
           
754
            /*
774
            /*
755
             * Integer values
775
             * Integer values
756
             */
776
             */
Line 850... Line 870...
850
                counter = -counter;
870
                counter = -counter;
851
                goto out;
871
                goto out;
852
            }
872
            }
853
           
873
           
854
            counter += retval;
874
            counter += retval;
855
            j = i + 1;
875
            j = nxt;
856
        }
876
        }
857
next_char:
877
next_char:
858
       
878
        ;
859
        i++;
-
 
860
    }
879
    }
861
   
880
   
862
    if (i > j) {
881
    if (i > j) {
863
        if ((retval = printf_putnchars_utf8(&fmt[j], i - j, ps)) < 0) {
882
        if ((retval = printf_putnchars(&fmt[j], i - j, ps)) < 0) {
864
            /* Error */
883
            /* Error */
865
            counter = -counter;
884
            counter = -counter;
866
            goto out;
885
            goto out;
867
        }
886
        }
868
        counter += retval;
887
        counter += retval;