[Home]

Summary:ASTERISK-04550: [patch] simplify ui string handling in pbx.c
Reporter:Luigi Rizzo (rizzo)Labels:
Date Opened:2005-07-10 16:48:01Date Closed:2011-06-07 14:03:01
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) pbx.gui.diff
Description:the generation of 'user interface' strings in pbx.c repeats far too many
times sections of code to replace empty strings with 'Not Available'
and add the magic constant 23 to the string size.
The attached patch replaces both constructs with functions, with
a significant improvement in readability of the code
(and ease of mainteinance should the magic 23 becomes 24 or 25 due
to inflation).

Comments:By: Tilghman Lesher (tilghman) 2005-07-10 23:45:12

Shouldn't those functions have the inline modifier, to keep from suffering a performance penalty?

By: Tilghman Lesher (tilghman) 2005-07-10 23:46:20

I'm also going to nitpick the choice of gui_ as the prefix.  These are strings for a textual user interface, not a graphical user interface.

By: Kevin P. Fleming (kpfleming) 2005-07-11 16:43:59

This can't be right (it's recursive):

+static int gui_size(const char *s)
+{
+ return 23 + gui_size(s);
+}

I think I'd prefer to see the only new function be the gui_string() one, and then in the expressions just use:

synopsis_size = strlen(gui_string(acf->synopsis)) + 23;

If the '23' is bothersome, let's make a #define for it, rather than putting it into a function.

I don't really care too much about the 'gui' prefix, although if you can come up with something better I wouldn't mind :-)

By: Michael Jerris (mikej) 2005-07-20 19:02:45

suspended due to lack of response.  feel free to re-open when you have updates ready.