diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2020-04-20 01:56:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 01:56:17 -0400 |
commit | 110489259c0696c0cee5bec6ad7695a0c93d4e74 (patch) | |
tree | 34a82b9e686c15e2acb00d62a0f8b95ac126de6d /lib/manifest.c | |
parent | 57c9489b28a481abc078ad3a2dd197079f9c414b (diff) | |
parent | 667574b2e5628976c0cc0ddc2e1ae25bf5c0fd02 (diff) | |
download | spmc-110489259c0696c0cee5bec6ad7695a0c93d4e74.tar.gz |
Merge pull request #28 from jhunkeler/circleci-macos
Circleci macos
Diffstat (limited to 'lib/manifest.c')
-rw-r--r-- | lib/manifest.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/manifest.c b/lib/manifest.c index a95b566..965665e 100644 --- a/lib/manifest.c +++ b/lib/manifest.c @@ -440,7 +440,16 @@ Manifest *manifest_read(char *file_or_url) { while (fgets(dptr, BUFSIZ, fp) != NULL) { total_records++; } - total_records--; // header does not count + + if (total_records == 0) { + spmerrno = SPM_ERR_MANIFEST_INVALID; + return NULL; + } + + // There's a header, but don't count it in the total + total_records--; + + // Going to reprocess the file again, so rewind rewind(fp); Manifest *info = (Manifest *)calloc(1, sizeof(Manifest)); @@ -582,10 +591,13 @@ void manifestlist_free(ManifestList *pManifestList) { */ void manifestlist_append(ManifestList *pManifestList, char *path) { Manifest *manifest = manifest_read(path); - if (manifest == NULL) { + if (manifest == NULL && spmerrno == 0) { fprintf(stderr, "Failed to create manifest in memory\n"); fprintf(SYSERROR); exit(1); + } else if (spmerrno == SPM_ERR_MANIFEST_EMPTY || spmerrno == SPM_ERR_MANIFEST_INVALID) { + manifest = calloc(1, sizeof(Manifest)); + manifest->packages = calloc(1, sizeof(ManifestPackage *)); } Manifest **tmp = realloc(pManifestList->data, (pManifestList->num_alloc + 1) * sizeof(Manifest *)); |