- Timestamp:
- Mar 16, 2022, 4:21:02 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20220316/Ohana/src/libfits/header/F_modify.c
r38441 r42116 8 8 /* this function is extremely similar to gfits_print, except it allows for changing an existing field. */ 9 9 10 char comment[82], string[82], data[82]; 10 // the output string needs to be long enough to keep the compiler from 11 // complaining, even though the string cannot be more than 80 chars 12 char comment[82], string[200], data[82]; 11 13 char *p, *qe; 12 14 va_list argp; … … 14 16 va_start (argp, N); 15 17 bzero (data, 82); 16 bzero (string, 82);18 bzero (string, 200); 17 19 bzero (comment, 82); 18 20 … … 51 53 52 54 /* write the numeric modes */ 53 if (!strcmp (mode, "%d")) { snprintf (string, 81, "%-8s= %20d / %-s ", field, va_arg (argp, int), comment); goto found_it; }54 if (!strcmp (mode, "%ld")) { snprintf (string, 81, "%-8s= %20ld / %-s ", field, va_arg (argp, long), comment); goto found_it; }55 if (!strcmp (mode, "%lld")) { snprintf (string, 81, "%-8s= %20lld / %-s ", field, va_arg (argp, long long), comment); goto found_it; }56 if (!strcmp (mode, "%Ld")) { snprintf (string, 81, "%-8s= %20lld / %-s ", field, va_arg (argp, long long), comment); goto found_it; }57 if (!strcmp (mode, "%u")) { snprintf (string, 81, "%-8s= %20u / %-s ", field, va_arg (argp, unsigned), comment); goto found_it; }58 if (!strcmp (mode, "%lu")) { snprintf (string, 81, "%-8s= %20lu / %-s ", field, va_arg (argp, unsigned long), comment); goto found_it; }59 if (!strcmp (mode, "%llu")) { snprintf (string, 81, "%-8s= %20llu / %-s ", field, va_arg (argp, unsigned long long), comment); goto found_it; }60 if (!strcmp (mode, "%Lu")) { snprintf (string, 81, "%-8s= %20llu / %-s ", field, va_arg (argp, unsigned long long), comment); goto found_it; }61 if (!strcmp (mode, "%hd")) { snprintf (string, 81, "%-8s= %20d / %-s ", field, va_arg (argp, int), comment); goto found_it; }62 if (!strcmp (mode, "%f")) { snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double), comment); goto found_it; }63 if (!strcmp (mode, "%lf")) { snprintf (string, 81, "%-8s= %20.10f / %-s ", field, va_arg (argp, double), comment); goto found_it; }64 if (!strcmp (mode, "%e")) { snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double), comment); goto found_it; }65 if (!strcmp (mode, "%le")) { snprintf (string, 81, "%-8s= %20.10E / %-s ", field, va_arg (argp, double), comment); goto found_it; }66 if (!strcmp (mode, "%g")) { snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double), comment); goto found_it; }67 if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %-s ", field, va_arg (argp, double), comment); goto found_it; }68 if (!strcmp (mode, "%jd")) { snprintf (string, 81, "%-8s= %20jd / %-s ", field, va_arg (argp, intmax_t), 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 if (!strcmp (mode, "%lu")) { snprintf (string, 200, "%-8s= %20lu / %-s ", field, va_arg (argp, unsigned long), comment); goto found_it; } 61 if (!strcmp (mode, "%llu")) { snprintf (string, 200, "%-8s= %20llu / %-s ", field, va_arg (argp, unsigned long long), comment); goto found_it; } 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; } 69 71 70 72 /* string value. Quotes must be at least 8 chars apart */ … … 73 75 if (!ptr) goto invalid; 74 76 strncpy (data, ptr, 68); 75 snprintf (string, 81, "%-8s= '%-8s' / %-s ", field, data, comment);77 snprintf (string, 200, "%-8s= '%-8s' / %-s ", field, data, comment); 76 78 goto found_it; 77 79 } … … 94 96 /* this function is extremely similar to gfits_print, except it allows for changing an existing field. */ 95 97 96 char comment[82], string[ 82], data[82];98 char comment[82], string[200], data[82]; 97 99 char *p, *qs, *qe; 98 100 va_list argp; … … 100 102 va_start (argp, N); 101 103 bzero (data, 82); 102 bzero (string, 82);103 104 bzero (comment, 82); 105 bzero (string, 200); 104 106 105 107 if (mode[0] != '%') { … … 139 141 if (!strcmp (mode, "%t")) { 140 142 if (va_arg (argp, int)) 141 snprintf (string, 81, "%-8s= %18s T / %-s ", field, " ", comment);143 snprintf (string, 200, "%-8s= %18s T / %-s ", field, " ", comment); 142 144 else 143 snprintf (string, 81, "%-8s= %18s F / %-s ", field, " ", comment);145 snprintf (string, 200, "%-8s= %18s F / %-s ", field, " ", comment); 144 146 } 145 147 … … 149 151 if (!ptr) goto invalid; 150 152 strncpy (data, ptr, 71); 151 snprintf (string, 81, "%-8s %-71s", field, data);153 snprintf (string, 200, "%-8s %-71s", field, data); 152 154 } 153 155 … … 167 169 strncpy (comment, ptr, 80); 168 170 gfits_pad_ending (comment, 0x20, 82); /* comment must contain spaces to the end */ 169 snprintf (string, 81, "%-8s= %s / %-s", field, data, comment);171 snprintf (string, 200, "%-8s= %s / %-s", field, data, comment); 170 172 /* this will keep the original line, but truncate the comment */ 171 173 }
Note:
See TracChangeset
for help on using the changeset viewer.
