74720ae3a83557093fcf0373528b24ad1d96f932 angie Tue Nov 14 11:33:38 2017 -0800 hgTablesTest's countNoncommentLines was skipping blank lines which caused it to get the wrong row count when querying a field that is sometimes empty. skipLeadingSpaces skips '\n' due to isspace; check for '\n' before calling it. refs #20534 diff --git src/hg/hgTablesTest/hgTablesTest.c src/hg/hgTablesTest/hgTablesTest.c index a797959..a784a27 100644 --- src/hg/hgTablesTest/hgTablesTest.c +++ src/hg/hgTablesTest/hgTablesTest.c @@ -278,38 +278,45 @@ if (formVar == NULL) errAbort("Couldn't find %s variable in form", var); return slNameInList(formVar->values, value); } boolean outTypeAvailable(struct htmlForm *form, char *value) /* Return true if outType options include value. */ { return varIncludesType(form, hgtaOutputType, value); } int countNoncommentLines(char *s) /* Count number of lines in s that don't start with # */ { int count = 0; +// beware, skipLeadingSpaces skips '\n' (isspace) so it skips blank lines. Check for '\n' first. +if (s && *s != '\n') s = skipLeadingSpaces(s); while (s != NULL && s[0] != 0) { if (s[0] != '#') ++count; s = strchr(s, '\n'); + if (s != NULL) + { + s++; + if (*s != '\n') s = skipLeadingSpaces(s); } + } return count; } int testAllFields(struct htmlPage *tablePage, struct htmlForm *mainForm, char *org, char *db, char *group, char *track, char *table) /* Get all fields and return count of rows. */ /* mainForm not used */ { struct htmlPage *outPage; int rowCount = 0; htmlPageSetVar(tablePage, NULL, hgtaOutputType, "primaryTable"); outPage = quickSubmit(tablePage, org, db, group, track, table, "allFields", hgtaDoTopSubmit, "submit"); /* check for NULL outPage */