1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[long] long -> intptr_t . Refs #8304

AFAIK on Windows long is sizeof 4, while void * is sizeof 8.
intptr_t is the same sizeof as void *.
This commit is contained in:
Witold Filipczyk 2022-08-17 20:48:58 +02:00
parent 9ed288c717
commit 361b8f661d
13 changed files with 72 additions and 27 deletions

View File

@ -4,6 +4,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@ -27,7 +31,7 @@ static int
menu_contains(struct menu_item *m, int f) menu_contains(struct menu_item *m, int f)
{ {
if (m->func != do_select_submenu) if (m->func != do_select_submenu)
return (long) m->data == f; return (intptr_t) m->data == f;
foreach_menu_item (m, m->data) { foreach_menu_item (m, m->data) {
if (menu_contains(m, f)) if (menu_contains(m, f))
@ -113,7 +117,7 @@ new_menu_item(struct list_menu *menu, char *name, int data, int fullname)
} else { } else {
add_to_menu(items, name, NULL, ACT_MAIN_NONE, add_to_menu(items, name, NULL, ACT_MAIN_NONE,
selected_item, selected_item,
(void *) (long) data, (fullname ? MENU_FULLNAME : 0)); (void *) (intptr_t) data, (fullname ? MENU_FULLNAME : 0));
} }
if (stack_size >= 2) { if (stack_size >= 2) {
@ -185,7 +189,7 @@ menu_labels(struct menu_item *items, const char *base, char **lbls)
mem_free(bs); mem_free(bs);
} else { } else {
assert(item->func == selected_item); assert(item->func == selected_item);
lbls[(long) item->data] = bs; lbls[(intptr_t) item->data] = bs;
} }
} }
} }

View File

