| 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 | 9 |
| 10 /* Convenient bit representation for modifier flags, which all fall | 10 /* Convenient bit representation for modifier flags, which all fall |
| 11 * within 31 codepoints of the space character. */ | 11 * within 31 codepoints of the space character. */ |
| 12 | 12 |
| 13 #define ALT_FORM (1U<<'#'-' ') | 13 #define ALT_FORM (1U<<('#'-' ')) |
| 14 #define ZERO_PAD (1U<<'0'-' ') | 14 #define ZERO_PAD (1U<<('0'-' ')) |
| 15 #define LEFT_ADJ (1U<<'-'-' ') | 15 #define LEFT_ADJ (1U<<('-'-' ')) |
| 16 #define PAD_POS (1U<<' '-' ') | 16 #define PAD_POS (1U<<(' '-' ')) |
| 17 #define MARK_POS (1U<<'+'-' ') | 17 #define MARK_POS (1U<<('+'-' ')) |
| 18 #define GROUPED (1U<<'\''-' ') | 18 #define GROUPED (1U<<('\''-' ')) |
| 19 | 19 |
| 20 #define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS|GROUPED) | 20 #define FLAGMASK (ALT_FORM|ZERO_PAD|LEFT_ADJ|PAD_POS|MARK_POS|GROUPED) |
| 21 | 21 |
| 22 #if UINT_MAX == ULONG_MAX | 22 #if UINT_MAX == ULONG_MAX |
| 23 #define LONG_IS_INT | 23 #define LONG_IS_INT |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #if SIZE_MAX != ULONG_MAX || UINTMAX_MAX != ULLONG_MAX | 26 #if SIZE_MAX != ULONG_MAX || UINTMAX_MAX != ULLONG_MAX |
| 27 #define ODD_TYPES | 27 #define ODD_TYPES |
| 28 #endif | 28 #endif |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (iswdigit(s[1]) && s[2]=='$') { | 202 if (iswdigit(s[1]) && s[2]=='$') { |
| 203 l10n=1; | 203 l10n=1; |
| 204 argpos = s[1]-'0'; | 204 argpos = s[1]-'0'; |
| 205 s+=3; | 205 s+=3; |
| 206 } else { | 206 } else { |
| 207 argpos = -1; | 207 argpos = -1; |
| 208 s++; | 208 s++; |
| 209 } | 209 } |
| 210 | 210 |
| 211 /* Read modifier flags */ | 211 /* Read modifier flags */ |
| 212 » » for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<*s-' ')); s++) | 212 » » for (fl=0; (unsigned)*s-' '<32 && (FLAGMASK&(1U<<(*s-' '))); s++
) |
| 213 » » » fl |= 1U<<*s-' '; | 213 » » » fl |= 1U<<(*s-' '); |
| 214 | 214 |
| 215 /* Read field width */ | 215 /* Read field width */ |
| 216 if (*s=='*') { | 216 if (*s=='*') { |
| 217 if (iswdigit(s[1]) && s[2]=='$') { | 217 if (iswdigit(s[1]) && s[2]=='$') { |
| 218 l10n=1; | 218 l10n=1; |
| 219 nl_type[s[1]-'0'] = INT; | 219 nl_type[s[1]-'0'] = INT; |
| 220 w = nl_arg[s[1]-'0'].i; | 220 w = nl_arg[s[1]-'0'].i; |
| 221 s+=3; | 221 s+=3; |
| 222 } else if (!l10n) { | 222 } else if (!l10n) { |
| 223 w = f ? va_arg(*ap, int) : 0; | 223 w = f ? va_arg(*ap, int) : 0; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 fwide(f, 1); | 362 fwide(f, 1); |
| 363 olderr = f->flags & F_ERR; | 363 olderr = f->flags & F_ERR; |
| 364 f->flags &= ~F_ERR; | 364 f->flags &= ~F_ERR; |
| 365 ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type); | 365 ret = wprintf_core(f, fmt, &ap2, nl_arg, nl_type); |
| 366 if (f->flags & F_ERR) ret = -1; | 366 if (f->flags & F_ERR) ret = -1; |
| 367 f->flags |= olderr; | 367 f->flags |= olderr; |
| 368 FUNLOCK(f); | 368 FUNLOCK(f); |
| 369 va_end(ap2); | 369 va_end(ap2); |
| 370 return ret; | 370 return ret; |
| 371 } | 371 } |
| OLD | NEW |