subr_scanf.c (7f8a436ff29ebeb1ce2ae2434add4505d5e7e2ca) subr_scanf.c (7e949c467cda56d24b24fb4b5d23d4299862ab71)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 45 unchanged lines hidden (view full) ---

54 * Flags used during conversion.
55 */
56#define LONG 0x01 /* l: long or double */
57#define SHORT 0x04 /* h: short */
58#define SUPPRESS 0x08 /* suppress assignment */
59#define POINTER 0x10 /* weird %p pointer (`fake hex') */
60#define NOSKIP 0x20 /* do not skip blanks */
61#define QUAD 0x400
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 45 unchanged lines hidden (view full) ---

54 * Flags used during conversion.
55 */
56#define LONG 0x01 /* l: long or double */
57#define SHORT 0x04 /* h: short */
58#define SUPPRESS 0x08 /* suppress assignment */
59#define POINTER 0x10 /* weird %p pointer (`fake hex') */
60#define NOSKIP 0x20 /* do not skip blanks */
61#define QUAD 0x400
62#define SHORTSHORT 0x4000 /** hh: char */
62
63/*
64 * The following are used in numeric conversions only:
65 * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point;
66 * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral.
67 */
68#define SIGNOK 0x40 /* +/- is (still) legal */
69#define NDIGITS 0x80 /* no digits detected */

--- 85 unchanged lines hidden (view full) ---

155 inr--, inp++;
156 nread++;
157 continue;
158
159 case '*':
160 flags |= SUPPRESS;
161 goto again;
162 case 'l':
63
64/*
65 * The following are used in numeric conversions only:
66 * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point;
67 * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral.
68 */
69#define SIGNOK 0x40 /* +/- is (still) legal */
70#define NDIGITS 0x80 /* no digits detected */

--- 85 unchanged lines hidden (view full) ---

156 inr--, inp++;
157 nread++;
158 continue;
159
160 case '*':
161 flags |= SUPPRESS;
162 goto again;
163 case 'l':
163 flags |= LONG;
164 if (flags & LONG){
165 flags &= ~LONG;
166 flags |= QUAD;
167 } else {
168 flags |= LONG;
169 }
164 goto again;
165 case 'q':
166 flags |= QUAD;
167 goto again;
168 case 'h':
170 goto again;
171 case 'q':
172 flags |= QUAD;
173 goto again;
174 case 'h':
169 flags |= SHORT;
175 if (flags & SHORT){
176 flags &= ~SHORT;
177 flags |= SHORTSHORT;
178 } else {
179 flags |= SHORT;
180 }
170 goto again;
171
172 case '0': case '1': case '2': case '3': case '4':
173 case '5': case '6': case '7': case '8': case '9':
174 width = width * 10 + c - '0';
175 goto again;
176
177 /*

--- 52 unchanged lines hidden (view full) ---

230 ccfn = strtouq;
231 base = 16;
232 break;
233
234 case 'n':
235 nconversions++;
236 if (flags & SUPPRESS) /* ??? */
237 continue;
181 goto again;
182
183 case '0': case '1': case '2': case '3': case '4':
184 case '5': case '6': case '7': case '8': case '9':
185 width = width * 10 + c - '0';
186 goto again;
187
188 /*

--- 52 unchanged lines hidden (view full) ---

241 ccfn = strtouq;
242 base = 16;
243 break;
244
245 case 'n':
246 nconversions++;
247 if (flags & SUPPRESS) /* ??? */
248 continue;
238 if (flags & SHORT)
249 if (flags & SHORTSHORT)
250 *va_arg(ap, char *) = nread;
251 else if (flags & SHORT)
239 *va_arg(ap, short *) = nread;
240 else if (flags & LONG)
241 *va_arg(ap, long *) = nread;
242 else if (flags & QUAD)
243 *va_arg(ap, quad_t *) = nread;
244 else
245 *va_arg(ap, int *) = nread;
246 continue;

--- 258 unchanged lines hidden (view full) ---

505 if ((flags & SUPPRESS) == 0) {
506 u_quad_t res;
507
508 *p = 0;
509 res = (*ccfn)(buf, (char **)NULL, base);
510 if (flags & POINTER)
511 *va_arg(ap, void **) =
512 (void *)(uintptr_t)res;
252 *va_arg(ap, short *) = nread;
253 else if (flags & LONG)
254 *va_arg(ap, long *) = nread;
255 else if (flags & QUAD)
256 *va_arg(ap, quad_t *) = nread;
257 else
258 *va_arg(ap, int *) = nread;
259 continue;

--- 258 unchanged lines hidden (view full) ---

518 if ((flags & SUPPRESS) == 0) {
519 u_quad_t res;
520
521 *p = 0;
522 res = (*ccfn)(buf, (char **)NULL, base);
523 if (flags & POINTER)
524 *va_arg(ap, void **) =
525 (void *)(uintptr_t)res;
526 else if (flags & SHORTSHORT)
527 *va_arg(ap, char *) = res;
513 else if (flags & SHORT)
514 *va_arg(ap, short *) = res;
515 else if (flags & LONG)
516 *va_arg(ap, long *) = res;
517 else if (flags & QUAD)
518 *va_arg(ap, quad_t *) = res;
519 else
520 *va_arg(ap, int *) = res;

--- 106 unchanged lines hidden ---
528 else if (flags & SHORT)
529 *va_arg(ap, short *) = res;
530 else if (flags & LONG)
531 *va_arg(ap, long *) = res;
532 else if (flags & QUAD)
533 *va_arg(ap, quad_t *) = res;
534 else
535 *va_arg(ap, int *) = res;

--- 106 unchanged lines hidden ---