IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 22, 2012, 6:26:57 AM (14 years ago)
Author:
eugene
Message:

add function gfits_set_bintable_column_reformat (sets column type to match output table description); give normal TZERO and TSCALE defaults (0,1); handle NULL argument to gfits_print/modify string functions with an error not a crash

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/libfits/header/F_modify.c

    r28246 r33128  
    7070  /* string value.  Quotes must be at least 18 chars apart */
    7171  if (!strcmp (mode, "%s")) {
    72     strncpy (data, va_arg (argp, char *), 68);
     72    char *ptr = va_arg (argp, char *);
     73    if (!ptr) goto invalid;
     74    strncpy (data, ptr, 68);
    7375    snprintf (string, 81, "%-8s= '%-18s' / %-s ", field, data, comment);
    7476    goto found_it;
     
    7678
    7779  /* failed to find mode */
     80invalid:
     81  va_end (argp);
    7882  return (FALSE);
    7983
     
    8286  va_end (argp);
    8387  return (TRUE);
    84 
    8588}
    8689
     
    143146  /* comment type of value.  */
    144147  if (!strcmp (mode, "%S")) {
    145     strncpy (data, va_arg (argp, char *), 71);
     148    char *ptr = va_arg (argp, char *);
     149    if (!ptr) goto invalid;
     150    strncpy (data, ptr, 71);
    146151    snprintf (string, 81, "%-8s %-71s", field, data);
    147152  } 
     
    157162
    158163    strncpy (data, qs, MAX (MIN (qe - qs, 71), 0));
    159     strncpy (comment, va_arg (argp, char *), 80);
     164
     165    char *ptr = va_arg (argp, char *);
     166    if (!ptr) goto invalid;
     167    strncpy (comment, ptr, 80);
    160168    gfits_pad_ending (comment, ' ', 82);  /* comment must contain spaces to the end */
    161169    snprintf (string, 81, "%-8s= %s / %-s", field, data, comment);
     
    167175  return (TRUE);
    168176
     177invalid:
     178  va_end (argp);
     179  return (FALSE);
    169180}
    170181
Note: See TracChangeset for help on using the changeset viewer.