diff options
-rw-r--r-- | doc/en/weechat_plugin_api.en.asciidoc | 63 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.asciidoc | 63 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.asciidoc | 70 | ||||
-rw-r--r-- | doc/ja/weechat_plugin_api.ja.asciidoc | 72 | ||||
-rw-r--r-- | src/core/wee-string.c | 46 | ||||
-rw-r--r-- | src/core/wee-utf8.c | 14 |
6 files changed, 178 insertions, 150 deletions
diff --git a/doc/en/weechat_plugin_api.en.asciidoc b/doc/en/weechat_plugin_api.en.asciidoc index f0bc3c351..47846da05 100644 --- a/doc/en/weechat_plugin_api.en.asciidoc +++ b/doc/en/weechat_plugin_api.en.asciidoc @@ -546,6 +546,8 @@ This function is not available in scripting API. ==== weechat_strcasecmp +_Updated in 1.0._ + Locale and case independent string comparison. Prototype: @@ -562,10 +564,9 @@ Arguments: Return value: -* difference between two strings: -** negative if string1 < string2 -** zero if string1 == string2 -** positive if string1 > string2 +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C example: @@ -579,7 +580,7 @@ This function is not available in scripting API. ==== weechat_strcasecmp_range -_WeeChat ≥ 0.3.7._ +_WeeChat ≥ 0.3.7, updated in 1.0._ Locale and case independent string comparison, using a range for case comparison. @@ -605,10 +606,9 @@ Values 29 and 30 are used by some protocols like IRC. Return value: -* difference between two strings: -** negative if string1 < string2 -** zero if string1 == string2 -** positive if string1 > string2 +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C example: @@ -622,6 +622,8 @@ This function is not available in scripting API. ==== weechat_strncasecmp +_Updated in 1.0._ + Locale and case independent string comparison, for 'max' chars. Prototype: @@ -639,10 +641,9 @@ Arguments: Return value: -* difference between two strings: -** negative if string1 < string2 -** zero if string1 == string2 -** positive if string1 > string2 +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C example: @@ -656,7 +657,7 @@ This function is not available in scripting API. ==== weechat_strncasecmp_range -_WeeChat ≥ 0.3.7._ +_WeeChat ≥ 0.3.7, updated in 1.0._ Locale and case independent string comparison, for 'max' chars, using a range for case comparison. @@ -683,10 +684,9 @@ Values 29 and 30 are used by some protocols like IRC. Return value: -* difference between two strings: -** negative if string1 < string2 -** zero if string1 == string2 -** positive if string1 > string2 +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C example: @@ -700,6 +700,8 @@ This function is not available in scripting API. ==== weechat_strcmp_ignore_chars +_Updated in 1.0._ + Locale (and optionally case independent) string comparison, ignoring some chars. @@ -721,10 +723,9 @@ Arguments: Return value: -* difference between two strings: -** negative if string1 < string2 -** zero if string1 == string2 -** positive if string1 > string2 +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C example: @@ -2201,6 +2202,8 @@ This function is not available in scripting API. ==== weechat_utf8_charcmp +_Updated in 1.0._ + Compare two UTF-8 chars. Prototype: @@ -2217,10 +2220,9 @@ Arguments: Return value: -* difference between first char of each string: -** negative if char1 < char2 -** zero if char1 == char2 -** positive if char1 > char2 +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C example: @@ -2234,6 +2236,8 @@ This function is not available in scripting API. ==== weechat_utf8_charcasecmp +_Updated in 1.0._ + Compare two UTF-8 chars, ignoring case. Prototype: @@ -2250,10 +2254,9 @@ Arguments: Return value: -* difference between first char of each string: -** negative if char1 < char2 -** zero if char1 == char2 -** positive if char1 > char2 +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C example: diff --git a/doc/fr/weechat_plugin_api.fr.asciidoc b/doc/fr/weechat_plugin_api.fr.asciidoc index 5343747f8..7e88aaa54 100644 --- a/doc/fr/weechat_plugin_api.fr.asciidoc +++ b/doc/fr/weechat_plugin_api.fr.asciidoc @@ -553,6 +553,8 @@ Cette fonction n'est pas disponible dans l'API script. ==== weechat_strcasecmp +_Mis à jour dans la 1.0._ + Comparer deux chaînes indépendemment de la locale et de la casse. Prototype : @@ -569,10 +571,9 @@ Paramètres : Valeur de retour : -* différence entre les deux chaînes : -** négative si string1 < string2 -** zéro si string1 == string2 -** positive si string1 > string2 +* -1 si string1 < string2 +* 0 si string1 == string2 +* 1 si string1 > string2 Exemple en C : @@ -586,7 +587,7 @@ Cette fonction n'est pas disponible dans l'API script. ==== weechat_strcasecmp_range -_WeeChat ≥ 0.3.7._ +_WeeChat ≥ 0.3.7, mis à jour dans la 1.0._ Comparer deux chaînes indépendemment de la locale et de la casse, avec un intervalle pour comparer la casse. @@ -612,10 +613,9 @@ Les valeurs 29 et 30 sont utilisés par quelques protocoles comme IRC. Valeur de retour : -* différence entre les deux chaînes : -** négative si string1 < string2 -** zéro si string1 == string2 -** positive si string1 > string2 +* -1 si string1 < string2 +* 0 si string1 == string2 +* 1 si string1 > string2 Exemple en C : @@ -629,6 +629,8 @@ Cette fonction n'est pas disponible dans l'API script. ==== weechat_strncasecmp +_Mis à jour dans la 1.0._ + Comparer deux chaînes indépendemment de la locale et de la casse, pour 'max' caractères. @@ -647,10 +649,9 @@ Paramètres : Valeur de retour : -* différence entre les deux chaînes : -** négative si string1 < string2 -** zéro si string1 == string2 -** positive si string1 > string2 +* -1 si string1 < string2 +* 0 si string1 == string2 +* 1 si string1 > string2 Exemple en C : @@ -664,7 +665,7 @@ Cette fonction n'est pas disponible dans l'API script. ==== weechat_strncasecmp_range -_WeeChat ≥ 0.3.7._ +_WeeChat ≥ 0.3.7, mis à jour dans la 1.0._ Comparer deux chaînes indépendemment de la locale et de la casse, pour 'max' caractères, avec un intervalle pour comparer la casse. @@ -691,10 +692,9 @@ Les valeurs 29 et 30 sont utilisés par quelques protocoles comme IRC. Valeur de retour : -* différence entre les deux chaînes : -** négative si string1 < string2 -** zéro si string1 == string2 -** positive si string1 > string2 +* -1 si string1 < string2 +* 0 si string1 == string2 +* 1 si string1 > string2 Exemple en C : @@ -708,6 +708,8 @@ Cette fonction n'est pas disponible dans l'API script. ==== weechat_strcmp_ignore_chars +_Mis à jour dans la 1.0._ + Comparer deux chaînes indépendemment de la locale (et en option de la casse), en ignorant des caractères. @@ -729,10 +731,9 @@ Paramètres : Valeur de retour : -* différence entre les deux chaînes : -** négative si string1 < string2 -** zéro si string1 == string2 -** positive si string1 > string2 +* -1 si string1 < string2 +* 0 si string1 == string2 +* 1 si string1 > string2 Exemple en C : @@ -2241,6 +2242,8 @@ Cette fonction n'est pas disponible dans l'API script. ==== weechat_utf8_charcmp +_Mis à jour dans la 1.0._ + Comparer deux caractères UTF-8. Prototype : @@ -2257,10 +2260,9 @@ Paramètres : Valeur de retour : -* différence entre le premier caractère de chaque chaîne : -** négative si char1 < char2 -** zéro si char1 == char2 -** positive si char1 > char2 +* -1 si string1 < string2 +* 0 si string1 == string2 +* 1 si string1 > string2 Exemple en C : @@ -2274,6 +2276,8 @@ Cette fonction n'est pas disponible dans l'API script. ==== weechat_utf8_charcasecmp +_Mis à jour dans la 1.0._ + Comparer deux caractères UTF-8 en ignorant la casse. Prototype : @@ -2290,10 +2294,9 @@ Paramètres : Valeur de retour : -* différence entre le premier caractère de chaque chaîne : -** négative si char1 < char2 -** zéro si char1 == char2 -** positive si char1 > char2 +* -1 si string1 < string2 +* 0 si string1 == string2 +* 1 si string1 > string2 Exemple en C : diff --git a/doc/it/weechat_plugin_api.it.asciidoc b/doc/it/weechat_plugin_api.it.asciidoc index a6e36c7cf..4f3d875f1 100644 --- a/doc/it/weechat_plugin_api.it.asciidoc +++ b/doc/it/weechat_plugin_api.it.asciidoc @@ -562,6 +562,9 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== weechat_strcasecmp +// TRANSLATION MISSING +_Updated in 1.0._ + Confronta stringa non sensibile alle maiuscole e alla localizzazione. Prototipo: @@ -578,10 +581,9 @@ Argomenti: Valore restituito: -* differenze tra le due stringhe: -** negativa se stringa1 < stringa2 -** zero se stringa1 == stringa1 -** positiva se stringa1 > stringa2 +* -1 se stringa1 < stringa2 +* 0 se stringa1 == stringa1 +* 1 se stringa1 > stringa2 Esempio in C: @@ -595,6 +597,9 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== weechat_strcasecmp_range +// TRANSLATION MISSING +_WeeChat ≥ 0.3.7, updated in 1.0._ + Confronta stringa non sensibile alle maiuscole e alla localizzazione, usando una serie per il confronto. @@ -619,10 +624,9 @@ I valori 29 e 30 vengono usati da alcuni protocolli come IRC. Valore restituito: -* differenze tra le due stringhe: -** negativa se stringa1 < stringa2 -** zero se stringa1 == stringa1 -** positiva se stringa1 > stringa2 +* -1 se stringa1 < stringa2 +* 0 se stringa1 == stringa1 +* 1 se stringa1 > stringa2 Esempio in C: @@ -636,6 +640,9 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== weechat_strncasecmp +// TRANSLATION MISSING +_Updated in 1.0._ + Confronta stringa indipendente non sensibile alle maiuscole e alla localizzazione, per un numero 'max' di caratteri. @@ -654,10 +661,9 @@ Argomenti: Valore restituito: -* differenze tra le due stringhe: -** negativa se string1 < string2 -** zero se string1 == string1 -** positiva se string1 > string2 +* -1 se stringa1 < stringa2 +* 0 se stringa1 == stringa1 +* 1 se stringa1 > stringa2 Esempio in C: @@ -671,6 +677,9 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== weechat_strncasecmp_range +// TRANSLATION MISSING +_WeeChat ≥ 0.3.7, updated in 1.0._ + Confronta una stringa non sensibile alle maiuscole e alla localizzazione, per un numero 'max' di caratteri, usando una serie per il confronto. @@ -696,10 +705,9 @@ I valori 29 e 30 vengono usati da alcuni protocolli come IRC. Valore restituito: -* differenze tra le due stringhe: -** negativa se string1 < string2 -** zero se string1 == string1 -** positiva se string1 > string2 +* -1 se stringa1 < stringa2 +* 0 se stringa1 == stringa1 +* 1 se stringa1 > stringa2 Esempio in C: @@ -713,6 +721,9 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== weechat_strcmp_ignore_chars +// TRANSLATION MISSING +_Updated in 1.0._ + Confronta una stringa localizzata (e opzionalmente non sensibile alle maiuscole), ignorando alcuni caratteri. @@ -734,10 +745,9 @@ Argomenti: Valore restituito: -* differenza tra le due stringhe: -** negativa se string1 < string2 -** zero se string1 == string2 -** positiva se string1 > string2 +* -1 se stringa1 < stringa2 +* 0 se stringa1 == stringa1 +* 1 se stringa1 > stringa2 Esempio in C: @@ -2255,6 +2265,9 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== weechat_utf8_charcmp +// TRANSLATION MISSING +_Updated in 1.0._ + Confronta due caratteri UTF-8. Prototipo: @@ -2271,10 +2284,9 @@ Argomenti: Valore restituito: -* differenza tra i primi caratteri di ogni stringa: -** negativa se char1 < char2 -** zero se char1 == char2 -** positivao se char1 > char2 +* -1 se string1 < string2 +* 0 se string1 == string2 +* 1 se string1 > string2 Esempio in C: @@ -2288,6 +2300,9 @@ Questa funzione non è disponibile nelle API per lo scripting. ==== weechat_utf8_charcasecmp +// TRANSLATION MISSING +_Updated in 1.0._ + Confronta due caratteri UTF-8, ignorando la sensibilità alle maiuscole. Prototipo: @@ -2304,10 +2319,9 @@ Argomenti: Valore restituito: -* differenza tra i primi caratteri di ogni stringa: -** negativa se char1 < char2 -** zero se char1 == char2 -** positivao se char1 > char2 +* -1 se string1 < string2 +* 0 se string1 == string2 +* 1 se string1 > string2 Esempio in C: diff --git a/doc/ja/weechat_plugin_api.ja.asciidoc b/doc/ja/weechat_plugin_api.ja.asciidoc index f5ed54cc2..1aae071ee 100644 --- a/doc/ja/weechat_plugin_api.ja.asciidoc +++ b/doc/ja/weechat_plugin_api.ja.asciidoc @@ -546,6 +546,8 @@ weechat_string_toupper (str); /* str is now: "ABCDé" */ ==== weechat_strcasecmp +_バージョン 1.0 で更新。_ + ロケールと大文字小文字を無視して文字列を比較。 プロトタイプ: @@ -562,10 +564,10 @@ int weechat_strcasecmp (const char *string1, const char *string2); 戻り値: -* 2 つの文字列の差: -** string1 < string2 の場合は負 -** string1 == string2 の場合はゼロ -** string1 > string2 の場合は正 +// TRANSLATION MISSING +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C 言語での使用例: @@ -579,7 +581,8 @@ int diff = weechat_strcasecmp ("aaa", "CCC"); /* == -2 */ ==== weechat_strcasecmp_range -_WeeChat バージョン 0.3.7 以上で利用可。_ +// TRANSLATION MISSING +_WeeChat ≥ 0.3.7, updated in 1.0._ 大文字小文字を無視する文字範囲の幅を使い、ロケールと大文字小文字を無視して文字列を比較。 @@ -604,10 +607,10 @@ int weechat_strcasecmp_range (const char *string1, const char *string2, int rang 戻り値: -* 2 つの文字列の差: -** string1 < string2 の場合は負 -** string1 == string2 の場合はゼロ -** string1 > string2 の場合は正 +// TRANSLATION MISSING +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C 言語での使用例: @@ -621,6 +624,8 @@ int diff = weechat_strcasecmp_range ("nick{away}", "NICK[away]", 29); /* == 0 */ ==== weechat_strncasecmp +_バージョン 1.0 で更新。_ + ロケールと大文字小文字を無視して 'max' 文字だけ文字列を比較。 プロトタイプ: @@ -638,10 +643,10 @@ int weechat_strncasecmp (const char *string1, const char *string2, int max); 戻り値: -* 2 つの文字列の差: -** string1 < string2 の場合は負 -** string1 == string2 の場合はゼロ -** string1 > string2 の場合は正 +// TRANSLATION MISSING +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C 言語での使用例: @@ -655,7 +660,8 @@ int diff = weechat_strncasecmp ("aabb", "aacc", 2); /* == 0 */ ==== weechat_strncasecmp_range -_WeeChat バージョン 0.3.7 以上で利用可。_ +// TRANSLATION MISSING +_WeeChat ≥ 0.3.7, updated in 1.0._ 大文字小文字を無視する文字範囲の幅を使い、ロケールと大文字小文字を無視して 'max' 文字だけ文字列を比較。 @@ -682,10 +688,10 @@ int weechat_strncasecmp_range (const char *string1, const char *string2, int max 戻り値: -* 2 つの文字列の差: -** string1 < string2 の場合は負 -** string1 == string2 の場合はゼロ -** string1 > string2 の場合は正 +// TRANSLATION MISSING +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C 言語での使用例: @@ -699,6 +705,8 @@ int diff = weechat_strncasecmp_range ("nick{away}", "NICK[away]", 6, 29); /* == ==== weechat_strcmp_ignore_chars +_バージョン 1.0 で更新。_ + 一部の文字列を無視して、ロケールに依存して (オプションで大文字小文字の区別をしない) 文字列を比較。 @@ -720,10 +728,10 @@ int weechat_strcmp_ignore_chars (const char *string1, const char *string2, 戻り値: -* 2 つの文字列の差: -** string1 < string2 の場合は負 -** string1 == string2 の場合はゼロ -** string1 > string2 の場合は正 +// TRANSLATION MISSING +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C 言語での使用例: @@ -2197,6 +2205,8 @@ int length_on_screen = weechat_utf8_strlen_screen ("é"); /* == 1 */ ==== weechat_utf8_charcmp +_バージョン 1.0 で更新。_ + 2 つの UTF-8 文字を比較。 プロトタイプ: @@ -2213,10 +2223,10 @@ int weechat_utf8_charcmp (const char *string1, const char *string2); 戻り値: -* 各文字列の 1 文字目同士の差: -** char1 < char2 の場合は負 -** char1 == char2 の場合はゼロ -** char1 > char2 の場合は正 +// TRANSLATION MISSING +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C 言語での使用例: @@ -2230,6 +2240,8 @@ int diff = weechat_utf8_charcmp ("aaa", "ccc"); /* == -2 */ ==== weechat_utf8_charcasecmp +_バージョン 1.0 で更新。_ + 大文字小文字の違いを無視して、2 つの UTF-8 文字を比較。 プロトタイプ: @@ -2246,10 +2258,10 @@ int weechat_utf8_charcasecmp (const char *string1, const char *string2); 戻り値: -* 各文字列の 1 文字目同士の差: -** char1 < char2 の場合は負 -** char1 == char2 の場合はゼロ -** char1 > char2 の場合は正 +// TRANSLATION MISSING +* -1 if string1 < string2 +* 0 if string1 == string2 +* 1 if string1 > string2 C 言語での使用例: diff --git a/src/core/wee-string.c b/src/core/wee-string.c index d4b3175ea..6890810d6 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -124,9 +124,9 @@ string_toupper (char *string) * Compares two strings (locale and case independent). * * Returns: - * < 0: string1 < string2 - * 0: string1 == string2 - * > 0: string1 > string2 + * -1: string1 < string2 + * 0: string1 == string2 + * 1: string1 > string2 */ int @@ -141,7 +141,7 @@ string_strcasecmp (const char *string1, const char *string2) { diff = utf8_charcasecmp (string1, string2); if (diff != 0) - return diff; + return (diff < 0) ? -1 : 1; string1 = utf8_next_char (string1); string2 = utf8_next_char (string2); @@ -163,9 +163,9 @@ string_strcasecmp (const char *string1, const char *string2) * (ranges 29 and 30 are used by some protocols like IRC) * * Returns: - * < 0: string1 < string2 - * 0: string1 == string2 - * > 0: string1 > string2 + * -1: string1 < string2 + * 0: string1 == string2 + * 1: string1 > string2 */ int @@ -180,7 +180,7 @@ string_strcasecmp_range (const char *string1, const char *string2, int range) { diff = utf8_charcasecmp_range (string1, string2, range); if (diff != 0) - return diff; + return (diff < 0) ? -1 : 1; string1 = utf8_next_char (string1); string2 = utf8_next_char (string2); @@ -193,9 +193,9 @@ string_strcasecmp_range (const char *string1, const char *string2, int range) * Compares two strings with max length (locale and case independent). * * Returns: - * < 0: string1 < string2 + * -1: string1 < string2 * 0: string1 == string2 - * > 0: string1 > string2 + * 1: string1 > string2 */ int @@ -211,7 +211,7 @@ string_strncasecmp (const char *string1, const char *string2, int max) { diff = utf8_charcasecmp (string1, string2); if (diff != 0) - return diff; + return (diff < 0) ? -1 : 1; string1 = utf8_next_char (string1); string2 = utf8_next_char (string2); @@ -238,9 +238,9 @@ string_strncasecmp (const char *string1, const char *string2, int max) * (ranges 29 and 30 are used by some protocols like IRC) * * Returns: - * < 0: string1 < string2 - * 0: string1 == string2 - * > 0: string1 > string2 + * -1: string1 < string2 + * 0: string1 == string2 + * 1: string1 > string2 */ int @@ -257,7 +257,7 @@ string_strncasecmp_range (const char *string1, const char *string2, int max, { diff = utf8_charcasecmp_range (string1, string2, range); if (diff != 0) - return diff; + return (diff < 0) ? -1 : 1; string1 = utf8_next_char (string1); string2 = utf8_next_char (string2); @@ -274,9 +274,9 @@ string_strncasecmp_range (const char *string1, const char *string2, int max, * Compares two strings, ignoring some chars. * * Returns: - * < 0: string1 < string2 - * 0: string1 == string2 - * > 0: string1 > string2 + * -1: string1 < string2 + * 0: string1 == string2 + * 1: string1 > string2 */ int @@ -285,12 +285,8 @@ string_strcmp_ignore_chars (const char *string1, const char *string2, { int diff; - if (!string1 && !string2) - return 0; - if (!string1 && string2) - return -1; - if (string1 && !string2) - return 1; + if (!string1 || !string2) + return (string1) ? 1 : ((string2) ? -1 : 0); while (string1 && string1[0] && string2 && string2[0]) { @@ -316,7 +312,7 @@ string_strcmp_ignore_chars (const char *string1, const char *string2, diff = (case_sensitive) ? (int)string1[0] - (int)string2[0] : utf8_charcasecmp (string1, string2); if (diff != 0) - return diff; + return (diff < 0) ? -1 : 1; string1 = utf8_next_char (string1); string2 = utf8_next_char (string2); diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c index 8871b78aa..c7fa38a20 100644 --- a/src/core/wee-utf8.c +++ b/src/core/wee-utf8.c @@ -524,9 +524,9 @@ utf8_strlen_screen (const char *string) * Compares two UTF-8 chars (case sensitive). * * Returns: - * < 0: char1 < char2 - * 0: char1 == char2 - * > 0: char1 > char2 + * -1: string1 < string2 + * 0: string1 == string2 + * 1: string1 > string2 */ int @@ -545,7 +545,7 @@ utf8_charcmp (const char *string1, const char *string2) { diff = (int)((unsigned char) string1[i]) - (int)((unsigned char) string2[i]); if (diff != 0) - return diff; + return (diff < 0) ? -1 : 1; i++; } /* string1 == string2 ? */ @@ -562,9 +562,9 @@ utf8_charcmp (const char *string1, const char *string2) * Compares two UTF-8 chars (case is ignored). * * Returns: - * < 0: char1 < char2 - * 0: char1 == char2 - * > 0: char1 > char2 + * -1: string1 < string2 + * 0: string1 == string2 + * 1: string1 > string2 */ int |