use `size_t' variables for fread/fwrite operations

This commit is contained in:
rlar 2010-11-04 19:15:41 +00:00
parent 96992f770a
commit f30f96a4c7
6 changed files with 27 additions and 19 deletions

View File

@ -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
* src/frontend/numparam/general.h ,
* src/frontend/numparam/mystring.c ,

View File

@ -263,7 +263,7 @@ com_rspice(wordlist *wl)
char *outfile;
FILE *inp, *serv, *out, *srv_input, *err_outp;
struct plot *pl;
int i;
size_t n;
int to_serv[2], from_serv[2], err_serv[2];
int pid;
long pos;
@ -342,9 +342,9 @@ com_rspice(wordlist *wl)
wl = wl->wl_next;
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) write(s, buf, i); */
/* (void) write(s, buf, n); */
wl = wl->wl_next;
fclose(inp);
}
@ -376,8 +376,8 @@ com_rspice(wordlist *wl)
}
if (p)
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 */
while (fgets(buf, BSIZE_SP, err_outp)) {

View File

@ -1043,7 +1043,7 @@ com_source(wordlist *wl)
char *tempfile = NULL;
wordlist *owl = wl;
int i;
size_t n;
inter = cp_interactive;
cp_interactive = FALSE;
@ -1063,8 +1063,8 @@ com_source(wordlist *wl)
unlink(tempfile);
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);
wl = wl->wl_next;
}

View File

@ -205,7 +205,7 @@ nutcom_source(wordlist *wl)
bool inter;
char *tempfile = NULL;
wordlist *owl = wl;
int i;
size_t n;
inter = cp_interactive;
cp_interactive = FALSE;
@ -225,8 +225,8 @@ nutcom_source(wordlist *wl)
(void) unlink(tempfile);
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);
wl = wl->wl_next;
}

View File

@ -622,10 +622,10 @@ static void
append_to_stream(FILE *dest, FILE *source)
{
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 */

View File

@ -323,7 +323,7 @@ main(int ac, char **av)
char buf[BSIZE_SP];
char t, f;
struct plot *pl;
int i;
size_t n;
char *infile = NULL;
char *outfile = NULL;
FILE *fp;
@ -352,8 +352,8 @@ main(int ac, char **av)
perror(infile);
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);
break;
@ -424,8 +424,8 @@ main(int ac, char **av)
perror(outfile);
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) unlink(infile);
(void) unlink(outfile);