2006-12-13 Paul Brook <paul@codesourcery.com>
[binutils-gdb.git] / gas / input-scrub.c
index 8562ee25dff38c8ac0fc116859125fd7d7bb9779..9efea1100e2a68c004c087f93fa80d9235e4e5b5 100644 (file)
@@ -1,6 +1,6 @@
 /* input_scrub.c - Break up input buffers into whole numbers of lines.
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   2000, 2001, 2003
+   2000, 2001, 2003, 2006
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -20,7 +20,6 @@
    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
    02110-1301, USA.  */
 
-#include <errno.h>             /* Need this to make errno declaration right */
 #include "as.h"
 #include "input-file.h"
 #include "sb.h"
 #define BEFORE_SIZE (1)
 #define AFTER_SIZE  (1)
 
+#ifndef TC_EOL_IN_INSN
+#define TC_EOL_IN_INSN(P) 0
+#endif
+
 static char *buffer_start;     /*->1st char of full buffer area.  */
 static char *partial_where;    /*->after last full line in buffer.  */
 static int partial_size;       /* >=0. Number of chars in partial line in buffer.  */
@@ -342,8 +345,9 @@ input_scrub_next_buffer (char **bufp)
   if (limit)
     {
       register char *p;                /* Find last newline.  */
-
-      for (p = limit - 1; *p != '\n'; --p)
+      /* Terminate the buffer to avoid confusing TC_EOL_IN_INSN.  */
+      *limit = '\0';
+      for (p = limit - 1; *p != '\n' || TC_EOL_IN_INSN (p); --p)
        ;
       ++p;
 
@@ -369,7 +373,9 @@ input_scrub_next_buffer (char **bufp)
              return NULL;
            }
 
-         for (p = limit - 1; *p != '\n'; --p)
+         /* Terminate the buffer to avoid confusing TC_EOL_IN_INSN.  */
+         *limit = '\0';
+         for (p = limit - 1; *p != '\n' || TC_EOL_IN_INSN (p); --p)
            ;
          ++p;
        }