Changeset 5ee7377 in mainline


Ignore:
Timestamp:
2009-03-05T22:39:23Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2069690
Parents:
3d360758
Message:

Remove over-indentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/generic/printf.c

    r3d360758 r5ee7377  
    8484static void print_number(const unative_t num, const unsigned int base)
    8585{
    86         int val = num;
    87         char d[sizeof(unative_t) * 8 + 1];              /* this is good enough even for base == 2 */
     86        int val = num; 
     87
     88        /* This is enough even for base 2. */
     89        char d[sizeof(unative_t) * 8 + 1];
    8890        int i = sizeof(unative_t) * 8 - 1;
    89        
     91
    9092        do {
    9193                d[i--] = digits[val % base];
    9294        } while (val /= base);
    93        
     95
    9496        d[sizeof(unative_t) * 8] = 0;   
    9597        puts(&d[i + 1]);
     
    157159        va_list ap;
    158160        char c;
    159        
     161
    160162        va_start(ap, fmt);
    161        
     163
    162164        while ((c = fmt[i++])) {
    163165                switch (c) {
    164                        
    165                         /* control character */
     166
     167                /* control character */
     168                case '%':
     169
     170                        switch (c = fmt[i++]) {
     171
     172                        /* percentile itself */
    166173                        case '%':
     174                                break;
     175
     176                        /*
     177                         * String and character conversions.
     178                         */
     179                        case 's':
     180                                puts(va_arg(ap, char_ptr));
     181                                goto loop;
     182
     183                        case 'c':
     184                                c = (char) va_arg(ap, int);
     185                                break;
     186
     187                        /*
     188                         * Hexadecimal conversions with fixed width.
     189                         */
     190                        case 'P':
     191                                puts("0x");
     192                        case 'p':
     193                                print_fixed_hex(va_arg(ap, unative_t),
     194                                    sizeof(unative_t));
     195                                goto loop;
     196
     197                        case 'Q':
     198                                puts("0x");
     199                        case 'q':
     200                                print_fixed_hex(va_arg(ap, uint64_t), INT64);
     201                                goto loop;
     202
     203                        case 'L':
     204                                puts("0x");
     205                        case 'l':
     206                                print_fixed_hex(va_arg(ap, unative_t), INT32);
     207                                goto loop;
     208
     209                        case 'W':
     210                                puts("0x");
     211                        case 'w':
     212                                print_fixed_hex(va_arg(ap, unative_t), INT16);
     213                                goto loop;
     214
     215                        case 'B':
     216                                puts("0x");
     217                        case 'b':
     218                                print_fixed_hex(va_arg(ap, unative_t), INT8);
     219                                goto loop;
     220
     221                        /*
     222                         * Decimal and hexadecimal conversions.
     223                         */
     224                        case 'd':
     225                                print_number(va_arg(ap, unative_t), 10);
     226                                goto loop;
    167227                               
    168                                 switch (c = fmt[i++]) {
    169                                        
    170                                         /* percentile itself */
    171                                         case '%':
    172                                                 break;
    173                                        
    174                                         /*
    175                                          * String and character conversions.
    176                                          */
    177                                         case 's':
    178                                                 puts(va_arg(ap, char_ptr));
    179                                                 goto loop;
    180                                        
    181                                         case 'c':
    182                                                 c = (char) va_arg(ap, int);
    183                                                 break;
    184                                        
    185                                         /*
    186                                          * Hexadecimal conversions with fixed width.
    187                                          */
    188                                         case 'P':
    189                                                 puts("0x");
    190                                         case 'p':
    191                                                 print_fixed_hex(va_arg(ap, unative_t), sizeof(unative_t));
    192                                                 goto loop;
    193                                        
    194                                         case 'Q':
    195                                                 puts("0x");
    196                                         case 'q':
    197                                                 print_fixed_hex(va_arg(ap, uint64_t), INT64);
    198                                                 goto loop;
    199                                        
    200                                         case 'L':
    201                                                 puts("0x");
    202                                         case 'l':
    203                                                 print_fixed_hex(va_arg(ap, unative_t), INT32);
    204                                                 goto loop;
    205                                        
    206                                         case 'W':
    207                                                 puts("0x");
    208                                         case 'w':
    209                                                 print_fixed_hex(va_arg(ap, unative_t), INT16);
    210                                                 goto loop;
    211                                        
    212                                         case 'B':
    213                                                 puts("0x");
    214                                         case 'b':
    215                                                 print_fixed_hex(va_arg(ap, unative_t), INT8);
    216                                                 goto loop;
    217                                        
    218                                         /*
    219                                          * Decimal and hexadecimal conversions.
    220                                          */
    221                                         case 'd':
    222                                                 print_number(va_arg(ap, unative_t), 10);
    223                                                 goto loop;
    224                                        
    225                                         case 'X':
    226                                                 puts("0x");
    227                                         case 'x':
    228                                                 print_number(va_arg(ap, unative_t), 16);
    229                                                 goto loop;
    230                                        
    231                                         /*
    232                                          * Bad formatting.
    233                                          */
    234                                         default:
    235                                                 goto out;
     228                        case 'X':
     229                                puts("0x");
     230                        case 'x':
     231                                print_number(va_arg(ap, unative_t), 16);
     232                                goto loop;
     233                               
     234                        /*
     235                         * Bad formatting.
     236                         */
     237                        default:
     238                                goto out;
    236239                        }
    237                        
    238                         default:
    239                                 write(&c, 1);
     240
     241                default:
     242                        write(&c, 1);
    240243                }
    241        
    242244loop:
    243245                ;
Note: See TracChangeset for help on using the changeset viewer.