Rev 6425 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6425 | Rev 6433 | ||
---|---|---|---|
Line 75... | Line 75... | ||
75 | // sign can be zero, 0, x, X, space, +, - |
75 | // sign can be zero, 0, x, X, space, +, - |
76 | { |
76 | { |
77 | int rc = 0, sign_len; |
77 | int rc = 0, sign_len; |
78 | char fill; |
78 | char fill; |
Line 79... | Line 79... | ||
79 | 79 | ||
80 | fill = (flags & flag_lead_zeros) ? '0' : ' '; |
80 | fill = (flags & flag_lead_zeros)&&((flags & flag_left_just)==0) ? '0' : ' '; |
81 | if(sign == 'x' || sign == 'X') |
81 | if(sign == 'x' || sign == 'X') |
82 | { |
82 | { |
83 | sign_len = 2; |
83 | sign_len = 2; |
84 | } else |
84 | } else |
Line 158... | Line 158... | ||
158 | norm_digit = number; |
158 | norm_digit = number; |
159 | if (flags & flag_plus) sign = '+'; else |
159 | if (flags & flag_plus) sign = '+'; else |
160 | if (flags & flag_space_plus) sign = ' '; |
160 | if (flags & flag_space_plus) sign = ' '; |
161 | } |
161 | } |
162 | // normalize |
162 | // normalize |
163 | while (norm_digit < 1.0) { norm_digit *= 10; mul--; } |
163 | while (norm_digit < 1.0 && norm_digit > 0) { norm_digit *= 10; mul--; } |
164 | while (norm_digit >= 10.0) { norm_digit /= 10; mul++; } |
164 | while (norm_digit >= 10.0) { norm_digit /= 10; mul++; } |
Line 165... | Line 165... | ||
165 | 165 | ||
Line 166... | Line 166... | ||
166 | len = formatted_double_to_string(norm_digit, 0, format2, buf, flags & ~(flag_plus | flag_space_plus)); |
166 | len = formatted_double_to_string(norm_digit, 0, format2, buf, flags & ~(flag_plus | flag_space_plus)); |
Line 610... | Line 610... | ||
610 | break; |
610 | break; |
611 | case 'g': case 'G': |
611 | case 'g': case 'G': |
612 | //prec special case, this is just workaround |
612 | //prec special case, this is just workaround |
613 | if (flag_long <= 1) doubledigit = va_arg(argp, double); else |
613 | if (flag_long <= 1) doubledigit = va_arg(argp, double); else |
614 | if (flag_long == 2) doubledigit = va_arg(argp, long double); |
614 | if (flag_long == 2) doubledigit = va_arg(argp, long double); |
- | 615 | if (flags & flag_point) |
|
615 | length = formatted_double_to_string(doubledigit, fmt1, fmt2, buf, flags); |
616 | length = formatted_double_to_string(doubledigit, fmt1, fmt2, buf, flags); |
- | 617 | else |
|
- | 618 | length = formatted_double_to_string(doubledigit, fmt1, 1, buf, flags | flag_point); |
|
616 | i = formatted_double_to_string_scientific(doubledigit, fmt1, fmt2, buf + sizeof buf / 2, flags); |
619 | i = formatted_double_to_string_scientific(doubledigit, fmt1, fmt2, buf + sizeof buf / 2, flags); |
617 | if(length > i) |
620 | if(length > i) |
618 | { |
621 | { |
619 | memcpy(buf, buf + sizeof buf / 2, i); |
622 | memcpy(buf, buf + sizeof buf / 2, i); |
620 | length = i; |
623 | length = i; |