Tcl Source Code

Artifact [70bbd87a4a]
Login

Artifact 70bbd87a4a3ba6e5eb60784fd9f10c1769f0b4ff:

Attachment "None" to ticket [402663ffff] added by kennykb 2000-12-06 02:59:22.
*** doc/scan.n.orig Tue Dec  5 14:36:52 2000
--- doc/scan.n Tue Dec  5 14:36:06 2000
***************
*** 82,91 ****
--- 82,102 ----
  \fBo\fR
  The input field must be an octal integer. It is read in and the 
  value is stored in the variable as a decimal string.
+ .VS 8.4
+ If the
+ value exceeds MAX_INT (017777777777 on platforms using 32-bit
+ integers), it will be truncated to a signed integer.  Hence,
+ 037777777777 will appear as -1 on a 32-bit machine.
+ .VE 8.4
  .TP 10
  \fBx\fR
  The input field must be a hexadecimal integer. It is read in 
  and the value is stored in the variable as a decimal string.
+ .VS 8.4
+ If the value exceeds MAX_INT (0x7FFFFFFF on platforms
+ using 32-bit integers), it will be truncated to a signed integer.
+ Hence, 0xFFFFFFFF will appear as -1 on a 32-bit machine.
+ .VE 8.4
  .VS 8.1
  .TP 10
  \fBu\fR
*** generic/tclScan.c.orig Tue Dec  5 11:53:48 2000
--- generic/tclScan.c Tue Dec  5 14:19:56 2000
***************
*** 694,705 ****
  	    case 'o':
  		op = 'i';
  		base = 8;
! 		fn = (long (*)())strtol;
  		break;
  	    case 'x':
  		op = 'i';
  		base = 16;
! 		fn = (long (*)())strtol;
  		break;
  	    case 'u':
  		op = 'i';
--- 694,705 ----
  	    case 'o':
  		op = 'i';
  		base = 8;
! 		fn = (long (*)())strtoul;
  		break;
  	    case 'x':
  		op = 'i';
  		base = 16;
! 		fn = (long (*)())strtoul;
  		break;
  	    case 'u':
  		op = 'i';
*** tests/scan.test.orig Tue Dec  5 11:58:36 2000
--- tests/scan.test Wed Dec  6 13:57:20 2000
***************
*** 324,329 ****
--- 324,358 ----
      set result
  } {1 {couldn't set variable "z"couldn't set variable "y"} abc}
  
+ # procedure that returns the range of integers
+ 
+ proc int_range {} {
+     for { set MIN_INT 1 } { $MIN_INT > 0 } {} {
+ 	set MIN_INT [expr { $MIN_INT << 1 }]
+     }
+     set MAX_INT [expr { ~ $MIN_INT }]
+     return [list $MIN_INT $MAX_INT]
+ }
+ 
+ test scan-4.62 {scanning of large and negative octal integers} {
+     foreach { MIN_INT MAX_INT } [int_range] {}
+     set scanstring [format {%o %o %o} -1 $MIN_INT $MAX_INT]
+     list [scan $scanstring {%o %o %o} a b c] \
+ 	[expr { $a == -1 }] [expr { $b == $MIN_INT }] [expr { $c == $MAX_INT }]
+ } {3 1 1 1}
+ test scan-4.63 {scanning of large and negative hex integers} {
+     foreach { MIN_INT MAX_INT } [int_range] {}
+     set scanstring [format {%x %x %x} -1 $MIN_INT $MAX_INT]
+     list [scan $scanstring {%x %x %x} a b c] \
+ 	[expr { $a == -1 }] [expr { $b == $MIN_INT }] [expr { $c == $MAX_INT }]
+ } {3 1 1 1}
+ 
+ # clean up from last two tests
+ 
+ catch {
+     rename int_range {}
+ }
+ 
  test scan-5.1 {integer scanning} {
      set a {}; set b {}; set c {}; set d {}
      list [scan "-20 1476 \n33 0" "%d %d %d %d" a b c d] $a $b $c $d
***************
*** 630,646 ****
  # cleanup
  ::tcltest::cleanupTests
  return
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
--- 659,661 ----