arg = strchr(fmt, '%');
} else {
/* LIKE arg: copy over up to the arg, then copy and convert arg */
- int escape = 0;
+ int escape = 0, pattern = 0;
+ char *likepos = res + (like - fmt);
strncpy(res, fmt, arg - fmt);
res += arg - fmt;
case '*':
*res++ = '%';
*res++ = '%'; /* need to double for build_sql_stmt */
+ pattern = 1;
break;
case '?':
*res++ = '_';
+ pattern = 1;
break;
case '%':
}
}
+ /* if no pattern characters, write over "LIKE" with " = " */
+ if (!pattern)
+ memcpy(likepos, " = ", 4);
+
fmt = arg + 2;
- if (*fmt == '\'')
+ while (*fmt != ' ')
*res++ = *fmt++;
if (escape)