From 2e7a7a5ca315578d53c9003ab355cbe45eb3abe7 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 20 Apr 2016 20:57:09 +0200 Subject: [PATCH] Compilation fixes for C++ --- src/config/conf.c | 20 ++++++----- src/config/dialogs.c | 2 +- src/config/kbdbind.c | 83 ++++++++++++++++++++++---------------------- 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/config/conf.c b/src/config/conf.c index 8355f4e1..26fbc4c9 100644 --- a/src/config/conf.c +++ b/src/config/conf.c @@ -57,19 +57,21 @@ * value to an option, but sometimes you may want to first create the option * ;). Then this will come handy. */ +struct conf_parsing_pos { + /** Points to the next character to be parsed from the + * configuration file. */ + unsigned char *look; + + /** The line number corresponding to #look. This is + * shown in error messages. */ + int line; +}; + struct conf_parsing_state { /** This part may be copied to a local variable as a bookmark * and restored later. So it must not contain any pointers * that would have to be freed in that situation. */ - struct conf_parsing_pos { - /** Points to the next character to be parsed from the - * configuration file. */ - unsigned char *look; - - /** The line number corresponding to #look. This is - * shown in error messages. */ - int line; - } pos; + struct conf_parsing_pos pos; /** When ELinks is rewriting the configuration file, @c mirrored * indicates the end of the part that has already been copied diff --git a/src/config/dialogs.c b/src/config/dialogs.c index afb21ed7..6a8c7972 100644 --- a/src/config/dialogs.c +++ b/src/config/dialogs.c @@ -552,7 +552,7 @@ init_keybinding_listboxes(struct keymap keymap_table[KEYMAP_MAX], { struct listbox_item *root = &keybinding_browser.root; const struct action *act; - enum keymap_id keymap_id; + int keymap_id; /* Do it backwards because add_listbox_item() add to front * of list. */ diff --git a/src/config/kbdbind.c b/src/config/kbdbind.c index 53ca020c..e742487e 100644 --- a/src/config/kbdbind.c +++ b/src/config/kbdbind.c @@ -26,8 +26,42 @@ /* Fix namespace clash on MacOS. */ #define table table_elinks -static const struct action_list action_table[KEYMAP_MAX]; -static struct keymap keymap_table[KEYMAP_MAX]; +#define ACTION_(map, name, action, caption, flags) \ + { name, ACT_##map##_##action, KEYMAP_ID, caption, flags } + +#undef KEYMAP_ID +#define KEYMAP_ID KEYMAP_MAIN +static const struct action main_action_table[MAIN_ACTIONS + 1] = { +#include "config/actions-main.inc" +}; + +#undef KEYMAP_ID +#define KEYMAP_ID KEYMAP_EDIT +static const struct action edit_action_table[EDIT_ACTIONS + 1] = { +#include "config/actions-edit.inc" +}; + +#undef KEYMAP_ID +#define KEYMAP_ID KEYMAP_MENU +static const struct action menu_action_table[MENU_ACTIONS + 1] = { +#include "config/actions-menu.inc" +}; + +static const struct action_list action_table[KEYMAP_MAX] = { + { main_action_table, sizeof_array(main_action_table) }, + { edit_action_table, sizeof_array(edit_action_table) }, + { menu_action_table, sizeof_array(menu_action_table) }, +}; + +#undef KEYMAP_ID +#undef ACTION_ + +static struct keymap keymap_table[] = { + { "main", KEYMAP_MAIN, N_("Main mapping") }, + { "edit", KEYMAP_EDIT, N_("Edit mapping") }, + { "menu", KEYMAP_MENU, N_("Menu mapping") }, +}; + static LIST_OF(struct keybinding) keymaps[KEYMAP_MAX]; static void add_default_keybindings(void); @@ -218,11 +252,6 @@ kbd_stroke_lookup(enum keymap_id keymap_id, const unsigned char *keystroke_str) } -static struct keymap keymap_table[] = { - { "main", KEYMAP_MAIN, N_("Main mapping") }, - { "edit", KEYMAP_EDIT, N_("Edit mapping") }, - { "menu", KEYMAP_MENU, N_("Menu mapping") }, -}; /* @@ -303,7 +332,7 @@ get_keymap(enum keymap_id keymap_id) static enum keymap_id get_keymap_id(unsigned char *keymap_str) { - enum keymap_id keymap_id; + int keymap_id; for (keymap_id = 0; keymap_id < KEYMAP_MAX; keymap_id++) if (!strcmp(keymap_table[keymap_id].str, keymap_str)) @@ -523,41 +552,11 @@ add_actions_to_string(struct string *string, action_id_T action_ids[], } } -#define ACTION_(map, name, action, caption, flags) \ - { name, ACT_##map##_##action, KEYMAP_ID, caption, flags } - -#undef KEYMAP_ID -#define KEYMAP_ID KEYMAP_MAIN -static const struct action main_action_table[MAIN_ACTIONS + 1] = { -#include "config/actions-main.inc" -}; - -#undef KEYMAP_ID -#define KEYMAP_ID KEYMAP_EDIT -static const struct action edit_action_table[EDIT_ACTIONS + 1] = { -#include "config/actions-edit.inc" -}; - -#undef KEYMAP_ID -#define KEYMAP_ID KEYMAP_MENU -static const struct action menu_action_table[MENU_ACTIONS + 1] = { -#include "config/actions-menu.inc" -}; - -static const struct action_list action_table[KEYMAP_MAX] = { - { main_action_table, sizeof_array(main_action_table) }, - { edit_action_table, sizeof_array(edit_action_table) }, - { menu_action_table, sizeof_array(menu_action_table) }, -}; - -#undef KEYMAP_ID -#undef ACTION_ - static void init_keymaps(struct module *xxx) { - enum keymap_id keymap_id; + int keymap_id; for (keymap_id = 0; keymap_id < KEYMAP_MAX; keymap_id++) init_list(keymaps[keymap_id]); @@ -569,7 +568,7 @@ init_keymaps(struct module *xxx) static void free_keymaps(struct module *xxx) { - enum keymap_id keymap_id; + int keymap_id; done_keybinding_listboxes(); @@ -829,7 +828,7 @@ add_default_keybindings(void) /* Maybe we shouldn't delete old keybindings. But on the other side, we * can't trust clueless users what they'll push into sources modifying * defaults, can we? ;)) */ - enum keymap_id keymap_id; + int keymap_id; for (keymap_id = 0; keymap_id < KEYMAP_MAX; keymap_id++) { struct default_kb *kb; @@ -978,7 +977,7 @@ single_bind_config_string(struct string *file, enum keymap_id keymap_id, void bind_config_string(struct string *file) { - enum keymap_id keymap_id; + int keymap_id; for (keymap_id = 0; keymap_id < KEYMAP_MAX; keymap_id++) { struct keybinding *keybinding;