[Getdata-commits] SF.net SVN: getdata:[931] branches/getdata-0.8
Scientific Database Format
Brought to you by:
ketiltrout
|
From: <ket...@us...> - 2014-12-05 09:55:57
|
Revision: 931
http://sourceforge.net/p/getdata/code/931
Author: ketiltrout
Date: 2014-12-05 09:55:45 +0000 (Fri, 05 Dec 2014)
Log Message:
-----------
More backporting from trunk.
Modified Paths:
--------------
branches/getdata-0.8/ChangeLog
branches/getdata-0.8/NEWS
branches/getdata-0.8/bindings/f77/fgetdata.c
branches/getdata-0.8/src/add.c
branches/getdata-0.8/src/field_list.c
branches/getdata-0.8/src/getdata.c
branches/getdata-0.8/src/mod.c
branches/getdata-0.8/test/Makefile.am
Added Paths:
-----------
branches/getdata-0.8/test/add_bit_scalars.c
branches/getdata-0.8/test/add_mplex_scalars.c
branches/getdata-0.8/test/add_polynom_scalar.c
branches/getdata-0.8/test/add_raw_spf_scalar.c
branches/getdata-0.8/test/get_carray_c2r.c
Removed Paths:
-------------
branches/getdata-0.8/test/add_mplex_val.c
Property Changed:
----------------
branches/getdata-0.8/test/
Modified: branches/getdata-0.8/ChangeLog
===================================================================
--- branches/getdata-0.8/ChangeLog 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/ChangeLog 2014-12-05 09:55:45 UTC (rev 931)
@@ -1,6 +1,31 @@
+2014-12-06 D. V. Wiebe <ge...@ke...> svn:931
+ Backport more bugfixes from trunk:
+
+ * src/getdata.c (_GD_DoConst): Return len instead of 1. (r848)
+ * src/field_list.c (gd_carrays gd_mcarrays): Update _GD_DoField calls to
+ deal with the above. (r848)
+ * test/get_carray_c2r.c: Added. (r848)
+
+ * src/add.c (_GD_CopyScalars): Added. (r848)
+ * src/add.c (_GD_Change): Fix scalar copying for GD_POLYNOM_ENTRY. Don't
+ throw errors for passed members which will be ignored due to scalars (spf,
+ numbits, bitnum). (r848)
+ * test/add_bit_scalars.c test/add_mplex_scalars.c test/add_raw_spf_scalar.c
+ * test/add_polynom_scalar.c: Added. (r848)
+
+ * src/mod.c (_GD_Change): Fix MPLEX scalar modifying. (r848)
+
2014-12-05 D. V. Wiebe <ge...@ke...> svn:930
- Backport fixes from trunk. Update build system for autotools bump.
+ Backport bugfixes from trunk:
+ * bindings/cxx/rawentry.cpp (RawEntry::RawEntry): Initialise filename.
+ Patch from S. J. Benton. (r862)
+
+ * src/add.c (_GD_Change): Don't throw an error on mplex.count_val < 0.
+ (r848)
+ * src/errors.c src/internal.h: Remove unused GD_E_ENTRY_CNTVAL. (r848)
+ * test/add_mplex_val.c: Deleted. (r848)
+
2013-09-05 D. V. Wiebe <ge...@ke...> svn:845
GetData-0.8.5 released.
Modified: branches/getdata-0.8/NEWS
===================================================================
--- branches/getdata-0.8/NEWS 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/NEWS 2014-12-05 09:55:45 UTC (rev 931)
@@ -1,7 +1,21 @@
-New in version 0.8.6a:
+New in verison 0.8.6a:
Library Changes:
+ * BUG FIX: The gd_[m]add() functions now ignore zero-length scalar strings.
+ Previously they would store these invalid field codes, causing problems
+ later.
+
+ * BUG FIX: Returning complex-valued CARRAYs as purely real now works.
+ Previously only the first element requested would be returned, the remaining
+ output buffer containing uninitialised data.
+
+ * BUG FIX: Entry members spf, bitnum, numbits, and period are now completely
+ ignored by gd_[m]add() when corresponding named scalars are specified.
+ Previously, an invalid value in these members would result in the entry
+ being rejected, even though the rest of GetData ignored the invalid, unsued
+ value.
+
* BUG FIX: The parsing of the \x and \u escape sequences is now correct.
* BUG FIX: A scalar field code specified for the last factor in a POLYNOM
@@ -58,6 +72,9 @@
Bindings Changes:
+ * F77 and F95 BUG FIX: Named scalar indices are now indexed from one instead
+ of zero, like all other array indices are in the Fortran GetData bindings.
+
* C++ BUG FIX: Fixed segfault in RawEntry destructor. Reported by S. J.
Benton.
Modified: branches/getdata-0.8/bindings/f77/fgetdata.c
===================================================================
--- branches/getdata-0.8/bindings/f77/fgetdata.c 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/bindings/f77/fgetdata.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -25,6 +25,16 @@
#include <stdio.h>
#include <string.h>
+/* convert scalar_ind from C to FORTRAN */
+#define GDF_SCIND_C2F(out,in) do { \
+ (out) = (in); if ((out) >= 0) (out)++; \
+} while (0)
+
+/* convert scalar ind from FORTRAN to C */
+#define GDF_SCIND_F2C(out,in) do { \
+ (out) = (in); if ((out) > 0) (out)--; \
+} while (0)
+
/* Fortran 77 has no facility to take a pointer to a DIRFILE* object.
* Instead, we keep a list of them here. If we ever run out of these,
* the caller will be abort()ed. */
@@ -3115,7 +3125,7 @@
ok = 0;
_GDF_FString(scalar, scalar_l, (ok) ? E.scalar[*index - 1] : "");
- *scalar_index = E.scalar_ind[*index - 1];
+ GDF_SCIND_C2F(*scalar_index, E.scalar_ind[*index - 1]);
gd_free_entry_strings(&E);
@@ -3189,7 +3199,7 @@
free(E.scalar[*index - 1]);
_GDF_CString(E.scalar + *index - 1, scalar, *scalar_l);
- E.scalar_ind[*index - 1] = *scalar_index;
+ GDF_SCIND_F2C(E.scalar_ind[*index - 1], *scalar_index);
gd_alter_entry(D, fc, &E, *recode);
Modified: branches/getdata-0.8/src/add.c
===================================================================
--- branches/getdata-0.8/src/add.c 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/src/add.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2012 D. V. Wiebe
+/* Copyright (C) 2008-2013 D. V. Wiebe
*
***************************************************************************
*
@@ -90,23 +90,53 @@
return P;
}
+/* copy scalar entries from the user's entry; returns a mask of
+ * initialised scalars */
+static unsigned _GD_CopyScalars(DIRFILE *restrict D,
+ gd_entry_t *restrict E, const gd_entry_t *restrict entry, unsigned mask)
+{
+ unsigned mask_out = 0;
+ int i;
+
+ dtrace("%p, %p, %p, 0x%X", D, E, entry, mask);
+
+ /* copy scalars */
+ for (i = 0; i <= GD_MAX_POLYORD; ++i) {
+ if (!(mask & (1 << i)) || entry->scalar[i] == NULL ||
+ entry->scalar[i][0] == '\0')
+ {
+ E->scalar[i] = NULL;
+ } else {
+ if (_GD_CheckCodeAffixes(D, NULL, entry->scalar[i],
+ entry->fragment_index))
+ {
+ break;
+ }
+ E->scalar[i] = _GD_Strdup(D, entry->scalar[i]);
+ E->scalar_ind[i] = entry->scalar_ind[i];
+ mask_out |= (1 << i);
+ }
+ }
+
+ dreturn("0x%X", mask_out);
+ return mask_out;
+}
+
/* add an entry - returns the added entry on success. */
static gd_entry_t *_GD_Add(DIRFILE *restrict D,
const gd_entry_t *restrict entry, const char *restrict parent)
{
char *temp_buffer;
int i, is_dot, offset;
- int copy_scalar[GD_MAX_POLYORD + 1];
void *new_list;
void *new_ref = NULL;
unsigned int u;
+ unsigned mask;
gd_entry_t *E;
gd_entry_t *P = NULL;
dtrace("%p, %p, \"%s\"", D, entry, parent);
- memset(copy_scalar, 0, sizeof(int) * (GD_MAX_POLYORD + 1));
-
_GD_ClearError(D);
/* check access mode */
@@ -263,9 +293,10 @@
if (D->error)
break;
- if ((E->EN(raw,spf) = entry->EN(raw,spf)) == 0)
- _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_SPF, NULL,
- entry->EN(raw,spf), NULL);
+ mask = _GD_CopyScalars(D, E, entry, 0x1);
+
+ if (!(mask & 1) && (E->EN(raw,spf) = entry->EN(raw,spf)) == 0)
+ _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_SPF, NULL, 0, NULL);
else if (E->EN(raw,data_type) & 0x40 || (E->e->u.raw.size =
GD_SIZE(E->EN(raw,data_type))) == 0)
_GD_SetError(D, GD_E_BAD_TYPE, entry->EN(raw,data_type), NULL, 0, NULL);
@@ -277,7 +308,6 @@
/* This is the first raw field in this fragment */
new_ref = _GD_Strdup(D, E->field);
}
- copy_scalar[0] = 1;
break;
case GD_LINCOM_ENTRY:
E->EN(lincom,n_fields) = entry->EN(lincom,n_fields);
@@ -286,48 +316,42 @@
_GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_NFIELDS, NULL,
E->EN(lincom,n_fields), NULL);
- for (i = 0; i < E->EN(lincom,n_fields); ++i) {
+ for (i = 0; i < E->EN(lincom,n_fields); ++i)
_GD_CheckCodeAffixes(D, NULL, entry->in_fields[i],
entry->fragment_index);
- _GD_CheckCodeAffixes(D, NULL, entry->scalar[i], entry->fragment_index);
- _GD_CheckCodeAffixes(D, NULL, entry->scalar[i + GD_MAX_LINCOM],
- entry->fragment_index);
- }
if (D->error)
break;
- else {
- if (entry->comp_scal) {
- int cs = 0;
- memcpy(E->EN(lincom,cm), entry->EN(lincom,cm), sizeof(double) * 2 *
- E->EN(lincom,n_fields));
- memcpy(E->EN(lincom,cb), entry->EN(lincom,cb), sizeof(double) * 2 *
- E->EN(lincom,n_fields));
- for (i = 0; i < E->EN(lincom,n_fields); ++i) {
- E->EN(lincom,m)[i] = creal(E->EN(lincom,cm)[i]);
- E->EN(lincom,b)[i] = creal(E->EN(lincom,cb)[i]);
- if (cimag(E->EN(lincom,cm)[i]) || cimag(E->EN(lincom,cb)[i]))
- cs = 1;
- }
- E->comp_scal = cs;
- } else {
- memcpy(E->EN(lincom,m), entry->EN(lincom,m), sizeof(double) *
- E->EN(lincom,n_fields));
- memcpy(E->EN(lincom,b), entry->EN(lincom,b), sizeof(double) *
- E->EN(lincom,n_fields));
- for (i = 0; i < E->EN(lincom,n_fields); ++i) {
- gd_rs2cs_(E->EN(lincom,cm)[i], E->EN(lincom,m)[i]);
- gd_rs2cs_(E->EN(lincom,cb)[i], E->EN(lincom,b)[i]);
- }
- E->comp_scal = 0;
- }
+ _GD_CopyScalars(D, E, entry, 9 * ((1 << E->EN(lincom,n_fields)) - 1));
+ if (entry->comp_scal) {
+ int cs = 0;
+ memcpy(E->EN(lincom,cm), entry->EN(lincom,cm), sizeof(double) * 2 *
+ E->EN(lincom,n_fields));
+ memcpy(E->EN(lincom,cb), entry->EN(lincom,cb), sizeof(double) * 2 *
+ E->EN(lincom,n_fields));
for (i = 0; i < E->EN(lincom,n_fields); ++i) {
- E->in_fields[i] = _GD_Strdup(D, entry->in_fields[i]);
- copy_scalar[i] = copy_scalar[i + GD_MAX_LINCOM] = 1;
+ E->EN(lincom,m)[i] = creal(E->EN(lincom,cm)[i]);
+ E->EN(lincom,b)[i] = creal(E->EN(lincom,cb)[i]);
+ if (cimag(E->EN(lincom,cm)[i]) || cimag(E->EN(lincom,cb)[i]))
+ cs = 1;
}
+ E->comp_scal = cs;
+ } else {
+ memcpy(E->EN(lincom,m), entry->EN(lincom,m), sizeof(double) *
+ E->EN(lincom,n_fields));
+ memcpy(E->EN(lincom,b), entry->EN(lincom,b), sizeof(double) *
+ E->EN(lincom,n_fields));
+ for (i = 0; i < E->EN(lincom,n_fields); ++i) {
+ gd_rs2cs_(E->EN(lincom,cm)[i], E->EN(lincom,m)[i]);
+ gd_rs2cs_(E->EN(lincom,cb)[i], E->EN(lincom,b)[i]);
+ }
+ E->comp_scal = 0;
}
+
+ for (i = 0; i < E->EN(lincom,n_fields); ++i)
+ E->in_fields[i] = _GD_Strdup(D, entry->in_fields[i]);
break;
case GD_LINTERP_ENTRY:
E->e->u.linterp.table_len = -1;
@@ -362,7 +386,8 @@
E->in_fields[0] = _GD_Strdup(D, entry->in_fields[0]);
- copy_scalar[0] = 1;
+ _GD_CopyScalars(D, E, entry, 0x1);
+
if (entry->comp_scal) {
gd_cs2cs_(E->EN(recip,cdividend), entry->EN(recip,cdividend));
E->EN(recip,dividend) = creal(E->EN(recip,cdividend));
@@ -385,16 +410,18 @@
}
E->in_fields[0] = _GD_Strdup(D, entry->in_fields[0]);
- if (E->EN(bit,numbits) < 1)
+
+ mask = _GD_CopyScalars(D, E, entry, 0x3);
+
+ if (!(mask & 2) && E->EN(bit,numbits) < 1)
_GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_NUMBITS, NULL,
entry->EN(bit,numbits), NULL);
- else if (E->EN(bit,bitnum) < 0)
+ else if (!(mask & 1) && E->EN(bit,bitnum) < 0)
_GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_BITNUM, NULL,
entry->EN(bit,bitnum), NULL);
- else if (E->EN(bit,bitnum) + E->EN(bit,numbits) - 1 > 63)
+ else if (!(mask & 3) && E->EN(bit,bitnum) + E->EN(bit,numbits) - 1 > 63)
_GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_BITSIZE, NULL,
E->EN(bit,bitnum) + E->EN(bit,numbits) - 1, NULL);
- copy_scalar[0] = copy_scalar[1] = 1;
break;
case GD_PHASE_ENTRY:
E->EN(phase,shift) = entry->EN(phase,shift);
@@ -405,8 +432,9 @@
break;
}
+ _GD_CopyScalars(D, E, entry, 0x1);
+
E->in_fields[0] = _GD_Strdup(D, entry->in_fields[0]);
- copy_scalar[0] = 1;
break;
case GD_WINDOW_ENTRY:
E->EN(window,windop) = entry->EN(window,windop);
@@ -419,12 +447,13 @@
break;
}
+ _GD_CopyScalars(D, E, entry, 0x1);
+
E->in_fields[0] = _GD_Strdup(D, entry->in_fields[0]);
E->in_fields[1] = _GD_Strdup(D, entry->in_fields[1]);
if (_GD_BadWindop(E->EN(window,windop)))
_GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_WINDOP, NULL,
entry->EN(window,windop), NULL);
- copy_scalar[0] = 1;
break;
case GD_MPLEX_ENTRY:
E->EN(mplex,count_val) = entry->EN(mplex,count_val);
@@ -441,11 +470,12 @@
E->in_fields[1] = _GD_Strdup(D, entry->in_fields[1]);
E->e->u.mplex.type = GD_NULL;
- if (entry->EN(mplex,period) < 0)
+ mask = _GD_CopyScalars(D, E, entry, 0x3);
+
+ if (!(mask & 2) && entry->EN(mplex,period) < 0)
_GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_PERIOD, NULL,
entry->EN(mplex,period), NULL);
- copy_scalar[0] = copy_scalar[1] = 1;
break;
case GD_CONST_ENTRY:
E->EN(scalar,const_type) = entry->EN(scalar,const_type);
@@ -503,6 +533,8 @@
if (D->error)
break;
+ _GD_CopyScalars(D, E, entry, (1 << (E->EN(polynom,poly_ord) + 1)) - 1);
+
if (entry->comp_scal) {
int cs = 0;
memcpy(E->EN(polynom,ca), entry->EN(polynom,ca), sizeof(double) * 2 *
@@ -522,9 +554,6 @@
}
E->in_fields[0] = _GD_Strdup(D, entry->in_fields[0]);
-
- for (i = 0; i <= E->EN(polynom,poly_ord); ++i)
- copy_scalar[i] = 1;
break;
case GD_ALIAS_ENTRY:
case GD_INDEX_ENTRY:
@@ -533,21 +562,6 @@
break;
}
- /* copy scalars */
- for (i = 0; i <= GD_MAX_POLYORD; ++i) {
- if (!copy_scalar[i] || entry->scalar[i] == NULL)
- E->scalar[i] = NULL;
- else {
- if (_GD_CheckCodeAffixes(D, NULL, entry->scalar[i],
- entry->fragment_index))
- {
- break;
- }
- E->scalar[i] = _GD_Strdup(D, entry->scalar[i]);
- E->scalar_ind[i] = entry->scalar_ind[i];
- }
- }
-
if (D->error != GD_E_OK) {
free(new_ref);
_GD_FreeE(D, E, 1);
Modified: branches/getdata-0.8/src/field_list.c
===================================================================
--- branches/getdata-0.8/src/field_list.c 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/src/field_list.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2012 D. V. Wiebe
+/* Copyright (C) 2008-2013 D. V. Wiebe
*
***************************************************************************
*
@@ -360,7 +360,7 @@
fl[n].n = D->entry[i]->EN(scalar,array_len);
fl[n].d = _GD_Alloc(D, return_type, fl[n].n);
if (D->error || _GD_DoField(D, D->entry[i], 0, 0, fl[n].n, return_type,
- fl[n].d) != 1)
+ fl[n].d) < 1)
break;
n++;
}
@@ -560,7 +560,7 @@
fl[n].n = e->p.meta_entry[i]->EN(scalar,array_len);
fl[n].d = _GD_Alloc(D, return_type, fl[n].n);
if (D->error || _GD_DoField(D, e->p.meta_entry[i], 0, 0, fl[n].n,
- return_type, fl[n].d) != 1)
+ return_type, fl[n].d) < 1)
break;
n++;
}
Modified: branches/getdata-0.8/src/getdata.c
===================================================================
--- branches/getdata-0.8/src/getdata.c 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/src/getdata.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 C. Barth Netterfield
- * Copyright (C) 2005-2012 D. V. Wiebe
+ * Copyright (C) 2005-2013 D. V. Wiebe
*
***************************************************************************
*
@@ -1845,8 +1845,8 @@
return 0;
}
- dreturn("%i", 1);
- return 1;
+ dreturn("%i", len);
+ return len;
}
/* _GD_DoField: Locate the field in the database and read it.
Modified: branches/getdata-0.8/src/mod.c
===================================================================
--- branches/getdata-0.8/src/mod.c 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/src/mod.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -794,7 +794,7 @@
if (j & GD_AS_ERROR)
break;
if (j & GD_AS_FREE_SCALAR)
- scalar_free |= 1;
+ scalar_free |= 2;
if (j & GD_AS_NEED_RECALC)
Qe.calculated = 0;
if (j & GD_AS_MODIFIED)
@@ -808,7 +808,7 @@
if (j & GD_AS_ERROR)
break;
if (j & GD_AS_FREE_SCALAR)
- scalar_free |= 2;
+ scalar_free |= 1;
if (j & GD_AS_NEED_RECALC)
Qe.calculated = 0;
if (j & GD_AS_MODIFIED)
Index: branches/getdata-0.8/test
===================================================================
--- branches/getdata-0.8/test 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/test 2014-12-05 09:55:45 UTC (rev 931)
Property changes on: branches/getdata-0.8/test
___________________________________________________________________
Modified: svn:ignore
## -17,6 +17,7 ##
add_bit_bitsize
add_bit_invalid
add_bit_numbits
+add_bit_scalars
add_carray
add_clincom
add_code
## -38,17 +39,19 ##
add_meta
add_meta_alias
add_mplex
-add_mplex_val
+add_mplex_scalars
add_multiply
add_multiply_invalid
add_phase
add_phase_invalid
add_polynom
+add_polynom_scalar
add_protect
add_raw
add_raw_include
add_raw_invalid
add_raw_spf
+add_raw_spf_scalar
add_raw_type
add_rdonly
add_recip
## -382,6 +385,7 ##
get_bad_code
get_bit
get_carray
+get_carray_c2r
get_carray_len
get_carray_slice
get_char
Modified: branches/getdata-0.8/test/Makefile.am
===================================================================
--- branches/getdata-0.8/test/Makefile.am 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/test/Makefile.am 2014-12-05 09:55:45 UTC (rev 931)
@@ -35,13 +35,14 @@
ADD_TESTS=add add_affix add_alias add_alias_affix add_alias_meta add_bit \
add_bit_bitnum add_bit_bitsize add_bit_invalid add_bit_numbits \
- add_carray add_clincom add_code add_const add_cpolynom add_crecip \
- add_crecip89 add_divide add_divide_invalid add_duplicate add_format \
- add_invalid add_lincom add_lincom_affix add_lincom_invalid \
- add_lincom_nfields add_linterp add_linterp_invalid add_meta \
- add_meta_alias add_mplex add_mplex_val add_multiply \
- add_multiply_invalid add_phase add_phase_invalid add_polynom \
- add_protect add_raw add_raw_include add_raw_invalid add_raw_spf \
+ add_bit_scalars add_carray add_clincom add_code add_const \
+ add_cpolynom add_crecip add_crecip89 add_divide add_divide_invalid \
+ add_duplicate add_format add_invalid add_lincom add_lincom_affix \
+ add_lincom_invalid add_lincom_nfields add_linterp \
+ add_linterp_invalid add_meta add_meta_alias add_mplex \
+ add_mplex_scalars add_multiply add_multiply_invalid add_phase \
+ add_phase_invalid add_polynom add_polynom_scalar add_protect add_raw \
+ add_raw_include add_raw_invalid add_raw_spf add_raw_spf_scalar \
add_raw_type add_rdonly add_recip add_resolv add_sbit add_scalar \
add_scalar_carray add_scalar_carray_bad add_sort add_spec \
add_spec_directive add_spec_invalid add_spec_meta add_spec_resolv \
@@ -173,7 +174,7 @@
fragment_name fragment_name_oor fragment_num fragment_parent
GET_TESTS=get64 get_affix get_bad_code get_bit get_carray get_carray_len \
- get_carray_slice get_char get_clincom get_complex128 \
+ get_carray_c2r get_carray_slice get_char get_clincom get_complex128 \
get_complex64 get_const get_const_complex get_const_repr \
get_cpolynom get_cpolynom1 get_cpolynom_int get_divide \
get_divide_ccin get_divide_crin \
Copied: branches/getdata-0.8/test/add_bit_scalars.c (from rev 862, trunk/getdata/test/add_bit_scalars.c)
===================================================================
--- branches/getdata-0.8/test/add_bit_scalars.c (rev 0)
+++ branches/getdata-0.8/test/add_bit_scalars.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -0,0 +1,81 @@
+/* Copyright (C) 2013 D. V. Wiebe
+ *
+ ***************************************************************************
+ *
+ * This file is part of the GetData project.
+ *
+ * GetData is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * GetData is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with GetData; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/* Add a dirfile field */
+#include "test.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+int main(void)
+{
+ const char *filedir = "dirfile";
+ const char *format = "dirfile/format";
+ const char *data = "dirfile/data";
+ int e1, e2, e3, r = 0;
+ DIRFILE *D;
+ gd_entry_t E;
+
+ rmdirfile();
+ memset(&E, 0, sizeof(E));
+ E.field = "bit1";
+ E.field_type = GD_BIT_ENTRY;
+ E.in_fields[0] = "INDEX";
+ E.EN(bit,bitnum) = -1;
+ E.EN(bit,numbits) = 1;
+ E.scalar[0] = "const";
+
+ D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
+ gd_add(D, &E);
+ e1 = gd_error(D);
+
+ E.field = "bit2";
+ E.EN(bit,bitnum) = 1;
+ E.EN(bit,numbits) = 0;
+ E.scalar[0] = NULL;
+ E.scalar[1] = "const";
+ gd_add(D, &E);
+ e2 = gd_error(D);
+
+ E.field = "bit3";
+ E.EN(bit,bitnum) = 61;
+ E.EN(bit,numbits) = 5;
+ E.scalar[0] = "const";
+ E.scalar[1] = "const";
+ gd_add(D, &E);
+ e3 = gd_error(D);
+
+ gd_discard(D);
+
+ unlink(data);
+ unlink(format);
+ rmdir(filedir);
+
+ CHECKI(e1, GD_E_OK);
+ CHECKI(e2, GD_E_OK);
+ CHECKI(e3, GD_E_OK);
+
+ return r;
+}
Copied: branches/getdata-0.8/test/add_mplex_scalars.c (from rev 862, trunk/getdata/test/add_mplex_scalars.c)
===================================================================
--- branches/getdata-0.8/test/add_mplex_scalars.c (rev 0)
+++ branches/getdata-0.8/test/add_mplex_scalars.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -0,0 +1,64 @@
+/* Copyright (C) 2013 D. V. Wiebe
+ *
+ ***************************************************************************
+ *
+ * This file is part of the GetData project.
+ *
+ * GetData is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * GetData is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with GetData; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/* Add a dirfile field */
+#include "test.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+int main(void)
+{
+ const char *filedir = "dirfile";
+ const char *format = "dirfile/format";
+ const char *data = "dirfile/data";
+ int error, r = 0;
+ DIRFILE *D;
+ gd_entry_t E;
+
+ rmdirfile();
+ memset(&E, 0, sizeof(E));
+ E.field = "mplex1";
+ E.field_type = GD_MPLEX_ENTRY;
+ E.in_fields[0] = "INDEX";
+ E.in_fields[1] = "INDEX";
+ E.EN(mplex,count_val) = 0;
+ E.EN(mplex,period) = -1;
+ E.scalar[1] = "const";
+
+ D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
+ gd_add(D, &E);
+ error = gd_error(D);
+
+ gd_discard(D);
+
+ unlink(data);
+ unlink(format);
+ rmdir(filedir);
+
+ CHECKI(error, GD_E_OK);
+
+ return r;
+}
Deleted: branches/getdata-0.8/test/add_mplex_val.c
===================================================================
--- branches/getdata-0.8/test/add_mplex_val.c 2014-12-05 01:37:25 UTC (rev 930)
+++ branches/getdata-0.8/test/add_mplex_val.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -1,43 +0,0 @@
-/* Copyright (C) 2012 D. V. Wiebe
- *
- ***************************************************************************
- *
- * This file is part of the GetData project.
- *
- * GetData is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation; either version 2.1 of the License, or (at your
- * option) any later version.
- *
- * GetData is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with GetData; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include "test.h"
-
-int main(void)
-{
- const char *filedir = "dirfile";
- const char *format = "dirfile/format";
- int error, r = 0;
- DIRFILE *D;
-
- rmdirfile();
- D = gd_open(filedir, GD_RDWR | GD_CREAT);
- gd_add_mplex(D, "new", "in", "count", 4, -3, 0);
- error = gd_error(D);
-
- gd_close(D);
-
- unlink(format);
- rmdir(filedir);
-
- CHECKI(error, GD_E_BAD_ENTRY);
-
- return r;
-}
Copied: branches/getdata-0.8/test/add_polynom_scalar.c (from rev 862, trunk/getdata/test/add_polynom_scalar.c)
===================================================================
--- branches/getdata-0.8/test/add_polynom_scalar.c (rev 0)
+++ branches/getdata-0.8/test/add_polynom_scalar.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -0,0 +1,79 @@
+/* Copyright (C) 2013 D. V. Wiebe
+ *
+ ***************************************************************************
+ *
+ * This file is part of the GetData project.
+ *
+ * GetData is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * GetData is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with GetData; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "test.h"
+
+int main(void)
+{
+ const char *filedir = "dirfile";
+ const char *format = "dirfile/format";
+ int error, r = 0;
+ DIRFILE *D;
+
+ gd_entry_t E, e;
+ memset(&E, 0, sizeof(E));
+ E.field = "data";
+ E.field_type = GD_POLYNOM_ENTRY;
+ E.fragment_index = 0;
+ E.EN(polynom,poly_ord) = 3;
+ E.comp_scal = 0;
+ E.in_fields[0] = "INDEX";
+ E.scalar[0] = "A";
+ E.scalar[1] = "B";
+ E.scalar[2] = "C";
+ E.scalar[3] = "D";
+
+ rmdirfile();
+ D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
+ gd_add_spec(D, "A CONST INT64 1", 0);
+ gd_add_spec(D, "B CONST INT64 2", 0);
+ gd_add_spec(D, "C CONST INT64 3", 0);
+ gd_add_spec(D, "D CONST INT64 4", 0);
+ gd_add(D, &E);
+ error = gd_error(D);
+
+ /* check */
+ gd_entry(D, "data", &e);
+ if (gd_error(D))
+ r = 1;
+ else {
+ CHECKI(e.field_type, GD_POLYNOM_ENTRY);
+ CHECKI(e.fragment_index, 0);
+ CHECKI(e.EN(polynom,poly_ord), 3);
+ CHECKF(e.EN(polynom,a)[0], 1);
+ CHECKF(e.EN(polynom,a)[1], 2);
+ CHECKF(e.EN(polynom,a)[2], 3);
+ CHECKF(e.EN(polynom,a)[3], 4);
+ CHECKS(e.scalar[0], "A");
+ CHECKS(e.scalar[1], "B");
+ CHECKS(e.scalar[2], "C");
+ CHECKS(e.scalar[3], "D");
+ gd_free_entry_strings(&e);
+ }
+
+ gd_close(D);
+
+ unlink(format);
+ rmdir(filedir);
+
+ CHECKI(error, GD_E_OK);
+
+ return r;
+}
Copied: branches/getdata-0.8/test/add_raw_spf_scalar.c (from rev 862, trunk/getdata/test/add_raw_spf_scalar.c)
===================================================================
--- branches/getdata-0.8/test/add_raw_spf_scalar.c (rev 0)
+++ branches/getdata-0.8/test/add_raw_spf_scalar.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -0,0 +1,76 @@
+/* Copyright (C) 2013 D. V. Wiebe
+ *
+ ***************************************************************************
+ *
+ * This file is part of the GetData project.
+ *
+ * GetData is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * GetData is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with GetData; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+/* Add a dirfile field */
+#include "test.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+
+int main(void)
+{
+ const char *filedir = "dirfile";
+ const char *format = "dirfile/format";
+ const char *data = "dirfile/data";
+ int error, r = 0;
+ DIRFILE *D;
+ gd_entry_t E, e;
+
+ rmdirfile();
+ E.field = "data";
+ E.field_type = GD_RAW_ENTRY;
+ E.fragment_index = 0;
+ E.EN(raw,spf) = 0;
+ E.EN(raw,data_type) = GD_UINT8;
+ E.scalar[0] = "const";
+
+ D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
+ gd_add_spec(D, "const CONST UINT8 2", 0);
+ gd_add(D, &E);
+ error = gd_error(D);
+
+ /* check */
+ gd_entry(D, "data", &e);
+ if (gd_error(D))
+ r = 1;
+ else {
+ CHECKI(e.field_type, GD_RAW_ENTRY);
+ CHECKI(e.fragment_index, 0);
+ CHECKI(e.EN(raw,spf), 2);
+ CHECKI(e.EN(raw,data_type), GD_UINT8);
+ CHECKS(e.scalar[0], "const");
+ gd_free_entry_strings(&e);
+ }
+
+ gd_close(D);
+
+ unlink(data);
+ unlink(format);
+ rmdir(filedir);
+
+ CHECKI(error, GD_E_OK);
+
+ return r;
+}
Copied: branches/getdata-0.8/test/get_carray_c2r.c (from rev 862, trunk/getdata/test/get_carray_c2r.c)
===================================================================
--- branches/getdata-0.8/test/get_carray_c2r.c (rev 0)
+++ branches/getdata-0.8/test/get_carray_c2r.c 2014-12-05 09:55:45 UTC (rev 931)
@@ -0,0 +1,62 @@
+/* Copyright (C) 2013 D. V. Wiebe
+ *
+ ***************************************************************************
+ *
+ * This file is part of the GetData project.
+ *
+ * GetData is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * GetData is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with GetData; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "test.h"
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <math.h>
+
+int main(void)
+{
+ const char *filedir = "dirfile";
+ const char *format = "dirfile/format";
+ const char *format_data = "carray CARRAY COMPLEX128 8.3;7.2 6.1;5.0 3.9;2.8 1.7;0.6\n";
+ double c[4];
+ int fd, i, n, error, r = 0;
+ DIRFILE *D;
+
+ rmdirfile();
+ mkdir(filedir, 0777);
+
+ fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
+ write(fd, format_data, strlen(format_data));
+ close(fd);
+
+ D = gd_open(filedir, GD_RDONLY | GD_VERBOSE);
+ n = gd_get_carray(D, "carray", GD_FLOAT64, c);
+ error = gd_error(D);
+
+ gd_close(D);
+
+ unlink(format);
+ rmdir(filedir);
+
+ CHECKI(error, 0);
+ CHECKI(n, 0);
+ for (i = 0; i < 4; ++i)
+ CHECKFi(i, c[i], 8.3 - 2 * i * 1.1);
+
+ return r;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|