ef238f93d0c9ff7ce3debc79bbb880ff5ee1a2be markd Mon Sep 12 14:41:09 2022 -0700 readInGulp only works on regular files, reading from a pipe returns an empty result. Generate an error if one attempts to read from a pipe. Perhaps this should be recoded to read to EOF if it is not a regular file diff --git src/lib/obscure.c src/lib/obscure.c index f4d5f5e..0694097 100644 --- src/lib/obscure.c +++ src/lib/obscure.c @@ -66,30 +66,32 @@ } return digCount; } void writeGulp(char *file, char *buf, int size) /* Write out a bunch of memory. */ { FILE *f = mustOpen(file, "w"); mustWrite(f, buf, size); carefulClose(&f); } void readInGulp(char *fileName, char **retBuf, size_t *retSize) /* Read whole file in one big gulp. */ { +if (fileExists(fileName) && !isRegularFile(fileName)) + errAbort("can only read regular files with readInGulp: %s", fileName); size_t size = (size_t)fileSize(fileName); char *buf; FILE *f = mustOpen(fileName, "rb"); *retBuf = buf = needLargeMem(size+1); mustRead(f, buf, size); buf[size] = 0; /* Just in case it needs zero termination. */ fclose(f); if (retSize != NULL) *retSize = size; } void readAllWords(char *fileName, char ***retWords, int *retWordCount, char **retBuf) /* Read in whole file and break it into words. You need to freeMem both * *retWordCount and *retBuf when done. */ {