Changeset 39059
- Timestamp:
- Nov 6, 2015, 10:25:18 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/tools/src/fits_to_mysql.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/tools/src/fits_to_mysql.c
r38998 r39059 302 302 *ncolumn = Ncolumn; 303 303 return column; 304 } 305 306 /* print a double an IOBuffer (sprintf_double) */ 307 int PrintIOBuffer_double (IOBuffer *buffer, double value) { 308 309 /* add the output line to the given IOBuffer */ 310 311 char output[128]; // I can use a fixed-length buffer since sprintf_double prints no more than 22 bytes; 312 313 int Nbyte = sprintf_double (output, value); 314 315 if (buffer[0].Nbuffer + Nbyte + 1 >= buffer[0].Nalloc) { 316 buffer[0].Nalloc = buffer[0].Nbuffer + Nbyte + 64; 317 REALLOCATE (buffer[0].buffer, char, buffer[0].Nalloc); 318 } 319 320 strcpy (&buffer[0].buffer[buffer[0].Nbuffer], output); 321 buffer[0].Nbuffer += Nbyte; 322 323 return (TRUE); 324 } 325 326 /* float to an IOBuffer (sprintf_float) */ 327 int PrintIOBuffer_float (IOBuffer *buffer, float value) { 328 329 /* add the output line to the given IOBuffer */ 330 331 char output[128]; // I can use a fixed-length buffer since sprintf_float prints no more than 14 bytes; 332 333 int Nbyte = sprintf_float (output, value); 334 335 if (buffer[0].Nbuffer + Nbyte + 1 >= buffer[0].Nalloc) { 336 buffer[0].Nalloc = buffer[0].Nbuffer + Nbyte + 64; 337 REALLOCATE (buffer[0].buffer, char, buffer[0].Nalloc); 338 } 339 340 strcpy (&buffer[0].buffer[buffer[0].Nbuffer], output); 341 buffer[0].Nbuffer += Nbyte; 342 343 return (TRUE); 304 344 } 305 345 … … 532 572 float myValue = value[i*columns[Nf].Nval + j]; 533 573 if (isfinite(myValue)) { 534 PrintIOBuffer (&output, "%e", myValue);574 PrintIOBuffer_float (&output, myValue); 535 575 } else { 536 576 PrintIOBuffer (&output, "-999"); … … 545 585 double *value = data[Nf]; 546 586 for (j = 0; j < columns[Nf].Nval; j++) { 547 PrintIOBuffer (&output, "%e", value[i*columns[Nf].Nval + j]); 587 double myValue = value[i*columns[Nf].Nval + j]; 588 if (isfinite(myValue)) { 589 PrintIOBuffer_double (&output, myValue); 590 } else { 591 PrintIOBuffer (&output, "-999"); 592 } 548 593 if (j < columns[Nf].Nval - 1) { 549 594 PrintIOBuffer (&output, ",\n");
Note:
See TracChangeset
for help on using the changeset viewer.
