From 91ebffedfa82e750fbfbcdfcf86b8e3b7cf2c612 Mon Sep 17 00:00:00 2001 From: barbieri Date: Tue, 31 Jul 2012 22:42:03 +0000 Subject: [PATCH] fix edje error reporting for once and for all. edje error was a mess. First someone (maybe myself) added eina log, then people changed it to be a mix with printf()... then they replaced eina_log with printf() + colors so it would be less verbose. It's fixed now! Using eina log infrastructure. If all that is wanted is specific messages for edje_cc domain, do it with a specific log print function (eina_log_print_cb_set()). I made it produce messages in the format: : Where: - levelcolor is defined by eina_log (I hacked the win32 version, since no public api to resolve level to color). - levelprefix is "Error. " or "Warning. " to cope with traditional output. If it does not look as you wanted, let me know before stuffing some printf() again. Bonus point: reduced 2 global variables (progname and verbose), removed lots of code. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@74701 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/edje_cc.c | 93 ++++++++- src/bin/edje_cc.h | 41 ++-- src/bin/edje_cc_handlers.c | 394 +++++++++++++++++--------------------- src/bin/edje_cc_mem.c | 8 +- src/bin/edje_cc_out.c | 249 ++++++++++-------------- src/bin/edje_cc_parse.c | 172 ++++++++--------- src/bin/edje_cc_sources.c | 6 +- src/bin/edje_convert.c | 6 +- src/bin/edje_convert_main.c | 5 +- src/bin/edje_decc.c | 119 ++++++++++-- src/bin/edje_decc.h | 9 + src/bin/edje_multisense_convert.c | 6 +- 12 files changed, 572 insertions(+), 536 deletions(-) diff --git a/src/bin/edje_cc.c b/src/bin/edje_cc.c index bbd5203..d0ec3bd 100644 --- a/src/bin/edje_cc.c +++ b/src/bin/edje_cc.c @@ -19,9 +19,9 @@ Eina_List *defines = NULL; char *file_in = NULL; char *tmp_dir = NULL; char *file_out = NULL; -char *progname = NULL; char *watchfile = NULL; -int verbose = 0; + +static char *progname = NULL; int no_lossy = 0; int no_comp = 0; @@ -33,6 +33,86 @@ int compress_mode = EET_COMPRESSION_DEFAULT; int threads = 0; static void +_edje_cc_log_cb(const Eina_Log_Domain *d, + Eina_Log_Level level, + const char *file, + const char *fnc, + int line, + const char *fmt, + __UNUSED__ void *data, + va_list args) +{ + if ((d->name) && (d->namelen == sizeof("edje_cc") - 1) && + (memcmp(d->name, "edje_cc", sizeof("edje_cc") - 1) == 0)) + { + const char *prefix; + Eina_Bool use_color = !eina_log_color_disable_get(); + + if (use_color) + { +#ifndef _WIN32 + fputs(eina_log_level_color_get(level), stderr); +#else + int color; + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + color = FOREGROUND_RED | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_ERR: + color = FOREGROUND_RED; + break; + case EINA_LOG_LEVEL_WARN: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_INFO: + color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_DBG: + color = FOREGROUND_BLUE | FOREGROUND_INTENSITY; + break; + default: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + } + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); +#endif + } + + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + prefix = "Critical. "; + break; + case EINA_LOG_LEVEL_ERR: + prefix = "Error. "; + break; + case EINA_LOG_LEVEL_WARN: + prefix = "Warning. "; + break; + default: + prefix = ""; + } + fprintf(stderr, "%s: %s", progname, prefix); + + if (use_color) + { +#ifndef _WIN32 + fputs(EINA_COLOR_RESET, stderr); +#else + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); +#endif + } + + + vfprintf(stderr, fmt, args); + putc('\n', stderr); + } + else + eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); +} + +static void main_help(void) { printf @@ -80,6 +160,9 @@ main(int argc, char **argv) EINA_LOG_ERR("Enable to create a log domain."); exit(-1); } + progname = (char *)ecore_file_file_get(argv[0]); + eina_log_print_cb_set(_edje_cc_log_cb, NULL); + tmp_dir = getenv("TMPDIR"); img_dirs = eina_list_append(img_dirs, "."); @@ -87,7 +170,6 @@ main(int argc, char **argv) /* add defines to epp so edc files can detect edje_cc version */ defines = eina_list_append(defines, mem_strdup("-DEDJE_VERSION_12=12")); - progname = (char *)ecore_file_file_get(argv[0]); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h")) @@ -97,7 +179,7 @@ main(int argc, char **argv) } else if (!strcmp(argv[i], "-v")) { - verbose = 1; + eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_INFO); } else if (!strcmp(argv[i], "-no-lossy")) { @@ -186,6 +268,7 @@ main(int argc, char **argv) else if (!file_out) file_out = argv[i]; } + if (!file_in) { fprintf(stderr, "%s: Error: no input file specified.\n", progname); @@ -193,6 +276,8 @@ main(int argc, char **argv) exit(-1); } + + pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */ main, /* an optional symbol to check path of */ "EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */ diff --git a/src/bin/edje_cc.h b/src/bin/edje_cc.h index 4b78382..d9468b6 100644 --- a/src/bin/edje_cc.h +++ b/src/bin/edje_cc.h @@ -18,43 +18,26 @@ extern Eina_Prefix *pfx; extern int _edje_cc_log_dom ; #define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN -#ifdef _WIN32 -# define EDJE_ERR_COLOR FOREGROUND_RED | FOREGROUND_INTENSITY -# define EDJE_INF_COLOR FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY -# define EDJE_WRN_COLOR FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY -# define EDJE_LOG(str, color, ...) do { \ - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), \ - color); \ - printf(str); \ - SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), \ - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); \ - printf(": "); \ - printf(__VA_ARGS__); \ - printf("\n"); \ - } while (0) -#else -# define EDJE_ERR_COLOR "\033[31m" -# define EDJE_INF_COLOR "\033[35m" -# define EDJE_WRN_COLOR "\033[33m" -# define EDJE_LOG(str, color, ...) do { \ - printf("\033[31m"); \ - printf(__VA_ARGS__); \ - printf("\033[0m\n"); } \ - while (0) -#endif - #ifdef ERR # undef ERR #endif -#define ERR(...) EDJE_LOG("ERR", EDJE_ERR_COLOR, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_edje_cc_log_dom, __VA_ARGS__) #ifdef INF # undef INF #endif -#define INF(...) EDJE_LOG("INF", EDJE_INF_COLOR, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_edje_cc_log_dom, __VA_ARGS__) #ifdef WRN # undef WRN #endif -#define WRN(...) EDJE_LOG("WRN", EDJE_WRN_COLOR, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__) +#ifdef CRIT +# undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_edje_cc_log_dom, __VA_ARGS__) +#ifdef DBG +# undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_edje_cc_log_dom, __VA_ARGS__) /* types */ typedef struct _New_Object_Handler New_Object_Handler; @@ -231,9 +214,7 @@ extern Eina_List *snd_dirs; extern char *file_in; extern char *tmp_dir; extern char *file_out; -extern char *progname; extern char *watchfile; -extern int verbose; extern int no_lossy; extern int no_comp; extern int no_raw; diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index ce4b695..eb91ed4 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -976,7 +976,8 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c if (!result) { - ERR("%s: Error. Unknown type %i of part %s in collection %s.", progname, type, part, collection); + ERR("Unknown type %i of part %s in collection %s.", + type, part, collection); exit(-1); } @@ -999,8 +1000,8 @@ _edje_program_check(const char *name, Edje_Program *me, Edje_Program **pgrms, un epp = (Edje_Program_Parser *)pgrms[i]; if (!epp->can_override) { - ERR("%s: Error. parse error %s:%i. There is already a program of the name %s\n", - progname, file_in, line - 1, name); + ERR("parse error %s:%i. There is already a program of the name %s", + file_in, line - 1, name); exit(-1); } else @@ -1078,9 +1079,8 @@ _edje_program_copy(Edje_Program *ep, Edje_Program *ep2) data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); else { - ERR("%s: Error. parse error %s:%i. " - "target may only be used after action", - progname, file_in, line - 1); + ERR("parse error %s:%i. target may only be used after action", + file_in, line - 1); exit(-1); } } @@ -1169,7 +1169,7 @@ st_externals_external(void) 0, sizeof (Edje_External_Directory)); if (!edje_file->external_dir->entries) { - ERR("%s: Error. not enough memory", progname); + ERR("not enough memory"); exit(-1); } @@ -1257,7 +1257,7 @@ st_images_image(void) 0, sizeof (Edje_Image_Directory_Entry)); if (!edje_file->image_dir->entries) { - ERR("%s: Error. No enough memory.", progname); + ERR("No enough memory."); exit(-1); } @@ -1346,7 +1346,7 @@ ob_images_set(void) 0, sizeof (Edje_Image_Directory_Set)); if (!edje_file->image_dir->sets) { - ERR("%s: Error. Not enough memory.", progname); + ERR("Not enough memory."); exit(-1); } edje_file->image_dir->sets[edje_file->image_dir->sets_count - 1].id = edje_file->image_dir->sets_count - 1; @@ -1462,8 +1462,8 @@ st_images_set_image_size(void) if (entry->size.min.w > entry->size.max.w || entry->size.min.h > entry->size.max.h) { - ERR("%s: Error. parse error %s:%i. Image min and max size are not in the right order ([%i, %i] < [%i, %i])", - progname, file_in, line - 1, + ERR("parse error %s:%i. Image min and max size are not in the right order ([%i, %i] < [%i, %i])", + file_in, line - 1, entry->size.min.w, entry->size.min.h, entry->size.max.w, entry->size.max.h); exit(-1); @@ -1601,23 +1601,23 @@ st_data_file(void) fd = open(filename, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) { - ERR("%s: Error. %s:%i when opening file \"%s\": \"%s\"", - progname, file_in, line, filename, strerror(errno)); + ERR("%s:%i when opening file \"%s\": \"%s\"", + file_in, line, filename, strerror(errno)); exit(-1); } if (fstat(fd, &buf)) { - ERR("%s: Error. %s:%i when stating file \"%s\": \"%s\"", - progname, file_in, line, filename, strerror(errno)); + ERR("%s:%i when stating file \"%s\": \"%s\"", + file_in, line, filename, strerror(errno)); exit(-1); } data = mmap(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0); if (data == MAP_FAILED) { - ERR("%s: Error. %s:%i when mapping file \"%s\": \"%s\"", - progname, file_in, line, filename, strerror(errno)); + ERR("%s:%i when mapping file \"%s\": \"%s\"", + file_in, line, filename, strerror(errno)); exit(-1); } @@ -1625,8 +1625,7 @@ st_data_file(void) for (i = 0; i < buf.st_size; ++i, ++over) if (*over == '\0') { - ERR("%s: Error. %s:%i file \"%s\" is a binary file.", - progname, file_in, line, filename); + ERR("%s:%i file \"%s\" is a binary file.", file_in, line, filename); exit(-1); } @@ -1710,8 +1709,8 @@ st_color_class_name(void) { if ((cc != tcc) && (!strcmp(cc->name, tcc->name))) { - fprintf(stderr, "%s: Error. parse error %s:%i. There is already a color class named \"%s\"\n", - progname, file_in, line - 1, cc->name); + ERR("parse error %s:%i. There is already a color class named \"%s\"", + file_in, line - 1, cc->name); exit(-1); } } @@ -1841,8 +1840,8 @@ st_styles_style_name(void) { if (stl->name && tstl->name && (stl != tstl) && (!strcmp(stl->name, tstl->name))) { - ERR("%s: Error. parse error %s:%i. There is already a style named \"%s\"", - progname, file_in, line - 1, stl->name); + ERR("parse error %s:%i. There is already a style named \"%s\"", + file_in, line - 1, stl->name); exit(-1); } } @@ -1868,8 +1867,8 @@ st_styles_style_base(void) stl = eina_list_data_get(eina_list_last(edje_file->styles)); if (stl->tags) { - ERR("%s: Error. parse error %s:%i. There is already a basic format for the style", - progname, file_in, line - 1); + ERR("parse error %s:%i. There is already a basic format for the style", + file_in, line - 1); exit(-1); } tag = mem_alloc(SZ(Edje_Style_Tag)); @@ -2014,7 +2013,7 @@ st_collections_group_sound_sample_name(void) if (!edje_file->sound_dir->samples) { - ERR("%s: Error. No enough memory.", progname); + ERR("No enough memory."); exit(-1); } @@ -2061,7 +2060,7 @@ st_collections_group_sound_sample_source(void) if (!edje_file->sound_dir->samples) { - ERR("%s: Error. Invalid sound sample source definition.", progname); + ERR("Invalid sound sample source definition."); exit(-1); } @@ -2071,7 +2070,7 @@ st_collections_group_sound_sample_source(void) if (!sample) { - ERR("%s: Error. Invalid sound sample source definition.", progname); + ERR("Invalid sound sample source definition."); exit(-1); } sample->snd_src = parse_str(0); @@ -2111,14 +2110,14 @@ st_collections_group_sound_tone(void) { if (!strcmp(edje_file->sound_dir->tones[i].name, tmp)) { - ERR("%s: Error. Tone name: %s already exist.", progname, tmp); + ERR("Tone name: %s already exist.", tmp); free((char *)tmp); exit(-1); } if (edje_file->sound_dir->tones[i].value == value) { - ERR("%s: Error. Tone name %s with same frequency %d exist.", - progname, edje_file->sound_dir->tones[i].name, value); + ERR("Tone name %s with same frequency %d exist.", + edje_file->sound_dir->tones[i].name, value); exit(-1); } } @@ -2130,7 +2129,7 @@ st_collections_group_sound_tone(void) if (!edje_file->sound_dir->tones) { - ERR("%s: Error. No enough memory.", progname); + ERR("No enough memory."); exit(-1); } @@ -2179,7 +2178,7 @@ ob_collections_group(void) if (current_de && !current_de->entry) { - ERR("%p: Error. A collection without a name was detected, that's not allowed.", progname); + ERR("A collection without a name was detected, that's not allowed."); exit(-1); } @@ -2304,16 +2303,16 @@ st_collections_group_inherit(void) } if (!pc2) { - ERR("%s: Error. parse error %s:%i. There isn't a group with the name %s", - progname, file_in, line - 1, parent_name); + ERR("parse error %s:%i. There isn't a group with the name %s", + file_in, line - 1, parent_name); exit(-1); } if (pc2 == pc) { - ERR("%s: Error. parse error %s:%i. You are trying to inherit '%s' from itself. That's not possible." + ERR("parse error %s:%i. You are trying to inherit '%s' from itself. That's not possible." "If there is another group of the same name, you want to inherit from that group and have the" "same name as that group, there is a trick ! Just put the inherit before the directive that set" - "the name !", progname, file_in, line - 1, parent_name); + "the name !", file_in, line - 1, parent_name); exit(-1); } @@ -2704,8 +2703,8 @@ ob_collections_group_script(void) cd->l2 = get_verbatim_line2(); if (cd->shared) { - ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group", - progname, file_in, line - 1); + ERR("parse error %s:%i. There is already an existing script section for the group", + file_in, line - 1); exit(-1); } cd->shared = s; @@ -2735,8 +2734,8 @@ ob_collections_group_lua_script(void) cd->l2 = get_verbatim_line2(); if (cd->shared) { - ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group", - progname, file_in, line - 1); + ERR("parse error %s:%i. There is already an existing script section for the group", + file_in, line - 1); exit(-1); } cd->shared = s; @@ -2845,7 +2844,7 @@ st_collections_group_limits_vertical(void) pc->limits.vertical = realloc(pc->limits.vertical, pc->limits.vertical_count * sizeof (Edje_Limit *)); if (!pc->limits.vertical || !el) { - ERR("%s: Error. Not enough memory.", progname); + ERR("Not enough memory."); exit(-1); } @@ -2883,7 +2882,7 @@ st_collections_group_limits_horizontal(void) pc->limits.horizontal = realloc(pc->limits.horizontal, pc->limits.horizontal_count * sizeof (Edje_Limit *)); if (!pc->limits.horizontal || !el) { - ERR("%s: Error. Not enough memory.", progname); + ERR("Not enough memory."); exit(-1); } @@ -2977,7 +2976,7 @@ ob_collections_group_parts_part(void) pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *)); if (!pc->parts) { - ERR("%s: Error. Not enough memory.", progname); + ERR("Not enough memory."); exit(-1); } current_part = pc->parts[pc->parts_count - 1] = ep; @@ -3044,8 +3043,8 @@ st_collections_group_parts_part_name(void) epp = (Edje_Part_Parser *)pc->parts[i]; if (!epp->can_override) { - ERR("%s: Error. parse error %s:%i. There is already a part of the name %s", - progname, file_in, line - 1, ep->name); + ERR("parse error %s:%i. There is already a part of the name %s", + file_in, line - 1, ep->name); exit(-1); } else @@ -3866,9 +3865,8 @@ static void ob_collections_group_parts_part_box_items_item(void) if ((ep->type != EDJE_PART_TYPE_BOX) && (ep->type != EDJE_PART_TYPE_TABLE)) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX or TABLE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. box attributes in non-BOX or TABLE part.", + file_in, line - 1); exit(-1); } @@ -3876,7 +3874,7 @@ static void ob_collections_group_parts_part_box_items_item(void) ep->items = realloc(ep->items, sizeof (Edje_Pack_Element*) * ep->items_count); if (!ep->items) { - ERR("%s: Error. Not enough memory.", progname); + ERR("Not enough memory."); exit(-1); } @@ -3931,9 +3929,8 @@ static void st_collections_group_parts_part_box_items_item_type(void) s = parse_str(0); if (strcmp(s, "GROUP")) { - ERR("%s: Error. parse error %s:%i. " - "token %s not one of: GROUP.", - progname, file_in, line - 1, s); + ERR("parse error %s:%i. token %s not one of: GROUP.", + file_in, line - 1, s); exit(-1); } /* FIXME: handle the enum, once everything else is supported */ @@ -3974,8 +3971,8 @@ static void st_collections_group_parts_part_box_items_item_name(void) pitem = (Edje_Pack_Element_Parser *)ep->items[i]; if (!pitem->can_override) { - ERR("%s: Error. parse error %s:%i. There is already a item of the name %s", - progname, file_in, line - 1, item->name); + ERR("parse error %s:%i. There is already a item of the name %s", + file_in, line - 1, item->name); exit(-1); } else @@ -4193,9 +4190,8 @@ static void st_collections_group_parts_part_table_items_item_position(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); exit(-1); } @@ -4220,9 +4216,8 @@ static void st_collections_group_parts_part_table_items_item_span(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); exit(-1); } @@ -4367,9 +4362,8 @@ st_collections_group_parts_part_description_inherit(void) if (!ed->state.name) { - ERR("%s: Error. parse error %s:%i. " - "inherit may only be used after state", - progname, file_in, line - 1); + ERR("parse error %s:%i. inherit may only be used after state", + file_in, line - 1); exit(-1); } @@ -4381,9 +4375,9 @@ st_collections_group_parts_part_description_inherit(void) /* inherit may not be used in the default description */ if (!ep->other.desc_count) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "inherit may not be used in the default description", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } @@ -4429,9 +4423,9 @@ st_collections_group_parts_part_description_inherit(void) if (!parent) { - ERR("%s: Error. parse error %s:%i. " - "cannot find referenced part state %s %lf", - ep->name, file_in, line - 1, parent_name, parent_val); + ERR("parse error %s:%i. " + "cannot find referenced part %s state %s %lf", + file_in, line - 1, ep->name, parent_name, parent_val); exit(-1); } @@ -4590,9 +4584,8 @@ st_collections_group_parts_part_description_source(void) if (current_part->type != EDJE_PART_TYPE_PROXY) { - ERR("%s: Error. parse error %s:%i. " - "source attributes in non-PROXY part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. source attributes in non-PROXY part.", + file_in, line - 1); exit(-1); } @@ -4635,9 +4628,8 @@ st_collections_group_parts_part_description_state(void) s = parse_str(0); if (!strcmp (s, "custom")) { - ERR("%s: Error. parse error %s:%i. " - "invalid state name: '%s'.", - progname, file_in, line - 1, s); + ERR("parse error %s:%i. invalid state name: '%s'.", + file_in, line - 1, s); exit(-1); } @@ -4701,9 +4693,8 @@ st_collections_group_parts_part_description_visible(void) if (current_part->type == EDJE_PART_TYPE_SPACER) { - ERR("%s: Error. parse error %s:%i. " - "SPACER part can't have a visibility defined", - progname, file_in, line - 1); + ERR("parse error %s:%i. SPACER part can't have a visibility defined", + file_in, line - 1); exit(-1); } @@ -4820,9 +4811,9 @@ st_collections_group_parts_part_description_min(void) if ((current_part->type != EDJE_PART_TYPE_IMAGE && current_part->type != EDJE_PART_TYPE_GROUP) || !tmp || strcmp(tmp, "SOURCE") != 0) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "Only IMAGE and GROUP part can have a min: SOURCE; defined", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } @@ -4880,9 +4871,9 @@ st_collections_group_parts_part_description_max(void) if (current_part->type != EDJE_PART_TYPE_IMAGE || !tmp || strcmp(tmp, "SOURCE") != 0) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "Only IMAGE part can have a max: SOURCE; defined", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } @@ -4978,9 +4969,8 @@ st_collections_group_parts_part_description_color_class(void) if (current_part->type == EDJE_PART_TYPE_SPACER) { - ERR("%s: Error. parse error %s:%i. " - "SPACER part can't have a color defined", - progname, file_in, line - 1); + ERR("parse error %s:%i. SPACER part can't have a color defined", + file_in, line - 1); exit(-1); } @@ -5004,9 +4994,8 @@ st_collections_group_parts_part_description_color(void) if (current_part->type == EDJE_PART_TYPE_SPACER) { - ERR("%s: Error. parse error %s:%i. " - "SPACER part can't have a color defined", - progname, file_in, line - 1); + ERR("parse error %s:%i. SPACER part can't have a color defined", + file_in, line - 1); exit(-1); } @@ -5033,9 +5022,8 @@ st_collections_group_parts_part_description_color2(void) if (current_part->type == EDJE_PART_TYPE_SPACER) { - ERR("%s: Error. parse error %s:%i. " - "SPACER part can't have a color defined", - progname, file_in, line - 1); + ERR("parse error %s:%i. SPACER part can't have a color defined", + file_in, line - 1); exit(-1); } @@ -5068,7 +5056,8 @@ st_collections_group_parts_part_description_color3(void) if (current_part->type != EDJE_PART_TYPE_TEXT && current_part->type != EDJE_PART_TYPE_TEXTBLOCK) { - ERR("%s: Error. Setting color3 in part %s from %s not of type TEXT or TEXTBLOCK.", progname, current_part->name, pc->part); + ERR("Setting color3 in part %s from %s not of type TEXT or TEXTBLOCK.", + current_part->name, pc->part); exit(-1); } @@ -5349,9 +5338,9 @@ st_collections_group_parts_part_description_image_normal(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } @@ -5389,9 +5378,8 @@ st_collections_group_parts_part_description_image_tween(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); exit(-1); } @@ -5434,9 +5422,8 @@ st_collections_group_parts_part_description_image_border(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); exit(-1); } @@ -5469,9 +5456,8 @@ st_collections_group_parts_part_description_image_middle(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); exit(-1); } @@ -5512,9 +5498,8 @@ st_collections_group_parts_part_description_image_border_scale_by(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); exit(-1); } @@ -5543,9 +5528,8 @@ st_collections_group_parts_part_description_image_border_scale(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); exit(-1); } @@ -5577,9 +5561,8 @@ st_collections_group_parts_part_description_image_scale_hint(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); exit(-1); } @@ -5659,9 +5642,9 @@ st_collections_group_parts_part_description_fill_smooth(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY `%s` part (%i).", - progname, file_in, line - 1, current_part->name, current_part->type); + file_in, line - 1, current_part->name, current_part->type); exit(-1); } } @@ -5693,9 +5676,8 @@ st_collections_group_parts_part_description_fill_spread(void) /* XXX this will need to include IMAGES when spread support is added to evas images */ { - ERR("%s: Error. parse error %s:%i. " - "fill.spread not supported yet.", - progname, file_in, line - 1); + ERR("parse error %s:%i. fill.spread not supported yet.", + file_in, line - 1); exit(-1); } @@ -5706,9 +5688,8 @@ st_collections_group_parts_part_description_fill_spread(void) if (ep->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); exit(-1); } @@ -5759,9 +5740,9 @@ st_collections_group_parts_part_description_fill_type(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5832,9 +5813,9 @@ st_collections_group_parts_part_description_fill_origin_relative(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5882,9 +5863,9 @@ st_collections_group_parts_part_description_fill_origin_offset(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5955,9 +5936,9 @@ st_collections_group_parts_part_description_fill_size_relative(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -6005,9 +5986,9 @@ st_collections_group_parts_part_description_fill_size_offset(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -6069,9 +6050,8 @@ st_collections_group_parts_part_description_text_text(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6116,9 +6096,8 @@ st_collections_group_parts_part_description_text_text_class(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6149,9 +6128,8 @@ st_collections_group_parts_part_description_text_font(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6182,9 +6160,8 @@ st_collections_group_parts_part_description_text_style(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6216,9 +6193,8 @@ st_collections_group_parts_part_description_text_repch(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6249,9 +6225,8 @@ st_collections_group_parts_part_description_text_size(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6283,9 +6258,8 @@ st_collections_group_parts_part_description_text_size_range(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6295,9 +6269,8 @@ st_collections_group_parts_part_description_text_size_range(void) ed->text.size_range_max = parse_int_range(1, 0, 255); if (ed->text.size_range_min > ed->text.size_range_max) { - ERR("%s: Error. parse error %s:%i. " - "min size is bigger than max size.", - progname, file_in, line - 1); + ERR("parse error %s:%i. min size is bigger than max size.", + file_in, line - 1); exit(-1); } } @@ -6324,9 +6297,8 @@ st_collections_group_parts_part_description_text_fit(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6359,9 +6331,8 @@ st_collections_group_parts_part_description_text_min(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6394,9 +6365,8 @@ st_collections_group_parts_part_description_text_max(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6428,9 +6398,8 @@ st_collections_group_parts_part_description_text_align(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6465,9 +6434,8 @@ st_collections_group_parts_part_description_text_source(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6507,9 +6475,8 @@ st_collections_group_parts_part_description_text_text_source(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6547,9 +6514,8 @@ st_collections_group_parts_part_description_text_elipsis(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); exit(-1); } @@ -6643,9 +6609,8 @@ static void st_collections_group_parts_part_description_box_layout(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); exit(-1); } @@ -6664,9 +6629,8 @@ static void st_collections_group_parts_part_description_box_align(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); exit(-1); } @@ -6684,9 +6648,8 @@ static void st_collections_group_parts_part_description_box_padding(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); exit(-1); } @@ -6705,9 +6668,8 @@ st_collections_group_parts_part_description_box_min(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); exit(-1); } @@ -6792,9 +6754,8 @@ static void st_collections_group_parts_part_description_table_homogeneous(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); exit(-1); } @@ -6815,9 +6776,8 @@ static void st_collections_group_parts_part_description_table_align(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); exit(-1); } @@ -6835,9 +6795,8 @@ static void st_collections_group_parts_part_description_table_padding(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); exit(-1); } @@ -6856,9 +6815,8 @@ st_collections_group_parts_part_description_table_min(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-TABLE part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. box attributes in non-TABLE part.", + file_in, line - 1); exit(-1); } @@ -7265,9 +7223,8 @@ _st_collections_group_parts_part_description_params(Edje_External_Param_Type typ if (current_part->type != EDJE_PART_TYPE_EXTERNAL) { - ERR("%s: Error. parse error %s:%i. " - "params in non-EXTERNAL part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. params in non-EXTERNAL part.", + file_in, line - 1); exit(-1); } @@ -7310,8 +7267,8 @@ _st_collections_group_parts_part_description_params(Edje_External_Param_Type typ param->s = parse_str(1); break; default: - ERR("%s: Error. parse error %s:%i. Invalid param type.\n", - progname, file_in, line - 1); + ERR("parse error %s:%i. Invalid param type.", + file_in, line - 1); break; } @@ -7654,8 +7611,7 @@ st_collections_group_programs_program_action(void) break; if (i == (int)(edje_file->sound_dir->samples_count - 1)) { - ERR("%s: Error. No Sample name %s exist.", progname, - ep->sample_name); + ERR("No Sample name %s exist.", ep->sample_name); exit(-1); } } @@ -7670,8 +7626,7 @@ st_collections_group_programs_program_action(void) break; if (i == (int)(edje_file->sound_dir->tones_count - 1)) { - ERR("%s: Error. No Tone name %s exist.", progname, - ep->tone_name); + ERR("No Tone name %s exist.", ep->tone_name); exit(-1); } } @@ -7835,9 +7790,8 @@ st_collections_group_programs_program_transition(void) current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; else if (get_arg_count() != 2) { - ERR("%s: Error. parse error %s:%i. " - "Need 2rd parameter to set time", - progname, file_in, line - 1); + ERR("parse error %s:%i. Need 2rd parameter to set time", + file_in, line - 1); exit(-1); } } @@ -7853,9 +7807,8 @@ st_collections_group_programs_program_transition(void) current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; else if (get_arg_count() != 3) { - ERR("%s: Error. parse error %s:%i. " - "Need 3rd parameter to set factor", - progname, file_in, line - 1); + ERR("parse error %s:%i. Need 3rd parameter to set factor", + file_in, line - 1); exit(-1); } current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0)); @@ -7872,9 +7825,9 @@ st_collections_group_programs_program_transition(void) current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; else if (get_arg_count() != 4) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "Need 3rd and 4th parameters to set factor and counts", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0)); @@ -7944,9 +7897,8 @@ st_collections_group_programs_program_target(void) data_queue_part_lookup(pc, name, &(et->id)); else { - ERR("%s: Error. parse error %s:%i. " - "target may only be used after action", - progname, file_in, line - 1); + ERR("parse error %s:%i. target may only be used after action", + file_in, line - 1); exit(-1); } free(name); @@ -8059,8 +8011,8 @@ ob_collections_group_programs_program_script(void) cp->original = strdup(s); if (cd->shared && cd->is_lua) { - ERR("%s: Error. parse error %s:%i. You're trying to mix Embryo and Lua scripting in the same group", - progname, file_in, line - 1); + ERR("parse error %s:%i. You're trying to mix Embryo and Lua scripting in the same group", + file_in, line - 1); exit(-1); } cd->is_lua = 0; diff --git a/src/bin/edje_cc_mem.c b/src/bin/edje_cc_mem.c index d2d4ae0..e1fa239 100644 --- a/src/bin/edje_cc_mem.c +++ b/src/bin/edje_cc_mem.c @@ -14,8 +14,8 @@ mem_alloc(size_t size) mem = calloc(1, size); if (mem) return mem; - ERR("%s: Error. %s:%i memory allocation of %zu bytes failed. %s", - progname, file_in, line, size, strerror(errno)); + ERR("%s:%i memory allocation of %zu bytes failed. %s", + file_in, line, size, strerror(errno)); exit(-1); return NULL; } @@ -27,8 +27,8 @@ mem_strdup(const char *s) str = strdup(s); if (str) return str; - ERR("%s: Error. %s:%i memory allocation of %zu bytes failed. %s. string being duplicated: \"%s\"", - progname, file_in, line, strlen(s) + 1, strerror(errno), s); + ERR("%s:%i memory allocation of %zu bytes failed. %s. string being duplicated: \"%s\"", + file_in, line, strlen(s) + 1, strerror(errno), s); exit(-1); return NULL; } diff --git a/src/bin/edje_cc_out.c b/src/bin/edje_cc_out.c index 043d71c..1c22637 100644 --- a/src/bin/edje_cc_out.c +++ b/src/bin/edje_cc_out.c @@ -204,10 +204,9 @@ error_and_abort(Eet_File *ef __UNUSED__, const char *fmt, ...) { va_list ap; - fprintf(stderr, "%s: Error. ", progname); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + eina_log_vprint(_edje_cc_log_dom, EINA_LOG_LEVEL_CRITICAL, + "unknown", "unknown", 0, fmt, ap); va_end(ap); unlink(file_out); exit(-1); @@ -236,7 +235,7 @@ check_image_part_desc(Edje_Part_Collection *pc, Edje_Part *ep, { if (epd->image.tweens[i]->id == -1) error_and_abort(ef, "Collection %i: tween image id missing for " - "part \"%s\", description \"%s\" %f\n", + "part \"%s\", description \"%s\" %f", pc->id, ep->name, epd->common.state.name, epd->common.state.value); } } @@ -250,11 +249,11 @@ check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) { if (ep->items[i]->type == EDJE_PART_TYPE_GROUP && !ep->items[i]->source) error_and_abort(ef, "Collection %i: missing source on packed item " - "of type GROUP in part \"%s\"\n", + "of type GROUP in part \"%s\"", pc->id, ep->name); if (ep->type == EDJE_PART_TYPE_TABLE && (ep->items[i]->col < 0 || ep->items[i]->row < 0)) error_and_abort(ef, "Collection %i: missing col/row on packed item " - "for part \"%s\" of type TABLE\n", + "for part \"%s\" of type TABLE", pc->id, ep->name); } } @@ -263,7 +262,7 @@ static void check_nameless_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Description_Common *ed, Eet_File *ef) { if (!ed->state.name) - error_and_abort(ef, "Collection %i: description with state missing on part \"%s\"\n", + error_and_abort(ef, "Collection %i: description with state missing on part \"%s\"", pc->id, ep->name); } @@ -274,7 +273,7 @@ check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) /* FIXME: check image set and sort them. */ if (!ep->default_desc) error_and_abort(ef, "Collection %i: default description missing " - "for part \"%s\"\n", pc->id, ep->name); + "for part \"%s\"", pc->id, ep->name); for (i = 0; i < ep->other.desc_count; ++i) check_nameless_state(pc, ep, ep->other.desc[i], ef); @@ -293,7 +292,7 @@ check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) /* FIXME: When mask are supported remove this check */ if (ep->clip_to_id != -1 && pc->parts[ep->clip_to_id]->type != EDJE_PART_TYPE_RECTANGLE) - error_and_abort(ef, "Collection %i: clip_to point to a non RECT part '%s' !\n", + error_and_abort(ef, "Collection %i: clip_to point to a non RECT part '%s' !", pc->id, pc->parts[ep->clip_to_id]->name); } @@ -309,7 +308,7 @@ check_program(Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef) case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: if (!ep->targets) error_and_abort(ef, "Collection %i: target missing in program " - "\"%s\"\n", pc->id, ep->name); + "\"%s\"", pc->id, ep->name); break; default: break; @@ -337,7 +336,7 @@ data_thread_head(void *data, Ecore_Thread *thread __UNUSED__) if (!ce->entry) { snprintf(buf, sizeof(buf), - "Collection %i: name missing.\n", ce->id); + "Collection %i: name missing.", ce->id); hw->errstr = strdup(buf); return; } @@ -356,7 +355,7 @@ data_thread_head(void *data, Ecore_Thread *thread __UNUSED__) if (!sce) { snprintf(buf, sizeof(buf), - "Collection %s (%i) can't find an correct alias.\n", + "Collection %s (%i) can't find an correct alias.", ce->entry, ce->id); hw->errstr = strdup(buf); return; @@ -370,16 +369,15 @@ data_thread_head(void *data, Ecore_Thread *thread __UNUSED__) if (bytes <= 0) { snprintf(buf, sizeof(buf), - "Unable to write \"edje_file\" entry to \"%s\" \n", + "Unable to write \"edje_file\" entry to \"%s\"", file_out); hw->errstr = strdup(buf); return; } } - if (verbose) - printf("%s: Wrote %9i bytes (%4iKb) for \"edje_file\" header\n", - progname, bytes, (bytes + 512) / 1024); + INF("Wrote %9i bytes (%4iKb) for \"edje_file\" header", + bytes, (bytes + 512) / 1024); } static void @@ -453,7 +451,7 @@ data_thread_fonts(void *data, Ecore_Thread *thread __UNUSED__) { if (f) eina_file_close(f); snprintf(buf, sizeof(buf), - "Unable to load font part \"%s\" entry to %s \n", + "Unable to load font part \"%s\" entry to %s", fc->fn->file, file_out); fc->errstr = strdup(buf); return; @@ -468,16 +466,15 @@ data_thread_fonts(void *data, Ecore_Thread *thread __UNUSED__) eina_file_close(f); snprintf(buf2, sizeof(buf2), "Unable to write font part \"%s\" as \"%s\" " - "part entry to %s \n", fc->fn->file, buf, file_out); + "part entry to %s", fc->fn->file, buf, file_out); fc->errstr = strdup(buf2); return; } - if (verbose) - printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]\n", - progname, bytes, (bytes + 512) / 1024, buf, fc->fn->file, - 100 - (100 * (double)bytes) / ((double)(eina_file_size_get(f))) - ); + INF("Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]", + bytes, (bytes + 512) / 1024, buf, fc->fn->file, + 100 - (100 * (double)bytes) / ((double)(eina_file_size_get(f))) + ); eina_file_map_free(f, m); eina_file_close(f); } @@ -607,7 +604,7 @@ error_and_abort_image_load_error(Eet_File *ef, const char *file, int error) } show_err: error_and_abort - (ef, "Unable to load image \"%s\" used by file \"%s\": %s.%s\n", + (ef, "Unable to load image \"%s\" used by file \"%s\": %s.%s", file, file_out, errmsg, hint); } @@ -691,7 +688,7 @@ data_thread_image(void *data, Ecore_Thread *thread __UNUSED__) snprintf(buf2, sizeof(buf2), "Unable to write image part " "\"%s\" as \"%s\" part entry to " - "%s\n", iw->img->entry, buf, file_out); + "%s", iw->img->entry, buf, file_out); iw->errstr = strdup(buf2); return; } @@ -701,18 +698,18 @@ data_thread_image(void *data, Ecore_Thread *thread __UNUSED__) snprintf(buf2, sizeof(buf2), "Unable to load image part " "\"%s\" as \"%s\" part entry to " - "%s\n", iw->img->entry, buf, file_out); + "%s", iw->img->entry, buf, file_out); iw->errstr = strdup(buf2); return; } - if (verbose) + if (eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_INFO)) { struct stat st; if (!iw->path || (stat(iw->path, &st))) st.st_size = 0; - printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]\n", - progname, bytes, (bytes + 512) / 1024, buf, iw->img->entry, + INF("Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]", + bytes, (bytes + 512) / 1024, buf, iw->img->entry, 100 - (100 * (double)bytes) / ((double)(iw->w * iw->h * 4)), 100 - (100 * (double)bytes) / ((double)(st.st_size)) ); @@ -765,8 +762,7 @@ data_write_images(Eet_File *ef, int *image_num) ecore_evas_init(); ee = ecore_evas_buffer_new(1, 1); if (!ee) - error_and_abort(ef, "Cannot create buffer engine canvas for image " - "load.\n"); + error_and_abort(ef, "Cannot create buffer engine canvas for image load."); evas = ecore_evas_get(ee); for (i = 0; i < (int)edje_file->image_dir->entries_count; i++) @@ -878,8 +874,7 @@ data_thread_sounds(void *data, Ecore_Thread *thread __UNUSED__) #endif if (!f) { - ERR("%s: Error: Unable to load sound data of: %s", - progname, sw->sample->name); + ERR("Unable to load sound data of: %s", sw->sample->name); exit(-1); } @@ -891,8 +886,8 @@ data_thread_sounds(void *data, Ecore_Thread *thread __UNUSED__) EET_COMPRESSION_NONE); if (eina_file_map_faulted(f, m)) { - ERR("%s: Error: File access error when reading '%s'", - progname, eina_file_filename_get(f)); + ERR("File access error when reading '%s'", + eina_file_filename_get(f)); exit(-1); } eina_file_map_free(f, m); @@ -903,18 +898,16 @@ data_thread_sounds(void *data, Ecore_Thread *thread __UNUSED__) //If encoded temporary file, delete it. if (enc_info->encoded) unlink(enc_info->file); #endif - if (verbose) - { #ifdef HAVE_LIBSNDFILE - printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry" - "\"%s\" \n", progname, bytes, (bytes + 512) / 1024, - sndid_str, enc_info->comp_type, sw->sample->name); + INF("Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry \"%s\"", + bytes, (bytes + 512) / 1024, + sndid_str, enc_info->comp_type, sw->sample->name); #else - printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry" - "\"%s\" \n", progname, bytes, (bytes + 512) / 1024, - sndid_str, "RAW PCM", sw->sample->name); + INF("Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry \"%s\"", + bytes, (bytes + 512) / 1024, + sndid_str, "RAW PCM", sw->sample->name); #endif - } + #ifdef HAVE_LIBSNDFILE if ((enc_info->file) && (!enc_info->encoded)) eina_stringshare_del(enc_info->file); @@ -1002,15 +995,14 @@ data_thread_group(void *data, Ecore_Thread *thread __UNUSED__) if (bytes <= 0) { snprintf(buf2, sizeof(buf2), - "Error. Unable to write \"%s\" part entry to %s\n", + "Unable to write \"%s\" part entry to %s", buf, file_out); gw->errstr = strdup(buf2); return; } - - if (verbose) - printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" aka \"%s\" collection entry\n", - progname, bytes, (bytes + 512) / 1024, buf, gw->pc->part); + + INF("Wrote %9i bytes (%4iKb) for \"%s\" aka \"%s\" collection entry", + bytes, (bytes + 512) / 1024, buf, gw->pc->part); } static void @@ -1040,8 +1032,7 @@ data_write_groups(Eet_File *ef, int *collection_num) gw = calloc(1, sizeof(Group_Write)); if (!gw) { - error_and_abort(ef, - "Error. Cannot allocate memory for group writer\n"); + error_and_abort(ef, "Cannot allocate memory for group writer"); return; } gw->ef = ef; @@ -1064,7 +1055,7 @@ create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd) FILE *f = fdopen(fd, "wb"); if (!f) error_and_abort(ef, "Unable to open temp file \"%s\" for script " - "compilation.\n", filename); + "compilation.", filename); Eina_List *ll; Code_Program *cp; @@ -1148,7 +1139,7 @@ data_thread_script(void *data, Ecore_Thread *thread __UNUSED__) if (!f) { snprintf(buf, sizeof(buf), - "Unable to open script object \"%s\" for reading.\n", + "Unable to open script object \"%s\" for reading.", sc->tmpo); sc->errstr = strdup(buf); return; @@ -1167,7 +1158,7 @@ data_thread_script(void *data, Ecore_Thread *thread __UNUSED__) if (fread(dat, size, 1, f) != 1) { snprintf(buf, sizeof(buf), - "Unable to read all of script object \"%s\"\n", + "Unable to read all of script object \"%s\"", sc->tmpo); sc->errstr = strdup(buf); return; @@ -1180,7 +1171,7 @@ data_thread_script(void *data, Ecore_Thread *thread __UNUSED__) else { snprintf(buf, sizeof(buf), - "Alloc failed for %lu bytes\n", (unsigned long)size); + "Alloc failed for %lu bytes", (unsigned long)size); sc->errstr = strdup(buf); return; } @@ -1238,7 +1229,7 @@ data_scripts_exe_del_cb(void *data __UNUSED__, int evtype __UNUSED__, void *evin if (ecore_exe_data_get(ev->exe) != sc) return ECORE_CALLBACK_RENEW; if (ev->exit_code != 0) { - error_and_abort(sc->ef, "Compiling script code not clean.\n"); + error_and_abort(sc->ef, "Compiling script code not clean."); return ECORE_CALLBACK_CANCEL; } if (threads) @@ -1288,14 +1279,14 @@ data_write_scripts(Eet_File *ef) sc->tmpn_fd = mkstemp(sc->tmpn); if (sc->tmpn_fd < 0) error_and_abort(ef, "Unable to open temp file \"%s\" for script " - "compilation.\n", sc->tmpn); + "compilation.", sc->tmpn); snprintf(sc->tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir); sc->tmpo_fd = mkstemp(sc->tmpo); if (sc->tmpo_fd < 0) { unlink(sc->tmpn); error_and_abort(ef, "Unable to open temp file \"%s\" for script " - "compilation.\n", sc->tmpn); + "compilation.", sc->tmpn); } create_script_file(ef, sc->tmpn, cd, sc->tmpn_fd); snprintf(buf, sizeof(buf), @@ -1354,7 +1345,7 @@ _edje_lua_error_and_abort(lua_State *L, int err_code, Script_Write *sc) break; } snprintf(buf, sizeof(buf), - "Lua %s error: %s\n", err_type, lua_tostring(L, -1)); + "Lua %s error: %s", err_type, lua_tostring(L, -1)); sc->errstr = strdup(buf); } @@ -1377,7 +1368,7 @@ data_thread_lua_script(void *data, Ecore_Thread *thread __UNUSED__) if (!L) { snprintf(buf, sizeof(buf), - "Lua error: Lua state could not be initialized\n"); + "Lua error: Lua state could not be initialized"); sc->errstr = strdup(buf); return; } @@ -1444,7 +1435,7 @@ data_thread_lua_script(void *data, Ecore_Thread *thread __UNUSED__) if (eet_write(sc->ef, buf, dat.buf, dat.size, compress_mode) <= 0) { snprintf(buf, sizeof(buf), - "Unable to write script %i\n", sc->i); + "Unable to write script %i", sc->i); sc->errstr = strdup(buf); return; } @@ -1540,16 +1531,14 @@ data_write(void) if (!edje_file) { - ERR("%s: Error. No data to put in \"%s\"", - progname, file_out); + ERR("No data to put in \"%s\"", file_out); exit(-1); } ef = eet_open(file_out, EET_FILE_MODE_WRITE); if (!ef) { - ERR("%s: Error. Unable to open \"%s\" for writing output", - progname, file_out); + ERR("Unable to open \"%s\" for writing output", file_out); exit(-1); } @@ -1560,25 +1549,15 @@ data_write(void) pending_threads++; t = ecore_time_get(); data_write_header(ef); - if (verbose) - { - printf("header: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + + INF("header: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_groups(ef, &collection_num); - if (verbose) - { - printf("groups: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("groups: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_scripts(ef); - if (verbose) - { - printf("scripts: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("scripts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_lua_scripts(ef); - if (verbose) - { - printf("lua scripts: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("lua scripts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); + pending_threads++; if (threads) ecore_thread_run(data_thread_source, data_thread_source_end, NULL, ef); @@ -1587,10 +1566,7 @@ data_write(void) data_thread_source(ef, NULL); data_thread_source_end(ef, NULL); } - if (verbose) - { - printf("source: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("source: %3.5f", ecore_time_get() - t); t = ecore_time_get(); pending_threads++; if (threads) ecore_thread_run(data_thread_fontmap, data_thread_fontmap_end, NULL, ef); @@ -1599,45 +1575,32 @@ data_write(void) data_thread_fontmap(ef, NULL); data_thread_fontmap_end(ef, NULL); } - if (verbose) - { - printf("fontmap: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("fontmap: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_images(ef, &image_num); - if (verbose) - { - printf("images: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("images: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_fonts(ef, &font_num); - if (verbose) - { - printf("fonts: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_sounds(ef, &sound_num); - if (verbose) - { - printf("sounds: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get(); pending_threads--; if (pending_threads > 0) ecore_main_loop_begin(); - if (verbose) - { - printf("THREADS: %3.5f\n", ecore_time_get() - t); t = ecore_time_get(); - } + INF("THREADS: %3.5f", ecore_time_get() - t); t = ecore_time_get(); eet_close(ef); - if (verbose) - printf("Summary:\n" - " Wrote %i collections\n" - " Wrote %i images\n" - " Wrote %i sounds\n" - " Wrote %i fonts\n" - , - collection_num, - image_num, - sound_num, - font_num); + if (eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_INFO)) + { + printf("Summary:\n" + " Wrote %i collections\n" + " Wrote %i images\n" + " Wrote %i sounds\n" + " Wrote %i fonts\n" + , + collection_num, + image_num, + sound_num, + font_num); + } } void @@ -1658,7 +1621,7 @@ reorder_parts(void) { ep = (Edje_Part_Parser *)pc->parts[i]; if (ep->reorder.insert_before && ep->reorder.insert_after) - ERR("%s: Error. Unable to use together insert_before and insert_after in part \"%s\".", progname, pc->parts[i]->name); + ERR("Unable to use together insert_before and insert_after in part \"%s\".", pc->parts[i]->name); if (ep->reorder.done) { @@ -1674,9 +1637,11 @@ reorder_parts(void) { ep2 = (Edje_Part_Parser *)pc->parts[j]; if (ep2->reorder.after) - ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name); + ERR("The part \"%s\" is ambiguous ordered part.", + pc->parts[i]->name); if (ep2->reorder.linked_prev) - ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name); + ERR("Unable to insert two or more parts in same part \"%s\".", + pc->parts[j]->name); k = j - 1; found = EINA_TRUE; ep2->reorder.linked_prev += ep->reorder.linked_prev + 1; @@ -1693,9 +1658,9 @@ reorder_parts(void) { ep2 = (Edje_Part_Parser *)pc->parts[j]; if (ep2->reorder.before) - ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name); + ERR("The part \"%s\" is ambiguous ordered part.", pc->parts[i]->name); if (ep2->reorder.linked_next) - ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name); + ERR("Unable to insert two or more parts in same part \"%s\".", pc->parts[j]->name); k = j; found = EINA_TRUE; ep2->reorder.linked_next += ep->reorder.linked_next + 1; @@ -1714,8 +1679,7 @@ reorder_parts(void) if (((i > k) && ((i - ep->reorder.linked_prev) <= k)) || ((i < k) && ((i + ep->reorder.linked_next) >= k))) - ERR("%s: Error. The part order is wrong. It has circular dependency.", - progname); + ERR("The part order is wrong. It has circular dependency."); amount = ep->reorder.linked_prev + ep->reorder.linked_next + 1; linked = i - ep->reorder.linked_prev; @@ -2175,8 +2139,8 @@ data_process_lookups(void) if (i == part->pc->parts_count) { - ERR("%s: Error. Unable to find part name \"%s\" needed in group '%s'.", - progname, alias, part->pc->part); + ERR("Unable to find part name \"%s\" needed in group '%s'.", + alias, part->pc->part); exit(-1); } } @@ -2217,11 +2181,10 @@ data_process_lookups(void) if (!find) { if (!program->anonymous) - ERR("%s: Error. Unable to find program name \"%s\".", - progname, program->u.name); + ERR("Unable to find program name \"%s\".", + program->u.name); else - ERR("%s: Error. Unable to find anonymous program.", - progname); + ERR("Unable to find anonymous program."); exit(-1); } @@ -2260,8 +2223,7 @@ data_process_lookups(void) if (!de) { - ERR("%s: Error. Unable to find group name \"%s\".", - progname, group->name); + ERR("Unable to find group name \"%s\".", group->name); exit(-1); } @@ -2333,8 +2295,7 @@ free_group: if (!find) { - ERR("%s: Error. Unable to find image name \"%s\".", - progname, image->name); + ERR("Unable to find image name \"%s\".", image->name); exit(-1); } @@ -2355,14 +2316,8 @@ free_group: if (de->entry && eina_hash_find(images_in_use, de->entry)) continue ; - if (verbose) - { - printf("%s: Image '%s' in ressource 'edje/image/%i' will not be included as it is unused.\n", progname, de->entry, de->id); - } - else - { - INF("Image '%s' in ressource 'edje/image/%i' will not be included as it is unused.", de->entry, de->id); - } + INF("Image '%s' in resource 'edje/image/%i' will not be included as it is unused.", + de->entry, de->id); de->entry = NULL; } @@ -2374,14 +2329,7 @@ free_group: if (set->name && eina_hash_find(images_in_use, set->name)) continue ; - if (verbose) - { - printf("%s: Set '%s' will not be included as it is unused.\n", progname, set->name); - } - else - { - INF("Set '%s' will not be included as it is unused.", set->name); - } + INF("Set '%s' will not be included as it is unused.", set->name); set->name = NULL; set->entries = NULL; @@ -2607,8 +2555,7 @@ data_process_script_lookups(void) n = eina_convert_itoa(cl->val, buf); if (n > cl->len) { - ERR("%s: Error. The unexpected happened. A numeric replacement string was larger than the original!", - progname); + ERR("The unexpected happened. A numeric replacement string was larger than the original!"); exit(-1); } memset(cl->ptr, ' ', cl->len); diff --git a/src/bin/edje_cc_parse.c b/src/bin/edje_cc_parse.c index a9a5f22..d315790 100644 --- a/src/bin/edje_cc_parse.c +++ b/src/bin/edje_cc_parse.c @@ -163,8 +163,8 @@ new_object(void) sh = eina_hash_find(_new_statement_hash, id); if (!sh) { - ERR("%s: Error. %s:%i unhandled keyword %s", - progname, file_in, line - 1, + ERR("%s:%i unhandled keyword %s", + file_in, line - 1, (char *)eina_list_data_get(eina_list_last(stack))); err_show(); exit(-1); @@ -188,8 +188,8 @@ new_statement(void) } else { - ERR("%s: Error. %s:%i unhandled keyword %s", - progname, file_in, line - 1, + ERR("%s:%i unhandled keyword %s", + file_in, line - 1, (char *)eina_list_data_get(eina_list_last(stack))); err_show(); exit(-1); @@ -286,8 +286,8 @@ next_token(char *p, char *end, char **new_p, int *delim) tmpstr = alloca(l + 1); if (!tmpstr) { - ERR("%s: Error. %s:%i malloc %i bytes failed", - progname, file_in, line - 1, l + 1); + ERR("%s:%i malloc %i bytes failed", + file_in, line - 1, l + 1); exit(-1); } strncpy(tmpstr, p, l); @@ -467,8 +467,8 @@ stack_chop_top(void) } else { - ERR("%s: Error. parse error %s:%i. } marker without matching { marker", - progname, file_in, line - 1); + ERR("parse error %s:%i. } marker without matching { marker", + file_in, line - 1); err_show(); exit(-1); } @@ -481,11 +481,8 @@ parse(char *data, off_t size) int delim = 0; int do_params = 0; - if (verbose) - { - INF("%s: Parsing input file", - progname); - } + DBG("Parsing input file"); + p = data; end = data + size; line = 1; @@ -496,8 +493,8 @@ parse(char *data, off_t size) */ if (do_params && delim && *token != ';') { - ERR("%s: Error. parse error %s:%i. %c marker before ; marker", - progname, file_in, line - 1, *token); + ERR("parse error %s:%i. %c marker before ; marker", + file_in, line - 1, *token); err_show(); exit(-1); } @@ -508,9 +505,9 @@ parse(char *data, off_t size) { if (do_params) { - ERR("%s: Error. parse error %s:%i. } marker before ; marker", - progname, file_in, line - 1); - err_show(); + ERR("Parse error %s:%i. } marker before ; marker", + file_in, line - 1); + err_show(); exit(-1); } else @@ -536,8 +533,8 @@ parse(char *data, off_t size) { if (do_params) { - ERR("%s: Error. parse error %s:%i. { marker before ; marker", - progname, file_in, line - 1); + ERR("parse error %s:%i. { marker before ; marker", + file_in, line - 1); err_show(); exit(-1); } @@ -620,8 +617,8 @@ parse(char *data, off_t size) } else { - ERR("%s: Error. parse error %s:%i. { marker does not have matching } marker", - progname, file_in, line - 1); + ERR("Parse error %s:%i. { marker does not have matching } marker", + file_in, line - 1); err_show(); exit(-1); } @@ -631,11 +628,8 @@ parse(char *data, off_t size) } } } - if (verbose) - { - INF("%s: Parsing done", - progname); - } + + DBG("Parsing done"); } static char *clean_file = NULL; @@ -750,14 +744,14 @@ compile(void) } else { - ERR("Error. Cannot run epp: %s", buf2); + ERR("Cannot run epp: %s", buf2); exit(-1); } if (ret == EXIT_SUCCESS) file_in = tmpn; else { - ERR("Error. Exit code of epp not clean: %i", ret); + ERR("Exit code of epp not clean: %i", ret); exit(-1); } free(def); @@ -765,14 +759,11 @@ compile(void) fd = open(file_in, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) { - ERR("%s: Error. cannot open file \"%s\" for input. %s", - progname, file_in, strerror(errno)); + ERR("Cannot open file \"%s\" for input. %s", + file_in, strerror(errno)); exit(-1); } - if (verbose) - { - INF("%s: Opening \"%s\" for input", progname, file_in); - } + DBG("Opening \"%s\" for input", file_in); size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); @@ -781,8 +772,7 @@ compile(void) parse(data, size); else { - ERR("%s: Error. cannot read file \"%s\". %s", - progname, file_in, strerror(errno)); + ERR("Cannot read file \"%s\". %s", file_in, strerror(errno)); exit(-1); } free(data); @@ -792,7 +782,7 @@ compile(void) { if (!stl->name) { - ERR("%s: Error. style must have a name.", progname); + ERR("style must have a name."); exit(-1); } } @@ -818,8 +808,8 @@ is_num(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -843,8 +833,8 @@ parse_str(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -868,8 +858,7 @@ _parse_enum(char *str, va_list va) /* End of the list, nothing matched. */ if (!s) { - fprintf(stderr, "%s: Error. %s:%i token %s not one of:", - progname, file_in, line - 1, str); + ERR("%s:%i token %s not one of:", file_in, line - 1, str); s = va_arg(va2, char *); while (s) { @@ -908,8 +897,8 @@ parse_enum(int n, ...) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -946,8 +935,8 @@ parse_int(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -964,16 +953,16 @@ parse_int_range(int n, int f, int t) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } i = my_atoi(str); if ((i < f) || (i > t)) { - ERR("%s: Error. %s:%i integer %i out of range of %i to %i inclusive", - progname, file_in, line - 1, i, f, t); + ERR("%s:%i integer %i out of range of %i to %i inclusive", + file_in, line - 1, i, f, t); err_show(); exit(-1); } @@ -989,16 +978,16 @@ parse_bool(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } if (!strstrip(str, buf, sizeof (buf))) { - ERR("%s: Error. %s:%i expression is too long", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", + file_in, line - 1); return 0; } @@ -1010,8 +999,8 @@ parse_bool(int n) i = my_atoi(str); if ((i < 0) || (i > 1)) { - ERR("%s: Error. %s:%i integer %i out of range of 0 to 1 inclusive", - progname, file_in, line - 1, i); + ERR("%s:%i integer %i out of range of 0 to 1 inclusive", + file_in, line - 1, i); err_show(); exit(-1); } @@ -1027,8 +1016,8 @@ parse_float(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -1045,16 +1034,16 @@ parse_float_range(int n, double f, double t) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } i = my_atof(str); if ((i < f) || (i > t)) { - ERR("%s: Error. %s:%i float %3.3f out of range of %3.3f to %3.3f inclusive", - progname, file_in, line - 1, i, f, t); + ERR("%s:%i float %3.3f out of range of %3.3f to %3.3f inclusive", + file_in, line - 1, i, f, t); err_show(); exit(-1); } @@ -1074,8 +1063,8 @@ check_arg_count(int required_args) if (num_args != required_args) { - ERR("%s: Error. %s:%i got %i arguments, but expected %i", - progname, file_in, line - 1, num_args, required_args); + ERR("%s:%i got %i arguments, but expected %i", + file_in, line - 1, num_args, required_args); err_show(); exit(-1); } @@ -1088,9 +1077,8 @@ check_min_arg_count(int min_required_args) if (num_args < min_required_args) { - ERR("%s: Error. %s:%i got %i arguments, " - "but expected at least %i", - progname, file_in, line - 1, num_args, min_required_args); + ERR("%s:%i got %i arguments, but expected at least %i", + file_in, line - 1, num_args, min_required_args); err_show(); exit(-1); } @@ -1117,8 +1105,8 @@ my_atoi(const char *s) if (!s) return 0; if (!strstrip(s, buf, sizeof(buf))) { - ERR("%s: Error. %s:%i expression is too long\n", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", + file_in, line - 1); return 0; } _alphai(buf, &res); @@ -1131,8 +1119,8 @@ _deltai(char *s, int *val) if (!val) return NULL; if ('(' != s[0]) { - ERR("%s: Error. %s:%i unexpected character at %s\n", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", + file_in, line - 1, s); return s; } else @@ -1162,8 +1150,8 @@ _funci(char *s, int *val) } else { - ERR("%s: Error. %s:%i unexpected character at %s\n", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", + file_in, line - 1, s); } return s; } @@ -1185,7 +1173,7 @@ _gammai(char *s, int *val) else { s = _funci(s, val); -// ERR("%s: Error. %s:%i unexpected character at %s\n", +// ERR("%s:%i unexpected character at %s", // progname, file_in, line - 1, s); } return s; @@ -1295,8 +1283,7 @@ _calci(char op, int a, int b) case '/': if (0 != b) a /= b; else - ERR("%s: Error. %s:%i divide by zero\n", - progname, file_in, line - 1); + ERR("%s:%i divide by zero", file_in, line - 1); return a; case '*': a *= b; @@ -1304,12 +1291,10 @@ _calci(char op, int a, int b) case '%': if (0 != b) a = a % b; else - ERR("%s: Error. %s:%i modula by zero\n", - progname, file_in, line - 1); + ERR("%s:%i modula by zero", file_in, line - 1); return a; default: - ERR("%s: Error. %s:%i unexpected character '%c'\n", - progname, file_in, line - 1, op); + ERR("%s:%i unexpected character '%c'", file_in, line - 1, op); } return a; } @@ -1326,8 +1311,7 @@ my_atof(const char *s) if (!strstrip(s, buf, sizeof (buf))) { - ERR("%s: Error. %s:%i expression is too long", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", file_in, line - 1); return 0; } _alphaf(buf, &res); @@ -1340,8 +1324,7 @@ _deltaf(char *s, double *val) if (!val) return NULL; if ('(' != s[0]) { - ERR("%s: Error. %s:%i unexpected character at %s", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", file_in, line - 1, s); return s; } else @@ -1370,8 +1353,7 @@ _funcf(char *s, double *val) } else { - ERR("%s: Error. %s:%i unexpected character at %s\n", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", file_in, line - 1, s); } return s; } @@ -1394,7 +1376,7 @@ _gammaf(char *s, double *val) else { s = _funcf(s, val); -// ERR("%s: Error. %s:%i unexpected character at %s\n", +// ERR("%s:%i unexpected character at %s", // progname, file_in, line - 1, s); } return s; @@ -1508,8 +1490,7 @@ _calcf(char op, double a, double b) case '/': if (b != 0) a /= b; else - ERR("%s: Error. %s:%i divide by zero\n", - progname, file_in, line - 1); + ERR("%s:%i divide by zero", file_in, line - 1); return a; case '*': a *= b; @@ -1517,12 +1498,10 @@ _calcf(char op, double a, double b) case '%': if (0 != b) a = (double)((int)a % (int)b); else - ERR("%s: Error. %s:%i modula by zero\n", - progname, file_in, line - 1); + ERR("%s:%i modula by zero", file_in, line - 1); return a; default: - ERR("%s: Error. %s:%i unexpected character '%c'\n", - progname, file_in, line - 1, op); + ERR("%s:%i unexpected character '%c'", file_in, line - 1, op); } return a; } @@ -1532,8 +1511,7 @@ strstrip(const char *in, char *out, size_t size) { if ((size -1 ) < strlen(in)) { - ERR("%s: Error. %s:%i expression is too long", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", file_in, line - 1); return 0; } /* remove spaces and tabs */ diff --git a/src/bin/edje_cc_sources.c b/src/bin/edje_cc_sources.c index ab2f5d9..4a6be70 100644 --- a/src/bin/edje_cc_sources.c +++ b/src/bin/edje_cc_sources.c @@ -66,8 +66,7 @@ source_fetch_file(const char *fil, const char *filname) f = fopen(fil, "rb"); if (!f) { - ERR("%s: Warning. Cannot open file '%s'", - progname, fil); + ERR("Cannot open file '%s'", fil); exit(-1); } @@ -82,8 +81,7 @@ source_fetch_file(const char *fil, const char *filname) tmp = fread(sf->file, sz, 1, f); if (tmp != 1) { - ERR("%s: Warning file length for (%s) doesn't match !", - progname, filname); + ERR("file length for (%s) doesn't match!", filname); exit(-1); } } diff --git a/src/bin/edje_convert.c b/src/bin/edje_convert.c index 63d11ba..bd6cf31 100644 --- a/src/bin/edje_convert.c +++ b/src/bin/edje_convert.c @@ -259,7 +259,7 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, /* Change structure layout */ edc = calloc(1, sizeof (Edje_Part_Collection)); - if (!edc) error_and_abort(ef, "Not enough memory\n"); + if (!edc) error_and_abort(ef, "Not enough memory"); ce->ref = edc; EINA_LIST_FREE(oedc->programs, pg) @@ -306,7 +306,7 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, edc->parts_count = eina_list_count(oedc->parts); edc->parts = calloc(edc->parts_count, sizeof (Edje_Part *)); if (edc->parts_count && !edc->parts) - error_and_abort(ef, "Not enough memory\n"); + error_and_abort(ef, "Not enough memory"); k = 0; EINA_LIST_FREE(oedc->parts, part) @@ -318,7 +318,7 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, replacement = eina_mempool_malloc(ce->mp.part, sizeof (Edje_Part)); if (!replacement) - error_and_abort(ef, "Not enough memory\n"); + error_and_abort(ef, "Not enough memory"); replacement->name = part->name; replacement->default_desc = _edje_description_convert(part->type, ce, part->default_desc); diff --git a/src/bin/edje_convert_main.c b/src/bin/edje_convert_main.c index bc3484d..e17d412 100644 --- a/src/bin/edje_convert_main.c +++ b/src/bin/edje_convert_main.c @@ -24,10 +24,9 @@ error_and_abort(Eet_File *ef, const char *fmt, ...) { va_list ap; - fprintf(stderr, "%s: Error. ", progname); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + eina_log_vprint(_edje_cc_log_dom, EINA_LOG_LEVEL_CRITICAL, + "unknown", "unknown", 0, fmt, ap); va_end(ap); eet_close(ef); exit(-1); diff --git a/src/bin/edje_decc.c b/src/bin/edje_decc.c index 358859e..e9d880f 100644 --- a/src/bin/edje_decc.c +++ b/src/bin/edje_decc.c @@ -19,7 +19,7 @@ #include "edje_decc.h" int _edje_cc_log_dom = -1; -char *progname = NULL; +static char *progname = NULL; char *file_in = NULL; char *file_out = NULL; int compress_mode = EET_COMPRESSION_DEFAULT; @@ -37,6 +37,87 @@ void output(void); static int compiler_cmd_is_sane(); static int root_filename_is_sane(); + +static void +_edje_cc_log_cb(const Eina_Log_Domain *d, + Eina_Log_Level level, + const char *file, + const char *fnc, + int line, + const char *fmt, + __UNUSED__ void *data, + va_list args) +{ + if ((d->name) && (d->namelen == sizeof("edje_decc") - 1) && + (memcmp(d->name, "edje_decc", sizeof("edje_decc") - 1) == 0)) + { + const char *prefix; + Eina_Bool use_color = !eina_log_color_disable_get(); + + if (use_color) + { +#ifndef _WIN32 + fputs(eina_log_level_color_get(level), stderr); +#else + int color; + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + color = FOREGROUND_RED | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_ERR: + color = FOREGROUND_RED; + break; + case EINA_LOG_LEVEL_WARN: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_INFO: + color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_DBG: + color = FOREGROUND_BLUE | FOREGROUND_INTENSITY; + break; + default: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + } + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); +#endif + } + + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + prefix = "Critical. "; + break; + case EINA_LOG_LEVEL_ERR: + prefix = "Error. "; + break; + case EINA_LOG_LEVEL_WARN: + prefix = "Warning. "; + break; + default: + prefix = ""; + } + fprintf(stderr, "%s: %s", progname, prefix); + + if (use_color) + { +#ifndef _WIN32 + fputs(EINA_COLOR_RESET, stderr); +#else + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); +#endif + } + + + vfprintf(stderr, fmt, args); + putc('\n', stderr); + } + else + eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); +} + static void main_help(void) { @@ -47,6 +128,7 @@ main_help(void) " -main-out\tCreate a symbolic link to the main edc \n" " -no-build-sh\tDon't output build.sh \n" " -current-dir\tOutput to current directory \n" + " -quiet\t\tProduce less output\n" "\n" ,progname); } @@ -70,7 +152,10 @@ main(int argc, char **argv) eina_shutdown(); exit(-1); } - progname = argv[0]; + progname = (char *)ecore_file_file_get(argv[0]); + eina_log_print_cb_set(_edje_cc_log_cb, NULL); + eina_log_domain_level_set("edje_decc", EINA_LOG_LEVEL_INFO); + for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h")) @@ -89,6 +174,8 @@ main(int argc, char **argv) build_sh = 0; else if (!strcmp(argv[i], "-current-dir")) new_dir = 0; + else if (!strcmp(argv[i], "-quiet")) + eina_log_domain_level_set("edje_decc", EINA_LOG_LEVEL_WARN); } if (!file_in) { @@ -104,9 +191,9 @@ main(int argc, char **argv) if (!decomp()) return -1; output(); - fprintf(stderr, "WARNING! If any Image or audio data was encoded in a LOSSY way, then\n" - "re-encoding will drop quality even more. You need access to the original\n" - "data to ensure no loss of quality.\n"); + WRN("If any Image or audio data was encoded in a LOSSY way, then " + "re-encoding will drop quality even more. " + "You need access to the original data to ensure no loss of quality."); eet_close(ef); edje_shutdown(); eina_log_domain_unregister(_edje_cc_log_dom); @@ -121,27 +208,27 @@ decomp(void) ef = eet_open(file_in, EET_FILE_MODE_READ); if (!ef) { - ERR("ERROR: cannot open %s", file_in); + ERR("cannot open %s", file_in); return 0; } srcfiles = source_load(ef); if (!srcfiles || !srcfiles->list) { - ERR("ERROR: %s has no decompile information", file_in); + ERR("%s has no decompile information", file_in); eet_close(ef); return 0; } if (!eina_list_data_get(srcfiles->list) || !root_filename_is_sane()) { - ERR("ERROR: Invalid root filename: '%s'", (char *) eina_list_data_get(srcfiles->list)); + ERR("Invalid root filename: '%s'", (char *) eina_list_data_get(srcfiles->list)); eet_close(ef); return 0; } edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje/file"); if (!edje_file) { - ERR("ERROR: %s does not appear to be an edje file", file_in); + ERR("%s does not appear to be an edje file", file_in); eet_close(ef); return 0; } @@ -153,7 +240,7 @@ decomp(void) } else if (!compiler_cmd_is_sane()) { - ERR("ERROR: invalid compiler executable: '%s'", edje_file->compiler); + ERR("invalid compiler executable: '%s'", edje_file->compiler); eet_close(ef); return 0; } @@ -225,7 +312,7 @@ output(void) snprintf(buf, sizeof(buf), "edje/images/%i", ei->id); evas_object_image_file_set(im, file_in, buf); snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry); - printf("Output Image: %s\n", out); + INF("Output Image: %s", out); pp = strdup(out); p = strrchr(pp, '/'); *p = 0; @@ -256,7 +343,7 @@ output(void) char *pp; snprintf(out, sizeof(out), "%s/%s", outdir, sf->name); - INF("Output Source File: %s\n", out); + INF("Output Source File: %s", out); pp = strdup(out); p = strrchr(pp, '/'); *p = 0; @@ -345,10 +432,10 @@ output(void) if (build_sh) { snprintf(out, sizeof(out), "%s/build.sh", outdir); - printf("Output Build Script: %s\n", out); + INF("Output Build Script: %s", out); if (strstr(out, "../")) { - ERR("potential security violation. attempt to write in parent dir.\n"); + ERR("potential security violation. attempt to write in parent dir."); exit (-1); } f = fopen(out, "wb"); @@ -356,7 +443,7 @@ output(void) fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n", edje_file->compiler, sf->name, outdir); fclose(f); - WRN("\n*** CAUTION ***\n" + WRN("*** CAUTION ***\n" "Please check the build script for anything malicious " "before running it!\n\n"); } @@ -366,7 +453,7 @@ output(void) snprintf(out, sizeof(out), "%s/%s", outdir, file_out); if (ecore_file_symlink(sf->name, out) != EINA_TRUE) { - ERR("symlink %s -> %s failed\n", sf->name, out); + ERR("symlink %s -> %s failed", sf->name, out); } } diff --git a/src/bin/edje_decc.h b/src/bin/edje_decc.h index 43e988d..c562715 100644 --- a/src/bin/edje_decc.h +++ b/src/bin/edje_decc.h @@ -6,6 +6,7 @@ /* logging variables */ extern int _edje_cc_log_dom ; #define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN + #ifdef ERR # undef ERR #endif @@ -18,6 +19,14 @@ extern int _edje_cc_log_dom ; # undef WRN #endif #define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__) +#ifdef CRIT +# undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_edje_cc_log_dom, __VA_ARGS__) +#ifdef DBG +# undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_edje_cc_log_dom, __VA_ARGS__) /* types */ typedef struct _Font Font; diff --git a/src/bin/edje_multisense_convert.c b/src/bin/edje_multisense_convert.c index 62c2f67..347961e 100644 --- a/src/bin/edje_multisense_convert.c +++ b/src/bin/edje_multisense_convert.c @@ -21,7 +21,7 @@ _edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double enc_info = calloc(1, sizeof(Edje_Sound_Encode)); if (!enc_info) { - ERR("Error. while allocating memory to load file "); + ERR("while allocating memory to load file "); exit(-1); } memset (&sfinfo, 0, sizeof (SF_INFO)); @@ -33,13 +33,13 @@ _edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double sfile = sf_open (filename, SFM_READ, &sfinfo); if (!sfile) { - ERR("Error. Unable to open audio file : %s", filename); + ERR("Unable to open audio file: %s", filename); exit(-1); } if (!sf_format_check(&sfinfo)) { - ERR("Error. Unknown file, not a valid audio file"); + ERR("Unknown file, not a valid audio file"); exit(-1); } -- 2.7.4