The filename "-" also means reading the standard input

This commit is contained in:
Pierre Pronchery 2011-03-22 11:48:21 +00:00
parent 7d85948347
commit 7a12feb5e9

View File

@ -59,7 +59,8 @@ static int _more_do(Prefs * prefs, char const * filename)
int n = 1; int n = 1;
int c; int c;
if(filename != NULL && (fp = fopen(filename, "r")) == NULL) if(filename != NULL && strcmp(filename, "-") != 0
&& (fp = fopen(filename, "r")) == NULL)
return _more_error(filename, 1); return _more_error(filename, 1);
while(fgets(buf, sizeof(buf), fp) != NULL) while(fgets(buf, sizeof(buf), fp) != NULL)
{ {
@ -76,7 +77,7 @@ static int _more_do(Prefs * prefs, char const * filename)
fputs("--more--", stderr); fputs("--more--", stderr);
while((c = getchar()) != EOF && c != '\n'); while((c = getchar()) != EOF && c != '\n');
} }
if(filename != NULL) if(filename != NULL && strcmp(filename, "-") != 0)
fclose(fp); fclose(fp);
return 0; return 0;
} }