Index: main/say.c =================================================================== --- main/say.c (revision 194832) +++ main/say.c (working copy) @@ -270,28 +270,28 @@ /* Forward declarations */ /*! \page Def_syntaxlang Asterisk Language Syntaxes supported - \note Not really language codes. + \note Not really language codes. For these language codes, Asterisk will change the syntax when saying numbers (and in some cases dates and voicemail messages as well) - \arg \b da - Danish - \arg \b de - German - \arg \b en - English (US) - \arg \b en_GB - English (British) - \arg \b es - Spanish, Mexican - \arg \b fr - French - \arg \b he - Hebrew - \arg \b it - Italian - \arg \b nl - Dutch - \arg \b no - Norwegian - \arg \b pl - Polish - \arg \b pt - Portuguese - \arg \b pt_BR - Portuguese (Brazil) - \arg \b se - Swedish - \arg \b tw - Taiwanese / Chinese - \arg \b ru - Russian - \arg \b ge - Georgian - \arg \b hu - Hungarian + \arg \b da - Danish + \arg \b de - German + \arg \b en - English (US) + \arg \b en_GB - English (British) + \arg \b es - Spanish, Mexican + \arg \b fr - French + \arg \b he - Hebrew + \arg \b it - Italian + \arg \b nl - Dutch + \arg \b no - Norwegian + \arg \b pl - Polish + \arg \b pt - Portuguese + \arg \b pt_BR - Portuguese (Brazil) + \arg \b se - Swedish + \arg \b tw - Taiwanese / Chinese + \arg \b ru - Russian + \arg \b ge - Georgian + \arg \b hu - Hungarian \par Gender: For Some languages the numbers differ for gender and plural. @@ -430,48 +430,49 @@ /* Called from AGI */ static int say_number_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) { - if (!strcasecmp(language, "en") ) { /* English syntax */ + /* A subset of en_GB? Tzafrir's folly */ + if (!strncasecmp(language, "en_GB", 2)) { /* British syntax */ + return(ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd)); + } else if (!strncasecmp(language, "en", 2)) { /* English syntax */ return(ast_say_number_full_en(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "cz") ) { /* Czech syntax */ + } else if (!strncasecmp(language, "cz", 2)) { /* Czech syntax */ return(ast_say_number_full_cz(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "da") ) { /* Danish syntax */ + } else if (!strncasecmp(language, "da", 2)) { /* Danish syntax */ return(ast_say_number_full_da(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "de") ) { /* German syntax */ + } else if (!strncasecmp(language, "de", 2)) { /* German syntax */ return(ast_say_number_full_de(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "en_GB") ) { /* British syntax */ - return(ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "no") ) { /* Norwegian syntax */ + } else if (!strncasecmp(language, "no", 2)) { /* Norwegian syntax */ return(ast_say_number_full_no(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "es") || !strcasecmp(language, "mx")) { /* Spanish syntax */ + } else if (!strncasecmp(language, "es", 2) || !strncasecmp(language, "mx", 2)) { /* Spanish syntax */ return(ast_say_number_full_es(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "fr") ) { /* French syntax */ + } else if (!strncasecmp(language, "fr", 2)) { /* French syntax */ return(ast_say_number_full_fr(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "he") ) { /* Hebrew syntax */ + } else if (!strncasecmp(language, "ge", 2)) { /* Georgian syntax */ + return(ast_say_number_full_ge(chan, num, ints, language, options, audiofd, ctrlfd)); + } else if (!strncasecmp(language, "gr", 2)) { /* Greek syntax */ + return(ast_say_number_full_gr(chan, num, ints, language, audiofd, ctrlfd)); + } else if (!strncasecmp(language, "he", 2)) { /* Hebrew syntax */ return(ast_say_number_full_he(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "hu") ) { /* Hungarian syntax */ + } else if (!strncasecmp(language, "hu", 2)) { /* Hungarian syntax */ return(ast_say_number_full_hu(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "it") ) { /* Italian syntax */ + } else if (!strncasecmp(language, "it", 2)) { /* Italian syntax */ return(ast_say_number_full_it(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "nl") ) { /* Dutch syntax */ + } else if (!strncasecmp(language, "nl", 2)) { /* Dutch syntax */ return(ast_say_number_full_nl(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "pl") ) { /* Polish syntax */ + } else if (!strncasecmp(language, "pl", 2)) { /* Polish syntax */ return(ast_say_number_full_pl(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "pt") || !strcasecmp(language, "pt_BR")) { /* Portuguese syntax */ + } else if (!strncasecmp(language, "pt", 2)) { /* Portuguese syntax */ return(ast_say_number_full_pt(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "se") ) { /* Swedish syntax */ + } else if (!strncasecmp(language, "ru", 2)) { /* Russian syntax */ + return(ast_say_number_full_ru(chan, num, ints, language, options, audiofd, ctrlfd)); + } else if (!strncasecmp(language, "se", 2)) { /* Swedish syntax */ return(ast_say_number_full_se(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "tw") || !strcasecmp(language, "zh") ) { /* Taiwanese / Chinese syntax */ + } else if (!strncasecmp(language, "th", 2)) { /* Thai syntax */ + return(ast_say_number_full_th(chan, num, ints, language, audiofd, ctrlfd)); + } else if (!strncasecmp(language, "tw", 2) || !strncasecmp(language, "zh", 2) ) { /* Taiwanese / Chinese syntax */ return(ast_say_number_full_tw(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "gr") ) { /* Greek syntax */ - return(ast_say_number_full_gr(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "ru") ) { /* Russian syntax */ - return(ast_say_number_full_ru(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "th") ) { /* Thai syntax */ - return(ast_say_number_full_th(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "ur") ) { /* Urdu syntax */ + } else if (!strncasecmp(language, "ur", 2)) { /* Urdu syntax */ return(ast_say_number_full_ur(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "ge") ) { /* Georgian syntax */ - return(ast_say_number_full_ge(chan, num, ints, language, options, audiofd, ctrlfd)); } /* Default to english */ @@ -994,8 +995,8 @@ /*! \brief ast_say_number_full_es: Spanish syntax */ /* New files: Requires a few new audios: - 1F.gsm: feminine 'una' - 21.gsm thru 29.gsm, cien.gsm, mil.gsm, millon.gsm, millones.gsm, 100.gsm, 200.gsm, 300.gsm, 400.gsm, 500.gsm, 600.gsm, 700.gsm, 800.gsm, 900.gsm, y.gsm + 1F.gsm: feminine 'una' + 21.gsm thru 29.gsm, cien.gsm, mil.gsm, millon.gsm, millones.gsm, 100.gsm, 200.gsm, 300.gsm, 400.gsm, 500.gsm, 600.gsm, 700.gsm, 800.gsm, 900.gsm, y.gsm */ static int ast_say_number_full_es(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) { @@ -2280,7 +2281,7 @@ playz++; continue; } - if (strcasecmp(language,"twz") == 0) + if (strcasecmp(language, "twz") == 0) snprintf(fn, sizeof(fn), "digits/%d", num); else snprintf(fn, sizeof(fn), "digits/%d", num); @@ -2595,16 +2596,16 @@ /* Called from AGI */ static int say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd) { - if (!strcasecmp(language, "en") ) { /* English syntax */ + if (!strncasecmp(language, "en", 2) ) { /* English syntax */ return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "da") ) { /* Danish syntax */ + } else if (!strncasecmp(language, "da", 2) ) { /* Danish syntax */ return(ast_say_enumeration_full_da(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "de") ) { /* German syntax */ + } else if (!strncasecmp(language, "de", 2) ) { /* German syntax */ return(ast_say_enumeration_full_de(chan, num, ints, language, options, audiofd, ctrlfd)); - } else if (!strcasecmp(language, "he")) { /* Hebrew syntax */ + } else if (!strncasecmp(language, "he", 2)) { /* Hebrew syntax */ return (ast_say_enumeration_full_he(chan, num, ints, language, options, audiofd, ctrlfd)); - } - + } + /* Default to english */ return(ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd)); } @@ -2615,7 +2616,7 @@ { int res = 0, t = 0; char fn[256] = ""; - + while (!res && num) { if (num < 0) { ast_copy_string(fn, "digits/minus", sizeof(fn)); /* kind of senseless for enumerations, but our best effort for error checking */ @@ -2623,11 +2624,11 @@ num = -num; } else { num = 0; - } + } } else if (num < 20) { snprintf(fn, sizeof(fn), "digits/h-%d", num); num = 0; - } else if (num < 100) { + } else if (num < 100) { int tens = num / 10; num = num % 10; if (num == 0) { @@ -2640,7 +2641,7 @@ num = num % 100; if (hundreds > 1 || t == 1) { res = ast_say_number_full_en(chan, hundreds, ints, language, audiofd, ctrlfd); - } + } if (res) return res; if (num) { @@ -2656,7 +2657,7 @@ } if (res) return res; - if (num) { + if (num) { ast_copy_string(fn, "digits/thousand", sizeof(fn)); } else { ast_copy_string(fn, "digits/h-thousand", sizeof(fn)); @@ -2669,7 +2670,7 @@ res = ast_say_number_full_en(chan, millions, ints, language, audiofd, ctrlfd); if (res) return res; - if (num) { + if (num) { ast_copy_string(fn, "digits/million", sizeof(fn)); } else { ast_copy_string(fn, "digits/h-million", sizeof(fn)); @@ -2681,7 +2682,7 @@ res = ast_say_number_full_en(chan, billions, ints, language, audiofd, ctrlfd); if (res) return res; - if (num) { + if (num) { ast_copy_string(fn, "digits/billion", sizeof(fn)); } else { ast_copy_string(fn, "digits/h-billion", sizeof(fn)); @@ -2734,7 +2735,7 @@ num = -num; } else { num = 0; - } + } } else if (num < 100 && t) { ast_copy_string(fn, "digits/and", sizeof(fn)); t = 0; @@ -2761,17 +2762,17 @@ } else { snprintf(fn, sizeof(fn), "digits/%d", hundreds); } - if (num) { + if (num) { ast_copy_string(fna, "digits/hundred", sizeof(fna)); } else { snprintf(fna, sizeof(fna), "digits/h-hundred%s", gender); } t = 1; - } else if (num < 1000000) { + } else if (num < 1000000) { int thousands = num / 1000; num = num % 1000; if (thousands == 1) { - if (num) { + if (num) { ast_copy_string(fn, "digits/1N", sizeof(fn)); ast_copy_string(fna, "digits/thousand", sizeof(fna)); } else { @@ -2787,7 +2788,7 @@ if (res) { return res; } - if (num) { + if (num) { ast_copy_string(fn, "digits/thousand", sizeof(fn)); } else { snprintf(fn, sizeof(fn), "digits/h-thousand%s", gender); @@ -2798,7 +2799,7 @@ int millions = num / 1000000; num = num % 1000000; if (millions == 1) { - if (num) { + if (num) { ast_copy_string(fn, "digits/1F", sizeof(fn)); ast_copy_string(fna, "digits/million", sizeof(fna)); } else { @@ -2810,7 +2811,7 @@ if (res) { return res; } - if (num) { + if (num) { ast_copy_string(fn, "digits/millions", sizeof(fn)); } else { snprintf(fn, sizeof(fn), "digits/h-million%s", gender); @@ -2821,7 +2822,7 @@ int billions = num / 1000000000; num = num % 1000000000; if (billions == 1) { - if (num) { + if (num) { ast_copy_string(fn, "digits/1F", sizeof(fn)); ast_copy_string(fna, "digits/milliard", sizeof(fna)); } else { @@ -2832,7 +2833,7 @@ res = ast_say_number_full_de(chan, billions, ints, language, options, audiofd, ctrlfd); if (res) return res; - if (num) { + if (num) { ast_copy_string(fn, "digits/milliards", sizeof(fna)); } else { snprintf(fn, sizeof(fna), "digits/h-milliard%s", gender); @@ -3124,28 +3125,28 @@ static int say_date(struct ast_channel *chan, time_t t, const char *ints, const char *lang) { - if (!strcasecmp(lang, "en") ) { /* English syntax */ + if (!strncasecmp(lang, "en", 2) ) { /* English syntax */ return(ast_say_date_en(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "da") ) { /* Danish syntax */ + } else if (!strncasecmp(lang, "da", 2)) { /* Danish syntax */ return(ast_say_date_da(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "de") ) { /* German syntax */ + } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ return(ast_say_date_de(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "fr") ) { /* French syntax */ + } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ return(ast_say_date_fr(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "hu") ) { /* Hungarian syntax */ + } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ + return(ast_say_date_ge(chan, t, ints, lang)); + } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ + return(ast_say_date_gr(chan, t, ints, lang)); + } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ + return (ast_say_date_he(chan, t, ints, lang)); + } else if (!strncasecmp(lang, "hu", 2)) { /* Hungarian syntax */ return(ast_say_date_hu(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */ + } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ return(ast_say_date_nl(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) { /* Portuguese syntax */ + } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ return(ast_say_date_pt(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "gr") ) { /* Greek syntax */ - return(ast_say_date_gr(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "th") ) { /* Thai syntax */ + } else if (!strncasecmp(lang, "th", 2)) { /* Thai syntax */ return(ast_say_date_th(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "ge") ) { /* Georgian syntax */ - return(ast_say_date_ge(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "he")) { /* Hebrew syntax */ - return (ast_say_date_he(chan, t, ints, lang)); } /* Default to English */ @@ -3469,32 +3470,32 @@ static int say_date_with_format(struct ast_channel *chan, time_t t, const char *ints, const char *lang, const char *format, const char *tzone) { - if (!strcasecmp(lang, "en") ) { /* English syntax */ + if (!strncasecmp(lang, "en", 2) ) { /* English syntax */ return (ast_say_date_with_format_en(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "da") ) { /* Danish syntax */ + } else if (!strncasecmp(lang, "da", 2)) { /* Danish syntax */ return(ast_say_date_with_format_da(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "de") ) { /* German syntax */ + } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ return(ast_say_date_with_format_de(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "es") || !strcasecmp(lang, "mx")) { /* Spanish syntax */ + } else if (!strncasecmp(lang, "es", 2) || !strncasecmp(lang, "mx", 2)) { /* Spanish syntax */ return (ast_say_date_with_format_es(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "he")) { /* Hebrew syntax */ + } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ + return (ast_say_date_with_format_gr(chan, t, ints, lang, format, tzone)); + } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ return (ast_say_date_with_format_he(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "fr")) { /* French syntax */ + } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ return (ast_say_date_with_format_fr(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "it")) { /* Italian syntax */ + } else if (!strncasecmp(lang, "it", 2)) { /* Italian syntax */ return (ast_say_date_with_format_it(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "nl")) { /* Dutch syntax */ + } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ return (ast_say_date_with_format_nl(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "pl")) { /* Polish syntax */ + } else if (!strncasecmp(lang, "pl", 2)) { /* Polish syntax */ return (ast_say_date_with_format_pl(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) { /* Portuguese syntax */ + } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ return (ast_say_date_with_format_pt(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "tw") || !strcasecmp(lang, "zh") ) { /* Taiwanese / Chinese syntax */ + } else if (!strncasecmp(lang, "th", 2)) { /* Thai syntax */ + return (ast_say_date_with_format_th(chan, t, ints, lang, format, tzone)); + } else if (!strncasecmp(lang, "tw", 2) || !strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */ return (ast_say_date_with_format_tw(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "th") ) { /* Thai syntax */ - return (ast_say_date_with_format_th(chan, t, ints, lang, format, tzone)); - } else if (!strcasecmp(lang, "gr") ) { /* Greek syntax */ - return (ast_say_date_with_format_gr(chan, t, ints, lang, format, tzone)); } /* Default to English */ @@ -4378,13 +4379,13 @@ break; case 'd': case 'e': /* Day of the month */ - /* I'm not sure exactly what the parameters - * audiofd and ctrlfd to - * ast_say_number_full_he mean, but it seems - * safe to pass -1 there. - * - * At least in one of the pathes :-( - */ + /* I'm not sure exactly what the parameters + * audiofd and ctrlfd to + * ast_say_number_full_he mean, but it seems + * safe to pass -1 there. + * + * At least in one of the pathes :-( + */ res = ast_say_number_full_he(chan, tm.tm_mday, ints, lang, "m", -1, -1); break; case 'Y': /* Year */ @@ -6074,31 +6075,30 @@ static int say_time(struct ast_channel *chan, time_t t, const char *ints, const char *lang) { - if (!strcasecmp(lang, "en") ) { /* English syntax */ + if (!strncasecmp(lang, "en", 2)) { /* English syntax */ return(ast_say_time_en(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "de") ) { /* German syntax */ + } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ return(ast_say_time_de(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "fr") ) { /* French syntax */ + } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ return(ast_say_time_fr(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "hu") ) { /* Hungarian syntax */ + } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ + return(ast_say_time_ge(chan, t, ints, lang)); + } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ + return(ast_say_time_gr(chan, t, ints, lang)); + } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ + return (ast_say_time_he(chan, t, ints, lang)); + } else if (!strncasecmp(lang, "hu", 2)) { /* Hungarian syntax */ return(ast_say_time_hu(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */ + } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ return(ast_say_time_nl(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */ + } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ return(ast_say_time_pt(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "pt_BR") ) { /* Brazilian Portuguese syntax */ + } else if (!strncasecmp(lang, "pt_BR", 2)) { /* Brazilian Portuguese syntax */ return(ast_say_time_pt_BR(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "tw") ) { /* Taiwanese syntax */ - } else if (!strcasecmp(lang, "tw") || !strcasecmp(lang, "zh") ) { /* Taiwanese / Chinese syntax */ + } else if (!strncasecmp(lang, "tw", 2) || !strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */ return(ast_say_time_tw(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "gr") ) { /* Greek syntax */ - return(ast_say_time_gr(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "th") ) { + } else if (!strncasecmp(lang, "th", 2)) { return(ast_say_time_th(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "ge") ) { /* Georgian syntax */ - return(ast_say_time_ge(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "he")) { /* Hebrew syntax */ - return (ast_say_time_he(chan, t, ints, lang)); } /* Default to English */ @@ -6392,29 +6392,29 @@ } static int say_datetime(struct ast_channel *chan, time_t t, const char *ints, const char *lang) { - if (!strcasecmp(lang, "en") ) { /* English syntax */ + if (!strncasecmp(lang, "en", 2)) { /* English syntax */ return(ast_say_datetime_en(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "de") ) { /* German syntax */ + } else if (!strncasecmp(lang, "de", 2)) { /* German syntax */ return(ast_say_datetime_de(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "fr") ) { /* French syntax */ + } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ return(ast_say_datetime_fr(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "nl") ) { /* Dutch syntax */ + } else if (!strncasecmp(lang, "nl", 2)) { /* Dutch syntax */ return(ast_say_datetime_nl(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "hu") ) { /* Hungarian syntax */ + } else if (!strncasecmp(lang, "hu", 2)) { /* Hungarian syntax */ return(ast_say_datetime_hu(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "pt") ) { /* Portuguese syntax */ + } else if (!strncasecmp(lang, "pt_BR", 5)) { /* Brazilian Portuguese syntax */ + return(ast_say_datetime_pt_BR(chan, t, ints, lang)); + } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ return(ast_say_datetime_pt(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "pt_BR") ) { /* Brazilian Portuguese syntax */ - return(ast_say_datetime_pt_BR(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "tw") || !strcasecmp(lang, "zh") ) { /* Taiwanese / Chinese syntax */ + } else if (!strncasecmp(lang, "tw", 2) || !strncasecmp(lang, "zh", 2)) { /* Taiwanese / Chinese syntax */ return(ast_say_datetime_tw(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "gr") ) { /* Greek syntax */ + } else if (!strncasecmp(lang, "gr", 2)) { /* Greek syntax */ return(ast_say_datetime_gr(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "th") ) { /* Thai syntax */ + } else if (!strncasecmp(lang, "th", 2)) { /* Thai syntax */ return(ast_say_datetime_th(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "ge") ) { /* Georgian syntax */ + } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ return(ast_say_datetime_ge(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "he")) { /* Hebrew syntax */ + } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ return (ast_say_datetime_he(chan, t, ints, lang)); } @@ -6829,15 +6829,15 @@ } static int say_datetime_from_now(struct ast_channel *chan, time_t t, const char *ints, const char *lang) { - if (!strcasecmp(lang, "en") ) { /* English syntax */ + if (!strncasecmp(lang, "en", 2)) { /* English syntax */ return(ast_say_datetime_from_now_en(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "fr") ) { /* French syntax */ + } else if (!strncasecmp(lang, "fr", 2)) { /* French syntax */ return(ast_say_datetime_from_now_fr(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "pt") || !strcasecmp(lang, "pt_BR")) { /* Portuguese syntax */ + } else if (!strncasecmp(lang, "pt", 2)) { /* Portuguese syntax */ return(ast_say_datetime_from_now_pt(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "ge") ) { /* Georgian syntax */ + } else if (!strncasecmp(lang, "ge", 2)) { /* Georgian syntax */ return(ast_say_datetime_from_now_ge(chan, t, ints, lang)); - } else if (!strcasecmp(lang, "he")) { /* Georgian syntax */ + } else if (!strncasecmp(lang, "he", 2)) { /* Hebrew syntax */ return (ast_say_datetime_from_now_he(chan, t, ints, lang)); } @@ -7841,7 +7841,7 @@ */ static const char *counted_noun_ending_slavic(int num) { - if (num < 0) { + if (num < 0) { num *= -1; } num %= 100; /* never pay attention to more than two digits */ @@ -7863,13 +7863,13 @@ char *temp; int temp_len; const char *ending; - if (!strcasecmp(chan->language, "ru")) { /* Russian */ + if (!strncasecmp(chan->language, "ru", 2)) { /* Russian */ ending = counted_noun_ending_slavic(num); - } else if(!strcasecmp(chan->language, "ua")) { /* Ukrainian */ + } else if (!strncasecmp(chan->language, "ua", 2)) { /* Ukrainian */ ending = counted_noun_ending_slavic(num); - } else if(!strcasecmp(chan->language, "ua")) { /* Polish */ + } else if (!strncasecmp(chan->language, "pl", 2)) { /* Polish */ ending = counted_noun_ending_slavic(num); - } else { /* English and default */ + } else { /* English and default */ ending = counted_noun_ending_en(num); } temp = alloca((temp_len = (strlen(noun) + strlen(ending) + 1))); @@ -7886,7 +7886,7 @@ */ static const char *counted_adjective_ending_ru(int num, const char gender[]) { - if (num < 0) { + if (num < 0) { num *= -1; } num %= 100; /* never pay attention to more than two digits */ @@ -7905,13 +7905,13 @@ char *temp; int temp_len; const char *ending; - if (!strcasecmp(chan->language, "ru")) { /* Russian */ + if (!strncasecmp(chan->language, "ru", 2)) { /* Russian */ ending = counted_adjective_ending_ru(num, gender); - } else if (!strcasecmp(chan->language, "ua")) { /* Ukrainian */ + } else if (!strncasecmp(chan->language, "ua", 2)) { /* Ukrainian */ ending = counted_adjective_ending_ru(num, gender); - } else if (!strcasecmp(chan->language, "pl")) { /* Polish */ + } else if (!strncasecmp(chan->language, "pl", 2)) { /* Polish */ ending = counted_adjective_ending_ru(num, gender); - } else { /* English and default */ + } else { /* English and default */ ending = ""; } temp = alloca((temp_len = (strlen(adjective) + strlen(ending) + 1)));