Category : C Source Code
Archive   : STRNG.ZIP
Filename : PHASE3.C

 
Output of file : PHASE3.C contained in archive : STRNG.ZIP
/*

phase3.c - the third phase

Kuba

*/

#include
#include
#include
#include
#include "phase.h"
#include "helpfnc.h"
#include "lex.h"

static int odl;

static int correct_file(int nf)
{
int flg;
int i;
char drive[MAXDRIVE];
char dir[MAXDIR];
char file[MAXFILE];
char ext[MAXEXT];
FILE *wf;
char *cline, *oline, *opt;
SCLASS *pc;
enum laelem atom = LA_EOL;

if((cline=malloc(MAXSTRLEN+1))==NULL)
{
error(ERR_OUT_MEM);
return(1);
}

fnsplit(actfile.fname, drive, dir, file, ext);
strcpy(out_dir+odl, file);
strcat(out_dir, ext);
if(strcmp(actfile.fname, out_dir)==0) /* the same file name */
{
flg = 1;
strcpy(out_dir+odl+strlen(file), ".$$$");
}
else
flg = 0;

if((wf=fopen(out_dir, "wt"))==NULL)
{
error(ERR_CANT_MODIF);
return(1);
}
*cline = 0;

i = nclass;
for(pc=fclass;pc;pc=pc->nclass)
{
if((pc->flags[nf/8] & (1<<(nf%8)))!=0) /* it has this class */
fprintf(wf, "#include \"JYS%05u.H\"\n", i);
i--;
}
lex_anal_start();
opt = bufptr;

do
{
if(atom==LA_EOL)
{
strcat(cline, opt);
fputs(cline, wf);
oline = cline;
}
else if(atom==LA_STRING)
oline += sprintf(oline, "_JYS%05u ",
find_string(la_lex_elem.string.addr, la_lex_elem.string.len));
else
{
strncpy(oline, opt, (unsigned)(bufptr-opt));
oline += (unsigned)(bufptr-opt);
}

opt = (atom==LA_EOL) ? linebuf : bufptr;
*oline = 0;
atom = lex_anal();
} while(atom!=LA_EOF && atom!=LA_ERR);

fclose(wf);
if(flg)
{
unlink(actfile.fname);
rename(out_dir, actfile.fname);
}
free(cline);
return(0);
}

int phase3(void)
{
int i;

puts("PASS 3: Module correction");

odl = strlen(out_dir);
start_enum_files();

for(i=0;i {
if(enum_file(1))
return(1);
if(correct_file(i))
return(1);
fclose(actfile.fp);
}

return(0);
}


  3 Responses to “Category : C Source Code
Archive   : STRNG.ZIP
Filename : PHASE3.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/