Index: trunk/Ohana/src/libfits/header/F_modify.c
===================================================================
--- trunk/Ohana/src/libfits/header/F_modify.c	(revision 3522)
+++ trunk/Ohana/src/libfits/header/F_modify.c	(revision 3609)
@@ -11,5 +11,5 @@
 
   char comment[82], string[82], data[82];
-  char *p, *q;
+  char *p, *qs, *qe;
   va_list argp;
   
@@ -27,5 +27,4 @@
   p = fits_header_field (header, field, N);
   if (p == NULL)  {
-
     /* new entry, find the END of the header */
     p = fits_header_field (header, "END", 1);
@@ -45,8 +44,9 @@
     memset (p, ' ', FT_LINE_LENGTH);
   } else {
-    q = fits_keyword_end (p);
-    q += 3;
-    q = MIN (p + 80, q);
-    strncpy (comment, q, p + 80 - q);
+    /* old entry, save the comment region (is this skipping a character for non-strings?) */
+    qe = fits_keyword_end (p);
+    qe += 3;
+    qe = MIN (p + 80, qe);
+    strncpy (comment, qe, p + 80 - qe);
   }
   pad_ending (comment, ' ', 82);  /* comment must contain spaces to the end */
@@ -86,9 +86,16 @@
   /* just a comment associated with a value.  this is assumes a fixed format position for the comment */
   if (!strcmp (mode, "%C")) { 
-    q = fits_keyword_end (p);
-    strncpy (data, p + 9, MAX (MIN ((q - p - 9), 71), 0));
+    qe = fits_keyword_end (p);
+    qs = fits_keyword_start (p);
+
+    /* keep ' on ends, if there */
+    if (qe[0]  == 0x27) qe ++;
+    if (qs[-1] == 0x27) qs --;
+
+    strncpy (data, qs, MAX (MIN (qe - qs, 71), 0));
     strncpy (comment, va_arg (argp, char *), 80);
     pad_ending (comment, ' ', 82);  /* comment must contain spaces to the end */
-    snprintf (string, 81, "%-8s=%21s / %-s", field, data, comment);
+    snprintf (string, 81, "%-8s= %s / %-s", field, data, comment);
+    /* this will keep the original line, but truncate the comment */
   }
 
