Changeset 1b0b48e0 in mainline for kernel/generic/src/printf/vprintf.c


Ignore:
Timestamp:
2009-04-01T19:01:39Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
06b785f
Parents:
f25b2819
Message:

Partial refactor of printf modules to reflect new string API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/printf/vprintf.c

    rf25b2819 r1b0b48e0  
    4646static int vprintf_write_utf8(const char *str, size_t size, void *data)
    4747{
    48         index_t index = 0;
    49         index_t chars = 0;
    50        
    51         while (index < size) {
    52                 putchar(chr_decode(str, &index, size));
     48        size_t offset = 0;
     49        count_t chars = 0;
     50
     51        while (offset < size) {
     52                putchar(chr_decode(str, &offset, size));
    5353                chars++;
    5454        }
    55        
     55
    5656        return chars;
    5757}
     
    6060{
    6161        index_t index = 0;
    62        
     62
    6363        while (index < (size / sizeof(wchar_t))) {
    6464                putchar(str[index]);
    6565                index++;
    6666        }
    67        
     67
    6868        return index;
    6969}
     
    7171int puts(const char *str)
    7272{
    73         index_t index = 0;
    74         index_t chars = 0;
     73        size_t offset = 0;
     74        count_t chars = 0;
    7575        wchar_t uc;
    76        
    77         while ((uc = chr_decode(str, &index, UTF8_NO_LIMIT)) != 0) {
     76
     77        while ((uc = chr_decode(str, &offset, UTF8_NO_LIMIT)) != 0) {
    7878                putchar(uc);
    7979                chars++;
    8080        }
    81        
     81
    8282        return chars;
    8383}
     
    9090                NULL
    9191        };
    92        
     92
    9393        ipl_t ipl = interrupts_disable();
    9494        spinlock_lock(&printf_lock);
    95        
     95
    9696        int ret = printf_core(fmt, &ps, ap);
    97        
     97
    9898        spinlock_unlock(&printf_lock);
    9999        interrupts_restore(ipl);
    100        
     100
    101101        return ret;
    102102}
Note: See TracChangeset for help on using the changeset viewer.