From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Thu, 26 Apr 2001 21:57:37 +0000 (+0000)
Subject: If some of the constants are prefixes of others,
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2facaf7c4dbd4158cb2080211e446e7fc84d66d8;p=p5sagit%2Fp5-mst-13.2.git

If some of the constants are prefixes of others,
the prefixes may never get recognized.  (See 20010426.006.)

p4raw-id: //depot/perl@9870
---

diff --git a/utils/h2xs.PL b/utils/h2xs.PL
index 1b4f387..48cfe53 100644
--- a/utils/h2xs.PL
+++ b/utils/h2xs.PL
@@ -1242,12 +1242,25 @@ END
     errno = 0;
 END
 
-  print $fh <<"END" if $off;
-    if ($offarg + $off >= len ) {
+  if ($off) {
+      my $null = 0;
+
+      foreach my $letter (keys %leading) {
+	  if ($letter eq '') {
+	      $null = 1;
+	      break;
+	  }
+      }
+
+      my $cmp = $null ? '>' : '>=';
+
+      print $fh <<"END"
+    if ($offarg + $off $cmp len ) {
 	errno = EINVAL;
 	return 0;
     }
 END
+  }
 
   print $fh <<"END";
     switch (name[$offarg + $off]) {