Tcl Source Code

Check-in [7f0027be0c]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:
[kennykb-numerics-branch]
* generic/tclScan.c: Bug fix: The %o, %x, %i formats of scan must not accept any 0b or 0o prefixes. [scan $s %o] must continue to work even with KILL_OCTAL enabled.
* generic/tclInt.h: Added TCL_PARSE_SCAN_PREFIXES to the flags * generic/tclStrToD.c: accepted by TclParseNumber.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | kennykb-numerics-branch
Files: files | file ages | folders
SHA1:7f0027be0c81920a8c7c0190dd10852495111eda
User & Date: dgp 2005-09-02 17:42:23
Context
2005-09-09
18:48
[kennykb-numerics-branch] Merge updates from HEAD.
check-in: 343239eeff user: dgp tags: kennykb-numerics-branch
2005-09-02
17:42
[kennykb-numerics-branch]
* generic/tclScan.c: Bug fix: The %o, %x, %i formats o...
check-in: 7f0027be0c user: dgp tags: kennykb-numerics-branch
2005-09-01
16:27
* generic/tclObj.c: TclParseNumber calls meant to parse an integer value now pas...
check-in: 6e311ccfa4 user: dgp tags: kennykb-numerics-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.












1
2
3
4
5
6
7











2005-09-01  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclObj.c:	TclParseNumber calls meant to parse an
	integer value now pass the TCL_PARSE_INTEGER_ONLY flag.

>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2005-09-02  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclScan.c:	Bug fix: The %o, %x, %i formats of [scan]
	must not accept any 0b or 0o prefixes.  [scan $s %o] must continue
	to work even with KILL_OCTAL enabled.

	* generic/tclInt.h:	Added TCL_PARSE_SCAN_PREFIXES to the flags
	* generic/tclStrToD.c:	accepted by TclParseNumber.

2005-09-01  Don Porter  <dgp@users.sourceforge.net>

	[kennykb-numerics-branch]

	* generic/tclObj.c:	TclParseNumber calls meant to parse an
	integer value now pass the TCL_PARSE_INTEGER_ONLY flag.

Changes to generic/tclInt.h.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1885
1886
1887
1888
1889
1890
1891
1892
1893

1894
1895
1896
1897
1898


1899
1900
1901
1902
1903
1904
1905
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 1998-19/99 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclInt.h,v 1.202.2.36 2005/09/01 16:09:56 dgp Exp $
 */

#ifndef _TCLINT
#define _TCLINT

/*
 * Some numerics configuration options
................................................................................

/*
 *----------------------------------------------------------------------
 * Flags for TclParseNumber
 *----------------------------------------------------------------------
 */

#define TCL_PARSE_DECIMAL_ONLY 1
				/* Leading zero doesn't denote octal or hex */

#define TCL_PARSE_OCTAL_ONLY 2	/* Parse octal even without prefix */
#define TCL_PARSE_HEXADECIMAL_ONLY 4
				/* Parse hexadecimal even without prefix */
#define TCL_PARSE_INTEGER_ONLY 8
				/* Disable floating point parsing */



/*
 *----------------------------------------------------------------
 * Variables shared among Tcl modules but not used by the outside world.
 *----------------------------------------------------------------
 */








|







 







|

>
|
|

|

>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
 * Copyright (c) 1994-1998 Sun Microsystems, Inc.
 * Copyright (c) 1998-19/99 by Scriptics Corporation.
 * Copyright (c) 2001, 2002 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclInt.h,v 1.202.2.37 2005/09/02 17:42:24 dgp Exp $
 */

#ifndef _TCLINT
#define _TCLINT

/*
 * Some numerics configuration options
................................................................................

/*
 *----------------------------------------------------------------------
 * Flags for TclParseNumber
 *----------------------------------------------------------------------
 */

#define TCL_PARSE_DECIMAL_ONLY		1
				/* Leading zero doesn't denote octal or hex */
#define TCL_PARSE_OCTAL_ONLY		2
				/* Parse octal even without prefix */
#define TCL_PARSE_HEXADECIMAL_ONLY	4
				/* Parse hexadecimal even without prefix */
#define TCL_PARSE_INTEGER_ONLY		8
				/* Disable floating point parsing */
#define TCL_PARSE_SCAN_PREFIXES		16
				/* Use [scan] rules dealing with 0? prefixes */

/*
 *----------------------------------------------------------------
 * Variables shared among Tcl modules but not used by the outside world.
 *----------------------------------------------------------------
 */

Changes to generic/tclScan.c.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
760
761
762
763
764
765
766

767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
 *	This file contains the implementation of the "scan" command.
 *
 * Copyright (c) 1998 by Scriptics Corporation.
 *
 * 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.16.2.4 2005/09/01 16:09:57 dgp Exp $
 */

