Besides being supported by more standards, strchr() has the important characteristic of having a prototype included in <string.h> on Solaris so that 64-bit compiles know it returns a pointer, not an integer. (On Solaris, index() is only found in <strings.h>, for SunOS compatibility.)
Without this fix, makestrs segfaulted in 64-bit builds on Solaris after commit f9baaf55ff8cbd4bf018a34f181eda30d03b20dc switched to <string.h>. Signed-off-by: Alan Coopersmith <[email protected]> --- util/makestrs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/makestrs.c b/util/makestrs.c index ce0a0a3..2c4dcc8 100644 --- a/util/makestrs.c +++ b/util/makestrs.c @@ -583,7 +583,7 @@ static void DoLine(char *buf) int rlen; int len; - if ((right = index(buf, ' '))) + if ((right = strchr(buf, ' '))) *right++ = 0; else right = buf + 1; @@ -666,8 +666,8 @@ static char* DoComment (char *line) int len; /* assume that the first line with two '$' in it is the RCS tag line */ - if ((tag = index (line, '$')) == NULL) return NULL; - if ((eol = index (tag + 1, '$')) == NULL) return NULL; + if ((tag = strchr (line, '$')) == NULL) return NULL; + if ((eol = strchr (tag + 1, '$')) == NULL) return NULL; len = eol - tag; if ((ret = malloc (len)) == NULL) exit (1); -- 1.7.9.2 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
