From 49c3c89dcb93515dec84d7ee7b7ca6146bcafc69 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 23 Dec 2006 01:44:26 +0200 Subject: [PATCH 1/5] Add an initial comment as commanded in doc/hacking.txt. --- src/ecmascript/see/checktype.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ecmascript/see/checktype.c b/src/ecmascript/see/checktype.c index 5e7ff9eb..6c1fc700 100644 --- a/src/ecmascript/see/checktype.c +++ b/src/ecmascript/see/checktype.c @@ -1,3 +1,5 @@ +/* Check the type of a SEE object so it's safe to cast */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif From d62144b944eb8af1e1d4428b7bfb9fbc7097dcad Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 23 Dec 2006 01:45:26 +0200 Subject: [PATCH 2/5] hacking.txt: spellings of UTF-8, utf8 --- doc/hacking.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/hacking.txt b/doc/hacking.txt index 140adf50..dfc4bef1 100644 --- a/doc/hacking.txt +++ b/doc/hacking.txt @@ -497,6 +497,9 @@ Use assert() and assertm() where applicable. It will prevent hidden bugs. Names of enum constants should be in upper case. +Please call the charset "utf8" or "UTF8" in identifiers, "UTF-8" +elsewhere, and "utf_8" only for compatibility. + If you see code in ELinks that doesn't follow these rules, fix it or tell us about it. From cde14dcd18a5382d5f071af6c1a9b50301146076 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 23 Dec 2006 01:48:07 +0200 Subject: [PATCH 3/5] utf8_to_unicode: Reject characters in the surrogate range. This isn't CESU-8. --- src/intl/charsets.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/intl/charsets.c b/src/intl/charsets.c index 37161b19..0d334713 100644 --- a/src/intl/charsets.c +++ b/src/intl/charsets.c @@ -639,7 +639,7 @@ utf8_to_unicode(unsigned char **string, unsigned char *end) } switch (length) { - case 1: + case 1: /* U+0000 to U+007F */ if (str[0] >= 0x80) { invalid_utf8: ++*string; @@ -647,7 +647,7 @@ invalid_utf8: } u = str[0]; break; - case 2: + case 2: /* U+0080 to U+07FF */ if ((str[1] & 0xc0) != 0x80) goto invalid_utf8; u = (str[0] & 0x1f) << 6; @@ -655,16 +655,16 @@ invalid_utf8: if (u < 0x80) goto invalid_utf8; break; - case 3: + case 3: /* U+0800 to U+FFFF, except surrogates */ if ((str[1] & 0xc0) != 0x80 || (str[2] & 0xc0) != 0x80) goto invalid_utf8; u = (str[0] & 0x0f) << 12; u += ((str[1] & 0x3f) << 6); u += (str[2] & 0x3f); - if (u < 0x800) + if (u < 0x800 || is_utf16_surrogate(u)) goto invalid_utf8; break; - case 4: + case 4: /* U+10000 to U+1FFFFF */ if ((str[1] & 0xc0) != 0x80 || (str[2] & 0xc0) != 0x80 || (str[3] & 0xc0) != 0x80) goto invalid_utf8; @@ -675,7 +675,7 @@ invalid_utf8: if (u < 0x10000) goto invalid_utf8; break; - case 5: + case 5: /* U+200000 to U+3FFFFFF */ if ((str[1] & 0xc0) != 0x80 || (str[2] & 0xc0) != 0x80 || (str[3] & 0xc0) != 0x80 || (str[4] & 0xc0) != 0x80) goto invalid_utf8; @@ -687,7 +687,7 @@ invalid_utf8: if (u < 0x200000) goto invalid_utf8; break; - case 6: + case 6: /* U+4000000 to U+7FFFFFFF */ if ((str[1] & 0xc0) != 0x80 || (str[2] & 0xc0) != 0x80 || (str[3] & 0xc0) != 0x80 || (str[4] & 0xc0) != 0x80 || (str[5] & 0xc0) != 0x80) From 15dce57bc9523d1ba3b36dcbfd6ed347189e1ae6 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 23 Dec 2006 02:11:01 +0200 Subject: [PATCH 4/5] Bug 908, activate_link: Set fs->state before the fs pointer becomes invalid. --- src/viewer/text/link.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 40e65e03..02d59232 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1019,6 +1019,13 @@ activate_link(struct session *ses, struct document_view *doc_view, return FRAME_EVENT_REFRESH; } + /* @link_fc->type must be FC_RADIO, then. First turn + * this one on, and then turn off all the other radio + * buttons in the group. Do it in this order because + * further @find_form_state calls may reallocate + * @doc_view->vs->form_info[] and thereby make the @fs + * pointer invalid. */ + fs->state = 1; foreach (form, doc_view->document->forms) { struct form_control *fc; @@ -1027,7 +1034,8 @@ activate_link(struct session *ses, struct document_view *doc_view, foreach (fc, form->items) { if (fc->type == FC_RADIO - && !xstrcmp(fc->name, link_fc->name)) { + && !xstrcmp(fc->name, link_fc->name) + && fc != link_fc) { struct form_state *frm_st; frm_st = find_form_state(doc_view, fc); @@ -1035,7 +1043,6 @@ activate_link(struct session *ses, struct document_view *doc_view, } } } - fs->state = 1; break; From 4b156678c687da4779acc5a3e5b33d9bb83bc7b4 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 23 Dec 2006 02:49:44 +0200 Subject: [PATCH 5/5] terminal._template_.utf_8_io: Move the comment above the option and extend it. This lets xgettext attach the comment to a more appropriate msgid. --- src/config/options.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/config/options.inc b/src/config/options.inc index c2fae4c7..485474dd 100644 --- a/src/config/options.inc +++ b/src/config/options.inc @@ -885,14 +885,16 @@ static struct option_info config_options_info[] = { "and lines working at the same time. Makes sense only with linux\n" "terminal.")), + /* When CONFIG_UTF8 is defined, any code that reads the "utf_8_io" + * option should also check whether the "codepage" option is UTF-8, + * and if so, behave as if "utf_8_io" were 1. (When CONFIG_UTF8 is + * not defined, it should not be possible to set UTF-8 as "codepage"; + * please report any such possibilities as bugs.) */ INIT_OPT_BOOL("terminal._template_", N_("UTF-8 I/O"), "utf_8_io", 0, 0, N_("Enable I/O in UTF-8 for Unicode terminals. Note that currently,\n" "only the subset of UTF-8 according to terminal codepage is used.\n" "ELinks ignores this option if the terminal codepage is UTF-8.")), - /* When CONFIG_UTF8 is defined, any code that reads the "utf_8_io" - * option should also check whether the "codepage" option is UTF-8, - * and if so, behave as if "utf_8_io" were 1. */ INIT_OPT_BOOL("terminal._template_", N_("Restrict frames in cp850/852"), "restrict_852", 0, 0,