Removed prefixes from some static functions.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 30 Sep 2013 21:17:45 +0000 (23:17 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 30 Sep 2013 21:28:17 +0000 (23:28 +0200)
src/ex.c
src/map.c

index b39ca62..694f277 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -110,10 +110,10 @@ static gboolean ex_set(const ExArg *arg);
 static gboolean ex_shellcmd(const ExArg *arg);
 static gboolean ex_shortcut(const ExArg *arg);
 
-static gboolean ex_complete(short direction);
-static void ex_completion_select(char *match);
-static gboolean ex_history(gboolean prev);
-static void ex_history_rewind(void);
+static gboolean complete(short direction);
+static void completion_select(char *match);
+static gboolean history(gboolean prev);
+static void history_rewind(void);
 
 /* The order of following command names is significant. If there exists
  * ambiguous commands matching to the users input, the first defined will be
@@ -216,11 +216,11 @@ VbResult ex_keypress(unsigned int key)
 
     switch (key) {
         case CTRL('I'): /* Tab */
-            ex_complete(1);
+            complete(1);
             break;
 
         case CTRL('O'): /* S-Tab */
-            ex_complete(-1);
+            complete(-1);
             break;
 
         case CTRL('['):
@@ -234,11 +234,11 @@ VbResult ex_keypress(unsigned int key)
             break;
 
         case CTRL('P'): /* up */
-            ex_history(true);
+            history(true);
             break;
 
         case CTRL('N'): /* down */
-            ex_history(false);
+            history(false);
             break;
 
         /* basic command line editing */
@@ -841,7 +841,7 @@ static gboolean ex_shortcut(const ExArg *arg)
  * put hte matched data back to inputbox, and prepares the tree list store
  * model containing matched values.
  */
-static gboolean ex_complete(short direction)
+static gboolean complete(short direction)
 {
     char *input;            /* input read from inputbox */
     const char *in;         /* pointer to input that we move */
@@ -923,7 +923,7 @@ static gboolean ex_complete(short direction)
             in = before_cmdname;
 
             /* backup the parsed data so we can access them in
-             * ex_completion_select function */
+             * completion_select function */
             excomp.count = arg->count;
 
             if (ex_fill_completion(store, in)) {
@@ -947,7 +947,7 @@ static gboolean ex_complete(short direction)
         );
     }
     if (found
-        && completion_create(GTK_TREE_MODEL(store), ex_completion_select, direction < 0)
+        && completion_create(GTK_TREE_MODEL(store), completion_select, direction < 0)
     ) {
         /* set the submode flag */
         vb.mode->flags |= FLAG_COMPLETION;
@@ -962,7 +962,7 @@ static gboolean ex_complete(short direction)
  * matche item accordings with previously saved prefix and command name to the
  * inputbox.
  */
-static void ex_completion_select(char *match)
+static void completion_select(char *match)
 {
     OVERWRITE_STRING(excomp.current, NULL);
 
@@ -974,11 +974,9 @@ static void ex_completion_select(char *match)
     vb_set_input_text(excomp.current);
 }
 
-static gboolean ex_history(gboolean prev)
+static gboolean history(gboolean prev)
 {
-    int type;
-    char *input, prefix[2] = {0};
-    const char *in;
+    char *input;
     GList *new = NULL;
 
     input = vb_get_input_text();
@@ -988,14 +986,16 @@ static gboolean ex_history(gboolean prev)
          * rewind the history to recreate it later new */
         char *current = g_strconcat(exhist.prefix, (char*)exhist.active->data, NULL);
         if (strcmp(input, current)) {
-            ex_history_rewind();
+            history_rewind();
         }
         g_free(current);
     }
 
     /* create the history list if the lookup is started or input was changed */
     if (!exhist.active) {
-        in = (const char*)input;
+        int type;
+        char prefix[2] = {0};
+        const char *in = (const char*)input;
 
         skip_whitespace(&in);
 
@@ -1005,22 +1005,20 @@ static gboolean ex_history(gboolean prev)
         /* check which type of history we should use */
         if (*in == ':') {
             type = VB_INPUT_COMMAND;
-            in++;
         } else if (*in == '/' || *in == '?') {
             /* the history does not distinguish between forward and backward
              * search, so we don't need the backward search here too */
             type = VB_INPUT_SEARCH_FORWARD;
-            in++;
+        } else {
+            goto failed;
         }
-        exhist.active = history_get_list(type, in);
-        if (!exhist.active) {
-            g_free(input);
 
-            return false;
+        exhist.active = history_get_list(type, in + 1);
+        if (!exhist.active) {
+            goto failed;
         }
         OVERWRITE_STRING(exhist.prefix, prefix);
     }
-    g_free(input);
 
     if (prev) {
         if ((new = g_list_next(exhist.active))) {
@@ -1032,10 +1030,15 @@ static gboolean ex_history(gboolean prev)
 
     vb_echo_force(VB_MSG_NORMAL, false, "%s%s", exhist.prefix, (char*)exhist.active->data);
 
+    g_free(input);
     return true;
+
+failed:
+    g_free(input);
+    return false;
 }
 
-static void ex_history_rewind(void)
+static void history_rewind(void)
 {
     if (exhist.active) {
         /* free temporary used history list */
index a7784bd..1bc423d 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -42,9 +42,9 @@ static struct {
     char   showbuf[10];             /* buffer to shw ambiguous key sequence */
 } map;
 
-static char *map_convert_keys(char *in, int inlen, int *len);
-static char *map_convert_keylabel(char *in, int inlen, int *len);
-static gboolean map_timeout(gpointer data);
+static char *convert_keys(char *in, int inlen, int *len);
+static char *convert_keylabel(char *in, int inlen, int *len);
+static gboolean do_timeout(gpointer data);
 static void showcmd(char *keys, int keylen);
 static char* transchar(char c);
 static void free_map(Map *map);
@@ -167,7 +167,7 @@ MapState map_handle_keys(const char *keys, int keylen)
         if (map.timout_id) {
             g_source_remove(map.timout_id);
         }
-        map.timout_id = g_timeout_add(vb.config.timeoutlen, (GSourceFunc)map_timeout, NULL);
+        map.timout_id = g_timeout_add(vb.config.timeoutlen, (GSourceFunc)do_timeout, NULL);
     }
 
     /* copy the keys onto the end of queue */
@@ -297,8 +297,8 @@ MapState map_handle_keys(const char *keys, int keylen)
 void map_insert(char *in, char *mapped, char mode)
 {
     int inlen, mappedlen;
-    char *lhs = map_convert_keys(in, strlen(in), &inlen);
-    char *rhs = map_convert_keys(mapped, strlen(mapped), &mappedlen);
+    char *lhs = convert_keys(in, strlen(in), &inlen);
+    char *rhs = convert_keys(mapped, strlen(mapped), &mappedlen);
 
     /* TODO replace keysymbols in 'in' and 'mapped' string */
     Map *new = g_new(Map, 1);
@@ -314,7 +314,7 @@ void map_insert(char *in, char *mapped, char mode)
 gboolean map_delete(char *in, char mode)
 {
     int len;
-    char *lhs = map_convert_keys(in, strlen(in), &len);
+    char *lhs = convert_keys(in, strlen(in), &len);
 
     for (GSList *l = map.list; l != NULL; l = l->next) {
         Map *m = (Map*)l->data;
@@ -335,7 +335,7 @@ gboolean map_delete(char *in, char mode)
  * Converts a keysequence into a internal raw keysequence.
  * Returned keyseqence must be freed if not used anymore.
  */
-static char *map_convert_keys(char *in, int inlen, int *len)
+static char *convert_keys(char *in, int inlen, int *len)
 {
     int symlen, rawlen;
     char *p, *dest, *raw;
@@ -385,7 +385,7 @@ static char *map_convert_keys(char *in, int inlen, int *len)
 
             /* if we could not convert it jet - try to translate the label */
             if (!rawlen) {
-                raw = map_convert_keylabel(p, symlen, &rawlen);
+                raw = convert_keylabel(p, symlen, &rawlen);
             }
         }
 
@@ -415,7 +415,7 @@ static char *map_convert_keys(char *in, int inlen, int *len)
  * Translate given key string into a internal representation <cr> -> \n.
  * The len of the translated key sequence is put into given *len pointer.
  */
-static char *map_convert_keylabel(char *in, int inlen, int *len)
+static char *convert_keylabel(char *in, int inlen, int *len)
 {
     static struct {
         char *label;
@@ -473,7 +473,7 @@ static char *map_convert_keylabel(char *in, int inlen, int *len)
 /**
  * Timeout function to signalize a key timeout to the map.
  */
-static gboolean map_timeout(gpointer data)
+static gboolean do_timeout(gpointer data)
 {
     /* signalize the timeout to the key handler */
     map_handle_keys("", 0);