diff --git a/src/bfu/listmenu.c b/src/bfu/listmenu.c index 31cf654d3..ee85fc688 100644 --- a/src/bfu/listmenu.c +++ b/src/bfu/listmenu.c @@ -4,6 +4,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include #include #include @@ -27,7 +31,7 @@ static int menu_contains(struct menu_item *m, int f) { if (m->func != do_select_submenu) - return (long) m->data == f; + return (intptr_t) m->data == f; foreach_menu_item (m, m->data) { if (menu_contains(m, f)) @@ -113,7 +117,7 @@ new_menu_item(struct list_menu *menu, char *name, int data, int fullname) } else { add_to_menu(items, name, NULL, ACT_MAIN_NONE, selected_item, - (void *) (long) data, (fullname ? MENU_FULLNAME : 0)); + (void *) (intptr_t) data, (fullname ? MENU_FULLNAME : 0)); } if (stack_size >= 2) { @@ -185,7 +189,7 @@ menu_labels(struct menu_item *items, const char *base, char **lbls) mem_free(bs); } else { assert(item->func == selected_item); - lbls[(long) item->data] = bs; + lbls[(intptr_t) item->data] = bs; } } } diff --git a/src/config/options.c b/src/config/options.c index 6fa690730..7b82be22c 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -4,6 +4,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include #include @@ -558,7 +562,7 @@ add_opt(struct option *tree, const char *path, const char *capt, option->value.number = (int) value; break; case OPT_LONG: - option->value.big_number = (long) value; /* FIXME: cast from void * */ + option->value.big_number = (intptr_t) value; /* FIXME: cast from void * */ break; case OPT_COLOR: decode_color((char *) value, strlen((char *) value), diff --git a/src/config/options.h b/src/config/options.h index 6b0c507df..5c50d56ea 100644 --- a/src/config/options.h +++ b/src/config/options.h @@ -1,4 +1,3 @@ - #ifndef EL__CONFIG_OPTIONS_H #define EL__CONFIG_OPTIONS_H @@ -152,7 +151,7 @@ union option_value { int number; /** Used by ::OPT_LONG */ - long big_number; + intptr_t big_number; /** The ::OPT_COLOR value */ color_T color; diff --git a/src/dialogs/info.cpp b/src/dialogs/info.cpp index bb7e4c3ea..dcb241ae4 100644 --- a/src/dialogs/info.cpp +++ b/src/dialogs/info.cpp @@ -4,6 +4,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include #include #include @@ -53,14 +57,14 @@ push_toggle_keys_display_button(void *data) { struct keys_toggle_info *info = (struct keys_toggle_info *)data; - menu_keys(info->term, (void *) (long) !info->toggle, NULL); + menu_keys(info->term, (void *) (intptr_t) !info->toggle, NULL); } void menu_keys(struct terminal *term, void *d_, void *xxx) { /* [gettext_accelerator_context(menu_keys)] */ - int d = (long) d_; + int d = (intptr_t) d_; /* We scale by main mapping because it has the most actions */ action_id_T action_ids[MAIN_ACTIONS] = { diff --git a/src/dialogs/options.c b/src/dialogs/options.c index 5177a5793..0e103eff2 100644 --- a/src/dialogs/options.c +++ b/src/dialogs/options.c @@ -4,6 +4,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include #include #include @@ -252,7 +256,7 @@ terminal_options(struct terminal *term, void *xxx, struct session *ses) static void menu_set_language(struct terminal *term, void *pcp_, void *xxx) { - int pcp = (long) pcp_; + int pcp = (intptr_t) pcp_; set_language(pcp); cls_redraw_all_terminals(); @@ -269,7 +273,7 @@ menu_language_list(struct terminal *term, void *xxx, void *ses) if (!mi) return; for (i = 0; languages[i].name; i++) { add_to_menu(&mi, languages[i].name, language_to_iso639(i), ACT_MAIN_NONE, - menu_set_language, (void *) (long) i, 0); + menu_set_language, (void *) (intptr_t) i, 0); } do_menu_selected(term, mi, ses, current_language, 0); diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 9759766f3..1a2caea0f 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -4,6 +4,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + /* Our current implementation of combining characters requires * wcwidth(). Therefore the configure script should have disabled * CONFIG_COMBINE if wcwidth() doesn't exist. */ @@ -2282,7 +2286,7 @@ html_special(struct html_context *html_context, html_special_type_T c, ...) ret_val = renderer_context.convert_table; break; case SP_USED: - ret_val = (void *) (long) !!document; + ret_val = (void *) (intptr_t) !!document; break; case SP_CACHE_CONTROL: { diff --git a/src/intl/charsets.c b/src/intl/charsets.c index c797432e2..5f4427198 100644 --- a/src/intl/charsets.c +++ b/src/intl/charsets.c @@ -8,6 +8,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #if HAVE_LANGINFO_CODESET #include #endif @@ -815,7 +819,7 @@ get_combined(unicode_val_T *data, int length) if (!combined_hash) return UCS_NO_CHAR; item = get_hash_item(combined_hash, (char *)data, length * sizeof(*data)); - if (item) return (unicode_val_T)(long)item->value; + if (item) return (unicode_val_T)(intptr_t)item->value; if (last_combined >= UCS_END_COMBINED) return UCS_NO_CHAR; key = (unicode_val_T *)mem_alloc((length + 1) * sizeof(*key)); @@ -835,7 +839,7 @@ get_combined(unicode_val_T *data, int length) } combined[indeks] = key; item = add_hash_item(combined_hash, (char *)key, - length * sizeof(*data), (void *)(long)(last_combined)); + length * sizeof(*data), (void *)(intptr_t)(last_combined)); if (!item) { last_combined--; mem_free(key); diff --git a/src/protocol/gemini/codes.c b/src/protocol/gemini/codes.c index f7e42e238..86d95f5a6 100644 --- a/src/protocol/gemini/codes.c +++ b/src/protocol/gemini/codes.c @@ -8,6 +8,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include "elinks.h" #include "cache/cache.h" @@ -52,7 +56,7 @@ static const struct gemini_code gemini_code[] = { static int compare_gemini_codes(const void *key, const void *element) { - int first = (long) key; + int first = (intptr_t) key; int second = ((const struct gemini_code *) element)->num; return first - second; @@ -62,7 +66,7 @@ static const char * gemini_code_to_string(int code) { const struct gemini_code *element - = (const struct gemini_code *)bsearch((void *) (long) code, gemini_code, + = (const struct gemini_code *)bsearch((void *) (intptr_t) code, gemini_code, sizeof_array(gemini_code), sizeof(*element), compare_gemini_codes); diff --git a/src/protocol/http/codes.c b/src/protocol/http/codes.c index 5dac1dd7a..209488d01 100644 --- a/src/protocol/http/codes.c +++ b/src/protocol/http/codes.c @@ -8,6 +8,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include "elinks.h" #include "cache/cache.h" @@ -76,7 +80,7 @@ static const struct http_code http_code[] = { static int compare_http_codes(const void *key, const void *element) { - int first = (long) key; + int first = (intptr_t) key; int second = ((const struct http_code *) element)->num; return first - second; @@ -86,7 +90,7 @@ static const char * http_code_to_string(int code) { const struct http_code *element - = (const struct http_code *)bsearch((void *) (long) code, http_code, + = (const struct http_code *)bsearch((void *) (intptr_t) code, http_code, sizeof_array(http_code), sizeof(*element), compare_http_codes); diff --git a/src/scripting/lua/core.c b/src/scripting/lua/core.c index 70ddc9e6c..3156c8915 100644 --- a/src/scripting/lua/core.c +++ b/src/scripting/lua/core.c @@ -4,6 +4,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include #include #include @@ -286,7 +290,7 @@ static enum evhook_status run_lua_func(va_list ap, void *data) { struct session *ses = va_arg(ap, struct session *); - int func_ref = (long) data; + int func_ref = (intptr_t) data; if (func_ref == LUA_NOREF) { alert_lua_error("key bound to nothing (internal error)"); @@ -336,7 +340,7 @@ l_bind_key(LS) if (!err) { event_id = register_event_hook(event_id, run_lua_func, 0, - (void *) (long) ref); + (void *) (intptr_t) ref); if (event_id == EVENT_NONE) err = gettext("Error registering event hook"); diff --git a/src/session/session.cpp b/src/session/session.cpp index 486e39ef1..4bec06a2d 100644 --- a/src/session/session.cpp +++ b/src/session/session.cpp @@ -5,6 +5,10 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif + #include #include #include @@ -172,7 +176,7 @@ add_session_info(struct session *ses, struct uri *uri, struct uri *referrer, * but it won't hurt to have a few seconds atleast. --jonas */ install_timer(&info->timer, (milliseconds_T) 10000, (void (*)(void *)) session_info_timeout, - (void *) (long) info->id); + (void *) (intptr_t) info->id); info->ses = ses; info->task = task; diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index 9431b65aa..553516d91 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -8,6 +8,9 @@ #include "config.h" #endif +#ifdef HAVE_STDINT_H +#include +#endif #include #include #ifdef HAVE_TERMIOS_H @@ -398,7 +401,7 @@ handle_trm(int std_in, int std_out, int sock_in, int sock_out, int ctl_in, } -/** A select_handler_T read_func and error_func for the pipe (long) @a h. +/** A select_handler_T read_func and error_func for the pipe (intptr_t) @a h. * This is called when the subprocess started on the terminal of this * ELinks process exits. ELinks then resumes using the terminal. */ static void @@ -708,11 +711,11 @@ has_nul_byte: if (fg == TERM_EXEC_FG) { set_handlers(blockh, (select_handler_T) unblock_itrm_x, NULL, (select_handler_T) unblock_itrm_x, - (void *) (long) blockh); + (void *) (intptr_t) blockh); } else { set_handlers(blockh, close_handle, NULL, close_handle, - (void *) (long) blockh); + (void *) (intptr_t) blockh); } } diff --git a/src/terminal/terminal.cpp b/src/terminal/terminal.cpp index 9bf1a43a4..fb4ad1ed9 100644 --- a/src/terminal/terminal.cpp +++ b/src/terminal/terminal.cpp @@ -7,6 +7,9 @@ #include #include +#ifdef HAVE_STDINT_H +#include +#endif #include #include #ifdef HAVE_UNISTD_H @@ -247,14 +250,14 @@ exec_thread(char *path, int p) void close_handle(void *h) { - close((long) h); - clear_handlers((long) h); + close((intptr_t) h); + clear_handlers((intptr_t) h); } static void unblock_terminal(struct terminal *term) { - close_handle((void *) (long) term->blocked); + close_handle((void *) (intptr_t) term->blocked); term->blocked = -1; set_handlers(term->fdin, (select_handler_T) in_term, NULL, (select_handler_T) destroy_terminal, term); @@ -325,7 +328,7 @@ exec_on_master_terminal(struct terminal *term, } else { set_handlers(blockh, close_handle, NULL, - close_handle, (void *) (long) blockh); + close_handle, (void *) (intptr_t) blockh); } }