Browse Source

use `size_t' variables for fread/fwrite operations

pre-master-46
rlar 16 years ago
parent
commit
f30f96a4c7
  1. 8
      ChangeLog
  2. 10
      src/frontend/aspice.c
  3. 6
      src/frontend/inp.c
  4. 6
      src/frontend/nutinp.c
  5. 6
      src/main.c
  6. 10
      src/ngsconvert.c

8
ChangeLog

@ -1,3 +1,11 @@
2010-11-04 Robert Larice
* src/main.c ,
* src/ngsconvert.c ,
* src/frontend/aspice.c ,
* src/frontend/inp.c ,
* src/frontend/nutinp.c :
use `size_t' variables for fread/fwrite operations
2010-11-02 Robert Larice 2010-11-02 Robert Larice
* src/frontend/numparam/general.h , * src/frontend/numparam/general.h ,
* src/frontend/numparam/mystring.c , * src/frontend/numparam/mystring.c ,

10
src/frontend/aspice.c

@ -263,7 +263,7 @@ com_rspice(wordlist *wl)
char *outfile; char *outfile;
FILE *inp, *serv, *out, *srv_input, *err_outp; FILE *inp, *serv, *out, *srv_input, *err_outp;
struct plot *pl; struct plot *pl;
int i;
size_t n;
int to_serv[2], from_serv[2], err_serv[2]; int to_serv[2], from_serv[2], err_serv[2];
int pid; int pid;
long pos; long pos;
@ -342,9 +342,9 @@ com_rspice(wordlist *wl)
wl = wl->wl_next; wl = wl->wl_next;
continue; /* Should be careful */ continue; /* Should be careful */
} }
while ((i = fread(buf, 1, BSIZE_SP, inp)) > 0)
while ((n = fread(buf, 1, BSIZE_SP, inp)) > 0)
(void) fwrite(buf, 1, strlen(buf), srv_input); (void) fwrite(buf, 1, strlen(buf), srv_input);
/* (void) write(s, buf, i); */
/* (void) write(s, buf, n); */
wl = wl->wl_next; wl = wl->wl_next;
fclose(inp); fclose(inp);
} }
@ -376,8 +376,8 @@ com_rspice(wordlist *wl)
} }
if (p) if (p)
fputs(buf, out); fputs(buf, out);
while ((i = fread(buf, 1, BSIZE_SP, serv))) {
(void) fwrite(buf, 1, i, out);
while ((n = fread(buf, 1, BSIZE_SP, serv))) {
(void) fwrite(buf, 1, n, out);
} }
/* We hope that positioning info + error messages < pipe size */ /* We hope that positioning info + error messages < pipe size */
while (fgets(buf, BSIZE_SP, err_outp)) { while (fgets(buf, BSIZE_SP, err_outp)) {

6
src/frontend/inp.c

@ -1043,7 +1043,7 @@ com_source(wordlist *wl)
char *tempfile = NULL; char *tempfile = NULL;
wordlist *owl = wl; wordlist *owl = wl;
int i;
size_t n;
inter = cp_interactive; inter = cp_interactive;
cp_interactive = FALSE; cp_interactive = FALSE;
@ -1063,8 +1063,8 @@ com_source(wordlist *wl)
unlink(tempfile); unlink(tempfile);
return; return;
} }
while ((i = fread(buf, 1, BSIZE_SP, tp)) > 0)
fwrite(buf, 1, i, fp);
while ((n = fread(buf, 1, BSIZE_SP, tp)) > 0)
fwrite(buf, 1, n, fp);
fclose(tp); fclose(tp);
wl = wl->wl_next; wl = wl->wl_next;
} }

6
src/frontend/nutinp.c

@ -205,7 +205,7 @@ nutcom_source(wordlist *wl)
bool inter; bool inter;
char *tempfile = NULL; char *tempfile = NULL;
wordlist *owl = wl; wordlist *owl = wl;
int i;
size_t n;
inter = cp_interactive; inter = cp_interactive;
cp_interactive = FALSE; cp_interactive = FALSE;
@ -225,8 +225,8 @@ nutcom_source(wordlist *wl)
(void) unlink(tempfile); (void) unlink(tempfile);
return; return;
} }
while ((i = fread(buf, 1, BSIZE_SP, tp)) > 0)
(void) fwrite(buf, 1, i, fp);
while ((n = fread(buf, 1, BSIZE_SP, tp)) > 0)
(void) fwrite(buf, 1, n, fp);
(void) fclose(tp); (void) fclose(tp);
wl = wl->wl_next; wl = wl->wl_next;
} }

6
src/main.c

@ -622,10 +622,10 @@ static void
append_to_stream(FILE *dest, FILE *source) append_to_stream(FILE *dest, FILE *source)
{ {
char buf[BSIZE_SP]; char buf[BSIZE_SP];
int i;
size_t n;
while ((i = fread(buf, 1, BSIZE_SP, source)) > 0)
fwrite(buf, i, 1, dest);
while ((n = fread(buf, 1, BSIZE_SP, source)) > 0)
fwrite(buf, n, 1, dest);
} }
#endif /* SIMULATOR */ #endif /* SIMULATOR */

10
src/ngsconvert.c

@ -323,7 +323,7 @@ main(int ac, char **av)
char buf[BSIZE_SP]; char buf[BSIZE_SP];
char t, f; char t, f;
struct plot *pl; struct plot *pl;
int i;
size_t n;
char *infile = NULL; char *infile = NULL;
char *outfile = NULL; char *outfile = NULL;
FILE *fp; FILE *fp;
@ -352,8 +352,8 @@ main(int ac, char **av)
perror(infile); perror(infile);
exit(EXIT_BAD); exit(EXIT_BAD);
} }
while ((i = fread(buf, 1, sizeof(buf), stdin)))
(void) fwrite(buf, 1, i, fp);
while ((n = fread(buf, 1, sizeof(buf), stdin)))
(void) fwrite(buf, 1, n, fp);
(void) fclose(fp); (void) fclose(fp);
break; break;
@ -424,8 +424,8 @@ main(int ac, char **av)
perror(outfile); perror(outfile);
exit(EXIT_BAD); exit(EXIT_BAD);
} }
while ((i = fread(buf, 1, sizeof(buf), fp)))
(void) fwrite(buf, 1, i, stdout);
while ((n = fread(buf, 1, sizeof(buf), fp)))
(void) fwrite(buf, 1, n, stdout);
(void) fclose(fp); (void) fclose(fp);
(void) unlink(infile); (void) unlink(infile);
(void) unlink(outfile); (void) unlink(outfile);

Loading…
Cancel
Save