Changeset 3609 for trunk/Ohana/src/libfits/header/F_modify.c
- Timestamp:
- Mar 31, 2005, 4:57:00 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/header/F_modify.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/header/F_modify.c
r3400 r3609 11 11 12 12 char comment[82], string[82], data[82]; 13 char *p, *q ;13 char *p, *qs, *qe; 14 14 va_list argp; 15 15 … … 27 27 p = fits_header_field (header, field, N); 28 28 if (p == NULL) { 29 30 29 /* new entry, find the END of the header */ 31 30 p = fits_header_field (header, "END", 1); … … 45 44 memset (p, ' ', FT_LINE_LENGTH); 46 45 } 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); 51 51 } 52 52 pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */ … … 86 86 /* just a comment associated with a value. this is assumes a fixed format position for the comment */ 87 87 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)); 90 96 strncpy (comment, va_arg (argp, char *), 80); 91 97 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 */ 93 100 } 94 101
Note:
See TracChangeset
for help on using the changeset viewer.
