Replacing the strchr call with two variables through a strstr call.
Calling strchr with two variables triggers a gcc 4.3/4.4
bug when used in combination with -Wlogical-op and at least -O1.
cur = str;
out = escaped;
while (*cur != 0) {
- if (strchr(toescape, *cur))
+ /* strchr work-around for gcc 4.3 & 4.4 bug with -Wlogical-op
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36513
+ */
+ char needle[2] = { *cur, 0 };
+ if (strstr(toescape, needle))
*out++ = '\\';
*out++ = *cur;
cur++;