about summary refs log tree commit diff
path: root/converter/other
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-01-29 04:19:22 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-01-29 04:19:22 +0000
commit23f5ae1861b268c4adcdaec6657406328dfdf811 (patch)
tree2dbb6a655764b3684f6d2877e3323a03ee00f623 /converter/other
parent3976c04edc6d4bdb583875176e06f93fc23d869f (diff)
downloadnetpbm-mirror-23f5ae1861b268c4adcdaec6657406328dfdf811.tar.gz
netpbm-mirror-23f5ae1861b268c4adcdaec6657406328dfdf811.tar.xz
netpbm-mirror-23f5ae1861b268c4adcdaec6657406328dfdf811.zip
Release 10.35.59
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@832 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
-rw-r--r--converter/other/fitstopnm.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/converter/other/fitstopnm.c b/converter/other/fitstopnm.c
index b143882b..b4240d63 100644
--- a/converter/other/fitstopnm.c
+++ b/converter/other/fitstopnm.c
@@ -359,6 +359,22 @@ main(int argc, char * argv[]) {
     exit( 0 );
 }
 
+
+static void
+swapbytes(void *       const p,
+          unsigned int const nbytes) {
+#if BYTE_ORDER == LITTLE_ENDIAN
+    unsigned char * const c = p;
+    unsigned int i;
+    for (i = 0; i < nbytes/2; ++i) {
+        unsigned char const orig = c[i];
+        c[i] = c[nbytes-(i+1)];
+        c[nbytes-(i+1)] = orig;
+    }
+#endif
+}
+
+
 /*
  ** This code will deal properly with integers, no matter what the byte order
  ** or integer size of the host machine.  Sign extension is handled manually
@@ -427,6 +443,7 @@ read_val (fp, bitpix, vp)
                 pm_error( "EOF / read error" );
             c[i] = ich;
         }
+        swapbytes(c, 4);
         *vp = *( (float *) c);
         break;
       
@@ -437,6 +454,7 @@ read_val (fp, bitpix, vp)
                 pm_error( "EOF / read error" );
             c[i] = ich;
         }
+        swapbytes(c, 8);
         *vp = *( (double *) c);
         break;