From 08c081ac33c48d8f5ffbbe6dc95083662d8d9893 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 13 Feb 2020 09:04:26 +0400 Subject: [PATCH] =?UTF-8?q?modification=20pour=20support=20des=20valeurs?= =?UTF-8?q?=20sp=C3=A9ciales=20(ne=20sont=20pas=20synchronis=C3=A9es)=20da?= =?UTF-8?q?ns=20LDAP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/awk | 58 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/lib/ulib/awk b/lib/ulib/awk index 1de1465..4395b73 100644 --- a/lib/ulib/awk +++ b/lib/ulib/awk @@ -582,19 +582,63 @@ function deli(num, i, j) { } function del(field) { deli(geth(field)) } -function comparevic(field1, value1, field2, value2, icfields, array) { +function __starts_with(prefix, string) { + return substr(string, 1, length(prefix)) == prefix +} +function __comparevic_truth(retval) { + return substr(retval, 1, 1) == "1" +} +function __comparevic_suffix(retval) { + return substr(retval, 2) +} +function comparevic(field1, value1, field2, value2, icfields, spfields, array, i, vs, f, prefix, suffix) { + # tester si on est un champ spécial. + prefix = "" + split(spfields, array, /,/) + for (i in array) { + split(array[i], vs, /=/) + f = tolower(vs[1]) + if (f == tolower(field1) || f == tolower(field2)) { + prefix = vs[2] + break + } + } + suffix = "" + if (prefix != "") { + # les valeurs ayant le préfixe spécifié sont ignorées + split(value1, array, /;/) + array_new(vs) + for (i in array) { + if (!__starts_with(prefix, array[i])) { + array_add(vs, array[i]) + } else { + if (suffix != "") suffix = suffix ";" + suffix = suffix array[i] + } + } + value1 = array_join(vs, ";") + split(value2, array, /;/) + array_new(vs) + for (i in array) { + if (!__starts_with(prefix, array[i])) { + array_add(vs, array[i]) + } + } + value2 = array_join(vs, ";") + } split(icfields, array, /,/) if (in_array(field1, array, 1) || in_array(field2, array, 1)) { - return tolower(value1) == tolower(value2) + i = tolower(value1) == tolower(value2)? "1": "0" } else { - return value1 == value2 + i = value1 == value2? "1": "0" } + return i suffix } -function ocompareic(field1, field2, icfields, v1, v2, array) { - return comparevic(field1, oget(field1), field2, oget(field2), icfields) +function ocompareic(field1, field2, icfields, spfields, v1, v2, array) { + return comparevic(field1, oget(field1), field2, oget(field2), icfields, spfields) } -function compareic(field1, field2, icfields, v1, v2, array) { - return comparevic(field1, get(field1), field2, get(field2), icfields) +function compareic(field1, field2, icfields, spfields, v1, v2, array) { + return comparevic(field1, get(field1), field2, get(field2), icfields, spfields) } function infields(field, fields, array) { split(fields, array, /,/)