From e22fc15589ff902f8b161fe6b25bfc929bd4bf49 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Mon, 10 Feb 2014 21:28:03 +0100 Subject: [PATCH] Deduct temporary library path name from library path name. Actually there's no need to fiddle with any automatic temp file name generation as we can just modify the library path name to generate a perfect temporary library path name. --- src/Makefile | 2 +- src/ar65/library.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index 5ac8ed7bd..7bdd5206a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ LD65_LIB = $(datadir)/lib LD65_OBJ = $(datadir)/lib LD65_CFG = $(datadir)/cfg -CFLAGS += -MMD -MP -O -std=c89 -D_SVID_SOURCE -I common \ +CFLAGS += -MMD -MP -O -std=c89 -I common \ -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \ -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) \ -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) diff --git a/src/ar65/library.c b/src/ar65/library.c index 1f8a2425e..e68f23d3d 100644 --- a/src/ar65/library.c +++ b/src/ar65/library.c @@ -64,7 +64,7 @@ /* Name of the library file */ const char* LibName = 0; -static const char* NewLibName = 0; +static char* NewLibName = 0; /* File descriptor for the library file */ static FILE* Lib = 0; @@ -249,10 +249,9 @@ void LibOpen (const char* Name, int MustExist, int NeedTemp) if (NeedTemp) { /* Create the temporary library name */ - NewLibName = tempnam (NULL, NULL); - if (NewLibName == 0) { - Error ("Cannot create temporary library file name: %s", strerror (errno)); - } + NewLibName = xmalloc (strlen (Name) + strlen (".temp") + 1); + strcpy (NewLibName, Name); + strcat (NewLibName, ".temp"); /* Create the temporary library */ NewLib = fopen (NewLibName, "w+b"); @@ -386,7 +385,7 @@ void LibClose (void) LibName, strerror (errno)); } - /* Copy the new library to the new one */ + /* Copy the temporary library to the new one */ fseek (NewLib, 0, SEEK_SET); while ((Count = fread (Buf, 1, sizeof (Buf), NewLib)) != 0) { if (fwrite (Buf, 1, Count, Lib) != Count) {