[asterisk-dev] [design] Matching algorithm
Leif Madsen
leif.madsen at asteriskdocs.org
Tue Jun 3 14:32:04 CDT 2008
Steve Edwards wrote:
>> On Tue, 2008-06-03 at 16:33 +0000, Tony Mountifield wrote:
>> Unfortunately, I know from experience that a _very large_ number of
>> people are using lower-case _nxxnxxxxxx for pattern matching, and so
>> even though I'd personally like to have only allowed upper-case letters
>> from the beginning, I think we'd be doing users in general a big
>> disservice by changing things at this point. Isn't hindsight a
>> wonderful thing?
>
> I use lower case everywhere except global and channel variables:
>
> ; templates
> [digit-timeout](!)
> exten = t,1, goto(${CONTEXT},s,1)
> [h](!)
> exten = h,1, verbose(1,${CONTEXT}:${EXTEN}:${PRIORITY})
> exten = h,n, goto(finish-call,h,1)
> [i](!)
> exten = i,1, goto(${CONTEXT},s,1)
> [pound-hangup](!)
> exten = #,1, hangup()
> [pound-main](!)
> exten = #,1, goto(main-menu,s,1)
> [s](!)
> exten = s,1, verbose(1,${CONTEXT}:${EXTEN}:${PRIORITY})
> [x](!)
> exten = _x.,1, verbose(1,${CONTEXT}:${EXTEN}:${PRIORITY})
>
> ; an example context
> [example](digit-timeout,h,i,pound-main,s)
> exten = s,n, dial(sip/example)
> exten = s,n, hangup()
>
> I think treating lowercase differently than uppercase would introduce
> hardship on existing dialplans, cause future dialplan writers grief,
> foster the "here the developers go again with another needless change just
> for the !@#$ of it" mentality, and contribute to global warming.
Hrmmm... well in this case, you're showing that those lowercase letters
are actually matching specifically, and not in a pattern match (except
for your one use of _x.)
My main reason for favouring the use of lowercase words to match
literal, is because I do a lot of this (because I hate writing 50 lines
of _NXXNXXXXXX in my dialplans). An example!
exten => _1NXXNXXXXXX,1,Verbose(1,Incoming call to ${EXTEN} from
${CALLERID(num)})
exten => _1NXXNXXXXXX,n,Set(ORIG_EXTEN=${EXTEN})
exten => _1NXXNXXXXXX,n,Goto(call,1)
exten => call,1,NoOp()
exten => call,n,...
exten => call,n,...
Now even while writing this, my problem was that my original intension
was to use 'call_handler' for the extension, but I'd have had to do this:
exten => call_ha[n]dler,1,NoOp()
exten => call_ha[n]dler,n,...
exten => call_ha[n]dler,n,...
So this is a place where I might advocate the use of an option in the
[general] section of the dialplan to have something like:
lowercasepatternmatch=<yes|no>
This way I could disable it, and you could enable it, and we'd both be
happy. So what the ideal in my mind would be is to fix lowercase pattern
matching to have the same weight as uppercase pattern matching (fix the
original bug), and to enable an option that would allow you|me to
disable lowercase pattern matching altogether for those of us who use a
lot of named extensions in our dialplans (in order to get away from
having to write complex, error prone pattern matches).
I have no idea how complex of a problem that poses, but if it were
implemented, I'd suggest that lowercasepatternmatch default to yes.
--
Leif Madsen
http://www.leifmadsen.com
http://www.oreilly.com/catalog/asterisk
More information about the asterisk-dev
mailing list