Index: trunk/psLib/src/fits/psFitsTable.c
===================================================================
--- trunk/psLib/src/fits/psFitsTable.c	(revision 12431)
+++ trunk/psLib/src/fits/psFitsTable.c	(revision 12549)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-14 00:39:50 $
+ *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-22 21:40:47 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -585,5 +585,5 @@
                         (char**)columnTypes->data, // format of the columns
                         NULL, // physical unit of columns
-                        (char*)extname, // extension name; casting away const because cfitsio is horrible
+                        NULL, // skip extension name: we set the by hand below
                         &status);
     } else {
@@ -605,5 +605,5 @@
                          (char**)columnTypes->data, // format of the columns
                          NULL, // physical unit of columns
-                         (char*)extname, // extension name; casting away const because cfitsio is horrible
+                         NULL, // skip extension name: we set this by hand below
                          0, &status);
     }
@@ -629,4 +629,13 @@
     }
 
+    // write the header, if any.
+    if (extname && strlen(extname) > 0) {
+        if (!psFitsSetExtName(fits, extname)) {
+	    psError(PS_ERR_IO, false, "Unable to write FITS header extension name.\n");
+	    psFree(colSpecsIter);
+	    psFree(colSpecs);
+	    return false;
+	}
+    }
 
     // cfitsio requires that we write the data by columns --- urgh!
