Module Name:    src
Committed By:   christos
Date:           Fri Jan 27 23:36:04 UTC 2023

Modified Files:
        src/external/gpl3/binutils/dist/gas: app.c

Log Message:
When trying to scrub characters in a macro to convert:

    # 123 "foo.c" 1 -> .linefile 123"foo.c"1

check if there is space first. Otherwise give up.

On the vax it was trying to scrub:

    # 2672 "foo.c" 1
    emul %r2,%r0,$0,%r4
    # 0 "" 2

and ended up with an incomplete string:

    .linefile 2672"foo.c"1
    emul %r2,%r0,$0,%r4
    .
And then when the assembler tried to parse the next line after the emul
barfed with unknown pseudo-op .


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.9 -r1.2 src/external/gpl3/binutils/dist/gas/app.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/binutils/dist/gas/app.c
diff -u src/external/gpl3/binutils/dist/gas/app.c:1.1.1.9 src/external/gpl3/binutils/dist/gas/app.c:1.2
--- src/external/gpl3/binutils/dist/gas/app.c:1.1.1.9	Fri Dec 23 14:01:17 2022
+++ src/external/gpl3/binutils/dist/gas/app.c	Fri Jan 27 18:36:04 2023
@@ -410,7 +410,7 @@ do_scrub_chars (size_t (*get) (char *, s
 {
   char *to = tostart;
   char *toend = tostart + tolen;
-  char *from;
+  char *from, *savefrom;
   char *fromend;
   size_t fromlen;
   int ch, ch2 = 0;
@@ -1234,6 +1234,7 @@ do_scrub_chars (size_t (*get) (char *, s
 	     thought out.  On i386, we want '/' as line comment start
 	     AND we want C style comments.  hence this hack.  The
 	     whole lexical process should be reworked.  xoxorich.  */
+	  savefrom = from;
 	  if (ch == '/')
 	    {
 	      ch2 = GET ();
@@ -1294,6 +1295,11 @@ do_scrub_chars (size_t (*get) (char *, s
 		out_string = "\tlinefile ";
 	      else
 		out_string = "\t.linefile ";
+	      if (toend - to < strlen(out_string) + strlen(from) + 1)
+		{
+		  from = savefrom - 1;
+		  goto tofull;
+		}
 	      PUT (*out_string++);
 	      break;
 	    }

Reply via email to