[GRASS5] Re: [GRASSLIST:1899] ERROR in read/write portable short

Hi Radim,

here darwin6.8 results:

[timonchiotwin:lib/vector/diglib] markus% otool -L OBJ.powerpc-apple-darwin6.8/test
OBJ.powerpc-apple-darwin6.8/test:
        /grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_dig2.dylib (compatibility version 0.0.0, current version 0.0.0)
        /grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_rtree.dylib (compatibility version 0.0.0, current version 0.0.0)
        /grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_gis.dylib (compatibility version 0.0.0, current version 0.0.0)
        /grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_datetime.dylib (compatibility version 0.0.0, current version 0.0.0)
        /sw/lib/libintl.1.dylib (compatibility version 2.0.0, current version 2.1.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 71.0.0)

OBJ.powerpc-apple-darwin6.8/test
ERROR in read/write portable short, byte_order = 0
  Written: -32768
  Read : 0
ERROR in read/write portable short, byte_order = 0
  Written: -12345
  Read : -57
ERROR in read/write portable short, byte_order = 0
  Written: 12345
  Read : 57
ERROR in read/write portable short, byte_order = 0
  Written: 32767
  Read : -1

Find attached portable.h and test.tmp.gz

Markus

(attachments)

portable.h (732 Bytes)
test.tmp.gz (305 Bytes)

It was quite a stupid bug (my), in dig_init_portable() (portable.c)
all port->xxx_cnvrt[i] = xxx_cnvrt[PORT_DOUBLE - i] should be
port->xxx_cnvrt[i] = xxx_cnvrt[PORT_DOUBLE - i - 1]

This should not have many consequences, because only vector files
written as little endian on big endian machine would be wrong,
but big endian machines by default write big endian files.

The only exception, where data may be corrupted, are vectors created
on little endian machine and then edited on big endian (v.digit),
but as files should be obviously wrong, it is not probable.

Before the fix, errors should appear when little endian files were read on
big endian machines, so it seams that nobody tried that.

Radim

On Friday 28 November 2003 11:00, Markus Neteler wrote:

Hi Radim,

here darwin6.8 results:

[timonchiotwin:lib/vector/diglib] markus% otool -L
OBJ.powerpc-apple-darwin6.8/test OBJ.powerpc-apple-darwin6.8/test:
        /grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_dig2.dylib
(compatibility version 0.0.0, current version 0.0.0)
/grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_rtree.dylib
(compatibility version 0.0.0, current version 0.0.0)
/grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_gis.dylib
(compatibility version 0.0.0, current version 0.0.0)
/grass57exp/dist.powerpc-apple-darwin6.8/lib/libgrass_datetime.dylib
(compatibility version 0.0.0, current version 0.0.0)
/sw/lib/libintl.1.dylib (compatibility version 2.0.0, current version
2.1.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version
1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 71.0.0)

OBJ.powerpc-apple-darwin6.8/test
ERROR in read/write portable short, byte_order = 0
  Written: -32768
  Read : 0
ERROR in read/write portable short, byte_order = 0
  Written: -12345
  Read : -57
ERROR in read/write portable short, byte_order = 0
  Written: 12345
  Read : 57
ERROR in read/write portable short, byte_order = 0
  Written: 32767
  Read : -1

Find attached portable.h and test.tmp.gz

Markus