From b65d63440f2177b1b2511c70115dcb66e752d699 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 6 Mar 2008 17:52:59 +0000 Subject: [PATCH] add cedrics dict check patch SVN revision: 33946 --- legacy/edje/Doxyfile | 4 +-- legacy/edje/gendoc | 4 ++- legacy/edje/src/lib/Makefile.am | 6 ++-- legacy/edje/src/lib/edje_embryo.c | 2 +- legacy/edje/src/lib/edje_load.c | 4 +-- legacy/edje/src/lib/edje_private.h | 34 ++++++++++----------- legacy/edje/src/lib/edje_textblock_styles.c | 4 +-- legacy/eet/src/lib/Eet.h | 1 + legacy/eet/src/lib/Eet_private.h | 3 ++ legacy/eet/src/lib/eet_data.c | 15 +++++++++ legacy/eet/src/lib/eet_dictionary.c | 29 ++++++++++++++++++ legacy/eet/src/lib/eet_lib.c | 7 ++++- 12 files changed, 85 insertions(+), 28 deletions(-) diff --git a/legacy/edje/Doxyfile b/legacy/edje/Doxyfile index b94ea0c6a6..accec4e3de 100644 --- a/legacy/edje/Doxyfile +++ b/legacy/edje/Doxyfile @@ -1,7 +1,7 @@ PROJECT_NAME = Edje PROJECT_NUMBER = OUTPUT_DIRECTORY = doc -INPUT = edje.c ./src/bin/edje_cc_handlers.c +INPUT = edje.c ./src/bin/edje_cc_handlers.c ./src/lib/Edje_Edit.h IMAGE_PATH = doc/img OUTPUT_LANGUAGE = English GENERATE_HTML = YES @@ -41,7 +41,7 @@ VERBATIM_HEADERS = NO SHOW_INCLUDE_FILES = NO JAVADOC_AUTOBRIEF = YES MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO +DETAILS_AT_TOP = YES INHERIT_DOCS = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES diff --git a/legacy/edje/gendoc b/legacy/edje/gendoc index 7d8cb5d8ef..1b20190859 100755 --- a/legacy/edje/gendoc +++ b/legacy/edje/gendoc @@ -1,7 +1,7 @@ #!/bin/sh cp ./edje.c.in ./edje.c cat ./src/lib/Edje.h >> ./edje.c -for I in `find ./src/lib -name "*.c" -print`; do +for I in `find ./src/lib -name "*.c" -print | grep -v edje_edit.c`; do cat $I >> ./edje.c done rm -rf ./doc/html ./doc/latex ./doc/man @@ -9,6 +9,8 @@ mkdir -p ./doc/html ./doc/latex ./doc/man doxygen cp doc/img/*.png doc/html/ cp doc/img/*.gif doc/html/ +cp doc/img/*.jpg doc/html/ +cp doc/*.css doc/html/ rm -f edje_docs.tar edje_docs.tar.gz tar -cvf edje_docs.tar doc/html doc/man doc/latex gzip -9 edje_docs.tar diff --git a/legacy/edje/src/lib/Makefile.am b/legacy/edje/src/lib/Makefile.am index 47a5a952dd..6c22a1be24 100644 --- a/legacy/edje/src/lib/Makefile.am +++ b/legacy/edje/src/lib/Makefile.am @@ -14,7 +14,8 @@ lib_LTLIBRARIES = \ libedje.la include_HEADERS = \ -Edje.h +Edje.h \ +Edje_Edit.h libedje_la_SOURCES = \ edje_calc.c \ @@ -35,7 +36,8 @@ edje_message_queue.c \ edje_private.h \ edje_cache.c \ edje_match.c \ -edje_textblock_styles.c +edje_textblock_styles.c \ +edje_edit.c libedje_la_LIBADD = -lm @EDJE_LIBS@ libedje_la_DEPENDENCIES = $(top_builddir)/config.h diff --git a/legacy/edje/src/lib/edje_embryo.c b/legacy/edje/src/lib/edje_embryo.c index c10f39445d..b743193df3 100644 --- a/legacy/edje/src/lib/edje_embryo.c +++ b/legacy/edje/src/lib/edje_embryo.c @@ -847,7 +847,7 @@ _edje_embryo_fn_get_state(Embryo_Program *ep, Embryo_Cell *params) Edje *ed; int part_id = 0; Edje_Real_Part *rp; - char *s; + const char *s; CHKPARAM(4); ed = embryo_program_data_get(ep); diff --git a/legacy/edje/src/lib/edje_load.c b/legacy/edje/src/lib/edje_load.c index 8c7c6dfa6c..e0943e81af 100644 --- a/legacy/edje/src/lib/edje_load.c +++ b/legacy/edje/src/lib/edje_load.c @@ -5,7 +5,7 @@ #include "Edje.h" #include "edje_private.h" -static void _edje_collection_free_part_description_free(Edje_Part_Description *desc, unsigned int free_strings); +void _edje_collection_free_part_description_free(Edje_Part_Description *desc, unsigned int free_strings); static Evas_Bool _edje_file_collection_hash_foreach(const Evas_Hash *hash, const char *key, void *data, void *fdata); #ifdef EDJE_PROGRAM_CACHE static int _edje_collection_free_prog_cache_matches_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata); @@ -948,7 +948,7 @@ _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec) free(ec); } -static void +void _edje_collection_free_part_description_free(Edje_Part_Description *desc, unsigned int free_strings) { while (desc->image.tween_list) diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h index 3ff3efedf2..85f320d65d 100644 --- a/legacy/edje/src/lib/edje_private.h +++ b/legacy/edje/src/lib/edje_private.h @@ -380,31 +380,31 @@ struct _Edje_Spectrum_Color struct _Edje_Program /* a conditional program to be run */ { - int id; /* id of program */ - char *name; /* name of the action */ + int id; /* id of program */ + const char *name; /* name of the action */ - char *signal; /* if signal emission name matches the glob here... */ - char *source; /* if part that emitted this (name) matches this glob */ + const char *signal; /* if signal emission name matches the glob here... */ + const char *source; /* if part that emitted this (name) matches this glob */ struct { - double from; - double range; + double from; + double range; } in; - int action; /* type - set state, stop action, set drag pos etc. */ - char *state; /* what state of alternates to apply, NULL = default */ - char *state2; /* what other state to use - for signal emit action */ - double value; /* value of state to apply (if multiple names match) */ - double value2; /* other value for drag actions */ + int action; /* type - set state, stop action, set drag pos etc. */ + const char *state; /* what state of alternates to apply, NULL = default */ + const char *state2; /* what other state to use - for signal emit action */ + double value; /* value of state to apply (if multiple names match) */ + double value2; /* other value for drag actions */ struct { - int mode; /* how to tween - linear, sinusoidal etc. */ - double time; /* time to graduate between current and new state */ + int mode; /* how to tween - linear, sinusoidal etc. */ + double time; /* time to graduate between current and new state */ } tween; - Evas_List *targets; /* list of target parts to apply the state to */ + Evas_List *targets; /* list of target parts to apply the state to */ - Evas_List *after; /* list of actions to run at the end of this, for looping */ + Evas_List *after; /* list of actions to run at the end of this, for looping */ }; struct _Edje_Program_Target /* the target of an action */ @@ -461,7 +461,7 @@ struct _Edje_Part_Collection struct _Edje_Part { - char *name; /* the name if any of the part */ + const char *name; /* the name if any of the part */ Edje_Part_Description *default_desc; /* the part descriptor for default */ Evas_List *other_desc; /* other possible descriptors */ char *source; @@ -500,7 +500,7 @@ struct _Edje_Part_Description { struct { double value; /* the value of the state (for ranges) */ - char *name; /* the named state if any */ + const char *name; /* the named state if any */ } state; Edje_Alignment align; /* 0 <-> 1.0 alignment within allocated space */ diff --git a/legacy/edje/src/lib/edje_textblock_styles.c b/legacy/edje/src/lib/edje_textblock_styles.c index 2d2e09fcb0..4236bd6da4 100644 --- a/legacy/edje/src/lib/edje_textblock_styles.c +++ b/legacy/edje/src/lib/edje_textblock_styles.c @@ -426,8 +426,8 @@ _edje_textblock_style_parse_and_fix(Edje_File *edf) /* Add and Handle tag parsed data */ if (ts) { - /* FIXME: How to know if the previous value was a stringshare */ -/* evas_stringshare_del(tag->value); */ + if (eet_dictionary_string_check(eet_dictionary_get(edf->ef), tag->value) == 0) + evas_stringshare_del(tag->value); tag->value = evas_stringshare_add(ts); buf = _edje_strbuf_append(buf, tag->value, &buflen, &bufalloc); free(ts); diff --git a/legacy/eet/src/lib/Eet.h b/legacy/eet/src/lib/Eet.h index 42597e4e90..0801b261f7 100644 --- a/legacy/eet/src/lib/Eet.h +++ b/legacy/eet/src/lib/Eet.h @@ -224,6 +224,7 @@ extern "C" { /* FIXME: Add some documentation */ EAPI Eet_Dictionary* eet_dictionary_get(Eet_File *ef); + EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string); /** * Read a specified entry from an eet file and return data diff --git a/legacy/eet/src/lib/Eet_private.h b/legacy/eet/src/lib/Eet_private.h index c339aa87bb..8480230894 100644 --- a/legacy/eet/src/lib/Eet_private.h +++ b/legacy/eet/src/lib/Eet_private.h @@ -87,6 +87,9 @@ struct _Eet_Dictionary int count; int total; + + const char *start; + const char *end; }; Eet_Dictionary *eet_dictionary_add(void); diff --git a/legacy/eet/src/lib/eet_data.c b/legacy/eet/src/lib/eet_data.c index 7b9f0afd62..b64b58afeb 100644 --- a/legacy/eet/src/lib/eet_data.c +++ b/legacy/eet/src/lib/eet_data.c @@ -1437,6 +1437,7 @@ _eet_data_dump_free(Node *node) case EET_T_UINT: case EET_T_ULONG_LONG: break; + case EET_T_INLINED_STRING: case EET_T_STRING: if (node->data.str) free(node->data.str); break; @@ -1620,6 +1621,7 @@ _eet_data_dump_encode(Eet_Dictionary *ed, free(data); } break; + case EET_T_INLINED_STRING: case EET_T_STRING: data = eet_data_put_type(ed, node->type, &(node->data.str), &size); if (data) @@ -2033,6 +2035,18 @@ _eet_data_descriptor_decode(const Eet_Dictionary *ed, } } } + else + if (type == EET_T_INLINED_STRING) + { + char **str; + + str = (char **)(((char *)data) + ede->offset); + if (*str) + { + *str = edd->func.str_alloc(*str); + _eet_freelist_str_add(*str); + } + } } else if (ede->subtype) { @@ -2244,6 +2258,7 @@ _eet_data_descriptor_decode(const Eet_Dictionary *ed, dumpfunc(dumpdata, "ulong_long: "); snprintf(tbuf, sizeof(tbuf), "%llu", *((unsigned long long *)dd)); dumpfunc(dumpdata, tbuf); break; + case EET_T_INLINED_STRING: case EET_T_STRING: { char *s; diff --git a/legacy/eet/src/lib/eet_dictionary.c b/legacy/eet/src/lib/eet_dictionary.c index 0e05c6f282..792158f8f9 100644 --- a/legacy/eet/src/lib/eet_dictionary.c +++ b/legacy/eet/src/lib/eet_dictionary.c @@ -170,8 +170,17 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed, int index) return NULL; if (index < ed->count) { +#ifdef _WIN32 + /* Windows file system could change the mmaped file when replacing a file. So we need to copy all string in memory to avoid bugs. */ + if (ed->all[index].str == NULL) + { + ed->all[index].str = strdup(ed->all[index].mmap); + ed->all[index].mmap = NULL; + } +#else if (ed->all[index].mmap) return ed->all[index].mmap; +#endif return ed->all[index].str; } return NULL; @@ -291,3 +300,23 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed, int index, double *re } return 0; } + +EAPI int +eet_dictionary_string_check(Eet_Dictionary *ed, const char *string) +{ + int i; + + if (ed == NULL + || string == NULL) + return 0; + + if (ed->start <= string + && string < ed->end) + return 1; + + for (i = 0; i < ed->count; ++i) + if (ed->all[i].str == string) + return 1; + + return 0; +} diff --git a/legacy/eet/src/lib/eet_lib.c b/legacy/eet/src/lib/eet_lib.c index 6e74d10a9e..64e8a87911 100644 --- a/legacy/eet/src/lib/eet_lib.c +++ b/legacy/eet/src/lib/eet_lib.c @@ -814,7 +814,9 @@ eet_internal_read2(Eet_File *ef) if (eet_test_close(!ef->ed->all, ef)) return NULL; ef->ed->count = num_dictionary_entries; - + ef->ed->start = start + bytes_dictionary_entries + bytes_directory_entries; + ef->ed->end = ef->ed->start; + for (j = 0; j < ef->ed->count; ++j) { int hash; @@ -839,6 +841,9 @@ eet_internal_read2(Eet_File *ef) ef->ed->all[j].mmap = start + offset; ef->ed->all[j].str = NULL; + if (ef->ed->all[j].mmap + ef->ed->all[j].len > ef->ed->end) + ef->ed->end = ef->ed->all[j].mmap + ef->ed->all[j].len; + /* Check '\0' at the end of the string */ if (eet_test_close(ef->ed->all[j].mmap[ef->ed->all[j].len - 1] != '\0', ef)) return NULL;