| OLD | NEW |
| 1 #include "stdio_impl.h" | 1 #include "stdio_impl.h" |
| 2 #include <errno.h> | 2 #include <errno.h> |
| 3 #include <ctype.h> | 3 #include <ctype.h> |
| 4 #include <limits.h> | 4 #include <limits.h> |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 #include <stdarg.h> | 6 #include <stdarg.h> |
| 7 #include <wchar.h> | 7 #include <wchar.h> |
| 8 #include <inttypes.h> | 8 #include <inttypes.h> |
| 9 #include <math.h> | 9 #include <math.h> |
| 10 #include <float.h> | 10 #include <float.h> |
| 11 | 11 |
| 12 /* Some useful macros */ | 12 /* Some useful macros */ |
| 13 | 13 |
| 14 #define MAX(a,b) ((a)>(b) ? (a) : (b)) | 14 #define MAX(a,b) ((a)>(b) ? (a) : (b)) |
| 15 #define MIN(a,b) ((a)<(b) ? (a) : (b)) | 15 #define MIN(a,b) ((a)<(b) ? (a) : (b)) |
| 16 | 16 |
| 17 /* Convenient bit representation for modifier flags, which all fall | 17 /* Convenient bit representation for modifier flags, which all fall |
| 18 * within 31 codepoints of the space character. */ | 18 * within 31 codepoints of the space character. */ |
| 19 | 19 |
| 20 #define ALT_FORM (1U<<'#'-' ') | 20 #define ALT_FORM (1U<<('#'-' ')) |
| 21 #define ZERO_PAD (1U<<'0'-' ') | 21 #define ZERO_PAD (1U<<('0'-' ')) |
| 22 #define LEFT_ADJ (1U<<'-'-' ') | 22 #define LEFT_ADJ (1U<<('-'-' ')) |
| 23 #define PAD_POS (1U<<' '-' ') | 23 #define PAD_POS (1U<<(' '-' ')) |
| 24 #define MARK_POS (1U<<'+'-' ') | 24 #define MARK_POS (1U<<('+'-' ')) |
| 25 #define GROUPED (1U<<'\''-' ') | 25 #define GROUPED (1U<<('\''-' ')) |
| 26 | 26 |
| 27 #define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS|GROUPED) | 27 #define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS|GROUPED) |
| 28 | 28 |
| 29 #if UINT_MAX == ULONG_MAX | 29 #if UINT_MAX == ULONG_MAX |
| 30 #define LONG_IS_INT | 30 #define LONG_IS_INT |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 #if SIZE_MAX != ULONG_MAX || UINTMAX_MAX != ULLONG_MAX | 33 #if SIZE_MAX != ULONG_MAX || UINTMAX_MAX != ULLONG_MAX |
| 34 #define ODD_TYPES | 34 #define ODD_TYPES |
| 35 #endif | 35 #endif |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (isdigit(s[1]) && s[2]=='$') { | 478 if (isdigit(s[1]) && s[2]=='$') { |
| 479 l10n=1; | 479 l10n=1; |
| 480 argpos = s[1]-'0'; | 480 argpos = s[1]-'0'; |
| 481 s+=3; | 481 s+=3; |
| 482 } else { | 482 } else { |
| 483 argpos = -1; | 483 argpos = -1; |
| 484 s++; | 484 s++; |
| 485 } | 485 } |
| 486 | 486 |
| 487 /* Read modifier flags */ | 487 /* Read modifier flags */ |
| 488 » » for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<*s-' ')); s++) | 488 » » for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<(*s-' '))); s++
) |
| 489 » » » fl |= 1U<<*s-' '; | 489 » » » fl |= 1U<<(*s-' '); |
| 490 | 490 |
| 491 /* Read field width */ | 491 /* Read field width */ |
| 492 if (*s=='*') { | 492 if (*s=='*') { |
| 493 if (isdigit(s[1]) && s[2]=='$') { | 493 if (isdigit(s[1]) && s[2]=='$') { |
| 494 l10n=1; | 494 l10n=1; |
| 495 nl_type[s[1]-'0'] = INT; | 495 nl_type[s[1]-'0'] = INT; |
| 496 w = nl_arg[s[1]-'0'].i; | 496 w = nl_arg[s[1]-'0'].i; |
| 497 s+=3; | 497 s+=3; |
| 498 } else if (!l10n) { | 498 } else if (!l10n) { |
| 499 w = f ? va_arg(*ap, int) : 0; | 499 w = f ? va_arg(*ap, int) : 0; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 f->buf = saved_buf; | 682 f->buf = saved_buf; |
| 683 f->buf_size = 0; | 683 f->buf_size = 0; |
| 684 f->wpos = f->wbase = f->wend = 0; | 684 f->wpos = f->wbase = f->wend = 0; |
| 685 } | 685 } |
| 686 if (f->flags & F_ERR) ret = -1; | 686 if (f->flags & F_ERR) ret = -1; |
| 687 f->flags |= olderr; | 687 f->flags |= olderr; |
| 688 FUNLOCK(f); | 688 FUNLOCK(f); |
| 689 va_end(ap2); | 689 va_end(ap2); |
| 690 return ret; | 690 return ret; |
| 691 } | 691 } |
| OLD | NEW |