From 6e003fd5f174a8e312d799d7f8812c2a5b87e433 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 6 Aug 2007 12:59:04 -0700 Subject: Replace index/rindex with C89 standard strchr/strrchr --- src/WrFFrI.c | 12 ++++++------ src/data.c | 2 +- src/parse.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/WrFFrI.c b/src/WrFFrI.c index 363f6c4..6477188 100644 --- a/src/WrFFrI.c +++ b/src/WrFFrI.c @@ -117,9 +117,9 @@ XpmWriteFileFromXpmImage(filename, image, info) #ifdef VMS name = filename; #else - if (!(name = rindex(filename, '/')) + if (!(name = strrchr(filename, '/')) #ifdef AMIGA - && !(name = rindex(filename, ':')) + && !(name = strrchr(filename, ':')) #endif ) name = filename; @@ -127,24 +127,24 @@ XpmWriteFileFromXpmImage(filename, image, info) name++; #endif /* let's try to make a valid C syntax name */ - if (index(name, '.')) { + if (strchr(name, '.')) { strncpy(new_name, name, sizeof(new_name)); new_name[sizeof(new_name)-1] = '\0'; /* change '.' to '_' */ name = s = new_name; - while ((dot = index(s, '.'))) { + while ((dot = strchr(s, '.'))) { *dot = '_'; s = dot; } } - if (index(name, '-')) { + if (strchr(name, '-')) { if (name != new_name) { strcpy(new_name, name); name = new_name; } /* change '-' to '_' */ s = name; - while ((dot = index(s, '-'))) { + while ((dot = strchr(s, '-'))) { *dot = '_'; s = dot; } diff --git a/src/data.c b/src/data.c index d0b86ee..87f4b3f 100644 --- a/src/data.c +++ b/src/data.c @@ -422,7 +422,7 @@ xpmParseHeader(data) if (!l) return (XpmFileInvalid); buf[l] = '\0'; - ptr = rindex(buf, '_'); + ptr = strrchr(buf, '_'); if (!ptr || strncmp("_format", ptr, l - (ptr - buf))) return XpmFileInvalid; /* this is definitely an XPM 1 file */ diff --git a/src/parse.c b/src/parse.c index c5ec1a1..bd5b52c 100644 --- a/src/parse.c +++ b/src/parse.c @@ -138,7 +138,7 @@ xpmParseValues(data, width, height, ncolors, cpp, ptr = buf; got_one = False; while (!got_one) { - ptr = index(ptr, '_'); + ptr = strchr(ptr, '_'); if (!ptr) return (XpmFileInvalid); switch (l - (ptr - buf)) { -- cgit v1.2.3