about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-08 21:03:26 +0000
committerJames Booth <boothj5@gmail.com>2015-02-08 21:03:26 +0000
commit8cec79faef1b0f49ee0d951aef5234724973a48f (patch)
treeffa34c550b1497f0a6394beaed167d22c50aa0d4 /src
parent129af0eafd7ccf2629e60f3cfb398a0f22492b63 (diff)
parent44c5b34a710f7c90b455ec92146530f95e25ab90 (diff)
downloadprofani-tty-8cec79faef1b0f49ee0d951aef5234724973a48f.tar.gz
Merge branch 'master' into readline
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c12
-rw-r--r--src/common.c22
-rw-r--r--src/common.h1
3 files changed, 33 insertions, 2 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 565facac..81b401f0 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1962,23 +1962,31 @@ _cmd_complete_parameters(const char * const input)
         if (nick_ac) {
             gchar *nick_choices[] = { "/msg", "/info", "/caps", "/status", "/software" } ;
 
+            // Remove quote character before and after names when doing autocomplete
+            char *unquoted = strip_arg_quotes(input);
             for (i = 0; i < ARRAY_SIZE(nick_choices); i++) {
-                result = autocomplete_param_with_ac(input, nick_choices[i], nick_ac, TRUE);
+                result = autocomplete_param_with_ac(unquoted, nick_choices[i], nick_ac, TRUE);
                 if (result) {
+                    free(unquoted);
                     return result;
                 }
             }
+            free(unquoted);
         }
 
     // otherwise autocomplete using roster
     } else {
         gchar *contact_choices[] = { "/msg", "/info", "/status" };
+        // Remove quote character before and after names when doing autocomplete
+        char *unquoted = strip_arg_quotes(input);
         for (i = 0; i < ARRAY_SIZE(contact_choices); i++) {
-            result = autocomplete_param_with_func(input, contact_choices[i], roster_contact_autocomplete);
+            result = autocomplete_param_with_func(unquoted, contact_choices[i], roster_contact_autocomplete);
             if (result) {
+                free(unquoted);
                 return result;
             }
         }
+        free(unquoted);
 
         gchar *resource_choices[] = { "/caps", "/software", "/ping" };
         for (i = 0; i < ARRAY_SIZE(resource_choices); i++) {
diff --git a/src/common.c b/src/common.c
index 6c130798..0c10a568 100644
--- a/src/common.c
+++ b/src/common.c
@@ -578,3 +578,25 @@ get_file_or_linked(char *loc, char *basedir)
 
     return true_loc;
 }
+
+char *
+strip_arg_quotes(const char * const input)
+{
+    char *unquoted = strdup(input);
+
+    // Remove starting quote if it exists
+    if(strchr(unquoted, '"') != NULL) {
+        if(strchr(unquoted, ' ') + 1 == strchr(unquoted, '"')) {
+            memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
+        }
+    }
+
+    // Remove ending quote if it exists
+    if(strchr(unquoted, '"') != NULL) {
+        if(strchr(unquoted, '\0') - 1 == strchr(unquoted, '"')) {
+            memmove(strchr(unquoted, '"'), strchr(unquoted, '"')+1, strchr(unquoted, '\0') - strchr(unquoted, '"'));
+        }
+    }
+
+    return unquoted;
+}
diff --git a/src/common.h b/src/common.h
index 8d35f99b..a19b3ea2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -131,5 +131,6 @@ int cmp_win_num(gconstpointer a, gconstpointer b);
 int get_next_available_win_num(GList *used);
 
 char* get_file_or_linked(char *loc, char *basedir);
+char * strip_arg_quotes(const char * const input);
 
 #endif