diff -rc --new-file lcc35/cpp/amiga.c lcc/cpp/amiga.c *** lcc35/cpp/amiga.c Thu Jan 1 00:00:00 1970 --- lcc/cpp/amiga.c Thu Feb 8 00:27:44 1996 *************** *** 0 **** --- 1,32 ---- + #ifdef AMIGA + + /* This file contains wrappers for some unix functions that make lcc work + with as little modification to the original source as possible. + */ + + #undef write + + #ifndef __LCC__ + #include + #endif + #include + #include + + /* The original version of lcc opens the output file, then dup2's it to + file descriptor 1 (stdout). Since dup2 is not available on the amiga, + we work around this by storing the file descriptor of the output file + in __fdo, and replacing write with amy_write (using -Dwrite=amy_write), + which writes to __fdo whenever it is asked to write to stdout. + */ + + int __fdo; + + int + amy_write(int fh, char *buffer, size_t length) + { + if (fh == 1) { + fh = __fdo; + } + return write(fh, buffer, length); + } + #endif diff -rc --new-file lcc35/cpp/include.c lcc/cpp/include.c *** lcc35/cpp/include.c Fri Feb 2 20:19:50 1996 --- lcc/cpp/include.c Fri Mar 15 09:29:20 1996 *************** *** 53,59 **** --- 53,72 ---- if (strlen(fname)+strlen(ip->file)+2 > sizeof(iname)) continue; strcpy(iname, ip->file); + #ifndef AMIGA strcat(iname, "/"); + #else + if (strcmp(iname, ".") == 0) { + /* "./foo" doesn't work on the amiga--use "foo" instead" */ + iname[0] = 0; + }else{ + if (iname[strlen(iname)-1] != ':' && iname[strlen(iname)-1] != '/') { + /* do not append "/" to volume names and paths ending in + "/", which is the Amiga's equivalent of ".." */ + strcat(iname, "/"); + } + } + #endif strcat(iname, fname); if ((fd = open(iname, 0)) >= 0) break; diff -rc --new-file lcc35/cpp/makefile lcc/cpp/makefile *** lcc35/cpp/makefile Wed Nov 30 20:23:03 1994 --- lcc/cpp/makefile Fri Mar 22 17:43:32 1996 *************** *** 1,11 **** ! CC=lcc -A ! CFLAGS=-g ! LDFLAGS=-g OBJS=cpp.o lex.o nlist.o tokens.o macro.o eval.o \ ! include.o hideset.o unix.o cpp: $(OBJS) ! $(CC) -o $@ $(LDFLAGS) $(OBJS) $(OBJS): cpp.h --- 1,11 ---- ! CC=gcc ! CFLAGS= -mstackextend -O2 -fno-builtin -Dwrite=amy_write ! LDFLAGS=-s -noixemul -lstack OBJS=cpp.o lex.o nlist.o tokens.o macro.o eval.o \ ! include.o hideset.o unix.o getopt.o amiga.o cpp: $(OBJS) ! $(CC) -o $@ $(OBJS) $(LDFLAGS) $(OBJS): cpp.h diff -rc --new-file lcc35/cpp/makefile.rcc lcc/cpp/makefile.rcc *** lcc35/cpp/makefile.rcc Thu Jan 1 00:00:00 1970 --- lcc/cpp/makefile.rcc Fri Mar 8 01:17:12 1996 *************** *** 0 **** --- 1,16 ---- + CC=lcc:bin/lcc + CFLAGS=-Dwrite=amy_write + LDFLAGS= + OBJS=cpp.o lex.o nlist.o tokens.o macro.o eval.o \ + include.o hideset.o unix.o getopt.o amiga.o + + cpp: $(OBJS) + $(CC) -o $@ $(LDFLAGS) $(OBJS) + + $(OBJS): cpp.h + + clean: + rm -f *.o core + + clobber: clean + rm -f cpp *.out diff -rc --new-file lcc35/cpp/unix.c lcc/cpp/unix.c *** lcc35/cpp/unix.c Fri Feb 2 20:19:50 1996 --- lcc/cpp/unix.c Thu Feb 8 00:27:46 1996 *************** *** 11,16 **** --- 11,19 ---- int Mflag; /* only print active include files */ char *objname; /* "src.$O: " */ int Cplusplus = 1; + #ifdef AMIGA + extern int __fdo; + #endif void setup(int argc, char **argv) *************** *** 79,86 **** --- 82,98 ---- int fdo = creat(argv[optind+1], 0666); if (fdo<0) error(FATAL, "Can't open output file %s", argv[optind+1]); + #ifndef AMIGA dup2(fdo, 1); + #else + __fdo = fdo; + #endif } + #ifdef AMIGA + else { + __fdo = 1; + } + #endif if(Mflag) setobjname(fp); includelist[NINCLUDE-1].always = 0; *************** *** 92,97 **** --- 104,110 ---- /* memmove is defined here because some vendors don't provide it at all and others do a terrible job (like calling malloc) */ + /* void * memmove(void *dp, const void *sp, size_t n) { *************** *** 114,116 **** --- 127,130 ---- } return 0; } + */