This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regen/utf8_strings.pl: Allow explicit default on input
[perl5.git] / regen / utf8_strings.pl
index 0c703f8..b868e59 100644 (file)
@@ -26,17 +26,19 @@ print $out_fh <<END;
 
 END
 
 
 END
 
-# The data are at the end of this file.  Each line represents one #define.
-# Each line begins with either a Unicode character name with the blanks in it
-# squeezed out or replaced by underscores; or it may be a hexadecimal code
-# point.  In the latter case, the name will be looked-up to use as the name
-# of the macro.  In either case, the macro name will have suffixes as
-# listed above, and all blanks will be replaced by underscores.
+# The data are at the end of this file.  A blank line is output as-is.
+# Otherwise, each line represents one #define, and begins with either a
+# Unicode character name with the blanks in it squeezed out or replaced by
+# underscores; or it may be a hexadecimal Unicode code point.  In the latter
+# case, the name will be looked-up to use as the name of the macro.  In either
+# case, the macro name will have suffixes as listed above, and all blanks will
+# be replaced by underscores.
 #
 # Each line may optionally have one of the following flags on it, separated by
 # white space from the initial token.
 #
 # Each line may optionally have one of the following flags on it, separated by
 # white space from the initial token.
-#   first   indicates that the output is to be of the FIRST_BYTE form
+#   string  indicates that the output is to be of the string form
 #           described in the comments above that are placed in the file.
 #           described in the comments above that are placed in the file.
+#   first   indicates that the output is to be of the FIRST_BYTE form.
 #   tail    indicates that the output is of the _TAIL form.
 #
 # This program is used to make it convenient to create compile time constants
 #   tail    indicates that the output is of the _TAIL form.
 #
 # This program is used to make it convenient to create compile time constants
@@ -44,6 +46,11 @@ END
 # having to figure things out.
 
 while ( <DATA> ) {
 # having to figure things out.
 
 while ( <DATA> ) {
+    if ($_ !~ /\S/) {
+        print $out_fh "\n";
+        next;
+    }
+
     chomp;
     unless ($_ =~ m/ ^ ( [^\ ]* )           # Name or code point token
                        (?: [\ ]+ ( .* ) )?  # optional flag
     chomp;
     unless ($_ =~ m/ ^ ( [^\ ]* )           # Name or code point token
                        (?: [\ ]+ ( .* ) )?  # optional flag
@@ -78,7 +85,7 @@ while ( <DATA> ) {
                        unpack("U0C*", pack("U", hex $cp));
 
     my $suffix = '_UTF8';
                        unpack("U0C*", pack("U", hex $cp));
 
     my $suffix = '_UTF8';
-    if (! defined $flag) {
+    if (! defined $flag  || $flag eq 'string') {
         $str = "\"$str\"";  # Will be a string constant
     } elsif ($flag eq 'tail') {
             $str =~ s/\\x..//;  # Remove the first byte
         $str = "\"$str\"";  # Will be a string constant
     } elsif ($flag eq 'tail') {
             $str =~ s/\\x..//;  # Remove the first byte
@@ -101,14 +108,17 @@ print $out_fh "\n#endif /* H_UTF8_STRINGS */\n";
 read_only_bottom_close_and_rename($out_fh);
 
 __DATA__
 read_only_bottom_close_and_rename($out_fh);
 
 __DATA__
-0300
-0301
-0308
-03B9 tail
-03C5 tail
+0300 string
+0301 string
+0308 string
+
 03B9 first
 03B9 first
+03B9 tail
+
 03C5 first
 03C5 first
+03C5 tail
+
 1100
 1160
 11A8
 1100
 1160
 11A8
-2010
+2010 string