]> andersk Git - moira.git/commitdiff
fix some bugs in build_qual
authordanw <danw>
Wed, 25 Mar 1998 17:59:51 +0000 (17:59 +0000)
committerdanw <danw>
Wed, 25 Mar 1998 17:59:51 +0000 (17:59 +0000)
server/qrtn.pc

index b720b7cf3f898c4d522c2d50cc7358ad33cbe9be..35249c87f11f25faee4195da701c67a979c11230 100644 (file)
@@ -459,7 +459,8 @@ char *build_qual(char *fmt_buf, int argc, char *argv[])
          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;
@@ -473,10 +474,12 @@ char *build_qual(char *fmt_buf, int argc, char *argv[])
                case '*':
                  *res++ = '%';
                  *res++ = '%'; /* need to double for build_sql_stmt */
+                 pattern = 1;
                  break;
 
                case '?':
                  *res++ = '_';
+                 pattern = 1;
                  break;
 
                case '%':
@@ -497,8 +500,12 @@ char *build_qual(char *fmt_buf, int argc, char *argv[])
                }
            }
 
+         /* if no pattern characters, write over "LIKE" with " =  " */
+         if (!pattern)
+           memcpy(likepos, " =  ", 4);
+
          fmt = arg + 2;
-         if (*fmt == '\'')
+         while (*fmt != ' ')
            *res++ = *fmt++;
 
          if (escape)
This page took 0.054344 seconds and 5 git commands to generate.