Tcl Source Code

Artifact [650fc1203e]
Login

Artifact 650fc1203ee3187de29d9682c7e351fad36083ed:

Attachment "regexp.diff" to ticket [667456ffff] added by davidw 2003-01-14 14:01:33.
Index: library/auto.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/auto.tcl,v
retrieving revision 1.12
diff -u -r1.12 auto.tcl
--- library/auto.tcl	28 Oct 2002 16:34:25 -0000	1.12
+++ library/auto.tcl	13 Jan 2003 22:06:44 -0000
@@ -429,7 +429,7 @@
     # we have to build procs with the fully qualified names, and
     # have the procs point to the aliases.
 
-    if {[regexp {::} $name]} {
+    if {[string match "*::*" $name]} {
         set exportCmd [list _%@namespace export [namespace tail $name]]
         $parser eval [list _%@namespace eval $ns $exportCmd]
  
Index: library/ldAout.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/ldAout.tcl,v
retrieving revision 1.5
diff -u -r1.5 ldAout.tcl
--- library/ldAout.tcl	28 Sep 2001 01:21:53 -0000	1.5
+++ library/ldAout.tcl	13 Jan 2003 22:06:45 -0000
@@ -88,9 +88,9 @@
 	} elseif {![string compare $a -o]} {
 	    set minusO 1
 	}
-	if {[regexp {^-[lL]} $a]} {
+	if {[string match -nocase "-l*" $a]} {
 	    lappend libraries $a
-	    if {[regexp {^-L} $a]} {
+	    if {[string match "-L*" $a]} {
 		lappend libdirs [string range $a 2 end]
 	    }
 	} elseif {$seenDotO} {
@@ -106,7 +106,7 @@
 
     set libs {}
     foreach lib $libraries {
-	if {[regexp {^-l} $lib]} {
+	if {[string match "-l*" $lib]} {
 	    set lname [string range $lib 2 end]
 	    foreach dir $libdirs {
 		if {[file exists [file join $dir lib${lname}_G0.a]]} {
@@ -138,7 +138,7 @@
 	error "Output file does not appear to have a suffix"
     }
     set modName [string tolower $m 0 [expr {$l-1}]]
-    if {[regexp {^lib} $modName]} {
+    if {[string match "lib*" $modName]} {
 	set modName [string range $modName 3 end]
     }
     if {[regexp {[0-9\.]*(_g0)?$} $modName match]} {
Index: library/safe.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/safe.tcl,v
retrieving revision 1.8
diff -u -r1.8 safe.tcl
--- library/safe.tcl	22 Feb 2002 19:51:29 -0000	1.8
+++ library/safe.tcl	13 Jan 2003 22:06:46 -0000
@@ -673,7 +673,7 @@
     proc TranslatePath {slave path} {
 	# somehow strip the namespaces 'functionality' out (the danger
 	# is that we would strip valid macintosh "../" queries... :
-	if {[regexp {(::)|(\.\.)} $path]} {
+	if {[string match "*::*" $path] || [string match "*..*" $path]} {
 	    error "invalid characters in path $path"
 	}
 	set n [expr {[Set [PathNumberName $slave]]-1}]
Index: library/http/http.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/http/http.tcl,v
retrieving revision 1.43
diff -u -r1.43 http.tcl
--- library/http/http.tcl	3 Oct 2002 13:34:32 -0000	1.43
+++ library/http/http.tcl	13 Jan 2003 22:06:47 -0000
@@ -678,8 +678,9 @@
 	} elseif {$n == 0} {
 	    variable encodings
 	    set state(state) body
-	    if {$state(-binary) || ![regexp -nocase ^text $state(type)] || \
-		    [regexp gzip|compress $state(coding)]} {
+	    if {$state(-binary) || ![string match -nocase "text*" $state(type)] || \
+		    [string match "*gzip*" $state(coding)] || \\
+		    [string match "*compress*" $state(coding)] } {
 		# Turn off conversions for non-text data
 		fconfigure $s -translation binary
 		if {[info exists state(-channel)]} {
@@ -716,7 +717,7 @@
 	    }
 	    if {[regexp -nocase {^([^:]+):(.+)$} $line x key value]} {
 		lappend state(meta) $key [string trim $value]
-	    } elseif {[regexp ^HTTP $line]} {
+	    } elseif {[string match "HTTP*" $line]} {
 		set state(http) $line
 	    }
 	}
Index: library/http1.0/http.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/http1.0/http.tcl,v
retrieving revision 1.4
diff -u -r1.4 http.tcl
--- library/http1.0/http.tcl	1 Feb 2000 11:48:30 -0000	1.4
+++ library/http1.0/http.tcl	13 Jan 2003 22:06:47 -0000
@@ -109,8 +109,8 @@
 	if {[regexp $pat $flag]} {
 	    # Validate numbers
 	    if {[info exists state($flag)] && \
-		    [regexp {^[0-9]+$} $state($flag)] && \
-		    ![regexp {^[0-9]+$} $value]} {
+		    [string is integer $state($flag)] && \
+		    ![string is integer $value]} {
 		return -code error "Bad value for $flag ($value), must be integer"
 	    }
 	    set state($flag) $value
Index: library/opt/optparse.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/opt/optparse.tcl,v
retrieving revision 1.8
diff -u -r1.8 optparse.tcl
--- library/opt/optparse.tcl	23 Nov 2002 01:41:35 -0000	1.8
+++ library/opt/optparse.tcl	13 Jan 2003 22:06:48 -0000
@@ -811,15 +811,15 @@
         }
     }
 
-    # Auto magic lasy type determination
+    # Auto magic lazy type determination
     proc OptGuessType {arg} {
-        if {[regexp -nocase {^(true|false)$} $arg]} {
+ 	 if { $arg == "true" || $arg == "false" } {
             return boolean
         }
-        if {[regexp {^(-+)?[0-9]+$} $arg]} {
+        if {[string is integer $arg]} {
             return int
         }
-        if {![catch {expr {double($arg)}}]} {
+        if {[string is double $arg]} {
             return float
         }
         return string
Index: tools/genStubs.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/tools/genStubs.tcl,v
retrieving revision 1.13
diff -u -r1.13 genStubs.tcl
--- tools/genStubs.tcl	4 Oct 2002 08:25:14 -0000	1.13
+++ tools/genStubs.tcl	13 Jan 2003 22:06:49 -0000
@@ -184,7 +184,7 @@
 
     while {![eof $in]} {
 	set line [gets $in]
-	if {[regexp {!BEGIN!} $line]} {
+	if {[string match "*!BEGIN!*" $line]} {
 	    break
 	}
 	puts $out $line
@@ -193,7 +193,7 @@
     puts $out $text
     while {![eof $in]} {
 	set line [gets $in]
-	if {[regexp {!END!} $line]} {
+	if {[string match "*!END!*" $line]} {
 	    break
 	}
     }
Index: tools/tcltk-man2html.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/tools/tcltk-man2html.tcl,v
retrieving revision 1.4
diff -u -r1.4 tcltk-man2html.tcl
--- tools/tcltk-man2html.tcl	4 May 2001 00:05:00 -0000	1.4
+++ tools/tcltk-man2html.tcl	13 Jan 2003 22:06:51 -0000
@@ -1582,7 +1582,7 @@
 	}
 	puts $afp "</H2><HR><DL>"
 	foreach k $keys {
-	    if {[regexp -nocase -- "^keyword-$a" $k]} {
+	    if {[string match -nocase "keyword-${a}*" $k]} {
 		set k [string range $k 8 end]
 		puts $afp "<DT><A NAME=\"$k\">$k</A><DD>"
 		set refs {}
Index: unix/mkLinks.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/mkLinks.tcl,v
retrieving revision 1.8
diff -u -r1.8 mkLinks.tcl
--- unix/mkLinks.tcl	25 Jun 2002 16:34:33 -0000	1.8
+++ unix/mkLinks.tcl	13 Jan 2003 22:06:51 -0000
@@ -75,7 +75,7 @@
     while {[gets $in line] >= 0} {
 	switch $state {
 	    begin {
-		if {[regexp "^.SH NAME" $line]} {
+		if {[string match ".SH NAME*" $line]} {
 		    set state name
 		}
 	    }