Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: P glob qual appends words when negated
- X-seq: zsh-workers 33136
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: P glob qual appends words when negated
- Date: Wed, 10 Sep 2014 19:24:20 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=ocv/6i4Q8Qe1kj+IzPG0zYwddmffRkETTdG9ntkJz4U=; b=P0exB/AjjPG0hk4ZZLKuDhZHt3wX20HIRffO2uZpseOrpQcmGo2EJZhG67LNNjWChU e03Uhwcvi2253T7sCvvJ9oft241G6aH3Y8J/O3lrtomyfrQlP3ch/gRBdTMRUwucxVHq PRED9Z2Ow6OnLQNDJl7KvGHCmGdK4gg9uhYp/F7qZvfibtsvdPWYXCbCV4iAjcTj+M+f wjObNWSGSh7lRaQCnx/liNUwPAOfiXPn8/qeFc3F1TirlmMuvG0LFmKeUjnoVGuk4xDp Q4r3HvmdLRm0MCnpLvcy4B7/uD2yYc0bhfEoLKNzb5Ht09zvLyYrAuMdrQ7u50DAAJ9D m/2g==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This is less often useful than prepending, but mplayer has backwards option parsing, possibly other programs do too. A is already taken and I'm not sure if this is worth a separate letter. Does anyone object to the relative grossness of using negation for this? I'll pop in some docs before committing if there's no complaints.
---
Src/glob.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/Src/glob.c b/Src/glob.c
index 99499ca..bf758d4 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -178,7 +178,7 @@ struct globdata {
int gd_gf_numsort;
int gd_gf_follow, gd_gf_sorts, gd_gf_nsorts;
struct globsort gd_gf_sortlist[MAX_SORTS];
- LinkList gd_gf_pre_words;
+ LinkList gd_gf_pre_words, gd_gf_post_words;
char *gd_glob_pre, *gd_glob_suf;
};
@@ -210,6 +210,7 @@ static struct globdata curglobdata;
#define gf_nsorts (curglobdata.gd_gf_nsorts)
#define gf_sortlist (curglobdata.gd_gf_sortlist)
#define gf_pre_words (curglobdata.gd_gf_pre_words)
+#define gf_post_words (curglobdata.gd_gf_post_words)
/* and macros for save/restore */
@@ -1074,7 +1075,14 @@ insert_glob_match(LinkList list, LinkNode next, char *data)
}
}
- insertlinknode(list, next, data);
+ next = insertlinknode(list, next, data);
+
+ if (gf_post_words) {
+ LinkNode added;
+ for (added = firstnode(gf_post_words); added; incnode(added)) {
+ next = insertlinknode(list, next, dupstring(getdata(added)));
+ }
+ }
}
/*
@@ -1190,7 +1198,7 @@ zglob(LinkList list, LinkNode np, int nountok)
gf_noglobdots = unset(GLOBDOTS);
gf_numsort = isset(NUMERICGLOBSORT);
gf_sorts = gf_nsorts = 0;
- gf_pre_words = NULL;
+ gf_pre_words = gf_post_words = NULL;
/* Check for qualifiers */
while (!nobareglob ||
@@ -1679,9 +1687,10 @@ zglob(LinkList list, LinkNode np, int nountok)
if (tt != NULL)
{
- if (!gf_pre_words)
- gf_pre_words = newlinklist();
- addlinknode(gf_pre_words, tt);
+ LinkList *words = sense & 1 ? &gf_post_words : &gf_pre_words;
+ if (!*words)
+ *words = newlinklist();
+ addlinknode(*words, tt);
}
break;
}
--
1.9.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author