Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/vsnprintf.c

    ra35b458 r9d58539  
    6565{
    6666        size_t left = data->size - data->len;
    67 
     67       
    6868        if (left == 0)
    6969                return ((int) size);
    70 
     70       
    7171        if (left == 1) {
    7272                /* We have only one free byte left in buffer
     
    7777                return ((int) size);
    7878        }
    79 
     79       
    8080        if (left <= size) {
    8181                /* We do not have enough space for the whole string
     
    8484                 */
    8585                size_t index = 0;
    86 
     86               
    8787                while (index < size) {
    8888                        wchar_t uc = str_decode(str, &index, size);
    89 
     89                       
    9090                        if (chr_encode(uc, data->dst, &data->len, data->size - 1) != EOK)
    9191                                break;
    9292                }
    93 
     93               
    9494                /* Put trailing zero at end, but not count it
    9595                 * into data->len so it could be rewritten next time
    9696                 */
    9797                data->dst[data->len] = 0;
    98 
     98               
    9999                return ((int) size);
    100100        }
    101 
     101       
    102102        /* Buffer is big enough to print the whole string */
    103103        memcpy((void *)(data->dst + data->len), (void *) str, size);
    104104        data->len += size;
    105 
     105       
    106106        /* Put trailing zero at end, but not count it
    107107         * into data->len so it could be rewritten next time
    108108         */
    109109        data->dst[data->len] = 0;
    110 
     110       
    111111        return ((int) size);
    112112}
     
    132132{
    133133        size_t index = 0;
    134 
     134       
    135135        while (index < (size / sizeof(wchar_t))) {
    136136                size_t left = data->size - data->len;
    137 
     137               
    138138                if (left == 0)
    139139                        return ((int) size);
    140 
     140               
    141141                if (left == 1) {
    142142                        /* We have only one free byte left in buffer
     
    147147                        return ((int) size);
    148148                }
    149 
     149               
    150150                if (chr_encode(str[index], data->dst, &data->len, data->size - 1) != EOK)
    151151                        break;
    152 
     152               
    153153                index++;
    154154        }
    155 
     155       
    156156        /* Put trailing zero at end, but not count it
    157157         * into data->len so it could be rewritten next time
    158158         */
    159159        data->dst[data->len] = 0;
    160 
     160       
    161161        return ((int) size);
    162162}
     
    174174                &data
    175175        };
    176 
     176       
    177177        /* Print 0 at end of string - fix the case that nothing will be printed */
    178178        if (size > 0)
    179179                str[0] = 0;
    180 
     180       
    181181        /* vsnprintf_write ensures that str will be terminated by zero. */
    182182        return printf_core(fmt, &ps, ap);
Note: See TracChangeset for help on using the changeset viewer.