Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1224 → Rev 1225

/uspace/trunk/libc/generic/io/print.c
165,7 → 165,8
char *digits = digits_small;
char d[PRINT_NUMBER_BUFFER_SIZE]; /* this is good enough even for base == 2, prefix and sign */
char *ptr = &d[PRINT_NUMBER_BUFFER_SIZE - 1];
int size = 0;
int size = 0; /* size of number with all prefixes and signs */
int number_size; /* size of plain number */
int written = 0;
char sgn;
183,7 → 184,9
size++;
} while (num /= base);
}
 
number_size = size;
/* Collect sum of all prefixes/signs/... to calculate padding and leading zeroes */
if (flags & __PRINTF_FLAG_PREFIX) {
switch(base) {
220,15 → 223,15
/* if number is leftaligned or precision is specified then zeropadding is ignored */
if (flags & __PRINTF_FLAG_ZEROPADDED) {
if ((precision == 0) && (width > size)) {
precision = width - size;
precision = width - size + number_size;
}
}
 
/* print leading spaces */
if (size > precision) /* We must print whole number not only a part */
precision = size;
if (number_size > precision) /* We must print whole number not only a part */
precision = number_size;
 
width -= precision;
width -= precision + size - number_size;
if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
while (width-- > 0) {
273,7 → 276,7
}
 
/* print leading zeroes */
precision -= size;
precision -= number_size;
while (precision-- > 0) {
putchar('0');
written++;