diff options
author | 2018-03-17 14:03:36 +0000 | |
---|---|---|
committer | 2018-03-17 14:03:36 +0000 | |
commit | 745ece38b867f16ee9cc677db6647746fbe499de (patch) | |
tree | 4df8e31ad30ff9153aedef695dc896d96b55d56c | |
parent | Add proper suspend/resume support. (diff) | |
download | wireguard-openbsd-745ece38b867f16ee9cc677db6647746fbe499de.tar.xz wireguard-openbsd-745ece38b867f16ee9cc677db6647746fbe499de.zip |
Split only LESS on $.
As guenther@ said "STOP SPLITTING ANYTHING BUT $LESS ON '$' !".
anton@ came up with the same diff. ok nicm@
-rw-r--r-- | usr.bin/less/funcs.h | 2 | ||||
-rw-r--r-- | usr.bin/less/main.c | 4 | ||||
-rw-r--r-- | usr.bin/less/option.c | 12 |
3 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/less/funcs.h b/usr.bin/less/funcs.h index 00eaf9b8090..49a39877ed1 100644 --- a/usr.bin/less/funcs.h +++ b/usr.bin/less/funcs.h @@ -213,7 +213,7 @@ void opt_quote(int, char *); void opt_query(int, char *); int get_swindow(void); char *propt(int); -void scan_option(char *); +void scan_option(char *, int); void toggle_option(struct loption *, int, char *, int); int opt_has_param(struct loption *); char *opt_prompt(struct loption *); diff --git a/usr.bin/less/main.c b/usr.bin/less/main.c index 6a06cd0679c..5fc7f131803 100644 --- a/usr.bin/less/main.c +++ b/usr.bin/less/main.c @@ -143,7 +143,7 @@ main(int argc, char *argv[]) s = lgetenv(less_is_more ? "MORE" : "LESS"); if (s != NULL) - scan_option(estrdup(s)); + scan_option(estrdup(s), 1); #define isoptstring(s) (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\0') while (argc > 0 && (isoptstring(*argv) || isoptpending())) { @@ -151,7 +151,7 @@ main(int argc, char *argv[]) argc--; if (strcmp(s, "--") == 0) break; - scan_option(s); + scan_option(s, 0); } #undef isoptstring diff --git a/usr.bin/less/option.c b/usr.bin/less/option.c index 83615f377d6..7bdda88ad75 100644 --- a/usr.bin/less/option.c +++ b/usr.bin/less/option.c @@ -24,7 +24,7 @@ static struct loption *pendopt; int plusoption = FALSE; -static char *optstring(char *, char **, char *, char *); +static char *optstring(char *, char **, char *, char *, int); static int flip_triple(int, int); extern int screen_trashed; @@ -66,7 +66,7 @@ propt(int c) * LESS environment variable) and process it. */ void -scan_option(char *s) +scan_option(char *s, int env) { struct loption *o; int optc; @@ -147,7 +147,7 @@ scan_option(char *s) * EVERY input file. */ plusoption = TRUE; - s = optstring(s, &str, propt('+'), NULL); + s = optstring(s, &str, propt('+'), NULL, 0); if (s == NULL) return; if (*str == '+') @@ -290,7 +290,7 @@ scan_option(char *s) */ while (*s == ' ') s++; - s = optstring(s, &str, printopt, o->odesc[1]); + s = optstring(s, &str, printopt, o->odesc[1], env); if (s == NULL) return; break; @@ -559,7 +559,7 @@ nopendopt(void) * Return a pointer to the remainder of the string, if any. */ static char * -optstring(char *s, char **p_str, char *printopt, char *validchars) +optstring(char *s, char **p_str, char *printopt, char *validchars, int env) { char *p; char *out; @@ -577,7 +577,7 @@ optstring(char *s, char **p_str, char *printopt, char *validchars) /* Take next char literally. */ ++p; } else { - if (*p == END_OPTION_STRING || + if ((*p == END_OPTION_STRING && env == 1) || (validchars != NULL && strchr(validchars, *p) == NULL)) /* End of option string. */ |