IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 31, 2005, 4:57:00 PM (21 years ago)
Author:
eugene
Message:

moving to autocode on imregister

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/header/F_modify.c

    r3400 r3609  
    1111
    1212  char comment[82], string[82], data[82];
    13   char *p, *q;
     13  char *p, *qs, *qe;
    1414  va_list argp;
    1515 
     
    2727  p = fits_header_field (header, field, N);
    2828  if (p == NULL)  {
    29 
    3029    /* new entry, find the END of the header */
    3130    p = fits_header_field (header, "END", 1);
     
    4544    memset (p, ' ', FT_LINE_LENGTH);
    4645  } else {
    47     q = fits_keyword_end (p);
    48     q += 3;
    49     q = MIN (p + 80, q);
    50     strncpy (comment, q, p + 80 - q);
     46    /* old entry, save the comment region (is this skipping a character for non-strings?) */
     47    qe = fits_keyword_end (p);
     48    qe += 3;
     49    qe = MIN (p + 80, qe);
     50    strncpy (comment, qe, p + 80 - qe);
    5151  }
    5252  pad_ending (comment, ' ', 82);  /* comment must contain spaces to the end */
     
    8686  /* just a comment associated with a value.  this is assumes a fixed format position for the comment */
    8787  if (!strcmp (mode, "%C")) {
    88     q = fits_keyword_end (p);
    89     strncpy (data, p + 9, MAX (MIN ((q - p - 9), 71), 0));
     88    qe = fits_keyword_end (p);
     89    qs = fits_keyword_start (p);
     90
     91    /* keep ' on ends, if there */
     92    if (qe[0]  == 0x27) qe ++;
     93    if (qs[-1] == 0x27) qs --;
     94
     95    strncpy (data, qs, MAX (MIN (qe - qs, 71), 0));
    9096    strncpy (comment, va_arg (argp, char *), 80);
    9197    pad_ending (comment, ' ', 82);  /* comment must contain spaces to the end */
    92     snprintf (string, 81, "%-8s=%21s / %-s", field, data, comment);
     98    snprintf (string, 81, "%-8s= %s / %-s", field, data, comment);
     99    /* this will keep the original line, but truncate the comment */
    93100  }
    94101
Note: See TracChangeset for help on using the changeset viewer.