Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Don't copy whitespace into the sql query. IMHO it doesn't make sense. It's just extra calls and extra stuff for sqlite to parse. Plus we're putting our own whitespace where it's needed.
Rolf Grossmann committed 13 years ago
commit f2c1e5b5fa20738c8da5bba2ae15744170948442
parent 7e3e69c984b9d25c45a265602f4e4cd282c25e57
1 file changed +7 -5
modified pkg/query.c
@@ -443,9 +443,10 @@ format_sql_condition(const char *str, struct sbuf *sqlcond)
				switch (str[0]) {
					case '(':
					case ')':
+
						sbuf_putc(sqlcond, str[0]);
+
						break;
					case ' ':
					case '\t':
-
						sbuf_putc(sqlcond, str[0]);
						break;
					case '|':
						if (str[1] == '|') {
@@ -467,8 +468,8 @@ format_sql_condition(const char *str, struct sbuf *sqlcond)
		} else if (state == OPERATOR_STRING || state == OPERATOR_INT) {
			/* only operators or space are allowed here */
			if (isspace(str[0])) {
-
				sbuf_putc(sqlcond, str[0]);
-
			} else if (str[0] == '~') {
+
				/* do nothing */
+
			} else if (str[0] == '~' ) {
				if (state != OPERATOR_STRING) {
					fprintf(stderr, "~ expected only for string testing");
					return (EPKG_FATAL);
@@ -516,7 +517,7 @@ format_sql_condition(const char *str, struct sbuf *sqlcond)
			}
		} else if (state == NEXT_IS_STRING || state == NEXT_IS_INT) {
			if (isspace(str[0])) {
-
				sbuf_putc(sqlcond, str[0]);
+
				/* do nothing */
			} else {
				if (state == NEXT_IS_STRING) {
					if (str[0] == '"') {
@@ -543,8 +544,9 @@ format_sql_condition(const char *str, struct sbuf *sqlcond)
			} else if (!isnumber(str[0])) {
				fprintf(stderr, "a number is expected, got: %c\n", str[0]);
				return (EPKG_FATAL);
+
			} else {
+
				sbuf_putc(sqlcond, str[0]);
			}
-
			sbuf_putc(sqlcond, str[0]);
		} else if (state == STRING || state == QUOTEDSTRING || state == SQUOTEDSTRING) {
			if ((state == STRING && isspace(str[0])) ||
			    (state == QUOTEDSTRING && str[0] == '"') ||