>From 123ba1c50078c0857c489809132cc39ab59d7636 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Droz?=
Date: Fri, 27 May 2011 14:58:01 +0200
Subject: [PATCH 2/3] added support of the -B flag to the 'complete' builtin.
It will allow registration of a $COMP_WORDBREAKS equivalent on
a per-completion basis.
---
builtins/complete.def | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtins/complete.def b/builtins/complete.def
index b9f0a13..248cd05 100644
--- a/builtins/complete.def
+++ b/builtins/complete.def
@@ -94,7 +94,7 @@ static void print_compopts __P((const char *, COMPSPEC *, int));
static void print_all_completions __P((void));
static int print_cmd_completions __P((WORD_LIST *));
-static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
+static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg, *Barg;
static const struct _compacts {
const char * const actname;
@@ -193,7 +193,7 @@ build_actions (list, flagp, actp, optp)
opt_given = 0;
reset_internal_getopt ();
- while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DE")) != -1)
+ while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:B:G:W:P:S:X:F:C:DE")) != -1)
{
opt_given = 1;
switch (opt)
@@ -278,6 +278,9 @@ build_actions (list, flagp, actp, optp)
}
acts |= compacts[ind].actflag;
break;
+ case 'B':
+ Barg = list_optarg;
+ break;
case 'C':
Carg = list_optarg;
break;
@@ -355,7 +358,7 @@ complete_builtin (list)
opt_given = oflags.pflag = oflags.rflag = oflags.Dflag = oflags.Eflag = 0;
acts = copts = (unsigned long)0L;
- Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
+ Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = Barg = (char *)NULL;
cs = (COMPSPEC *)NULL;
/* Build the actions from the arguments. Also sets the [A-Z]arg variables
@@ -423,6 +426,7 @@ complete_builtin (list)
cs->funcname = STRDUP (Farg);
cs->command = STRDUP (Carg);
cs->filterpat = STRDUP (Xarg);
+ cs->word_breaks = STRDUP (Barg);
for (rval = EXECUTION_SUCCESS, l = wl ? wl : list ; l; l = l->next)
{
--
1.7.3.4