summaryrefslogtreecommitdiff
path: root/bcc/preproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'bcc/preproc.c')
-rw-r--r--bcc/preproc.c51
1 files changed, 42 insertions, 9 deletions
diff --git a/bcc/preproc.c b/bcc/preproc.c
index e292329..1f35013 100644
--- a/bcc/preproc.c
+++ b/bcc/preproc.c
@@ -53,6 +53,7 @@ PRIVATE struct macroposition macrostack[MAX_MACRO];
FORWARD void asmcontrol P((void));
FORWARD void warningcntl P((void));
+FORWARD void errorcntl P((void));
FORWARD void control P((void));
FORWARD void defineorundefinestring P((char *str, bool_pt defineflag));
FORWARD void elifcontrol P((void));
@@ -157,20 +158,49 @@ PUBLIC void checknotinif()
}
}
+/* warningcntl() - process #warning */
-/* This is a major hack. It doesn't handle continued lines.
- * It does let me avoid wrapping warning directives though. */
PRIVATE void warningcntl()
{
- char *s = lineptr;
+ char estr[256], *ep = estr;
- while (*lineptr && (*lineptr != EOL)) {
- ++lineptr;
+ if (!orig_cppmode) {
+ *ep++ = '%'; *ep++ = 'w';
+ }
+ while( ch != EOL ) {
+ if (ep < estr+sizeof(estr)-2 )
+ *ep++ = ch;
+ gch1();
+ }
+ *ep = 0;
+
+ if (!orig_cppmode)
+ error(estr);
+ else {
+ outstr("#warning");
+ outnstr(estr);
+ }
+}
+
+/* errorcntl() - process #error */
+
+PRIVATE void errorcntl()
+{
+ char estr[256], *ep = estr;
+
+ while( ch != EOL ) {
+ if (ep < estr+sizeof(estr)-2 )
+ *ep++ = ch;
+ gch1();
+ }
+ *ep = 0;
+
+ if (!orig_cppmode)
+ error(estr);
+ else {
+ outstr("#error");
+ outnstr(estr);
}
- write(2, "warning: #warning", 17);
- write(2, s, lineptr - s);
- write(2, "\n", 1);
- ch = *lineptr;
}
/* control() - select and switch to control statement */
@@ -261,6 +291,9 @@ PRIVATE void control()
case WARNINGCNTL:
warningcntl();
break;
+ case ERRORCNTL:
+ errorcntl();
+ break;
}
}