I think I’ve found an edge case with the string transformations for line.count:

In pv_trans.c, the following code does not appear to consider the last line if 
there are multiple lines and the last one is not terminated with \n.

case TR_LINE_COUNT:
    n=0;
    for(i=0; i<val->rs.len; i++)
        if(val->rs.s[i]=='\n')
            n++;
    if(n==0 && val->rs.len>0)
        n = 1;
    val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR;
    val->ri = n;
    val->rs.s = int2str(val->ri, &val->rs.len);
    break;

This means that my count is always one off unless I force a blank line at the 
end of my string.


Also, this code does not cater for cases where there is a different line 
terminator, such as CR or CRLF as is the case when the string comes from a Mac 
or windows system, respectively; it might be useful to have a transformation 
for doing that as I’ve had to hack it using s.replace with hexadecimal escape 
codes (\r and \n do not work) in a variable.


With every blessing,
—
Daniel Donoghue

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!
Edit mailing list options or unsubscribe:
  * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to