[asterisk-commits] tilghman: branch 1.6.0 r132114 - in /branches/1.6.0: ./ main/say.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 18 14:10:21 CDT 2008
Author: tilghman
Date: Fri Jul 18 14:10:21 2008
New Revision: 132114
URL: http://svn.digium.com/view/asterisk?view=rev&rev=132114
Log:
Merged revisions 132113 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r132113 | tilghman | 2008-07-18 14:09:39 -0500 (Fri, 18 Jul 2008) | 14 lines
Merged revisions 132112 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r132112 | tilghman | 2008-07-18 14:06:10 -0500 (Fri, 18 Jul 2008) | 6 lines
Fix for Taiwanese number syntax
(closes issue #12319)
Reported by: CharlesWang
Patches:
saynumber-tw-1.4.18.1.patch uploaded by CharlesWang (license 444)
........
................
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/main/say.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/main/say.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/say.c?view=diff&rev=132114&r1=132113&r2=132114
==============================================================================
--- branches/1.6.0/main/say.c (original)
+++ branches/1.6.0/main/say.c Fri Jul 18 14:10:21 2008
@@ -2243,11 +2243,15 @@
{
int res = 0;
int playh = 0;
+ int playt = 0;
+ int playz = 0;
+ int last_length = 0;
+ char buf[20] = "";
char fn[256] = "";
if (!num)
return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd);
- while (!res && (num || playh)) {
+ while (!res && (num || playh || playt || playz)) {
if (num < 0) {
ast_copy_string(fn, "digits/minus", sizeof(fn));
if ( num > INT_MIN ) {
@@ -2255,38 +2259,90 @@
} else {
num = 0;
}
+ } else if (playz) {
+ snprintf(fn, sizeof(fn), "digits/0");
+ last_length = 0;
+ playz = 0;
} else if (playh) {
ast_copy_string(fn, "digits/hundred", sizeof(fn));
playh = 0;
+ } else if (playt) {
+ snprintf(fn, sizeof(fn), "digits/thousand");
+ playt = 0;
} else if (num < 10) {
- snprintf(fn, sizeof(fn), "digits/%d", num);
+ snprintf(buf, 10, "%d", num);
+ if (last_length - strlen(buf) > 1 && last_length != 0) {
+ last_length = strlen(buf);
+ playz++;
+ continue;
+ }
+ if (strcasecmp(language,"twz") == 0)
+ snprintf(fn, sizeof(fn), "digits/%d", num);
+ else
+ snprintf(fn, sizeof(fn), "digits/%d", num);
num = 0;
} else if (num < 100) {
- snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10);
+ snprintf(buf, 10, "%d", num);
+ if (last_length - strlen(buf) > 1 && last_length != 0) {
+ last_length = strlen(buf);
+ playz++;
+ continue;
+ }
+ last_length = strlen(buf);
+ snprintf(fn, sizeof(fn), "digits/%d", (num / 10) * 10);
num %= 10;
} else {
if (num < 1000){
- snprintf(fn, sizeof(fn), "digits/%d", (num/100));
+ snprintf(buf, 10, "%d", num);
+ if (last_length - strlen(buf) > 1 && last_length != 0) {
+ last_length = strlen(buf);
+ playz++;
+ continue;
+ }
+ snprintf(fn, sizeof(fn), "digits/%d", (num / 100));
playh++;
- num %= 100;
- } else {
- if (num < 1000000) { /* 1,000,000 */
- res = ast_say_number_full_tw(chan, num / 1000, ints, language, audiofd, ctrlfd);
+ snprintf(buf, 10, "%d", num);
+ ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
+ last_length = strlen(buf);
+ num -= ((num / 100) * 100);
+ } else if (num < 10000){
+ snprintf(buf, 10, "%d", num);
+ if (last_length - strlen(buf) > 1 && last_length != 0 && last_length % strlen(buf) > 0) {
+ last_length = strlen(buf);
+ playz++;
+ continue;
+ }
+ snprintf(fn, sizeof(fn), "digits/%d", (num / 1000));
+ playt++;
+ snprintf(buf, 10, "%d", num);
+ ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
+ last_length = strlen(buf);
+ num -= ((num / 1000) * 1000);
+ } else if (num < 100000000) { /* 100,000,000 */
+ res = ast_say_number_full_tw(chan, num / 10000, ints, language, audiofd, ctrlfd);
if (res)
return res;
- num %= 1000;
- ast_copy_string(fn, "digits/thousand", sizeof(fn));
+ if (((num / 10000) % (num/100000)) == 0)
+ playz++;
+
+ snprintf(buf, 10, "%d", num);
+ ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
+ num -= ((num / 10000) * 10000);
+ last_length = strlen(buf);
+ snprintf(fn, sizeof(fn), "digits/wan");
+ } else {
+ if (num < 1000000000) { /* 1,000,000,000 */
+ res = ast_say_number_full_tw(chan, num / 100000000, ints, language, audiofd, ctrlfd);
+ if (res)
+ return res;
+ snprintf(buf, 10, "%d", num);
+ ast_log(LOG_DEBUG, "Number '%d' %d %d\n", num, (int)strlen(buf), last_length);
+ last_length = strlen(buf);
+ num -= ((num / 100000000) * 100000000);
+ snprintf(fn, sizeof(fn), "digits/yi");
} else {
- if (num < 1000000000) { /* 1,000,000,000 */
- res = ast_say_number_full_tw(chan, num / 1000000, ints, language, audiofd, ctrlfd);
- if (res)
- return res;
- num %= 1000000;
- ast_copy_string(fn, "digits/million", sizeof(fn));
- } else {
- ast_debug(1, "Number '%d' is too big for me\n", num);
- res = -1;
- }
+ ast_debug(1, "Number '%d' is too big for me\n", num);
+ res = -1;
}
}
}
More information about the asterisk-commits
mailing list