Deleted Added
full compact
2c2
< * Copyright (C) 1984-2000 Mark Nudelman
---
> * Copyright (C) 1984-2002 Mark Nudelman
20a21,24
> * -mx Specifies "x" to be a metachar.
> * -nn Specifies "n" to be a metachar, as an integer.
> * -ex Specifies "x" to be the escape char for metachars.
> * -fn Specifies "x" to be the escape char for metachars, as an integer.
27c31
< static char *version = "$Revision: 1.6 $";
---
> static char *version = "$Revision: 1.9 $";
31a36,39
> static char *meta_escape = "\\";
> static char meta_escape_buf[2];
> static char metachars[64] = "";
> static int num_metachars = 0;
37c45
< "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-a] file ...\n");
---
> "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n");
172,174d179
< case 'o':
< openquote = *++arg;
< break;
177a183,202
> case 'd':
> closequote = lstrtol(++arg, 0, &s);
> if (s == arg)
> pr_error("Missing number after -d");
> break;
> case 'e':
> if (strcmp(++arg, "-") == 0)
> meta_escape = "";
> else
> meta_escape = arg;
> break;
> case 'f':
> meta_escape_buf[0] = lstrtol(++arg, 0, &s);
> meta_escape = meta_escape_buf;
> if (s == arg)
> pr_error("Missing number after -f");
> break;
> case 'o':
> openquote = *++arg;
> break;
181c206
< pr_error("Missing number after -O");
---
> pr_error("Missing number after -p");
183,184c208,213
< case 'd':
< closequote = lstrtol(++arg, 0, &s);
---
> case 'm':
> metachars[num_metachars++] = *++arg;
> metachars[num_metachars] = '\0';
> break;
> case 'n':
> metachars[num_metachars++] = lstrtol(++arg, 0, &s);
186c215,216
< pr_error("Missing number after -C");
---
> pr_error("Missing number after -n");
> metachars[num_metachars] = '\0';
214a245
> int has_meta = 0;
216c247,255
< if (quote_all || strchr(arg, ' ') != NULL)
---
> for (s = arg; *s != '\0'; s++)
> {
> if (strchr(metachars, *s) != NULL)
> {
> has_meta = 1;
> break;
> }
> }
> if (quote_all || (has_meta && strlen(meta_escape) == 0))
218,219c257,265
< else
< printf("%s", arg);
---
> else
> {
> for (s = arg; *s != '\0'; s++)
> {
> if (strchr(metachars, *s) != NULL)
> printf("%s", meta_escape);
> printf("%c", *s);
> }
> }