src/hg/utils/tdbQuery/tdbQuery.c 1.20
1.20 2009/12/06 20:11:21 kent
Making tdbRecord have start and end lineIx, and also text representation of stanza.
Index: src/hg/utils/tdbQuery/tdbQuery.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/utils/tdbQuery/tdbQuery.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -b -B -U 4 -r1.19 -r1.20
--- src/hg/utils/tdbQuery/tdbQuery.c 5 Dec 2009 22:47:39 -0000 1.19
+++ src/hg/utils/tdbQuery/tdbQuery.c 6 Dec 2009 20:11:21 -0000 1.20
@@ -76,9 +76,9 @@
/* Write out where record ends. */
{
struct tdbFilePos *pos;
for (pos = rec->posList; pos != NULL; pos = pos->next)
- fprintf(out, "in track %s stanza ending line %d of %s\n", rec->key, pos->lineIx, pos->fileName);
+ fprintf(out, "in track %s stanza starting line %d of %s\n", rec->key, pos->startLineIx, pos->fileName);
}
void recordWarn(struct tdbRecord *rec, char *format, ...)
/* Issue a warning message. */
@@ -297,9 +297,9 @@
struct tdbField *field;
for (field = record->fieldList; field != NULL; field = field->next)
{
if (hashLookup(uniqHash, field->name))
- errAbort("Duplicate tag %s in record ending line %d of %s", field->name,
+ errAbort("Duplicate tag %s in record starting line %d of %s", field->name,
lf->lineIx, lf->fileName);
hashAdd(uniqHash, field->name, NULL);
}
hashFree(&uniqHash);
@@ -367,29 +367,29 @@
if (newRelease == NULL && oldRelease != NULL)
{
errAbort("Have release tag for track %s at line %d of %s, but not "
"at line %d of %s",
- key, oldPos->lineIx, oldPos->fileName,
- newPos->lineIx, newPos->fileName);
+ key, oldPos->startLineIx, oldPos->fileName,
+ newPos->startLineIx, newPos->fileName);
}
else if (oldRelease == NULL && newRelease != NULL)
{
errAbort("Have release tag for track %s at line %d of %s, but not "
"at line %d of %s",
- key, newPos->lineIx, newPos->fileName,
- oldPos->lineIx, oldPos->fileName);
+ key, newPos->startLineIx, newPos->fileName,
+ oldPos->startLineIx, oldPos->fileName);
}
else
{
if (sameString(oldPos->fileName, newPos->fileName))
{
- errAbort("Duplicate tracks %s ending lines %d and %d of %s",
- key, oldPos->lineIx, newPos->lineIx, oldPos->fileName);
+ errAbort("Duplicate tracks %s starting lines %d and %d of %s",
+ key, oldPos->startLineIx, newPos->startLineIx, oldPos->fileName);
}
else
- errAbort("Duplicate tracks %s ending lines %d of %s and %d of %s",
- key, oldPos->lineIx, oldPos->fileName,
- newPos->lineIx, newPos->fileName);
+ errAbort("Duplicate tracks %s starting lines %d of %s and %d of %s",
+ key, oldPos->startLineIx, oldPos->fileName,
+ newPos->startLineIx, newPos->fileName);
}
}
}
hashAdd(uniqHash, key, record);
@@ -403,9 +403,8 @@
/* Recurse through include files. */
{
struct tdbRecord *record;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *lmFileName = lmCloneString(lm, fileName);
while ((record = tdbRecordReadOne(lf, glKeyField, lm)) != NULL)
{
struct tdbField *firstField = record->fieldList;
if (sameString(firstField->name, "include"))
@@ -414,10 +413,10 @@
for (field = firstField; field != NULL; field = field->next)
{
if (!sameString(field->name, "include"))
{
- errAbort("Non-include tag %s in an include stanza ending line %d of %s",
- field->name, lf->lineIx, lf->fileName);
+ errAbort("Non-include tag %s in an include stanza starting line %d of %s",
+ field->name, tdbRecordLineIx(record), lf->fileName);
}
char *relPath = field->val;
char dir[PATH_LEN];
splitPath(lf->fileName, dir, NULL, NULL);
@@ -425,9 +424,9 @@
safef(includeName, sizeof(includeName), "%s%s", dir, relPath);
if (hashLookup(circularHash, includeName))
{
errAbort("Including file %s in an infinite loop line %d of %s",
- includeName, lf->lineIx, lf->fileName);
+ includeName, tdbRecordLineIx(record), lf->fileName);
}
recurseThroughIncludes(includeName, lm, circularHash, pRecordList);
}
}
@@ -435,9 +434,8 @@
{
checkDupeFields(record, lf);
if (record->key != NULL)
{
- record->posList = tdbFilePosNew(lm, lmFileName, lf->lineIx);
slAddHead(pRecordList, record);
}
}
}
@@ -499,16 +497,16 @@
continue;
}
if (slCount(record->fieldList) != 2)
{
- errAbort("Expecting just two fields, track and %s, got %d in record ending line %d of %s",
- fieldName, slCount(record->fieldList), lf->lineIx, lf->fileName);
+ errAbort("Expecting just two fields, track and %s, got %d in record starting line %d of %s",
+ fieldName, slCount(record->fieldList), tdbRecordLineIx(record), lf->fileName);
}
struct tdbField *field = tdbRecordField(record, fieldName);
if (field == NULL)
{
- errAbort("Missing %s tag in record ending line %d of %s", fieldName,
- lf->lineIx, lf->fileName);
+ errAbort("Missing %s tag in record starting line %d of %s", fieldName,
+ tdbRecordLineIx(record), lf->fileName);
}
mergeRecords(oldRecord, record, glKeyField, lm);
}
lineFileClose(&lf);
@@ -552,9 +550,9 @@
{
struct tdbFilePos *parentFp = parent->posList, *childFp = child->posList;
if (!sameString(parentFp->fileName, childFp->fileName))
return BIGNUM/2;
-int distance = childFp->lineIx - parentFp->lineIx;
+int distance = childFp->startLineIx - parentFp->startLineIx;
if (distance < 0)
return BIGNUM/4 - distance;
return distance;
}
@@ -871,9 +869,9 @@
for (pos = parent->posList; pos != NULL; pos = pos->next)
{
if (sameString(pos->fileName, childPos->fileName))
{
- int distance = childPos->lineIx - pos->lineIx;
+ int distance = childPos->startLineIx - pos->startLineIx;
if (distance > 0)
{
if (distance < closestDistance)
{
@@ -900,20 +898,20 @@
for (parentFp = parent->posList; parentFp != NULL; parentFp = parentFp->next)
{
if (sameString(parentFp->fileName, childFp->fileName))
{
- if (parentFp->lineIx > childFp->lineIx)
+ if (parentFp->startLineIx > childFp->startLineIx)
errAbort("Child before parent in %s\n"
"Child (%s) at line %d, parent (%s) at line %d",
- childFp->fileName, child->key, childFp->lineIx,
- parent->key, parentFp->lineIx);
+ childFp->fileName, child->key, childFp->startLineIx,
+ parent->key, parentFp->startLineIx);
struct tdbRecord *closestParent = closestParentInFile(allParentRefs, childFp);
assert(closestParent != NULL);
if (closestParent != parent)
errAbort("%s comes between parent (%s) and child (%s) in %s\n"
"Parent at line %d, child at line %d.",
closestParent->key, parent->key, child->key, childFp->fileName,
- parentFp->lineIx, childFp->lineIx);
+ parentFp->startLineIx, childFp->startLineIx);
}
}
}
}
@@ -1032,9 +1030,9 @@
recordAbort(record, "using reserved field 'filePos'");
struct tdbFilePos *fp;
dyStringClear(fileString);
for (fp = record->posList; fp != NULL; fp = fp->next)
- dyStringPrintf(fileString, " %s %d", fp->fileName, fp->lineIx);
+ dyStringPrintf(fileString, " %s %d", fp->fileName, fp->startLineIx);
fileField = tdbFieldNew("filePos", fileString->string, lm);
slAddTail(&record->fieldList, fileField);