- Timestamp:
- Mar 16, 2010, 6:44:32 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_scan.c
r21059 r27295 17 17 char *p, *q, *s, tmp[81]; 18 18 int Nchar, status; 19 double value; 19 long long value; 20 double fvalue; 20 21 21 22 /* find the correct line with field */ … … 77 78 s = gfits_keyword_start (p); /* points at first char (not ') */ 78 79 q = gfits_keyword_end (p); /* points at following space or ' */ 79 value = strtod (s, &q); 80 if ((*q == 'd') || (*q == 'D')) 81 value *= pow (10.0, atof (q + 1)); 82 83 if (!strcmp (mode, "%d")) { *va_arg (argp, int *) = value; return (TRUE); } 84 if (!strcmp (mode, "%u")) { *va_arg (argp, unsigned *) = value; return (TRUE); } 85 if (!strcmp (mode, "%ld")) { *va_arg (argp, long *) = value; return (TRUE); } 86 if (!strcmp (mode, "%hd")) { *va_arg (argp, short *) = value; return (TRUE); } 87 if (!strcmp (mode, "%f")) { *va_arg (argp, float *) = value; return (TRUE); } 88 if (!strcmp (mode, "%lf")) { *va_arg (argp, double *) = value; return (TRUE); } 80 81 if (!strcmp (mode, "%f") || !strcmp (mode, "%lf")) { 82 fvalue = strtod (s, &q); 83 if ((*q == 'd') || (*q == 'D')) 84 fvalue *= pow (10.0, atof (q + 1)); 85 86 if (!strcmp (mode, "%f")) { *va_arg (argp, float *) = fvalue; return (TRUE); } 87 if (!strcmp (mode, "%lf")) { *va_arg (argp, double *) = fvalue; return (TRUE); } 88 } 89 90 value = strtoll (s, &q, 0); 91 if ((*q == 'd') || (*q == 'D')) value *= pow (10.0, atof (q + 1)); 92 93 if (!strcmp (mode, "%d")) { *va_arg (argp, int *) = value; return (TRUE); } 94 if (!strcmp (mode, "%ld")) { *va_arg (argp, long *) = value; return (TRUE); } 95 if (!strcmp (mode, "%lld")) { *va_arg (argp, long long *) = value; return (TRUE); } 96 if (!strcmp (mode, "%Ld")) { *va_arg (argp, long long *) = value; return (TRUE); } 97 if (!strcmp (mode, "%u")) { *va_arg (argp, unsigned *) = value; return (TRUE); } 98 if (!strcmp (mode, "%lu")) { *va_arg (argp, unsigned long *) = value; return (TRUE); } 99 if (!strcmp (mode, "%llu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); } 100 if (!strcmp (mode, "%Lu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); } 101 if (!strcmp (mode, "%hd")) { *va_arg (argp, short *) = value; return (TRUE); } 89 102 90 103 /* no valid mode found */ … … 97 110 char *p, *q, *s, tmp[81]; 98 111 int Nchar, Nfield; 99 double value; 112 long long value; 113 double fvalue; 100 114 101 115 /* find the correct line with field */ … … 156 170 s = gfits_hierarch_keyword_start (p, field); /* points at first char (not ') */ 157 171 q = gfits_hierarch_keyword_end (p, field); /* points at following space or ' */ 158 value = strtod (s, &q); 159 if ((*q == 'd') || (*q == 'D')) 160 value *= pow (10.0, atof (q + 1)); 161 162 if (!strcmp (mode, "%d")) { *va_arg (argp, int *) = value; return (TRUE); } 163 if (!strcmp (mode, "%u")) { *va_arg (argp, unsigned *) = value; return (TRUE); } 164 if (!strcmp (mode, "%ld")) { *va_arg (argp, long *) = value; return (TRUE); } 165 if (!strcmp (mode, "%hd")) { *va_arg (argp, short *) = value; return (TRUE); } 166 if (!strcmp (mode, "%f")) { *va_arg (argp, float *) = value; return (TRUE); } 167 if (!strcmp (mode, "%lf")) { *va_arg (argp, double *) = value; return (TRUE); } 172 173 if (!strcmp (mode, "%f") || !strcmp (mode, "%lf")) { 174 fvalue = strtod (s, &q); 175 if ((*q == 'd') || (*q == 'D')) 176 fvalue *= pow (10.0, atof (q + 1)); 177 178 if (!strcmp (mode, "%f")) { *va_arg (argp, float *) = fvalue; return (TRUE); } 179 if (!strcmp (mode, "%lf")) { *va_arg (argp, double *) = fvalue; return (TRUE); } 180 } 181 182 value = strtoll (s, &q, 0); 183 if ((*q == 'd') || (*q == 'D')) value *= pow (10.0, atof (q + 1)); 184 185 if (!strcmp (mode, "%d")) { *va_arg (argp, int *) = value; return (TRUE); } 186 if (!strcmp (mode, "%ld")) { *va_arg (argp, long *) = value; return (TRUE); } 187 if (!strcmp (mode, "%lld")) { *va_arg (argp, long long *) = value; return (TRUE); } 188 if (!strcmp (mode, "%Ld")) { *va_arg (argp, long long *) = value; return (TRUE); } 189 if (!strcmp (mode, "%u")) { *va_arg (argp, unsigned *) = value; return (TRUE); } 190 if (!strcmp (mode, "%lu")) { *va_arg (argp, unsigned long *) = value; return (TRUE); } 191 if (!strcmp (mode, "%llu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); } 192 if (!strcmp (mode, "%Lu")) { *va_arg (argp, unsigned long long *) = value; return (TRUE); } 193 if (!strcmp (mode, "%hd")) { *va_arg (argp, short *) = value; return (TRUE); } 168 194 169 195 /* no valid mode found */
Note:
See TracChangeset
for help on using the changeset viewer.
