summaryrefslogtreecommitdiff
path: root/xts5/src/bin
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2009-06-08 22:13:33 -0700
committerDan Nicholson <dbn.lists@gmail.com>2009-06-08 22:44:58 -0700
commit4cf626f5f94622145be8c1fbf0d52b430d54a19c (patch)
tree22d07a070ef1311097a69b37d77f95dfafec0959 /xts5/src/bin
parent781e53309fd9632f47a5a3dc2c57aad7c0dc5bd8 (diff)
mc: Pass back unique temp file name
Now that mc makes the temp file unique by adding the pid to name, let need to let the caller know about the path in case it needs more than the fd.
Diffstat (limited to 'xts5/src/bin')
-rw-r--r--xts5/src/bin/mc/code.c16
-rw-r--r--xts5/src/bin/mc/error.c5
-rw-r--r--xts5/src/bin/mc/expand.c4
-rw-r--r--xts5/src/bin/mc/files.c18
-rw-r--r--xts5/src/bin/mc/ma.c6
-rw-r--r--xts5/src/bin/mc/make.c8
-rw-r--r--xts5/src/bin/mc/mas.c4
-rw-r--r--xts5/src/bin/mc/mcproto.h2
-rw-r--r--xts5/src/bin/mc/sections.c5
9 files changed, 41 insertions, 27 deletions
diff --git a/xts5/src/bin/mc/code.c b/xts5/src/bin/mc/code.c
index cd29d28b..01b7436f 100644
--- a/xts5/src/bin/mc/code.c
+++ b/xts5/src/bin/mc/code.c
@@ -191,12 +191,12 @@ void
mcstart(buf)
char *buf;
{
- FpBanner = cretmpfile(F_BANNER);
- FpSynopsis = cretmpfile(F_SYNOPSIS);
- FpExtern = cretmpfile(F_EXTERN);
- FpInclude = cretmpfile(F_INCLUDE);
- FpCode = cretmpfile(F_CODE);
- FpStrategy = cretmpfile(F_STRATEGY);
+ FpBanner = cretmpfile(F_BANNER, NULL);
+ FpSynopsis = cretmpfile(F_SYNOPSIS, NULL);
+ FpExtern = cretmpfile(F_EXTERN, NULL);
+ FpInclude = cretmpfile(F_INCLUDE, NULL);
+ FpCode = cretmpfile(F_CODE, NULL);
+ FpStrategy = cretmpfile(F_STRATEGY, NULL);
FpAssertion = (FILE *)-1;
FpStrategy = (FILE *)-1;
setoutline();
@@ -657,7 +657,7 @@ char **cpp;
fclose(FpAssertion);
unlink(F_ASSERTION);
}
- FpAssertion = cretmpfile(F_ASSERTION);
+ FpAssertion = cretmpfile(F_ASSERTION, NULL);
if (State.type == NULL) {
err("Missing type\n");
@@ -832,7 +832,7 @@ char *buf;
fclose(FpStrategy);
unlink(F_STRATEGY);
}
- FpStrategy = cretmpfile(F_STRATEGY);
+ FpStrategy = cretmpfile(F_STRATEGY, NULL);
while (newline(fp, buf) != NULL && !SECSTART(buf)) {
(void) fprintf(FpStrategy, "%s", buf);
}
diff --git a/xts5/src/bin/mc/error.c b/xts5/src/bin/mc/error.c
index 61d44aa6..712195d9 100644
--- a/xts5/src/bin/mc/error.c
+++ b/xts5/src/bin/mc/error.c
@@ -205,10 +205,11 @@ char *buf;
{
int i;
FILE *fp;
+char *tmpfile;
State.err = ER_VALUE;
- fp = cretmpfile(F_TVAL);
+ fp = cretmpfile(F_TVAL, &tmpfile);
(void) fprintf(fp, ">>ASSERTION Bad A\n");
(void) fprintf(fp, "When the value of\n.A %s\n", Alts[1]);
@@ -248,7 +249,7 @@ FILE *fp;
(void) fprintf(fp, "};\n\n");
(void) fclose(fp);
- includefile(F_TVAL, buf);
+ includefile(tmpfile, buf);
}
valerrdefs()
diff --git a/xts5/src/bin/mc/expand.c b/xts5/src/bin/mc/expand.c
index 3903b84c..788dde23 100644
--- a/xts5/src/bin/mc/expand.c
+++ b/xts5/src/bin/mc/expand.c
@@ -142,8 +142,8 @@ void
mepstart(buf)
char *buf;
{
- FpExp = cretmpfile(F_EXPAND);
- FpBanner = cretmpfile(F_BANNER);
+ FpExp = cretmpfile(F_EXPAND, NULL);
+ FpBanner = cretmpfile(F_BANNER, NULL);
}
/*ARGSUSED*/
diff --git a/xts5/src/bin/mc/files.c b/xts5/src/bin/mc/files.c
index ff431d96..410e6bab 100644
--- a/xts5/src/bin/mc/files.c
+++ b/xts5/src/bin/mc/files.c
@@ -201,18 +201,30 @@ char buf[BUFSIZ];
* and return the stream pointer.
*/
FILE *
-cretmpfile(file)
+cretmpfile(file, crefile)
char *file;
+char **crefile;
{
register FILE *fp;
-char tmpfile[PATH_MAX];
+char *tmpfile;
+
+ tmpfile = malloc(PATH_MAX);
+ if (!tmpfile) {
+ fprintf(stderr, "Could not allocate memory for tmpfile %s\n",
+ file);
+ errexit();
+ }
snprintf(tmpfile, PATH_MAX, "%s.%d", file, (int)getpid());
if ((fp = fopen(tmpfile, "w+")) == NULL) {
(void) fprintf(stderr, "Could not open %s\n", tmpfile);
errexit();
}
- filetemp(strdup(tmpfile));
+
+ if (crefile)
+ *crefile = tmpfile;
+ filetemp(tmpfile);
+
return(fp);
}
diff --git a/xts5/src/bin/mc/ma.c b/xts5/src/bin/mc/ma.c
index 079024f8..64341c25 100644
--- a/xts5/src/bin/mc/ma.c
+++ b/xts5/src/bin/mc/ma.c
@@ -192,8 +192,8 @@ void
mastart(buf)
char *buf;
{
- FpBanner = cretmpfile(F_BANNER);
- FpText = cretmpfile(F_TEXT);
+ FpBanner = cretmpfile(F_BANNER, NULL);
+ FpText = cretmpfile(F_TEXT, NULL);
}
/*ARGSUSED*/
@@ -205,7 +205,7 @@ char *buf;
outfile(FpBanner);
if (hflag) {
if (sflag) {
- FpHeader = cretmpfile(F_HEADER);
+ FpHeader = cretmpfile(F_HEADER, NULL);
(void) fprintf(FpHeader, ".so head.t\n");
outfile(FpHeader);
} else {
diff --git a/xts5/src/bin/mc/make.c b/xts5/src/bin/mc/make.c
index 3847926d..cc106b6f 100644
--- a/xts5/src/bin/mc/make.c
+++ b/xts5/src/bin/mc/make.c
@@ -178,10 +178,10 @@ char *buf;
/* Index into files is one more than number of files */
filenames = createmclist();
- FpBanner = cretmpfile(F_BANNER);
- FpDefines = cretmpfile(F_DEFINES);
- FpDepends = cretmpfile(F_DEPS);
- FpTop = cretmpfile(F_TOP);
+ FpBanner = cretmpfile(F_BANNER, NULL);
+ FpDefines = cretmpfile(F_DEFINES, NULL);
+ FpDepends = cretmpfile(F_DEPS, NULL);
+ FpTop = cretmpfile(F_TOP, NULL);
}
diff --git a/xts5/src/bin/mc/mas.c b/xts5/src/bin/mc/mas.c
index 24598772..19de7a3e 100644
--- a/xts5/src/bin/mc/mas.c
+++ b/xts5/src/bin/mc/mas.c
@@ -193,8 +193,8 @@ void
masstart(buf)
char *buf;
{
- FpBanner = cretmpfile(F_BANNER);
- FpText = cretmpfile(F_TEXT);
+ FpBanner = cretmpfile(F_BANNER, NULL);
+ FpText = cretmpfile(F_TEXT, NULL);
}
/*ARGSUSED*/
diff --git a/xts5/src/bin/mc/mcproto.h b/xts5/src/bin/mc/mcproto.h
index 288eedb7..80d9f34f 100644
--- a/xts5/src/bin/mc/mcproto.h
+++ b/xts5/src/bin/mc/mcproto.h
@@ -105,7 +105,7 @@ void mepset(char *buf);
void mepcomment(char *buf);
FILE *nextfile(struct mclist *sources);
void outcopy(char *file);
-FILE *cretmpfile(char *file);
+FILE *cretmpfile(char *file, char **crefile);
int outfile(FILE *fp);
int remfiles(void);
int includefile(char *file, char *bp);
diff --git a/xts5/src/bin/mc/sections.c b/xts5/src/bin/mc/sections.c
index 384df749..7eece144 100644
--- a/xts5/src/bin/mc/sections.c
+++ b/xts5/src/bin/mc/sections.c
@@ -593,6 +593,7 @@ char *buf;
{
FILE *fp;
int needed;
+char *tmpfile;
/*
* If there is any supplied strategy or code then there are no defaults.
@@ -609,7 +610,7 @@ int needed;
}
/* Default code stub */
- fp = cretmpfile(F_TDEFCODE);
+ fp = cretmpfile(F_TDEFCODE, &tmpfile);
switch (State.category) {
case CAT_B: case CAT_D: /* Untested */
@@ -641,5 +642,5 @@ int needed;
}
fclose(fp);
- includefile(F_TDEFCODE, buf);
+ includefile(tmpfile, buf);
}