summaryrefslogtreecommitdiff
path: root/bcc
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2004-01-24 16:27:32 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:49 +0200
commitbeba34dc223aa0dcf3e5f696966c5e8408b022c3 (patch)
treeea0523ac242bd3e877338e9a771b975d4cd3839a /bcc
parentb5dac1e3bdd01a2ce105df747a9073ff0d6a94e2 (diff)
downloaddev86-beba34dc223aa0dcf3e5f696966c5e8408b022c3.tar.gz
Import Dev86src-0.16.15.tar.gzv0.16.15
Diffstat (limited to 'bcc')
-rw-r--r--bcc/Makefile7
-rw-r--r--bcc/bcc-cc1.c2
-rw-r--r--bcc/bcc.c244
-rw-r--r--bcc/bcc.doc4
-rw-r--r--bcc/const.h1
-rw-r--r--bcc/declare.c2
-rw-r--r--bcc/input.c76
-rw-r--r--bcc/input.h5
-rw-r--r--bcc/output.c4
-rw-r--r--bcc/preproc.c20
-rw-r--r--bcc/scan.c31
11 files changed, 299 insertions, 97 deletions
diff --git a/bcc/Makefile b/bcc/Makefile
index 8c2c19b..8f13f6e 100644
--- a/bcc/Makefile
+++ b/bcc/Makefile
@@ -4,13 +4,12 @@
#
PREFIX=/usr
-LIBPRE=$(PREFIX)
CFLAGS =-O
LDFLAGS =-s
BINDIR =$(PREFIX)/bin
-LIBDIR =$(LIBPRE)/lib/bcc
-BCCDEFS =-DLOCALPREFIX=$(LIBPRE) -DBINDIR=$(BINDIR) -DDEFARCH=0
+LIBDIR =$(PREFIX)/lib/bcc
+BCCDEFS =-DLOCALPREFIX=$(PREFIX) -DBINDIR=$(BINDIR) -DDEFARCH=0
BCFLAGS=$(ANSI) $(CFLAGS) $(LDFLAGS)
@@ -31,7 +30,7 @@ bcc: bcc.c
$(CC) $(BCFLAGS) $(BCCDEFS) bcc.c -o $@
ncc: bcc.c
- $(CC) $(BCFLAGS) -DL_TREE -DDEFARCH=0 bcc.c -o $@
+ $(CC) $(BCFLAGS) -DLOCALPREFIX= -DDEFARCH=0 bcc.c -o $@
bcc09: bcc.c
$(CC) $(BCFLAGS) -DMC6809 $(BCCDEFS) bcc.c -o $@
diff --git a/bcc/bcc-cc1.c b/bcc/bcc-cc1.c
index 6f545be..7ba8be0 100644
--- a/bcc/bcc-cc1.c
+++ b/bcc/bcc-cc1.c
@@ -11,8 +11,10 @@ char **argv;
growheap(0); /* init order is important */
syminit();
etreeinit();
+#ifdef BUILTIN_CPP
ifinit();
predefine();
+#endif
openio(argc, argv);
codeinit();
typeinit();
diff --git a/bcc/bcc.c b/bcc/bcc.c
index 67e5469..5efc4c6 100644
--- a/bcc/bcc.c
+++ b/bcc/bcc.c
@@ -42,7 +42,6 @@
#define W_OK 2 /* Test for write permission. */
#define X_OK 1 /* Test for execute permission. */
#define F_OK 0 /* Test for existence. */
-#define L_TREE 1 /* Use different tree style */
#define DEFARCH 0 /* Default to 8086 code */
#include "version.h"
#else
@@ -132,6 +131,7 @@ char * tmpdir = "/tmp/";
int main P((int argc, char **argv));
void getargs P((int argc, char **argv));
void add_prefix P((char * path));
+void build_prefix P((char * path1, char * path2, char * path3));
void run_aspreproc P((struct file_list * file));
void run_preproc P((struct file_list * file));
void run_unproto P((struct file_list * file));
@@ -149,45 +149,35 @@ void validate_link_opts P((void));
void append_file P((char * filename, int ftype));
void append_option P((char * option, int otype));
void prepend_option P((char * option, int otype));
-char * expand_tilde P((char * str));
+char * build_libpath P((char * opt, char * str, char * suffix));
void * xalloc P((int size));
void Usage P((void));
void fatal P((char * why));
char * copystr P((char * str));
char * catstr P((char * str, char * str2));
-#ifdef L_TREE
-void reset_localprefix P((void));
-#endif
+void reset_prefix_path P((void));
void run_command P((struct file_list * file));
-#ifndef LOCALPREFIX
-#define LOCALPREFIX /usr
+char * prefix_path = "";
+
+#ifdef LOCALPREFIX
+char * localprefix = QUOT(LOCALPREFIX);
+#else
+char * localprefix = "/";
#endif
-char * localprefix = QUOT(LOCALPREFIX);
-#ifndef L_TREE
-char * default_include = "-I~/include";
-char * default_libdir0 = "-L~/lib/bcc/i86/";
-char * default_libdir3 = "-L~/lib/bcc/i386/";
-char * optim_rules = "-d~/lib/bcc/i86";
+
+/* These paths are NATIVE install paths, change others below */
+char * default_include = "/usr/include";
+char * optim_rules = "/lib";
+#ifdef LIBDIR
+char * default_libdir = QUOT(LIBDIR);
#else
-char * default_include = "-I~/include";
-char * default_libdir0 = "-L~/lib/";
-char * default_libdir3 = "-L~/lib/i386/";
-char * optim_rules = "-d~/lib";
+char * default_libdir = "/lib";
#endif
+char * libdir_suffix = "";
char devnull[] = "/dev/null";
-char * exec_prefixs[] = {
-
- /* Place fillers for dynamic fill */
- devnull, devnull, devnull, devnull, devnull,
-
- "~/lib/bcc/",
-#ifdef BINDIR
- QUOT(BINDIR) "/",
-#endif
- "~/lib/",
- "~/bin/",
+char * exec_prefixs[16] = {
0 /* Last chance is contents of $PATH */
};
@@ -199,18 +189,55 @@ int argc;
char ** argv;
{
struct file_list * next_file;
+ char * temp;
progname = argv[0];
-#ifdef L_TREE
- reset_localprefix();
-#endif
+ if ((temp = getenv("BCC_PREFIX")) != 0 )
+ localprefix = copystr(temp);
+
getargs(argc, argv);
validate_link_opts();
- default_include = expand_tilde(default_include);
- default_libdir0 = expand_tilde(default_libdir0);
- default_libdir3 = expand_tilde(default_libdir3);
- optim_rules = expand_tilde(optim_rules);
+ reset_prefix_path();
+
+ if (!*localprefix || !localprefix[1]) {
+
+ if (*localprefix == '/') {
+ /* Paths for full NATIVE install "-M/" */
+ build_prefix(default_libdir, libdir_suffix, "");
+ build_prefix(default_libdir, "", "");
+
+ default_include = build_libpath("-I", "/usr/include", "");
+ default_libdir = build_libpath("-L", default_libdir, libdir_suffix);
+ optim_rules = build_libpath("-d", optim_rules, libdir_suffix);
+#if 0
+ } else if (*localprefix == '+') {
+ /* Paths for a special */
+#endif
+ } else {
+ /* Relative paths to a build dir "-M-" */
+ build_prefix("/lib", libdir_suffix, "");
+ build_prefix("/lib", "", "");
+
+ default_include = build_libpath("-I", "/include", "");
+ default_libdir = build_libpath("-L", "/lib", libdir_suffix);
+ optim_rules = build_libpath("-d", "/lib", libdir_suffix);
+ }
+
+ } else {
+ /* Relative paths to normal PREFIX directory */
+ default_include = build_libpath("-I", "/lib/bcc/include", "");
+ default_libdir = build_libpath("-L", "/lib/bcc", libdir_suffix);
+ optim_rules = build_libpath("-d", "/lib/bcc", libdir_suffix);
+
+ build_prefix("/lib/bcc", libdir_suffix, "");
+ build_prefix("/lib/bcc", "", "");
+ }
+
+ build_prefix("/bin", "", "");
+#ifdef BINDIR
+ add_prefix(QUOT(BINDIR) "/");
+#endif
if (opt_v>1) { command.cmd = ""; command_reset(); }
@@ -260,7 +287,7 @@ void
run_aspreproc(file)
struct file_list * file;
{
- static char * cc1bcc = CC1BCC;
+ static char cc1bcc[] = CC1BCC;
if (opt_arch<5) {
if (opt_e)
@@ -290,7 +317,7 @@ struct file_list * file;
{
int last_stage = 0;
int combined_cpp;
- static char * cc1bcc = CC1BCC;
+ static char cc1bcc[] = CC1BCC;
if (opt_arch<5) {
if (opt_e)
@@ -381,21 +408,32 @@ struct file_list * file;
command_reset();
newfilename(file, !do_as, 's', 1);
command_opt("-c!");
- if (opt_O)
+ if (opt_O && opt_arch == 0)
{
sprintf(buf, "-huse16 %c86", opt_O);
command_opt(buf);
}
command_opt(optim_rules);
- command_opts('o');
command_opt("rules.start");
- if (opt_O)
- {
- sprintf(buf, "rules.%c86", opt_O);
+ command_opts('o');
+
+ if (opt_O) {
+ if (opt_arch == 0)
+ sprintf(buf, "rules.%c86", opt_O);
+ else
+ sprintf(buf, "rules.lv_%c", opt_O);
command_opt(buf);
}
- command_opt("rules.86");
+
+ switch(opt_arch) {
+ case 0: command_opt("rules.86"); break;
+ case 1:
+ case 2: command_opt("rules.i386"); break;
+ case 4: command_opt("rules.6809"); break;
+ default:command_opt("rules.mid"); break;
+ }
+
command_opt("rules.end");
run_command(file);
@@ -436,9 +474,9 @@ struct file_list * file;
{
command.cmd = LD86;
command_reset();
- newfilename(file, !do_link, 'o', 1);
command_opt("-r");
command_opt("-N");
+ newfilename(file, !do_link, 'o', 1);
run_command(file);
}
}
@@ -472,15 +510,14 @@ run_link()
command_opt("-i");
if (!opt_L)
- {
- if (opt_arch==1) command_opt(default_libdir3);
- else command_opt(default_libdir0);
- }
+ command_opt(default_libdir);
command_arch();
if (!opt_x)
command_opt("-C0");
}
+ /* Current Debian compilers only work in with this: */
+ else command_opt("--static");
for(next_file = files; next_file; next_file = next_file->next)
command_opt(next_file->file);
@@ -605,13 +642,13 @@ command_reset()
memcpy(buf, *prefix, p-*prefix);
buf[p-*prefix] = 0;
- strcat(buf, localprefix);
+ strcat(buf, prefix_path);
strcat(buf, p+1);
}
strcat(buf, command.cmd);
if (!*command.cmd)
- fprintf(stderr, "PATH+=%s\n", buf);
+ fprintf(stderr, "PATH%d=%s\n", prefix-exec_prefixs, buf);
else if (access(buf, X_OK) == 0)
{
command.fullpath = copystr(buf);
@@ -832,7 +869,7 @@ char ** argv;
case 'O':
do_optim=1;
- if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '3' ))
+ if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '9' ))
opt_O = opt_arg[0];
else if (opt_arg[0] == '-')
append_option(opt_arg, 'o');
@@ -866,7 +903,15 @@ char ** argv;
break;
case 'M':
+ if (opt_arg[0] == '/') {
+ localprefix = copystr(opt_arg);
+ break;
+ }
if (opt_arg[1]) Usage();
+ if (opt_arg[0] == '-') {
+ localprefix = "";
+ break;
+ }
opt_M = *opt_arg;
break;
@@ -1002,23 +1047,21 @@ char ** argv;
opt_arch = 2;
prepend_option("-D__unix__", 'p');
prepend_option("-D__linux__", 'p');
- /* This one works (in Debian potato), /usr/bin/gcc crashes. */
- add_prefix("/usr/bin/i486-linuxlibc1-");
+
+ /* This is a more traditional libc, it also gives a 20k executable
+ * for hello world vs. 400k with glibc2 and --static.
+ * NB: DLL libc no longer seems to work.
+ */
+ add_prefix("/usr/bin/i386-uclibc-");
break;
case '8': /* Use 'c386' program as compiler */
opt_arch = 3;
+ prepend_option("-D__unix__", 'p');
+ prepend_option("-D__c386__", 'p');
break;
case '9': /* 6809 compiler */
opt_arch = 4;
-#ifndef L_TREE
- default_libdir0 = "-L~/lib/bcc/m09/";
- optim_rules = "-d~/lib/bcc/m09";
- add_prefix("~/lib/bcc/m09/");
-#else
- default_libdir0 = "-L~/lib/m09/";
- optim_rules = "-d~/lib/m09";
- add_prefix("~/lib/m09/");
-#endif
+ prepend_option("-D__6809__", 'p');
break;
case '0': /* Plain old Unix V7 style */
opt_arch = 5;
@@ -1036,6 +1079,29 @@ char ** argv;
append_option("-O", 'C');
append_option("-O", 'a');
}
+
+ if (opt_arch == 1) libdir_suffix = "/i386";
+ if (opt_arch == 4) libdir_suffix = "/m09";
+}
+
+void
+build_prefix(path1, path2, path3)
+char * path1, * path2, * path3;
+{
+ char * newstr;
+ int l;
+ newstr = xalloc(strlen(path1)+strlen(path1)+strlen(path3)
+ + strlen(prefix_path)+2);
+
+ strcpy(newstr, prefix_path);
+ strcat(newstr, path1);
+ strcat(newstr, path2);
+ strcat(newstr, path3);
+ l = strlen(newstr);
+ if (l>1 && newstr[l-1] != '/')
+ strcat(newstr, "/");
+
+ add_prefix(newstr);
}
void
@@ -1045,14 +1111,18 @@ char * path;
char ** p;
if (!path || !*path) return;
- for(p=exec_prefixs; *p; p++) {
- if( *p == devnull )
+ for( p=exec_prefixs;
+ p<exec_prefixs+(sizeof(exec_prefixs)/sizeof(*p))-1;
+ p++) {
+
+ if( !*p )
{
*p = path;
- break;
+ return;
}
+ if (strcmp(*p, path) == 0) return;
}
- if (!*p) fatal("Too many -B options");
+ fatal("Too many -B options");
}
void append_file (filename, ftype)
@@ -1128,17 +1198,15 @@ int otype;
options = newopt;
}
-char * expand_tilde(str)
-char * str;
+char * build_libpath(opt, str, suffix)
+char * opt, * str, * suffix;
{
char * newstr;
- char * ptr = strchr(str, '~');
- if( ptr == 0 ) return copystr(str);
-
- newstr = xalloc(strlen(str)+strlen(localprefix));
- if( ptr!=str ) memcpy(newstr, str, ptr-str);
- strcpy(newstr+(ptr-str), localprefix);
- strcat(newstr, ptr+1);
+ newstr = xalloc(strlen(opt)+strlen(str)+strlen(prefix_path)+strlen(suffix)+1);
+ strcpy(newstr, opt);
+ strcat(newstr, prefix_path);
+ strcat(newstr, str);
+ strcat(newstr, suffix);
return newstr;
}
@@ -1168,28 +1236,42 @@ char * str;
exit(1);
}
-#ifdef L_TREE
#ifdef MSDOS
-void reset_localprefix()
+void reset_prefix_path()
{
char *ptr, *temp;
+ if (*localprefix && localprefix[1]) {
+ prefix_path = localprefix;
+ return;
+ }
+
temp = copystr(progname);
if( (ptr = strrchr(temp, '\\')) != 0
&& temp<ptr-4 && strncmp(ptr-4, "\\BIN", 4) == 0 )
{
ptr[-4] = 0;
- localprefix = temp;
+ prefix_path = temp;
}
else
free(temp);
}
#else
-void reset_localprefix()
+void reset_prefix_path()
{
char *ptr, *temp;
+ if (*localprefix && localprefix[1]) {
+ prefix_path = localprefix;
+ return;
+ }
+
+ if ( *localprefix == '/' && !localprefix[1]) {
+ prefix_path = "";
+ return;
+ }
+
if( *progname == '/' )
temp = copystr(progname);
else
@@ -1237,14 +1319,12 @@ void reset_localprefix()
&& temp<ptr-4 && strncmp(ptr-4, "/bin", 4) == 0 )
{
ptr[-4] = 0;
- localprefix = temp;
+ prefix_path = temp;
}
else
free(temp);
}
#endif
-#endif
-
void
run_command(file)
diff --git a/bcc/bcc.doc b/bcc/bcc.doc
index acf4ab0..31c19f9 100644
--- a/bcc/bcc.doc
+++ b/bcc/bcc.doc
@@ -1,3 +1,5 @@
+WARNING: This document bis out of date; it's kept mainly for the 6809 notes.
+
bcc options
-----------
@@ -15,7 +17,7 @@ outfile stdout for preprocessor output
somewhere/file.[cis] -> file.o for assembler output
a.out for ld output
--ansi Pass the source through '/usr/bin/unprotoize' first
+-ansi Pass the source through 'unproto' first
-0 8086 target (works even on 80386 host)
-3 80386 target (works even on 8086 host)
-A pass remainder of option to assembler (e.g. -A-l -Alistfile for a listing)
diff --git a/bcc/const.h b/bcc/const.h
index a854685..7055354 100644
--- a/bcc/const.h
+++ b/bcc/const.h
@@ -26,6 +26,7 @@
#ifndef VERY_SMALL_MEMORY
#define DEBUG /* generate compiler-debugging code */
#define OPTIMISE /* include optimisation code */
+#define BUILTIN_CPP
#endif
#ifdef I8088
diff --git a/bcc/declare.c b/bcc/declare.c
index 1b9e00a..ad3b31e 100644
--- a/bcc/declare.c
+++ b/bcc/declare.c
@@ -1052,9 +1052,11 @@ PUBLIC void needvarname()
PUBLIC void program()
{
+#ifdef BUILTIN_CPP
if (orig_cppmode)
cppscan(0);
else
+#endif
{
nextsym();
while (sym != EOFSYM)
diff --git a/bcc/input.c b/bcc/input.c
index 4f8ec6a..317c053 100644
--- a/bcc/input.c
+++ b/bcc/input.c
@@ -19,6 +19,10 @@
#define INBUFSIZE 2048
+#ifndef BUILTIN_CPP
+#define NO_EOFHACK
+#endif
+
struct fbufstruct /* file buffer structure */
{
struct fcbstruct fcb; /* status after opening an include sub-file */
@@ -51,8 +55,10 @@ PRIVATE struct inclist inclast =
#endif
NULL,
};
+#ifdef BUILTIN_CPP
PRIVATE fastin_t inclevel; /* nest level of include files */
/* depends on zero init */
+#endif
PRIVATE struct fbufstruct *inputbuf; /* current input file buffer */
/* its fcb only to date in includes */
/* depends on zero (NULL) init */
@@ -63,8 +69,10 @@ FORWARD void backslash P((void));
#endif
FORWARD void definefile P((char *fname));
FORWARD void inputinit P((char *fname, fd_t fd));
-FORWARD void leaveinclude P((void));
FORWARD void usage P((void));
+#ifdef BUILTIN_CPP
+FORWARD void leaveinclude P((void));
+#endif
#ifdef ARBITRARY_BACKSLASH_NEWLINES
PRIVATE void backslash()
@@ -138,10 +146,13 @@ PUBLIC void closein()
#else
close(input.fd);
#endif
+#ifdef BUILTIN_CPP
while (inclevel != 0)
leaveinclude();
+#endif
}
+#ifdef BUILTIN_CPP
PRIVATE void definefile(fname)
char *fname;
{
@@ -155,6 +166,7 @@ char *fname;
definestring(def);
ourfree(def);
}
+#endif
PUBLIC void errorloc()
{
@@ -170,6 +182,7 @@ PUBLIC void errorloc()
{
outudec(input.linenumber);
outbyte('.');
+#ifdef BUILTIN_CPP
if (maclevel == 0)
outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset);
else
@@ -180,6 +193,9 @@ PUBLIC void errorloc()
outudec((unsigned) maclevel);
outbyte(')');
}
+#else
+ outudec((unsigned) (lineptr - inputbuf->fbuf) - input.lineoffset);
+#endif
}
infbuf->fcb.includer = input.includer;
while ((infbuf = infbuf->fcb.includer) != NULL)
@@ -202,6 +218,7 @@ PUBLIC void gch1()
specialchar();
}
+#ifdef BUILTIN_CPP
/* process #include */
PUBLIC void include()
@@ -217,10 +234,15 @@ PUBLIC void include()
while (blanksident())
{
+#ifdef BUILTIN_CPP
if ((gsymptr = findlorg(gsname)) == NULL ||
gsymptr->flags != DEFINITION)
break;
entermac();
+#else
+ if ((gsymptr = findlorg(gsname)) == NULL )
+ break;
+#endif
}
if ((terminator = ch) == '<')
terminator = '>';
@@ -345,6 +367,7 @@ ts_s_filename_tot -= charptr - fnameptr;
#endif
charptr = fnameptr;
}
+#endif
/* initialise current input file */
@@ -373,14 +396,18 @@ ts_s_inputbuf_tot += sizeof *inputbuf;
inputbuf = newinputbuf;
newinputbuf->fname = fname;
newinputbuf->fname_malloced = FALSE;
+#ifdef BUILTIN_CPP
undefinestring(filemacro);
definefile(fname);
if (orig_cppmode && !suppress_line_numbers)
outcpplinenumber(1, fname, input.includer == NULL ? "" : " 1");
+#endif
*(input.limit = newinputbuf->fbuf) = EOL;
+#ifdef BUILTIN_CPP
/* dummy line so #include processing can start with skipline() */
ch = *(lineptr = newinputbuf->fbuf - 1) = EOL;
+#endif
}
PUBLIC void linecontol()
@@ -412,11 +439,14 @@ ts_s_pathname_tot -= strlen(inputbuf->fname) + 1;
inputbuf->fname = linename;
ptr=lineptr;
+#ifdef BUILTIN_CPP
undefinestring(filemacro);
definefile(inputbuf->fname);
+#endif
ch = *(lineptr = ptr);
}
+#ifdef BUILTIN_CPP
/* switch from include file to file which included it */
PRIVATE void leaveinclude()
@@ -442,13 +472,16 @@ ts_s_inputbuf_tot -= sizeof *inputbuf;
#endif
inputbuf = input.includer;
input = inputbuf->fcb;
+#ifdef BUILTIN_CPP
undefinestring(filemacro);
definefile(inputbuf->fname);
+#endif
ch = *(lineptr = input.lineptr);
skipline();
if (orig_cppmode && !suppress_line_numbers)
outcpplinenumber(input.linenumber, inputbuf->fname, " 2");
}
+#endif
/* open input and output files and get options */
@@ -499,7 +532,9 @@ char *argv[];
#ifdef DEBUG
case 'd': /* print debugging information in asm output */
#endif
+#ifdef BUILTIN_CPP
case 'E': /* acting as cpp */
+#endif
case 'f': /* pass first argument in register */
#ifdef DYNAMIC_LONG_ORDER
case 'l': /* long big-endian */
@@ -520,6 +555,7 @@ char *argv[];
if (arg[1] == '0') /* flag 0 is negative logic flag 3 */
flag['3'] = TRUE + FALSE - flag['0'];
break;
+#ifdef BUILTIN_CPP
case 'D':
definestring(arg + 2);
break;
@@ -536,6 +572,7 @@ ts_s_includelist += sizeof *incnew;
case 'U':
undefinestring(arg + 2);
break;
+#endif
case 'o':
if (arg[2] != 0 || ++argn >= argc)
usage();
@@ -546,6 +583,7 @@ ts_s_includelist += sizeof *incnew;
break;
}
}
+#ifdef BUILTIN_CPP
#ifdef I8088
#ifdef I80386
if (flag['3'])
@@ -607,6 +645,28 @@ ts_s_includelist += sizeof *incnew;
#ifdef NOFLOAT
definestring("__HAS_NO_FLOATS__");
#endif
+
+#else /* !BUILTIN_CPP */
+
+#ifdef I80386
+ if (flag['3']) i386_32 = TRUE;
+#endif
+ if (flag['c']) callersaves = TRUE;
+#ifdef DEBUG
+ debugon = flag['d'];
+#endif
+ if (flag['f']) arg1inreg = TRUE;
+ arg1op = arg1inreg ? ROOTLISTOP : LISTOP;
+#ifdef DYNAMIC_LONG_ORDER
+ if (flag['l']) long_big_endian = TRUE;
+#endif
+ suppress_line_numbers = flag['P'];
+#ifdef POSINDEPENDENT
+ if (flag['p']) posindependent = TRUE;
+#endif
+ if (flag['O']) optimise = TRUE;
+
+#endif
ctext = flag['t'];
#ifdef DEBUG
if (ctext) debugon = 1;
@@ -642,6 +702,7 @@ PUBLIC void skipeol()
outbyte(' ');
outline(lineptr);
}
+#ifdef BUILTIN_CPP
#ifndef ASM_BARE
if (!virtual_nl && (orig_cppmode || asmmode))
#else
@@ -651,6 +712,13 @@ PUBLIC void skipeol()
if (!skip_printing_nl)
#endif
outbyte('\n');
+#else /* !BUILTIN_CPP */
+ if (asmmode)
+#ifdef INSERT_BACKSLASH_NEWLINES
+ if (!skip_printing_nl)
+#endif
+ outbyte('\n');
+#endif
#ifdef INSERT_BACKSLASH_NEWLINES
if (bs_state == 1 && *(lineptr - 1) == EOL)
@@ -715,6 +783,7 @@ case0:
ch = *lineptr;
if (nread == 0)
{
+#ifdef BUILTIN_CPP
if (inclevel == 0)
{
eofile = TRUE;
@@ -725,6 +794,9 @@ case0:
leaveinclude();
skipeol();
}
+#else
+ eofile = TRUE;
+#endif
return;
}
if (ctext && !asmmode)
@@ -738,6 +810,7 @@ case0:
PUBLIC void specialchar()
{
+#ifdef BUILTIN_CPP
if (maclevel != 0)
{
if (ch == EOL) /* it might also be backslash or COEOL */
@@ -745,6 +818,7 @@ PUBLIC void specialchar()
if (ch != EOL)
return;
}
+#endif
more:
#ifdef ARBITRARY_BACKSLASH_NEWLINES
if (ch == '\\')
diff --git a/bcc/input.h b/bcc/input.h
index 42c31f7..9a1a269 100644
--- a/bcc/input.h
+++ b/bcc/input.h
@@ -26,13 +26,16 @@ struct fcbstruct /* file control block structure */
EXTERN bool_t asmmode; /* nonzero when processing assembler code */
/* depends on zero init */
EXTERN char ch; /* current char */
-EXTERN bool_t cppmode; /* nonzero if acting as cpp not as compiler */
EXTERN bool_t eofile; /* nonzero after end of main file reached */
/* depends on zero init */
EXTERN struct fcbstruct input; /* current input file control block */
/* input.lineptr is not kept up to date */
EXTERN char *lineptr; /* ptr to current char */
+
+#ifdef BUILTIN_CPP
+EXTERN bool_t cppmode; /* nonzero if acting as cpp not as compiler */
EXTERN maclev_t maclevel; /* nest level of #defined identifiers */
/* depends on zero init */
EXTERN bool_t orig_cppmode; /* same as cppmode ex. not varied while in # */
EXTERN bool_t virtual_nl; /* For -C and asm, don't print first nl */
+#endif
diff --git a/bcc/output.c b/bcc/output.c
index b82f968..dd00c71 100644
--- a/bcc/output.c
+++ b/bcc/output.c
@@ -157,7 +157,9 @@ char *message;
PUBLIC void finishup()
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode)
+#endif
{
if (watchlc)
{
@@ -208,7 +210,9 @@ PUBLIC void flushout()
}
if (nbytes != 0)
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode)
+#endif
clearlabels(outbufptr, outbufptr + nbytes);
if (write(output, outbufptr, nbytes) != nbytes)
{
diff --git a/bcc/preproc.c b/bcc/preproc.c
index 1f35013..97e2a96 100644
--- a/bcc/preproc.c
+++ b/bcc/preproc.c
@@ -12,6 +12,16 @@
#include "table.h"
#include "type.h"
+/* blanksident() - return nonzero if at blanks followed by an identifier */
+
+PUBLIC bool_pt blanksident()
+{
+ blanks();
+ return isident();
+}
+
+#ifdef BUILTIN_CPP
+
#define MAX_IF 32
#define MAX__LINE__ 10 /* enough for 32-bit source unsigneds */
#define MAX_MACRO 32
@@ -138,14 +148,6 @@ PRIVATE void asmcontrol()
outnstr("!BCC_ENDASM");
}
-/* blanksident() - return nonzero if at blanks followed by an identifier */
-
-PUBLIC bool_pt blanksident()
-{
- blanks();
- return isident();
-}
-
PUBLIC void checknotinif()
{
while (iflevel != 0)
@@ -1076,3 +1078,5 @@ char *str;
{
defineorundefinestring(str, FALSE);
}
+
+#endif
diff --git a/bcc/scan.c b/bcc/scan.c
index b96093d..36271e4 100644
--- a/bcc/scan.c
+++ b/bcc/scan.c
@@ -119,6 +119,7 @@ PUBLIC void blanks()
continue;
reglineptr = lineptr;
}
+#ifdef BUILTIN_CPP
if (*reglineptr != '/')
return;
if (SYMOFCHAR(*(reglineptr + 1)) == SPECIALCHAR)
@@ -131,6 +132,9 @@ PUBLIC void blanks()
return;
gch1();
skipcomment();
+#else
+ return;
+#endif
}
}
@@ -139,8 +143,10 @@ int asm_only;
{
int start_of_line = 1;
#ifndef ASM_BARE
+#ifdef BUILTIN_CPP
virtual_nl = 1;
#endif
+#endif
while (!asm_only || asmmode)
{
int sym = SYMOFCHAR(ch);
@@ -172,6 +178,7 @@ int asm_only;
outstr(constant.value.s); /* XXX - embedded null would kill it */
charptr = constant.value.s;
break;
+#ifdef BUILTIN_CPP
case CONTROL:
gch1();
if (maclevel != 0)
@@ -196,6 +203,12 @@ int asm_only;
}
outbyte('/');
break;
+#else /* !BUILTIN_CPP */
+ case CONTROL:
+ gch1();
+ docontrol();
+ continue;
+#endif
case FLOATCONST:
gch1();
if (SYMOFCHAR(ch) == INTCONST)
@@ -211,6 +224,7 @@ int asm_only;
break;
case IDENT:
getident();
+#ifdef BUILTIN_CPP
if ((gsymptr = findlorg(gsname)) != NULL)
{
if (gsymptr->flags == DEFINITION)
@@ -219,6 +233,7 @@ int asm_only;
break;
}
}
+#endif
outstr(gsname);
break;
case INTCONST:
@@ -253,7 +268,11 @@ int asm_only;
/* must be '\\' */
default:
/* Allow for multi-instruction lines in asm */
+#ifdef BUILTIN_CPP
if( ch == '^' && !orig_cppmode && asmmode ) ch='\n';
+#else
+ if( ch == '^' && asmmode ) ch='\n';
+#endif
OUTBYTE(ch);
ch = *++lineptr;
@@ -261,8 +280,10 @@ int asm_only;
break;
}
#ifndef ASM_BARE
+#ifdef BUILTIN_CPP
virtual_nl = 0;
#endif
+#endif
}
}
@@ -473,12 +494,14 @@ PUBLIC void nextsym()
constant.type = itype;
return;
case CONTROL:
+#ifdef BUILTIN_CPP
if (maclevel != 0)
{
error("# in a macro: not preprocessed"); /* XXX? */
return;
}
else
+#endif
{
int old_asmmode = asmmode;
docontrol();
@@ -505,11 +528,13 @@ PUBLIC void nextsym()
getident();
if ((gsymptr = findlorg(gsname)) != NULL)
{
+#ifdef BUILTIN_CPP
if (gsymptr->flags == DEFINITION)
{
entermac();
break;
}
+#endif
if (gsymptr->flags == KEYWORD)
sym = gsymptr->offset.offsym;
}
@@ -609,11 +634,13 @@ PUBLIC void nextsym()
}
return;
case SLASH:
+#ifdef BUILTIN_CPP
if (ch == '*')
{
skipcomment();
break;
}
+#endif
if (ch == '=')
{
sym = DIVABOP;
@@ -749,7 +776,9 @@ PUBLIC void stringorcharconst()
gch1();
if (ch == EOL)
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode)
+#endif
eofin("escape sequence");
break;
}
@@ -758,7 +787,9 @@ PUBLIC void stringorcharconst()
GCH1();
if (ch == EOL)
{
+#ifdef BUILTIN_CPP
if (!orig_cppmode && ifcheck() )
+#endif
error(terminator == '"' ? "end of line in string constant"
: "end of line in character constant");
break;