summaryrefslogtreecommitdiff
path: root/usr.bin/pcc
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-09-17 18:29:21 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-09-17 18:29:21 +0000
commit93c6079912cf83ba58dc300341a108bd8257b13c (patch)
tree2ec8d235fe1a7d4cb63ac1447a5d88aaa50856ba /usr.bin/pcc
parent1c27baa68a04273c33ad33b1f0bd02451d148bb9 (diff)
merge from ragge's repo:
Add -dM for preprocessor, by Todd T. Fries.
Diffstat (limited to 'usr.bin/pcc')
-rw-r--r--usr.bin/pcc/cc/cc/cc.c4
-rw-r--r--usr.bin/pcc/cc/cpp/cpp.c57
-rw-r--r--usr.bin/pcc/cc/cpp/cpp.h4
-rw-r--r--usr.bin/pcc/cc/cpp/scanner.l19
4 files changed, 25 insertions, 59 deletions
diff --git a/usr.bin/pcc/cc/cc/cc.c b/usr.bin/pcc/cc/cc/cc.c
index a49659ff4e9..1b3eccf61d7 100644
--- a/usr.bin/pcc/cc/cc/cc.c
+++ b/usr.bin/pcc/cc/cc/cc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cc.c,v 1.4 2007/09/17 07:40:06 otto Exp $ */
+/* $Id: cc.c,v 1.5 2007/09/17 18:29:20 otto Exp $ */
/*
* Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
*
@@ -371,6 +371,8 @@ main(int argc, char *argv[])
av[na++] = "-D_PTHREADS";
if (Mflag)
av[na++] = "-M";
+ if (dflag)
+ av[na++] = alist;
for (j = 0; cppadd[j]; j++)
av[na++] = cppadd[j];
for (j = 0; cppmdadd[j]; j++)
diff --git a/usr.bin/pcc/cc/cpp/cpp.c b/usr.bin/pcc/cc/cpp/cpp.c
index 7441c49d893..8fe6ea6e47f 100644
--- a/usr.bin/pcc/cc/cpp/cpp.c
+++ b/usr.bin/pcc/cc/cpp/cpp.c
@@ -1,4 +1,4 @@
-/* $Id: cpp.c,v 1.4 2007/09/17 07:40:06 otto Exp $ */
+/* $Id: cpp.c,v 1.5 2007/09/17 18:29:20 otto Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -106,7 +106,7 @@ int dflag; /* debug printouts */
int ofd;
usch outbuf[CPPBUF];
int obufp, istty;
-int Cflag, Mflag;
+int Cflag, Mflag, dMflag;
usch *Mfile;
struct initar *initar;
@@ -175,9 +175,8 @@ main(int argc, char **argv)
struct incs *w, *w2;
struct symtab *nl;
register int ch;
-// usch *osp;
- while ((ch = getopt(argc, argv, "CD:I:MS:U:di:t")) != -1)
+ while ((ch = getopt(argc, argv, "CD:I:MS:U:d:i:tv")) != -1)
switch (ch) {
case 'C': /* Do not discard comments */
Cflag++;
@@ -193,30 +192,6 @@ main(int argc, char **argv)
it->str = optarg;
it->next = initar;
initar = it;
-#if 0
- osp = (usch *)optarg;
- while (*osp && *osp != '=')
- osp++;
- if (*osp == '=') {
- *osp++ = 0;
- while (*osp)
- osp++;
- *osp = OBJCT;
- } else {
- static usch c[3] = { 0, '1', OBJCT };
- osp = &c[2];
- }
- nl = lookup((usch *)optarg, ENTER);
- if (nl->value) {
- /* check for redefinition */
- usch *o = nl->value, *n = osp;
- while (*o && *o == *n)
- o--, n--;
- if (*o || *o != *n)
- error("%s redefined", optarg);
- }
- nl->value = osp;
-#endif
break;
case 'M': /* Generate dependencies for make */
@@ -237,28 +212,22 @@ main(int argc, char **argv)
incdir[ch == 'I' ? INCINC : SYSINC] = w;
break;
-#if 0
- case 'U':
- if ((nl = lookup((usch *)optarg, FIND)))
- nl->value = NULL;
- break;
-#endif
#ifdef CPP_DEBUG
- case 'd':
+ case 'v':
dflag++;
break;
#endif
- case 't':
- tflag = 1;
+ case 'd':
+ if (optarg[0] == 'M') {
+ dMflag = 1;
+ Mflag = 1;
+ }
+ /* ignore others */
break;
-#if 0
- case 'i':
- if (ifile)
- error("max 1 -i entry");
- ifile = optarg;
+ case 't':
+ tflag = 1;
break;
-#endif
case '?':
usage();
@@ -294,7 +263,7 @@ main(int argc, char **argv)
nl->value = stringbuf-1;
}
- if (Mflag) {
+ if (Mflag && !dMflag) {
usch *c;
if (argc < 1)
diff --git a/usr.bin/pcc/cc/cpp/cpp.h b/usr.bin/pcc/cc/cpp/cpp.h
index 5abca41c3e9..95fcf0fc940 100644
--- a/usr.bin/pcc/cc/cpp/cpp.h
+++ b/usr.bin/pcc/cc/cpp/cpp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpp.h,v 1.2 2007/09/15 22:04:39 ray Exp $ */
+/* $Id: cpp.h,v 1.3 2007/09/17 18:29:20 otto Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
@@ -44,7 +44,7 @@ extern int flslvl;
extern int elflvl;
extern int elslvl;
extern int tflag, Cflag;
-extern int Mflag;
+extern int Mflag, dMflag;
extern usch *Mfile;
extern int ofd;
diff --git a/usr.bin/pcc/cc/cpp/scanner.l b/usr.bin/pcc/cc/cpp/scanner.l
index 25bf1f26944..45704c294bd 100644
--- a/usr.bin/pcc/cc/cpp/scanner.l
+++ b/usr.bin/pcc/cc/cpp/scanner.l
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: scanner.l,v 1.3 2007/09/16 18:52:52 otto Exp $ */
+/* $OpenBSD: scanner.l,v 1.4 2007/09/17 18:29:20 otto Exp $ */
/*
* Copyright (c) 2004 Anders Magnusson. All rights reserved.
@@ -374,6 +374,8 @@ prinit(struct initar *it, struct includ *ic)
pre = "#include \"";
post = "\"\n";
break;
+ default:
+ error("prinit");
}
strcat((char *)ic->buffer, pre);
strcat((char *)ic->buffer, it->str);
@@ -418,19 +420,10 @@ pushfile(usch *file)
if (initar) {
*ic->maxread = 0;
prinit(initar, ic);
+ if (dMflag)
+ write(ofd, ic->buffer, strlen((char *)ic->buffer));
initar = NULL;
}
-#if 0
- if (old == NULL && ifile != NULL) {
- strcpy((char *)ic->buffer, "#include \"");
- strcat((char *)ic->buffer, ifile);
- strcat((char *)ic->buffer, "\"\n");
- while (*ic->maxread)
- ic->maxread++;
- ic->lineno = 0;
- ifile = NULL;
- }
-#endif
otrulvl = trulvl;
@@ -454,6 +447,8 @@ prtline()
usch *s, *os = stringbuf;
if (Mflag) {
+ if (dMflag)
+ return; /* no output */
if (ifiles->lineno == 1) {
s = sheap("%s: %s\n", Mfile, ifiles->fname);
write(ofd, s, strlen((char *)s));