Changeset 39324 for trunk/Ohana/src/libfits/table/F_set_column.c
- Timestamp:
- Jan 27, 2016, 11:18:36 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/table/F_set_column.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/table/F_set_column.c
r38553 r39324 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 # define OHANA_MEMCHECK 0 3 4 4 5 # define SWAP_NONE … … 34 35 double Bscale, Bzero; 35 36 37 # if (OHANA_MEMCHECK) 38 memset (tlabel, 0x7f, 256); 39 memset (field, 0x7f, 256); 40 memset (format, 0x7f, 256); 41 memset (type, 0x7f, 64); 42 memset (tmpline, 0x7f, 64); 43 44 ohana_memcheck_block (data); 45 # endif 46 36 47 if (label == (char *) NULL) return (FALSE); 37 48 if (label[0] == 0) return (FALSE); … … 42 53 for (i = 1; strcasecmp (label, tlabel) && (i < Nfields + 1); i++) { 43 54 snprintf (field, 256, "TTYPE%d", i); 44 gfits_scan (header, field, "%s", 1, tlabel);55 if (!gfits_scan (header, field, "%s", 1, tlabel)) return FALSE; 45 56 } 46 57 if (strcasecmp (label, tlabel)) return (FALSE); … … 57 68 } 58 69 snprintf (field, 256, "TFORM%d", N); 59 gfits_scan (header, field, "%s", 1, format);70 if (!gfits_scan (header, field, "%s", 1, format)) return FALSE; 60 71 61 72 if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE); … … 72 83 if (Ny != Nrow) return (FALSE); 73 84 85 // if we call this function with a null pointer, we are only validating the header and allocating the data array 86 if (!data) return TRUE; 87 74 88 /* scan columns to find insert point */ 75 89 Nstart = 0; 76 90 for (i = 1; i < N; i++) { 77 91 snprintf (field, 256, "TFORM%d", i); 78 gfits_scan (header, field, "%s", 1, format);92 if (!gfits_scan (header, field, "%s", 1, format)) return FALSE; 79 93 gfits_bintable_format (format, tmpline, &Nv, &Nb); 80 94 Nstart += Nv*Nb; … … 86 100 Pin = data; 87 101 Pout = array; 102 88 103 // does it makes sense to scale 'char' data? 89 104 if (!strcmp (type, "char")) { … … 92 107 } 93 108 } 109 94 110 if (!strcmp (type, "byte")) { 95 111 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 97 113 } 98 114 } 115 99 116 if (!strcmp (type, "short")) { 100 117 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 105 122 } 106 123 } 124 107 125 if (!strcmp (type, "int")) { 108 126 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 113 131 } 114 132 } 133 115 134 if (!strcmp (type, "int64_t")) { 116 135 // XXX 64 bit int operations with Bzero & Bscale are inaccurate even with doubles … … 131 150 } 132 151 } 152 133 153 if (!strcmp (type, "float")) { 134 154 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 139 159 } 140 160 } 161 141 162 if (!strcmp (type, "double")) { 142 163 for (i = 0; i < Nval*Nrow; i++, Pin+=Nbytes, Pout+=Nbytes) { … … 179 200 } 180 201 202 # if (OHANA_MEMCHECK) 203 myAssert ( tlabel[255] == 0x7f, "oops"); 204 myAssert ( field[255] == 0x7f, "oops"); 205 myAssert ( format[255] == 0x7f, "oops"); 206 myAssert ( type[63] == 0x7f, "oops"); 207 myAssert (tmpline[63] == 0x7f, "oops"); 208 209 ohana_memcheck (TRUE); 210 # endif 211 181 212 free (array); 213 182 214 return (TRUE); 183 215 }
Note:
See TracChangeset
for help on using the changeset viewer.
