File getdata-bigendian.patch of Package getdata

Index: getdata-0.8.2/bindings/python/pyentry.c
===================================================================
--- getdata-0.8.2.orig/bindings/python/pyentry.c
+++ getdata-0.8.2/bindings/python/pyentry.c
@@ -96,25 +96,51 @@
     *scalar = gdpy_dup_pystring(pyobj);
   else {
     *scalar = NULL;
-    if (type == GD_INT64)
-      *(int64_t*)data = (int64_t)PyLong_AsLongLong(pyobj);
-    else if (type == GD_COMPLEX128)
-      *(double complex*)data = gdpy_as_complex(pyobj);
-    else if (type == GD_FLOAT64)
-      *(double*)data = PyFloat_AsDouble(pyobj);
-    else if (type == GD_INT16)
-      *(int16_t*)data = PyLong_AsLong(pyobj);
-    else if (type == GD_UINT16)
-      *(uint16_t*)data = PyLong_AsUnsignedLong(pyobj);
-    else if (type == GD_UINT64) {
+    switch (type) {
+      case GD_UINT8:
+        *(uint8_t*)data = (uint8_t)PyInt_AsUnsignedLongMask(pyobj);
+        break;
+      case GD_INT8:
+        *(int8_t*)data = (int8_t)PyInt_AsLong(pyobj);
+        break;
+      case GD_UINT16:
+        *(uint16_t*)data = (uint16_t)PyInt_AsUnsignedLongMask(pyobj);
+        break;
+      case GD_INT16:
+        *(int16_t*)data = (int16_t)PyInt_AsLong(pyobj);
+        break;
+      case GD_UINT32:
+        *(uint32_t*)data = (uint32_t)PyLong_AsUnsignedLong(pyobj);
+        break;
+      case GD_INT32:
+        *(int32_t*)data = (int32_t)PyLong_AsLong(pyobj);
+        break;
+      case GD_UINT64:
       if (PyLong_Check(pyobj))
         *(uint64_t*)data = PyLong_AsUnsignedLongLong(pyobj);
       else
         *(uint64_t*)data = PyInt_AsUnsignedLongLongMask(pyobj);
-    } else
+        break;
+      case GD_INT64:
+        *(int64_t*)data = (int64_t)PyLong_AsLongLong(pyobj);
+        break;
+      case GD_FLOAT32:
+        *(float*)data = (float)PyFloat_AsDouble(pyobj);
+        break;
+      case GD_FLOAT64:
+        *(double*)data = PyFloat_AsDouble(pyobj);
+        break;
+      case GD_COMPLEX64:
+        *(float complex*)data = gdpy_as_complex(pyobj);
+        break;
+      case GD_COMPLEX128:
+        *(double complex*)data = gdpy_as_complex(pyobj);
+        break;
+      default:
         PyErr_Format(PyExc_RuntimeError,
               "unexpected field type (%x) inside %s", type, __func__);
   }
+  }
 
   dreturnvoid();
 }
@@ -187,7 +213,7 @@
         PyErr_SetString(PyExc_ValueError,
             "'pygetdata.entry' invalid data type");
 
-      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 1), GD_UINT16,
+      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 1), GD_UINT_TYPE,
           &E->scalar[0], &E->spf);
       break;
     case GD_LINCOM_ENTRY:
@@ -283,10 +309,10 @@
         return;
       }
 
-      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 1), GD_INT16,
+      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 1), GD_INT_TYPE,
           &E->scalar[0], &E->bitnum);
       if (size > 2)
-        gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 2), GD_INT16,
+        gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 2), GD_INT_TYPE,
             &E->scalar[1], &E->numbits);
       else {
         E->numbits = 1;
@@ -445,10 +471,10 @@
         return;
       }
 
-      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 2), GD_UINT16,
+      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 2), GD_INT_TYPE,
           &E->scalar[0], &E->count_val);
 
-      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 3), GD_UINT16,
+      gdpy_set_scalar_from_pyobj(PyTuple_GetItem(tuple, 3), GD_INT_TYPE,
           &E->scalar[1], &E->count_max);
       break;
     case GD_CARRAY_ENTRY:
@@ -1035,7 +1061,7 @@
     return -1;
   }
 
-  gdpy_set_scalar_from_pyobj(value, GD_UINT16, &scalar, &spf);
+  gdpy_set_scalar_from_pyobj(value, GD_UINT_TYPE, &scalar, &spf);
 
   if (PyErr_Occurred()) {
     free(scalar);
@@ -1421,7 +1447,7 @@
     return -1;
   }
 
-  gdpy_set_scalar_from_pyobj(value, GD_INT16, &scalar, &bitnum);
+  gdpy_set_scalar_from_pyobj(value, GD_INT_TYPE, &scalar, &bitnum);
   if (PyErr_Occurred()) {
     free(scalar);
     dreturn("%i", -1);
@@ -1476,7 +1502,7 @@
     return -1;
   }
 
-  gdpy_set_scalar_from_pyobj(value, GD_INT16, &scalar, &numbits);
+  gdpy_set_scalar_from_pyobj(value, GD_INT_TYPE, &scalar, &numbits);
 
   if (PyErr_Occurred()) {
     dreturn("%i", -1);
@@ -1646,7 +1672,7 @@
     return -1;
   }
 
-  gdpy_set_scalar_from_pyobj(value, GD_UINT16, &scalar, &count_val);
+  gdpy_set_scalar_from_pyobj(value, GD_INT_TYPE, &scalar, &count_val);
 
   if (PyErr_Occurred()) {
     dreturn("%i", -1);
@@ -1698,7 +1724,7 @@
     return -1;
   }
 
