diff options
author | Robert de Bath <rdebath@poboxes.com> | 2002-08-11 08:50:48 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:48:48 +0200 |
commit | 26ade8d624457b7164502ed9c190ca3f146bda0c (patch) | |
tree | 75a70b6a562bc595c971e170994a8e302a8c7b3b /cpp/main.c | |
parent | 660429af0232d4afcb3e03fb0437053dd6e16286 (diff) | |
download | dev86-26ade8d624457b7164502ed9c190ca3f146bda0c.tar.gz |
Import Dev86src-0.16.8.tar.gzv0.16.8
Diffstat (limited to 'cpp/main.c')
-rw-r--r-- | cpp/main.c | 42 |
1 files changed, 28 insertions, 14 deletions
@@ -21,6 +21,8 @@ void define_macro _P((char *)); void undefine_macro _P((char *)); void cmsg _P((char * mtype, char * str)); char * token_txn _P((int)); +void pr_indent _P((int)); +void hash_line _P((void)); char * include_paths[MAXINCPATH]; @@ -28,6 +30,7 @@ char last_name[512] = ""; int last_line = -1; int debug_mode = 0; int p_flag = 0; +int exit_code = 0; char * outfile = 0; FILE * ofd = 0; @@ -146,7 +149,7 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; print_toks_cpp(); if (outfile) fclose(ofd); - exit(0); + exit(exit_code); } void @@ -192,24 +195,34 @@ char * fname; char * mode; int checkrel; { - FILE * fd; + FILE * fd = 0; int i; - char buf[256]; + char buf[256], *p; if( checkrel ) { - fd=fopen(fname, mode); - if( fd ) return fd; + strcpy(buf, c_fname); + p = strrchr(buf, '/'); + if (p) *++p = 0; else *(p=buf) = 0; + strcpy(p, fname); + + fd=fopen(buf, mode); + } + if (!fd) { + for(i=0; i<MAXINCPATH; i++) + if (include_paths[i]) { + strcpy(buf, include_paths[i]); + if (buf[strlen(buf)-1] != '/') strcat(buf, "/"); + strcat(buf, fname); + fd=fopen(buf, mode); + if( fd ) break; + } } - for(i=0; i<MAXINCPATH; i++) - if (include_paths[i]) { - strcpy(buf, include_paths[i]); - if (buf[strlen(buf)-1] != '/') strcat(buf, "/"); - strcat(buf, fname); - fd=fopen(buf, mode); - if( fd ) return fd; - } - return 0; + if (!fd) return fd; + c_fname = strdup(buf); + c_lineno = 1; + + return fd; } /*----------------------------------------------------------------------*/ @@ -242,6 +255,7 @@ void cerror(str) char * str; { + exit_code = 1; cmsg("error", str); } |