cb491cef9bf0ed30c70a6223e134aba708e0afa1
1800812+nathanweeks
  Thu Jul 23 06:37:12 2020 -0500
Use fileno() to obtain integer file descriptor from FILE *

Fixes musl "error: arithmetic on pointer to an incomplete type"

diff --git src/lib/fof.c src/lib/fof.c
index 23c0799..feb3295 100644
--- src/lib/fof.c
+++ src/lib/fof.c
@@ -324,31 +324,31 @@
 static int cmpOnKey(const void *va, const void *vb)
 /* Comparison function for qsort on an array of offset pointers.
  * Sorts on key. */
 {
 const struct fofBatch *a = *((struct fofBatch **)va);
 const struct fofBatch *b = *((struct fofBatch **)vb);
 return strcmp(a->key, b->key);
 }
 
 static int cmpOnFilePos(const void *va, const void *vb)
 /* Comparison function for qsort on an array of offset pointers.
  * Sorts on file then file offset. */
 {
 const struct fofBatch *a = *((struct fofBatch **)va);
 const struct fofBatch *b = *((struct fofBatch **)vb);
-int dif = a->f - b->f;
+int dif = fileno(a->f) - fileno(b->f);
 if (dif == 0)
     dif = a->offset - b->offset;
 return dif;
 }
 
 static void elFromRec(struct fof *fof, struct fofRecord *rec, struct fofBatch *el)
 /* Fill in a batch element from record. */
 {
 FILE *ff;
 int fileIx = rec->fileIx;
 if ((ff = fof->files[fileIx]) != NULL)
     {
     el->f = ff;
     }
 else