SCCS-vsn: usr.bin/pascal/src/savenl.c 1.2
/* Copyright (c) 1982 Regents of the University of California */
/* Copyright (c) 1982 Regents of the University of California */
-static char sccsid[] = "@(#)savenl.c 1.1 %G%";
+static char sccsid[] = "@(#)savenl.c 1.2 %G%";
/*
* savenl - routines for saving namelist and line number information
/*
* savenl - routines for saving namelist and line number information
#include "whoami.h"
#include "0.h"
#include "whoami.h"
#include "0.h"
LOCAL FILE *filesfp;
LOCAL FILE *linesfp;
LOCAL FILE *filesfp;
LOCAL FILE *linesfp;
/*
* create temporary files for the namelist info
*/
startnlfile()
{
/*
* create temporary files for the namelist info
*/
startnlfile()
{
mktemp(symname);
mktemp(strname);
mktemp(filesname);
mktemp(symname);
mktemp(strname);
mktemp(filesname);
fclose(strfp);
fclose(filesfp);
fclose(linesfp);
fclose(strfp);
fclose(filesfp);
fclose(linesfp);
+ if (!opt('g')) {
+ removenlfile();
+ return;
+ }
symfd = open(symname, 0);
strfd = open(strname, 0);
filesfd = open(filesname, 0);
symfd = open(symname, 0);
strfd = open(strname, 0);
filesfd = open(filesname, 0);
+nlhdrsize()
+{
+ int r;
+
+ if (!opt('g')) {
+ r = 0;
+ } else {
+ r = nlsize + sizeof(nlhdr);
+ }
+ return r;
+}
+
#define isblock(s) (s->class == FUNC || s->class == PROC)
#define isbuiltin(s) ((s->nl_block&037) == 0 && isblock(s))
#define symno(p) (p==NULL ? 0 : nloff(p))
#define isblock(s) (s->class == FUNC || s->class == PROC)
#define isbuiltin(s) ((s->nl_block&037) == 0 && isblock(s))
#define symno(p) (p==NULL ? 0 : nloff(p))
continue;
}
nlhdr.nsyms++;
continue;
}
nlhdr.nsyms++;
+ nlsize += sizeof(OBJSYM) + sizeof(int);
putw(symno(p), symfp);
if (p->symbol != NULL) {
s->strindex = nlhdr.stringsize;
putw(symno(p), symfp);
if (p->symbol != NULL) {
s->strindex = nlhdr.stringsize;
-LOCAL int olc = BASEADDR;
+LOCAL int olc = HEADER_BYTES;
lineno(line)
int line;
{
if (line != oline) {
nlhdr.nlines++;
lineno(line)
int line;
{
if (line != oline) {
nlhdr.nlines++;
putc(line - oline, linesfp);
putc(lc - olc, linesfp);
oline = line;
putc(line - oline, linesfp);
putc(lc - olc, linesfp);
oline = line;
FILETAB ft;
nlhdr.nfiles++;
FILETAB ft;
nlhdr.nfiles++;
+ nlsize += sizeof(FILETAB);
ft.line = line;
oline = line;
if (lc == 0) {
ft.addr = 0;
} else {
ft.line = line;
oline = line;
if (lc == 0) {
ft.addr = 0;
} else {
- ft.addr = lc - BASEADDR;
+ ft.addr = lc - HEADER_BYTES;
}
ft.filename = (char *) nlhdr.stringsize;
putstring(s);
}
ft.filename = (char *) nlhdr.stringsize;
putstring(s);
static OBJSYM zerosym;
nlhdr.nsyms++;
static OBJSYM zerosym;
nlhdr.nsyms++;
+ nlsize += sizeof(OBJSYM) + sizeof(int);
putw(0, symfp);
zerosym.strindex = nlhdr.stringsize;
putstring(s);
putw(0, symfp);
zerosym.strindex = nlhdr.stringsize;
putstring(s);
- for (p = s; *p != '\0'; p++)
+ for (p = s; *p != '\0'; p++) {
nlhdr.stringsize += (p - s + 1);
nlhdr.stringsize += (p - s + 1);