mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Fixed reading from stdin with calc -p
This commit is contained in:
11
input.c
11
input.c
@@ -361,6 +361,10 @@ f_pathopen(char *name, char *mode, char *pathlist, char **openpath)
|
||||
}
|
||||
if (*openpath == NULL) {
|
||||
free(path);
|
||||
if ((conf->calc_debug & CALCDBG_TTY) && ret == stdin) {
|
||||
printf("f_pathopen: closing stdin "
|
||||
"on malloc return error\n");
|
||||
}
|
||||
fclose(ret);
|
||||
math_error("cannot malloc return openpath buffer");
|
||||
/*NOTREACHED*/
|
||||
@@ -647,8 +651,13 @@ closeinput(void)
|
||||
return;
|
||||
if (cip->i_str)
|
||||
free(cip->i_str);
|
||||
if (cip->i_fp)
|
||||
if (cip->i_fp) {
|
||||
if ((conf->calc_debug & CALCDBG_TTY) && cip->i_fp == stdin) {
|
||||
printf("closeinput: closing stdin "
|
||||
"at depth: %d\n", depth);
|
||||
}
|
||||
fclose(cip->i_fp);
|
||||
}
|
||||
if (cip->i_name)
|
||||
free(cip->i_name);
|
||||
depth--;
|
||||
|
Reference in New Issue
Block a user