[asterisk-bugs] [Asterisk 0015025]: [patch] Functions INC and DEC

Asterisk Bug Tracker noreply at bugs.digium.com
Tue May 12 03:56:27 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=15025 
====================================================================== 
Reported By:                greenfieldtech
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   15025
Category:                   Functions/func_math
Reproducibility:            N/A
Severity:                   feature
Priority:                   normal
Status:                     new
Asterisk Version:           SVN 
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases):  trunk 
SVN Revision (number only!): 191919M 
Request Review:              
====================================================================== 
Date Submitted:             2009-05-03 20:30 CDT
Last Modified:              2009-05-12 03:56 CDT
====================================================================== 
Summary:                    [patch] Functions INC and DEC
Description: 
Over the course of time, developing Asterisk dialplans becomes fairly
cumbersome, especially when writing While() loops in the dialplan. Mainly,
when we want to iterate a few times, the ever annoying Set(Var=$[${Var} +
1]) is really annoying.
INCrement and DECrement follow the old PASCAL functions, allowing to
increment and decrement a variable.

The functions are built to handle both numeric and alpha-numeric values.
If an alpha-numeric value is given, the functions will simply bail out and
issue a LOG_NOTICE accordingly.

In order to implement this, i've added some functionality to func_math.c
and added a new ast_is_numeric function to strings.h

Please find attached patches for TRUNK.
====================================================================== 

---------------------------------------------------------------------- 
 (0104572) tilghman (administrator) - 2009-05-12 03:56
 http://bugs.digium.com/view.php?id=15025#c104572 
---------------------------------------------------------------------- 
There's no need to use ast_strdupa() on the value if the channel is locked
the entire time.  The only reason to ast_strdupa() is if you immediately
unlock the channel and you want your pointer to remain valid.

All conditionals need braces around the body, even when the body is only a
single line.  This is part of our coding guidelines.

There should be a space after every comma in a multi-parameter function,
such as snprintf().

Comments on the same line as code should be indented with spaces, not
tabs.  Tabs should only be used for indenting at the very beginning of a
line.

The returnvar only needs to be 12 characters long if you're using an int
type.  It could be 23 characters long if you're using a long long type,
though.  32 is way overkill.  If you want to use a calculation based upon
the type, you can always use:  char returnvar[3 + 2.4083 * sizeof(int)] 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-05-12 03:56 tilghman       Note Added: 0104572                          
======================================================================




More information about the asterisk-bugs mailing list