mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
select: fix string list selection to match whole words only but not prefixes of searched string
$ lvs -o name,tags vg/lvol0 LV LV Tags lvol0 a Before this patch: $ lvs -o name,tags vg/lvol0 -S 'tags=[a]' LV LV Tags lvol0 a $ lvs -o name,tags vg/lvol0 -S 'tags=[ab]' LV LV Tags lvol0 a (incorrect!) $ lvs -o name,tags vg/lvol0 -S 'tags=[abc]' LV LV Tags lvol0 a (incorrect!) With this patch applied: $ lvs -o name,tags vg/lvol0 -S 'tags=[a]' LV LV Tags lvol0 a $ lvs -o name,tags vg/lvol0 -S 'tags=[ab]' (no result - correct!) $ lvs -o name,tags vg/lvol0 -S 'tags=[abc]' (no result - correct!)
This commit is contained in:
parent
9738a02d3d
commit
6dd98c1fa8
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.89 -
|
Version 1.02.89 -
|
||||||
=================================
|
=================================
|
||||||
|
Fix string list selection to match whole words only, not prefixes.
|
||||||
|
|
||||||
Version 1.02.88 - 5th August 2014
|
Version 1.02.88 - 5th August 2014
|
||||||
=================================
|
=================================
|
||||||
|
@ -1260,7 +1260,8 @@ static int _cmp_field_string_list_all(const struct str_list_sort_value *val,
|
|||||||
|
|
||||||
/* both lists are sorted so they either match 1:1 or not */
|
/* both lists are sorted so they either match 1:1 or not */
|
||||||
dm_list_iterate_items(sel_item, sel->list) {
|
dm_list_iterate_items(sel_item, sel->list) {
|
||||||
if (strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
|
if ((strlen(sel_item->str) != val->items[i].len) ||
|
||||||
|
strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
|
||||||
return 0;
|
return 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -1285,7 +1286,8 @@ static int _cmp_field_string_list_any(const struct str_list_sort_value *val,
|
|||||||
* Make use of the fact that the lists are sorted!
|
* Make use of the fact that the lists are sorted!
|
||||||
*/
|
*/
|
||||||
for (i = 1; i <= val->items[0].len; i++) {
|
for (i = 1; i <= val->items[0].len; i++) {
|
||||||
if (!strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
|
if ((strlen(sel_item->str) == val->items[i].len) &&
|
||||||
|
!strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user