diff --git a/util/LLgen/src/machdep.c b/util/LLgen/src/machdep.c index babe3b34d..d04f9ac3d 100644 --- a/util/LLgen/src/machdep.c +++ b/util/LLgen/src/machdep.c @@ -43,17 +43,7 @@ void UNLINK(string x) #endif } -void RENAME(string x,string y) -{ - /* Must move the file "x" to the file "y" */ -#ifdef USE_SYS - if(!sys_rename(x,y)) fatal(1,"Cannot rename to %s",y); -#else - if (rename(x, y) == -1) - fatal(1, "Cannot rename to %s", y); -#endif -} string libpath(string s) { diff --git a/util/LLgen/src/main.c b/util/LLgen/src/main.c index f26446e51..1f1cab2be 100644 --- a/util/LLgen/src/main.c +++ b/util/LLgen/src/main.c @@ -353,6 +353,28 @@ void copyfile(string file) fclose(f); } +void copyto(string target, string source) +{ + FILE *fsource; + FILE *ftarget; + int c; + + ftarget = fopen(target,"wb+"); + if (ftarget == NULL) + { + fatal(0, "Cannot open file %s, call an expert", target); + } + fsource = fopen(source,"rb"); + if (fsource == NULL) + { + fatal(0, "Cannot open file %s, call an expert", source); + } + while ((c = getc(fsource)) != EOF) + putc(c, ftarget); + fclose(fsource); + fclose(ftarget); +} + void install(string target, string source) { /* @@ -377,7 +399,7 @@ void install(string target, string source) if ((f2 = fopen(target, "r")) == NULL) { fclose(f1); - RENAME(f_pars, target); + copyto(target, f_pars); return; } /* @@ -406,6 +428,6 @@ void install(string target, string source) { fatal(0, "%s : not a file generated by LLgen", target); } - RENAME(f_pars, target); + copyto(target, f_pars); } }