Skip to content

Commit

Permalink
cpp: quick clean up
Browse files Browse the repository at this point in the history
The cpp pass seems to be working now with the front end hacks. It does
need some adjustment for line number behaviour it seems.
  • Loading branch information
EtchedPixels committed Sep 9, 2023
1 parent 86fcdb2 commit ef6cc42
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 82 deletions.
45 changes: 0 additions & 45 deletions Applications/cpp/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions Applications/cpp/Makefile.8085
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include Makefile.common
29 changes: 29 additions & 0 deletions Applications/cpp/Makefile.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include $(FUZIX_ROOT)/Target/rules.$(USERCPU)

SRC = cpp.c hash.c main.c token1.c token2.c

.SUFFIXES: .c .o

OBJ = $(SRC:.c=.o)

all: cpp

.c.o:
$(CC) $(CFLAGS) $(CCOPTS) -c $<

cpp: $(OBJ)
$(LINKER) $(CRT0) $^ -o $@ $(LINKER_OPT) $(LINKER_TAIL)

clean:
rm -f *.o $(APPS) $(APPSNS) $(SRCS:.c=) core *~ *.asm *.lst *.sym *.map *.noi *.lk *.ihx *.tmp *.bin size.report

rmbak:
rm -f *~ core

main.o: cc.h
cpp.o: cc.h
hash.o: cc.h
tree.o: cc.h

token1.o: token1.h
token2.o: token2.h
7 changes: 0 additions & 7 deletions Applications/cpp/cc.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

#ifndef P
#if __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif

extern void cfatal P((char*));
extern void cerror P((char*));
Expand Down
11 changes: 1 addition & 10 deletions Applications/cpp/cpp.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

#include <stdio.h>
#include <string.h>
#ifdef __STDC__
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include "cc.h"

#define CPP_DEBUG 0 /* LOTS of junk to stderr. */
Expand Down Expand Up @@ -52,11 +47,7 @@ FILE * curfile;
char * c_fname;
int c_lineno = 0;

#ifdef __BCC__
typedef long int_type; /* Used for preprocessor expressions */
#else
typedef int int_type; /* Used for preprocessor expressions */
#endif
static int curtok = 0; /* Used for preprocessor expressions */

static int fi_count = 0;
Expand Down Expand Up @@ -1239,7 +1230,7 @@ static int_type get_exp_value(void)
return sign<0 ? -value: value;
}

void gen_substrings(char *macname, char *data_str, int arg_count, int is_vararg)
static void gen_substrings(char *macname, char *data_str, int arg_count, int is_vararg)
{
char * mac_text = 0;
struct arg_store *arg_list;
Expand Down
2 changes: 1 addition & 1 deletion Applications/cpp/fuzix-cpp.pkg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ccp
if-file cpp

f 0644 /usr/bin/cpp cpp
f 0755 /usr/bin/cpp cpp
20 changes: 1 addition & 19 deletions Applications/cpp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char *argv[])
{
int ar, i;
char * p;
static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile";
static char Usage[] = "Usage: cpp -E -Dxxx -Uxxx -Ixxx infile -o outfile";

#ifdef LC_CTYPE
setlocale(LC_CTYPE, "");
Expand All @@ -56,22 +56,6 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile";
case 'A': dialect = DI_ANSI; break;
case 'K': dialect = DI_KNR; break;

/* Some options for describing the code generator. */
case '0': define_macro("__BCC__");
define_macro("__AS386_16__");
define_macro("__8086__");
break;
case '3': define_macro("__BCC__");
define_macro("__AS386_32__");
define_macro("__i386__");
break;
case 'c': define_macro("__CALLER_SAVES__");
break;
case 'f': define_macro("__FIRST_ARG_IN_AX__");
break;
case 'O': define_macro("__OPTIMISED__");
break;

case 'C': /* Keep comments. */
cwarn("-C not implemented");
break;
Expand Down Expand Up @@ -136,7 +120,6 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile";
if (!curfile)
cfatal(Usage);

#if 0
/* Define date and time macros. */
if (dialect != DI_KNR) {
time_t now;
Expand All @@ -152,7 +135,6 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile";
sprintf(buf, "__DATE__=\"%.3s %.2s %.4s\"", timep + 4, timep + 8, timep + 20);
define_macro(buf);
}
#endif

if (outfile) ofd = fopen(outfile, "w");
else ofd = stdout;
Expand Down

0 comments on commit ef6cc42

Please sign in to comment.