From: Michael Tremer Date: Thu, 1 Feb 2018 14:19:30 +0000 (+0000) Subject: Fix searching for ASes X-Git-Tag: 0.9.0~69 X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Flibloc.git;a=commitdiff_plain;h=273948cfa02a1bacf906f1b4dc296f81b7d8441e;hp=da3e360e369c735bd5d09f8dd8f4545de15ceea7 Fix searching for ASes The name of the AS has not been converted to lowercase before which causes that we didn't find all ASes. Signed-off-by: Michael Tremer --- diff --git a/src/as.c b/src/as.c index 8721eff..8be229a 100644 --- a/src/as.c +++ b/src/as.c @@ -131,18 +131,9 @@ int loc_as_to_database_v0(struct loc_as* as, struct loc_stringpool* pool, } int loc_as_match_string(struct loc_as* as, const char* string) { - int r = 1; - - char* name = strdup(as->name); - - // Convert string to lowercase - for (char* p = name; *p; p++) - *p = tolower(*p); - // Search if string is in name - if (strstr(as->name, string) != NULL) - r = 0; + if (strcasestr(as->name, string) != NULL) + return 1; - free(name); - return r; + return 0; } diff --git a/src/database.c b/src/database.c index 2c8af0c..fe5e6dc 100644 --- a/src/database.c +++ b/src/database.c @@ -621,7 +621,7 @@ LOC_EXPORT struct loc_as* loc_database_enumerator_next_as(struct loc_database_en return NULL; r = loc_as_match_string(as, enumerator->string); - if (r == 0) { + if (r == 1) { DEBUG(enumerator->ctx, "AS%d (%s) matches %s\n", loc_as_get_number(as), loc_as_get_name(as), enumerator->string);