summaryrefslogtreecommitdiff
path: root/bcc
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-07-28 22:10:50 +0200
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:47 +0200
commite6248da18100235ae33468d058e5b71fcefeff3b (patch)
tree4e3833ed515d03d2366c27f71ef0fe349a2dee12 /bcc
parent2060b4f4cc1c13975e495d088344825f7700181b (diff)
downloaddev86-e6248da18100235ae33468d058e5b71fcefeff3b.tar.gz
Import Dev86src-0.16.6.tar.gzv0.16.6
Diffstat (limited to 'bcc')
-rw-r--r--bcc/bcc.c76
-rw-r--r--bcc/input.c1
-rw-r--r--bcc/preproc.c51
-rw-r--r--bcc/scan.h1
-rw-r--r--bcc/table.c3
5 files changed, 95 insertions, 37 deletions
diff --git a/bcc/bcc.c b/bcc/bcc.c
index be59905..f7e7eb6 100644
--- a/bcc/bcc.c
+++ b/bcc/bcc.c
@@ -13,6 +13,7 @@
* -Ml i386 Linux
* -M8 CvW's c386
* -M9 MC6809 with bcc
+ * -M0 A framework for the -B option.
*/
#include <stdio.h>
#ifdef __STDC__
@@ -57,7 +58,7 @@
#define AS09 "as09" EXESUF
#define LD09 "ld09" EXESUF
-#define CPPBCC "bcc-cc1" EXESUF
+#define CPPBCC "bcc-cpp" EXESUF
#define CC1BCC "bcc-cc1" EXESUF
#define AS86 "as86" EXESUF
#define LD86 "ld86" EXESUF
@@ -78,11 +79,12 @@
struct command {
char * cmd;
+ char * altcmd;
char * fullpath;
int numargs;
int maxargs;
char ** arglist;
-} command = { 0,0,0,0,0 };
+} command = { 0,0,0,0,0,0 };
struct file_list {
struct file_list * next;
@@ -276,8 +278,14 @@ struct file_list * file;
{
int last_stage = 0;;
- if (opt_arch<5) command.cmd = CPPBCC;
- else command.cmd = CPP;
+ if (opt_arch<5 && !opt_e)
+ command.cmd = CC1BCC;
+ else if (opt_arch<5) {
+ command.cmd = CPPBCC;
+ command.altcmd = CC1BCC;
+ }
+ else
+ command.cmd = CPP;
command_reset();
if (!opt_e && !do_optim && !do_as ) last_stage =1;
@@ -285,7 +293,10 @@ struct file_list * file;
newfilename(file, last_stage, (opt_e?'i':'s'), (opt_arch<5));
- if (opt_e && opt_arch<5) command_opt("-E");
+ if (opt_e && opt_arch<5) {
+ command_opt("-E");
+ if (do_unproto) command_opt("-A");
+ }
command_opts('p');
if (!opt_e)
@@ -484,7 +495,7 @@ validate_link_opt(char * option)
break;
}
if (err)
- fprintf(stderr, "warning: linker option %s not unrecognised.\n", option);
+ fprintf(stderr, "warning: linker option %s not recognised.\n", option);
}
void
@@ -532,33 +543,40 @@ command_reset()
/* Search for the exe, nb as this will probably be called from 'make'
* there's not much point saving this.
*/
- for(prefix=exec_prefixs; *prefix; prefix++)
+ for(;;)
{
- char * p;
- if (*prefix == devnull) continue;
-
- p = strchr(*prefix, '~');
- if (!p) strcpy(buf, *prefix);
- else
+ for(prefix=exec_prefixs; *prefix; prefix++)
{
- memcpy(buf, *prefix, p-*prefix);
- buf[p-*prefix] = 0;
+ char * p;
+ if (*prefix == devnull) continue;
- strcat(buf, localprefix);
- strcat(buf, p+1);
- }
- strcat(buf, command.cmd);
+ p = strchr(*prefix, '~');
+ if (!p) strcpy(buf, *prefix);
+ else
+ {
+ memcpy(buf, *prefix, p-*prefix);
+ buf[p-*prefix] = 0;
- if (!*command.cmd)
- fprintf(stderr, "PATH+=%s\n", buf);
- else if (access(buf, X_OK) == 0)
- {
- command.fullpath = copystr(buf);
- break;
+ strcat(buf, localprefix);
+ strcat(buf, p+1);
+ }
+ strcat(buf, command.cmd);
+
+ if (!*command.cmd)
+ fprintf(stderr, "PATH+=%s\n", buf);
+ else if (access(buf, X_OK) == 0)
+ {
+ command.fullpath = copystr(buf);
+ break;
+ }
}
+ if (command.fullpath || !command.altcmd) break;
+ command.cmd = command.altcmd;
}
+
if (!command.fullpath)
command.fullpath = copystr(command.cmd);
+ command.altcmd = 0;
}
void
@@ -698,7 +716,7 @@ char ** argv;
/* Special case -? is different from -?abcdef */
if(!pflag && argv[ar][2] == 0) switch(argv[ar][1])
{
- case 'a': case 'L': case 'M': case 'O': case 'P': case 'Q':
+ case 'a': case 'L': case 'I': case 'M': case 'O': case 'P': case 'Q':
pflag = argv[ar]+1;
used_arg = 0;
break;
@@ -710,8 +728,12 @@ char ** argv;
if(strcmp(argv[ar], "-ansi") == 0) {
do_unproto = 1;
opt_e = 1;
- /* NOTE I'm setting this to zero, this isn't a _real_ STDC */
+#if 1
+ /* NOTE I'm setting this to zero, this isn't a _real_ Ansi cpp. */
prepend_option("-D__STDC__=0", 'p');
+#else
+ prepend_option("-D__STDC__", 'p');
+#endif
}
else
Usage();
diff --git a/bcc/input.c b/bcc/input.c
index b89eb78..259ae04 100644
--- a/bcc/input.c
+++ b/bcc/input.c
@@ -511,6 +511,7 @@ char *argv[];
case 't': /* print source code in asm output */
case 'w': /* watch location counter */
case 'O': /* Optimisation. */
+ case 'A': /* Ansi mode. */
if (arg[2] == 0)
flag[(int)arg[1]] = TRUE;
else if (arg[2] == '-' && arg[3] == 0)
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;
}
}
diff --git a/bcc/scan.h b/bcc/scan.h
index d1de894..48ff5d2 100644
--- a/bcc/scan.h
+++ b/bcc/scan.h
@@ -172,6 +172,7 @@ enum scan_states
LINECNTL,
UNDEFCNTL,
WARNINGCNTL,
+ ERRORCNTL,
ELIFCNTL, /* "IF" controls must be contiguous */
ELSECNTL,
diff --git a/bcc/table.c b/bcc/table.c
index 203b4fb..79dcf62 100644
--- a/bcc/table.c
+++ b/bcc/table.c
@@ -30,7 +30,7 @@
#define MAXEXPR 500
#endif
#define MAXLOCAL 100
-#define NKEYWORDS 38
+#define NKEYWORDS 39
#ifdef NOFLOAT
#define NSCALTYPES 10
#else
@@ -128,6 +128,7 @@ PRIVATE struct keywordstruct keywords[NKEYWORDS] =
{ "#line", LINECNTL, },
{ "#undef", UNDEFCNTL, },
{ "#warning", WARNINGCNTL, },
+ { "#error", ERRORCNTL, },
{ "defined", DEFINEDSYM, }, /* should be deactivated except in #if's */
};