diff options
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r-- | generic/tclScan.c | 203 |
1 files changed, 1 insertions, 202 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c index eede9f3..327bc2f 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclScan.c,v 1.19 2005/10/08 14:42:45 dgp Exp $ + * RCS: @(#) $Id: tclScan.c,v 1.20 2005/10/19 18:39:58 dgp Exp $ */ #include "tclInt.h" @@ -22,15 +22,6 @@ #define SCAN_UNSIGNED 0x4 /* Read an unsigned value. */ #define SCAN_WIDTH 0x8 /* A width value was supplied. */ -#if 0 -#define SCAN_SIGNOK 0x10 /* A +/- character is allowed. */ -#define SCAN_NODIGITS 0x20 /* No digits have been scanned. */ -#define SCAN_NOZERO 0x40 /* No zero digits have been scanned. */ -#define SCAN_XOK 0x80 /* An 'x' is allowed. */ -#define SCAN_PTOK 0x100 /* Decimal point is allowed. */ -#define SCAN_EXPOK 0x200 /* An exponent is allowed. */ -#endif - #define SCAN_LONGER 0x400 /* Asked for a wide value. */ #define SCAN_BIG 0x800 /* Asked for a bignum value. */ @@ -600,13 +591,6 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv) char buf[513]; /* Temporary buffer to hold scanned number * strings before they are passed to * strtoul. */ -#if 0 - int base = 0; - long (*fn) _ANSI_ARGS_((char*,void*,int)) = NULL; -#ifndef TCL_WIDE_INT_IS_LONG - Tcl_WideInt (*lfn) _ANSI_ARGS_((char*,void*,int)) = NULL; -#endif -#endif if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, @@ -754,57 +738,22 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv) case 'd': op = 'i'; parseFlag = TCL_PARSE_DECIMAL_ONLY; -#if 0 - base = 10; - fn = (long (*) _ANSI_ARGS_((char*,void*,int)))strtol; -#ifndef TCL_WIDE_INT_IS_LONG - lfn = (Tcl_WideInt (*)_ANSI_ARGS_((char*,void*,int)))strtoll; -#endif -#endif break; case 'i': op = 'i'; parseFlag = TCL_PARSE_SCAN_PREFIXES; -#if 0 - base = 0; - fn = (long (*)_ANSI_ARGS_((char*,void*,int)))strtol; -#ifndef TCL_WIDE_INT_IS_LONG - lfn = (Tcl_WideInt (*)_ANSI_ARGS_((char*,void*,int)))strtoll; -#endif -#endif break; case 'o': op = 'i'; parseFlag = TCL_PARSE_OCTAL_ONLY | TCL_PARSE_SCAN_PREFIXES; -#if 0 - base = 8; - fn = (long (*)_ANSI_ARGS_((char*,void*,int)))strtoul; -#ifndef TCL_WIDE_INT_IS_LONG - lfn = (Tcl_WideInt (*)_ANSI_ARGS_((char*,void*,int)))strtoull; -#endif -#endif break; case 'x': op = 'i'; parseFlag = TCL_PARSE_HEXADECIMAL_ONLY; -#if 0 - base = 16; - fn = (long (*)_ANSI_ARGS_((char*,void*,int)))strtoul; -#ifndef TCL_WIDE_INT_IS_LONG - lfn = (Tcl_WideInt (*)_ANSI_ARGS_((char*,void*,int)))strtoull; -#endif -#endif break; case 'u': op = 'i'; flags |= SCAN_UNSIGNED; -#if 0 - base = 10; - fn = (long (*)_ANSI_ARGS_((char*,void*,int)))strtoul; -#ifndef TCL_WIDE_INT_IS_LONG - lfn = (Tcl_WideInt (*)_ANSI_ARGS_((char*,void*,int)))strtoull; -#endif -#endif break; case 'f': @@ -941,155 +890,6 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv) /* * Scan an unsigned or signed integer. */ - -#if 0 - if ((width == 0) || (width > sizeof(buf) - 1)) { - width = sizeof(buf) - 1; - } - flags |= SCAN_SIGNOK | SCAN_NODIGITS | SCAN_NOZERO; - for (end = buf; width > 0; width--) { - switch (*string) { - /* - * The 0 digit has special meaning at the beginning of a - * number. If we are unsure of the base, it indicates that - * we are in base 8 or base 16 (if it is followed by an - * 'x'). - * - * 8.1 - 8.3.4 incorrectly handled 0x... base-16 cases for - * %x by not reading the 0x as the auto-prelude for - * base-16. [Bug #495213] - */ - case '0': - if (base == 0) { - base = 8; - flags |= SCAN_XOK; - } - if (base == 16) { - flags |= SCAN_XOK; - } - if (flags & SCAN_NOZERO) { - flags &= ~(SCAN_SIGNOK | SCAN_NODIGITS | SCAN_NOZERO); - } else { - flags &= ~(SCAN_SIGNOK | SCAN_XOK | SCAN_NODIGITS); - } - goto addToInt; - - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': - if (base == 0) { - base = 10; - } - flags &= ~(SCAN_SIGNOK | SCAN_XOK | SCAN_NODIGITS); - goto addToInt; - - case '8': case '9': - if (base == 0) { - base = 10; - } - if (base <= 8) { - break; - } - flags &= ~(SCAN_SIGNOK | SCAN_XOK | SCAN_NODIGITS); - goto addToInt; - - case 'A': case 'B': case 'C': - case 'D': case 'E': case 'F': - case 'a': case 'b': case 'c': - case 'd': case 'e': case 'f': - if (base <= 10) { - break; - } - flags &= ~(SCAN_SIGNOK | SCAN_XOK | SCAN_NODIGITS); - goto addToInt; - - case '+': case '-': - if (flags & SCAN_SIGNOK) { - flags &= ~SCAN_SIGNOK; - goto addToInt; - } - break; - - case 'x': case 'X': - if ((flags & SCAN_XOK) && (end == buf+1)) { - base = 16; - flags &= ~SCAN_XOK; - goto addToInt; - } - break; - } - - /* - * We got an illegal character so we are done accumulating. - */ - - break; - - addToInt: - /* - * Add the character to the temporary buffer. - */ - - *end++ = *string++; - if (*string == '\0') { - break; - } - } - - /* - * Check to see if we need to back up because we only got a sign - * or a trailing x after a 0. - */ - - if (flags & SCAN_NODIGITS) { - if (*string == '\0') { - underflow = 1; - } - goto done; - } else if (end[-1] == 'x' || end[-1] == 'X') { - end--; - string--; - } - - /* - * Scan the value from the temporary buffer. If we are returning a - * large unsigned value, we have to convert it back to a string - * since Tcl only supports signed values. - */ - - if (!(flags & SCAN_SUPPRESS)) { - *end = '\0'; -#ifndef TCL_WIDE_INT_IS_LONG - if (flags & SCAN_LONGER) { - wideValue = (Tcl_WideInt) (*lfn)(buf, NULL, base); - if ((flags & SCAN_UNSIGNED) && (wideValue < 0)) { - /* INTL: ISO digit */ - sprintf(buf, "%" TCL_LL_MODIFIER "u", - (Tcl_WideUInt)wideValue); - objPtr = Tcl_NewStringObj(buf, -1); - } else { - objPtr = Tcl_NewWideIntObj(wideValue); - } - } else { -#endif /* !TCL_WIDE_INT_IS_LONG */ - value = (long) (*fn)(buf, NULL, base); - if ((flags & SCAN_UNSIGNED) && (value < 0)) { - sprintf(buf, "%lu", value); /* INTL: ISO digit */ - objPtr = Tcl_NewStringObj(buf, -1); - } else if ((flags & SCAN_LONGER) - || (unsigned long) value > UINT_MAX) { - objPtr = Tcl_NewLongObj(value); - } else { - objPtr = Tcl_NewIntObj(value); - } -#ifndef TCL_WIDE_INT_IS_LONG - } -#endif - Tcl_IncrRefCount(objPtr); - objs[objIndex++] = objPtr; - } - - break; -#else objPtr = Tcl_NewLongObj(0); Tcl_IncrRefCount(objPtr); if (width == 0) { @@ -1137,7 +937,6 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv) } objs[objIndex++] = objPtr; break; -#endif case 'f': /* |