Category : C Source Code
Archive   : TBISON0.ZIP
Filename : FILES.C
copyright (C) 1984 Bob Corbett and Richard Stallman */
#include
/*#include
#include "files.h"
#include "new.h"
#include "gram.h"
FILE *fopen();
FILE *finput = NULL;
FILE *foutput = NULL;
FILE *fdefines = NULL;
FILE *ftable = NULL;
FILE *fattrs = NULL;
FILE *fguard = NULL;
FILE *faction = NULL;
FILE *fparser = NULL;
FILE *fparser1 = NULL;
char *infile;
char *outfile;
char *defsfile;
char *tabfile;
char *attrsfile;
char *guardfile;
char *actfile;
char *pfile;
char *pfile1;
char *rulesfile;
extern int verboseflag;
extern int definesflag;
int fixed_outfiles = 0;
char*
stringappend(string1, end1, string2)
char *string1;
int end1;
char *string2;
{
register char *ostring;
register char *cp, *cp1;
register int i;
#ifdef ALLOC_TRACE
alloc_flag = 1;
#else
alloc_flag = 0;
#endif
cp = string2; i = 0;
while (*cp++) i++;
/* only call to allocate via NEW2 */
#ifdef ALLOC_TRACE
fprintf(stderr,"files ");
#endif
ostring = NEW2(i+end1+1, char);
cp = ostring;
cp1 = string1;
for (i = 0; i < end1; i++)
*cp++ = *cp1++;
cp1 = string2;
while (*cp++ = *cp1++) ;
return ostring;
}
openfiles()
{
static char *openerror = "cannot open %s";
pfile = PFILE;
pfile1 = PFILE1;
{
char *name_base;
register int i;
register char *cp;
if (verboseflag) fprintf(stderr,"files\n");
name_base = fixed_outfiles ? "y.y" : infile;
if (fixed_outfiles)
{ name_base = "y.y";
i = 1; }
else
{ name_base = infile;
if ((cp = strrchr(name_base, '.')) > strrchr(name_base, '\\'))
i = cp - name_base;
else
{ i = strlen(name_base);
infile = stringappend(name_base, i, ".y"); } }
outfile = stringappend(name_base, i, ".out");
defsfile = stringappend(name_base, i, ".h");
tabfile = stringappend(name_base, i, ".c");
attrsfile = stringappend(name_base, i, ".t");
guardfile = stringappend(name_base, i, ".g");
actfile = stringappend(name_base, i, ".a");
rulesfile = stringappend(name_base, i, ".r");
}
finput = fopen(infile, "r");
if (finput == NULL)
fatals(openerror, infile);
fparser = fopen(pfile, "r");
if (fparser == NULL)
fatals(openerror, pfile);
fparser1 = fopen(pfile1, "r");
if (fparser1 == NULL)
fatals(openerror, pfile1);
if (verboseflag)
{
foutput = fopen(outfile, "w");
if (foutput == NULL)
fatals(openerror, outfile);
}
if (definesflag)
{
fdefines = fopen(defsfile, "w");
if (fdefines == NULL)
fatals(openerror, defsfile);
}
faction = fopen(actfile, "w");
if (faction == NULL)
fatals(openerror, actfile);
ftable = fopen(tabfile, "w");
if (ftable == NULL)
fatals(openerror, tabfile);
#ifndef SMALL_MODEL
if (verboseflag) alloc_status();
#endif
}
/* open the output files needed only for the semantic parser. This is
done when %semantic_parser is seen in the declarations section. */
open_extra_files()
{
static char *openerror = "cannot open %s";
fattrs = fopen(attrsfile, "w");
if (fattrs == NULL)
fatals(openerror, attrsfile);
fguard = fopen(guardfile, "w");
if (fguard == NULL)
fatals(openerror, guardfile);
}
done(k)
int k;
{
if (faction)
fclose(faction);
if (fattrs)
fclose(fattrs);
if (fguard)
fclose(fguard);
if (finput)
fclose(finput);
if (fparser)
fclose(fparser);
if (fparser1)
fclose(fparser1);
if (ftable)
fclose(ftable);
if (foutput)
fclose(foutput);
exit(k);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/