Commit: 8f066a6faa646ec951139aedee90405d47462445
Parent: d2f52a49d8eaf3fb8ba0e8a642668185125b21ae
Author: opask
Date: Fri, 27 Jul 2018 20:02:03 -0600
cleanup more #defines/#ifdefs
Diffstat:
14 files changed, 15 insertions(+), 252 deletions(-)
diff --git a/config.h b/config.h
@@ -3,5 +3,3 @@
/* */
#define HAVE_SIGFILLSET 1
-
-#define HAVE_GETHOSTBYNAME 1
diff --git a/default.c b/default.c
@@ -187,7 +187,7 @@ static unsigned char *create_config_string(struct option *options)
if (options[i].wr_cfg)
options[i].wr_cfg(&options[i], &s, &l);
}
- add_to_str(&s, &l, cast_uchar NEWLINE);
+ add_to_str(&s, &l, cast_uchar "\n");
return s;
}
@@ -436,7 +436,7 @@ static int write_config_data(unsigned char *prefix, unsigned char *name, struct
static void add_nm(struct option *o, unsigned char **s, int *l)
{
- if (*l) add_to_str(s, l, cast_uchar NEWLINE);
+ if (*l) add_to_str(s, l, cast_uchar "\n");
add_to_str(s, l, cast_uchar o->cfg_name);
add_to_str(s, l, cast_uchar " ");
}
@@ -959,11 +959,7 @@ static unsigned char *lookup_cmd(struct option *o, unsigned char ***argv, int *a
do_real_lookup(h3, ipv6_options.addr_preference, &addr);
free(h3);
if (!addr.n) {
-#if !defined(USE_GETADDRINFO)
- herror("error");
-#else
fprintf(stderr, "error: host not found\n");
-#endif
do_exit(RET_ERROR);
return NULL;
}
@@ -1831,7 +1827,7 @@ void save_url_history(void)
if (!*hi->str || hi->str[0] == ' ' || strchr(cast_const_char hi->str, 10) || strchr(cast_const_char hi->str, 13)) continue;
if (!url_not_saveable(hi->str)) {
add_to_str(&hs, &hsl, hi->str);
- add_to_str(&hs, &hsl, cast_uchar NEWLINE);
+ add_to_str(&hs, &hsl, cast_uchar "\n");
}
}
write_to_config_file(history_file, hs, 0);
diff --git a/dip.c b/dip.c
@@ -1613,7 +1613,7 @@ static struct font_cache_entry *locked_color_entry = NULL;
/* Adds required entry into font_cache and returns pointer to the entry.
*/
-ATTR_NOINLINE static struct font_cache_entry *supply_color_cache_entry(struct style *style, struct letter *letter)
+static struct font_cache_entry *supply_color_cache_entry(struct style *style, struct letter *letter)
{
struct font_cache_entry *found, *neww;
unsigned short *primary_data;
diff --git a/dns.c b/dns.c
@@ -15,14 +15,7 @@ struct dnsentry {
unsigned char name[1];
};
-#ifndef THREAD_SAFE_LOOKUP
-struct dnsquery *dns_queue = NULL;
-#endif
-
struct dnsquery {
-#ifndef THREAD_SAFE_LOOKUP
- struct dnsquery *next_in_queue;
-#endif
void (*fn)(void *, int);
void *data;
int h;
@@ -156,8 +149,6 @@ static void add_address(struct lookup_result *host, int af,
host->n++;
}
-#ifdef USE_GETADDRINFO
-
static int use_getaddrinfo(unsigned char *name, struct addrinfo *hints, int preference, struct lookup_result *host)
{
int gai_err;
@@ -188,8 +179,6 @@ static int use_getaddrinfo(unsigned char *name, struct addrinfo *hints, int pref
return 0;
}
-#endif
-
void rotate_addresses(struct lookup_result *host)
{
#if MAX_ADDRESSES > 1
@@ -258,7 +247,6 @@ void do_real_lookup(unsigned char *name, int preference, struct lookup_result *h
}
}
-#if defined(USE_GETADDRINFO)
use_getaddrinfo(name, NULL, preference, host);
#if defined(EXTRA_IPV6_LOOKUP)
if ((preference == ADDR_PREFERENCE_IPV4 && !host->n) ||
@@ -276,25 +264,6 @@ void do_real_lookup(unsigned char *name, int preference, struct lookup_result *h
}
already_have_inet6:;
#endif
-#elif defined(HAVE_GETHOSTBYNAME)
- {
- int i;
- struct hostent *hst;
- if ((hst = gethostbyname(cast_const_char name))) {
- if (hst->h_addrtype != AF_INET || hst->h_length != 4 || !hst->h_addr)
- goto ret;
-#ifdef h_addr
- for (i = 0; hst->h_addr_list[i]; i++) {
- add_address(host, AF_INET, cast_uchar hst->h_addr_list[i], 0, preference);
- }
-#else
- add_address(host, AF_INET, cast_uchar hst->h_addr, 0, preference);
-#endif
- goto ret;
- }
- }
-#endif
-
ret:
return;
}
@@ -308,22 +277,7 @@ static int do_lookup(struct dnsquery *q, int force_async)
static int do_queued_lookup(struct dnsquery *q)
{
-#ifndef THREAD_SAFE_LOOKUP
- q->next_in_queue = NULL;
- if (!dns_queue) {
- dns_queue = q;
-#endif
return do_lookup(q, 0);
-#ifndef THREAD_SAFE_LOOKUP
- } else {
- /*debug("queuing lookup for %s", q->name);*/
- if (dns_queue->next_in_queue)
- internal("DNS queue corrupted");
- dns_queue->next_in_queue = q;
- dns_queue = q;
- return 1;
- }
-#endif
}
static void check_dns_cache_addr_preference(void)
@@ -361,12 +315,6 @@ static void end_dns_lookup(struct dnsquery *q, int a)
size_t sl;
void (*fn)(void *, int);
void *data;
-#ifndef THREAD_SAFE_LOOKUP
- if (q->next_in_queue) {
- do_lookup(q->next_in_queue, 1);
- } else
- dns_queue = NULL;
-#endif
if (!q->fn || !q->addr) {
free(q);
return;
diff --git a/file.c b/file.c
@@ -12,16 +12,11 @@ static void stat_mode(unsigned char **p, int *l, struct stat *stp)
unsigned char bp[12] = "?--------- ";
if (stp)
strmode(stp->st_mode, cast_char bp);
-#ifndef FS_UNIX_RIGHTS
- bp[1] = ' ';
- bp[2] = 0;
-#endif
add_to_str(p, l, bp);
}
#else
-#ifdef FS_UNIX_RIGHTS
static void setrwx(unsigned m, unsigned char *p)
{
if (m & S_IRUSR) p[0] = 'r';
@@ -50,7 +45,6 @@ static void setst(unsigned m, unsigned char *p)
}
#endif
}
-#endif
static void stat_mode(unsigned char **p, int *l, struct stat *stp)
{
@@ -79,7 +73,6 @@ static void stat_mode(unsigned char **p, int *l, struct stat *stp)
#endif
}
add_chr_to_str(p, l, c);
-#ifdef FS_UNIX_RIGHTS
{
unsigned char rwx[10] = "---------";
if (stp) {
@@ -91,7 +84,6 @@ static void stat_mode(unsigned char **p, int *l, struct stat *stp)
}
add_to_str(p, l, rwx);
}
-#endif
add_chr_to_str(p, l, ' ');
}
@@ -100,27 +92,22 @@ static void stat_mode(unsigned char **p, int *l, struct stat *stp)
static void stat_links(unsigned char **p, int *l, struct stat *stp)
{
-#ifdef FS_UNIX_HARDLINKS
unsigned char lnk[64];
if (!stp) add_to_str(p, l, cast_uchar " ");
else {
sprintf(cast_char lnk, "%3ld ", (unsigned long)stp->st_nlink);
add_to_str(p, l, lnk);
}
-#endif
}
-#ifdef FS_UNIX_USERS
static int last_uid = -1;
static unsigned char last_user[64];
static int last_gid = -1;
static unsigned char last_group[64];
-#endif
static void stat_user(unsigned char **p, int *l, struct stat *stp, int g)
{
-#ifdef FS_UNIX_USERS
struct passwd *pwd;
struct group *grp;
int id;
@@ -149,7 +136,6 @@ static void stat_user(unsigned char **p, int *l, struct stat *stp, int g)
add_to_str(p, l, pp);
for (i = (int)strlen(cast_const_char pp); i < 8; i++) add_chr_to_str(p, l, ' ');
add_chr_to_str(p, l, ' ');
-#endif
}
static void stat_size(unsigned char **p, int *l, struct stat *stp)
@@ -217,7 +203,7 @@ struct dirs {
unsigned char *f;
};
-LIBC_CALLBACK static int comp_de(const void *d1_, const void *d2_)
+static int comp_de(const void *d1_, const void *d2_)
{
const struct dirs *d1 = (const struct dirs *)d1_;
const struct dirs *d2 = (const struct dirs *)d2_;
@@ -298,10 +284,8 @@ void file_func(struct connection *c)
closedir(d);
goto end;
}
-#ifdef FS_UNIX_USERS
last_uid = -1;
last_gid = -1;
-#endif
file = init_str();
fl = 0;
add_to_str(&file, &fl, cast_uchar "<html><head><title>");
@@ -334,11 +318,7 @@ void file_func(struct connection *c)
l = 0;
n = stracpy(name);
add_to_strn(&n, cast_uchar de->d_name);
-#ifdef FS_UNIX_SOFTLINKS
EINTRLOOP(rs, lstat(cast_const_char n, &stt));
-#else
- EINTRLOOP(rs, stat(cast_const_char n, &stt));
-#endif
if (rs) stp = NULL;
else stp = &stt;
free(n);
@@ -353,7 +333,6 @@ void file_func(struct connection *c)
if (dirl) qsort(dir, dirl, sizeof(struct dirs), (int (*)(const void *, const void *))comp_de);
for (i = 0; i < dirl; i++) {
unsigned char *lnk = NULL;
-#ifdef FS_UNIX_SOFTLINKS
if (dir[i].s[0] == 'l') {
unsigned char *buf = NULL;
int size = 0;
@@ -376,7 +355,6 @@ void file_func(struct connection *c)
xxx:
free(n);
}
-#endif
/*add_to_str(&file, &fl, cast_uchar " ");*/
add_to_str(&file, &fl, dir[i].s);
add_to_str(&file, &fl, cast_uchar "<a href=\"./");
diff --git a/links.h b/links.h
@@ -126,7 +126,7 @@ static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
}
return 0;
}
-#else
+#else /* if !defined(HAVE_PTHREAD_SIGMASK) */
#define do_sigprocmask sigprocmask
#define sigset_t int
#ifndef SIG_BLOCK
@@ -157,17 +157,13 @@ static inline int do_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
#ifdef HAVE_SIGFILLSET
#undef HAVE_SIGFILLSET
#endif
-#endif
+#endif /* defined(HAVE_PTHREAD_SIGMASK) */
+
#ifdef HAVE_SIGFILLSET
static inline void sig_fill_set(sigset_t *set)
{
sigfillset(set);
}
-#else
-static inline void sig_fill_set(sigset_t *set)
-{
- memset(set, -1, sizeof(sigset_t));
-}
#endif
#define option option_dirty_workaround_for_name_clash_with_include_on_cygwin
@@ -217,13 +213,9 @@ void *xrealloc(void *, size_t);
#define ANSI_CLEAR_BOLD "\033[0m"
void *do_not_optimize_here(void *p);
-void error(char *, ...) PRINTF_FORMAT(1, 2);
-void fatal_exit(char *, ...) PRINTF_FORMAT(1, 2) ATTR_NORETURN;
-void int_error(char *, ...) PRINTF_FORMAT(1, 2)
-#ifndef NO_IE
- ATTR_NORETURN
-#endif
- ;
+void error(char *, ...);
+void fatal_exit(char *, ...);
+void int_error(char *, ...);
extern int errline;
extern unsigned char *errfile;
@@ -428,9 +420,6 @@ int c_accept(int, struct sockaddr *, socklen_t *);
int c_open(unsigned char *, int);
int c_open3(unsigned char *, int, int);
DIR *c_opendir(unsigned char *);
-#ifdef HAVE_OPEN_PREALLOC
-int open_prealloc(unsigned char *, int, int, off_t);
-#endif
int get_input_handle(void);
int get_output_handle(void);
int get_ctl_handle(void);
@@ -558,11 +547,7 @@ void set_sigcld(void);
/* dns.c */
-#ifdef USE_GETADDRINFO
#define MAX_ADDRESSES 64
-#else
-#define MAX_ADDRESSES 1
-#endif
struct host_address {
int af;
diff --git a/menu.c b/menu.c
@@ -1105,7 +1105,6 @@ static void dlg_net_options(struct terminal *term, void *xxx, void *yyy)
d->items[a].fn = check_number;
d->items[a].gid = 1;
d->items[a++].gnum = 9999;
-#ifdef USE_GETADDRINFO
net_msg[a] = TEXT_(T_TIMEOUT_WHEN_TRYING_MULTIPLE_ADDRESSES);
d->items[a].type = D_FIELD;
d->items[a].data = addrtime_str;
@@ -1113,7 +1112,6 @@ static void dlg_net_options(struct terminal *term, void *xxx, void *yyy)
d->items[a].fn = check_number;
d->items[a].gid = 1;
d->items[a++].gnum = 999;
-#endif
net_msg[a] = TEXT_(T_BIND_TO_LOCAL_IP_ADDRESS);
d->items[a].type = D_FIELD;
d->items[a].data = bind_ip_address;
diff --git a/os_dep.c b/os_dep.c
@@ -320,36 +320,6 @@ DIR *c_opendir(unsigned char *path)
return d;
}
-#if defined(O_SIZE) && defined(__EMX__)
-
-int open_prealloc(unsigned char *name, int flags, int mode, off_t siz)
-{
- int h;
- fd_lock();
- EINTRLOOP(h, open(cast_const_char name, flags | O_SIZE, mode, (unsigned long)siz));
- if (h != -1) new_fd_bin(h);
- fd_unlock();
- return h;
-}
-
-#elif defined(HAVE_OPEN_PREALLOC)
-
-int open_prealloc(unsigned char *name, int flags, int mode, off_t siz)
-{
- int h, rs;
- fd_lock();
- EINTRLOOP(h, open(cast_const_char name, flags, mode));
- if (h == -1) {
- fd_unlock();
- return -1;
- }
- new_fd_bin(h);
- fd_unlock();
- return h;
-}
-
-#endif
-
/* Exec */
int is_twterm(void)
diff --git a/os_dep.h b/os_dep.h
@@ -27,18 +27,11 @@
#if defined(UNIX)
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_UNIX
#define SYSTEM_NAME "Unix"
#define DEFAULT_SHELL "/bin/sh"
#define GETSHELL getenv("SHELL")
#define SHARED_CONFIG_DIR "/etc/"
-#define ASSOC_BLOCK
-#define ASSOC_CONS_XWIN
#endif
diff --git a/os_depx.h b/os_depx.h
@@ -123,29 +123,6 @@
#define SA_RESTART 0
#endif
-#ifdef __EMX__
-#define getcwd _getcwd2
-#define chdir _chdir2
-#endif
-
-#if defined(O_SIZE) && defined(__EMX__)
-#define HAVE_OPEN_PREALLOC
-#elif (defined(HAVE_FALLOCATE) || defined(HAVE_POSIX_FALLOCATE))
-#define HAVE_OPEN_PREALLOC
-#endif
-
-#if defined(__WATCOMC__) && defined(_WCRTLINK)
-#define LIBC_CALLBACK _WCRTLINK
-#else
-#define LIBC_CALLBACK
-#endif
-
-#if defined(__WATCOMC__) && defined(__LINUX__)
-#define SIGNAL_HANDLER __declspec(__cdecl)
-#else
-#define SIGNAL_HANDLER
-#endif
-
#ifndef PF_INET
#define PF_INET AF_INET
#endif
@@ -156,37 +133,6 @@
#define my_intptr_t long
#define my_uintptr_t unsigned long
-#if defined(__GNUC__)
-#if __GNUC__ >= 2
-#define PRINTF_FORMAT(a, b) __attribute__((format(printf, a, b)))
-#endif
-#endif
-#ifndef PRINTF_FORMAT
-#define PRINTF_FORMAT(a, b)
-#endif
-
-#if defined(__clang_analyzer__)
-#define ATTR_NORETURN __attribute__((analyzer_noreturn))
-#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)
-#define ATTR_NORETURN __attribute__((noreturn))
-#endif
-#endif
-#ifndef ATTR_NORETURN
-#define ATTR_NORETURN
-#endif
-
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-#define ATTR_NOINLINE __attribute__((__noinline__))
-#endif
-#endif
-#ifndef ATTR_NOINLINE
-#define ATTR_NOINLINE
-#endif
-
-#define USE_GETADDRINFO
-
#ifndef PF_INET6
#define PF_INET6 AF_INET6
#endif
@@ -210,9 +156,3 @@ typedef const char *const_char_ptr;
#if defined(HAVE_PTHREADS)
#define EXEC_IN_THREADS
#endif
-
-#if !defined(EXEC_IN_THREADS) || !defined(HAVE_GETHOSTBYNAME) || defined(USE_GETADDRINFO)
-#define THREAD_SAFE_LOOKUP
-#endif
-
-#define loop_select select
diff --git a/select.c b/select.c
@@ -634,7 +634,7 @@ static volatile struct signal_handler signal_handlers[NUM_SIGNALS];
pid_t signal_pid;
int signal_pipe[2];
-SIGNAL_HANDLER static void got_signal(int sig)
+static void got_signal(int sig)
{
void (*fn)(void *);
int sv_errno = errno;
@@ -903,7 +903,7 @@ void select_loop(void (*init)(void))
#ifdef DEBUG_CALLS
fprintf(stderr, "select\n");
#endif
- if ((n = loop_select(w_max, &x_read, &x_write, NULL, tm)) < 0) {
+ if ((n = select(w_max, &x_read, &x_write, NULL, tm)) < 0) {
#ifdef DEBUG_CALLS
fprintf(stderr, "select intr\n");
#endif
diff --git a/session.c b/session.c
@@ -833,26 +833,6 @@ static int download_write(struct download *down, void *ptr, off_t to_write)
return 0;
}
-static int download_prealloc(struct download *down, off_t est_length)
-{
- if (est_length <= 0)
- return 0;
-#ifdef HAVE_OPEN_PREALLOC
- if (!down->last_pos && !strcmp(cast_const_char down->file, cast_const_char down->orig_file)) {
- struct stat st;
- int rs;
- EINTRLOOP(rs, fstat(down->handle, &st));
- if (rs || !S_ISREG(st.st_mode))
- return 0;
- close_download_file(down);
- delete_download_file(down);
- if ((down->handle = create_download_file(get_download_ses(down), down->cwd, down->file, !down->prog ? CDF_EXCL : CDF_RESTRICT_PERMISSION | CDF_EXCL, est_length)) < 0)
- return -1;
- }
-#endif
- return 0;
-}
-
static void download_data(struct status *stat, void *down_)
{
struct download *down = (struct download *)down_;
@@ -915,8 +895,6 @@ static void download_data(struct status *stat, void *down_)
foreach(struct fragment, frag, lfrag, ce->frag) {
have_frag:
while (frag->offset <= down->last_pos && frag->offset + frag->length > down->last_pos) {
- if (download_prealloc(down, stat->state < 0 ? ce->length : down->stat.prg ? down->stat.prg->size : 0))
- goto det_abt;
if (download_write(down, frag->data + (down->last_pos - frag->offset), frag->length - (down->last_pos - frag->offset))) {
det_abt:
detach_connection(stat, down->last_pos, 0, 0);
@@ -935,8 +913,6 @@ have_frag:
int err;
get_file_by_term(ses ? ses->term : NULL, ce, &start, &end, &err);
if (err) goto det_abt;
- if (download_prealloc(down, end - start))
- goto det_abt;
while (down->last_pos < end - start) {
if (download_write(down, start + down->last_pos, end - start - down->last_pos)) goto det_abt;
}
@@ -1008,14 +984,7 @@ int create_download_file(struct session *ses, unsigned char *cwd, unsigned char
wd = get_cwd();
set_cwd(cwd);
file = translate_download_file(fi);
-#ifdef HAVE_OPEN_PREALLOC
- if (siz && !(mode & CDF_NOTRUNC)) {
- h = open_prealloc(file, O_CREAT | O_NOCTTY | O_WRONLY | O_TRUNC | (mode & CDF_EXCL ? O_EXCL : 0), perm, siz);
- } else
-#endif
- {
- h = c_open3(file, O_CREAT | O_NOCTTY | O_WRONLY | (mode & CDF_NOTRUNC ? 0 : O_TRUNC) | (mode & CDF_EXCL ? O_EXCL : 0), perm);
- }
+ h = c_open3(file, O_CREAT | O_NOCTTY | O_WRONLY | (mode & CDF_NOTRUNC ? 0 : O_TRUNC) | (mode & CDF_EXCL ? O_EXCL : 0), perm);
if (h == -1) {
unsigned char *msg, *msge;
int errn = errno;
diff --git a/types.c b/types.c
@@ -143,13 +143,9 @@ static unsigned char * const ct_msg[] = {
TEXT_(T_LABEL),
TEXT_(T_CONTENT_TYPES),
TEXT_(T_PROGRAM__IS_REPLACED_WITH_FILE_NAME),
-#ifdef ASSOC_BLOCK
TEXT_(T_BLOCK_TERMINAL_WHILE_PROGRAM_RUNNING),
-#endif
-#ifdef ASSOC_CONS_XWIN
TEXT_(T_RUN_ON_TERMINAL),
TEXT_(T_RUN_IN_XWINDOW),
-#endif
TEXT_(T_ASK_BEFORE_OPENING),
TEXT_(T_ACCEPT_HTTP),
TEXT_(T_ACCEPT_FTP),
@@ -163,12 +159,8 @@ static void assoc_edit_item_fn(struct dialog_data *dlg)
int y = gf_val(-1, -G_BFU_FONT_SIZE);
int p = 3;
if (dlg->win->term->spec->braille) y += gf_val(1, G_BFU_FONT_SIZE);
-#ifdef ASSOC_BLOCK
p++;
-#endif
-#ifdef ASSOC_CONS_XWIN
p += 2;
-#endif
max_text_width(term, ct_msg[0], &max, AL_LEFT);
min_text_width(term, ct_msg[0], &min, AL_LEFT);
max_text_width(term, ct_msg[1], &max, AL_LEFT);
@@ -309,19 +301,15 @@ static void assoc_edit_item(struct dialog_data *dlg, struct list *data, void (*o
d->items[2].data = prog;
d->items[2].fn = check_nonempty;
p = 3;
-#ifdef ASSOC_BLOCK
d->items[p].type = D_CHECKBOX;
d->items[p].data = (unsigned char *)&neww->block;
d->items[p++].dlen = sizeof(int);
-#endif
-#ifdef ASSOC_CONS_XWIN
d->items[p].type = D_CHECKBOX;
d->items[p].data = (unsigned char *)&neww->cons;
d->items[p++].dlen = sizeof(int);
d->items[p].type = D_CHECKBOX;
d->items[p].data = (unsigned char *)&neww->xwin;
d->items[p++].dlen = sizeof(int);
-#endif
d->items[p].type = D_CHECKBOX;
d->items[p].data = (unsigned char *)&neww->ask;
d->items[p++].dlen = sizeof(int);
diff --git a/view.c b/view.c
@@ -117,7 +117,7 @@ static int find_tag(struct f_data *f, unsigned char *name)
return -1;
}
-LIBC_CALLBACK static int comp_links(const void *l1_, const void *l2_)
+static int comp_links(const void *l1_, const void *l2_)
{
const struct link *l1 = (const struct link *)l1_;
const struct link *l2 = (const struct link *)l2_;