[Home]

Summary:ASTERISK-04672: [patch] code cleanup - chan_sip.c has two almost identical functions 'get_in_brackets' and 'ditch_braces'
Reporter:Frank Sautter (xylome)Labels:
Date Opened:2005-07-25 04:53:50Date Closed:2008-01-15 15:42:27.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) ditchbraces.chan_sip.r784.txt
( 1) get_in_brackets.chan_sip.r784.txt
( 2) get_in_brackets.chan_sip.r787.txt
Description:both functions get the text within braces ('<' and '>'). ditch_braces additionally jumps over a quoted section.
i removed 'get_in_brackets' and modified 'ditch_braces' so it has a mode resembling the 'get_in_brackets' functionality.
mode == 0: find the text within braces after quoted section
mode == 1: find the text within braces ignoring quotes


****** ADDITIONAL INFORMATION ******

i don't know, if mode == 1 makes sense at all, but this was the
functionality of function call 'get_in_brackets(char*)'
Comments:By: Olle Johansson (oej) 2005-07-25 08:45:26

We always need to skip beyond the quotes, in order to avoid any <> within the caller ID name...

By: Olle Johansson (oej) 2005-07-25 08:47:23

Xylome: I prefer the get_in_brackets name, can we use that instead? Otherwise, it seems fine with me.

By: Frank Sautter (xylome) 2005-07-25 09:57:55

ok.
removed the 'mode' nosense (i was pretty sure this was an implementation error of the programmer of former 'get_in_brackets' - but not 100%. good to have this confirmed by you oej)
changed the name from ditch_braces to get_in_brackets.

By: Kevin P. Fleming (kpfleming) 2005-07-25 13:16:49

Can you take a look and see if using ast_strip_quoted() would be of value here?

By: Frank Sautter (xylome) 2005-07-25 14:15:35

kpflemming: no, because the function first skips over any double quoted parts and then strips away the '<' and '>'.
strings being operated on are just like email addresses "K. P. Flemming" <kpflemming@somewhere.com>. we need the part kpflemming@somewhere.com.

but thanks for reviewing this!

By: Frank Sautter (xylome) 2005-07-25 14:17:53

updated to revision 787 of chan_sip.c

By: Kevin P. Fleming (kpfleming) 2005-07-25 14:30:30

Committed to CVS HEAD, with a minor mod to eliminate a compiler warning. Thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:42:27.000-0600

Repository: asterisk
Revision: 6197

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r6197 | kpfleming | 2008-01-15 15:42:26 -0600 (Tue, 15 Jan 2008) | 2 lines

combine bracket-removing functions (bug ASTERISK-4672, with compiler warning mod)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=6197