gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
274 stars 61 forks source link

READ_BINARY.PRO should read 4-byte packages in case of LONGs #1731

Closed frankmri closed 7 months ago

frankmri commented 7 months ago

Hi, I ran into errors with existing code using READ_BINARY.PRO and believe (maybe I'm wrong) the number of bytes should be 4 when reading long ints (IDL type code 3) from binary files. It is currently 2:

READ_BINARY.PRO ... nbytes = [0, 1, 2, 2, 4, 8, 8, 0, 0, 16, 0, 0, 2, 4, 8, 8] ... should be:

READ_BINARY.PRO ... nbytes = [0, 1, 2, 4, 4, 8, 8, 0, 0, 16, 0, 0, 2, 4, 8, 8] ... Best Frank

alaingdl commented 7 months ago

Thanks for the report. Before any modification, I would like to write few test cases ... without success up to now ... I also notice that we have to change "wc" in the code, a very old code ... (we do have the correct function inside GDL now)

Since you can change locally, it is not super urgent

GillesDuvert commented 7 months ago

I believe this comes from a wrong number of bytes at line 115 in read_binary.pro, with nbytes[3]=2 instead of 4. (others must be checked too). If confirmed, this would be a 1-liner correction.

alaingdl commented 7 months ago

I am working on writing tests ... but it is a low priority :)

GillesDuvert commented 7 months ago

one liner done.