links2

links 2.15+ fork
git clone git://git.codemadness.org/links2
Log | Files | Refs | README

commit 43e03ff163ec61d7659e118fea57c2e9fa16da13
parent ac66d3efa0cbfdbef2c3594b6815207a101dc7a8
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  4 May 2018 13:03:38 +0200

remove unused code, update TODO

Diffstat:
Makefile | 3++-
TODO | 2++
config.h | 1+
html.c | 3---
main.c | 148-------------------------------------------------------------------------------
os_dep.c | 81-------------------------------------------------------------------------------
os_dep.h | 219-------------------------------------------------------------------------------
7 files changed, 5 insertions(+), 452 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ # links terminal -#CFLAGS = -include config.h -I. -I/usr/local/include -O2 #-g -O0 +#CFLAGS = -DUSE_PLEDGE -include config.h -I. -I/usr/local/include -O2 #-g -O0 #LDFLAGS = -L/usr/local/lib -levent -lssl -lz -s # links-g @@ -7,6 +7,7 @@ CFLAGS = -include config.h \ -DG=1 -DGRDRV_X \ -DHAVE_JPEG=1 -DHAVE_LIBJPEG=1 -DHAVE_JPEGLIB_H=1 \ -DHAVE_PNG_H=1 -DHAVE_LIBPNG=1 -DHAVE_LIBPNG_PNG_H=1 \ + -DUSE_PLEDGE \ -I. -I/usr/local/include -I/usr/X11R6/include -O2 #-g -O0 LDFLAGS = -L/usr/X11R6/lib -L/usr/local/lib -lX11 -levent -lpng -ljpeg -lssl -lz -s diff --git a/TODO b/TODO @@ -2,6 +2,8 @@ in menu opening telnet program settings crashes now. === +- check punycode decoding (dont do it). + - improve Makefile/build. - dont use all object files for normal terminal version. diff --git a/config.h b/config.h @@ -675,3 +675,4 @@ #undef USE_WIN32_HEAP #undef LEAK_DEBUG #undef OOPS +#undef RISCOS diff --git a/html.c b/html.c @@ -1325,9 +1325,6 @@ static void html_blockquote(unsigned char *a) static void html_h(int h, unsigned char *a) { -#if defined(__GNUC__) && defined(__arm__) - do_not_optimize_here(&h); -#endif #ifdef G if (F) { html_linebrk(a); diff --git a/main.c b/main.c @@ -578,160 +578,12 @@ main(int argc, char *argv[]) return 1; } -#if 0 - if (argc != 3) - fprintf(stderr, "two args expected\n"), exit(1); - printf("cookie %saccepted\n", allow_cookie_domain(cast_uchar argv[1], cast_uchar argv[2]) ? "" : "not "); - return 0; -#endif - init_heap(); init_os(); get_path_to_exe(); -#if 0 - { - int i; - int ix, iy, ox, oy, rep; - ulonglong tm = 0; - parse_options(g_argc - 1, g_argv + 1); - ix = getenv("SRC_X") ? atoi(getenv("SRC_X")) : 100; - iy = getenv("SRC_Y") ? atoi(getenv("SRC_Y")) : ix; - ox = getenv("DST_X") ? atoi(getenv("DST_X")) : 100; - oy = getenv("DST_Y") ? atoi(getenv("DST_Y")) : ox; - rep = getenv("REP") ? atoi(getenv("REP")) : 1; - for (i = 0; i <= rep; i++) { - unsigned short *dst; - unsigned short *src; - struct timeval tv1, tv2; - src = mem_alloc(sizeof(unsigned short) * ix * iy * 3); - memset(src, 0x12, sizeof(unsigned short) * ix * iy * 3); - gettimeofday(&tv1, NULL); - scale_color(src, ix, iy, &dst, ox, oy); - gettimeofday(&tv2, NULL); - if (dst) mem_free(dst); - if (i) - tm += ((ulonglong)tv2.tv_sec * 1000000 + tv2.tv_usec) - ((ulonglong)tv1.tv_sec * 1000000 + tv1.tv_usec); - } - fprintf(stderr, "time: %f\n", (double)tm / 1000 / rep); - check_memory_leaks(); - return 0; - } -#endif -#if 0 - { - int i; - for (i = 0; i < 100; i++) { - unsigned char *a = mem_calloc(i); - unsigned char *b = base64_encode(a, i, cast_uchar "", cast_uchar "", 5); - fprintf(stderr, "X:\n%.*s\n", (int)strlen(cast_const_char b), b); - mem_free(a); - mem_free(b); - } - check_memory_leaks(); - return 0; - } -#endif -#if 0 - { - unsigned char *puny_encode(unsigned char *s); - unsigned char *puny_decode(unsigned char *s); - int i; - for (i = 1; i < g_argc; i++) { - unsigned char *str = puny_encode(g_argv[i]); - if (str) { - fprintf(stderr, "'%s'\n", str); - unsigned char *d = puny_decode(str); - if (!d || strcmp(cast_const_char d, cast_const_char g_argv[i])) { - internal("mismatch - %s", d); - } - mem_free(str); - mem_free(d); - } - } - check_memory_leaks(); - return 0; - } -#endif -#if 0 - while (1) { -#define maxn 12 - static unsigned long long count = 0; - unsigned char *puny_encode(unsigned char *s, int len); - unsigned char *puny_decode(unsigned char *s, int len); - int punycode_encode(size_t input_length, const uint32_t input[], const unsigned char case_flags[], size_t *output_length, char output[]); - int punycode_decode(size_t input_length, const char input[], size_t * output_length, uint32_t output[], unsigned char case_flags[]); - uint32_t unistr[maxn]; - unsigned i, n; - unsigned char *utfstr, *puny, *dec; - int utfstr_l; - char pce_o[60]; - size_t pce_ol; - int pce_s; - n = random() % (maxn + 1); - for (i = 0; i < n; i++) { - uint32_t uni; - uni = random() % (0x10FFFF + 1); - if (uni >= 0xd800 && uni <= 0xdfff) - uni = random() % 128; - while (uni < 128 && !( - uni == '-' || - (uni >= '0' && uni <= '9') || - (uni >= 'A' && uni <= 'Z') || - (uni >= 'a' && uni <= 'z'))) { - uni = random() % 128; - } - unistr[i] = uni; - } - utfstr = init_str(); - utfstr_l = 0; - for (i = 0; i < n; i++) { - unsigned char *us = encode_utf_8(unistr[i]); - add_to_str(&utfstr, &utfstr_l, us); - } - puny = puny_encode(utfstr, utfstr_l); - if (!puny) { - fprintf(stderr, "failed:"); - goto err; - } - dec = puny_decode(puny, (int)strlen(cast_const_char puny)); - if (!dec) - dec = stracpy(puny); - if (strcmp(cast_const_char utfstr, cast_const_char dec)) { - fprintf(stderr, "mismatch(%s,%s):", utfstr, dec); - goto err; - } - pce_ol = 59; - pce_s = punycode_encode(n, unistr, NULL, &pce_ol, pce_o); - if (pce_s) { - fprintf(stderr, "punycode_encode(%d):", pce_s); - goto err; - } - pce_o[pce_ol] = 0; - if (!strncmp(cast_const_char puny, "xn--", 4) && strcmp(cast_const_char puny + 4, pce_o)) { - fprintf(stderr, "punycode_encode differs(%s,%s):", puny, pce_o); - goto err; - } - mem_free(dec); - mem_free(puny); - mem_free(utfstr); - if (0) { -err: - for (i = 0; i < n; i++) { - fprintf(stderr, " %u", unistr[i]); - } - internal("failed"); - } - count++; - if (!(count % 10000)) { - printf("%llu\r", count); - fflush(stdout); - } - } -#endif - select_loop(init); terminate_all_subsystems(); diff --git a/os_dep.c b/os_dep.c @@ -7,17 +7,10 @@ #include <sys/ioctl.h> - - - #ifdef HAVE_PTHREADS #include <pthread.h> #endif - - - - #if defined(HAVE_PTHREADS) static pthread_mutex_t pth_mutex; static void fd_lock(void); @@ -50,11 +43,8 @@ void init_os(void) fatal_exit("pthread_atfork failed: %s", strerror(r)); } #endif - - } - int is_safe_in_shell(unsigned char c) { return c == '@' || c == '+' || c == '-' || c == '.' || c == ',' || c == '=' || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z'); @@ -158,7 +148,6 @@ uttime get_time(void) return get_absolute_time(); } - static unsigned char *clipboard = NULL; void os_free_clipboard(void) @@ -168,9 +157,6 @@ void os_free_clipboard(void) /* Terminal size */ - -#if defined(UNIX) || defined(WIN) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) - #ifdef SIGWINCH static void sigwinch(void *s) { @@ -192,7 +178,6 @@ void unhandle_terminal_resize(int fd) #endif } - int get_terminal_size(int fd, int *x, int *y) { int rs = -1; @@ -221,12 +206,7 @@ int get_terminal_size(int fd, int *x, int *y) return 0; } - -#endif - - #if defined(HAVE_PTHREADS) - static void fd_lock(void) { int r; @@ -401,8 +381,6 @@ int open_prealloc(unsigned char *name, int flags, int mode, off_t siz) /* Exec */ -#if defined(UNIX) || defined(ATHEOS) || defined(INTERIX) - int is_twterm(void) { static int xt = -1; @@ -410,17 +388,6 @@ int is_twterm(void) return xt; } -#else - -int is_twterm(void) -{ - return 0; -} - -#endif - -#if defined(UNIX) || defined(ATHEOS) || defined(INTERIX) - int is_screen(void) { static int xt = -1; @@ -428,17 +395,6 @@ int is_screen(void) return xt; } -#else - -int is_screen(void) -{ - return 0; -} - -#endif - -#if defined(UNIX) || defined(SPAD) - int is_xterm(void) { static int xt = -1; @@ -446,22 +402,6 @@ int is_xterm(void) return xt; } -#elif defined(BEOS) || defined(ATHEOS) || defined(DOS) - -int is_xterm(void) -{ - return 0; -} - -#elif defined(RISCOS) - -int is_xterm(void) -{ - return 1; -} - -#endif - void close_fork_tty(void) { struct terminal *t; @@ -505,30 +445,20 @@ void get_path_to_exe(void) path_to_exe = g_argv[0]; } - void init_os_terminal(void) { } - - unsigned char *os_conv_to_external_path(unsigned char *file, unsigned char *prog) { return stracpy(file); } - - unsigned char *os_fixup_external_program(unsigned char *prog) { return stracpy(prog); } - - -#if defined(UNIX) || defined(INTERIX) || defined(BEOS) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) || defined(OPENVMS) || defined(DOS) - - /* UNIX */ int exe(unsigned char *path, int fg) { @@ -556,7 +486,6 @@ int exe(unsigned char *path, int fg) return system(cast_const_char path); } - /* clipboard -> links */ unsigned char *get_clipboard_text(struct terminal *term) { @@ -609,8 +538,6 @@ int resize_window(int x, int y) return -1; } -#endif - /* Threads */ #if (defined(HAVE_BEGINTHREAD) && defined(OS2)) || defined(BEOS) || defined(HAVE_PTHREADS) || defined(HAVE_ATHEOS_THREADS_H) @@ -633,25 +560,17 @@ static void bgt(void *t_) free(t); } - #endif -#if defined(UNIX) || defined(OS2) || defined(WIN) || defined(INTERIX) || defined(RISCOS) || defined(ATHEOS) || defined(SPAD) - void terminate_osdep(void) { } -#endif - - void block_stdin(void) {} void unblock_stdin(void) {} - #if defined(HAVE_PTHREADS) - static unsigned thread_count = 0; static inline void reset_thread_count(void) diff --git a/os_dep.h b/os_dep.h @@ -21,27 +21,6 @@ #ifdef UNIX #undef UNIX -#endif - -#if defined(__EMX__) -#define OS2 -#elif defined(_WIN32) || defined(__CYGWIN__) -#define WIN -#elif defined(__INTERIX) -#define INTERIX -#elif defined(__BEOS__) || defined(__HAIKU__) -#define BEOS -#elif defined(__riscos__) -#define RISCOS -#elif defined(__ATHEOS__) || defined(__SYLLABLE__) -#define ATHEOS -#elif defined(__SPAD__) -#define SPAD -#elif defined(__VMS) -#define OPENVMS -#elif defined(__DJGPP) -#define DOS -#else #define UNIX #endif @@ -66,204 +45,6 @@ static inline int dir_sep(unsigned char x) { return x == '/'; } #define ASSOC_BLOCK #define ASSOC_CONS_XWIN -#elif defined(OS2) - -static inline int dir_sep(unsigned char x) { return x == '/' || x == '\\'; } -#define NEWLINE "\r\n" -/*#define NO_ASYNC_LOOKUP*/ -#define SYSTEM_ID SYS_OS2 -#define SYSTEM_NAME "OS/2" -#define DEFAULT_SHELL "cmd.exe" -#define GETSHELL getenv("COMSPEC") -#define NO_FG_EXEC -#define NO_CTRL_Z -#define DOS_FS -#define DOS_FS_8_3 -#define NO_FILE_SECURITY -#define NO_FORK_ON_EXIT -#define ASSOC_CONS_XWIN -#define DISABLE_SMB - -#elif defined(WIN) - -static inline int dir_sep(unsigned char x) { return x == '/' || x == '\\'; } -#define NEWLINE "\r\n" -/*#define NO_ASYNC_LOOKUP*/ -#define SYSTEM_ID SYS_WIN_32 -#define SYSTEM_NAME "Win32" -#define DEFAULT_SHELL "cmd.exe" -#define GETSHELL getenv("COMSPEC") -#define NO_FG_EXEC -#define NO_CTRL_Z -#define DOS_FS -#define SET_WINDOW_TITLE_UTF_8 -#define ASSOC_CONS_XWIN -#define DISABLE_SMB -#ifdef __CYGWIN__ -#define OS_BAD_SIGNALS -#endif -#ifndef HAVE_PTHREADS -#define HAVE_PTHREADS -#endif -#if defined(HAVE_SYS_UN_H) && !defined(_UWIN) -#define USE_AF_UNIX -#else -#define DONT_USE_AF_UNIX -#endif -#if defined(_UWIN) -#define USE_WIN32_HEAP -#endif -#ifdef USE_WIN32_HEAP -#define NO_FORK_ON_EXIT -#endif -#ifndef __CYGWIN__ -#define OS_NO_SYSTEM_CHARSET -#endif - -#elif defined(INTERIX) - -static inline int dir_sep(unsigned char x) { return x == '/'; } -#define NEWLINE "\n" -#define FS_UNIX_RIGHTS -#define FS_UNIX_HARDLINKS -#define FS_UNIX_SOFTLINKS -#define FS_UNIX_USERS -#define SYSTEM_ID SYS_INTERIX -#define SYSTEM_NAME "Interix" -#define DEFAULT_SHELL "/bin/sh" -#define GETSHELL getenv("SHELL") -#define SHARED_CONFIG_DIR "/etc/" -#ifdef HAVE_SYS_UN_H -#define USE_AF_UNIX -#else -#define DONT_USE_AF_UNIX -#endif -#define ASSOC_BLOCK -#define ASSOC_CONS_XWIN -#define OS_NO_SYSTEM_CHARSET - -#elif defined(BEOS) - -static inline int dir_sep(unsigned char x) { return x == '/'; } -#define NEWLINE "\n" -#define NO_ASYNC_LOOKUP /* async lookup works on BeOS but crashes the Haiku kernel */ -#define FS_UNIX_RIGHTS -#define FS_UNIX_SOFTLINKS -#define FS_UNIX_USERS -#define SYSTEM_ID SYS_BEOS -#define SYSTEM_NAME "BeOS" -#define DEFAULT_SHELL "/bin/sh" -#define GETSHELL getenv("SHELL") -#define NO_CTRL_Z -#define SHARED_CONFIG_DIR "/etc/" -#define NO_FORK_ON_EXIT -#define ASSOC_BLOCK -#define OS_NO_SYSTEM_CHARSET -#define OS_NO_SYSTEM_LANGUAGE - -#include <sys/time.h> -#include <sys/types.h> -#ifdef HAVE_NET_SOCKET_H -#include <net/socket.h> -#endif -#include <sys/socket.h> - -#include "beos.h" - -#elif defined(RISCOS) - -static inline int dir_sep(unsigned char x) { return x == '/' || x == '\\'; } -#define NEWLINE "\n" -#define SYSTEM_ID SYS_RISCOS -#define SYSTEM_NAME "RISC OS" -#define DEFAULT_SHELL "gos" -#define GETSHELL getenv("SHELL") -#define NO_FG_EXEC -#define NO_CTRL_Z -#define NO_FILE_SECURITY -#define NO_FORK_ON_EXIT -#define DISABLE_SMB -#define OS_NO_SYSTEM_CHARSET -#define OS_NO_SYSTEM_LANGUAGE - -#elif defined(ATHEOS) - -static inline int dir_sep(unsigned char x) { return x == '/'; } -#define NEWLINE "\n" -#define FS_UNIX_RIGHTS -#define FS_UNIX_HARDLINKS -#define FS_UNIX_SOFTLINKS -#define FS_UNIX_USERS -#define SYSTEM_ID SYS_ATHEOS -#define SYSTEM_NAME "Atheos" -#define DEFAULT_SHELL "/bin/sh" -#define GETSHELL getenv("SHELL") -#define SHARED_CONFIG_DIR "/etc/" -#define DONT_USE_AF_UNIX -#define NO_FORK_ON_EXIT -#define ASSOC_BLOCK - -#elif defined(SPAD) - -static inline int dir_sep(unsigned char x) { return x == '/'; } -#define NEWLINE "\n" -#define SYSTEM_ID SYS_SPAD -#define SYSTEM_NAME "Spad" -#define DEFAULT_SHELL "LIB.:/SHELL.EXE" -#define GETSHELL "LIB.:/SHELL.EXE" -#define NO_CTRL_Z -#define SHARED_CONFIG_DIR "ETC.:/" -#ifdef HAVE_SYS_UN_H -#define USE_AF_UNIX -#else -#define DONT_USE_AF_UNIX -#endif -#define NO_FORK_ON_EXIT -#define ASSOC_BLOCK -#define ASSOC_CONS_XWIN -#define OS_NO_SYSTEM_CHARSET -#define OS_NO_SYSTEM_LANGUAGE - -#elif defined(OPENVMS) - -static inline int dir_sep(unsigned char x) { return x == '/'; } -#define NEWLINE "\n" -#define FS_UNIX_RIGHTS -#define SYSTEM_ID SYS_OPENVMS -#define SYSTEM_NAME "VMS" -#define DEFAULT_SHELL "/DCL" -#define GETSHELL NULL -#define SHARED_CONFIG_DIR "/etc/" -#ifndef HAVE_PTHREADS -#define HAVE_PTHREADS -#endif -#define DONT_USE_AF_UNIX -#define NO_CTRL_Z -#define NO_FORK_ON_EXIT -#define ASSOC_BLOCK -#define ASSOC_CONS_XWIN -#define DISABLE_SMB -#define OS_NO_SYSTEM_CHARSET -#define OS_NO_SYSTEM_LANGUAGE - -#elif defined(DOS) - -static inline int dir_sep(unsigned char x) { return x == '/' || x == '\\'; } -#define NEWLINE "\r\n" -#define NO_ASYNC_LOOKUP -#define SYSTEM_ID SYS_DOS -#define SYSTEM_NAME "DOS" -#define DEFAULT_SHELL "command.com" -#define GETSHELL getenv("COMSPEC") -#define SHARED_CONFIG_DIR "/dev/env/DJDIR/etc" -#define NO_CTRL_Z -#define DOS_FS -#define DOS_FS_8_3 -#define NO_FILE_SECURITY -#define DONT_USE_AF_UNIX -#define NO_FORK_ON_EXIT -#define DISABLE_SMB - #endif #ifdef FS_UNIX_USERS