summaryrefslogtreecommitdiff
path: root/bracecomp.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-12-07 09:20:50 -0500
committerChet Ramey <chet.ramey@case.edu>2011-12-07 09:20:50 -0500
commitd356441fc69cf21730db35ed8ed63d6e210af762 (patch)
treeef2626361d29088f768bfbb142356432efa5160e /bracecomp.c
parent7e52d2bf76242ffeca9cea61e99146b50204a277 (diff)
downloadbash-d356441fc69cf21730db35ed8ed63d6e210af762.tar.gz
commit bash-20080320 snapshot
Diffstat (limited to 'bracecomp.c')
-rw-r--r--bracecomp.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/bracecomp.c b/bracecomp.c
index 34fc91e8..c5645f6c 100644
--- a/bracecomp.c
+++ b/bracecomp.c
@@ -35,10 +35,13 @@
#endif
#include "bashansi.h"
+#include "shmbutil.h"
#include "shell.h"
#include <readline/readline.h>
+static int _strcompare __P((char **, char **));
+
/* Find greatest common prefix of two strings. */
static int
string_gcd (s1, s2)
@@ -146,13 +149,30 @@ really_munge_braces (array, real_start, real_end, gcd_zero)
}
static int
+_strcompare (s1, s2)
+ char **s1, **s2;
+{
+ int result;
+
+ result = **s1 - **s2;
+ if (result == 0)
+ result = strcmp (*s1, *s2);
+
+ return result;
+}
+
+static int
hack_braces_completion (names)
char **names;
{
register int i;
char *temp;
- temp = really_munge_braces (names, 1, strvec_len (names), 0);
+ i = strvec_len (names);
+ if (MB_CUR_MAX > 1 && i > 2)
+ qsort (names+1, i-1, sizeof (char *), (QSFUNC *)_strcompare);
+
+ temp = really_munge_braces (names, 1, i, 0);
for (i = 0; names[i]; ++i)
{