Summary:ASTERISK-04921: Problems with negative value expressions.
Reporter:Knut-Håvard Aksnes (knut-haavard aksnes)Labels:
Date Opened:2005-08-29 03:38:20Date Closed:2008-01-15 15:45:58.000-0600
Versions:Frequency of
Description:It seems to me that asterisk have switched from int to unsigned int internally
fairly recently, the problem wasn't present in CVS head from 2004-08-24.
This breaks lots of variable matching of the type ${FOO:-4:2}. My extensions.conf fails as I do positioning from the end of strings a lot. An example from my extensions.conf follows:

EXTLEN => ${LEN(${EXT})}
exten => _${EXT},1,Goto(${CALLERIDNUM:${LOCALPOS}:${CUSTLEN}}${EXTEN},1)

This used to work but doesn't any longer as LOCALPOS now are 4294967292 and not -4 as intended. Workarounds will always be possible but ugly.
${CALLERIDNUM:-5} can be written as ${CALLERIDNUM:$[${LEN(${CALLERIDNUM})} - ${LOCALLEN}]} but this is fairly ugly and the offset can't be precomputed in the general section as the length of CALLERIDNUM will in the general case be unknown at this point.


I am running Fedora Core 3 on i686 platform.
Comments:By: Michael Jerris (mikej) 2005-08-29 05:54:51

can you provide a patch to correct this?

By: Kevin P. Fleming (kpfleming) 2005-08-29 15:30:36

I've put the exact lines you have posted into my [globals] section, and ran NoOp() to inspect the results of all four expressions. They are all as expected: 2, 2, 4, -4.

By: Kevin P. Fleming (kpfleming) 2005-08-29 15:31:40

If you can provide a more complete example of the problem occurring, please reopen the bug.

By: Olle Johansson (oej) 2005-08-29 15:41:05

Reproduced the problem

By: Kevin P. Fleming (kpfleming) 2005-08-29 15:54:40

I've now been able to reproduce this on a 32-bit machine (my previous test was on a 64-bit system). I'll get it fixed :-)

By: Kevin P. Fleming (kpfleming) 2005-08-29 16:42:35

Fixed in CVS HEAD.

By: Digium Subversion (svnbot) 2008-01-15 15:45:57.000-0600

Repository: asterisk
Revision: 6436

U   trunk/ast_expr2.fl
U   trunk/ast_expr2.y

r6436 | kpfleming | 2008-01-15 15:45:57 -0600 (Tue, 15 Jan 2008) | 3 lines

don't use unsigned in on Solaris, will break math expressions that are
supposed to generate negative results (related to issue ASTERISK-4921)



By: Digium Subversion (svnbot) 2008-01-15 15:45:58.000-0600

Repository: asterisk
Revision: 6437

U   trunk/ast_expr2.c
U   trunk/ast_expr2.fl
U   trunk/ast_expr2.h
U   trunk/ast_expr2.y
U   trunk/ast_expr2f.c

r6437 | kpfleming | 2008-01-15 15:45:58 -0600 (Tue, 15 Jan 2008) | 3 lines

fix signed/unsigned result issue on 32-bit platforms (issue ASTERISK-4921)
(expression parser was rebuilt with bison 1.875d as well)