From f25f944123d97041e31c1dea3e7b07e7718a2137 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 10 Dec 2005 17:03:41 +0100 Subject: [PATCH 01/42] Fix update-po and check-po when srcdir != builddir Now, $(lang).po files are always read and written in srcdir. Also, document how *.gmo files end up in both srcdir and builddir. --- po/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/po/Makefile b/po/Makefile index 1aa549a77..57b2bdd45 100644 --- a/po/Makefile +++ b/po/Makefile @@ -12,6 +12,10 @@ MSGMERGE = msgmerge POTFILES_ABS_LIST = potfiles.list +# Distributed elinks-*.tar.gz packages include po/*.gmo files, so that +# users can install ELinks even if they don't have a msgfmt program. +# However, if srcdir != builddir, then this Makefile ignores the *.gmo +# files in the srcdir and builds new ones in the builddir. %.gmo: $(srcdir)/%.po @file=`echo $* | sed 's,.*/,,'`.gmo \ && rm -f $$file && echo -n $*": " \ @@ -65,8 +69,8 @@ update-po: Makefile $(srcdir)/$(PACKAGE).pot @cd $(srcdir) @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \ echo -n "$(lang): "; \ - if $(MSGMERGE) $(lang).po $(PACKAGE).pot -o $(lang).new.po; then \ - mv -f $(lang).new.po $(lang).po; \ + if $(MSGMERGE) $(srcdir)/$(lang).po $(srcdir)/$(PACKAGE).pot -o $(lang).new.po; then \ + mv -f $(lang).new.po $(srcdir)/$(lang).po; \ else \ echo "msgmerge failed!"; \ rm -f $(lang).new.po; \ @@ -84,7 +88,7 @@ update-gmo: Makefile $(GMOFILES) check-po: @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \ echo -n "$(lang): "; \ - $(GMSGFMT) --check --check-accelerators=~ --verbose --statistics -o /dev/null $(lang).po; \ + $(GMSGFMT) --check --check-accelerators=~ --verbose --statistics -o /dev/null $(srcdir)/$(lang).po; \ ) ### Installation and distribution From ce852b9d5f3a101a686e9e851aef505f0462c2fb Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 10 Dec 2005 17:07:21 +0100 Subject: [PATCH 02/42] Use $@ to simplify a rule and try to nullify metacharacters I changed the %.gmo rule in po/Makefile to use $@ instead of a shell variable, and made various tweaks in it to better support strange file names, e.g. spaces in $(srcdir). I suppose other makefiles in ELinks and other rules in po/Makefile do not support those, but one must start somewhere. I don't think it will ever be feasible to support backslashes and quotes without horrible contortions, but spaces and dashes should be doable. I also quoted the ~ in --check-accelerators=~ in case some shell might want to expand it as the home directory. Bash 3.00.16(1) doesn't because the word contains dashes. --- po/Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/po/Makefile b/po/Makefile index 57b2bdd45..be4177497 100644 --- a/po/Makefile +++ b/po/Makefile @@ -17,9 +17,8 @@ POTFILES_ABS_LIST = potfiles.list # However, if srcdir != builddir, then this Makefile ignores the *.gmo # files in the srcdir and builds new ones in the builddir. %.gmo: $(srcdir)/%.po - @file=`echo $* | sed 's,.*/,,'`.gmo \ - && rm -f $$file && echo -n $*": " \ - && $(GMSGFMT) --statistics -o $$file $< + @rm -f -- "$@" && printf "%s: " "$*" \ + && $(GMSGFMT) --statistics -o "$@" -- "$<" ### The default rule @@ -88,7 +87,7 @@ update-gmo: Makefile $(GMOFILES) check-po: @$(foreach lang,$(basename $(if $(strip $(PO)),$(PO),$(GMOFILES))), \ echo -n "$(lang): "; \ - $(GMSGFMT) --check --check-accelerators=~ --verbose --statistics -o /dev/null $(srcdir)/$(lang).po; \ + $(GMSGFMT) --check --check-accelerators="~" --verbose --statistics -o /dev/null $(srcdir)/$(lang).po; \ ) ### Installation and distribution From f9dea85126822a4fb72a870c4cbf42b14d0865e2 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sat, 10 Dec 2005 16:24:54 +0000 Subject: [PATCH 03/42] Drop a line that should have been dropped with commit 3719e750688fe968d50e78c42d70eda0b146a5a6, 'Reduce code redundancy.' --- src/document/html/parser/forms.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c index a0c19f952..17f62a466 100644 --- a/src/document/html/parser/forms.c +++ b/src/document/html/parser/forms.c @@ -417,8 +417,6 @@ abort: if (!closing_tag) { unsigned char *value, *label; - add_select_item(&lnk_menu, &lbl, &orig_lbl, values, order, nnmi); - if (has_attr(t_attr, "disabled", html_context->options)) goto see; if (preselect == -1 From ce3778c3c0b3d92ff860dc4c012c4d8da76f5301 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 18:37:47 +0100 Subject: [PATCH 04/42] Add struct dom_string In time it should be used for all strings in the DOM engine. For now it is just used for node->string. --- src/document/dom/node.c | 26 +++++++++++++------------- src/document/dom/node.h | 4 ++-- src/document/dom/renderer.c | 6 +++--- src/document/dom/stack.h | 4 ++-- src/document/dom/string.h | 21 +++++++++++++++++++++ src/document/sgml/sgml.c | 6 +++--- 6 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 src/document/dom/string.h diff --git a/src/document/dom/node.c b/src/document/dom/node.c index ece10b6b5..91d41e5fa 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -155,13 +155,13 @@ dom_node_cmp(struct dom_node_search *search, struct dom_node *node) } } { - int length = int_min(key->length, node->length); - int string_diff = strncasecmp(key->string, node->string, length); + int length = int_min(key->string.length, node->string.length); + int string_diff = strncasecmp(key->string.string, node->string.string, length); /* If the lengths or strings don't match strncasecmp() does the * job else return which ever is bigger. */ - return string_diff ? string_diff : key->length - node->length; + return string_diff ? string_diff : key->string.length - node->string.length; } } @@ -213,7 +213,7 @@ struct dom_node * get_dom_node_map_entry(struct dom_node_list *list, enum dom_node_type type, uint16_t subtype, unsigned char *name, int namelen) { - struct dom_node node = { type, namelen, name }; + struct dom_node node = { type, INIT_DOM_STRING(name, namelen) }; struct dom_node_search search = INIT_DOM_NODE_SEARCH(&node, subtype, list); return dom_node_list_bsearch(&search, list); @@ -235,9 +235,8 @@ init_dom_node_(unsigned char *file, int line, if (!node) return NULL; node->type = type; - node->string = string; - node->length = length; node->parent = parent; + set_dom_string(&node->string, string, length); if (parent) { struct dom_node_list **list = get_dom_node_list(parent, node); @@ -272,7 +271,7 @@ done_dom_node_data(struct dom_node *node) switch (node->type) { case DOM_NODE_ATTRIBUTE: if (data->attribute.allocated) - mem_free(node->string); + done_dom_string(&node->string); break; case DOM_NODE_DOCUMENT: @@ -296,7 +295,7 @@ done_dom_node_data(struct dom_node *node) case DOM_NODE_TEXT: if (data->text.allocated) - mem_free(node->string); + done_dom_string(&node->string); break; case DOM_NODE_PROCESSING_INSTRUCTION: @@ -383,8 +382,8 @@ get_dom_node_name(struct dom_node *node) case DOM_NODE_NOTATION: case DOM_NODE_PROCESSING_INSTRUCTION: default: - name = node->string; - namelen = node->length; + name = node->string.string; + namelen = node->string.length; } return memacpy(name, namelen); @@ -435,12 +434,13 @@ get_dom_node_value(struct dom_node *node, int codepage) case DOM_NODE_CDATA_SECTION: case DOM_NODE_COMMENT: case DOM_NODE_TEXT: - value = node->string; - valuelen = node->length; + value = node->string.string; + valuelen = node->string.length; break; case DOM_NODE_ENTITY_REFERENCE: - value = get_entity_string(node->string, node->length, + value = get_entity_string(node->string.string, + node->string.length, codepage); valuelen = value ? strlen(value) : 0; break; diff --git a/src/document/dom/node.h b/src/document/dom/node.h index d6c996211..0d0d627de 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -2,6 +2,7 @@ #ifndef EL__DOCUMENT_DOM_NODE_H #define EL__DOCUMENT_DOM_NODE_H +#include "document/dom/string.h" #include "util/hash.h" struct dom_node_list; @@ -207,8 +208,7 @@ struct dom_node { /* Can contain either stuff like element name or for attributes the * attribute name. */ - uint16_t length; - unsigned char *string; + struct dom_string string; struct dom_node *parent; diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index e0abb2db4..1cd372f4e 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -517,8 +517,8 @@ static inline void render_dom_node_text(struct dom_renderer *renderer, struct screen_char *template, struct dom_node *node) { - unsigned char *string = node->string; - int length = node->length; + unsigned char *string = node->string.string; + int length = node->string.length; if (node->type == DOM_NODE_ENTITY_REFERENCE) { string -= 1; @@ -565,7 +565,7 @@ render_dom_proc_instr_source(struct dom_stack *stack, struct dom_node *node, voi if (!value || node->data.proc_instruction.map) return node; - if (check_dom_node_source(renderer, node->string, node->length)) { + if (check_dom_node_source(renderer, node->string.string, node->string.length)) { render_dom_flush(renderer, value); renderer->position = value + valuelen; } diff --git a/src/document/dom/stack.h b/src/document/dom/stack.h index 15c55e1f5..87494b0ea 100644 --- a/src/document/dom/stack.h +++ b/src/document/dom/stack.h @@ -96,8 +96,8 @@ search_dom_stack(struct dom_stack *stack, enum dom_node_type type, struct dom_node *parent = state->node; if (parent->type == type - && parent->length == length - && !strncasecmp(parent->string, string, length)) + && parent->string.length == length + && !strncasecmp(parent->string.string, string, length)) return state; } diff --git a/src/document/dom/string.h b/src/document/dom/string.h new file mode 100644 index 000000000..b93cf7c22 --- /dev/null +++ b/src/document/dom/string.h @@ -0,0 +1,21 @@ +#ifndef EL__DOCUMENT_DOM_STRING_H +#define EL__DOCUMENT_DOM_STRING_H + +struct dom_string { + uint16_t length; + unsigned char *string; +}; + +#define INIT_DOM_STRING(strvalue, strlength) \ + { (strlength) == -1 ? sizeof(strvalue) - 1 : (strlength), (strvalue) } + +static inline void +set_dom_string(struct dom_string *string, unsigned char *value, uint16_t length) +{ + string->string = value; + string->length = length; +} + +#define done_dom_string(str) mem_free((str)->string); + +#endif diff --git a/src/document/sgml/sgml.c b/src/document/sgml/sgml.c index 422e3657c..91fa9ff3e 100644 --- a/src/document/sgml/sgml.c +++ b/src/document/sgml/sgml.c @@ -20,9 +20,9 @@ sgml_info_strcmp(const void *key_, const void *node_) { struct dom_node *key = (struct dom_node *) key_; struct sgml_node_info *node = (struct sgml_node_info *) node_; - int length = int_min(key->length, node->length); - int string_diff = strncasecmp(key->string, node->string, length); - int length_diff = key->length - node->length; + int length = int_min(key->string.length, node->length); + int string_diff = strncasecmp(key->string.string, node->string, length); + int length_diff = key->string.length - node->length; /* If the lengths or strings don't match strncasecmp() does the job * else return which ever is bigger. */ From ed7a292966eb3bc288512a4230ef829c27619f5c Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 18:42:54 +0100 Subject: [PATCH 05/42] Use struct dom_string for node->attribute.value --- src/document/dom/node.c | 4 ++-- src/document/dom/node.h | 6 ++---- src/document/dom/renderer.c | 6 +++--- src/document/dom/string.h | 2 ++ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 91d41e5fa..3ab91d553 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -422,8 +422,8 @@ get_dom_node_value(struct dom_node *node, int codepage) switch (node->type) { case DOM_NODE_ATTRIBUTE: - value = node->data.attribute.value; - valuelen = node->data.attribute.valuelen; + value = node->data.attribute.value.string; + valuelen = node->data.attribute.value.length; break; case DOM_NODE_PROCESSING_INSTRUCTION: diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 0d0d627de..688b6002e 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -107,8 +107,7 @@ struct dom_attribute_node { /* The string that hold the attribute value. The @string / @length * members of {struct dom_node} holds the name that identifies the node * in the map. */ - unsigned char *value; - uint16_t valuelen; + struct dom_string value; /* For xml:lang="en" attributes this holds the offset of 'lang' */ uint16_t namespace_offset; @@ -272,8 +271,7 @@ add_dom_attribute(struct dom_node *parent, unsigned char *string, int length, struct dom_node *node = add_dom_node(parent, DOM_NODE_ATTRIBUTE, string, length); if (node && value) { - node->data.attribute.value = value; - node->data.attribute.valuelen = valuelen; + set_dom_string(&node->data.attribute.value, value, valuelen); } return node; diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 1cd372f4e..05ccb0ae0 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -645,10 +645,10 @@ render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void #endif render_dom_node_text(renderer, template, node); - if (node->data.attribute.value) { + if (is_dom_string_set(&node->data.attribute.value)) { int quoted = node->data.attribute.quoted == 1; - unsigned char *value = node->data.attribute.value - quoted; - int valuelen = node->data.attribute.valuelen + quoted * 2; + unsigned char *value = node->data.attribute.value.string - quoted; + int valuelen = node->data.attribute.value.length + quoted * 2; if (check_dom_node_source(renderer, value, 0)) { render_dom_flush(renderer, value); diff --git a/src/document/dom/string.h b/src/document/dom/string.h index b93cf7c22..5956bea1d 100644 --- a/src/document/dom/string.h +++ b/src/document/dom/string.h @@ -16,6 +16,8 @@ set_dom_string(struct dom_string *string, unsigned char *value, uint16_t length) string->length = length; } +#define is_dom_string_set(str) ((str)->string && (str)->length) + #define done_dom_string(str) mem_free((str)->string); #endif From 9935bf2083f268e03d6e2c31a440a922996ec442 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 18:51:08 +0100 Subject: [PATCH 06/42] Convert some yet unused strings to use the dom_string struct Also remove the unneeded path member from the dom_node_id_item struct. It was obsoleted by the addition of dom_node->parent. --- src/document/dom/node.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 688b6002e..3661f2ef9 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -31,11 +31,6 @@ struct dom_node_id_item { /* The attibute node containing the id value */ struct dom_node *id_attribute; - /* The path to the node. This can be passed to the DOM navigator to - * locate the node. The path should not contain the id node itself. - * E.g. for element "html/body/p/span". */ - unsigned char *path; - /* The node with the @id attribute */ struct dom_node *node; }; @@ -55,15 +50,12 @@ struct dom_document_node { }; struct dom_id { - unsigned char *public_id; - uint16_t pid_length; - uint16_t sid_length; - unsigned char *system_id; + struct dom_string public_id; + struct dom_string system_id; }; struct dom_doctype_subset_info { - uint16_t internallen; - unsigned char *internal; + struct dom_string internal; struct dom_id external; }; From 0546759b4b6ac1d57f5b1d23ca71eceae0ed3539 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 18:59:17 +0100 Subject: [PATCH 07/42] Use struct dom_string for node->proc_instruction.instruction --- src/document/dom/node.c | 4 ++-- src/document/dom/node.h | 6 ++---- src/document/dom/renderer.c | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 3ab91d553..043f553f8 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -427,8 +427,8 @@ get_dom_node_value(struct dom_node *node, int codepage) break; case DOM_NODE_PROCESSING_INSTRUCTION: - value = node->data.proc_instruction.instruction; - valuelen = node->data.proc_instruction.instructionlen; + value = node->data.proc_instruction.instruction.string; + valuelen = node->data.proc_instruction.instruction.length; break; case DOM_NODE_CDATA_SECTION: diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 3661f2ef9..6313f9b61 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -160,8 +160,7 @@ struct dom_proc_instruction_node { /* The target of the processing instruction (xml for '') * is in the @string / @length members. */ /* This holds the value to be processed */ - unsigned char *instruction; - uint16_t instructionlen; + struct dom_string instruction; /* For fast checking of the target type */ uint16_t type; /* enum dom_proc_instruction_type */ @@ -276,8 +275,7 @@ add_dom_proc_instruction(struct dom_node *parent, unsigned char *string, int len struct dom_node *node = add_dom_node(parent, DOM_NODE_PROCESSING_INSTRUCTION, string, length); if (node && instruction) { - node->data.proc_instruction.instruction = instruction; - node->data.proc_instruction.instructionlen = instructionlen; + set_dom_string(&node->data.proc_instruction.instruction, instruction, instructionlen); } return node; diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 05ccb0ae0..7ea2a6e91 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -559,8 +559,8 @@ render_dom_proc_instr_source(struct dom_stack *stack, struct dom_node *node, voi render_dom_node_text(renderer, &renderer->styles[node->type], node); - value = node->data.proc_instruction.instruction; - valuelen = node->data.proc_instruction.instructionlen; + value = node->data.proc_instruction.instruction.string; + valuelen = node->data.proc_instruction.instruction.length; if (!value || node->data.proc_instruction.map) return node; From 5f69255cbcc75cc47b47e988a39002911c1c041a Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 19:21:12 +0100 Subject: [PATCH 08/42] get_dom_node_map_entry(): take name as a dom_string Requires that dom_string->length becomes a size_t. --- src/document/dom/node.c | 4 ++-- src/document/dom/node.h | 2 +- src/document/dom/string.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 043f553f8..0f37e6069 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -211,9 +211,9 @@ int get_dom_node_map_index(struct dom_node_list *list, struct dom_node *node) struct dom_node * get_dom_node_map_entry(struct dom_node_list *list, enum dom_node_type type, - uint16_t subtype, unsigned char *name, int namelen) + uint16_t subtype, struct dom_string *name) { - struct dom_node node = { type, INIT_DOM_STRING(name, namelen) }; + struct dom_node node = { type, INIT_DOM_STRING(name->string, name->length) }; struct dom_node_search search = INIT_DOM_NODE_SEARCH(&node, subtype, list); return dom_node_list_bsearch(&search, list); diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 6313f9b61..a9428cfb5 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -243,7 +243,7 @@ int get_dom_node_map_index(struct dom_node_list *list, struct dom_node *node); struct dom_node * get_dom_node_map_entry(struct dom_node_list *node_map, enum dom_node_type type, uint16_t subtype, - unsigned char *name, int namelen); + struct dom_string *name); struct dom_node * init_dom_node_(unsigned char *file, int line, diff --git a/src/document/dom/string.h b/src/document/dom/string.h index 5956bea1d..cc46faa18 100644 --- a/src/document/dom/string.h +++ b/src/document/dom/string.h @@ -2,7 +2,7 @@ #define EL__DOCUMENT_DOM_STRING_H struct dom_string { - uint16_t length; + size_t length; unsigned char *string; }; From 2aedeb0a676d519400067d4c9d3b248447554b58 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 19:28:37 +0100 Subject: [PATCH 09/42] get_dom_node_type_name(): return struct dom_string * --- src/document/dom/node.c | 32 ++++++++++++++++---------------- src/document/dom/node.h | 2 +- src/document/dom/renderer.c | 6 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 0f37e6069..d8a96988e 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -460,26 +460,26 @@ get_dom_node_value(struct dom_node *node, int codepage) return compress_string(value, valuelen); } -unsigned char * +struct dom_string * get_dom_node_type_name(enum dom_node_type type) { - static unsigned char *dom_node_type_names[DOM_NODES] = { - NULL, - /* DOM_NODE_ELEMENT */ "element", - /* DOM_NODE_ATTRIBUTE */ "attribute", - /* DOM_NODE_TEXT */ "text", - /* DOM_NODE_CDATA_SECTION */ "cdata-section", - /* DOM_NODE_ENTITY_REFERENCE */ "entity-reference", - /* DOM_NODE_ENTITY */ "entity", - /* DOM_NODE_PROCESSING_INSTRUCTION */ "proc-instruction", - /* DOM_NODE_COMMENT */ "comment", - /* DOM_NODE_DOCUMENT */ "document", - /* DOM_NODE_DOCUMENT_TYPE */ "document-type", - /* DOM_NODE_DOCUMENT_FRAGMENT */ "document-fragment", - /* DOM_NODE_NOTATION */ "notation", + static struct dom_string dom_node_type_names[DOM_NODES] = { + INIT_DOM_STRING(NULL, 0), + /* DOM_NODE_ELEMENT */ INIT_DOM_STRING("element", -1), + /* DOM_NODE_ATTRIBUTE */ INIT_DOM_STRING("attribute", -1), + /* DOM_NODE_TEXT */ INIT_DOM_STRING("text", -1), + /* DOM_NODE_CDATA_SECTION */ INIT_DOM_STRING("cdata-section", -1), + /* DOM_NODE_ENTITY_REFERENCE */ INIT_DOM_STRING("entity-reference", -1), + /* DOM_NODE_ENTITY */ INIT_DOM_STRING("entity", -1), + /* DOM_NODE_PROCESSING_INSTRUCTION */ INIT_DOM_STRING("proc-instruction", -1), + /* DOM_NODE_COMMENT */ INIT_DOM_STRING("comment", -1), + /* DOM_NODE_DOCUMENT */ INIT_DOM_STRING("document", -1), + /* DOM_NODE_DOCUMENT_TYPE */ INIT_DOM_STRING("document-type", -1), + /* DOM_NODE_DOCUMENT_FRAGMENT */ INIT_DOM_STRING("document-fragment", -1), + /* DOM_NODE_NOTATION */ INIT_DOM_STRING("notation", -1), }; assert(type < DOM_NODES); - return dom_node_type_names[type]; + return &dom_node_type_names[type]; } diff --git a/src/document/dom/node.h b/src/document/dom/node.h index a9428cfb5..8877e27fa 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -292,7 +292,7 @@ unsigned char *get_dom_node_name(struct dom_node *node); unsigned char *get_dom_node_value(struct dom_node *node, int codepage); /* Returns the name used for identifying the node type. */ -unsigned char *get_dom_node_type_name(enum dom_node_type type); +struct dom_string *get_dom_node_type_name(enum dom_node_type type); /* Returns a pointer to a node list containing attributes. */ #define get_dom_node_attributes(node) \ diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 7ea2a6e91..4a6a1cc54 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -97,8 +97,7 @@ init_dom_renderer(struct dom_renderer *renderer, struct document *document, color_T foreground = document->options.default_fg; static int i_want_struct_module_for_dom; - unsigned char *name = get_dom_node_type_name(type); - int namelen = name ? strlen(name) : 0; + struct dom_string *name = get_dom_node_type_name(type); struct css_selector *selector = NULL; if (!i_want_struct_module_for_dom) { @@ -119,9 +118,10 @@ init_dom_renderer(struct dom_renderer *renderer, struct document *document, } if (name) + if (is_dom_string_set(name)) selector = find_css_selector(&css->selectors, CST_ELEMENT, CSR_ROOT, - name, namelen); + name->string, name->length); if (selector) { struct list_head *properties = &selector->properties; From 7d6db6b1525fa8f845b1066eb92bd515588bb876 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 19:44:01 +0100 Subject: [PATCH 10/42] Update the DOM tree renderer to support dom_strings --- src/document/dom/renderer.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 4a6a1cc54..5993c5fc2 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -286,6 +286,8 @@ render_dom_text(struct dom_renderer *renderer, struct screen_char *template, } } +/*#define DOM_TREE_RENDERER*/ + #ifdef DOM_TREE_RENDERER static void render_dom_printf(struct dom_renderer *renderer, struct screen_char *template, @@ -390,17 +392,17 @@ render_dom_tree(struct dom_stack *stack, struct dom_node *node, void *data) { struct dom_renderer *renderer = stack->renderer; struct screen_char *template = &renderer->styles[node->type]; - unsigned char *name, *value; + struct dom_string *value = &node->string; + unsigned char *name; assert(node && renderer); name = get_dom_node_name(node); - value = memacpy(node->string, node->length); - render_dom_printf(renderer, template, "%-16s: %s\n", name, value); + render_dom_printf(renderer, template, "%-16s: %.*s\n", name, + value->length, value->string); mem_free_if(name); - mem_free_if(value); return node; } @@ -411,7 +413,8 @@ render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *da struct dom_renderer *renderer = stack->renderer; struct document *document = renderer->document; struct screen_char *template = &renderer->styles[node->type]; - unsigned char *name, *value, *id; + unsigned char *name, *value; + struct dom_string *id; assert(node && document); @@ -420,7 +423,10 @@ render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *da id = get_dom_node_type_name(node->type); renderer->canvas_x += stack->depth; - render_dom_printf(renderer, template, "%-16s: %s -> %s\n", id, name, value); + if (id->length < 16) + render_dom_text(renderer, template, " ", 16 - id->length); + render_dom_printf(renderer, template, "%.*s: %s -> %s\n", + id->length, id->string, name, value); mem_free_if(name); mem_free_if(value); @@ -456,7 +462,8 @@ render_dom_tree_branch(struct dom_stack *stack, struct dom_node *node, void *dat struct dom_renderer *renderer = stack->renderer; struct document *document = renderer->document; struct screen_char *template = &renderer->styles[node->type]; - unsigned char *name, *id; + unsigned char *name; + struct dom_string *id; assert(node && document); @@ -464,7 +471,10 @@ render_dom_tree_branch(struct dom_stack *stack, struct dom_node *node, void *dat id = get_dom_node_type_name(node->type); renderer->canvas_x += stack->depth; - render_dom_printf(renderer, template, "%-16s: %s\n", id, name); + if (id->length < 16) + render_dom_text(renderer, template, " ", 16 - id->length); + render_dom_printf(renderer, template, "%.*s: %s\n", + id->length, id->string, name); mem_free_if(name); From 295679a5e640dacc765a677966a25673e9b440c4 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 20:03:43 +0100 Subject: [PATCH 11/42] get_dom_node_name(): return struct dom_string * Also, simplify the rendering a bit for now. --- src/document/dom/node.c | 29 ++++++++++++----------------- src/document/dom/node.h | 2 +- src/document/dom/renderer.c | 31 +++++++++++++------------------ 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index d8a96988e..e6838d1f7 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -345,34 +345,32 @@ done_dom_node(struct dom_node *node) #define set_node_name(name, namelen, str) \ do { (name) = (str); (namelen) = sizeof(str) - 1; } while (0) -unsigned char * +struct dom_string * get_dom_node_name(struct dom_node *node) { - unsigned char *name; - uint16_t namelen; + static struct dom_string cdata_section_str = INIT_DOM_STRING("#cdata-section", -1); + static struct dom_string comment_str = INIT_DOM_STRING("#comment", -1); + static struct dom_string document_str = INIT_DOM_STRING("#document", -1); + static struct dom_string document_fragment_str = INIT_DOM_STRING("#document-fragment", -1); + static struct dom_string text_str = INIT_DOM_STRING("#text", -1); assert(node); switch (node->type) { case DOM_NODE_CDATA_SECTION: - set_node_name(name, namelen, "#cdata-section"); - break; + return &cdata_section_str; case DOM_NODE_COMMENT: - set_node_name(name, namelen, "#comment"); - break; + return &comment_str; case DOM_NODE_DOCUMENT: - set_node_name(name, namelen, "#document"); - break; + return &document_str; case DOM_NODE_DOCUMENT_FRAGMENT: - set_node_name(name, namelen, "#document-fragment"); - break; + return &document_fragment_str; case DOM_NODE_TEXT: - set_node_name(name, namelen, "#text"); - break; + return &text_str; case DOM_NODE_ATTRIBUTE: case DOM_NODE_DOCUMENT_TYPE: @@ -382,11 +380,8 @@ get_dom_node_name(struct dom_node *node) case DOM_NODE_NOTATION: case DOM_NODE_PROCESSING_INSTRUCTION: default: - name = node->string.string; - namelen = node->string.length; + return &node->string; } - - return memacpy(name, namelen); } static inline unsigned char * diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 8877e27fa..1c0c404a3 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -285,7 +285,7 @@ add_dom_proc_instruction(struct dom_node *parent, unsigned char *string, int len void done_dom_node(struct dom_node *node); /* Returns the name of the node in an allocated string. */ -unsigned char *get_dom_node_name(struct dom_node *node); +struct dom_string *get_dom_node_name(struct dom_node *node); /* Returns the value of the node in an allocated string. * @codepage denotes how entity strings should be decoded. */ diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 5993c5fc2..1fef16080 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -393,13 +393,10 @@ render_dom_tree(struct dom_stack *stack, struct dom_node *node, void *data) struct dom_renderer *renderer = stack->renderer; struct screen_char *template = &renderer->styles[node->type]; struct dom_string *value = &node->string; - unsigned char *name; + struct dom_string *name = get_dom_node_name(node); - assert(node && renderer); - - name = get_dom_node_name(node); - - render_dom_printf(renderer, template, "%-16s: %.*s\n", name, + render_dom_printf(renderer, template, "%.*s: %.*s\n", + name->length, name->string, value->length, value->string); mem_free_if(name); @@ -413,7 +410,8 @@ render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *da struct dom_renderer *renderer = stack->renderer; struct document *document = renderer->document; struct screen_char *template = &renderer->styles[node->type]; - unsigned char *name, *value; + unsigned char *value; + struct dom_string *name; struct dom_string *id; assert(node && document); @@ -423,12 +421,10 @@ render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *da id = get_dom_node_type_name(node->type); renderer->canvas_x += stack->depth; - if (id->length < 16) - render_dom_text(renderer, template, " ", 16 - id->length); - render_dom_printf(renderer, template, "%.*s: %s -> %s\n", - id->length, id->string, name, value); + render_dom_printf(renderer, template, "%.*s: %.*s -> %s\n", + id->length, id->string, name->length, name->string, + value); - mem_free_if(name); mem_free_if(value); return node; @@ -440,7 +436,8 @@ render_dom_tree_leaf(struct dom_stack *stack, struct dom_node *node, void *data) struct dom_renderer *renderer = stack->renderer; struct document *document = renderer->document; struct screen_char *template = &renderer->styles[node->type]; - unsigned char *name, *value; + struct dom_string *name; + unsigned char *value; assert(node && document); @@ -462,7 +459,7 @@ render_dom_tree_branch(struct dom_stack *stack, struct dom_node *node, void *dat struct dom_renderer *renderer = stack->renderer; struct document *document = renderer->document; struct screen_char *template = &renderer->styles[node->type]; - unsigned char *name; + struct dom_string *name; struct dom_string *id; assert(node && document); @@ -471,10 +468,8 @@ render_dom_tree_branch(struct dom_stack *stack, struct dom_node *node, void *dat id = get_dom_node_type_name(node->type); renderer->canvas_x += stack->depth; - if (id->length < 16) - render_dom_text(renderer, template, " ", 16 - id->length); - render_dom_printf(renderer, template, "%.*s: %s\n", - id->length, id->string, name); + render_dom_printf(renderer, template, "%.*s: %.*s\n", + id->length, id->string, name->length, name->string); mem_free_if(name); From 52f5276f926c575fbd8a6ad87524e76ff59d7256 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 20:05:01 +0100 Subject: [PATCH 12/42] get_dom_node_name(): indent switch statement --- src/document/dom/node.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index e6838d1f7..d662fc820 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -357,30 +357,30 @@ get_dom_node_name(struct dom_node *node) assert(node); switch (node->type) { - case DOM_NODE_CDATA_SECTION: - return &cdata_section_str; + case DOM_NODE_CDATA_SECTION: + return &cdata_section_str; - case DOM_NODE_COMMENT: - return &comment_str; + case DOM_NODE_COMMENT: + return &comment_str; - case DOM_NODE_DOCUMENT: - return &document_str; + case DOM_NODE_DOCUMENT: + return &document_str; - case DOM_NODE_DOCUMENT_FRAGMENT: - return &document_fragment_str; + case DOM_NODE_DOCUMENT_FRAGMENT: + return &document_fragment_str; - case DOM_NODE_TEXT: - return &text_str; + case DOM_NODE_TEXT: + return &text_str; - case DOM_NODE_ATTRIBUTE: - case DOM_NODE_DOCUMENT_TYPE: - case DOM_NODE_ELEMENT: - case DOM_NODE_ENTITY: - case DOM_NODE_ENTITY_REFERENCE: - case DOM_NODE_NOTATION: - case DOM_NODE_PROCESSING_INSTRUCTION: - default: - return &node->string; + case DOM_NODE_ATTRIBUTE: + case DOM_NODE_DOCUMENT_TYPE: + case DOM_NODE_ELEMENT: + case DOM_NODE_ENTITY: + case DOM_NODE_ENTITY_REFERENCE: + case DOM_NODE_NOTATION: + case DOM_NODE_PROCESSING_INSTRUCTION: + default: + return &node->string; } } From 0fab644bee4790126ca64a88e8e01a05412ff3b5 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 21:37:47 +0100 Subject: [PATCH 13/42] get_dom_node_value(): move non-compliant functionality to the tree renderer Entity references are supposed to have a null value and the string compression is for improving the tree view. --- src/document/dom/node.c | 52 +++---------------------- src/document/dom/node.h | 6 +-- src/document/dom/renderer.c | 75 ++++++++++++++++++++++++++++++++----- 3 files changed, 73 insertions(+), 60 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index d662fc820..fb4a5a3cb 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -384,62 +384,24 @@ get_dom_node_name(struct dom_node *node) } } -static inline unsigned char * -compress_string(unsigned char *string, unsigned int length) +struct dom_string * +get_dom_node_value(struct dom_node *node) { - struct string buffer; - unsigned char escape[2] = "\\"; - - if (!init_string(&buffer)) return NULL; - - for (; length > 0; string++, length--) { - unsigned char *bytes = string; - - if (*string == '\n' || *string == '\r' || *string == '\t') { - bytes = escape; - escape[1] = *string == '\n' ? 'n' - : (*string == '\r' ? 'r' : 't'); - } - - add_bytes_to_string(&buffer, bytes, bytes == escape ? 2 : 1); - } - - return buffer.source; -} - -unsigned char * -get_dom_node_value(struct dom_node *node, int codepage) -{ - unsigned char *value; - uint16_t valuelen; - assert(node); switch (node->type) { case DOM_NODE_ATTRIBUTE: - value = node->data.attribute.value.string; - valuelen = node->data.attribute.value.length; - break; + return &node->data.attribute.value; case DOM_NODE_PROCESSING_INSTRUCTION: - value = node->data.proc_instruction.instruction.string; - valuelen = node->data.proc_instruction.instruction.length; - break; + return &node->data.proc_instruction.instruction; case DOM_NODE_CDATA_SECTION: case DOM_NODE_COMMENT: case DOM_NODE_TEXT: - value = node->string.string; - valuelen = node->string.length; - break; + return &node->string; case DOM_NODE_ENTITY_REFERENCE: - value = get_entity_string(node->string.string, - node->string.length, - codepage); - valuelen = value ? strlen(value) : 0; - break; - case DOM_NODE_NOTATION: case DOM_NODE_DOCUMENT: case DOM_NODE_DOCUMENT_FRAGMENT: @@ -449,10 +411,6 @@ get_dom_node_value(struct dom_node *node, int codepage) default: return NULL; } - - if (!value) value = ""; - - return compress_string(value, valuelen); } struct dom_string * diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 1c0c404a3..56df9e3dc 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -287,9 +287,9 @@ void done_dom_node(struct dom_node *node); /* Returns the name of the node in an allocated string. */ struct dom_string *get_dom_node_name(struct dom_node *node); -/* Returns the value of the node in an allocated string. - * @codepage denotes how entity strings should be decoded. */ -unsigned char *get_dom_node_value(struct dom_node *node, int codepage); +/* Returns the value of the node or NULL if no value is defined for the node + * type. */ +struct dom_string *get_dom_node_value(struct dom_node *node); /* Returns the name used for identifying the node type. */ struct dom_string *get_dom_node_type_name(enum dom_node_type type); diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 1fef16080..3a8aadcc5 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -387,6 +387,58 @@ add_dom_link(struct dom_renderer *renderer, unsigned char *string, int length) /* DOM Tree Renderer */ #ifdef DOM_TREE_RENDERER +static inline unsigned char * +compress_string(unsigned char *string, unsigned int length) +{ + struct string buffer; + unsigned char escape[2] = "\\"; + + if (!init_string(&buffer)) return NULL; + + for (; length > 0; string++, length--) { + unsigned char *bytes = string; + + if (*string == '\n' || *string == '\r' || *string == '\t') { + bytes = escape; + escape[1] = *string == '\n' ? 'n' + : (*string == '\r' ? 'r' : 't'); + } + + add_bytes_to_string(&buffer, bytes, bytes == escape ? 2 : 1); + } + + return buffer.source; +} + +/* @codepage denotes how entity strings should be decoded. */ +static void +set_enhanced_dom_node_value(struct dom_string *string, struct dom_node *node, + int codepage) +{ + struct dom_string *value; + + assert(node); + + switch (node->type) { + case DOM_NODE_ENTITY_REFERENCE: + string->string = get_entity_string(node->string.string, + node->string.length, + codepage); + break; + + default: + value = get_dom_node_value(node); + if (!value) { + set_dom_string(string, NULL, 0); + return; + } + + string->string = compress_string(value->string, value->length); + } + + string->length = string->string ? strlen(string->string) : 0; +} + static struct dom_node * render_dom_tree(struct dom_stack *stack, struct dom_node *node, void *data) { @@ -410,22 +462,23 @@ render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *da struct dom_renderer *renderer = stack->renderer; struct document *document = renderer->document; struct screen_char *template = &renderer->styles[node->type]; - unsigned char *value; + struct dom_string value; struct dom_string *name; struct dom_string *id; assert(node && document); name = get_dom_node_name(node); - value = get_dom_node_value(node, document->options.cp); id = get_dom_node_type_name(node->type); + set_enhanced_dom_node_value(&value, node, document->options.cp); renderer->canvas_x += stack->depth; - render_dom_printf(renderer, template, "%.*s: %.*s -> %s\n", + render_dom_printf(renderer, template, "%.*s: %.*s -> %.*s\n", id->length, id->string, name->length, name->string, - value); + value.length, value.string); - mem_free_if(value); + if (is_dom_string_set(&value)) + done_dom_string(&value); return node; } @@ -437,18 +490,20 @@ render_dom_tree_leaf(struct dom_stack *stack, struct dom_node *node, void *data) struct document *document = renderer->document; struct screen_char *template = &renderer->styles[node->type]; struct dom_string *name; - unsigned char *value; + struct dom_string value; assert(node && document); name = get_dom_node_name(node); - value = get_dom_node_value(node, document->options.cp); + set_enhanced_dom_node_value(&value, node, document->options.cp); renderer->canvas_x += stack->depth; - render_dom_printf(renderer, template, "%-16s: %s\n", name, value); + render_dom_printf(renderer, template, "%.*s: %.*s\n", + name->length, name->string, + value.length, value.string); - mem_free_if(name); - mem_free_if(value); + if (is_dom_string_set(&value)) + done_dom_string(&value); return node; } From 87aad88c96e582874a896270297d52c02ca39ab7 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 21:42:49 +0100 Subject: [PATCH 14/42] Use dom_string throughout the DOM stack interface --- src/document/dom/stack.c | 4 ++-- src/document/dom/stack.h | 8 ++++---- src/document/sgml/parser.c | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/document/dom/stack.c b/src/document/dom/stack.c index e760a88f4..e61fe954c 100644 --- a/src/document/dom/stack.c +++ b/src/document/dom/stack.c @@ -177,13 +177,13 @@ pop_dom_node(struct dom_stack *stack) void pop_dom_nodes(struct dom_stack *stack, enum dom_node_type type, - unsigned char *string, uint16_t length) + struct dom_string *string) { struct dom_stack_state *state; if (!dom_stack_has_parents(stack)) return; - state = search_dom_stack(stack, type, string, length); + state = search_dom_stack(stack, type, string); if (state) pop_dom_state(stack, type, state); } diff --git a/src/document/dom/stack.h b/src/document/dom/stack.h index 87494b0ea..831237d86 100644 --- a/src/document/dom/stack.h +++ b/src/document/dom/stack.h @@ -86,7 +86,7 @@ get_dom_stack_state(struct dom_stack *stack, int top_offset) /* Dive through the stack states in search for the specified match. */ static inline struct dom_stack_state * search_dom_stack(struct dom_stack *stack, enum dom_node_type type, - unsigned char *string, uint16_t length) + struct dom_string *string) { struct dom_stack_state *state; int pos; @@ -96,8 +96,8 @@ search_dom_stack(struct dom_stack *stack, enum dom_node_type type, struct dom_node *parent = state->node; if (parent->type == type - && parent->string.length == length - && !strncasecmp(parent->string.string, string, length)) + && parent->string.length == string->length + && !strncasecmp(parent->string.string, string->string, string->length)) return state; } @@ -125,7 +125,7 @@ void pop_dom_node(struct dom_stack *stack); /* Ascends the stack looking for specific parent */ void pop_dom_nodes(struct dom_stack *stack, enum dom_node_type type, - unsigned char *string, uint16_t length); + struct dom_string *string); /* Pop all stack states until a specific state is reached. */ void diff --git a/src/document/sgml/parser.c b/src/document/sgml/parser.c index f28ccfa79..ef026078e 100644 --- a/src/document/sgml/parser.c +++ b/src/document/sgml/parser.c @@ -243,10 +243,12 @@ parse_sgml_document(struct dom_stack *stack, struct scanner *scanner) if (!token->length) { pop_dom_node(stack); } else { + struct dom_string string; struct dom_stack_state *state; + set_dom_string(&string, token->string, token->length); state = search_dom_stack(stack, DOM_NODE_ELEMENT, - token->string, token->length); + &string); if (state) { struct sgml_parser_state *pstate; From 86c9a3781089d191ac835f28f335ff220961ed1d Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 21:49:33 +0100 Subject: [PATCH 15/42] Factor out dom_string_casecmp() --- src/document/dom/node.c | 9 +-------- src/document/dom/string.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index fb4a5a3cb..fa0d0005e 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -154,15 +154,8 @@ dom_node_cmp(struct dom_node_search *search, struct dom_node *node) break; } } - { - int length = int_min(key->string.length, node->string.length); - int string_diff = strncasecmp(key->string.string, node->string.string, length); - /* If the lengths or strings don't match strncasecmp() does the - * job else return which ever is bigger. */ - - return string_diff ? string_diff : key->string.length - node->string.length; - } + return dom_string_casecmp(&key->string, &node->string); } static inline int diff --git a/src/document/dom/string.h b/src/document/dom/string.h index cc46faa18..d1d7d3b30 100644 --- a/src/document/dom/string.h +++ b/src/document/dom/string.h @@ -16,6 +16,17 @@ set_dom_string(struct dom_string *string, unsigned char *value, uint16_t length) string->length = length; } +static inline int +dom_string_casecmp(struct dom_string *string1, struct dom_string *string2) +{ + size_t length = int_min(string1->length, string2->length); + size_t string_diff = strncasecmp(string1->string, string2->string, length); + + /* If the lengths or strings don't match strncasecmp() does the + * job else return which ever is bigger. */ + return string_diff ? string_diff : string1->length - string2->length; +} + #define is_dom_string_set(str) ((str)->string && (str)->length) #define done_dom_string(str) mem_free((str)->string); From cdc749def30935b771b5a793e7d1424b3f3b88eb Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 21:50:40 +0100 Subject: [PATCH 16/42] get_dom_node_value(): indent switch --- src/document/dom/node.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index fa0d0005e..30e5f3206 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -383,26 +383,26 @@ get_dom_node_value(struct dom_node *node) assert(node); switch (node->type) { - case DOM_NODE_ATTRIBUTE: - return &node->data.attribute.value; + case DOM_NODE_ATTRIBUTE: + return &node->data.attribute.value; - case DOM_NODE_PROCESSING_INSTRUCTION: - return &node->data.proc_instruction.instruction; + case DOM_NODE_PROCESSING_INSTRUCTION: + return &node->data.proc_instruction.instruction; - case DOM_NODE_CDATA_SECTION: - case DOM_NODE_COMMENT: - case DOM_NODE_TEXT: - return &node->string; + case DOM_NODE_CDATA_SECTION: + case DOM_NODE_COMMENT: + case DOM_NODE_TEXT: + return &node->string; - case DOM_NODE_ENTITY_REFERENCE: - case DOM_NODE_NOTATION: - case DOM_NODE_DOCUMENT: - case DOM_NODE_DOCUMENT_FRAGMENT: - case DOM_NODE_DOCUMENT_TYPE: - case DOM_NODE_ELEMENT: - case DOM_NODE_ENTITY: - default: - return NULL; + case DOM_NODE_ENTITY_REFERENCE: + case DOM_NODE_NOTATION: + case DOM_NODE_DOCUMENT: + case DOM_NODE_DOCUMENT_FRAGMENT: + case DOM_NODE_DOCUMENT_TYPE: + case DOM_NODE_ELEMENT: + case DOM_NODE_ENTITY: + default: + return NULL; } } From c1136b879124e451d2f38a18a97042250b730c44 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 21:58:59 +0100 Subject: [PATCH 17/42] Use dom_string for storing sgml_node_info data Reduces code redundancy for node searching. Oh, comment the purpose of the special SGML_NODE_HEAD() macro. --- src/document/sgml/sgml.c | 8 +------- src/document/sgml/sgml.h | 14 ++++++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/document/sgml/sgml.c b/src/document/sgml/sgml.c index 91fa9ff3e..4bebc213e 100644 --- a/src/document/sgml/sgml.c +++ b/src/document/sgml/sgml.c @@ -20,12 +20,6 @@ sgml_info_strcmp(const void *key_, const void *node_) { struct dom_node *key = (struct dom_node *) key_; struct sgml_node_info *node = (struct sgml_node_info *) node_; - int length = int_min(key->string.length, node->length); - int string_diff = strncasecmp(key->string.string, node->string, length); - int length_diff = key->string.length - node->length; - /* If the lengths or strings don't match strncasecmp() does the job - * else return which ever is bigger. */ - - return (!length_diff || string_diff) ? string_diff : length_diff; + return dom_string_casecmp(&key->string, &node->string); } diff --git a/src/document/sgml/sgml.h b/src/document/sgml/sgml.h index a2b5ccba0..4d36e71b9 100644 --- a/src/document/sgml/sgml.h +++ b/src/document/sgml/sgml.h @@ -5,6 +5,7 @@ #include #include "document/dom/stack.h" +#include "document/dom/string.h" /* The flags stored in the attribute sgml node info data */ /* TODO: Other potential flags (there can be only 16) @@ -43,20 +44,21 @@ enum sgml_element_flags { }; struct sgml_node_info { - unsigned char *string; - int length; + struct dom_string string; uint16_t type; uint16_t flags; }; +/* The header node is special. It is used for storing the number of nodes and + * for returning the default 'unknown' node. */ #define SGML_NODE_HEAD(doctype, nodetype) \ - { NULL, doctype##_##nodetype##S - 1, doctype##_##nodetype##_UNKNOWN } + { INIT_DOM_STRING(NULL, doctype##_##nodetype##S - 1), doctype##_##nodetype##_UNKNOWN } #define SGML_NODE_INFO(doctype, nodetype, name, data) \ - { #name, sizeof(#name) - 1, doctype##_##nodetype##_##name, data } + { INIT_DOM_STRING(#name, sizeof(#name) - 1), doctype##_##nodetype##_##name, data } #define SGML_NODE_INF2(doctype, nodetype, name, ident, data) \ - { ident, sizeof(ident) - 1, doctype##_##nodetype##_##name, data } + { INIT_DOM_STRING(ident, sizeof(ident) - 1), doctype##_##nodetype##_##name, data } #define SGML_NODE_INFO_TYPE(doctype, nodetype, name) doctype##_##nodetype##_##name @@ -66,7 +68,7 @@ static inline struct sgml_node_info * get_sgml_node_info(struct sgml_node_info list[], struct dom_node *node) { struct sgml_node_info *map = &list[1]; - size_t map_size = list->length; + size_t map_size = list->string.length; size_t obj_size = sizeof(struct sgml_node_info); void *match = bsearch(node, map, map_size, obj_size, sgml_info_strcmp); From 458fc5ee7972434b397b151d10285192a0973793 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 10 Dec 2005 22:24:30 +0100 Subject: [PATCH 18/42] Review and change dom_string specific uint16_t value to size_t --- src/document/dom/node.c | 2 +- src/document/dom/node.h | 6 +++--- src/document/sgml/parser.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 30e5f3206..142d08e3c 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -217,7 +217,7 @@ get_dom_node_map_entry(struct dom_node_list *list, enum dom_node_type type, struct dom_node * init_dom_node_(unsigned char *file, int line, struct dom_node *parent, enum dom_node_type type, - unsigned char *string, uint16_t length) + unsigned char *string, size_t length) { #ifdef DEBUG_MEMLEAK struct dom_node *node = debug_mem_calloc(file, line, 1, sizeof(*node)); diff --git a/src/document/dom/node.h b/src/document/dom/node.h index 56df9e3dc..e1057195d 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -248,7 +248,7 @@ get_dom_node_map_entry(struct dom_node_list *node_map, struct dom_node * init_dom_node_(unsigned char *file, int line, struct dom_node *parent, enum dom_node_type type, - unsigned char *string, uint16_t length); + unsigned char *string, size_t length); #define init_dom_node(type, string, length) init_dom_node_(__FILE__, __LINE__, NULL, type, string, length) #define add_dom_node(parent, type, string, length) init_dom_node_(__FILE__, __LINE__, parent, type, string, length) @@ -257,7 +257,7 @@ init_dom_node_(unsigned char *file, int line, static inline struct dom_node * add_dom_attribute(struct dom_node *parent, unsigned char *string, int length, - unsigned char *value, uint16_t valuelen) + unsigned char *value, size_t valuelen) { struct dom_node *node = add_dom_node(parent, DOM_NODE_ATTRIBUTE, string, length); @@ -270,7 +270,7 @@ add_dom_attribute(struct dom_node *parent, unsigned char *string, int length, static inline struct dom_node * add_dom_proc_instruction(struct dom_node *parent, unsigned char *string, int length, - unsigned char *instruction, uint16_t instructionlen) + unsigned char *instruction, size_t instructionlen) { struct dom_node *node = add_dom_node(parent, DOM_NODE_PROCESSING_INSTRUCTION, string, length); diff --git a/src/document/sgml/parser.c b/src/document/sgml/parser.c index ef026078e..c654a7653 100644 --- a/src/document/sgml/parser.c +++ b/src/document/sgml/parser.c @@ -28,7 +28,7 @@ static inline struct dom_node * add_sgml_document(struct dom_stack *stack, struct uri *uri) { unsigned char *string = struri(uri); - int length = strlen(string); + size_t length = strlen(string); struct dom_node *node = init_dom_node(DOM_NODE_DOCUMENT, string, length); return node ? push_dom_node(stack, node) : node; @@ -70,7 +70,7 @@ add_sgml_attribute(struct dom_stack *stack, struct sgml_parser *parser = stack->parser; struct dom_node *parent = get_dom_stack_top(stack)->node; unsigned char *value = valtoken ? valtoken->string : NULL; - uint16_t valuelen = valtoken ? valtoken->length : 0; + size_t valuelen = valtoken ? valtoken->length : 0; struct sgml_node_info *info; struct dom_node *node; @@ -102,11 +102,11 @@ add_sgml_proc_instruction(struct dom_stack *stack, struct scanner_token *token) /* Anything before the separator becomes the target name ... */ unsigned char *name = token->string; - int namelen = separator ? separator - token->string : token->length; + size_t namelen = separator ? separator - token->string : token->length; /* ... and everything after the instruction value. */ unsigned char *value = separator ? separator + 1 : NULL; - int valuelen = value ? token->length - namelen - 1 : 0; + size_t valuelen = value ? token->length - namelen - 1 : 0; node = add_dom_proc_instruction(parent, name, namelen, value, valuelen); if (!node) return NULL; From ac5441db9e80c846ff346ff7defc063ebcc0601a Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Mon, 12 Dec 2005 17:00:08 +0100 Subject: [PATCH 19/42] Prevent successive calls to time(), since it doesn't have much impact. --- src/cookies/cookies.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cookies/cookies.c b/src/cookies/cookies.c index 74f732e54..b96e82c97 100644 --- a/src/cookies/cookies.c +++ b/src/cookies/cookies.c @@ -602,9 +602,6 @@ is_path_prefix(unsigned char *d, unsigned char *s) } -#define is_expired(t) ((t) && (t) <= time(NULL)) -#define is_dead(t) (!(t) || (t) <= time(NULL)) - struct string * send_cookies(struct uri *uri) { @@ -612,6 +609,7 @@ send_cookies(struct uri *uri) struct cookie *c, *next; unsigned char *path = NULL; static struct string header; + time_t now; if (!uri->host || !uri->data) return NULL; @@ -626,12 +624,13 @@ send_cookies(struct uri *uri) init_string(&header); + now = time(NULL); foreachsafe (c, next, cookies) { if (!is_in_domain(c->domain, uri->host, uri->hostlen) || !is_path_prefix(c->path, path)) continue; - if (is_expired(c->expires)) { + if (c->expires && c->expires <= now) { #ifdef DEBUG_COOKIES DBG("Cookie %s=%s (exp %d) expired.", c->name, c->value, c->expires); @@ -681,6 +680,7 @@ load_cookies(void) { unsigned char in_buffer[6 * MAX_STR_LEN]; unsigned char *cookfile = COOKIES_FILENAME; FILE *fp; + time_t now; if (elinks_home) { cookfile = straconcat(elinks_home, cookfile, NULL); @@ -701,6 +701,7 @@ load_cookies(void) { * periodically to our death. */ cookies_nosave = 1; + now = time(NULL); while (fgets(in_buffer, 6 * MAX_STR_LEN, fp)) { struct cookie *cookie; unsigned char *p, *q = in_buffer; @@ -728,7 +729,7 @@ load_cookies(void) { /* Skip expired cookies if any. */ expires = str_to_time_t(members[EXPIRES].pos); - if (is_dead(expires)) { + if (!expires || expires <= now) { cookies_dirty = 1; continue; } @@ -765,6 +766,7 @@ save_cookies(void) { struct cookie *c; unsigned char *cookfile; struct secure_save_info *ssi; + time_t now; if (cookies_nosave || !elinks_home || !cookies_dirty || get_cmd_opt_bool("anonymous")) @@ -777,8 +779,9 @@ save_cookies(void) { mem_free(cookfile); if (!ssi) return; + now = time(NULL); foreach (c, cookies) { - if (is_dead(c->expires)) continue; + if (!c->expires || c->expires <= now) continue; if (secure_fprintf(ssi, "%s\t%s\t%s\t%s\t%s\t%ld\t%d\n", c->name, c->value, c->server->host, From 59c8dcc4739ba46510a0e4141d35cf4302eab6c3 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Mon, 12 Dec 2005 17:05:43 +0100 Subject: [PATCH 20/42] get_current_link_info(): simplify code flow. --- src/viewer/text/link.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 2321b49a4..9954cbe27 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -1269,11 +1269,7 @@ get_current_link_info(struct session *ses, struct document_view *doc_view) /* TODO: Provide info about script event hooks too. --pasky */ - if (link_is_form(link)) { - if (!get_link_form_control(link)) return NULL; - - return get_form_info(ses, doc_view); - } else { + if (!link_is_form(link)) { struct terminal *term = ses->tab->term; struct string str; unsigned char *uristring = link->where; @@ -1302,4 +1298,8 @@ get_current_link_info(struct session *ses, struct document_view *doc_view) decode_uri_string_for_display(&str); return str.source; } + + if (!get_link_form_control(link)) return NULL; + + return get_form_info(ses, doc_view); } From c769b81f93869cb0dd9b588af9c6eb7cdb1b7a0c Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Mon, 12 Dec 2005 17:11:28 +0100 Subject: [PATCH 21/42] send_event(): initialize @doc_view only when needed, and prevent a useless test for mouse event when event is of keyboard type. --- src/viewer/text/view.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c index a32c3eab4..ca7c8d505 100644 --- a/src/viewer/text/view.c +++ b/src/viewer/text/view.c @@ -1185,22 +1185,23 @@ quit: void send_event(struct session *ses, struct term_event *ev) { - struct document_view *doc_view; - assert(ses && ev); if_assert_failed return; - doc_view = current_frame(ses); if (ev->ev == EVENT_KBD) { + struct document_view *doc_view = current_frame(ses); + ses = send_kbd_event(ses, doc_view, ev); } #ifdef CONFIG_MOUSE - if (ev->ev == EVENT_MOUSE) { + else if (ev->ev == EVENT_MOUSE) { + struct document_view *doc_view = current_frame(ses); + ses = send_mouse_event(ses, doc_view, ev); } #endif /* CONFIG_MOUSE */ - /* ses may disappear ie. in close_tab() */ + /* @ses may disappear ie. in close_tab() */ if (ses) ses->kbdprefix.repeat_count = 0; } From 27116d6385991112b9f5442aa8f0c5fbfe74a439 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 12 Dec 2005 17:41:09 +0100 Subject: [PATCH 22/42] Make the DOM stack and the SGML parser interface more general They now both hold a single private data member. This means the parser now holds the renderer data. --- src/document/dom/renderer.c | 15 ++++++++++----- src/document/dom/stack.c | 5 ++--- src/document/dom/stack.h | 5 ++--- src/document/sgml/parser.c | 9 +++++---- src/document/sgml/parser.h | 3 ++- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index 3a8aadcc5..361faac95 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -597,7 +597,8 @@ render_dom_node_text(struct dom_renderer *renderer, struct screen_char *template static struct dom_node * render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *data) { - struct dom_renderer *renderer = stack->renderer; + struct sgml_parser *parser = stack->data; + struct dom_renderer *renderer = parser->data; assert(node && renderer && renderer->document); @@ -611,7 +612,8 @@ render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *dat static struct dom_node * render_dom_proc_instr_source(struct dom_stack *stack, struct dom_node *node, void *data) { - struct dom_renderer *renderer = stack->renderer; + struct sgml_parser *parser = stack->data; + struct dom_renderer *renderer = parser->data; unsigned char *value; int valuelen; @@ -638,7 +640,8 @@ render_dom_proc_instr_source(struct dom_stack *stack, struct dom_node *node, voi static struct dom_node * render_dom_element_source(struct dom_stack *stack, struct dom_node *node, void *data) { - struct dom_renderer *renderer = stack->renderer; + struct sgml_parser *parser = stack->data; + struct dom_renderer *renderer = parser->data; assert(node && renderer && renderer->document); @@ -650,7 +653,8 @@ render_dom_element_source(struct dom_stack *stack, struct dom_node *node, void * static struct dom_node * render_dom_element_end_source(struct dom_stack *stack, struct dom_node *node, void *data) { - struct dom_renderer *renderer = stack->renderer; + struct sgml_parser *parser = stack->data; + struct dom_renderer *renderer = parser->data; struct sgml_parser_state *pstate = data; struct scanner_token *token = &pstate->end_token; unsigned char *string = token->string; @@ -675,7 +679,8 @@ render_dom_element_end_source(struct dom_stack *stack, struct dom_node *node, vo static struct dom_node * render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void *data) { - struct dom_renderer *renderer = stack->renderer; + struct sgml_parser *parser = stack->data; + struct dom_renderer *renderer = parser->data; struct screen_char *template = &renderer->styles[node->type]; assert(node && renderer->document); diff --git a/src/document/dom/stack.c b/src/document/dom/stack.c index e61fe954c..a5692a879 100644 --- a/src/document/dom/stack.c +++ b/src/document/dom/stack.c @@ -45,7 +45,7 @@ realloc_dom_stack_state_objects(struct dom_stack *stack) } void -init_dom_stack(struct dom_stack *stack, void *parser, void *renderer, +init_dom_stack(struct dom_stack *stack, void *data, dom_stack_callback_T push_callbacks[DOM_NODES], dom_stack_callback_T pop_callbacks[DOM_NODES], size_t object_size, int keep_nodes) @@ -54,8 +54,7 @@ init_dom_stack(struct dom_stack *stack, void *parser, void *renderer, memset(stack, 0, sizeof(*stack)); - stack->parser = parser; - stack->renderer = renderer; + stack->data = data; stack->object_size = object_size; stack->keep_nodes = !!keep_nodes; diff --git a/src/document/dom/stack.h b/src/document/dom/stack.h index 831237d86..e1383cd6f 100644 --- a/src/document/dom/stack.h +++ b/src/document/dom/stack.h @@ -52,8 +52,7 @@ struct dom_stack { dom_stack_callback_T pop_callbacks[DOM_NODES]; /* Data specific to the parser and renderer. */ - void *renderer; - void *parser; + void *data; }; #define dom_stack_has_parents(nav) \ @@ -110,7 +109,7 @@ search_dom_stack(struct dom_stack *stack, enum dom_node_type type, /* The @object_size arg tells whether the stack should allocate objects for each * state to be assigned to the state's @data member. Zero means no state data should * be allocated. */ -void init_dom_stack(struct dom_stack *stack, void *parser, void *renderer, +void init_dom_stack(struct dom_stack *stack, void *data, dom_stack_callback_T push_callbacks[DOM_NODES], dom_stack_callback_T pop_callbacks[DOM_NODES], size_t object_size, int keep_nodes); diff --git a/src/document/sgml/parser.c b/src/document/sgml/parser.c index c654a7653..50590553d 100644 --- a/src/document/sgml/parser.c +++ b/src/document/sgml/parser.c @@ -37,7 +37,7 @@ add_sgml_document(struct dom_stack *stack, struct uri *uri) static inline struct dom_node * add_sgml_element(struct dom_stack *stack, struct scanner_token *token) { - struct sgml_parser *parser = stack->parser; + struct sgml_parser *parser = stack->data; struct dom_node *parent = get_dom_stack_top(stack)->node; struct dom_stack_state *state; struct sgml_parser_state *pstate; @@ -67,7 +67,7 @@ static inline void add_sgml_attribute(struct dom_stack *stack, struct scanner_token *token, struct scanner_token *valtoken) { - struct sgml_parser *parser = stack->parser; + struct sgml_parser *parser = stack->data; struct dom_node *parent = get_dom_stack_top(stack)->node; unsigned char *value = valtoken ? valtoken->string : NULL; size_t valuelen = valtoken ? valtoken->length : 0; @@ -305,7 +305,7 @@ parse_sgml_document(struct dom_stack *stack, struct scanner *scanner) struct sgml_parser * -init_sgml_parser(enum sgml_parser_type type, void *renderer, struct uri *uri, +init_sgml_parser(enum sgml_parser_type type, void *data, struct uri *uri, dom_stack_callback_T push_callbacks[DOM_NODES], dom_stack_callback_T pop_callbacks[DOM_NODES]) { @@ -318,8 +318,9 @@ init_sgml_parser(enum sgml_parser_type type, void *renderer, struct uri *uri, parser->type = type; parser->uri = get_uri_reference(uri); parser->info = &sgml_html_info; + parser->data = data; - init_dom_stack(&parser->stack, parser, renderer, + init_dom_stack(&parser->stack, parser, push_callbacks, pop_callbacks, obj_size, type != SGML_PARSER_STREAM); diff --git a/src/document/sgml/parser.h b/src/document/sgml/parser.h index 6021f1c21..6447351fd 100644 --- a/src/document/sgml/parser.h +++ b/src/document/sgml/parser.h @@ -29,6 +29,7 @@ struct sgml_parser { struct uri *uri; struct dom_node *root; + void *data; struct scanner scanner; struct dom_stack stack; @@ -42,7 +43,7 @@ struct sgml_parser_state { }; struct sgml_parser * -init_sgml_parser(enum sgml_parser_type type, void *renderer, struct uri *uri, +init_sgml_parser(enum sgml_parser_type type, void *data, struct uri *uri, dom_stack_callback_T push_callbacks[DOM_NODES], dom_stack_callback_T pop_callbacks[DOM_NODES]); From 5ff0849eb38a13b543e988c7b6058cd487ea494e Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 12 Dec 2005 17:42:26 +0100 Subject: [PATCH 23/42] set_dom_string(): take length as size_t; -1 means use strlen() to get size --- src/document/dom/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/document/dom/string.h b/src/document/dom/string.h index d1d7d3b30..f107c9a18 100644 --- a/src/document/dom/string.h +++ b/src/document/dom/string.h @@ -10,10 +10,10 @@ struct dom_string { { (strlength) == -1 ? sizeof(strvalue) - 1 : (strlength), (strvalue) } static inline void -set_dom_string(struct dom_string *string, unsigned char *value, uint16_t length) +set_dom_string(struct dom_string *string, unsigned char *value, size_t length) { string->string = value; - string->length = length; + string->length = length == -1 ? strlen(value) : length; } static inline int From 73e3cdecd0fdcd7c4bd7f447e1caaa00fb9fa39d Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Mon, 12 Dec 2005 22:58:05 +0000 Subject: [PATCH 24/42] Factor activate_link out of enter, which now just acquires the link reference, calls activate_link, and triggers the onClick event. --- src/viewer/text/link.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 9954cbe27..1dca49dde 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -888,24 +888,15 @@ goto_current_link(struct session *ses, struct document_view *doc_view, int do_re return link; } -enum frame_event_status -enter(struct session *ses, struct document_view *doc_view, int do_reload) +static enum frame_event_status +activate_link(struct session *ses, struct document_view *doc_view, + struct link *link, int do_reload) { struct form_control *link_fc; - struct link *link; - - assert(ses && doc_view && doc_view->vs && doc_view->document); - if_assert_failed return FRAME_EVENT_REFRESH; - - link = get_current_link(doc_view); - if (!link) return FRAME_EVENT_REFRESH; if (!link_is_form(link) || link_is_textinput(link) || link->type == LINK_BUTTON) { - if (!current_link_evhook(doc_view, SEVHOOK_ONCLICK)) - return FRAME_EVENT_REFRESH; - if (goto_current_link(ses, doc_view, do_reload)) return FRAME_EVENT_OK; @@ -959,12 +950,29 @@ enter(struct session *ses, struct document_view *doc_view, int do_reload) INTERNAL("bad link type %d", link->type); } - if (!current_link_evhook(doc_view, SEVHOOK_ONCLICK)) - return FRAME_EVENT_REFRESH; - return FRAME_EVENT_REFRESH; } +enum frame_event_status +enter(struct session *ses, struct document_view *doc_view, int do_reload) +{ + enum frame_event_status ret; + struct link *link; + + assert(ses && doc_view && doc_view->vs && doc_view->document); + if_assert_failed return FRAME_EVENT_REFRESH; + + link = get_current_link(doc_view); + if (!link) return FRAME_EVENT_REFRESH; + + ret = activate_link(ses, doc_view, link, do_reload); + if (ret != FRAME_EVENT_IGNORED) + if (!current_link_evhook(doc_view, SEVHOOK_ONCLICK)) + return FRAME_EVENT_REFRESH; + + return ret; +} + struct link * get_link_at_coordinates(struct document_view *doc_view, int x, int y) { From b1912478948172f7f2dba995d6e54b6db66fde61 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Mon, 12 Dec 2005 23:57:37 +0000 Subject: [PATCH 25/42] Reflow some code to reduce indentation in activate_link. --- src/viewer/text/link.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index 1dca49dde..ee682b27b 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -910,6 +910,7 @@ activate_link(struct session *ses, struct document_view *doc_view, if (link->type == LINK_CHECKBOX) { struct form_state *fs; + struct form *form; fs = find_form_state(doc_view, link_fc); if (!fs) return FRAME_EVENT_OK; @@ -917,27 +918,26 @@ activate_link(struct session *ses, struct document_view *doc_view, if (link_fc->type == FC_CHECKBOX) { fs->state = !fs->state; - } else { - struct form *form; + return FRAME_EVENT_REFRESH; + } - foreach (form, doc_view->document->forms) { - struct form_control *fc; + foreach (form, doc_view->document->forms) { + struct form_control *fc; - if (form != link_fc->form) - continue; + if (form != link_fc->form) + continue; - foreach (fc, form->items) { - if (fc->type == FC_RADIO - && !xstrcmp(fc->name, link_fc->name)) { - struct form_state *frm_st; + foreach (fc, form->items) { + if (fc->type == FC_RADIO + && !xstrcmp(fc->name, link_fc->name)) { + struct form_state *frm_st; - frm_st = find_form_state(doc_view, fc); - if (frm_st) frm_st->state = 0; - } + frm_st = find_form_state(doc_view, fc); + if (frm_st) frm_st->state = 0; } } - fs->state = 1; } + fs->state = 1; } else if (link->type == LINK_SELECT) { object_lock(doc_view->document); From db5b9be213245067209d18323a224b1990b49d72 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Tue, 13 Dec 2005 00:00:08 +0000 Subject: [PATCH 26/42] Convert the body of activate_link to a single switch statement. --- src/viewer/text/link.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/viewer/text/link.c b/src/viewer/text/link.c index ee682b27b..8a819304b 100644 --- a/src/viewer/text/link.c +++ b/src/viewer/text/link.c @@ -893,24 +893,25 @@ activate_link(struct session *ses, struct document_view *doc_view, struct link *link, int do_reload) { struct form_control *link_fc; + struct form_state *fs; + struct form *form; - if (!link_is_form(link) - || link_is_textinput(link) - || link->type == LINK_BUTTON) { + switch (link->type) { + case LINK_HYPERTEXT: + case LINK_MAP: + case LINK_FIELD: + case LINK_AREA: + case LINK_BUTTON: if (goto_current_link(ses, doc_view, do_reload)) return FRAME_EVENT_OK; - return FRAME_EVENT_REFRESH; - } + break; - link_fc = get_link_form_control(link); + case LINK_CHECKBOX: + link_fc = get_link_form_control(link); - if (form_field_is_readonly(link_fc)) - return FRAME_EVENT_OK; - - if (link->type == LINK_CHECKBOX) { - struct form_state *fs; - struct form *form; + if (form_field_is_readonly(link_fc)) + return FRAME_EVENT_OK; fs = find_form_state(doc_view, link_fc); if (!fs) return FRAME_EVENT_OK; @@ -939,14 +940,23 @@ activate_link(struct session *ses, struct document_view *doc_view, } fs->state = 1; - } else if (link->type == LINK_SELECT) { + break; + + case LINK_SELECT: + link_fc = get_link_form_control(link); + + if (form_field_is_readonly(link_fc)) + return FRAME_EVENT_OK; + object_lock(doc_view->document); add_empty_window(ses->tab->term, (void (*)(void *)) release_document, doc_view->document); do_select_submenu(ses->tab->term, link_fc->menu, ses); - } else { + break; + + default: INTERNAL("bad link type %d", link->type); } From 771a2eea821b8c872bcaaa4c9921bbdda91978d2 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 04:50:30 +0100 Subject: [PATCH 27/42] Prepare the CSS scanner for parsing [foo{|,*,^,$,}=bar] selectors --- src/document/css/scanner.c | 32 +++++++++++++++++++++++++++++--- src/document/css/scanner.h | 7 ++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/document/css/scanner.c b/src/document/css/scanner.c index 05aff4204..eb80e1748 100644 --- a/src/document/css/scanner.c +++ b/src/document/css/scanner.c @@ -43,12 +43,12 @@ static const struct scan_table_info css_scan_table_info[] = { SCAN_TABLE_STRING(" \f\n\r\t\v\000", CSS_CHAR_WHITESPACE), SCAN_TABLE_STRING("\f\n\r", CSS_CHAR_NEWLINE), SCAN_TABLE_STRING("-", CSS_CHAR_IDENT), - SCAN_TABLE_STRING(".#@!\"'<-/", CSS_CHAR_TOKEN_START), + SCAN_TABLE_STRING(".#@!\"'<-/|^$*", CSS_CHAR_TOKEN_START), /* Unicode escape (that we do not handle yet) + other special chars */ - SCAN_TABLE_STRING("\\_*", CSS_CHAR_IDENT | CSS_CHAR_IDENT_START), + SCAN_TABLE_STRING("\\_", CSS_CHAR_IDENT | CSS_CHAR_IDENT_START), /* This should contain mostly used char tokens like ':' and maybe a few * garbage chars that people might put in their CSS code */ - SCAN_TABLE_STRING("({});:,.>", CSS_CHAR_TOKEN), + SCAN_TABLE_STRING("[({})];:,.>", CSS_CHAR_TOKEN), SCAN_TABLE_STRING("", CSS_CHAR_SGML_MARKUP), SCAN_TABLE_END, @@ -259,6 +259,32 @@ scan_css_token(struct scanner *scanner, struct scanner_token *token) CSS_TOKEN_AT_KEYWORD); } + } else if (first_char == '*') { + if (*string == '=') { + type = CSS_TOKEN_SELECT_CONTAINS; + string++; + } else { + type = CSS_TOKEN_IDENT; + } + + } else if (first_char == '^') { + if (*string == '=') { + type = CSS_TOKEN_SELECT_BEGIN; + string++; + } + + } else if (first_char == '$') { + if (*string == '=') { + type = CSS_TOKEN_SELECT_END; + string++; + } + + } else if (first_char == '|') { + if (*string == '=') { + type = CSS_TOKEN_SELECT_HYPHEN_LIST; + string++; + } + } else if (first_char == '!') { scan_css(scanner, string, CSS_CHAR_WHITESPACE); if (!strncasecmp(string, "important", 9)) { diff --git a/src/document/css/scanner.h b/src/document/css/scanner.h index 591b64239..4820a0a63 100644 --- a/src/document/css/scanner.h +++ b/src/document/css/scanner.h @@ -69,7 +69,12 @@ enum css_token_type { CSS_TOKEN_IMPORTANT, /* !important */ - /* TODO: Selector stuff like "|=" and "~=" */ + /* TODO: Selector stuff: */ + CSS_TOKEN_SELECT_SPACE_LIST, /* ~= */ + CSS_TOKEN_SELECT_HYPHEN_LIST, /* |= */ + CSS_TOKEN_SELECT_BEGIN, /* ^= */ + CSS_TOKEN_SELECT_END, /* $= */ + CSS_TOKEN_SELECT_CONTAINS, /* *= */ /* Special tokens: */ From f35026ecfbaa9fd7c151b1b475e77f739acb2e23 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 04:52:47 +0100 Subject: [PATCH 28/42] Add DOM_NODE_UNKNOWN node type for internal purposes only --- src/document/dom/node.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/document/dom/node.h b/src/document/dom/node.h index e1057195d..5f74263a7 100644 --- a/src/document/dom/node.h +++ b/src/document/dom/node.h @@ -8,6 +8,8 @@ struct dom_node_list; enum dom_node_type { + DOM_NODE_UNKNOWN = 0, /* for internal purpose only */ + DOM_NODE_ELEMENT = 1, DOM_NODE_ATTRIBUTE = 2, DOM_NODE_TEXT = 3, From b2c1af16116f97786bdece69502774330b0318b9 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 16:16:55 +0100 Subject: [PATCH 29/42] Add key parameter to the tracker announce URI If non-empty it will be sent to the tracker. A short description of the purpose: * key: Optional. An additional identification that is not shared with any users. It is intended to allow a client to prove their identity should their IP address change. Reported by Toksyuryel. --- src/protocol/bittorrent/bittorrent.c | 8 ++++++++ src/protocol/bittorrent/tracker.c | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/protocol/bittorrent/bittorrent.c b/src/protocol/bittorrent/bittorrent.c index bed15193c..f0847b03e 100644 --- a/src/protocol/bittorrent/bittorrent.c +++ b/src/protocol/bittorrent/bittorrent.c @@ -70,6 +70,14 @@ static struct option_info bittorrent_protocol_options[] = { "no IP address will be sent and the tracker will automatically\n" "determine an appropriate IP address.")), + INIT_OPT_STRING("protocol.bittorrent.tracker", N_("User identification string"), + "key", 0, "", + N_("An additional identification that is not shared with any users.\n" + "It is intended to allow a client to prove their identity should\n" + "their IP address change. It is an optional parameter, but some\n" + "trackers require this parameter. If set to \"\" no user key will\n" + "be sent to the tracker.")), + INIT_OPT_INT("protocol.bittorrent.tracker", N_("Maximum number of peers to request"), "numwant", 0, 0, INT_MAX, 50, N_("The maximum number of peers to request from the tracker.\n" diff --git a/src/protocol/bittorrent/tracker.c b/src/protocol/bittorrent/tracker.c index 855e4757f..67ab65eef 100644 --- a/src/protocol/bittorrent/tracker.c +++ b/src/protocol/bittorrent/tracker.c @@ -140,7 +140,7 @@ do_send_bittorrent_tracker_request(struct connection *conn) { struct bittorrent_connection *bittorrent = conn->info; int stopped = (bittorrent->tracker.event == BITTORRENT_EVENT_STOPPED); - unsigned char *ip; + unsigned char *ip, *key; struct string request; struct uri *uri = NULL; int numwant, index, min_size; @@ -193,6 +193,12 @@ do_send_bittorrent_tracker_request(struct connection *conn) /* This one is required for each request. */ add_format_to_string(&request, "&port=%u", bittorrent->port); + key = get_opt_str("protocol.bittorrent.tracker.key"); + if (*key) { + add_to_string(&request, "&key=", key); + encode_uri_string(&request, key, strlen(key), 1); + } + if (bittorrent->tracker.event != BITTORRENT_EVENT_REGULAR) { unsigned char *event; From cd4fd51438005cfc70758109ef196a25b07d4eaa Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 16:28:14 +0100 Subject: [PATCH 30/42] Compile fix, reported by zas --- src/protocol/bittorrent/tracker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocol/bittorrent/tracker.c b/src/protocol/bittorrent/tracker.c index 67ab65eef..b62628591 100644 --- a/src/protocol/bittorrent/tracker.c +++ b/src/protocol/bittorrent/tracker.c @@ -195,7 +195,7 @@ do_send_bittorrent_tracker_request(struct connection *conn) key = get_opt_str("protocol.bittorrent.tracker.key"); if (*key) { - add_to_string(&request, "&key=", key); + add_to_string(&request, "&key="); encode_uri_string(&request, key, strlen(key), 1); } From be3223b38e97626ac7d91ad16a744ffe97cabe9f Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 16:32:53 +0100 Subject: [PATCH 31/42] Don't try MIME handlers for application/x-bittorrent It is an internally supported protocol, so it should be all internal. The other thing was just causing headacks. Thanks to Neuromancer for suggesting not to endeavor into another configuration nightmare. And thanks to arcatan for requesting this for the n-th time. ;) --- src/session/download.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/session/download.c b/src/session/download.c index a0a075a95..924be1d6d 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -1183,8 +1183,9 @@ setup_download_handler(struct session *ses, struct download *loading, if (type_query) { ret = 1; #ifdef CONFIG_BITTORRENT - if (!handler - && (!strcasecmp(ctype, "application/x-bittorrent") + /* A terrible waste of a good MIME handler here, but we want + * to use the type_query this is easier. */ + if ((!strcasecmp(ctype, "application/x-bittorrent") || !strcasecmp(ctype, "application/x-torrent")) && !get_cmd_opt_bool("anonymous")) query_bittorrent_dialog(type_query); From d1635d697043582e3f09781f7679aeebfd5d0147 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 16:33:50 +0100 Subject: [PATCH 32/42] Fix wrong assertion message string You just cannot print dom_string structs with %s. --- src/document/dom/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 142d08e3c..785cf6281 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -236,7 +236,7 @@ init_dom_node_(unsigned char *file, int line, int sort = (type == DOM_NODE_ATTRIBUTE); int index; - assertm(list, "Adding %s to bad parent %s", + assertm(list, "Adding node to bad parent", get_dom_node_type_name(node->type), get_dom_node_type_name(parent->type)); From 2eebef098d922a9136652ee0385170b430da4aac Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 16:35:41 +0100 Subject: [PATCH 33/42] Prepare the CSS scanner for tokenizing ~ and + as char tokens They are used for "E ~ F" and "E + F" element relations. --- src/document/css/scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/document/css/scanner.c b/src/document/css/scanner.c index eb80e1748..0781968c3 100644 --- a/src/document/css/scanner.c +++ b/src/document/css/scanner.c @@ -48,7 +48,7 @@ static const struct scan_table_info css_scan_table_info[] = { SCAN_TABLE_STRING("\\_", CSS_CHAR_IDENT | CSS_CHAR_IDENT_START), /* This should contain mostly used char tokens like ':' and maybe a few * garbage chars that people might put in their CSS code */ - SCAN_TABLE_STRING("[({})];:,.>", CSS_CHAR_TOKEN), + SCAN_TABLE_STRING("[({})];:,.>+~", CSS_CHAR_TOKEN), SCAN_TABLE_STRING("", CSS_CHAR_SGML_MARKUP), SCAN_TABLE_END, From 852bdaec889f0c50e981219161910bb6199c70e9 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 16:50:04 +0100 Subject: [PATCH 34/42] sort_queue(): make @swp variable local to the loop. --- src/network/connection.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/network/connection.c b/src/network/connection.c index 996d20fbf..ea3c160e2 100644 --- a/src/network/connection.c +++ b/src/network/connection.c @@ -662,12 +662,10 @@ abort_all_keepalive_connections(void) static void sort_queue(void) { - int swp; - - do { + while (1) { struct connection *conn; + int swp = 0; - swp = 0; foreach (conn, connection_queue) { if (!list_has_next(connection_queue, conn)) break; @@ -679,7 +677,9 @@ sort_queue(void) swp = 1; } } - } while (swp); + + if (!swp) break; + }; } static void From f331c7ac85caf570c1a9a369981d8d0861972abd Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 16:52:08 +0100 Subject: [PATCH 35/42] sort_bittorrent_peer_connections(): make @resort variable local to the loop. --- src/protocol/bittorrent/connection.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protocol/bittorrent/connection.c b/src/protocol/bittorrent/connection.c index 7a66c5d68..b55832b24 100644 --- a/src/protocol/bittorrent/connection.c +++ b/src/protocol/bittorrent/connection.c @@ -54,13 +54,12 @@ static void sort_bittorrent_peer_connections(struct bittorrent_connection *bittorrent) { struct bittorrent_peer_connection *peer, *prev; - int resort = 0; - do { + while (1) { struct bittorrent_peer_connection *next; + int resort = 0; prev = NULL; - resort = 0; foreachsafe (peer, next, bittorrent->peers) { if (prev && prev->stats.download_rate < peer->stats.download_rate) { @@ -72,7 +71,8 @@ sort_bittorrent_peer_connections(struct bittorrent_connection *bittorrent) prev = peer; } - } while (resort); + if (!resort) break; + }; #ifdef CONFIG_DEBUG prev = NULL; From 1c7b27c99f5c737f5adf2439a888abcde80d7018 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 16:53:56 +0100 Subject: [PATCH 36/42] abort_files_load(): make @more and @ftl variables local to the loop. --- src/session/session.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/session/session.c b/src/session/session.c index e7664c20e..82608db01 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -288,11 +288,10 @@ print_error_dialog(struct session *ses, enum connection_state state, static void abort_files_load(struct session *ses, int interrupt) { - struct file_to_load *ftl; - int more; + while (1) { + struct file_to_load *ftl; + int more = 0; - do { - more = 0; foreach (ftl, ses->more_files) { if (!file_to_load_is_active(ftl)) continue; @@ -300,7 +299,9 @@ abort_files_load(struct session *ses, int interrupt) more = 1; change_connection(&ftl->download, NULL, PRI_CANCEL, interrupt); } - } while (more); + + if (!more) break; + }; } void From 4a930507e45efad234bc97c2233694d0155dd185 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 16:57:17 +0100 Subject: [PATCH 37/42] process_file_requests(): move @more, @ftl and @doc_view variables to inner scope. --- src/session/session.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/session/session.c b/src/session/session.c index 82608db01..1ecb1f2e3 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -707,16 +707,16 @@ load_additional_file(struct file_to_load *ftl, struct document_view *doc_view, void process_file_requests(struct session *ses) { - struct file_to_load *ftl; - struct document_view *doc_view = NULL; - int more; - if (ses->status.processing_file_requests) return; ses->status.processing_file_requests = 1; - do { - more = 0; + while (1) { + struct file_to_load *ftl; + int more = 0; + foreach (ftl, ses->more_files) { + struct document_view *doc_view; + if (ftl->req_sent) continue; @@ -726,7 +726,9 @@ process_file_requests(struct session *ses) load_additional_file(ftl, doc_view, CACHE_MODE_NORMAL); more = 1; } - } while (more); + + if (!more) break; + }; ses->status.processing_file_requests = 0; } From dbcc033edbad603bea3b19fa9a171a3736ad4bb9 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 16:59:10 +0100 Subject: [PATCH 38/42] draw_frames(): move @more to inner scope. --- src/viewer/text/draw.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/viewer/text/draw.c b/src/viewer/text/draw.c index 07ded04f7..95d21e371 100644 --- a/src/viewer/text/draw.c +++ b/src/viewer/text/draw.c @@ -291,7 +291,7 @@ draw_frames(struct session *ses) { struct document_view *doc_view, *current_doc_view; int *l; - int n, d, more; + int n, d; assert(ses && ses->doc_view && ses->doc_view->document); if_assert_failed return; @@ -308,16 +308,19 @@ draw_frames(struct session *ses) current_doc_view = current_frame(ses); d = 0; - do { - more = 0; + while (1) { + int more = 0; + foreach (doc_view, ses->scrn_frames) { if (doc_view->depth == d) draw_doc(ses, doc_view, doc_view == current_doc_view); else if (doc_view->depth > d) more = 1; } + + if (!more) break; d++; - } while (more); + }; } /* @rerender is ridiciously wound-up. */ From 10aa67fb3249283b84a3c97fd8ce976f97453f5d Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 17:01:45 +0100 Subject: [PATCH 39/42] sort_submitted_values(): move @change abd @next to inner scope. --- src/viewer/text/form.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index c9792a80d..a5413116d 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -518,29 +518,32 @@ add_submitted_value_to_list(struct form_control *fc, static void sort_submitted_values(struct list_head *list) { - int changed; + while (1) { + struct submitted_value *sub; + int changed = 0; - do { - struct submitted_value *sub, *next; - - changed = 0; foreach (sub, *list) if (list_has_next(*list, sub)) if (sub->next->position < sub->position) { - next = sub->next; + struct submitted_value *next = sub->next; + del_from_list(sub); add_at_pos(next, sub); sub = next; changed = 1; } + foreachback (sub, *list) if (list_has_next(*list, sub)) if (sub->next->position < sub->position) { - next = sub->next; + struct submitted_value *next = sub->next; + del_from_list(sub); add_at_pos(next, sub); sub = next; changed = 1; } - } while (changed); + + if (!changed) break; + }; } static void From 1ca88c914700b63f79f93fbb7ef648b8ad170cf8 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 17:04:24 +0100 Subject: [PATCH 40/42] encode_multipart(): move @rd to inner scope. --- src/viewer/text/form.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index a5413116d..a76cfabad 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -784,7 +784,6 @@ encode_multipart(struct session *ses, struct list_head *l, struct string *data, if (*sv->value) { unsigned char *filename; - ssize_t rd; if (get_cmd_opt_bool("anonymous")) { errno = EPERM; @@ -800,14 +799,21 @@ encode_multipart(struct session *ses, struct list_head *l, struct string *data, if (fh == -1) goto encode_error; set_bin(fh); - do { - rd = safe_read(fh, buffer, F_BUFLEN); - if (rd == -1) { - close(fh); - goto encode_error; + while (1) { + ssize_t rd = safe_read(fh, buffer, F_BUFLEN); + + if (rd) { + if (rd == -1) { + close(fh); + goto encode_error; + } + + add_bytes_to_string(data, buffer, rd); + + } else { + break; } - if (rd) add_bytes_to_string(data, buffer, rd); - } while (rd); + }; close(fh); } #undef F_BUFLEN From 22f3f394f9be5ccff0f51405d31efed0e07664a1 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 13 Dec 2005 17:26:02 +0100 Subject: [PATCH 41/42] French translation was updated. --- po/fr.po | 200 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 109 insertions(+), 91 deletions(-) diff --git a/po/fr.po b/po/fr.po index b2e5b48c5..ad83dc663 100644 --- a/po/fr.po +++ b/po/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: ELinks 0.10.CVS\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-12-06 22:02+0100\n" -"PO-Revision-Date: 2005-12-06 22:03+0100\n" +"POT-Creation-Date: 2005-12-13 17:20+0100\n" +"PO-Revision-Date: 2005-12-13 17:21+0100\n" "Last-Translator: Laurent Monin \n" "Language-Team: French \n" "MIME-Version: 1.0\n" @@ -35,7 +35,7 @@ msgstr "Pressez espace pour d #: src/dialogs/options.c:210 src/dialogs/options.c:290 src/mime/dialogs.c:129 #: src/protocol/auth/dialogs.c:110 src/protocol/protocol.c:231 #: src/scripting/lua/core.c:377 src/scripting/lua/core.c:457 -#: src/session/session.c:799 src/viewer/text/search.c:1593 +#: src/session/session.c:802 src/viewer/text/search.c:1593 msgid "~OK" msgstr "~OK" @@ -1784,7 +1784,7 @@ msgstr "Description" #: src/config/dialogs.c:320 src/protocol/bittorrent/dialogs.c:594 #: src/protocol/protocol.c:225 src/session/session.c:282 -#: src/session/session.c:961 src/viewer/text/textarea.c:362 +#: src/session/session.c:964 src/viewer/text/textarea.c:362 #: src/viewer/text/textarea.c:369 msgid "Error" msgstr "Erreur" @@ -3738,7 +3738,7 @@ msgstr "Texte" msgid "Dialog text colors." msgstr "Couleurs du texte des dialogues." -#: src/config/options.inc:978 src/viewer/text/form.c:1451 +#: src/config/options.inc:978 src/viewer/text/form.c:1460 msgid "Checkbox" msgstr "Case à cocher" @@ -3786,7 +3786,7 @@ msgstr "Raccourci du bouton" msgid "Selected button shortcut" msgstr "Raccourci du bouton sélectionné" -#: src/config/options.inc:1006 src/viewer/text/form.c:1455 +#: src/config/options.inc:1006 src/viewer/text/form.c:1464 msgid "Text field" msgstr "Champ texte" @@ -4302,7 +4302,7 @@ msgid "Goto URL History" msgstr "Historique Aller à" #. name: -#: src/cookies/cookies.c:80 src/cookies/cookies.c:824 +#: src/cookies/cookies.c:80 src/cookies/cookies.c:827 msgid "Cookies" msgstr "Cookies" @@ -6547,7 +6547,7 @@ msgstr "Gestionnaire d'authentification" #. name: #: src/protocol/bittorrent/bittorrent.c:26 -#: src/protocol/bittorrent/bittorrent.c:327 +#: src/protocol/bittorrent/bittorrent.c:335 msgid "BitTorrent" msgstr "BitTorrent" @@ -6636,10 +6636,28 @@ msgstr "" "l'adresse appropriée." #: src/protocol/bittorrent/bittorrent.c:73 +msgid "User identification string" +msgstr "Identification de l'utilisateur" + +#: src/protocol/bittorrent/bittorrent.c:75 +msgid "" +"An additional identification that is not shared with any users.\n" +"It is intended to allow a client to prove their identity should\n" +"their IP address change. It is an optional parameter, but some\n" +"trackers require this parameter. If set to \"\" no user key will\n" +"be sent to the tracker." +msgstr "" +"Une clé d'identification additionnelle qui n'est pas partagée avec\n" +"d'autres utilisateurs. L'objectif est de permette l'identification\n" +"d'un client même après un changement d'IP. Ce paramètre est optionnel,\n" +"mais certains trackers le demandent. Si mis à \"\" aucune clé ne sera\n" +"envoyée." + +#: src/protocol/bittorrent/bittorrent.c:81 msgid "Maximum number of peers to request" msgstr "Nombre maximum de postes à demander" -#: src/protocol/bittorrent/bittorrent.c:75 +#: src/protocol/bittorrent/bittorrent.c:83 msgid "" "The maximum number of peers to request from the tracker.\n" "Set to 0 to use the server default." @@ -6647,11 +6665,11 @@ msgstr "" "Nombre maximum de postes à demander au serveur.\n" "Mettre à 0 pour utiliser la valeur par défaut du serveur." -#: src/protocol/bittorrent/bittorrent.c:78 +#: src/protocol/bittorrent/bittorrent.c:86 msgid "Minimum peers to skip rerequesting" msgstr "Nombre minimal de postes avant abandon de requêtes" -#: src/protocol/bittorrent/bittorrent.c:80 +#: src/protocol/bittorrent/bittorrent.c:88 msgid "" "The minimum number of peers to have in the current peer info\n" "pool before skipping requesting of more peers. I.e. setting\n" @@ -6665,19 +6683,19 @@ msgstr "" #. ****************************************************************** #. Lowlevel peer-wire options: #. ****************************************************************** -#: src/protocol/bittorrent/bittorrent.c:90 +#: src/protocol/bittorrent/bittorrent.c:98 msgid "Peer-wire" msgstr "Liens postes" -#: src/protocol/bittorrent/bittorrent.c:92 +#: src/protocol/bittorrent/bittorrent.c:100 msgid "Lowlevel peer-wire options." msgstr "Options de bas niveau pour les liens postes." -#: src/protocol/bittorrent/bittorrent.c:94 +#: src/protocol/bittorrent/bittorrent.c:102 msgid "Maximum number of peer connections" msgstr "Nombre maximum de connexions aux postes" -#: src/protocol/bittorrent/bittorrent.c:96 +#: src/protocol/bittorrent/bittorrent.c:104 msgid "" "The maximum number of allowed connections to both active and\n" "non-active peers. By increasing the number of allowed connections,\n" @@ -6691,11 +6709,11 @@ msgstr "" "Toutefois, trop de connexions peuvent conduire à une congestion TCP.\n" "Si le maximum est atteint, toutes les nouvelles connexions seront fermées." -#: src/protocol/bittorrent/bittorrent.c:102 +#: src/protocol/bittorrent/bittorrent.c:110 msgid "Maximum peer message length" msgstr "Longueur maximale des messages" -#: src/protocol/bittorrent/bittorrent.c:104 +#: src/protocol/bittorrent/bittorrent.c:112 msgid "" "The maximum length of messages to accept over the wire.\n" "Larger values will cause the connection to be dropped." @@ -6703,11 +6721,11 @@ msgstr "" "Longueur maximale des messages à accepter sur le lien.\n" "De plus grande valeurs causeront une déconnexion." -#: src/protocol/bittorrent/bittorrent.c:107 +#: src/protocol/bittorrent/bittorrent.c:115 msgid "Maximum allowed request length" msgstr "Longueur maximale de requête autorisée" -#: src/protocol/bittorrent/bittorrent.c:109 +#: src/protocol/bittorrent/bittorrent.c:117 msgid "" "The maximum length to allow for incoming requests.\n" "Larger requests will cause the connection to be dropped." @@ -6715,11 +6733,11 @@ msgstr "" "Longueur maximale autorisée pour les requêtes entrantes.\n" "De plus grande valeurs causeront une déconnexion." -#: src/protocol/bittorrent/bittorrent.c:112 +#: src/protocol/bittorrent/bittorrent.c:120 msgid "Length of requests" msgstr "Longueur des requêtes" -#: src/protocol/bittorrent/bittorrent.c:114 +#: src/protocol/bittorrent/bittorrent.c:122 msgid "" "How many bytes to query for per request. This is complementary\n" "to the max_request_length option. If the configured length is\n" @@ -6729,11 +6747,11 @@ msgstr "" "l'option max_request_length. Si la valeur configurée est plus\n" "grande que la longueur des morceaux celle-ci sera tronquée." -#: src/protocol/bittorrent/bittorrent.c:118 +#: src/protocol/bittorrent/bittorrent.c:126 msgid "Peer inactivity timeout" msgstr "Délai d'inactivité pour un poste" -#: src/protocol/bittorrent/bittorrent.c:120 +#: src/protocol/bittorrent/bittorrent.c:128 msgid "" "The number of seconds to wait before closing a socket on\n" "which nothing has been received or sent." @@ -6741,11 +6759,11 @@ msgstr "" "Le nombre de secondes à attendre avant de fermer une\n" "connexion sur laquelle rien n'a circulé." -#: src/protocol/bittorrent/bittorrent.c:123 +#: src/protocol/bittorrent/bittorrent.c:131 msgid "Maximum peer pool size" msgstr "Taille maximale du groupe de postes" -#: src/protocol/bittorrent/bittorrent.c:125 +#: src/protocol/bittorrent/bittorrent.c:133 msgid "" "Maximum number of items in the peer pool. The peer pool\n" "contains information used for establishing connections to\n" @@ -6760,11 +6778,11 @@ msgstr "" #. ****************************************************************** #. Piece management options: #. ****************************************************************** -#: src/protocol/bittorrent/bittorrent.c:135 +#: src/protocol/bittorrent/bittorrent.c:143 msgid "Maximum piece cache size" msgstr "Taille maximale du cache de morceaux" -#: src/protocol/bittorrent/bittorrent.c:137 +#: src/protocol/bittorrent/bittorrent.c:145 msgid "" "The maximum amount of memory used to hold recently\n" "downloaded pieces.\n" @@ -6774,11 +6792,11 @@ msgstr "" "les morceaux récemment téléchargés.\n" "Mettre à 0 pour une taille illimitée." -#: src/protocol/bittorrent/bittorrent.c:146 +#: src/protocol/bittorrent/bittorrent.c:154 msgid "Sharing rate" msgstr "Ratio de partage" -#: src/protocol/bittorrent/bittorrent.c:148 +#: src/protocol/bittorrent/bittorrent.c:156 msgid "" "The minimum sharing rate to achieve before stop seeding.\n" "The sharing rate is computed as the number of uploaded bytes\n" @@ -6794,22 +6812,22 @@ msgstr "" "Mettre à 1.0 pour uploader une copie complète des données et\n" "à 0.0 pour avoir un ratio de partage sans limite." -#: src/protocol/bittorrent/bittorrent.c:155 +#: src/protocol/bittorrent/bittorrent.c:163 msgid "Maximum number of uploads" msgstr "Nombre maximal de téléchargements montants" -#: src/protocol/bittorrent/bittorrent.c:157 +#: src/protocol/bittorrent/bittorrent.c:165 msgid "The maximum number of uploads to allow at once." msgstr "" "Nombre maximal de téléchargements montants autorisés\n" "à un instant." #. The number of uploads to fill out to with extra optimistic unchokes -#: src/protocol/bittorrent/bittorrent.c:160 +#: src/protocol/bittorrent/bittorrent.c:168 msgid "Minimum number of uploads" msgstr "Nombre minimal de téléchargements montants" -#: src/protocol/bittorrent/bittorrent.c:162 +#: src/protocol/bittorrent/bittorrent.c:170 msgid "" "The minimum number of uploads which should at least\n" "be used for new connections." @@ -6817,11 +6835,11 @@ msgstr "" "Le nombre minimal de téléchargements montants qui devraient\n" "être utilisés pour les nouvelles connexions." -#: src/protocol/bittorrent/bittorrent.c:166 +#: src/protocol/bittorrent/bittorrent.c:174 msgid "Keepalive interval" msgstr "Intervalle pour le maintien en vie des connexions" -#: src/protocol/bittorrent/bittorrent.c:168 +#: src/protocol/bittorrent/bittorrent.c:176 msgid "" "The number of seconds to pause between sending keepalive\n" "messages." @@ -6829,11 +6847,11 @@ msgstr "" "Nombre de secondes entre chaque envoi de messages de maintien\n" "en vie." -#: src/protocol/bittorrent/bittorrent.c:171 +#: src/protocol/bittorrent/bittorrent.c:179 msgid "Number of pending requests" msgstr "Nombre de requêtes en attente" -#: src/protocol/bittorrent/bittorrent.c:173 +#: src/protocol/bittorrent/bittorrent.c:181 msgid "" "How many piece requests to continuously keep in queue. Pipelining\n" "of requests is essential to saturate connections and get a good\n" @@ -6850,11 +6868,11 @@ msgstr "" "demandés à de multiples postes." #. Bram uses 30 seconds here. -#: src/protocol/bittorrent/bittorrent.c:182 +#: src/protocol/bittorrent/bittorrent.c:190 msgid "Peer snubbing interval" msgstr "Intervalle de subbing pour les postes" -#: src/protocol/bittorrent/bittorrent.c:184 +#: src/protocol/bittorrent/bittorrent.c:192 msgid "" "The number of seconds to wait for file data before assuming\n" "the peer has been snubbed." @@ -6862,11 +6880,11 @@ msgstr "" "Nombre de secondes à attendre les données avant de supposer\n" "qu'un poste a été snubbé." -#: src/protocol/bittorrent/bittorrent.c:187 +#: src/protocol/bittorrent/bittorrent.c:195 msgid "Peer choke interval" msgstr "Intervalle de choke pour les postes" -#: src/protocol/bittorrent/bittorrent.c:189 +#: src/protocol/bittorrent/bittorrent.c:197 msgid "" "The number of seconds between updating the connection state\n" "and most importantly choke and unchoke peer connections. The\n" @@ -6880,11 +6898,11 @@ msgstr "" "connexions unchokées démarrent mais assez petite pour ne pas permettre\n" "à certains d'utiliser trop de bande passante." -#: src/protocol/bittorrent/bittorrent.c:195 +#: src/protocol/bittorrent/bittorrent.c:203 msgid "Rarest first piece selection cutoff" msgstr "Limite pour la sélection des morceaux par rareté" -#: src/protocol/bittorrent/bittorrent.c:197 +#: src/protocol/bittorrent/bittorrent.c:205 msgid "" "The number of pieces to obtain before switching piece\n" "selection strategy from random to rarest first." @@ -6892,11 +6910,11 @@ msgstr "" "Nombre de morceaux à obtenir avant de modifier la stratégie\n" "de sélection de morceaux du mode hasard au mode rareté." -#: src/protocol/bittorrent/bittorrent.c:200 src/protocol/http/http.c:106 +#: src/protocol/bittorrent/bittorrent.c:208 src/protocol/http/http.c:106 msgid "Allow blacklisting" msgstr "Autoriser la mise en liste noire" -#: src/protocol/bittorrent/bittorrent.c:202 +#: src/protocol/bittorrent/bittorrent.c:210 msgid "Allow blacklisting of buggy peers." msgstr "Autoriser la mise en liste noire des postes bogués." @@ -7904,11 +7922,11 @@ msgstr "Le fichier sera ouvert avec le programme '%s'." msgid "~Open" msgstr "~Ouvrir" -#: src/session/session.c:749 src/session/session.c:768 src/session/task.c:269 +#: src/session/session.c:752 src/session/session.c:771 src/session/task.c:269 msgid "Warning" msgstr "Avertissement" -#: src/session/session.c:750 +#: src/session/session.c:753 msgid "" "You have empty string in protocol.http.user_agent - this was a default value " "in the past, substituted by default ELinks User-Agent string. However, " @@ -7927,7 +7945,7 @@ msgstr "" "défaut sera utilisée. Si vous n'avez aucune idée de quoi nous parlons alors " "faites juste ça. Toutes nos excuses pour ce désagrément." -#: src/session/session.c:769 +#: src/session/session.c:772 msgid "" "You have option config.saving_style set to a de facto obsolete value. The " "configuration saving algorithms of ELinks were changed from the last time " @@ -7948,11 +7966,11 @@ msgstr "" "l'option config.saving_style dans le but d'obtenir un fonctionnement " "correct. Toutes nos excuses pour l'éventuel désagrément causé." -#: src/session/session.c:794 +#: src/session/session.c:797 msgid "Welcome" msgstr "Bienvenue" -#: src/session/session.c:795 +#: src/session/session.c:798 msgid "" "Welcome to ELinks!\n" "\n" @@ -8063,164 +8081,164 @@ msgstr "Ancre manquante" msgid "The requested fragment \"#%s\" doesn't exist." msgstr "L'ancre recherchée \"#%s\" n'existe pas." -#: src/viewer/text/form.c:855 +#: src/viewer/text/form.c:864 msgid "Error while posting form" msgstr "Erreur lors de l'envoi du formulaire" -#: src/viewer/text/form.c:856 +#: src/viewer/text/form.c:865 #, c-format msgid "Could not load file %s: %s" msgstr "Impossible de charger le fichier %s: %s" -#: src/viewer/text/form.c:1436 +#: src/viewer/text/form.c:1445 msgid "Reset form" msgstr "Réinitialiser le formulaire" -#: src/viewer/text/form.c:1438 +#: src/viewer/text/form.c:1447 msgid "Harmless button" msgstr "Bouton sans impact" -#: src/viewer/text/form.c:1446 +#: src/viewer/text/form.c:1455 msgid "Submit form to" msgstr "Envoi du formulaire à" -#: src/viewer/text/form.c:1447 +#: src/viewer/text/form.c:1456 msgid "Post form to" msgstr "Transfert du formulaire à" -#: src/viewer/text/form.c:1449 +#: src/viewer/text/form.c:1458 msgid "Radio button" msgstr "Bouton radio" -#: src/viewer/text/form.c:1453 +#: src/viewer/text/form.c:1462 msgid "Select field" msgstr "Liste" -#: src/viewer/text/form.c:1457 +#: src/viewer/text/form.c:1466 msgid "Text area" msgstr "Champ texte multiligne" -#: src/viewer/text/form.c:1459 +#: src/viewer/text/form.c:1468 msgid "File upload" msgstr "Envoi de fichier" -#: src/viewer/text/form.c:1461 +#: src/viewer/text/form.c:1470 msgid "Password field" msgstr "Champ mot de passe" -#: src/viewer/text/form.c:1499 +#: src/viewer/text/form.c:1508 msgid "name" msgstr "Nom" -#: src/viewer/text/form.c:1511 +#: src/viewer/text/form.c:1520 msgid "value" msgstr "Valeur" -#: src/viewer/text/form.c:1524 +#: src/viewer/text/form.c:1533 msgid "read only" msgstr "lecture seule" -#: src/viewer/text/form.c:1535 +#: src/viewer/text/form.c:1544 #, c-format msgid "press %s to navigate" msgstr "pressez %s pour naviguer" -#: src/viewer/text/form.c:1537 +#: src/viewer/text/form.c:1546 #, c-format msgid "press %s to edit" msgstr "pressez %s pour éditer" -#: src/viewer/text/form.c:1573 +#: src/viewer/text/form.c:1582 #, c-format msgid "press %s to submit to %s" msgstr "pressez %s pour soumettre à %s" -#: src/viewer/text/form.c:1575 +#: src/viewer/text/form.c:1584 #, c-format msgid "press %s to post to %s" msgstr "pressez %s pour poster à %s" -#: src/viewer/text/link.c:1145 +#: src/viewer/text/link.c:1148 msgid "Display ~usemap" msgstr "Afficher ~usemap" -#: src/viewer/text/link.c:1148 +#: src/viewer/text/link.c:1151 msgid "~Follow link" msgstr "~Suivre le lien" -#: src/viewer/text/link.c:1150 +#: src/viewer/text/link.c:1153 msgid "Follow link and r~eload" msgstr "Suivre le lien et ~recharger" -#: src/viewer/text/link.c:1154 +#: src/viewer/text/link.c:1157 msgid "Open in new ~window" msgstr "Ouvrir dans une nouvelle ~fenêtre" -#: src/viewer/text/link.c:1156 +#: src/viewer/text/link.c:1159 msgid "Open in new ~tab" msgstr "Ouvrir dans un nouvel ongle~t" -#: src/viewer/text/link.c:1158 +#: src/viewer/text/link.c:1161 msgid "Open in new tab in ~background" msgstr "Ouvrir dans un nouvel onglet en arrière-~plan" -#: src/viewer/text/link.c:1163 +#: src/viewer/text/link.c:1166 msgid "~Download link" msgstr "~Enregistrer le lien" -#: src/viewer/text/link.c:1166 +#: src/viewer/text/link.c:1169 msgid "~Add link to bookmarks" msgstr "~Ajouter ce lien aux signets" -#: src/viewer/text/link.c:1178 src/viewer/text/link.c:1214 +#: src/viewer/text/link.c:1181 src/viewer/text/link.c:1217 msgid "~Reset form" msgstr "Remettre à ~zéro le formulaire" -#: src/viewer/text/link.c:1191 +#: src/viewer/text/link.c:1194 msgid "Open in ~external editor" msgstr "Ouvrir dans un ~éditeur externe" -#: src/viewer/text/link.c:1197 +#: src/viewer/text/link.c:1200 msgid "~Submit form" msgstr "~Envoyer le formulaire" -#: src/viewer/text/link.c:1198 +#: src/viewer/text/link.c:1201 msgid "Submit form and rel~oad" msgstr "Envoyer le formulaire et ~recharger" -#: src/viewer/text/link.c:1202 +#: src/viewer/text/link.c:1205 msgid "Submit form and open in new ~window" msgstr "Envoyer le formulaire et ouvrir dans une nouvelle ~fenêtre" -#: src/viewer/text/link.c:1204 +#: src/viewer/text/link.c:1207 msgid "Submit form and open in new ~tab" msgstr "Envoyer le formulaire et ouvrir un ~onglet" -#: src/viewer/text/link.c:1207 +#: src/viewer/text/link.c:1210 msgid "Submit form and open in new tab in ~background" msgstr "Envoyer le formulaire et ouvrir un onglet en ~arrière-plan" -#: src/viewer/text/link.c:1212 +#: src/viewer/text/link.c:1215 msgid "Submit form and ~download" msgstr "Envoyer le formulaire et ~télécharger" -#: src/viewer/text/link.c:1219 +#: src/viewer/text/link.c:1222 msgid "V~iew image" msgstr "~Voir l'image" -#: src/viewer/text/link.c:1221 +#: src/viewer/text/link.c:1224 msgid "Download ima~ge" msgstr "Enregistrer l'~image" -#: src/viewer/text/link.c:1229 +#: src/viewer/text/link.c:1232 msgid "No link selected" msgstr "Aucun lien sélectionné" -#: src/viewer/text/link.c:1281 +#: src/viewer/text/link.c:1280 msgid "Image" msgstr "Image" -#: src/viewer/text/link.c:1286 +#: src/viewer/text/link.c:1285 msgid "Usemap" msgstr "Usemap" @@ -8308,10 +8326,10 @@ msgstr "Aller au lien" msgid "Enter link number" msgstr "Entrez un numéro de lien" -#: src/viewer/text/view.c:1287 +#: src/viewer/text/view.c:1288 msgid "Save error" msgstr "Erreur lors de la sauvegarde" -#: src/viewer/text/view.c:1288 +#: src/viewer/text/view.c:1289 msgid "Error writing to file" msgstr "Erreur lors de l'écriture du fichier" From 5ef041c051e1b286b1af3fbde80593d510eab95b Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 13 Dec 2005 20:08:58 +0100 Subject: [PATCH 42/42] Redo the assertm() message to just show the type of the node and parent --- src/document/dom/node.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/document/dom/node.c b/src/document/dom/node.c index 785cf6281..87d41b61b 100644 --- a/src/document/dom/node.c +++ b/src/document/dom/node.c @@ -236,9 +236,8 @@ init_dom_node_(unsigned char *file, int line, int sort = (type == DOM_NODE_ATTRIBUTE); int index; - assertm(list, "Adding node to bad parent", - get_dom_node_type_name(node->type), - get_dom_node_type_name(parent->type)); + assertm(list, "Adding node %d to bad parent %d", + node->type, parent->type); index = *list && (*list)->size > 0 && sort ? get_dom_node_map_index(*list, node) : -1;