Index: trunk/Ohana/src/libfits/table/F_read_T.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_read_T.c	(revision 39995)
+++ trunk/Ohana/src/libfits/table/F_read_T.c	(revision 39996)
@@ -29,9 +29,28 @@
 }
 
+/*********************** gfits_fread_incomplete_case ***********************************/
+int gfits_fread_incomplete_case (FILE *f, FTable *table, int padIfShort, off_t Nread, off_t Nbytes) {
+  char string[128];
+
+  snprintf (string, 128, "FITS file is short (%s)", __func__);
+  perror (string);
+  if (Nread < gfits_data_min_size (table[0].header)) {
+    fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__,  Nread,  gfits_data_min_size (table[0].header));
+    if (!padIfShort) {
+      gfits_free_table (table);
+      return FALSE;
+    }
+    memset (&table[0].buffer[Nread], 0, Nbytes - Nread);
+    fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n");
+  } else {
+    fprintf (stderr, "warning: file missing pad\n");
+  }
+  return TRUE;
+}
+
 /*********************** fits read ftable data ***********************************/
 int gfits_fread_ftable_data (FILE *f, FTable *table, int padIfShort) {
 
   off_t Nbytes, Nread;
-  char string[128];
 
   /* find buffer size */
@@ -41,16 +60,13 @@
   Nread = fread (table[0].buffer, sizeof (char), Nbytes, f);
   if (Nread != Nbytes) {
-    snprintf (string, 128, "FITS file is short (%s)", __func__);
-    perror (string);
-    if (Nread < gfits_data_min_size (table[0].header)) {
-      fprintf (stderr, "error: fits read error in %s, read "OFF_T_FMT", need "OFF_T_FMT"\n", __func__,  Nread,  gfits_data_min_size (table[0].header));
-      if (!padIfShort) {
-	gfits_free_table (table);
-	return (FALSE);
+    if (feof(f)) {
+      if (!gfits_fread_incomplete_case(f, table, padIfShort, Nread, Nbytes)) return FALSE;
+    } else {
+      off_t Nextra = Nbytes - Nread;
+      off_t Nxread = fread (&table[0].buffer[Nread], sizeof (char), Nextra, f);
+      Nread += Nxread;
+      if (Nread != Nbytes) {
+	if (!gfits_fread_incomplete_case(f, table, padIfShort, Nread, Nbytes)) return FALSE;
       }
-      memset (&table[0].buffer[Nread], 0, Nbytes - Nread);
-      fprintf (stderr, "warning: file missing data, padding with zeros: USE AT YOUR OWN RISK!\n");
-    } else {
-      fprintf (stderr, "warning: file missing pad\n");
     }
   }
