|Summary:||ASTERISK-06007: [patch] enable ast_skip_blanks on const char *|
|Reporter:||Luigi Rizzo (rizzo)||Labels:|
|Date Opened:||2006-01-07 03:59:17.000-0600||Date Closed:||2006-01-07 08:46:20.000-0600|
|Environment:||Attachments:||( 0) strings.patch|
|Description:||the attached patch enables the use of ast_skip_blanks|
on const char * arguments, following the same strategy
used for strstr etc. - basically, the result is
cast to (char *), so it is up to the user to use it
Unfortunately C does not let us do any better, other than using
two different functions for const and non-const args.
|Comments:||By: Tilghman Lesher (tilghman) 2006-01-07 07:49:55.000-0600|
Why would we want to disable our checks for modification of a string we shouldn't modify?
By: Luigi Rizzo (rizzo) 2006-01-07 08:35:01.000-0600
we don't want, but it is very typical to write
s = ast_skip_blanks(s);
with both char *s and const char *s.
and C does not let us preserve the attribute.
So we have two alternative - one is the patch i submitted, the
other one is have ast_skip_blanks_const()
(actually, the main one would be ast_skip_blanks_const()
and then #define ast_skip_blanks(s) (char *)ast_skip_blanks_const(s)
I am neutral - just followed the libc approach, which
has a similar issue with strstr() and friends,
and solves it taking const char * as input and returning char *.
By: Tilghman Lesher (tilghman) 2006-01-07 08:46:08.000-0600
Committed to trunk