This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
With shared hash key scalars now accessing the hash via the PVX, you
[perl5.git] / utils / h2xs.PL
index 2e8e23e..a9ff420 100644 (file)
@@ -522,8 +522,9 @@ OPTIONS:
     -O, --overwrite-ok    Allow overwriting of a pre-existing extension directory.
     -P, --omit-pod        Omit the stub POD section.
     -X, --omit-XS         Omit the XS portion (implies both -c and -f).
-    -a, --gen-accessors   Generate get/set accessors for struct and union members                           (used with -x).
-    -b, --compat-version  Specify a perl version to be backwards compatibile with
+    -a, --gen-accessors   Generate get/set accessors for struct and union members
+                          (used with -x).
+    -b, --compat-version  Specify a perl version to be backwards compatibile with.
     -c, --omit-constant   Omit the constant() function and specialised AUTOLOAD
                           from the XS file.
     -d, --debugging       Turn on debugging messages.
@@ -533,7 +534,7 @@ OPTIONS:
     -f, --force           Force creation of the extension even if the C header
                           does not exist.
     -g, --global          Include code for safely storing static data in the .xs file.
-    -h, -?, --help        Display this help message
+    -h, -?, --help        Display this help message.
     -k, --omit-const-func Omit 'const' attribute on function arguments
                           (used with -x).
     -m, --gen-tied-var    Generate tied variables for access to declared
@@ -543,14 +544,14 @@ OPTIONS:
     -p, --remove-prefix   Specify a prefix which should be removed from the
                           Perl function names.
     -s, --const-subs      Create subroutines for specified macros.
-    -t, --default-type    Default type for autoloaded constants (default is IV)
-        --use-new-tests   Use Test::More in backward compatible modules
-        --use-old-tests   Use the module Test rather than Test::More
-        --skip-exporter   Do not export symbols
-        --skip-ppport     Do not use portability layer
-        --skip-autoloader Do not use the module C<AutoLoader>
-        --skip-strict     Do not use the pragma C<strict>
-        --skip-warnings   Do not use the pragma C<warnings>
+    -t, --default-type    Default type for autoloaded constants (default is IV).
+        --use-new-tests   Use Test::More in backward compatible modules.
+        --use-old-tests   Use the module Test rather than Test::More.
+        --skip-exporter   Do not export symbols.
+        --skip-ppport     Do not use portability layer.
+        --skip-autoloader Do not use the module C<AutoLoader>.
+        --skip-strict     Do not use the pragma C<strict>.
+        --skip-warnings   Do not use the pragma C<warnings>.
     -v, --version         Specify a version number for this extension.
     -x, --autogen-xsubs   Autogenerate XSUBs using C::Scan.
 
@@ -638,10 +639,10 @@ usage if $opt_h;
 
 if( $opt_b ){
     usage "You cannot use -b and -m at the same time.\n" if ($opt_b && $opt_m);
-    $opt_b =~ /^\d+\.\d+\.\d+/ ||
+    $opt_b =~ /^v?(\d+)\.(\d+)\.(\d+)/ ||
     usage "You must provide the backwards compatibility version in X.Y.Z form. "
           .  "(i.e. 5.5.0)\n";
-    my ($maj,$min,$sub) = split(/\./,$opt_b,3);
+    my ($maj,$min,$sub) = ($1,$2,$3);
     if ($maj < 5 || ($maj == 5 && $min < 6)) {
         $compat_version =
            $sub ? sprintf("%d.%03d%02d",$maj,$min,$sub) :
@@ -900,9 +901,9 @@ if( @path_h ){
             next if $opt_e && $enum_name =~ /$opt_e/;
             my $val = 0;
             for my $item (split /,/, $enum_body) {
-                my ($key, $declared_val) = $item =~ /(\w*)\s*=\s*(.*)/;
-                $val = length($declared_val) ? $declared_val : 1 + $val;
-                $seen_define{$key} = $declared_val;
+                my ($key, $declared_val) = $item =~ /(\w+)\s*(?:=\s*(.*))?/;
+                $val = defined($declared_val) && length($declared_val) ? $declared_val : 1 + $val;
+                $seen_define{$key} = $val;
                 $const_names{$key}++;
             }
         } # while (...)