summaryrefslogtreecommitdiff
path: root/recipes/opensync/wbxml2/04_saxlike_entity_parsing.patch
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
committerDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
commit709c4d66e0b107ca606941b988bad717c0b45d9b (patch)
tree37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/opensync/wbxml2/04_saxlike_entity_parsing.patch
parentfa6cd5a3b993f16c27de4ff82b42684516d433ba (diff)
rename packages/ to recipes/ per earlier agreement
See links below for more details: http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326 http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816 Signed-off-by: Denys Dmytriyenko <denis@denix.org> Acked-by: Mike Westerhof <mwester@dls.net> Acked-by: Philip Balister <philip@balister.org> Acked-by: Khem Raj <raj.khem@gmail.com> Acked-by: Marcin Juszkiewicz <hrw@openembedded.org> Acked-by: Koen Kooi <koen@openembedded.org> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/opensync/wbxml2/04_saxlike_entity_parsing.patch')
-rw-r--r--recipes/opensync/wbxml2/04_saxlike_entity_parsing.patch90
1 files changed, 90 insertions, 0 deletions
diff --git a/recipes/opensync/wbxml2/04_saxlike_entity_parsing.patch b/recipes/opensync/wbxml2/04_saxlike_entity_parsing.patch
new file mode 100644
index 0000000000..43d915b8b7
--- /dev/null
+++ b/recipes/opensync/wbxml2/04_saxlike_entity_parsing.patch
@@ -0,0 +1,90 @@
+diff --git a/src/wbxml_parser.c b/src/wbxml_parser.c
+index c022e00..bea2062 100644
+--- a/src/wbxml_parser.c
++++ b/src/wbxml_parser.c
+@@ -43,6 +43,7 @@
+ */
+
+ #include "wbxml.h"
++#include <assert.h>
+
+
+ /* Memory management related defines */
+@@ -56,10 +57,6 @@
+ /** For unknown Tag Name or Attribute Name (in Best Effort Mode) */
+ #define WBXML_PARSER_UNKNOWN_STRING ((WB_UTINY *)"unknown")
+
+-/** If you want to modify this define, change the 'entcode' variable length in parse_entity() too please */
+-#define WBXML_PARSER_MAX_ENTITY_CODE 999999
+-
+-
+ /**
+ * @brief The WBXML Application Token types
+ */
+@@ -1661,7 +1658,6 @@ static WBXMLError parse_extension(WBXMLParser *parser, WBXMLTokenType code_space
+ */
+ static WBXMLError parse_entity(WBXMLParser *parser, WBXMLBuffer **result)
+ {
+- WB_TINY entity[10];
+ WB_ULONG code = 0;
+ WBXMLError ret = WBXML_OK;
+
+@@ -1674,23 +1670,44 @@ static WBXMLError parse_entity(WBXMLParser *parser, WBXMLBuffer **result)
+ return ret;
+ }
+
+- /* Build Entity */
+- if ( code > WBXML_PARSER_MAX_ENTITY_CODE ) {
+- return WBXML_ERROR_ENTITY_CODE_OVERFLOW;
+- }
+-
+- /**
+- * WARNING: If you change the entity variable length (10 chars), change too
+- * 'WBXML_PARSER_MAX_ENTITY_CODE' defined in this file !
++ /*
++ * Convert the UCS-4 code to a UTF-8 encoded string.
+ */
+- sprintf(entity, "&#%u;", code);
+
+- /* Create result buffer */
+- if ( (*result = wbxml_buffer_create_from_cstr(entity)) == NULL ) {
+- return WBXML_ERROR_NOT_ENOUGH_MEMORY;
++ assert(code < 0x80000000);
++
++ if (code < 0x80)
++ {
++ /* For codes under 0x80, we don't need any fancy formatting. */
++ WB_TINY entity[2] = {(WB_TINY)code, 0};
++
++ /* Create result buffer */
++ if ( (*result = wbxml_buffer_create_from_cstr(entity)) == NULL ) {
++ return WBXML_ERROR_NOT_ENOUGH_MEMORY;
++ }
++
++ return WBXML_OK;
++ }
++ else
++ {
++ WB_TINY masks[5] = {0xFC, 0xF8, 0xF0, 0xE0, 0xC0};
++ WB_TINY entity[7] = {0, 0, 0, 0, 0, 0, 0};
++
++ int index = 5;
++ while (code >= 0x40)
++ {
++ entity[index] = 0x80 | (code & 0x3F);
++ code >>= 6; index--;
++ }
++ entity[index] = masks[index] | code;
++
++ /* Create result buffer */
++ if ( (*result = wbxml_buffer_create_from_cstr(entity + index)) == NULL ) {
++ return WBXML_ERROR_NOT_ENOUGH_MEMORY;
++ }
++
++ return WBXML_OK;
+ }
+-
+- return WBXML_OK;
+ }
+
+