0041b20e68b02a86962e10a3ba591c8d205b3178 chmalee Wed Jan 17 10:11:57 2024 -0800 Fix Table Browser csv output of header when there is an itemRgb field in the field list, which went through a special print function for some reason, refs #32865 diff --git src/hg/hgTables/hgTables.c src/hg/hgTables/hgTables.c index 2ed8bc9..7feca16 100644 --- src/hg/hgTables/hgTables.c +++ src/hg/hgTables/hgTables.c @@ -1014,47 +1014,47 @@ hOrFPrintf(f, "%d,%d,%d", (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, (rgb & 0xff)); /* Print the rest if there are any */ if (itemRgbCol < lastCol) { hOrFPrintf(f, "\t"); for (colIx = itemRgbCol+1; colIx < lastCol; ++colIx) hOrFPrintf(f, "%s\t", row[colIx]); hOrFPrintf(f, "%s\n", row[lastCol]); } else hOrFPrintf(f, "\n"); /* itemRgbCol was the last column */ } -static int itemRgbHeader(FILE *f, struct sqlResult *sr, int lastCol) +static int itemRgbHeader(FILE *f, struct sqlResult *sr, int lastCol, char outSep) /* print out bed header, recognize "reserved" column, return which * column it is, or -1 if not found */ { int colIx; int ret = -1; char *field = sqlFieldName(sr); for (colIx = 0; colIx < lastCol; ++colIx) { if (sameWord("reserved",field)) { - hOrFPrintf(f, "itemRgb\t"); + hOrFPrintf(f, "itemRgb%c", outSep); ret = colIx; } else - hOrFPrintf(f, "%s\t", field); + hOrFPrintf(f, "%s%c", field, outSep); field = sqlFieldName(sr); } if (sameWord("reserved",field)) { hOrFPrintf(f, "itemRgb\n"); ret = lastCol; } else hOrFPrintf(f, "%s\n", field); return(ret); } void doTabOutDb( char *db, char *dbVarName, char *table, char *tableVarName, FILE *f, struct sqlConnection *conn, char *fields, char outSep) @@ -1122,31 +1122,31 @@ region, isPositional, filter); if (sr == NULL) continue; /* First time through print column names. */ if (! printedColumns) { // Show only the SQL filter built from filter page options, not identifierFilter, // because identifierFilter can get enormous (like 126kB for 12,500 rsIDs). char *filterNoIds = filterClause(dbVarName, tableVarName, region->chrom, NULL); if (filterNoIds != NULL) hOrFPrintf(f, "#filter: %s\n", filterNoIds+NOSQLINJ_SIZE); hOrFPrintf(f, "#"); if (showItemRgb) { - itemRgbCol = itemRgbHeader(f, sr, lastCol); + itemRgbCol = itemRgbHeader(f, sr, lastCol, outSep); if (itemRgbCol == -1) showItemRgb = FALSE; /* did not find "reserved" */ } else { for (colIx = 0; colIx < lastCol; ++colIx) { if (outSep == ',') hOrFPrintf(f, "\""); hOrFPrintf(f, "%s", sqlFieldName(sr)); if (outSep == ',') hOrFPrintf(f, "\""); hOrFPrintf(f, "%c", outSep); } if (outSep == ',') hOrFPrintf(f, "\""); hOrFPrintf(f, "%s", sqlFieldName(sr)); if (outSep == ',') hOrFPrintf(f, "\"");