@ -4,6 +4,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
@ -558,7 +562,7 @@ add_opt(struct option *tree, const char *path, const char *capt,
option->value.number = (int) value; option->value.number = (int) value;
break; break;
case OPT_LONG: 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; break;
case OPT_COLOR: case OPT_COLOR:
decode_color((char *) value, strlen((char *) value), decode_color((char *) value, strlen((char *) value),

View File

@ -1,4 +1,3 @@
#ifndef EL__CONFIG_OPTIONS_H #ifndef EL__CONFIG_OPTIONS_H
#define EL__CONFIG_OPTIONS_H #define EL__CONFIG_OPTIONS_H
@ -152,7 +151,7 @@ union option_value {
int number; int number;
/** Used by ::OPT_LONG */ /** Used by ::OPT_LONG */
long big_number; intptr_t big_number;
/** The ::OPT_COLOR value */ /** The ::OPT_COLOR value */
color_T color; color_T color;

View File

@ -4,6 +4,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -53,14 +57,14 @@ push_toggle_keys_display_button(void *data)
{ {
struct keys_toggle_info *info = (struct keys_toggle_info *)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 void
menu_keys(struct terminal *term, void *d_, void *xxx) menu_keys(struct terminal *term, void *d_, void *xxx)
{ {
/* [gettext_accelerator_context(menu_keys)] */ /* [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 */ /* We scale by main mapping because it has the most actions */
action_id_T action_ids[MAIN_ACTIONS] = { action_id_T action_ids[MAIN_ACTIONS] = {

View File

@ -4,6 +4,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -252,7 +256,7 @@ terminal_options(struct terminal *term, void *xxx, struct session *ses)
static void static void
menu_set_language(struct terminal *term, void *pcp_, void *xxx) menu_set_language(struct terminal *term, void *pcp_, void *xxx)
{ {
int pcp = (long) pcp_; int pcp = (intptr_t) pcp_;
set_language(pcp); set_language(pcp);
cls_redraw_all_terminals(); cls_redraw_all_terminals();
@ -269,7 +273,7 @@ menu_language_list(struct terminal *term, void *xxx, void *ses)
if (!mi) return; if (!mi) return;
for (i = 0; languages[i].name; i++) { for (i = 0; languages[i].name; i++) {
add_to_menu(&mi, languages[i].name, language_to_iso639(i), ACT_MAIN_NONE, 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); do_menu_selected(term, mi, ses, current_language, 0);

View File

@ -4,6 +4,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
/* Our current implementation of combining characters requires /* Our current implementation of combining characters requires
* wcwidth(). Therefore the configure script should have disabled * wcwidth(). Therefore the configure script should have disabled
* CONFIG_COMBINE if wcwidth() doesn't exist. */ * 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; ret_val = renderer_context.convert_table;
break; break;
case SP_USED: case SP_USED:
ret_val = (void *) (long) !!document; ret_val = (void *) (intptr_t) !!document;
break; break;
case SP_CACHE_CONTROL: case SP_CACHE_CONTROL:
{ {

View File

@ -8,6 +8,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_LANGINFO_CODESET #if HAVE_LANGINFO_CODESET
#include <langinfo.h> #include <langinfo.h>
#endif #endif
@ -815,7 +819,7 @@ get_combined(unicode_val_T *data, int length)
if (!combined_hash) return UCS_NO_CHAR; if (!combined_hash) return UCS_NO_CHAR;
item = get_hash_item(combined_hash, (char *)data, length * sizeof(*data)); 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; if (last_combined >= UCS_END_COMBINED) return UCS_NO_CHAR;
key = (unicode_val_T *)mem_alloc((length + 1) * sizeof(*key)); 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; combined[indeks] = key;
item = add_hash_item(combined_hash, (char *)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) { if (!item) {
last_combined--; last_combined--;
mem_free(key); mem_free(key);

View File

@ -8,6 +8,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include "elinks.h" #include "elinks.h"
#include "cache/cache.h" #include "cache/cache.h"
@ -52,7 +56,7 @@ static const struct gemini_code gemini_code[] = {
static int static int
compare_gemini_codes(const void *key, const void *element) 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; int second = ((const struct gemini_code *) element)->num;
return first - second; return first - second;
@ -62,7 +66,7 @@ static const char *
gemini_code_to_string(int code) gemini_code_to_string(int code)
{ {
const struct gemini_code *element 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_array(gemini_code),
sizeof(*element), sizeof(*element),
compare_gemini_codes); compare_gemini_codes);

View File

@ -8,6 +8,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include "elinks.h" #include "elinks.h"
#include "cache/cache.h" #include "cache/cache.h"
@ -76,7 +80,7 @@ static const struct http_code http_code[] = {
static int static int
compare_http_codes(const void *key, const void *element) 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; int second = ((const struct http_code *) element)->num;
return first - second; return first - second;
@ -86,7 +90,7 @@ static const char *
http_code_to_string(int code) http_code_to_string(int code)
{ {
const struct http_code *element 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_array(http_code),
sizeof(*element), sizeof(*element),
compare_http_codes); compare_http_codes);

View File

@ -4,6 +4,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <setjmp.h> #include <setjmp.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
@ -286,7 +290,7 @@ static enum evhook_status
run_lua_func(va_list ap, void *data) run_lua_func(va_list ap, void *data)
{ {
struct session *ses = va_arg(ap, struct session *); struct session *ses = va_arg(ap, struct session *);
int func_ref = (long) data; int func_ref = (intptr_t) data;
if (func_ref == LUA_NOREF) { if (func_ref == LUA_NOREF) {
alert_lua_error("key bound to nothing (internal error)"); alert_lua_error("key bound to nothing (internal error)");
@ -336,7 +340,7 @@ l_bind_key(LS)
if (!err) { if (!err) {
event_id = register_event_hook(event_id, run_lua_func, 0, event_id = register_event_hook(event_id, run_lua_func, 0,
(void *) (long) ref); (void *) (intptr_t) ref);
if (event_id == EVENT_NONE) if (event_id == EVENT_NONE)
err = gettext("Error registering event hook"); err = gettext("Error registering event hook");

View File

@ -5,6 +5,10 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -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 */ * but it won't hurt to have a few seconds atleast. --jonas */
install_timer(&info->timer, (milliseconds_T) 10000, install_timer(&info->timer, (milliseconds_T) 10000,
(void (*)(void *)) session_info_timeout, (void (*)(void *)) session_info_timeout,
(void *) (long) info->id); (void *) (intptr_t) info->id);
info->ses = ses; info->ses = ses;
info->task = task; info->task = task;

View File

@ -8,6 +8,9 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_TERMIOS_H #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 * This is called when the subprocess started on the terminal of this
* ELinks process exits. ELinks then resumes using the terminal. */ * ELinks process exits. ELinks then resumes using the terminal. */
static void static void
@ -708,11 +711,11 @@ has_nul_byte:
if (fg == TERM_EXEC_FG) { if (fg == TERM_EXEC_FG) {
set_handlers(blockh, (select_handler_T) unblock_itrm_x, set_handlers(blockh, (select_handler_T) unblock_itrm_x,
NULL, (select_handler_T) unblock_itrm_x, NULL, (select_handler_T) unblock_itrm_x,
(void *) (long) blockh); (void *) (intptr_t) blockh);
} else { } else {
set_handlers(blockh, close_handle, NULL, close_handle, set_handlers(blockh, close_handle, NULL, close_handle,
(void *) (long) blockh); (void *) (intptr_t) blockh);
} }
} }

View File

@ -7,6 +7,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
@ -247,14 +250,14 @@ exec_thread(char *path, int p)
void void
close_handle(void *h) close_handle(void *h)
{ {
close((long) h); close((intptr_t) h);
clear_handlers((long) h); clear_handlers((intptr_t) h);
} }
static void static void
unblock_terminal(struct terminal *term) unblock_terminal(struct terminal *term)
{ {
close_handle((void *) (long) term->blocked); close_handle((void *) (intptr_t) term->blocked);
term->blocked = -1; term->blocked = -1;
set_handlers(term->fdin, (select_handler_T) in_term, NULL, set_handlers(term->fdin, (select_handler_T) in_term, NULL,
(select_handler_T) destroy_terminal, term); (select_handler_T) destroy_terminal, term);
@ -325,7 +328,7 @@ exec_on_master_terminal(struct terminal *term,
} else { } else {
set_handlers(blockh, close_handle, NULL, set_handlers(blockh, close_handle, NULL,
close_handle, (void *) (long) blockh); close_handle, (void *) (intptr_t) blockh);
} }
} }