#include "tclInt.h"

/*
 * Flag values used by Tcl_ScanObjCmd.
 */
................................................................................
#ifndef TCL_WIDE_INT_IS_LONG
	    lfn = (Tcl_WideInt (*)_ANSI_ARGS_((char*,void*,int)))strtoll;
#endif
#endif
	    break;
	case 'i':
	    op = 'i';

#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;
#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







|







 







>










|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
 *	This file contains the implementation of the "scan" command.
 *
 * Copyright (c) 1998 by Scriptics Corporation.
 *
 * 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.16.2.5 2005/09/02 17:42:24 dgp Exp $
 */

#include "tclInt.h"

/*
 * Flag values used by Tcl_ScanObjCmd.
 */
................................................................................
#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

Changes to generic/tclStrToD.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
33
34
35
36
37
38
39




40
41
42
43
44
45
46
...
373
374
375
376
377
378
379
380



381



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396

397
398
399
400
401
402
403
 *	interconversion among 'double' and 'mp_int' types.
 *
 * Copyright (c) 2005 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclStrToD.c,v 1.1.2.35 2005/09/01 16:09:57 dgp Exp $
 *
 *----------------------------------------------------------------------
 */

#include <tclInt.h>
#include <stdio.h>
#include <stdlib.h>
................................................................................
 * Define KILL_OCTAL as well as TIP_114_FORMATS to suppress interpretation
 * of numbers with leading zero as octal. (Ceterum censeo: numeros octonarios
 * delendos esse.)
 */

#define	TIP_114_FORMATS
#undef	KILL_OCTAL





/*
 * This code supports (at least hypothetically), IBM, Cray, VAX and
 * IEEE-754 floating point; of these, only IEEE-754 can represent NaN.
 * IEEE-754 can be uniquely determined by radix and by the widths of
 * significand and exponent.
 */
................................................................................
	     */
	    acceptState = state;
	    acceptPoint = p;
	    acceptLen = len;
	    if (c == 'x' || c == 'X') {
		state = ZERO_X;
		break;
	    }



#ifdef TIP_114_FORMATS 



	    if (c == 'b' || c == 'B') {
		state = ZERO_B;
		break;
	    }
	    if (c == 'o' || c == 'O') {
		explicitOctal = 1;
		state = ZERO_O;
		break;
	    }
#endif
	    if (flags & TCL_PARSE_HEXADECIMAL_ONLY) {
		goto zerox;
	    }
#ifdef KILL_OCTAL
	    goto decimal;

#endif
	    /* FALLTHROUGH */

	case OCTAL:
	    /*
	     * Scanned an optional + or -, followed by a string of
	     * octal digits.  Acceptable inputs are more digits,







|







 







>
>
>
>







 








>
>
>

>
>
>









<
<
<
<


>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400




401
402
403
404
405
406
407
408
409
410
 *	interconversion among 'double' and 'mp_int' types.
 *
 * Copyright (c) 2005 by Kevin B. Kenny.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclStrToD.c,v 1.1.2.36 2005/09/02 17:42:24 dgp Exp $
 *
 *----------------------------------------------------------------------
 */

#include <tclInt.h>
#include <stdio.h>
#include <stdlib.h>
................................................................................
 * Define KILL_OCTAL as well as TIP_114_FORMATS to suppress interpretation
 * of numbers with leading zero as octal. (Ceterum censeo: numeros octonarios
 * delendos esse.)
 */

#define	TIP_114_FORMATS
#undef	KILL_OCTAL

#ifndef TIP_114_FORMATS
#undef	KILL_OCTAL
#endif

/*
 * This code supports (at least hypothetically), IBM, Cray, VAX and
 * IEEE-754 floating point; of these, only IEEE-754 can represent NaN.
 * IEEE-754 can be uniquely determined by radix and by the widths of
 * significand and exponent.
 */
................................................................................
	     */
	    acceptState = state;
	    acceptPoint = p;
	    acceptLen = len;
	    if (c == 'x' || c == 'X') {
		state = ZERO_X;
		break;
	    }
	    if (flags & TCL_PARSE_HEXADECIMAL_ONLY) {
		goto zerox;
	    }
#ifdef TIP_114_FORMATS 
	    if (flags & TCL_PARSE_SCAN_PREFIXES) {
		goto zeroo;
	    }
	    if (c == 'b' || c == 'B') {
		state = ZERO_B;
		break;
	    }
	    if (c == 'o' || c == 'O') {
		explicitOctal = 1;
		state = ZERO_O;
		break;
	    }




#ifdef KILL_OCTAL
	    goto decimal;
#endif
#endif
	    /* FALLTHROUGH */

	case OCTAL:
	    /*
	     * Scanned an optional + or -, followed by a string of
	     * octal digits.  Acceptable inputs are more digits,