Summary: | ASTERISK-09597: [patch] Add bitwise & and bitwise | functionality | ||
Reporter: | Curt Moore (jcmoore) | Labels: | |
Date Opened: | 2007-06-05 19:37:26 | Date Closed: | 2007-06-28 15:41:11 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Functions/func_math |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) bitwise_functions.diff.txt | |
Description: | This patch adds bitwise AND (&) and bitwise OR (|) functionality to func_math. ****** ADDITIONAL INFORMATION ****** If anyone has suggestions on another operator to use instead of | for the bitwise OR , I'm open to suggestions. The | will work in the dialplan but it has to be escaped with a \ otherwise the pipe is interpreted as an option delimiter instead of an operator. | ||
Comments: | By: Dwayne Hubbard (dhubbard) 2007-06-06 18:07:10 jcmoore, I'm not seeing bitwise OR working. I've tried the following: exten => 601,1,NoOp(trying bitwise AND 7 & 3 -> ${MATH(7&3)}) exten => 601,n,NoOp(trying bitwise AND 5 & 6 -> ${MATH(5&6)}) exten => 601,n,NoOp(trying bitwise AND 5 & 7 -> ${MATH(5&7)}) exten => 601,n,NoOp(trying bitwise OR 1 | 2 -> ${MATH(1|2)}) exten => 601,n,NoOp(trying bitwise OR 1 | 3 -> ${MATH(1|3)}) I've also tried with one and more escape characters before the pipe, but no success. Can you provide a sample of your working use of this functionality? By: Curt Moore (jcmoore) 2007-06-06 18:44:23 Actually, you have to double escape the pipe and put a space after the pipe. Why this matters, I'm not sure. Hopefully someone with more experience with option parsing can shed some light. I modified your example and this works for me: exten => 601,1,NoOp(trying bitwise AND 7 & 3 -> ${MATH(7&3)}) exten => 601,n,NoOp(trying bitwise AND 5 & 6 -> ${MATH(5&6)}) exten => 601,n,NoOp(trying bitwise AND 5 & 7 -> ${MATH(5&7)}) exten => 601,n,NoOp(trying bitwise OR 1 | 2 -> ${MATH(1 \\| 2)}) exten => 601,n,NoOp(trying bitwise OR 1 | 3 -> ${MATH(1 \\| 3)}) By: Joshua C. Colp (jcolp) 2007-06-06 18:47:16 I suspect the argument parser is interpreting the | as an argument separater... perhaps a different character should be used? By: Curt Moore (jcmoore) 2007-06-06 18:57:05 Any thoughts on a preferred character? I would say that o and O are out as they could be confused with 0. What about r or R? By: Jason Parker (jparker) 2007-06-26 10:30:49 Dwayne and I talked about this yesterday, and discussed the possibility of using the words "OR" and "AND" By: Dwayne Hubbard (dhubbard) 2007-06-28 15:41:11 Changed '&' to 'AND', '|' to 'OR', and added XOR. Committed to revision 72524. Thanks jcmoore! |