fixed aid selection

This commit is contained in:
merlokk 2019-11-04 23:21:02 +02:00
commit 6eb7c8e7a5

View file

@ -123,13 +123,17 @@ int PrintAIDDescription(char *aid, bool verbose) {
goto out; goto out;
json_t *elm = NULL; json_t *elm = NULL;
int maxaidlen = 0;
for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) { for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) {
json_t *data = AIDSearchGetElm(root, elmindx); json_t *data = AIDSearchGetElm(root, elmindx);
if (data == NULL) if (data == NULL)
continue; continue;
if (aidCompare(jsonStrGet(data, "AID"), aid)) { const char *dictaid = jsonStrGet(data, "AID");
elm = data; if (aidCompare(aid, dictaid)) { // dictaid may be less length than requested aid
break; if (maxaidlen < strlen(dictaid) && strlen(dictaid) <= strlen(aid)) {
maxaidlen = strlen(dictaid);
elm = data;
}
} }
} }