[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: strchr() vs. ber_bvchr()

> Pierangelo Masarati writes:
>> I've also added the ber_bv[r]chr_{left,right}() calls that after
>> locating
>> the desired char, turn the first argument into a berval containing the
>> requested portion of the input one; so, for example,
>>     struct berval bv = { 16, "0123456789abcdef" }, out;
>>     ber_bvchr_left( &out, &bv, 'a' );
>>     /* sets out = { 10, "0123456789" } */
>>     ber_bvchr_right( &out, &bv, 'a' );
>>     /* sets out = { 6, "abcdef" } */
> Please rename these.  The names seem confusing to me.  In particular
> ber_bvchr_left()'s function is different from anything I expected from
> the name.  Maybe ber_substr_to[r]chr() and ber_substr_from[r]chr(),
> though those are a bit long.

I'm not quite comfortable with to/from as well; left/right indicates what
portion of the original berval should be returned in case of match.  What
about leading/trailing, or start/end, or first/last?

>> However I'm unsure about the semantics when the char is not found:
>> should they return a NULL berval or a berval respectively set to the
>> whole input value (left) and to an empty value (the right)?
> Whatever is most convenient, as long as the name doesn't indicate the
> opposite:-)

I guess setting the berval to BVNULL is mostly appropriate, at least to
recall the behavior of the original functions.  In any case, I don't see
an urgent need for these calls now.  I might axe them before they get ever


Pierangelo Masarati

Ing. Pierangelo Masarati
Responsabile Open Solution

SysNet s.n.c.
Via Dossi, 8 - 27100 Pavia - ITALIA
Office:   +39.02.23998309          
Mobile:   +39.333.4963172
Email:    pierangelo.masarati@sys-net.it