summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre De Dommelin <adedommelin@tuxz.net>2017-03-12 15:49:46 -0700
committerLukas Schwaighofer <lukas@schwaighofer.name>2017-03-12 15:49:46 -0700
commit7b63dc42973f07f58890612f63fbeb38b5781c7a (patch)
tree2cca475635bdf6d2072af19b073fb07b74d9ecb2
parentb241ae318e41b663bd23c24ca6d37910977046c1 (diff)
debian-changes-0.9.2-2.1
Gbp-Pq: Name debian-changes-0.9.2-2.1
-rw-r--r--src/gtkcompletionline.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/gtkcompletionline.cc b/src/gtkcompletionline.cc
index 99fdfcf..90897f7 100644
--- a/src/gtkcompletionline.cc
+++ b/src/gtkcompletionline.cc
@@ -374,6 +374,27 @@ select_executables_only(const struct dirent* dent)
return 0;
}
+int my_alphasort(const struct dirent** a, const struct dirent** b) {
+ const char* s1 = (*a)->d_name;
+ const char* s2 = (*b)->d_name;
+
+ int l1 = strlen(s1);
+ int l2 = strlen(s2);
+ int result = strcmp(s1, s2);
+
+ if (result == 0) return 0;
+
+ if (l1 < l2) {
+ int res2 = strncmp(s1, s2, l1);
+ if (res2 == 0) return -1;
+ } else {
+ int res2 = strncmp(s1, s2, l2);
+ if (res2 == 0) return 1;
+ }
+
+ return result;
+}
+
static void
generate_execs()
{
@@ -381,7 +402,7 @@ generate_execs()
for (StrSet::iterator i = path.begin(); i != path.end(); i++) {
struct dirent **eps;
- int n = scandir(i->c_str(), &eps, select_executables_only, alphasort);
+ int n = scandir(i->c_str(), &eps, select_executables_only, my_alphasort);
if (n >= 0) {
for (int j = 0; j < n; j++) {
execs.insert(eps[j]->d_name);
@@ -481,7 +502,7 @@ generate_dirlist(const char *what)
dirlist.clear();
struct dirent **eps;
prefix = filename;
- n = scandir(dest.c_str(), &eps, select_executables_only, alphasort);
+ n = scandir(dest.c_str(), &eps, select_executables_only, my_alphasort);
if (n >= 0) {
for (int j = 0; j < n; j++) {
{