develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34095 - trunk/tools/build

From:
chromatic
Date:
December 18, 2008 18:05
Subject:
[svn:parrot] r34095 - trunk/tools/build
Message ID:
20081219020504.267ADCBA12@x12.develooper.com
Author: chromatic
Date: Thu Dec 18 18:05:03 2008
New Revision: 34095

Modified:
   trunk/tools/build/c2str.pl

Log:
[tools] Added an exception to c2str.pl when a CONST_STRING macro occurs after a
linebreak.  The regex to detect this may need tweaking in the future, but this
should prevent weird error messages on compilers with very picky #line
handling.

Modified: trunk/tools/build/c2str.pl
==============================================================================
--- trunk/tools/build/c2str.pl	(original)
+++ trunk/tools/build/c2str.pl	Thu Dec 18 18:05:03 2008
@@ -131,23 +131,37 @@
 
     # There is a chance that the same __LINE__ will reoccur if #line directives
     # are used.
+    my $prev_line;
     my %lines_seen;
+
     while (<$IN>) {
         if (m/^\s*#\s*line\s+(\d+)/) {
 
             # #line directive
             $line = $1 - 1;
+            $prev_line = $_;
             next;
         }
         $line++;
-        next if m/^\s*#/;    # otherwise ignore preprocessor
-        next unless s/.*\bCONST_STRING(_GEN)?\s*\(\w+\s*,//;
+        # otherwise ignore preprocessor
+
+        do { $prev_line = $_; next } if m/^\s*#/;
+        do { $prev_line = $_; next }
+            unless s/.*\bCONST_STRING(_GEN)?\s*\(\w+\s*,//;
+
         my $const_string = defined $1 ? 'CONST_STRING_GEN' : 'CONST_STRING';
 
         if ( $lines_seen{"$line:$const_string"}++ ) {
             die "Seen line $line before in $infile - can't continue";
         }
 
+        # semicolons, blank lines, opening braces, closing parens, #directives
+        # comments, labels, else keyword
+        if ($prev_line !~ /([{});:]|\*\/|\w+:|else)$/
+        &&  $prev_line !~ /^\s*(#.*)?$/) {
+            die "CONST_STRING split across lines at $line in $infile\n";
+        }
+
         my $str = extract_delimited;    # $_, '"';
         $str    = substr $str, 1, -1;
         ## print STDERR "** '$str' $line\n";
@@ -161,8 +175,10 @@
                 print "#define _${const_string}_$line $n\n";
             }
             $this_file_seen{"$const_string:$str"} = $line;
+            $prev_line = $_;
             next;
         }
+
         my $len               = get_length($str);
         my $hashval           = hash_val($str);
         push @all_strings, [ $len, $hashval, $str ];



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About