diff options
author | Anders Magnusson <ragge@cvs.openbsd.org> | 2008-01-12 17:58:30 +0000 |
---|---|---|
committer | Anders Magnusson <ragge@cvs.openbsd.org> | 2008-01-12 17:58:30 +0000 |
commit | b57c92d41f744c900cae9201c4319409b1f8825d (patch) | |
tree | 1c5f06788e724fee9e8131ddd0deaf4fccb65811 /usr.bin | |
parent | 2dce4761cf71c47669692689feb164e881aeb186 (diff) |
Updates from master repo:
> Fix whitespace bug.
> Define __STDC_VERSION__ to 199901L.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/pcc/cpp/cpp.1 | 18 | ||||
-rw-r--r-- | usr.bin/pcc/cpp/cpp.c | 46 | ||||
-rw-r--r-- | usr.bin/pcc/cpp/scanner.l | 16 |
3 files changed, 59 insertions, 21 deletions
diff --git a/usr.bin/pcc/cpp/cpp.1 b/usr.bin/pcc/cpp/cpp.1 index dcba1e3a99e..2f4606ee011 100644 --- a/usr.bin/pcc/cpp/cpp.1 +++ b/usr.bin/pcc/cpp/cpp.1 @@ -1,6 +1,6 @@ -.\" $Id: cpp.1,v 1.2 2007/10/27 12:50:50 ragge Exp $ +.\" $Id: cpp.1,v 1.3 2008/01/12 17:58:29 ragge Exp $ .\" $NetBSD$ -.\" $OpenBSD: cpp.1,v 1.2 2007/10/27 12:50:50 ragge Exp $ +.\" $OpenBSD: cpp.1,v 1.3 2008/01/12 17:58:29 ragge Exp $ ."\ .\" Copyright (c) 2007 Jeremy C. Reed <reed@reedmedia.net> .\" @@ -118,8 +118,9 @@ Traditional cpp syntax. Do not define the .Dv __TIME__ , .Dv __DATE__ , +.Dv __STDC__ , and -.Dv __STDC__ +.Dv __STDC_VERSION__ , macros. .\" .It Fl U Ar macro @@ -155,7 +156,16 @@ When read from standard input, it expands to Expands to the line number of the current line containing the macro. .It __STDC__ Expands to the constant 1. -This means the compiler conforms to ISO Standard C. +This means the compiler conforms to ISO Standard C, +ISO/IEC 9899:1990 +.Po also known as +.Do C90 Dc Pc . +.It __STDC_VERSION__ +Expands to +.Dq 199901L +which indicates it supports ISO/IEC 9899:1999 standard +.Po commonly referred to as +.Do C99 Dc Pc . .It __TIME__ Expands to the time in hour, minutes, and seconds from .Xr ctime 3 diff --git a/usr.bin/pcc/cpp/cpp.c b/usr.bin/pcc/cpp/cpp.c index 8343f3077bf..b2f9702f35a 100644 --- a/usr.bin/pcc/cpp/cpp.c +++ b/usr.bin/pcc/cpp/cpp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpp.c,v 1.7 2007/12/09 21:11:42 ragge Exp $ */ +/* $OpenBSD: cpp.c,v 1.8 2008/01/12 17:58:29 ragge Exp $ */ /* * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). @@ -263,6 +263,10 @@ main(int argc, char **argv) nl = lookup((usch *)"__STDC__", ENTER); savch(0); savch('1'); savch(OBJCT); nl->value = stringbuf-1; + + nl = lookup((usch *)"__STDC_VERSION__", ENTER); + savch(0); savstr((usch *)"199901L"); savch(OBJCT); + nl->value = stringbuf-1; } if (Mflag && !dMflag) { @@ -795,7 +799,7 @@ static void pragoper(void) { usch *opb; - int t; + int t, plev; slow = 1; putstr((usch *)"\n#pragma "); @@ -806,27 +810,39 @@ pragoper(void) if ((t = yylex()) == WSPACE) t = yylex(); opb = stringbuf; - while (t != ')') { + for (plev = 0; ; t = yylex()) { + if (t == '(') + plev++; + if (t == ')') + plev--; + if (plev < 0) + break; savstr((usch *)yytext); - t = yylex(); } + savch(0); cunput(WARN); unpstr(opb); stringbuf = opb; expmac(NULL); + cunput('\n'); while (stringbuf > opb) cunput(*--stringbuf); - if ((t = yylex()) != STRING) - goto bad; - opb = (usch *)yytext; - if (*opb++ == 'L') - opb++; - while ((t = *opb++) != '\"') { - if (t == '\\' && (*opb == '\"' || *opb == '\\')) - t = *opb++; - putch(t); + while ((t = yylex()) != '\n') { + if (t == WSPACE) + continue; + if (t != STRING) + goto bad; + opb = (usch *)yytext; + if (*opb++ == 'L') + opb++; + while ((t = *opb++) != '\"') { + if (t == '\\' && (*opb == '\"' || *opb == '\\')) + t = *opb++; + putch(t); + } } + putch('\n'); prtline(); return; @@ -1149,7 +1165,9 @@ expdef(vp, rp, gotwarn) } if (narg == 0 && ellips == 0) - c = yylex(); + while ((c = yylex()) == WSPACE || c == '\n') + ; + if (c != ')' || (i != narg && ellips == 0) || (i < narg && ellips == 1)) error("wrong arg count"); diff --git a/usr.bin/pcc/cpp/scanner.l b/usr.bin/pcc/cpp/scanner.l index eed538e8d77..5e155d30d52 100644 --- a/usr.bin/pcc/cpp/scanner.l +++ b/usr.bin/pcc/cpp/scanner.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scanner.l,v 1.7 2007/12/09 21:11:42 ragge Exp $ */ +/* $OpenBSD: scanner.l,v 1.8 2008/01/12 17:58:29 ragge Exp $ */ /* * Copyright (c) 2004 Anders Magnusson. All rights reserved. @@ -618,6 +618,8 @@ elsestmt(void) static void ifdefstmt(void) { + int t; + if (flslvl) { /* just ignore the rest of the line */ while (input() != '\n') @@ -628,7 +630,10 @@ ifdefstmt(void) return; } slow = 1; - if (yylex() != WSPACE || yylex() != IDENT) + do + t = yylex(); + while (t == WSPACE); + if (t != IDENT) error("bad ifdef"); slow = 0; if (flslvl == 0 && lookup((usch *)yytext, FIND) != 0) @@ -641,8 +646,13 @@ ifdefstmt(void) static void ifndefstmt(void) { + int t; + slow = 1; - if (yylex() != WSPACE || yylex() != IDENT) + do + t = yylex(); + while (t == WSPACE); + if (t != IDENT) error("bad ifndef"); slow = 0; if (flslvl == 0 && lookup((usch *)yytext, FIND) == 0) |