Fixing Portuguese syntax for saying dates and times. Also some coding guidelines cleanup.

(closes issue #11599, reported and patched by caio1982, coding guidelines cleanup by me)



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@94420 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2007-12-21 15:45:14 +00:00
parent 2f24e1b1bf
commit eac09a0cd0
2 changed files with 43 additions and 46 deletions

View File

@@ -2079,6 +2079,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
break; break;
/* On "ringall" strategy we only move to the next penalty level /* On "ringall" strategy we only move to the next penalty level
when *all* ringing phones are done in the current penalty level */ when *all* ringing phones are done in the current penalty level */
ast_log(LOG_DEBUG, "I actually hit this...\n");
ring_one(qe, outgoing, &numbusies); ring_one(qe, outgoing, &numbusies);
/* and retry... */ /* and retry... */
} }

View File

@@ -468,7 +468,7 @@ static int ast_say_number_full_en(struct ast_channel *chan, int num, const char
if (!num) if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && (num || playh)) { while (!res && (num || playh)) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -512,7 +512,7 @@ static int ast_say_number_full_en(struct ast_channel *chan, int num, const char
} }
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -570,7 +570,7 @@ static int ast_say_number_full_cz(struct ast_channel *chan, int num, const char
if (!num) if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && (num || playh)) { while (!res && (num || playh)) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -634,7 +634,7 @@ static int ast_say_number_full_cz(struct ast_channel *chan, int num, const char
num -= left * (exp10_int(length-1)); num -= left * (exp10_int(length-1));
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) { if ((audiofd > -1) && (ctrlfd > -1)) {
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
} else { } else {
@@ -663,7 +663,7 @@ static int ast_say_number_full_da(struct ast_channel *chan, int num, const char
if (options && !strncasecmp(options, "n",1)) cn = -1; if (options && !strncasecmp(options, "n",1)) cn = -1;
while(!res && (num || playh || playa )) { while (!res && (num || playh || playa )) {
/* The grammar for Danish numbers is the same as for English except /* The grammar for Danish numbers is the same as for English except
* for the following: * for the following:
* - 1 exists in both commune ("en", file "1N") and neuter ("et", file "1") * - 1 exists in both commune ("en", file "1N") and neuter ("et", file "1")
@@ -743,7 +743,7 @@ static int ast_say_number_full_da(struct ast_channel *chan, int num, const char
} }
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -776,7 +776,7 @@ static int ast_say_number_full_de(struct ast_channel *chan, int num, const char
if (options && (!strncasecmp(options, "f",1))) if (options && (!strncasecmp(options, "f",1)))
mf = -1; mf = -1;
while(!res && num) { while (!res && num) {
/* The grammar for German numbers is the same as for English except /* The grammar for German numbers is the same as for English except
* for the following: * for the following:
* - numbers 20 through 99 are said in reverse order, i.e. 21 is * - numbers 20 through 99 are said in reverse order, i.e. 21 is
@@ -873,7 +873,7 @@ static int ast_say_number_full_de(struct ast_channel *chan, int num, const char
res = -1; res = -1;
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -908,7 +908,7 @@ static int ast_say_number_full_en_GB(struct ast_channel *chan, int num, const ch
if (!num) if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && (num || playh || playa )) { while (!res && (num || playh || playa )) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -959,7 +959,7 @@ static int ast_say_number_full_en_GB(struct ast_channel *chan, int num, const ch
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -1063,7 +1063,7 @@ static int ast_say_number_full_es(struct ast_channel *chan, int num, const char
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -1094,7 +1094,7 @@ static int ast_say_number_full_fr(struct ast_channel *chan, int num, const char
if (options && !strncasecmp(options, "f",1)) if (options && !strncasecmp(options, "f",1))
mf = -1; mf = -1;
while(!res && (num || playh || playa)) { while (!res && (num || playh || playa)) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -1155,7 +1155,7 @@ static int ast_say_number_full_fr(struct ast_channel *chan, int num, const char
res = -1; res = -1;
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -1233,7 +1233,7 @@ static int ast_say_number_full_he(struct ast_channel *chan, int num,
mf = -1; mf = -1;
/* Do we have work to do? */ /* Do we have work to do? */
while(!res && (num || (state>0) )) { while (!res && (num || (state>0) )) {
/* first type of work: play a second sound. In this loop /* first type of work: play a second sound. In this loop
* we can only play one sound file at a time. Thus playing * we can only play one sound file at a time. Thus playing
* a second one requires repeating the loop just for the * a second one requires repeating the loop just for the
@@ -1304,7 +1304,7 @@ static int ast_say_number_full_he(struct ast_channel *chan, int num,
res = -1; res = -1;
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -1351,7 +1351,7 @@ static int ast_say_number_full_it(struct ast_channel *chan, int num, const char
So the right file is provided. So the right file is provided.
*/ */
while(!res && (num || playh)) { while (!res && (num || playh)) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -1457,7 +1457,7 @@ static int ast_say_number_full_it(struct ast_channel *chan, int num, const char
} }
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -1548,7 +1548,7 @@ static int ast_say_number_full_nl(struct ast_channel *chan, int num, const char
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -1577,7 +1577,7 @@ static int ast_say_number_full_no(struct ast_channel *chan, int num, const char
if (options && !strncasecmp(options, "n",1)) cn = -1; if (options && !strncasecmp(options, "n",1)) cn = -1;
while(!res && (num || playh || playa )) { while (!res && (num || playh || playa )) {
/* The grammar for Norwegian numbers is the same as for English except /* The grammar for Norwegian numbers is the same as for English except
* for the following: * for the following:
* - 1 exists in both commune ("en", file "1") and neuter ("ett", file "1N") * - 1 exists in both commune ("en", file "1") and neuter ("ett", file "1N")
@@ -1640,7 +1640,7 @@ static int ast_say_number_full_no(struct ast_channel *chan, int num, const char
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -1964,7 +1964,7 @@ static int ast_say_number_full_pt(struct ast_channel *chan, int num, const char
if (options && !strncasecmp(options, "f",1)) if (options && !strncasecmp(options, "f",1))
mf = -1; mf = -1;
while(!res && num ) { while (!res && num ) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -2057,7 +2057,7 @@ static int ast_say_number_full_se(struct ast_channel *chan, int num, const char
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
if (options && !strncasecmp(options, "n",1)) cn = -1; if (options && !strncasecmp(options, "n",1)) cn = -1;
while(!res && (num || playh)) { while (!res && (num || playh)) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -2106,7 +2106,7 @@ static int ast_say_number_full_se(struct ast_channel *chan, int num, const char
} }
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -2127,7 +2127,7 @@ static int ast_say_number_full_tw(struct ast_channel *chan, int num, const char
if (!num) if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && (num || playh)) { while (!res && (num || playh)) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -2171,7 +2171,7 @@ static int ast_say_number_full_tw(struct ast_channel *chan, int num, const char
} }
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -2219,7 +2219,7 @@ static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char
if (!num) if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && (num)) { while (!res && (num)) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); snprintf(fn, sizeof(fn), "digits/minus");
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -2228,7 +2228,7 @@ static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char
num = 0; num = 0;
} }
} else if (num < 20) { } else if (num < 20) {
if(options && strlen(options) == 1 && num < 3) { if (options && strlen(options) == 1 && num < 3) {
snprintf(fn, sizeof(fn), "digits/%d%s", num, options); snprintf(fn, sizeof(fn), "digits/%d%s", num, options);
} else { } else {
snprintf(fn, sizeof(fn), "digits/%d", num); snprintf(fn, sizeof(fn), "digits/%d", num);
@@ -2313,7 +2313,7 @@ static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const
int res = 0, t = 0; int res = 0, t = 0;
char fn[256] = ""; char fn[256] = "";
while(!res && num) { while (!res && num) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */ snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -2424,7 +2424,7 @@ static int ast_say_enumeration_full_da(struct ast_channel *chan, int num, const
if (!num) if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && num) { while (!res && num) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */ snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -2587,7 +2587,7 @@ static int ast_say_enumeration_full_de(struct ast_channel *chan, int num, const
if (!num) if (!num)
return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd); return ast_say_digits_full(chan, 0,ints, language, audiofd, ctrlfd);
while(!res && num) { while (!res && num) {
if (num < 0) { if (num < 0) {
snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */ snprintf(fn, sizeof(fn), "digits/minus"); /* kind of senseless for enumerations, but our best effort for error checking */
if ( num > INT_MIN ) { if ( num > INT_MIN ) {
@@ -4908,7 +4908,7 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha
char sndfile[256], nextmsg[256]; char sndfile[256], nextmsg[256];
if (format == NULL) if (format == NULL)
format = "Ad 'digits/pt-de' B 'digits/pt-de' Y 'digits/at' IMp"; format = "Ad 'digits/pt-de' B 'digits/pt-de' Y I 'digits/pt-e' Mp";
ast_localtime(&time,&tm,timezone); ast_localtime(&time,&tm,timezone);
@@ -4979,8 +4979,6 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha
} }
if (!res) if (!res)
res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f"); res = ast_say_number(chan, (tm.tm_hour % 12), ints, lang, "f");
if ((!res) && (format[offset] == 'I'))
res = ast_say_date_with_format(chan, time, ints, lang, "P", timezone);
} }
} else { } else {
if (tm.tm_hour == 0) { if (tm.tm_hour == 0) {
@@ -5052,10 +5050,9 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha
res = wait_file(chan, ints, "digits/pt-hora", lang); res = wait_file(chan, ints, "digits/pt-hora", lang);
if (tm.tm_hour != 1) if (tm.tm_hour != 1)
if (!res) if (!res)
res = wait_file(chan, ints, "digits/pt-sss", lang); } else { res = wait_file(chan, ints, "digits/pt-sss", lang);
res = wait_file(chan,ints,"digits/pt-e",lang); } else {
if (!res) res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
} }
} }
break; break;
@@ -5240,12 +5237,12 @@ int ast_say_date_with_format_tw(struct ast_channel *chan, time_t time, const cha
} else { } else {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday - (tm.tm_mday % 10)); snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday - (tm.tm_mday % 10));
res = wait_file(chan,ints,nextmsg,lang); res = wait_file(chan,ints,nextmsg,lang);
if(!res) { if (!res) {
snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday % 10); snprintf(nextmsg,sizeof(nextmsg), "digits/%d", tm.tm_mday % 10);
res = wait_file(chan,ints,nextmsg,lang); res = wait_file(chan,ints,nextmsg,lang);
} }
} }
if(!res) res = wait_file(chan,ints,"digits/day",lang); if (!res) res = wait_file(chan,ints,"digits/day",lang);
break; break;
case 'Y': case 'Y':
/* Year */ /* Year */
@@ -6207,7 +6204,7 @@ static int ast_say_number_full_gr(struct ast_channel *chan, int num, const char
return ast_waitstream(chan, ints); return ast_waitstream(chan, ints);
} }
while(!res && num ) { while (!res && num ) {
i++; i++;
if (num < 13) { if (num < 13) {
snprintf(fn, sizeof(fn), "digits/%d", num); snprintf(fn, sizeof(fn), "digits/%d", num);
@@ -6220,15 +6217,14 @@ static int ast_say_number_full_gr(struct ast_channel *chan, int num, const char
/* 100 < num < 200 */ /* 100 < num < 200 */
snprintf(fn, sizeof(fn), "digits/hundred-100"); snprintf(fn, sizeof(fn), "digits/hundred-100");
num -= ((num / 100) * 100); num -= ((num / 100) * 100);
}else if (num < 1000) { } else if (num < 1000) {
/* 200 < num < 1000 */ /* 200 < num < 1000 */
snprintf(fn, sizeof(fn), "digits/hundred-%d", (num/100)*100); snprintf(fn, sizeof(fn), "digits/hundred-%d", (num/100)*100);
num -= ((num / 100) * 100); num -= ((num / 100) * 100);
}else if (num < 2000){ } else if (num < 2000){
snprintf(fn, sizeof(fn), "digits/xilia"); snprintf(fn, sizeof(fn), "digits/xilia");
num -= ((num / 1000) * 1000); num -= ((num / 1000) * 1000);
} } else {
else {
/* num > 1000 */ /* num > 1000 */
if (num < 1000000) { if (num < 1000000) {
res = ast_say_number_full_gr(chan, (num / 1000), ints, chan->language, audiofd, ctrlfd); res = ast_say_number_full_gr(chan, (num / 1000), ints, chan->language, audiofd, ctrlfd);
@@ -6250,7 +6246,7 @@ static int ast_say_number_full_gr(struct ast_channel *chan, int num, const char
} }
} }
if (!res) { if (!res) {
if(!ast_streamfile(chan, fn, language)) { if (!ast_streamfile(chan, fn, language)) {
if ((audiofd > -1) && (ctrlfd > -1)) if ((audiofd > -1) && (ctrlfd > -1))
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
else else
@@ -6773,7 +6769,7 @@ static int ast_say_number_full_ge(struct ast_channel *chan, int num, const char
free(new_string); free(new_string);
remainder = s + 1; /* position just after the found space char. */ remainder = s + 1; /* position just after the found space char. */
while(*remainder == ' ') /* skip multiple spaces */ while (*remainder == ' ') /* skip multiple spaces */
remainder++; remainder++;
} }