This is the change file for CWEB's COMMON under MacOS (Contributed by Markus van Almsick m.van.almsick@cityweb.de, October 2000) Changes necessary for compiling with Metrowerks CodeWarrior Pro 5 Use the stationary for a Std C console This change file addresses three issues: 1. The MacOS does not have a /dev/null device. We work around this problem by skipping input_ln routines for FILEs named /dev/null. 2. The MacOS has a different path name convention. We take '\','/', and ':' as path name separators. 3. CWEB does not always close files after using them. We make sure that web and change files are closed before reopening these files or before exiting the program. FILE* pointers of closed files are set to NULL. @x section 70 /* emulate input from |/dev/null| */ int input_ln(fp) /* copies a line into |buffer| or returns 0 */ FILE *fp; /* what file to read from */ { register int c=EOF; /* character read; initialized so some compilers won't complain */ register char *k; /* where next character goes */ @y int input_ln(fp) /* copies a line into |buffer| or returns 0 */ FILE *fp; /* what file to read from */ { register int c=EOF; /* character read; initialized so some compilers won't complain */ register char *k; /* where next character goes */ if (fp == NULL) return(0); /* MacOS /dev/null substitute */ @z @x /* initialize files with NULL pointer to mark them as still closed */ FILE *file[max_include_depth]; /* stack of non-change files */ FILE *change_file; /* change file */ @y FILE *file[max_include_depth]={NULL,NULL}; /* stack of non-change files */ FILE *change_file=NULL; /* change file */ @z @x /* close an open web file before reopening it */ @= @y @= if (web_file != NULL) { /* make sure file is closed before (re)opening */ fclose(web_file); web_file = NULL; } @z @x /* close an open change file before reopening it and don't look for |/dev/null| */ if ((change_file=fopen(change_file_name,"r"))==NULL) fatal("! Cannot open change file ", change_file_name); @y if (change_file != NULL) { /* make sure file is closed before (re)opening */ fclose(change_file); change_file = NULL; } if(strcmp(change_file_name,"/dev/null")==0) change_file=NULL; /* MacOS substitute for a |/dev/null| file */ else { if ((change_file=fopen(change_file_name,"r"))==NULL) fatal("! Cannot open change file ", change_file_name); } @z @x /* close open change and web files before exiting the program */ int wrap_up() { @y int wrap_up() { if(web_file!=NULL) { /* make sure |web_file| is closed */ fclose(web_file); } if(change_file!=NULL) { /* make sure |change_file| is closed */ fclose(change_file); } @z @x /* implement DOS and MacOS path name separators */ else if (*s=='/') dot_pos=NULL,name_pos=++s; @y else if (*s == ':' || *s == '\\' || *s == '/') dot_pos=NULL,name_pos=++s; @z