7b6109c56aed0d87818fb8d54d963acd9c6f37b7 kent Thu Jun 21 12:48:54 2018 -0700 Adding checking on hashTwoColumnFile to make sure that the file doesn't have more than two columns. diff --git src/lib/obscure.c src/lib/obscure.c index 9b95092..e1e1467 100644 --- src/lib/obscure.c +++ src/lib/obscure.c @@ -142,34 +142,36 @@ * hash keyed by name with integer values */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[2]; struct hash *hash = hashNew(16); while (lineFileRow(lf, row)) hashAddInt(hash, row[0], lineFileNeedNum(lf, row, 1)); lineFileClose(&lf); return hash; } struct hash *hashTwoColumnFile(char *fileName) /* Given a two column file (key, value) return a hash. */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); -char *row[2]; struct hash *hash = hashNew(16); -while (lineFileRow(lf, row)) +char *row[3]; +int fields = 0; +while ((fields = lineFileChop(lf, row)) != 0) { + lineFileExpectWords(lf, 2, fields); char *name = row[0]; char *value = lmCloneString(hash->lm, row[1]); hashAdd(hash, name, value); } lineFileClose(&lf); return hash; } struct slPair *slPairTwoColumnFile(char *fileName) /* Read in a two column file into an slPair list */ { char *row[2]; struct slPair *list = NULL; struct lineFile *lf = lineFileOpen(fileName, TRUE); while (lineFileRow(lf, row))