6a3c69bdf84c82867390f2352d5c26e5dfa19304
max
Thu Apr 25 11:35:12 2013 -0700
removed EXTRA_FIELDS_SUPPORT ifdef-blocks, as they made the code very hard to read, got OK from Tim by email
diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 78f8609..c32a693 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -1415,131 +1415,97 @@
chopPrefix(dbOnly);
printf("%-20s %d\n",hOrganism(dbOnly), diff);
}
printf("
");
}
}
}
}
int extraFieldsPrint(struct trackDb *tdb,struct sqlResult *sr,char **fields,int fieldCount)
// Any extra bed or bigBed fields (defined in as and occurring after N in bed N + types.
// sr may be null for bigBeds.
// Returns number of extra fields actually printed.
{
-#ifdef EXTRA_FIELDS_SUPPORT
-struct extraField *extras = extraFieldsGet(database, tdb);
-if (extras == NULL)
- return 0;
-#else///ifndef EXTRA_FIELDS_SUPPORT
struct sqlConnection *conn = NULL ;
if (!trackHubDatabase(database))
conn = hAllocConnTrack(database, tdb);
struct asObject *as = asForTdb(conn, tdb);
hFreeConn(&conn);
if (as == NULL)
return 0;
-#endif///ndef EXTRA_FIELDS_SUPPORT
// We are trying to print extra fields so we need to figure out how many fields to skip
int start = 0;
char *type = cloneString(tdb->type);
char *word = nextWord(&type);
if (word && (sameWord(word,"bed") || sameWord(word,"bigBed")))
{
if (NULL != (word = nextWord(&type)))
start = sqlUnsigned(word);
- #ifndef EXTRA_FIELDS_SUPPORT
else // custom beds and bigBeds may not have full type "begBed 9 +"
start = max(0,slCount(as->columnList) - fieldCount);
- #else///ifdef EXTRA_FIELDS_SUPPORT
- // extraFields do not have to define all fields
- if (fieldCount > slCount(extras))
- start = 0;
- #endif///def EXTRA_FIELDS_SUPPORT
}
int count = 0;
-#ifdef EXTRA_FIELDS_SUPPORT
-struct extraField *col = extras;
-#else///ifndef EXTRA_FIELDS_SUPPORT
struct asColumn *col = as->columnList;
-#endif///ndef EXTRA_FIELDS_SUPPORT
for (;col != NULL && count < fieldCount;col=col->next)
{
if (start > 0) // skip past already known fields
{
start--;
continue;
}
int ix = count;
if (sr != NULL)
{
ix = sqlFieldColumn(sr, col->name); // If sr provided, name must match sql columnn name!
if (ix == -1 || ix > fieldCount) // so extraField really just provides a label
continue;
}
// Print as table rows
if (count == 0)
printf("
%s: | ", col->label); - if (col->type == ftInteger) - { - long long valInt = sqlLongLong(fields[ix]); - printf("%lld | %g | \n", valDouble); - } - #else///ifndef EXTRA_FIELDS_SUPPORT printf("
%s: | ", col->comment); if (col->isList || col->isArray || col->lowType->stringy) { printf("%s | %ld | \n", valInt); else printf("%s | \n", fields[ix]); // decided not to print error } else if (asTypesIsFloating(col->lowType->type)) { double valDouble = strtod(fields[ix],NULL); if (errno == 0 && valDouble != 0) printf("%g | \n", valDouble); else printf("%s | \n", fields[ix]); // decided not to print error } - #endif///ndef EXTRA_FIELDS_SUPPORT else { printf("%s | \n", fields[ix]); } } -#ifdef EXTRA_FIELDS_SUPPORT -extraFieldsFree(&extras); -#else///ifndef EXTRA_FIELDS_SUPPORT asObjectFree(&as); -#endif///ndef EXTRA_FIELDS_SUPPORT if (count > 0) printf("