links

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

Commit: 3ae103d2de295de287a6c2327f073f6dfd265fd0
Parent: cf766a6822643026bc11a12eb79ee89758676e08
Author: opask
Date:   Tue, 21 Aug 2018 08:52:59 -0600

simplification: language.c

Diffstat:
Mdefault.c | 4++--
Mlanguage.c | 25+------------------------
Mlanguage.inc | 5++++-
Mlinks.h | 2--
Mmain.c | 8++++----
5 files changed, 11 insertions(+), 33 deletions(-)

diff --git a/default.c b/default.c @@ -929,7 +929,7 @@ static unsigned char *x_proxy_cmd(struct option *o, unsigned char ***argv, int * unsigned char *result, *ret; if (!*argc) return cast_uchar "Parameter expected"; result = xmalloc(MAX_STR_LEN); - if (save(get_commandline_charset(), result, **argv)) { + if (save(0, result, **argv)) { free(result); return err; } @@ -960,7 +960,7 @@ static unsigned char *lookup_cmd(struct option *o, unsigned char ***argv, int *a if (*argc >= 2) return cast_uchar "Too many parameters"; h = *(*argv)++; (*argc)--; - h2 = convert(get_commandline_charset(), 0, h, NULL); + h2 = stracpy(h); h3 = idn_encode_host(h2, (int)strlen(cast_const_char h2), cast_uchar ".", 0); if (!h3) h3 = stracpy(h2); free(h2); diff --git a/language.c b/language.c @@ -5,36 +5,13 @@ #include "links.h" #include "language.h" - -struct translation { - int code; - const char *name; -}; - #include "language.inc" unsigned char dummyarray[T__N_TEXTS]; -int get_commandline_charset(void) -{ - return dump_codepage == -1 ? 0 : dump_codepage; -} - -static inline int is_direct_text(unsigned char *text) -{ - return !(text >= dummyarray && text < (dummyarray + T__N_TEXTS)); -} - unsigned char *get_text_translation(unsigned char *text, struct terminal *term) { - if (is_direct_text(text)) - return text; - return (unsigned char *)translation[text - dummyarray].name; -} - -unsigned char *get_english_translation(unsigned char *text) -{ - if (is_direct_text(text)) + if (!(text >= dummyarray && text < (dummyarray + T__N_TEXTS))) return text; return (unsigned char *)translation[text - dummyarray].name; } diff --git a/language.inc b/language.inc @@ -1,6 +1,9 @@ /* Automatically generated by gen-intl */ -static const struct translation translation[] = { +static const struct { + int code; + const char *name; +} translation[] = { { 0, NULL }, {T__CHAR_SET, "us-ascii" }, {T__LANGUAGE, "English" }, diff --git a/links.h b/links.h @@ -1636,9 +1636,7 @@ extern unsigned char dummyarray[]; extern int current_language; -int get_commandline_charset(void); unsigned char *get_text_translation(unsigned char *, struct terminal *term); -unsigned char *get_english_translation(unsigned char *); #define TEXT_(x) (dummyarray + x) /* TEXT causes name clash on windows */ diff --git a/main.c b/main.c @@ -276,13 +276,13 @@ static void end_dump(struct object_request *r, void *p) o.xw = screen_width; o.yw = 25; o.col = 0; - o.cp = get_commandline_charset(); + o.cp = 0; ds2do(&dds, &o, 0); o.plain = 0; o.frames = 0; o.framename = cast_uchar ""; if (!casecmp(r->url, cast_uchar "file://", 7) && !o.hard_assume) { - o.assume_cp = get_commandline_charset(); + o.assume_cp = 0; } if (!(fd->f_data = cached_format_html(fd, r, r->url, &o, NULL, 0))) goto term_1; dump_to_file(fd->f_data, 1); @@ -292,7 +292,7 @@ static void end_dump(struct object_request *r, void *p) } if (r->state != O_OK) { unsigned char *m = get_err_msg(r->stat.state); - fprintf(stderr, "%s\n", get_english_translation(m)); + fprintf(stderr, "%s\n", get_text_translation(m, NULL)); retval = RET_ERROR; goto terminate; } @@ -410,7 +410,7 @@ static void init(void) retval = RET_SYNTAX; goto tttt; } - uu = convert(get_commandline_charset(), 0, u, NULL); + uu = stracpy(u); if (!(uuu = translate_url(uu, wd = get_cwd()))) uuu = stracpy(uu); free(uu); request_object(NULL, uuu, NULL, PRI_MAIN, NC_RELOAD, ALLOW_ALL, end_dump, NULL, &dump_obj);