130c65d9512af860b1a14c406620f3ac71296ddf braney Sun May 26 12:52:25 2013 -0700 added TRIX search for track hubs. UDC'ified trix library. Refs #10426 diff --git src/lib/udc.c src/lib/udc.c index 97ed816..a864432 100644 --- src/lib/udc.c +++ src/lib/udc.c @@ -1379,30 +1379,65 @@ if (isSwapped) val = byteSwapFloat(val); return val; } double udcReadDouble(struct udcFile *file, boolean isSwapped) /* Read and optionally byte-swap double-precision floating point number. */ { double val; udcMustRead(file, &val, sizeof(val)); if (isSwapped) val = byteSwapDouble(val); return val; } +char *udcReadLine(struct udcFile *file) +/* Fetch next line from udc cache. */ +{ +char shortBuf[2], *longBuf = NULL, *buf = shortBuf; +int i, bufSize = sizeof(shortBuf); +for (i=0; ; ++i) + { + /* See if need to expand buffer, which is initially on stack, but if it gets big goes into + * heap. */ + if (i >= bufSize) + { + int newBufSize = bufSize*2; + char *newBuf = needLargeMem(newBufSize); + memcpy(newBuf, buf, bufSize); + freeMem(longBuf); + buf = longBuf = newBuf; + bufSize = newBufSize; + } + + char c; + bits64 sizeRead = udcRead(file, &c, 1); + if (sizeRead == 0) + return NULL; + buf[i] = c; + if (c == '\n') + { + buf[i] = 0; + break; + } + } +char *retString = cloneString(buf); +freeMem(longBuf); +return retString; +} + char *udcReadStringAndZero(struct udcFile *file) /* Read in zero terminated string from file. Do a freeMem of result when done. */ { char shortBuf[2], *longBuf = NULL, *buf = shortBuf; int i, bufSize = sizeof(shortBuf); for (i=0; ; ++i) { /* See if need to expand buffer, which is initially on stack, but if it gets big goes into * heap. */ if (i >= bufSize) { int newBufSize = bufSize*2; char *newBuf = needLargeMem(newBufSize); memcpy(newBuf, buf, bufSize); freeMem(longBuf);