- Timestamp:
- Jan 31, 2023, 10:55:31 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20220316/Ohana/src/libfits/header/F_modify.c
r42116 r42343 48 48 qe += 3; 49 49 qe = MIN (p + 80, qe); 50 strncpy (comment, qe, p + 80 - qe);50 strncpy_nowarn (comment, qe, p + 80 - qe); 51 51 } 52 52 gfits_pad_ending (comment, 0x20, 82); /* comment must contain spaces to the end */ 53 53 54 54 /* write the numeric modes */ 55 if (!strcmp (mode, "%d")) { snprintf (string, 200, "%-8s= %20d / %-s ", field, va_arg (argp, int), comment); goto found_it; }56 if (!strcmp (mode, "%ld")) { snprintf (string, 200, "%-8s= %20ld / %-s ", field, va_arg (argp, long), comment); goto found_it; }57 if (!strcmp (mode, "%lld")) { snprintf (string, 200, "%-8s= %20lld / %-s ", field, va_arg (argp, long long), comment); goto found_it; }58 if (!strcmp (mode, "%Ld")) { snprintf (string, 200, "%-8s= %20lld / %-s ", field, va_arg (argp, long long), comment); goto found_it; }59 if (!strcmp (mode, "%u")) { snprintf (string, 200, "%-8s= %20u / %-s ", field, va_arg (argp, unsigned), comment); goto found_it; }55 if (!strcmp (mode, "%d")) { snprintf (string, 200, "%-8s= %20d / %-s ", field, va_arg (argp, int), comment); goto found_it; } 56 if (!strcmp (mode, "%ld")) { snprintf (string, 200, "%-8s= %20ld / %-s ", field, va_arg (argp, long), comment); goto found_it; } 57 if (!strcmp (mode, "%lld")) { snprintf (string, 200, "%-8s= %20lld / %-s ", field, va_arg (argp, long long), comment); goto found_it; } 58 if (!strcmp (mode, "%Ld")) { snprintf (string, 200, "%-8s= %20lld / %-s ", field, va_arg (argp, long long), comment); goto found_it; } 59 if (!strcmp (mode, "%u")) { snprintf (string, 200, "%-8s= %20u / %-s ", field, va_arg (argp, unsigned), comment); goto found_it; } 60 60 if (!strcmp (mode, "%lu")) { snprintf (string, 200, "%-8s= %20lu / %-s ", field, va_arg (argp, unsigned long), comment); goto found_it; } 61 61 if (!strcmp (mode, "%llu")) { snprintf (string, 200, "%-8s= %20llu / %-s ", field, va_arg (argp, unsigned long long), comment); goto found_it; } 62 62 if (!strcmp (mode, "%Lu")) { snprintf (string, 200, "%-8s= %20llu / %-s ", field, va_arg (argp, unsigned long long), comment); goto found_it; } 63 if (!strcmp (mode, "%hd")) { snprintf (string, 200, "%-8s= %20d / %-s ", field, va_arg (argp, int), comment); goto found_it; }64 if (!strcmp (mode, "%f")) { snprintf (string, 200, "%-8s= %20.10f / %-s ", field, va_arg (argp, double), comment); goto found_it; }65 if (!strcmp (mode, "%lf")) { snprintf (string, 200, "%-8s= %20.10f / %-s ", field, va_arg (argp, double), comment); goto found_it; }66 if (!strcmp (mode, "%e")) { snprintf (string, 200, "%-8s= %20.10E / %-s ", field, va_arg (argp, double), comment); goto found_it; }67 if (!strcmp (mode, "%le")) { snprintf (string, 200, "%-8s= %20.10E / %-s ", field, va_arg (argp, double), comment); goto found_it; }68 if (!strcmp (mode, "%g")) { snprintf (string, 200, "%-8s= %20.10G / %-s ", field, va_arg (argp, double), comment); goto found_it; }69 if (!strcmp (mode, "%lg")) { snprintf (string, 200, "%-8s= %20.10G / %-s ", field, va_arg (argp, double), comment); goto found_it; }70 if (!strcmp (mode, "%jd")) { snprintf (string, 200, "%-8s= %20jd / %-s ", field, va_arg (argp, intmax_t), comment); goto found_it; }63 if (!strcmp (mode, "%hd")) { snprintf (string, 200, "%-8s= %20d / %-s ", field, va_arg (argp, int), comment); goto found_it; } 64 if (!strcmp (mode, "%f")) { snprintf (string, 200, "%-8s= %20.10f / %-s ", field, va_arg (argp, double), comment); goto found_it; } 65 if (!strcmp (mode, "%lf")) { snprintf (string, 200, "%-8s= %20.10f / %-s ", field, va_arg (argp, double), comment); goto found_it; } 66 if (!strcmp (mode, "%e")) { snprintf (string, 200, "%-8s= %20.10E / %-s ", field, va_arg (argp, double), comment); goto found_it; } 67 if (!strcmp (mode, "%le")) { snprintf (string, 200, "%-8s= %20.10E / %-s ", field, va_arg (argp, double), comment); goto found_it; } 68 if (!strcmp (mode, "%g")) { snprintf (string, 200, "%-8s= %20.10G / %-s ", field, va_arg (argp, double), comment); goto found_it; } 69 if (!strcmp (mode, "%lg")) { snprintf (string, 200, "%-8s= %20.10G / %-s ", field, va_arg (argp, double), comment); goto found_it; } 70 if (!strcmp (mode, "%jd")) { snprintf (string, 200, "%-8s= %20jd / %-s ", field, va_arg (argp, intmax_t), comment); goto found_it; } 71 71 72 72 /* string value. Quotes must be at least 8 chars apart */ … … 74 74 char *ptr = va_arg (argp, char *); 75 75 if (!ptr) goto invalid; 76 strncpy (data, ptr, 68);76 strncpy_nowarn (data, ptr, 68); 77 77 snprintf (string, 200, "%-8s= '%-8s' / %-s ", field, data, comment); 78 78 goto found_it; … … 85 85 86 86 found_it: 87 strncpy (p, string, 80);87 memcpy (p, string, 80); // do not use strncpy_nowarn: do NOT set last byte to NULL 88 88 va_end (argp); 89 89 return (TRUE); … … 134 134 qe += 3; 135 135 qe = MIN (p + 80, qe); 136 strncpy (comment, qe, p + 80 - qe);136 strncpy_nowarn (comment, qe, p + 80 - qe); 137 137 } 138 138 gfits_pad_ending (comment, 0x20, 82); /* comment must contain spaces to the end */ … … 150 150 char *ptr = va_arg (argp, char *); 151 151 if (!ptr) goto invalid; 152 strncpy (data, ptr, 71);152 strncpy_nowarn (data, ptr, 71); 153 153 snprintf (string, 200, "%-8s %-71s", field, data); 154 154 } … … 163 163 if (qs[-1] == 0x27) qs --; 164 164 165 strncpy (data, qs, MAX (MIN (qe - qs, 71), 0));165 strncpy_nowarn (data, qs, MAX (MIN (qe - qs, 71), 0)); 166 166 167 167 char *ptr = va_arg (argp, char *); 168 168 if (!ptr) goto invalid; 169 strncpy (comment, ptr, 80);169 strncpy_nowarn (comment, ptr, 80); 170 170 gfits_pad_ending (comment, 0x20, 82); /* comment must contain spaces to the end */ 171 171 snprintf (string, 200, "%-8s= %s / %-s", field, data, comment); … … 173 173 } 174 174 175 strncpy (p, string, 80);175 memcpy (p, string, 80); // do not use strncpy_nowarn: do NOT set last byte to NULL 176 176 va_end (argp); 177 177 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
