Simplify file copying

Also enlarge buffers.
This commit is contained in:
Michael Weber 2010-11-28 22:10:47 +01:00
parent 42f2334450
commit f277db6c7e

6
main.c
View file

@ -54,7 +54,7 @@ cleanup()
FILE * FILE *
cpyfile(const char *src, const char *tgt) cpyfile(const char *src, const char *tgt)
{ FILE *inp, *out; { FILE *inp, *out;
char buf[1024]; char buf[4096];
inp = fopen(src, "r"); inp = fopen(src, "r");
out = fopen(tgt, "w"); out = fopen(tgt, "w");
@ -62,8 +62,8 @@ cpyfile(const char *src, const char *tgt)
{ printf("ltl2ba: cannot cp %s to %s\n", src, tgt); { printf("ltl2ba: cannot cp %s to %s\n", src, tgt);
alldone(1); alldone(1);
} }
while (fgets(buf, 1024, inp)) while (fgets(buf, sizeof buf, inp))
fprintf(out, "%s", buf); fputs(buf, out);
fclose(inp); fclose(inp);
return out; return out;
} }