-  gdpy_set_scalar_from_pyobj(value, GD_UINT16, &scalar, &count_max);
+  gdpy_set_scalar_from_pyobj(value, GD_INT_TYPE, &scalar, &count_max);
 
   if (PyErr_Occurred()) {
     dreturn("%i", -1);
Index: getdata-0.8.2/src/del.c
===================================================================
--- getdata-0.8.2.orig/src/del.c
+++ getdata-0.8.2/src/del.c
@@ -135,7 +135,7 @@ static void _GD_DeReference(DIRFILE *res
 
   switch(E->field_type) {
     case GD_RAW_ENTRY:
-      _GD_DeReferenceOne(D, E, C, check, 0, GD_UINT16, &E->EN(raw,spf));
+      _GD_DeReferenceOne(D, E, C, check, 0, GD_UINT_TYPE, &E->EN(raw,spf));
       break;
     case GD_POLYNOM_ENTRY:
       for (i = 0; i <= E->EN(polynom,poly_ord); ++i) {
Index: getdata-0.8.2/src/entry.c
===================================================================
--- getdata-0.8.2.orig/src/entry.c
+++ getdata-0.8.2/src/entry.c
@@ -206,7 +206,7 @@ int _GD_CalculateEntry(DIRFILE *restrict
 
   switch(E->field_type) {
     case GD_RAW_ENTRY:
-      _GD_GetScalar(D, E, 0, GD_UINT16, &E->EN(raw,spf), err);
+      _GD_GetScalar(D, E, 0, GD_UINT_TYPE, &E->EN(raw,spf), err);
       break;
     case GD_POLYNOM_ENTRY:
       E->comp_scal = 0;
Index: getdata-0.8.2/src/flush.c
===================================================================
--- getdata-0.8.2.orig/src/flush.c
+++ getdata-0.8.2/src/flush.c
@@ -391,7 +391,7 @@ static void _GD_FieldSpec(DIRFILE* D, FI
         fprintf(stream, " RAW%s %s ", pretty ? "     " : "",
             (permissive || D->standards >= 5) ?  _GD_TypeName(D,
               E->EN(raw,data_type)) : _GD_OldTypeName(D, E->EN(raw,data_type)));
-        _GD_WriteConst(D, stream, me, permissive, GD_UINT16, &E->EN(raw,spf),
+        _GD_WriteConst(D, stream, me, permissive, GD_UINT_TYPE, &E->EN(raw,spf),
             E->scalar[0], E->scalar_ind[0], "\n");
         break;
       case GD_LINCOM_ENTRY:
Index: getdata-0.8.2/src/mod.c
===================================================================
--- getdata-0.8.2.orig/src/mod.c
+++ getdata-0.8.2/src/mod.c
@@ -257,7 +257,7 @@ static int _GD_Change(DIRFILE *D, const
   switch(E->field_type) {
     case GD_RAW_ENTRY:
       j = _GD_AlterScalar(D, N->EN(raw,spf) && N->EN(raw,spf) != E->EN(raw,spf),
-          GD_UINT16, &Q.EN(raw,spf), &N->EN(raw,spf), Q.scalar, Q.scalar_ind,
+          GD_UINT_TYPE, &Q.EN(raw,spf), &N->EN(raw,spf), Q.scalar, Q.scalar_ind,
           N->scalar[0], N->scalar_ind[0], E->e->calculated, E->fragment_index);
 
       if (j & GD_AS_ERROR)
@@ -293,7 +293,7 @@ static int _GD_Change(DIRFILE *D, const
         struct encoding_t *enc;
 
         if (j & GD_AS_NEED_RECALC)
-          if (gd_get_constant(D, Q.scalar[0], GD_UINT16, &Q.EN(raw,spf)))
+          if (gd_get_constant(D, Q.scalar[0], GD_UINT_TYPE, &Q.EN(raw,spf)))
             break;
 
         nf = BUFFER_SIZE / _gd_max(E->e->u.raw.size,
Index: getdata-0.8.2/src/parse.c
===================================================================
--- getdata-0.8.2.orig/src/parse.c
+++ getdata-0.8.2/src/parse.c
@@ -316,7 +316,7 @@ static gd_entry_t *_GD_ParseRaw(DIRFILE
     _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_BAD_TYPE, format_file, line,
         in_cols[2]);
   else if ((E->scalar[0] = _GD_SetScalar(D, in_cols[3], &E->EN(raw,spf),
-          GD_UINT16, me, format_file, line, E->scalar_ind, NULL, standards,
+          GD_UINT_TYPE, me, format_file, line, E->scalar_ind, NULL, standards,
           pedantic)) == NULL)
   {
     E->e->calculated = 1;
@@ -772,13 +772,13 @@ static gd_entry_t *_GD_ParseMplex(DIRFIL
   E->in_fields[1] = _GD_MungeFromFrag(D, NULL, me, in_cols[3], &offset);
 
   E->scalar[0] = _GD_SetScalar(D, in_cols[4], &E->EN(mplex,count_val),
-      GD_UINT16, me, format_file, line, E->scalar_ind, NULL, standards,
+      GD_INT_TYPE, me, format_file, line, E->scalar_ind, NULL, standards,
       pedantic);
 
   /* the count max, if present */
   if (n_cols > 5) {
     E->scalar[1] = _GD_SetScalar(D, in_cols[5], &E->EN(mplex,count_max),
-        GD_UINT16, me, format_file, line, E->scalar_ind + 1, NULL, standards,
+        GD_INT_TYPE, me, format_file, line, E->scalar_ind + 1, NULL, standards,
         pedantic);
     if (E->EN(mplex,count_max) < 0)
       _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_MPLEXVAL, format_file, line,
openSUSE Build Service is sponsored by