1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-15 23:35:34 +00: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"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
@ -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;
}
}
}

View File

@ -4,6 +4,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <ctype.h>
#include <string.h>
@ -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),

View File

@ -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;

View File

@ -4,6 +4,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.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;
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] = {

View File

@ -4,6 +4,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -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);

View File

@ -4,6 +4,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#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:
{

View File

@ -8,6 +8,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_LANGINFO_CODESET
#include <langinfo.h>
#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);

View File

@ -8,6 +8,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#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);

View File

@ -8,6 +8,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#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);

View File

@ -4,6 +4,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
@ -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");

View File

@ -5,6 +5,10 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.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 */
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;

View File

@ -8,6 +8,9 @@
#include "config.h"
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdlib.h>
#include <string.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
* 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);
}
}

View File

@ -7,6 +7,9 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#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);
}
}