133 // Returns the number of possible completions. |
134 // Returns the number of possible completions. |
134 guint new_completion(const char *prefix, GSList *compl_cat, const gchar *suffix) |
135 guint new_completion(const char *prefix, GSList *compl_cat, const gchar *suffix) |
135 { |
136 { |
136 compl *c; |
137 compl *c; |
137 GSList *sl_cat; |
138 GSList *sl_cat; |
|
139 gint (*cmp)(const char *s1, const char *s2, size_t n); |
138 size_t len = strlen(prefix); |
140 size_t len = strlen(prefix); |
139 |
141 |
140 if (InputCompl) { // This should not happen, but hey... |
142 if (InputCompl) { // This should not happen, but hey... |
141 cancel_completion(); |
143 cancel_completion(); |
142 } |
144 } |
|
145 |
|
146 if (settings_opt_get_int("completion_ignore_case")) |
|
147 cmp = &strncasecmp; |
|
148 else |
|
149 cmp = &strncmp; |
143 |
150 |
144 c = g_new0(compl, 1); |
151 c = g_new0(compl, 1); |
145 // Build the list of matches |
152 // Build the list of matches |
146 for (sl_cat = compl_cat; sl_cat; sl_cat = g_slist_next(sl_cat)) { |
153 for (sl_cat = compl_cat; sl_cat; sl_cat = g_slist_next(sl_cat)) { |
147 char *word = sl_cat->data; |
154 char *word = sl_cat->data; |
148 if (!strncasecmp(prefix, word, len)) { |
155 if (!cmp(prefix, word, len)) { |
149 if (strlen(word) != len) { |
156 if (strlen(word) != len) { |
150 gchar *compval; |
157 gchar *compval; |
151 if (suffix) |
158 if (suffix) |
152 compval = g_strdup_printf("%s%s", word+len, suffix); |
159 compval = g_strdup_printf("%s%s", word+len, suffix); |
153 else |
160 else |