Refactor lessopen_stream
Use early returns to spare a level of indentation.
This commit is contained in:
@@ -8781,20 +8781,17 @@ lessopen_stream(char *path)
|
||||
{
|
||||
char *lessopen;
|
||||
FILE *fp;
|
||||
|
||||
lessopen = getenv("LESSOPEN");
|
||||
if (lessopen == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (lessopen[0] == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lessopen[0] == '|') {
|
||||
/* pipe mode */
|
||||
Str tmpf;
|
||||
int c;
|
||||
|
||||
lessopen = getenv("LESSOPEN");
|
||||
if (lessopen == NULL || lessopen[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
if (lessopen[0] != '|') /* filename mode, not supported m(__)m */
|
||||
return NULL;
|
||||
|
||||
/* pipe mode */
|
||||
++lessopen;
|
||||
tmpf = Sprintf(lessopen, shell_quote(path));
|
||||
fp = popen(tmpf->ptr, "r");
|
||||
@@ -8807,12 +8804,6 @@ lessopen_stream(char *path)
|
||||
return NULL;
|
||||
}
|
||||
ungetc(c, fp);
|
||||
}
|
||||
else {
|
||||
/* filename mode */
|
||||
/* not supported m(__)m */
|
||||
fp = NULL;
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user