diff mbox series

[FFmpeg-devel,GASPP,1/2] Handle line continuations within gas-preprocessor

Message ID 20200923063917.19016-1-martin@martin.st
State New
Headers show
Series [FFmpeg-devel,GASPP,1/2] Handle line continuations within gas-preprocessor | expand

Checks

Context Check Description
andriy/default pending
andriy/configure warning Failed to apply patch

Commit Message

Martin Storsjö Sept. 23, 2020, 6:39 a.m. UTC
If preprocessing with cl.exe, the preprocessor doesn't take care of
concatenating continued lines.
---
 gas-preprocessor.pl | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index 126ee50..e9baeba 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -295,12 +295,11 @@  while (<INPUT>) {
     s/\r$//;
 
     foreach my $subline (split(";", $_)) {
-        # Add newlines at the end of lines that don't already have one
         chomp $subline;
-        $subline .= "\n";
-        parse_line($subline);
+        parse_line_continued($subline);
     }
 }
+parse_line_continued("");
 
 sub eval_expr {
     my $expr = $_[0];
@@ -383,6 +382,20 @@  sub parse_if_line {
     return 0;
 }
 
+my $last_line = "";
+sub parse_line_continued {
+    my $line = $_[0];
+    $last_line .= $line;
+    if ($last_line =~ /\\$/) {
+        $last_line =~ s/\\$//;
+    } else {
+        # Add newlines at the end of lines after concatenation.
+        $last_line .= "\n";
+        parse_line($last_line);
+        $last_line = "";
+    }
+}
+
 sub parse_line {
     my $line = $_[0];