IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2023, 12:17:35 PM (3 years ago)
Author:
eugene
Message:

merge from eam_branches/ipp-20220316. fixes for more pendantic gcc; add opihi memory stats; string vector improvements; use named macros for fixed string lengths

Location:
trunk/Ohana
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/libfits/header/F_print.c

    r34577 r42389  
    88
    99  static char blank[] = " ";
    10   char string[82], line[80];
     10  char string[200], line[80];
    1111  char *p;
    1212  va_list argp; 
     
    4646
    4747  /* write the numeric modes */
    48   if (!strcmp (mode, "%d"))  { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
    49   if (!strcmp (mode, "%ld")) { snprintf (string, 81, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),               blank); goto found_it; }
    50   if (!strcmp (mode, "%lld")){ snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
    51   if (!strcmp (mode, "%Ld")) { snprintf (string, 81, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
    52   if (!strcmp (mode, "%u"))  { snprintf (string, 81, "%-8s= %20u / %46s ",    field, va_arg (argp, unsigned),           blank); goto found_it; }
    53   if (!strcmp (mode, "%lu")) { snprintf (string, 81, "%-8s= %20lu / %46s ",   field, va_arg (argp, unsigned long),      blank); goto found_it; }
    54   if (!strcmp (mode, "%llu")){ snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
    55   if (!strcmp (mode, "%Lu")) { snprintf (string, 81, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
    56   if (!strcmp (mode, "%hd")) { snprintf (string, 81, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
    57   if (!strcmp (mode, "%f"))  { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    58   if (!strcmp (mode, "%lf")) { snprintf (string, 81, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    59   if (!strcmp (mode, "%e"))  { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    60   if (!strcmp (mode, "%le")) { snprintf (string, 81, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    61   if (!strcmp (mode, "%g"))  { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    62   if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
    63   if (!strcmp (mode, "%jd")) { snprintf (string, 81, "%-8s= %20jd / %46s ",   field, va_arg (argp, intmax_t),           blank); goto found_it; }
     48  if (!strcmp (mode, "%d"))  { snprintf (string, 200, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
     49  if (!strcmp (mode, "%ld")) { snprintf (string, 200, "%-8s= %20ld / %46s ",   field, va_arg (argp, long),               blank); goto found_it; }
     50  if (!strcmp (mode, "%lld")){ snprintf (string, 200, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
     51  if (!strcmp (mode, "%Ld")) { snprintf (string, 200, "%-8s= %20lld / %46s ",  field, va_arg (argp, long long),          blank); goto found_it; }
     52  if (!strcmp (mode, "%u"))  { snprintf (string, 200, "%-8s= %20u / %46s ",    field, va_arg (argp, unsigned),           blank); goto found_it; }
     53  if (!strcmp (mode, "%lu")) { snprintf (string, 200, "%-8s= %20lu / %46s ",   field, va_arg (argp, unsigned long),      blank); goto found_it; }
     54  if (!strcmp (mode, "%llu")){ snprintf (string, 200, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
     55  if (!strcmp (mode, "%Lu")) { snprintf (string, 200, "%-8s= %20llu / %46s ",  field, va_arg (argp, unsigned long long), blank); goto found_it; }
     56  if (!strcmp (mode, "%hd")) { snprintf (string, 200, "%-8s= %20d / %46s ",    field, va_arg (argp, int),                blank); goto found_it; }
     57  if (!strcmp (mode, "%f"))  { snprintf (string, 200, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     58  if (!strcmp (mode, "%lf")) { snprintf (string, 200, "%-8s= %20.10f / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     59  if (!strcmp (mode, "%e"))  { snprintf (string, 200, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     60  if (!strcmp (mode, "%le")) { snprintf (string, 200, "%-8s= %20.10E / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     61  if (!strcmp (mode, "%g"))  { snprintf (string, 200, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     62  if (!strcmp (mode, "%lg")) { snprintf (string, 200, "%-8s= %20.10G / %46s ", field, va_arg (argp, double),             blank); goto found_it; }
     63  if (!strcmp (mode, "%jd")) { snprintf (string, 200, "%-8s= %20jd / %46s ",   field, va_arg (argp, intmax_t),           blank); goto found_it; }
    6464
    6565  /* string value.  Quotes must be at least 8 chars apart.  Longer lines will this should be fixed to allow arbitrary string lengths, up to 69 chars */
     
    6969    strcpy (line, ptr);
    7070    line[68] = 0;
    71     snprintf (string, 81, "%-8s= '%-8s' / %46s ", field, line, blank);
     71    snprintf (string, 200, "%-8s= '%-8s' / %46s ", field, line, blank);
    7272    goto found_it;
    7373  }
     
    7878
    7979found_it:
    80   strncpy (p, string, 80);
     80  memcpy (p, string, 80); // do not use strncpy_nowarn: do NOT set last byte to NULL
    8181  va_end (argp);
    8282  return (TRUE);
     
    8989
    9090  static char blank[] = " ";
    91   char string[82], line[80];
     91  char string[200], line[80];
    9292  char *p, a;
    9393  va_list argp; 
     
    126126    a = va_arg (argp, int);
    127127    if (a == 1)
    128       snprintf (string, 81, "%-8s= %18s T / %46s ", field, blank, blank);
     128      snprintf (string, 200, "%-8s= %18s T / %46s ", field, blank, blank);
    129129    else
    130       snprintf (string, 81, "%-8s= %18s F / %46s ", field, blank, blank);
     130      snprintf (string, 200, "%-8s= %18s F / %46s ", field, blank, blank);
    131131  }
    132132
     
    137137    if (!ptr) goto invalid;
    138138    bzero (line, 80);
    139     strncpy (line, ptr, 71);
    140     snprintf (string, 81, "%-8s %-71s", field, line);
     139    strncpy_nowarn (line, ptr, 71);
     140    snprintf (string, 200, "%-8s %-71s", field, line);
    141141  } 
    142142
     
    154154  if (!strcmp (mode, "%C")) goto invalid;
    155155
    156   strncpy (p, string, 80);
     156  memcpy (p, string, 80); // do not use strncpy_nowarn: do NOT set last byte to NULL
    157157 
    158158  va_end (argp);
Note: See TracChangeset for help on using the changeset viewer.