From c067bbe34a677f50c7e134384735bd90ce2fae11 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 8 Jan 2016 10:40:09 +0200 Subject: [PATCH] Formatted the canonical query test. The file is now formatted according to the style guide. --- .../test/canonical_tests/canonizer.c | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/query_classifier/test/canonical_tests/canonizer.c b/query_classifier/test/canonical_tests/canonizer.c index 3f5de1e1a..21268b4dc 100644 --- a/query_classifier/test/canonical_tests/canonizer.c +++ b/query_classifier/test/canonical_tests/canonizer.c @@ -42,6 +42,12 @@ int main(int argc, char** argv) return 1; } + if (!utils_init()) + { + printf("Utils library init failed.\n"); + return 1; + } + if (mysql_library_init(num_elements, server_options, server_groups)) { printf("Embedded server init failed.\n"); @@ -57,29 +63,31 @@ int main(int argc, char** argv) return 1; } - while (!feof(infile) && fgets(readbuff, 4092, infile)) - { - fgets(readbuff,4092,infile); - char* nl = strchr(readbuff, '\n'); - if(nl) - { - *nl = '\0'; - } - psize = strlen(readbuff); - qbuff = gwbuf_alloc(psize + 7); - *(qbuff->sbuf->data + 0) = (unsigned char)psize; - *(qbuff->sbuf->data + 1) = (unsigned char)(psize>>8); - *(qbuff->sbuf->data + 2) = (unsigned char)(psize>>16); - *(qbuff->sbuf->data + 4) = 0x03; - memcpy(qbuff->start + 5,readbuff,psize + 1); - tok = qc_get_canonical(qbuff); - fprintf(outfile,"%s\n",tok); - free(tok); - gwbuf_free(qbuff); + while (!feof(infile) && fgets(readbuff, 4092, infile)) + { + char* nl = strchr(readbuff, '\n'); + if (nl) + { + *nl = '\0'; + } + if (strlen(readbuff) > 0) + { + psize = strlen(readbuff); + qbuff = gwbuf_alloc(psize + 7); + *(qbuff->sbuf->data + 0) = (unsigned char) psize; + *(qbuff->sbuf->data + 1) = (unsigned char) (psize >> 8); + *(qbuff->sbuf->data + 2) = (unsigned char) (psize >> 16); + *(qbuff->sbuf->data + 4) = 0x03; + memcpy(qbuff->start + 5, readbuff, psize + 1); + tok = qc_get_canonical(qbuff); + fprintf(outfile, "%s\n", tok); + free(tok); + gwbuf_free(qbuff); + } } fclose(infile); fclose(outfile); mysql_library_end(); - return 0; + return 0; }