From 8a7e35d9a03d22349adab8355d319cbdc3710b89 Mon Sep 17 00:00:00 2001 From: "Robert R. Henry" Date: Sat, 17 Apr 1982 01:55:07 -0800 Subject: [PATCH] Fixed buffering bug. Fix bug in string assembly with back slash escaped numerical constants SCCS-vsn: old/as.vax/asscan2.c 4.4 --- usr/src/old/as.vax/asscan2.c | 46 ++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/usr/src/old/as.vax/asscan2.c b/usr/src/old/as.vax/asscan2.c index fcdc3d8c9f..077a087e7d 100644 --- a/usr/src/old/as.vax/asscan2.c +++ b/usr/src/old/as.vax/asscan2.c @@ -2,7 +2,7 @@ * Copyright (c) 1982 Regents of the University of California */ #ifndef lint -static char sccsid[] = "@(#)asscan2.c 4.3 %G%"; +static char sccsid[] = "@(#)asscan2.c 4.4 %G%"; #endif not lint #include "asscanl.h" @@ -42,12 +42,16 @@ static char *InBufPtr = 0; static char p_swapped = '\0'; static char *p_start = &inbuffer[NINBUFFERS * BUFSIZ]; static char *p_stop = &inbuffer[NINBUFFERS * BUFSIZ]; + char *fillinbuffer() { register char *to; register char *from; char *inbufptr; int nread; + static int hadeof; + int goal; + int got; *p_start = p_swapped; inbufptr = &inbuffer[1*BUFSIZ] - (p_stop - p_start); @@ -57,13 +61,40 @@ char *fillinbuffer() /* * Now, go read two full buffers (hopefully) */ - nread = read(stdin->_file, &inbuffer[1*BUFSIZ], (NINBUFFERS - 1)*BUFSIZ); + if (hadeof){ + hadeof = 0; + return (0); + } + goal = (NINBUFFERS - 1)*BUFSIZ; + nread = 0; + do { + got = read(stdin->_file, &inbuffer[1*BUFSIZ + nread], goal); + if (got == 0) + hadeof = 1; + if (got <= 0) + break; + nread += got; + goal -= got; + } while (goal); + if (nread == 0) return(0); p_stop = from = &inbuffer[1*BUFSIZ + nread]; *from = '\0'; - while (*--from != '\n') /* back over the partial line */ - continue; + + while (*--from != '\n'){ + /* + * back over the partial line + */ + if (from == &inbuffer[1*BUFSIZ]) { + from = p_stop; + *p_stop++ = '\n'; + break; + } else { + continue; + } + } + from++; /* first char of partial line */ p_start = from; p_swapped = *p_start; @@ -376,13 +407,14 @@ scan_dot_s(bufferbox) && !(INCHARSET( (ch = getchar()), STRESCAPE)) ){ stuff: - maxstrlg-= 1; + maxstrlg -= 1; pchar(bufptr, ch); } if (maxstrlg <= 0){ /*enough characters to fill a string buffer*/ ungetc('"'); /*will read it next*/ } - else if (ch == '"'); /*done*/ + else if (ch == '"') + /*VOID*/ ; /*done*/ else if (ch == '\n'){ yywarning("New line embedded in a string constant."); scanlineno++; @@ -422,7 +454,7 @@ scan_dot_s(bufferbox) ch = getchar(); } ungetc(ch); - val = (char)intval; + ch = (char)intval; goto stuff; } /* -- 2.20.1