Have preprocessor strip all DOS returns

git-svn-id: file://localhost/svn/verilator/trunk/verilator@788 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder
2006-09-13 14:38:48 +00:00
parent f283076570
commit f9697463cc
6 changed files with 87 additions and 44 deletions
+10 -8
View File
@@ -537,10 +537,12 @@ int V3PreProcImp::getRawToken() {
int tok = yylex();
if (debug()>4) {
char buf[10000]; strncpy(buf, yytext, yyleng); buf[yyleng] = '\0';
for (char* cp=buf; *cp; cp++) if (*cp=='\n') *cp='$';
string buf = string (yytext, yyleng);
string::size_type pos;
while ((pos=buf.find("\n")) != string::npos) { buf.replace(pos, 1, "\\n"); }
while ((pos=buf.find("\r")) != string::npos) { buf.replace(pos, 1, "\\r"); }
fprintf (stderr, "%d: RAW %d %d: %-10s: %s\n",
fileline()->lineno(), m_off, m_state, tokenName(tok), buf);
fileline()->lineno(), m_off, m_state, tokenName(tok), buf.c_str());
}
// On EOF, try to pop to upper level includes, as needed.
@@ -867,12 +869,12 @@ string V3PreProcImp::getline() {
while (NULL==(rtnp=strchr(m_lineChars.c_str(),'\n'))) {
int tok = getToken();
if (debug()>4) {
char buf[100000];
strncpy(buf, yytext, yyleng);
buf[yyleng] = '\0';
for (char* cp=buf; *cp; cp++) if (*cp=='\n') *cp='$';
string buf = string (yytext, yyleng);
string::size_type pos;
while ((pos=buf.find("\n")) != string::npos) { buf.replace(pos, 1, "\\n"); }
while ((pos=buf.find("\r")) != string::npos) { buf.replace(pos, 1, "\\r"); }
fprintf (stderr,"%d: GETFETC: %-10s: %s\n",
fileline()->lineno(), tokenName(tok), buf);
fileline()->lineno(), tokenName(tok), buf.c_str());
}
if (tok==VP_EOF) {
// Add a final newline, in case the user forgot the final \n.