links

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

Commit: 130c24d8d85968b220b67bba964672476c0f7fd7
Parent: 2f8b7ef9dd9b7dacb1e68e8e6174c9963f82d747
Author: opask
Date:   Sat,  4 Aug 2018 19:46:12 -0600

style cleanup

Diffstat:
Merror.c | 6+++---
Mimgcache.c | 105++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msession.c | 6+++---
3 files changed, 56 insertions(+), 61 deletions(-)

diff --git a/error.c b/error.c @@ -59,8 +59,8 @@ void int_error(char *m, ...) va_list l; fatal_tty_exit(); va_start(l, m); - sprintf(cast_char errbuf, "\n"ANSI_SET_BOLD"INTERNAL ERROR"ANSI_CLEAR_BOLD" at %s:%d: %s", errfile, errline, m); - er(cast_char errbuf, l); + sprintf((char *)errbuf, "\n"ANSI_SET_BOLD"INTERNAL ERROR"ANSI_CLEAR_BOLD" at %s:%d: %s", errfile, errline, m); + er((char *)errbuf, l); va_end(l); exit(RET_INTERNAL); #endif @@ -89,5 +89,5 @@ unsigned char *memacpy(const unsigned char *src, size_t len) unsigned char *stracpy(const unsigned char *src) { - return src ? memacpy(src, src != DUMMY ? strlen(cast_const_char src) : 0) : NULL; + return src ? memacpy(src, src != DUMMY ? strlen((const char *)src) : 0) : NULL; } diff --git a/imgcache.c b/imgcache.c @@ -16,28 +16,26 @@ struct cached_image *find_cached_image(int bg, unsigned char *url, int xw, int y struct cached_image *i; struct list_head *li; if (xw >= 0 && yw >= 0 && xyw_meaning == MEANING_DIMS) { - /* The xw and yw is already scaled so that scale and - * aspect don't matter. - */ - foreach(struct cached_image, i, li, image_cache) { + /* The xw and yw is already scaled so that scale and + * aspect don't matter. + */ + foreach(struct cached_image, i, li, image_cache) if (i->background_color == bg - && !strcmp(cast_const_char i->url, cast_const_char url) - && i->wanted_xw == xw - && i->wanted_yw == yw - && i->wanted_xyw_meaning == xyw_meaning - ) goto hit; - } - }else{ - foreach(struct cached_image, i, li, image_cache) { + && !strcmp(cast_const_char i->url, cast_const_char url) + && i->wanted_xw == xw + && i->wanted_yw == yw + && i->wanted_xyw_meaning == xyw_meaning) + goto hit; + } else { + foreach(struct cached_image, i, li, image_cache) if (i->background_color == bg - && !strcmp(cast_const_char i->url, cast_const_char url) - && i->wanted_xw == xw - && i->wanted_yw == yw - && i->wanted_xyw_meaning == xyw_meaning - && i->scale == scale - && i->aspect == aspect - ) goto hit; - } + && !strcmp(cast_const_char i->url, cast_const_char url) + && i->wanted_xw == xw + && i->wanted_yw == yw + && i->wanted_xyw_meaning == xyw_meaning + && i->scale == scale + && i->aspect == aspect) + goto hit; } return NULL; @@ -56,33 +54,26 @@ void add_image_to_cache(struct cached_image *ci) static unsigned long image_size(struct cached_image *cimg) { unsigned long siz = sizeof(struct cached_image); - switch(cimg->state){ - case 0: - case 1: - case 2: - case 3: - case 8: - case 9: - case 10: - case 11: + switch(cimg->state) { + case 0: + case 1: + case 2: + case 3: + case 8: + case 9: + case 10: + case 11: break; - case 12: - case 14: - siz+=(unsigned long)cimg->width*cimg->height*cimg->buffer_bytes_per_pixel; - if (cimg->bmp_used){ - case 13: - case 15: - siz+=(unsigned long)cimg->bmp.x*cimg->bmp.y*(drv->depth&7); - } + case 12: + case 14: + siz += (unsigned long)cimg->width * cimg->height * cimg->buffer_bytes_per_pixel; + if (cimg->bmp_used) + case 13: + case 15: + siz += (unsigned long)cimg->bmp.x * cimg->bmp.y * (drv->depth&7); break; -#ifdef DEBUG - default: - fprintf(stderr,"cimg->state=%d\n",cimg->state); - internal("Invalid cimg->state in image_size\n"); - break; -#endif /* #ifdef DEBUG */ } return siz; } @@ -93,7 +84,9 @@ static int shrink_image_cache(int u) struct list_head *li; longlong si = 0; int r = 0; - foreach(struct cached_image, i, li, image_cache) if (!i->refcount) si += image_size(i); + foreach(struct cached_image, i, li, image_cache) + if (!i->refcount) + si += image_size(i); foreachback(struct cached_image, i, li, image_cache) { if (si <= image_cache_size && u == SH_CHECK_QUOTA) break; @@ -104,7 +97,8 @@ static int shrink_image_cache(int u) si -= image_size(i); del_from_list(i); img_destruct_cached_image(i); - if (u == SH_FREE_SOMETHING) break; + if (u == SH_FREE_SOMETHING) + break; } return r | (list_empty(image_cache) ? ST_CACHE_EMPTY : 0); } @@ -116,17 +110,18 @@ int imgcache_info(int type) int n = 0; foreach(struct cached_image, i, li, image_cache) { switch (type) { - case CI_BYTES: - n += image_size(i); - break; - case CI_LOCKED: - if (!i->refcount) break; - /*-fallthrough*/ - case CI_FILES: - n++; + case CI_BYTES: + n += image_size(i); + break; + case CI_LOCKED: + if (!i->refcount) break; - default: - internal("imgcache_info: query %d", type); + /* fallthrough */ + case CI_FILES: + n++; + break; + default: + internal("imgcache_info: query %d", type); } } return n; diff --git a/session.c b/session.c @@ -1181,8 +1181,7 @@ unsigned char *subst_file(unsigned char *prog, unsigned char *file, int cyg_subs int l = 0; while (*prog) { int p; - for (p = 0; prog[p] && prog[p] != '%'; p++) - ; + for (p = 0; prog[p] && prog[p] != '%'; p++); add_bytes_to_str(&n, &l, prog, p); prog += p; if (*prog == '%') { @@ -1208,7 +1207,8 @@ void start_download(struct session *ses, unsigned char *file, int mode) unsigned char *xl_file; off_t last_pos = 0, file_shift = 0; - if (!url) return; + if (!url) + return; extract_position(url); if (create_or_append_download_file(ses, ses->term->cwd, file, mode, &h, &xl_file, &last_pos, &file_shift) < 0) return;