cce51ca0744763b5d358c73cf6190d7a6ea29399 braney Sun Jan 30 07:38:58 2022 -0800 oops ... added an errant lineFileClose on the last checkin diff --git src/lib/fieldedTable.c src/lib/fieldedTable.c index 9875d08..73a9904 100644 --- src/lib/fieldedTable.c +++ src/lib/fieldedTable.c @@ -247,62 +247,64 @@ table->startsSharp = startsSharp; return table; } struct fieldedTable *fieldedTableAttach(struct lineFile *lf, char *requiredFields[], int requiredCount) /* Read table from tab-separated file with a #header line that defines the fields * from already open lineFile.. Ensures all requiredFields (if any) are present. * should be NULL for most purposes. */ { struct fieldedTable *table = fieldedTableReadTabHeader(lf, requiredFields, requiredCount); char *row[table->fieldCount]; while (lineFileNextRowTab(lf, row, table->fieldCount)) { fieldedTableAdd(table, row, table->fieldCount, lf->lineIx); } - -/* Clean up and go home. */ -lineFileClose(&lf); return table; } struct fieldedTable *fieldedTableFromTabFile(char *fileName, char *reportFileName, char *requiredFields[], int requiredCount) /* Read table from tab-separated file with a #header line that defines the fields. Ensures * all requiredFields (if any) are present. The reportFileName is just used for error reporting and * should be NULL for most purposes. This is used by edwSubmit though which * first copies to a local file, and we want to report errors from the remote file. * We do know the remote file exists at least, because we just copied it. */ { /* Open file with fileName */ struct lineFile *lf = netLineFileOpen(fileName); /* Substitute in reportFileName for error reporting */ if (reportFileName != NULL) { if (differentString(reportFileName, fileName)) { freeMem(lf->fileName); lf->fileName = cloneString(reportFileName); } } else { reportFileName = fileName; } -return fieldedTableAttach(lf, requiredFields, requiredCount); +struct fieldedTable *table = fieldedTableAttach(lf, requiredFields, requiredCount); + +/* Clean up and go home. */ +lineFileClose(&lf); + +return table; } void fieldedTableToTabFileWithId(struct fieldedTable *table, char *fileName, char *idField, int startId) /* Write out a fielded table back to file. If idField is non-NULL it will be added * to the start of each output line as a steadily incrementing integer starting with startId. */ { FILE *f = mustOpen(fileName, "w"); /* Write out header row with optional leading # */ if (table->startsSharp) fputc('#', f); int curId = startId; int i; if (idField)