Changeset cdafab1 in mainline


Ignore:
Timestamp:
2006-04-23T15:04:08Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d3b8c1f
Parents:
34c4d69
Message:

Printf precision is counted without prefixes now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libc/generic/io/print.c

    r34c4d69 rcdafab1  
    166166        char d[PRINT_NUMBER_BUFFER_SIZE];       /* this is good enough even for base == 2, prefix and sign */
    167167        char *ptr = &d[PRINT_NUMBER_BUFFER_SIZE - 1];
    168         int size = 0;
     168        int size = 0; /* size of number with all prefixes and signs */
     169        int number_size; /* size of plain number */
    169170        int written = 0;
    170171        char sgn;
     
    184185                } while (num /= base);
    185186        }
    186 
     187       
     188        number_size = size;
     189       
    187190        /* Collect sum of all prefixes/signs/... to calculate padding and leading zeroes */
    188191        if (flags & __PRINTF_FLAG_PREFIX) {
     
    221224        if (flags & __PRINTF_FLAG_ZEROPADDED) {
    222225                if ((precision == 0) && (width > size)) {
    223                         precision = width - size;
     226                        precision = width - size + number_size;
    224227                }
    225228        }
    226229
    227230        /* print leading spaces */
    228         if (size > precision) /* We must print whole number not only a part */
    229                 precision = size;
    230 
    231         width -= precision;
     231        if (number_size > precision) /* We must print whole number not only a part */
     232                precision = number_size;
     233
     234        width -= precision + size - number_size;
    232235       
    233236        if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
     
    274277
    275278        /* print leading zeroes */
    276         precision -= size;
     279        precision -= number_size;
    277280        while (precision-- > 0) {       
    278281                putchar('0');   
Note: See TracChangeset for help on using the changeset viewer.