X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=config%2Fsymbol.c;h=b664d6ed515ffe27e4a805734a5f51d839078da4;hb=a423328607a8dfbf84e3b92cbde918a8bd7a8c8d;hp=d550300ec00c34e5b1748478c6381341e9412e0b;hpb=48f3c1c38c4e6b786938dbe813743953e722b01e;p=carl9170fw.git diff --git a/config/symbol.c b/config/symbol.c index d550300..b664d6e 100644 --- a/config/symbol.c +++ b/config/symbol.c @@ -963,11 +963,11 @@ struct sym_match { * - first, symbols that match exactly * - then, alphabetical sort */ -static int sym_rel_comp( const void *sym1, const void *sym2 ) +static int sym_rel_comp(const void *sym1, const void *sym2) { struct sym_match *s1 = *(struct sym_match **)sym1; struct sym_match *s2 = *(struct sym_match **)sym2; - int l1, l2; + int exact1, exact2; /* Exact match: * - if matched length on symbol s1 is the length of that symbol, @@ -978,11 +978,11 @@ static int sym_rel_comp( const void *sym1, const void *sym2 ) * exactly; if this is the case, we can't decide which comes first, * and we fallback to sorting alphabetically. */ - l1 = s1->eo - s1->so; - l2 = s2->eo - s2->so; - if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name)) + exact1 = (s1->eo - s1->so) == strlen(s1->sym->name); + exact2 = (s2->eo - s2->so) == strlen(s2->sym->name); + if (exact1 && !exact2) return -1; - if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name)) + if (!exact1 && exact2) return 1; /* As a fallback, sort symbols alphabetically */ @@ -1014,9 +1014,8 @@ struct symbol **sym_re_search(const char *pattern) void *tmp; size += 16; tmp = realloc(sym_match_arr, size * sizeof(struct sym_match *)); - if (!tmp) { + if (!tmp) goto sym_re_search_free; - } sym_match_arr = tmp; } sym_calc_value(sym); @@ -1024,7 +1023,7 @@ struct symbol **sym_re_search(const char *pattern) if (!tmp_sym_match) goto sym_re_search_free; tmp_sym_match->sym = sym; - /* As regexec return 0, we know we have a match, so + /* As regexec returned 0, we know we have a match, so * we can use match[0].rm_[se]o without further checks */ tmp_sym_match->so = match[0].rm_so;