diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-10-24 10:22:38 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-12-17 15:25:24 +0200 |
commit | 9dcef9e579d2e06f294dabe7918fe6753054e6cb (patch) | |
tree | 6f9b91acf9df5f6f3b1881cc031bcad2fdd98f16 /src/wordsplit.h | |
parent | 49b4b7e2e45bd22992df25ab999cb8c3ed73930f (diff) | |
download | grecs-9dcef9e579d2e06f294dabe7918fe6753054e6cb.tar.gz grecs-9dcef9e579d2e06f294dabe7918fe6753054e6cb.tar.bz2 |
wordsplit: implement tilde and pathname expansion
* src/wordsplit.c (wordsplit_tildexpand)
(wordsplit_pathexpand): New functions.
(wordsplit_process_list): Run tilde and pathname expansion
if WRDSF_PATHEXPAND flag is set.
* src/wordsplit.h (wordsplit)<ws_options>: New member.
(WRDSF_PATHEXPAND): New flag.
(WRDSO_NULLGLOB,WRDSO_FAILGLOB)
(WRDSO_DOTGLOB): New defines.
* tests/wsp.c: New options pathexpand, nullglob, failglob,
dotglob. Fix help output.
Diffstat (limited to 'src/wordsplit.h')
-rw-r--r-- | src/wordsplit.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/wordsplit.h b/src/wordsplit.h index eee262d..a531ac0 100644 --- a/src/wordsplit.h +++ b/src/wordsplit.h @@ -26,6 +26,7 @@ struct wordsplit size_t ws_offs; size_t ws_wordn; int ws_flags; + int ws_options; const char *ws_delim; const char *ws_comment; const char *ws_escape; @@ -122,11 +123,20 @@ struct wordsplit #define WRDSF_INCREMENTAL 0x20000000 /* ws_command needs argv parameter */ #define WRDSF_ARGV 0x40000000 +/* Perform pathname and tilde expansion */ +#define WRDSF_PATHEXPAND 0x80000000 #define WRDSF_DEFFLAGS \ (WRDSF_NOVAR | WRDSF_NOCMD | \ WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS | WRDSF_CESCAPES) +/* Remove the word that produces empty string after path expansion */ +#define WRDSO_NULLGLOB 0x01 +/* Print error message if path expansion produces empty string */ +#define WRDSO_FAILGLOB 0x02 +/* Allow a leading period to be matched by metacharacters. */ +#define WRDSO_DOTGLOB 0x04 + #define WRDSE_OK 0 #define WRDSE_EOF WRDSE_OK #define WRDSE_QUOTE 1 @@ -136,7 +146,8 @@ struct wordsplit #define WRDSE_UNDEF 5 #define WRDSE_NOINPUT 6 #define WRDSE_PAREN 7 -#define WRDSE_USERERR 8 +#define WRDSE_GLOBERR 8 +#define WRDSE_USERERR 9 int wordsplit (const char *s, struct wordsplit *p, int flags); int wordsplit_len (const char *s, size_t len, |