Changeset 42389 for trunk/Ohana/src/libfits/header/F_print.c
- Timestamp:
- Feb 8, 2023, 12:17:35 PM (3 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/libfits/header/F_print.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
trunk/Ohana/src/libfits/header/F_print.c
r34577 r42389 8 8 9 9 static char blank[] = " "; 10 char string[ 82], line[80];10 char string[200], line[80]; 11 11 char *p; 12 12 va_list argp; … … 46 46 47 47 /* 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; } 64 64 65 65 /* 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 */ … … 69 69 strcpy (line, ptr); 70 70 line[68] = 0; 71 snprintf (string, 81, "%-8s= '%-8s' / %46s ", field, line, blank);71 snprintf (string, 200, "%-8s= '%-8s' / %46s ", field, line, blank); 72 72 goto found_it; 73 73 } … … 78 78 79 79 found_it: 80 strncpy (p, string, 80);80 memcpy (p, string, 80); // do not use strncpy_nowarn: do NOT set last byte to NULL 81 81 va_end (argp); 82 82 return (TRUE); … … 89 89 90 90 static char blank[] = " "; 91 char string[ 82], line[80];91 char string[200], line[80]; 92 92 char *p, a; 93 93 va_list argp; … … 126 126 a = va_arg (argp, int); 127 127 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); 129 129 else 130 snprintf (string, 81, "%-8s= %18s F / %46s ", field, blank, blank);130 snprintf (string, 200, "%-8s= %18s F / %46s ", field, blank, blank); 131 131 } 132 132 … … 137 137 if (!ptr) goto invalid; 138 138 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); 141 141 } 142 142 … … 154 154 if (!strcmp (mode, "%C")) goto invalid; 155 155 156 strncpy (p, string, 80);156 memcpy (p, string, 80); // do not use strncpy_nowarn: do NOT set last byte to NULL 157 157 158 158 va_end (argp);
Note:
See TracChangeset
for help on using the changeset viewer.
