Commit: 2c6a995c97990dcf85365262945b5a640b38ba3c
Parent: cefc42c4c0eea41086161d1c3560d9fb1fd5b4d1
Author: opask
Date: Fri, 3 Aug 2018 21:03:32 -0600
general style cleanup
Diffstat:
16 files changed, 147 insertions(+), 126 deletions(-)
diff --git a/cache.c b/cache.c
@@ -9,7 +9,7 @@
static struct list_head cache = {&cache, &cache};
-static my_uintptr_t cache_size = 0;
+static int cache_size = 0;
static tcount cache_count = 1;
@@ -42,8 +42,7 @@ static void cache_delete_from_tree(struct cache_entry *e)
if (!e->url[0])
return;
- p = tdelete(e->url, &cache_root, ce_compare);
- if (!p)
+ if (!(p = tdelete(e->url, &cache_root, ce_compare)))
internal("cache_delete_from_tree: url '%s' not found", e->url);
}
@@ -51,37 +50,39 @@ static struct cache_entry *cache_search_tree(unsigned char *url)
{
void **p;
- p = tfind(url, &cache_root, ce_compare);
- if (!p)
+ if (!(p = tfind(url, &cache_root, ce_compare)))
return NULL;
+
return get_struct(*p, struct cache_entry, url);
}
-my_uintptr_t cache_info(int type)
+int cache_info(int type)
{
- my_uintptr_t i = 0;
+ int i = 0;
struct cache_entry *ce;
struct list_head *lce;
switch (type) {
case CI_BYTES:
return cache_size;
case CI_FILES:
- return (my_uintptr_t)list_size(&cache);
+ return list_size(&cache);
case CI_LOCKED:
- foreach(struct cache_entry, ce, lce, cache) i += !!ce->refcount;
+ foreach(struct cache_entry, ce, lce, cache)
+ i += !!ce->refcount;
return i;
case CI_LOADING:
- foreach(struct cache_entry, ce, lce, cache) i += is_entry_used(ce);
+ foreach(struct cache_entry, ce, lce, cache)
+ i += is_entry_used(ce);
return i;
default:
- internal("cache_info: bad request");
+ die("cache_info: bad request");
}
return 0;
}
-my_uintptr_t decompress_info(int type)
+int decompress_info(int type)
{
- my_uintptr_t i = 0;
+ int i = 0;
struct cache_entry *ce;
struct list_head *lce;
switch (type) {
@@ -190,7 +191,7 @@ void detach_cache_entry(struct cache_entry *e)
e->url[0] = 0;
}
-#define sf(x) e->data_size += (x), cache_size += (my_uintptr_t)(x)
+#define sf(x) e->data_size += (x), cache_size += (int)(x)
int page_size = 4096;
@@ -452,16 +453,17 @@ static int shrink_file_cache(int u)
int r = 0;
struct cache_entry *e, *f;
struct list_head *le, *lf;
- my_uintptr_t ncs = cache_size;
- my_uintptr_t ccs = 0, ccs2 = 0;
+ int ncs = cache_size;
+ int ccs = 0, ccs2 = 0;
- if (u == SH_CHECK_QUOTA && cache_size + decompressed_cache_size <= (my_uintptr_t)memory_cache_size) goto ret;
+ if (u == SH_CHECK_QUOTA && cache_size + decompressed_cache_size <= memory_cache_size)
+ goto ret;
foreachback(struct cache_entry, e, le, cache) {
if (e->refcount || is_entry_used(e)) {
- if (ncs < (my_uintptr_t)e->data_size) {
+ if (ncs < (int)e->data_size) {
internal("cache_size underflow: %lu, %lu", (unsigned long)ncs, (unsigned long)e->data_size);
}
- ncs -= (my_uintptr_t)e->data_size;
+ ncs -= (int)e->data_size;
} else if (u == SH_FREE_SOMETHING) {
if (e->decompressed_len)
free_decompressed_data(e);
@@ -470,11 +472,11 @@ static int shrink_file_cache(int u)
goto ret;
}
if (!e->refcount && e->decompressed_len
- && cache_size + decompressed_cache_size > (my_uintptr_t)memory_cache_size) {
+ && cache_size + decompressed_cache_size > memory_cache_size) {
free_decompressed_data(e);
r = 1;
}
- ccs += (my_uintptr_t)e->data_size;
+ ccs += (int)e->data_size;
ccs2 += e->decompressed_len;
}
if (ccs != cache_size) {
@@ -488,18 +490,20 @@ static int shrink_file_cache(int u)
(unsigned long)ccs2);
decompressed_cache_size = ccs2;
}
- if (u == SH_CHECK_QUOTA && ncs <= (my_uintptr_t)memory_cache_size) goto ret;
+ if (u == SH_CHECK_QUOTA && ncs <= memory_cache_size)
+ goto ret;
foreachback(struct cache_entry, e, le, cache) {
- if (u == SH_CHECK_QUOTA && (longlong)ncs <= (longlong)memory_cache_size * MEMORY_CACHE_GC_PERCENT) goto g;
+ if (u == SH_CHECK_QUOTA && (long)ncs <= (long)memory_cache_size * MEMORY_CACHE_GC_PERCENT)
+ goto g;
if (e->refcount || is_entry_used(e)) {
e->tgc = 0;
continue;
}
e->tgc = 1;
- if (ncs < (my_uintptr_t)e->data_size) {
+ if (ncs < (int)e->data_size) {
internal("cache_size underflow: %lu, %lu", (unsigned long)ncs, (unsigned long)e->data_size);
}
- ncs -= (my_uintptr_t)e->data_size;
+ ncs -= (int)e->data_size;
}
if (ncs) internal("cache_size(%lu) is larger than size of all objects(%lu)", (unsigned long)cache_size, (unsigned long)(cache_size - ncs));
g:
@@ -509,8 +513,8 @@ static int shrink_file_cache(int u)
if (u == SH_CHECK_QUOTA) {
foreachfrom(struct cache_entry, f, lf, cache, le) {
if (f->data_size
- && (longlong)ncs + f->data_size <= (longlong)memory_cache_size * MEMORY_CACHE_GC_PERCENT) {
- ncs += (my_uintptr_t)f->data_size;
+ && (long)ncs + f->data_size <= (long)memory_cache_size * MEMORY_CACHE_GC_PERCENT) {
+ ncs += (int)f->data_size;
f->tgc = 0;
}
}
diff --git a/compress.c b/compress.c
@@ -6,7 +6,7 @@
#undef write
#endif
-my_uintptr_t decompressed_cache_size = 0;
+int decompressed_cache_size = 0;
static int display_error(struct terminal *term, unsigned char *msg, int *errp)
{
diff --git a/cookies.c b/cookies.c
@@ -24,6 +24,8 @@ struct c_server {
static struct list_head c_servers = { &c_servers, &c_servers };
+static void accept_cookie(struct cookie *);
+
void free_cookie(struct cookie *c)
{
free(c->name);
@@ -34,7 +36,6 @@ void free_cookie(struct cookie *c)
free(c);
}
-static void accept_cookie(struct cookie *);
/* sezere 1 cookie z retezce str, na zacatku nesmi byt zadne whitechars
* na konci muze byt strednik nebo 0
@@ -73,21 +74,21 @@ int set_cookie(struct terminal *term, unsigned char *url, unsigned char *str)
cookie->path = stracpy(cast_uchar "/");
else if (cookie->path[0] != '/') {
add_to_strn(&cookie->path, cast_uchar "x");
- memmove(cookie->path + 1, cookie->path, strlen(cast_const_char cookie->path) - 1);
+ memmove(cookie->path + 1, cookie->path, strlen((const char *)cookie->path) - 1);
cookie->path[0] = '/';
}
dom = parse_header_param(str, cast_uchar "domain", 0);
if (!dom)
cookie->domain = stracpy(server);
else {
- cookie->domain = idn_encode_host(dom, (int)strlen(cast_const_char dom), cast_uchar ".", 0);
+ cookie->domain = idn_encode_host(dom, strlen((const char *)dom), cast_uchar ".", 0);
if (!cookie->domain)
cookie->domain = stracpy(server);
free(dom);
}
if (cookie->domain[0] == '.')
memmove(cookie->domain, cookie->domain + 1,
- strlen(cast_const_char cookie->domain));
+ strlen((const char *)cookie->domain));
if ((s = parse_header_param(str, cast_uchar "secure", 0))) {
cookie->secure = 1;
free(s);
@@ -140,7 +141,7 @@ static void accept_cookie(struct cookie *c)
foreach(struct c_domain, cd, lcd, c_domains)
if (!casestrcmp(cd->domain, c->domain))
return;
- sl = strlen(cast_const_char c->domain);
+ sl = strlen((const char *)c->domain);
if (sl > MAXINT - sizeof(struct c_domain))
overalloc();
cd = xmalloc(sizeof(struct c_domain) + sl);
@@ -150,8 +151,8 @@ static void accept_cookie(struct cookie *c)
int is_in_domain(unsigned char *d, unsigned char *s)
{
- const int dl = strlen(cast_const_char d);
- const int sl = strlen(cast_const_char s);
+ const int dl = strlen((const char *)d);
+ const int sl = strlen((const char *)s);
if (dl > sl)
return 0;
if (dl == sl)
@@ -163,8 +164,8 @@ int is_in_domain(unsigned char *d, unsigned char *s)
int is_path_prefix(unsigned char *d, unsigned char *s)
{
- const int dl = strlen(cast_const_char d);
- const int sl = strlen(cast_const_char s);
+ const int dl = strlen((const char *)d);
+ const int sl = strlen((const char *)s);
if (!dl)
return 1;
if (dl > sl)
diff --git a/dip.c b/dip.c
@@ -1968,7 +1968,7 @@ void update_aspect(void)
destroy_font_cache();
}
-my_uintptr_t fontcache_info(int type)
+int fontcache_info(int type)
{
switch (type) {
case CI_BYTES:
diff --git a/html.c b/html.c
@@ -2080,7 +2080,7 @@ static void new_menu_item(unsigned char *name, long data, int fullname)
item->rtext = data == -1 ? cast_uchar ">" : cast_uchar "";
item->hotkey = fullname ? cast_uchar "\000\001" : cast_uchar "\000\000"; /* dirty */
item->func = data == -1 ? do_select_submenu : selected_item;
- item->data = data == -1 ? nmenu : (void *)(my_intptr_t)data;
+ item->data = data == -1 ? nmenu : (void *)data;
item->in_m = data == -1 ? 1 : 0;
item->free_i = 0;
item++;
@@ -2145,15 +2145,18 @@ static void menu_labels(struct menu_item *m, unsigned char *base, unsigned char
}
} else {
if ((bs = stracpy(m->hotkey[1] ? (unsigned char *)"" : base))) add_to_strn(&bs, m->text);
- lbls[(my_intptr_t)m->data] = bs;
+ lbls[(int)m->data] = bs;
}
}
}
static int menu_contains(struct menu_item *m, int f)
{
- if (m->func != do_select_submenu) return (my_intptr_t)m->data == f;
- for (m = m->data; m->text; m++) if (menu_contains(m, f)) return 1;
+ if (m->func != do_select_submenu)
+ return (int)m->data == f;
+ for (m = m->data; m->text; m++)
+ if (menu_contains(m, f))
+ return 1;
return 0;
}
diff --git a/html_gr.c b/html_gr.c
@@ -684,7 +684,7 @@ static void *g_html_special(void *p_, int c, ...)
return convert_table;
case SP_USED:
va_end(l);
- return (void *)(my_intptr_t)!!p->data;
+ return (void *)!!p->data;
case SP_FRAMESET:
fsp = va_arg(l, struct frameset_param *);
va_end(l);
diff --git a/html_r.c b/html_r.c
@@ -968,7 +968,7 @@ static void *html_special(void *p_, int c, ...)
return convert_table;
case SP_USED:
va_end(l);
- return (void *)(my_intptr_t)!!p->data;
+ return (void *)!!p->data;
case SP_FRAMESET:
fsp = va_arg(l, struct frameset_param *);
va_end(l);
diff --git a/imgcache.c b/imgcache.c
@@ -109,11 +109,11 @@ static int shrink_image_cache(int u)
return r | (list_empty(image_cache) ? ST_CACHE_EMPTY : 0);
}
-my_uintptr_t imgcache_info(int type)
+int imgcache_info(int type)
{
struct cached_image *i;
struct list_head *li;
- my_uintptr_t n = 0;
+ int n = 0;
foreach(struct cached_image, i, li, image_cache) {
switch (type) {
case CI_BYTES:
diff --git a/links.h b/links.h
@@ -247,11 +247,12 @@ struct list_head {
#define foreachback(struc, e, h, l) foreachbackfrom(struc, e, h, l, (l).prev)
#define free_list(struc, l) do { while (!list_empty(l)) { struc *a__ = list_struct((l).next, struc); del_from_list(a__); free(a__); } } while (0)
-static inline unsigned long list_size(struct list_head *l)
+static inline int list_size(struct list_head *l)
{
struct list_head *e;
- unsigned long n = 0;
- for (e = l->next; e != l; e = e->next) n++;
+ int n = 0;
+ for (e = l->next; e != l; e = e->next)
+ n++;
return n;
}
@@ -274,7 +275,7 @@ static inline unsigned long list_size(struct list_head *l)
/* string.c */
-int snprint(unsigned char *s, int n, my_uintptr_t num);
+int snprint(unsigned char *s, int n, int num);
int snzprint(unsigned char *s, int n, off_t num);
void add_to_strn(unsigned char **s, unsigned char *a);
void extend_str(unsigned char **s, int n);
@@ -291,7 +292,7 @@ void add_bytes_to_str(unsigned char **s, int *l, unsigned char *a, size_t ll);
void add_to_str(unsigned char **s, int *l, unsigned char *a);
void add_chr_to_str(unsigned char **s, int *l, unsigned char a);
void add_unsigned_num_to_str(unsigned char **s, int *l, off_t n);
-void add_unsigned_long_num_to_str(unsigned char **s, int *l, my_uintptr_t n);
+void add_unsigned_long_num_to_str(unsigned char **s, int *l, long n);
void add_num_to_str(unsigned char **s, int *l, off_t n);
void add_knum_to_str(unsigned char **s, int *l, off_t n);
long strtolx(unsigned char *c, unsigned char **end);
@@ -563,8 +564,8 @@ extern int page_size;
struct connection;
void init_cache(void);
-my_uintptr_t cache_info(int);
-my_uintptr_t decompress_info(int);
+int cache_info(int);
+int decompress_info(int);
int find_in_cache(unsigned char *, struct cache_entry **);
int get_connection_cache_entry(struct connection *);
int new_cache_entry(unsigned char *, struct cache_entry **);
@@ -1045,7 +1046,7 @@ struct lru_entry {
struct lru {
int (*compare_function)(void *, void *);
struct lru_entry *top, *bottom;
- my_uintptr_t bytes, items;
+ int bytes, items;
};
void lru_insert(struct lru *cache, void *entry, struct lru_entry **row, unsigned bytes_consumed);
@@ -1261,7 +1262,7 @@ void generic_set_clip_area(struct graphics_device *dev, struct rect *r);
*/
extern unsigned aspect; /* Must hold at least 20 bits */
-my_uintptr_t fontcache_info(int type);
+int fontcache_info(int type);
#define G_BFU_FONT_SIZE menu_font_size
@@ -1440,7 +1441,7 @@ struct links_event {
int ev;
int x;
int y;
- my_intptr_t b;
+ int b;
};
#define EV_INIT 0
@@ -1732,7 +1733,7 @@ void detach_object_connection(struct object_request *, off_t);
/* compress.c */
-extern my_uintptr_t decompressed_cache_size;
+extern int decompressed_cache_size;
int get_file_by_term(struct terminal *term, struct cache_entry *ce, unsigned char **start, unsigned char **end, int *errp);
int get_file(struct object_request *o, unsigned char **start, unsigned char **end);
@@ -3090,7 +3091,7 @@ int known_image_type(unsigned char *type);
#ifdef G
void init_imgcache(void);
-my_uintptr_t imgcache_info(int type);
+int imgcache_info(int type);
struct cached_image *find_cached_image(int bg, unsigned char *url, int xw, int
yw, int xyw_meaning, int scale, unsigned aspect);
void add_image_to_cache(struct cached_image *ci);
diff --git a/menu.c b/menu.c
@@ -447,7 +447,7 @@ static void flush_caches(struct terminal *term, void *d, void *e)
void go_backwards(struct terminal *term, void *id_ptr, void *ses_)
{
struct session *ses = (struct session *)ses_;
- unsigned want_id = (unsigned)(my_intptr_t)id_ptr;
+ unsigned want_id = (unsigned)id_ptr;
struct location *l;
struct list_head *ll;
int n = 0;
@@ -478,11 +478,14 @@ static_const struct menu_item no_hist_menu[] = {
static void add_history_menu_entry(struct terminal *term, struct menu_item **mi, int *n, struct location *l)
{
unsigned char *url;
- if (!*mi) *mi = new_menu(3);
+ if (!*mi)
+ *mi = new_menu(3);
url = display_url(term, l->url, 1);
- add_to_menu(mi, url, cast_uchar "", cast_uchar "", go_backwards, (void *)(my_intptr_t)l->location_id, 0, *n);
+ add_to_menu(mi, url, cast_uchar "", cast_uchar "", go_backwards,
+ (void *)(int)l->location_id, 0, *n);
(*n)++;
- if (*n == MAXINT) overalloc();
+ if (*n == MAXINT)
+ overalloc();
}
static void history_menu(struct terminal *term, void *ddd, void *ses_)
@@ -557,7 +560,7 @@ static void menu_toggle(struct terminal *term, void *ddd, void *ses_)
static void set_display_codepage(struct terminal *term, void *pcp, void *ptr)
{
- int cp = (int)(my_intptr_t)pcp;
+ int cp = (int)pcp;
struct term_spec *t = new_term_spec(term->term);
t->character_set = cp;
cls_redraw_all_terminals();
@@ -565,7 +568,7 @@ static void set_display_codepage(struct terminal *term, void *pcp, void *ptr)
static void set_val(struct terminal *term, void *ip, void *d)
{
- *(int *)d = (int)(my_intptr_t)ip;
+ *(int *)d = (int)ip;
}
static void charset_sel_list(struct terminal *term, int ini, void (*set)(struct terminal *term, void *ip, void *ptr), void *ptr, int utf, int def)
@@ -589,7 +592,7 @@ static void charset_sel_list(struct terminal *term, int ini, void (*set)(struct
n = get_cp_name(i);
r = stracpy(cast_uchar "");
}
- add_to_menu(&mi, n, r, cast_uchar "", set, (void *)(my_intptr_t)i, 0, i + def);
+ add_to_menu(&mi, n, r, cast_uchar "", set, (void *)i, 0, i + def);
}
ini += def;
if (ini < 0)
diff --git a/os_depx.h b/os_depx.h
@@ -123,20 +123,6 @@
#define SA_RESTART 0
#endif
-#ifndef PF_INET
-#define PF_INET AF_INET
-#endif
-#ifndef PF_UNIX
-#define PF_UNIX AF_UNIX
-#endif
-
-#define my_intptr_t long
-#define my_uintptr_t unsigned long
-
-#ifndef PF_INET6
-#define PF_INET6 AF_INET6
-#endif
-
#if !defined(INET_ADDRSTRLEN)
#define INET_ADDRSTRLEN 16
#endif
diff --git a/select.c b/select.c
@@ -618,7 +618,7 @@ void clear_events(int h, int blocking)
static void clear_events_ptr(void *handle)
{
- clear_events((int)(my_intptr_t)handle, 0);
+ clear_events((int)handle, 0);
}
@@ -829,7 +829,7 @@ void select_loop(void (*init)(void))
}
set_nonblock(signal_pipe[0]);
set_nonblock(signal_pipe[1]);
- set_handlers(signal_pipe[0], clear_events_ptr, NULL, (void *)(my_intptr_t)signal_pipe[0]);
+ set_handlers(signal_pipe[0], clear_events_ptr, NULL, (void *)signal_pipe[0]);
#endif
init();
CHK_BH;
diff --git a/string.c b/string.c
@@ -5,9 +5,9 @@
#include "links.h"
-int snprint(unsigned char *s, int n, my_uintptr_t num)
+int snprint(unsigned char *s, int n, int num)
{
- my_uintptr_t q = 1;
+ int q = 1;
while (q <= num / 10) q *= 10;
while (n-- > 1 && q) {
*(s++) = (unsigned char)(num / q + '0');
@@ -98,7 +98,7 @@ void add_chr_to_str(unsigned char **s, int *l, unsigned char a)
add_bytes_to_str(s, l, &a, 1);
}
-void add_unsigned_long_num_to_str(unsigned char **s, int *l, my_uintptr_t n)
+void add_unsigned_long_num_to_str(unsigned char **s, int *l, long n)
{
unsigned char a[64];
snprint(a, 64, n);
diff --git a/suffix.c b/suffix.c
@@ -39,7 +39,10 @@ int is_tld(unsigned char *name)
{
char *end;
unsigned long l;
- if (strlen(cast_const_char name) == 2 && upcase(name[0]) >= 'A' && upcase(name[0]) <= 'Z' && upcase(name[1]) >= 'A' && upcase(name[1]) <= 'Z' && casestrcmp(name, cast_uchar "gz") && casestrcmp(name, cast_uchar "xz"))
+ if (strlen((const char *)name) == 2 && upcase(name[0]) >= 'A'
+ && upcase(name[0]) <= 'Z' && upcase(name[1]) >= 'A'
+ && upcase(name[1]) <= 'Z' && casestrcmp(name, cast_uchar "gz")
+ && casestrcmp(name, cast_uchar "xz"))
return 1;
l = strtoul(cast_const_char name, &end, 10);
if (!*end && l <= 255)
@@ -49,16 +52,27 @@ int is_tld(unsigned char *name)
int allow_cookie_domain(unsigned char *server, unsigned char *domain)
{
- int sl = (int)strlen(cast_const_char server);
- int dl = (int)strlen(cast_const_char domain);
- if (dl > sl) return 0;
- if (casestrcmp(domain, server + sl - dl)) return 0;
- if (dl == sl) return 1;
- if (!numeric_ip_address(server, NULL)) return 0;
- if (!numeric_ipv6_address(server, NULL, NULL)) return 0;
- if (server[sl - dl - 1] != '.') return 0;
- if (search_list_and_wildcards(domain_suffix_x, array_elements(domain_suffix_x), domain)) return 1;
- if (!strchr(cast_const_char domain, '.')) return 0;
- if (search_list_and_wildcards(domain_suffix, array_elements(domain_suffix), domain)) return 0;
+ const int sl = strlen((const char *)server);
+ const int dl = strlen((const char *)domain);
+ if (dl > sl)
+ return 0;
+ if (casestrcmp(domain, server + sl - dl))
+ return 0;
+ if (dl == sl)
+ return 1;
+ if (!numeric_ip_address(server, NULL))
+ return 0;
+ if (!numeric_ipv6_address(server, NULL, NULL))
+ return 0;
+ if (server[sl - dl - 1] != '.')
+ return 0;
+ if (search_list_and_wildcards(domain_suffix_x,
+ array_elements(domain_suffix_x), domain))
+ return 1;
+ if (!strchr(cast_const_char domain, '.'))
+ return 0;
+ if (search_list_and_wildcards(domain_suffix,
+ array_elements(domain_suffix), domain))
+ return 0;
return 1;
}
diff --git a/terminal.c b/terminal.c
@@ -837,7 +837,7 @@ static void in_term(void *term_)
term->cwd[MAX_CWD_LEN - 1] = 0;
term->environment = *(int *)(iq + sizeof(struct links_event) + MAX_TERM_LEN + MAX_CWD_LEN);
term->default_character_set = *(int *)(iq + sizeof(struct links_event) + MAX_TERM_LEN + MAX_CWD_LEN + sizeof(int));
- ev->b = (my_intptr_t)(iq + sizeof(struct links_event) + MAX_TERM_LEN + MAX_CWD_LEN + 2 * sizeof(int));
+ ev->b = (int)(iq + sizeof(struct links_event) + MAX_TERM_LEN + MAX_CWD_LEN + 2 * sizeof(int));
r = (int)sizeof(struct links_event) + MAX_TERM_LEN + MAX_CWD_LEN + 3 * (int)sizeof(int) + init_len;
sync_term_specs();
}
@@ -1304,14 +1304,14 @@ void exec_thread(void *path_, int p)
void close_handle(void *p)
{
- int h = (int)(my_intptr_t)p;
+ int h = (int)p;
close_socket(&h);
}
static void unblock_terminal(void *term_)
{
struct terminal *term = (struct terminal *)term_;
- close_handle((void *)(my_intptr_t)term->blocked);
+ close_handle(&term->blocked);
term->blocked = -1;
if (!F) {
set_handlers(term->fdin, in_term, NULL, term);
@@ -1402,7 +1402,7 @@ void exec_on_terminal(struct terminal *term, unsigned char *path, unsigned char
if (!F) set_handlers(term->fdin, NULL, NULL, term);
/*block_itrm(term->fdin);*/
} else {
- set_handlers(blockh, close_handle, NULL, (void *)(my_intptr_t)blockh);
+ set_handlers(blockh, close_handle, NULL, &blockh);
}
}
} else {
diff --git a/view.c b/view.c
@@ -447,24 +447,28 @@ static int is_in_range(struct f_data *f, int y, int yw, unsigned char *txt, int
*min = MAXINT;
*max = 0;
- if (!utf8) {
- l = (int)strlen(cast_const_char txt);
- } else {
+ if (!utf8)
+ l = (int)strlen((const char *)txt);
+ else
l = strlen_utf8(txt);
- }
- if (get_range(f, y, yw, l, &s1, &s2)) return 0;
+ if (get_range(f, y, yw, l, &s1, &s2))
+ return 0;
for (; s1 <= s2; s1++) {
int i;
if (!utf8) {
- if (f->search_chr[s1] != txt[0]) goto cont;
- for (i = 1; i < l; i++) if (f->search_chr[s1 + i] != txt[i]) goto cont;
+ if (f->search_chr[s1] != txt[0])
+ continue;
+ for (i = 1; i < l; i++)
+ if (f->search_chr[s1 + i] != txt[i])
+ goto cont;
} else {
unsigned char *tt = txt;
for (i = 0; i < l; i++) {
unsigned cc;
GET_UTF_8(tt, cc);
- if (f->search_chr[s1 + i] != cc) goto cont;
+ if (f->search_chr[s1 + i] != cc)
+ goto cont;
}
}
for (i = 0; i < l; i++) {
@@ -472,16 +476,18 @@ static int is_in_range(struct f_data *f, int y, int yw, unsigned char *txt, int
if (sr->y >= y && sr->y < y + yw && sr->n) goto in_view;
}
continue;
- in_view:
+in_view:
found = 1;
for (i = 0; i < l; i++) {
struct search *sr = search_lookup(f, s1 + i);
if (sr->n) {
- if (sr->x < *min) *min = sr->x;
- if (sr->x + sr->n > *max) *max = sr->x + sr->n;
+ if (sr->x < *min)
+ *min = sr->x;
+ if (sr->x + sr->n > *max)
+ *max = sr->x + sr->n;
}
}
- cont:;
+cont:;
}
return found;
}
@@ -503,34 +509,40 @@ static int get_searched(struct f_data_c *scr, struct point **pt, int *pl)
int len = 0;
unsigned char *ww;
unsigned char *w = scr->ses->search_word;
- if (!w || !*w) return -1;
+ if (!w || !*w)
+ return -1;
if (get_search_data(f) < 0) {
free(scr->ses->search_word);
scr->ses->search_word = NULL;
return -1;
}
if (!utf8) {
- l = (int)strlen(cast_const_char w);
+ l = (int)strlen((const char *)w);
c = w[0];
} else {
l = strlen_utf8(w);
ww = w;
GET_UTF_8(ww, c);
}
- if (get_range(f, scr->vs->view_pos, scr->yw, l, &s1, &s2)) goto ret;
+ if (get_range(f, scr->vs->view_pos, scr->yw, l, &s1, &s2))
+ goto ret;
for (; s1 <= s2; s1++) {
int i, j;
if (f->search_chr[s1] != c) {
- c:continue;
+c:
+ continue;
}
if (!utf8) {
- for (i = 1; i < l; i++) if (f->search_chr[s1 + i] != w[i]) goto c;
+ for (i = 1; i < l; i++)
+ if (f->search_chr[s1 + i] != w[i])
+ goto c;
} else {
ww = w;
for (i = 0; i < l; i++) {
unsigned cc;
GET_UTF_8(ww, cc);
- if (f->search_chr[s1 + i] != cc) goto c;
+ if (f->search_chr[s1 + i] != cc)
+ goto c;
}
}
for (i = 0; i < l; i++) {
@@ -539,17 +551,14 @@ static int get_searched(struct f_data_c *scr, struct point **pt, int *pl)
int x = sr->x + j + xp - vx;
int y = sr->y + yp - vy;
if (x >= xp && y >= yp && x < xp + xw && y < yp + yw) {
- /*unsigned co;
- co = get_char(t, x, y);
- co = ((co >> 3) & 0x0700) | ((co << 3) & 0x3800);
- set_color(t, x, y, co);*/
if (!(len & (ALLOC_GR - 1))) {
struct point *points2;
if ((unsigned)len > MAXINT / sizeof(struct point) - ALLOC_GR)
goto ret;
points2 = xrealloc(points,
sizeof(struct point) * (len + ALLOC_GR));
- if (!points2) goto ret;
+ if (!points2)
+ goto ret;
points = points2;
}
points[len].x = sr->x + j;
@@ -558,7 +567,7 @@ static int get_searched(struct f_data_c *scr, struct point **pt, int *pl)
}
}
}
- ret:
+ret:
*pt = points;
*pl = len;
return 0;
@@ -1954,7 +1963,7 @@ void toggle(struct session *ses, struct f_data_c *f, int a)
void selected_item(struct terminal *term, void *pitem, void *ses_)
{
struct session *ses = (struct session *)ses_;
- int item = (int)(my_intptr_t)pitem;
+ int item = (int)pitem;
struct f_data_c *f = current_frame(ses);
struct link *l;
struct form_state *fs;
@@ -2859,7 +2868,7 @@ void send_event(struct session *ses, struct links_event *ev)
goto x;
}
if ((upcase(ev->x) == 'Q' && !(ev->y & (KBD_CTRL | KBD_ALT))) || ev->x == KBD_CTRL_C) {
- exit_prog(ses->term, (void *)(my_intptr_t)(ev->x == KBD_CTRL_C || ev->x == 'Q'), ses);
+ exit_prog(ses->term, (int *)(ev->x == KBD_CTRL_C || ev->x == 'Q'), ses);
goto x;
}
if (ev->x == KBD_CLOSE) {