Subversion Repositories HelenOS

Rev

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

Rev 4348 Rev 4691
Line 172... Line 172...
172
 * @return Number of characters printed, negative value on failure.
172
 * @return Number of characters printed, negative value on failure.
173
 *
173
 *
174
 */
174
 */
175
static int print_char(const char ch, int width, uint32_t flags, printf_spec_t *ps)
175
static int print_char(const char ch, int width, uint32_t flags, printf_spec_t *ps)
176
{
176
{
177
    count_t counter = 0;
177
    size_t counter = 0;
178
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
178
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
179
        while (--width > 0) {
179
        while (--width > 0) {
180
            /*
180
            /*
181
             * One space is consumed by the character itself, hence
181
             * One space is consumed by the character itself, hence
182
             * the predecrement.
182
             * the predecrement.
Line 210... Line 210...
210
 * @return Number of characters printed, negative value on failure.
210
 * @return Number of characters printed, negative value on failure.
211
 *
211
 *
212
 */
212
 */
213
static int print_wchar(const wchar_t ch, int width, uint32_t flags, printf_spec_t *ps)
213
static int print_wchar(const wchar_t ch, int width, uint32_t flags, printf_spec_t *ps)
214
{
214
{
215
    count_t counter = 0;
215
    size_t counter = 0;
216
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
216
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
217
        while (--width > 0) {
217
        while (--width > 0) {
218
            /*
218
            /*
219
             * One space is consumed by the character itself, hence
219
             * One space is consumed by the character itself, hence
220
             * the predecrement.
220
             * the predecrement.
Line 253... Line 253...
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. */
258
    count_t strw = str_length(str);
258
    size_t strw = str_length(str);
259
    if (precision == 0)
259
    if (precision == 0)
260
        precision = strw;
260
        precision = strw;
261
 
261
 
262
    /* Left padding */
262
    /* Left padding */
263
    count_t counter = 0;
263
    size_t counter = 0;
264
    width -= precision;
264
    width -= precision;
265
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
265
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
266
        while (width-- > 0) {
266
        while (width-- > 0) {
267
            if (printf_putchar(' ', ps) == 1)
267
            if (printf_putchar(' ', ps) == 1)
268
                counter++;
268
                counter++;
Line 300... Line 300...
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
   
304
   
305
    if (*str == U_BOM)
-
 
306
        str++;
-
 
307
   
-
 
308
    /* Print leading spaces. */
305
    /* Print leading spaces. */
309
    size_t strw = wstr_length(str);
306
    size_t strw = wstr_length(str);
310
    if (precision == 0)
307
    if (precision == 0)
311
        precision = strw;
308
        precision = strw;
312
   
309
   
313
    /* Left padding */
310
    /* Left padding */
314
    count_t counter = 0;
311
    size_t counter = 0;
315
    width -= precision;
312
    width -= precision;
316
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
313
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
317
        while (width-- > 0) {
314
        while (width-- > 0) {
318
            if (printf_putchar(' ', ps) == 1)
315
            if (printf_putchar(' ', ps) == 1)
319
                counter++;
316
                counter++;
Line 431... Line 428...
431
        /* Print the whole number, not only a part */
428
        /* Print the whole number, not only a part */
432
        precision = number_size;
429
        precision = number_size;
433
    }
430
    }
434
   
431
   
435
    width -= precision + size - number_size;
432
    width -= precision + size - number_size;
436
    count_t counter = 0;
433
    size_t counter = 0;
437
   
434
   
438
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
435
    if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
439
        while (width-- > 0) {
436
        while (width-- > 0) {
440
            if (printf_putchar(' ', ps) == 1)
437
            if (printf_putchar(' ', ps) == 1)
441
                counter++;
438
                counter++;
Line 594... Line 591...
594
{
591
{
595
    size_t i;        /* Index of the currently processed character from fmt */
592
    size_t i;        /* Index of the currently processed character from fmt */
596
    size_t nxt = 0;  /* Index of the next character from fmt */
593
    size_t nxt = 0;  /* Index of the next character from fmt */
597
    size_t j = 0;    /* Index to the first not printed nonformating character */
594
    size_t j = 0;    /* Index to the first not printed nonformating character */
598
   
595
   
599
    count_t counter = 0;  /* Number of characters printed */
596
    size_t counter = 0;   /* Number of characters printed */
600
    int retval;           /* Return values from nested functions */
597
    int retval;           /* Return values from nested functions */
601
   
598
   
602
    while (true) {
599
    while (true) {
603
        i = nxt;
600
        i = nxt;
604
        wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
601
        wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT);