links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: b8d0c0f40343d774f34cd149f6d5f9cb6639169a
Parent: f74f3badc2c5e1c0d37376aa68b8477d9301f672
Author: 0x766F6964
Date:   Sun,  3 Nov 2019 22:23:07 -0700

minor cleanup

Diffstat:
Mcharsets.c | 19++++---------------
Mlinks.h | 6++----
Mos_dep.c | 4++--
Mterminal.c | 18+++++++++---------
Mx.c | 8++++----
5 files changed, 21 insertions(+), 34 deletions(-)

diff --git a/charsets.c b/charsets.c @@ -50,8 +50,6 @@ static const unsigned char strings[256][2] = { "\370", "\371", "\372", "\373", "\374", "\375", "\376", "\377", }; -static const unsigned char no_str[] = "*"; - unsigned char *u2cp(int u) { return encode_utf_8(u); @@ -126,20 +124,11 @@ static struct conv_table *get_translation_table_to_utf_8(int from) utf_table_init = 0; } else free_utf_table(); - if (!from) { - for (i = 128; i < 256; i += 4) { - utf_table[i].u.str = stracpy(strings[i]); - utf_table[i + 1].u.str = stracpy(strings[i + 1]); - utf_table[i + 2].u.str = stracpy(strings[i + 2]); - utf_table[i + 3].u.str = stracpy(strings[i + 3]); - } - return utf_table; - } for (i = 128; i < 256; i += 4) { - utf_table[i].u.str = stracpy(no_str); - utf_table[i + 1].u.str = stracpy(no_str); - utf_table[i + 2].u.str = stracpy(no_str); - utf_table[i + 3].u.str = stracpy(no_str); + utf_table[i].u.str = stracpy(strings[i]); + utf_table[i + 1].u.str = stracpy(strings[i + 1]); + utf_table[i + 2].u.str = stracpy(strings[i + 2]); + utf_table[i + 3].u.str = stracpy(strings[i + 3]); } return utf_table; } diff --git a/links.h b/links.h @@ -340,7 +340,7 @@ void ignore_signals(void); int os_get_system_name(unsigned char *buffer); unsigned char *os_conv_to_external_path(unsigned char *, unsigned char *); unsigned char *os_fixup_external_program(unsigned char *); -int exe(unsigned char *, int); +int exe(char *, int); int can_open_os_shell(int); unsigned char *links_xterm(void); struct open_in_new *get_open_in_new(int); @@ -1105,7 +1105,7 @@ struct graphics_driver { /* set window title. title is in utf-8 encoding -- you should recode it to device charset */ /* if device doesn't support titles (svgalib, framebuffer), this should be NULL, not empty function ! */ - int (*exec)(unsigned char *command, int flag); + int (*exec)(char *command, int flag); /* -if !NULL executes command on this graphics device, -if NULL links uses generic (console) command executing functions @@ -1598,8 +1598,6 @@ void set_cursor(struct terminal *, int, int, int, int); void destroy_all_terminals(void); void block_itrm(int); int unblock_itrm(int); -void exec_thread(void *, int); -void close_handle(void *); #define TERM_FN_TITLE 1 #define TERM_FN_RESIZE 2 diff --git a/os_dep.c b/os_dep.c @@ -347,7 +347,7 @@ unsigned char *os_fixup_external_program(unsigned char *prog) } /* UNIX */ -int exe(unsigned char *path, int fg) +int exe(char *path, int fg) { #ifdef SIGCHLD do_signal(SIGCHLD, SIG_DFL); @@ -368,7 +368,7 @@ int exe(unsigned char *path, int fg) #ifdef G if (F && drv->exec) return drv->exec(path, fg); #endif - return system(cast_const_char path); + return system(path); } /* clipboard -> links */ diff --git a/terminal.c b/terminal.c @@ -89,8 +89,8 @@ static void alloc_term_screen(struct terminal *term) term->x = 1; if (term->y < 0) term->y = 1; - if ((term->x && (unsigned)term->x * (unsigned)term->y / (unsigned)term->x != (unsigned)term->y) - || (unsigned)term->x * (unsigned)term->y > INT_MAX / sizeof(*term->screen)) + if ((term->x && term->x * term->y / term->x != term->y) + || term->x * term->y > INT_MAX / sizeof(*term->screen)) overalloc(); s = xrealloc(term->screen, term->x * term->y * sizeof(*term->screen)); t = xrealloc(term->last_screen, @@ -1117,21 +1117,21 @@ void set_cursor(struct terminal *term, int x, int y, int altx, int alty) term->cy = y; } -void exec_thread(void *path_, int p) +static void exec_thread(void *path_, int p) { - unsigned char *path = (unsigned char *)path_; + char *path = path_; int rs; if (path[0] == 2) EINTRLOOP(rs, setpgid(0, 0)); exe(path + 1, path[0]); - if (path[1 + strlen(cast_const_char(path + 1)) + 1]) - EINTRLOOP(rs, unlink(cast_const_char(path + 1 + strlen(cast_const_char(path + 1)) + 1))); + if (path[1 + strlen(path + 1) + 1]) + EINTRLOOP(rs, unlink(path + 1 + strlen(path + 1) + 1)); } -void close_handle(void *p) +static void close_handle(void *p) { - int h = (int)(long)p; - close_socket(&h); + int *h = p; + close_socket(h); } static void unblock_terminal(void *term_) diff --git a/x.c b/x.c @@ -2430,14 +2430,14 @@ static void addchr(char *str, size_t *l, char c) s[*l] = 0; } -static int x_exec(unsigned char *command, int fg) +static int x_exec(char *command, int fg) { char *pattern, *final; size_t i, j, l; int retval; if (!fg) { - retval = system(cast_const_char command); + retval = system(command); return retval; } @@ -2458,8 +2458,8 @@ static int x_exec(unsigned char *command, int fg) l = 0; for (i = 0; pattern[i]; i++) { if (pattern[i] == '%') - for (j = 0; j < strlen((char *)command); j++) - addchr(final, &l, (char)command[j]); + for (j = 0; j < strlen(command); j++) + addchr(final, &l, command[j]); else addchr(final, &l, pattern[i]); }