IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 1, 2021, 1:58:44 PM (5 years ago)
Author:
eugene
Message:

fix FITS ASCII column reading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/table/F_set_column.c

    r41422 r41676  
    478478  /* print line with appropriate formatting */
    479479  ALLOCATE (array, char, Nbytes*Nval*Nrow);
    480   ALLOCATE (line, char, Nval+1);
     480  ALLOCATE (line, char, Nbytes+1);
    481481  Pin = data;
    482482  Pout = array;
    483483  if (!strcmp (type, "char")) {
    484     for (i = 0; i < Nval*Nrow; i++, Pin++, Pout++) {
     484    for (i = 0; i < Nbytes*Nval*Nrow; i++, Pin++, Pout++) {
    485485      *Pout = *Pin;
    486486    }
    487487  }
    488488  if (!strcmp (type, "int")) {
    489     for (i = 0; i < Nrow; i++, Pin+=4, Pout+=Nval) {
    490       snprintf (line, Nval + 1, cformat, *(int *)Pin);
    491       memcpy (Pout, line, Nval);
     489    for (i = 0; i < Nrow; i++, Pin+=4, Pout+=Nbytes) {
     490      snprintf (line, Nbytes + 1, cformat, *(int *)Pin);
     491      memcpy (Pout, line, Nbytes);
    492492    }
    493493  }
    494494  if (!strcmp (type, "float")) {
    495     for (i = 0; i < Nrow; i++, Pin+=4, Pout+=Nval) {
    496       snprintf (line, Nval + 1, cformat, *(float *)Pin);
    497       memcpy (Pout, line, Nval);
     495    for (i = 0; i < Nrow; i++, Pin+=4, Pout+=Nbytes) {
     496      snprintf (line, Nbytes + 1, cformat, *(float *)Pin);
     497      memcpy (Pout, line, Nbytes);
    498498    }
    499499  }
Note: See TracChangeset for help on using the changeset viewer.