getdata-commits Mailing List for GetData (Page 3)
Scientific Database Format
Brought to you by:
ketiltrout
This list is closed, nobody may subscribe to it.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
(20) |
Nov
(21) |
Dec
(16) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(1) |
Feb
(1) |
Mar
(56) |
Apr
(20) |
May
(4) |
Jun
(2) |
Jul
(3) |
Aug
(11) |
Sep
(2) |
Oct
(4) |
Nov
(18) |
Dec
(16) |
2012 |
Jan
(8) |
Feb
(12) |
Mar
(30) |
Apr
(13) |
May
(10) |
Jun
(17) |
Jul
(18) |
Aug
(19) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(9) |
2013 |
Jan
(1) |
Feb
(4) |
Mar
(27) |
Apr
(6) |
May
(3) |
Jun
(1) |
Jul
(10) |
Aug
|
Sep
(3) |
Oct
(15) |
Nov
(4) |
Dec
(9) |
2014 |
Jan
|
Feb
(3) |
Mar
(4) |
Apr
(10) |
May
(15) |
Jun
|
Jul
(14) |
Aug
|
Sep
(2) |
Oct
(6) |
Nov
|
Dec
(9) |
2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ket...@us...> - 2014-05-05 21:17:06
|
Revision: 896 http://sourceforge.net/p/getdata/code/896 Author: ketiltrout Date: 2014-05-05 21:16:59 +0000 (Mon, 05 May 2014) Log Message: ----------- Make gd_encoding_support() work with modules. Do some sorting of configure.ac. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/configure.ac trunk/getdata/src/encoding.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-05-05 20:38:45 UTC (rev 895) +++ trunk/getdata/ChangeLog 2014-05-05 21:16:59 UTC (rev 896) @@ -1,3 +1,6 @@ +2014-05-05 D. V. Wiebe <ge...@ke...> svn:896 + * src/encoding.c (gd_encoding_support): Call _GD_InitialiseFramework(). + 2014-05-05 D. V. Wiebe <ge...@ke...> svn:895 * src/getdata.h.in: Remove GD_MAX_CARRAY_LENGTH. * src/add.c (_GD_Add) src/mod.c (_GD_Change) src/parse.c (_GD_ParseArray): Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2014-05-05 20:38:45 UTC (rev 895) +++ trunk/getdata/configure.ac 2014-05-05 21:16:59 UTC (rev 896) @@ -183,8 +183,8 @@ dnl Fortran 77 bindings AC_ARG_ENABLE(fortran, AS_HELP_STRING([--disable-fortran], - [don't build the Fortran 77 bindings (libfgetdata) nor the - Fortran 95 bindings (libf95getdata)]), + [don't build the Fortran 77 bindings (libfgetdata) nor ]dnl' + [the Fortran 95 bindings (libf95getdata)]), [ case "${enableval}" in no) make_f77bindings="no" ;; @@ -194,7 +194,7 @@ dnl Fortran 95 bindings AC_ARG_ENABLE(fortran95, AS_HELP_STRING([--disable-fortran95], - [don't build the Fortran 95 bindings (libf95getdata)]), + [don't build the Fortran 95 bindings (libf95getdata)]),dnl' [ case "${enableval}" in no) make_f95bindings="no" ;; @@ -212,29 +212,10 @@ AC_MSG_CHECKING([whether to include the Fortran 77 bindings]) AC_MSG_RESULT([$make_f77bindings]) -dnl DL library path munging for test suite -case "${host}" in - *-apple-darwin*) DL_LIBRARY_PATH="DYLD_LIBRARY_PATH" ;; - *) DL_LIBRARY_PATH="LD_LIBRARY_PATH" ;; -esac -AC_SUBST([DL_LIBRARY_PATH]) - -dnl Python bindings -AC_ARG_ENABLE(python, AS_HELP_STRING([--disable-python], - [don't build the Python bindings (pygetdata)]), - [ - case "${enableval}" in - no) make_pybindings="no" ;; - *) make_pybindings="yes" ;; - esac - ]) - -AC_MSG_CHECKING([whether to include the Python bindings]) -AC_MSG_RESULT([$make_pybindings]) - dnl IDL bindings AC_ARG_ENABLE(idl, AS_HELP_STRING([--disable-idl], - [don't build the Interactive Data Language (IDL) bindings (IDL_GetData)]), + [don't build the Interactive Data Language (IDL) bindings ]dnl' + [(IDL_GetData)]), [ case "${enableval}" in no) make_idlbindings="no" ;; @@ -245,6 +226,19 @@ AC_MSG_CHECKING([whether to include the IDL bindings]) AC_MSG_RESULT([$make_idlbindings]) +dnl MATLAB bindings +AC_ARG_ENABLE(matlab, AS_HELP_STRING([--disable-matlab], + [don't build the MATLAB bindings]),dnl' + [ + case "${enableval}" in + no) make_matlabbindings="no" ;; + *) make_matlabbindings="yes" ;; + esac + ]) + +AC_MSG_CHECKING([whether to include the MATLAB bindings]) +AC_MSG_RESULT([$make_matlabbindings]) + dnl Perl bindings AC_ARG_ENABLE(perl, AS_HELP_STRING([--disable-perl], [don't build the Perl bindings (GetData)]),dnl' @@ -258,19 +252,6 @@ AC_MSG_CHECKING([whether to include the Perl bindings]) AC_MSG_RESULT([$make_perlbindings]) -dnl MATLAB bindings -AC_ARG_ENABLE(matlab, AS_HELP_STRING([--disable-matlab], - [don't build the MATLAB bindings]),dnl' - [ - case "${enableval}" in - no) make_matlabbindings="no" ;; - *) make_matlabbindings="yes" ;; - esac - ]) - -AC_MSG_CHECKING([whether to include the MATLAB bindings]) -AC_MSG_RESULT([$make_matlabbindings]) - dnl PHP bindings AC_ARG_ENABLE(php, AS_HELP_STRING([--disable-php], [don't build the PHP bindings]),dnl' @@ -281,6 +262,19 @@ esac ]) +dnl Python bindings +AC_ARG_ENABLE(python, AS_HELP_STRING([--disable-python], + [don't build the Python bindings (pygetdata)]),dnl' + [ + case "${enableval}" in + no) make_pybindings="no" ;; + *) make_pybindings="yes" ;; + esac + ]) + +AC_MSG_CHECKING([whether to include the Python bindings]) +AC_MSG_RESULT([$make_pybindings]) + AC_MSG_CHECKING([whether to include the PHP bindings]) AC_MSG_RESULT([$make_phpbindings]) @@ -451,6 +445,13 @@ AC_MSG_RESULT([yes]) fi +dnl DL library path munging for test suite +case "${host}" in + *-apple-darwin*) DL_LIBRARY_PATH="DYLD_LIBRARY_PATH" ;; + *) DL_LIBRARY_PATH="LD_LIBRARY_PATH" ;; +esac +AC_SUBST([DL_LIBRARY_PATH]) + echo echo "*** Checking C compiler characteristics" echo @@ -865,48 +866,6 @@ #endif ]) -dnl python -if test "x$make_pybindings" = "xyes"; then - echo - echo "*** Configuring python bindings" - echo - GD_PYTHON([2.3]) - have_numpy="no" - if test "x$have_python" = "xno"; then - make_pybindings="no" - else - AC_MSG_CHECKING([for NumPy]) - cat > conftest.py << EOF -import sys -try: - import numpy -except ImportError: - sys.exit(1) -EOF - if $PYTHON conftest.py > /dev/null 2>&1; then - have_numpy="yes" - fi - AC_MSG_RESULT([$have_numpy]) - fi - if test "x$have_numpy" = "xyes"; then - AC_MSG_CHECKING([NumPy includes]) - NUMPY_CPPFLAGS=-I`$PYTHON -c "import numpy; print numpy.get_include()"` - AC_MSG_RESULT([$NUMPY_CPPFLAGS]) - - saved_cppflags=$CPPFLAGS - CPPFLAGS="${CPPFLAGS} ${PYTHON_CPPFLAGS} ${NUMPY_CPPFLAGS}" - AC_CHECK_HEADERS([numpy/arrayobject.h],,[have_numpy="no"],[ -#include<Python.h> -]) - CPPFLAGS=$saved_cppflags - fi - - if test "x$have_numpy" = "xyes"; then - AC_DEFINE([USE_NUMPY], [], - [ Define to enable NumPy support in the Python bindings ]) - fi -fi - dnl idl if test "x$make_idlbindings" = "xyes"; then echo @@ -927,6 +886,17 @@ fi fi +dnl matlab +if test "x$make_matlabbindings" = "xyes"; then + echo + echo "*** Configuring MATLAB bindings" + echo + GD_MATLAB + if test "x$have_matlab" = "xno"; then + make_matlabbindings=no + fi +fi + dnl perl if test "x$make_perlbindings" = "xyes"; then echo @@ -938,17 +908,6 @@ fi fi -dnl matlab -if test "x$make_matlabbindings" = "xyes"; then - echo - echo "*** Configuring MATLAB bindings" - echo - GD_MATLAB - if test "x$have_matlab" = "xno"; then - make_matlabbindings=no - fi -fi - dnl php if test "x$make_phpbindings" = "xyes"; then echo @@ -969,6 +928,48 @@ fi fi +dnl python +if test "x$make_pybindings" = "xyes"; then + echo + echo "*** Configuring python bindings" + echo + GD_PYTHON([2.3]) + have_numpy="no" + if test "x$have_python" = "xno"; then + make_pybindings="no" + else + AC_MSG_CHECKING([for NumPy]) + cat > conftest.py << EOF +import sys +try: + import numpy +except ImportError: + sys.exit(1) +EOF + if $PYTHON conftest.py > /dev/null 2>&1; then + have_numpy="yes" + fi + AC_MSG_RESULT([$have_numpy]) + fi + if test "x$have_numpy" = "xyes"; then + AC_MSG_CHECKING([NumPy includes]) + NUMPY_CPPFLAGS=-I`$PYTHON -c "import numpy; print numpy.get_include()"` + AC_MSG_RESULT([$NUMPY_CPPFLAGS]) + + saved_cppflags=$CPPFLAGS + CPPFLAGS="${CPPFLAGS} ${PYTHON_CPPFLAGS} ${NUMPY_CPPFLAGS}" + AC_CHECK_HEADERS([numpy/arrayobject.h],,[have_numpy="no"],[ +#include<Python.h> +]) + CPPFLAGS=$saved_cppflags + fi + + if test "x$have_numpy" = "xyes"; then + AC_DEFINE([USE_NUMPY], [], + [ Define to enable NumPy support in the Python bindings ]) + fi +fi + dnl external encodings GD_CHECK_ENCODING([bzip2],[bz2],[BZ2_bzReadOpen],[bzlib.h],[bzip2],[bunzip2],[]) GD_CHECK_ENCODING([gzip],[z],[gzopen],[zlib.h],[gzip],[gunzip],[]) @@ -980,8 +981,8 @@ dnl zzslim hackery -- there's no easy way to check whether slim supports zzip AC_ARG_ENABLE(zzslim, AS_HELP_STRING([--enable-zzslim], [skip probing for zzslim required features and enable the zzslim - encoding. The default is to autodetect support. Note: zzslim - encoding support requires both slim and zzip encoding support.]), + encoding. Note: zzslim encoding support requires both slim and + zzip encoding support. [default: autodetect]]), [ case "${enableval}" in no) zzslim_override="no" ;; Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-05-05 20:38:45 UTC (rev 895) +++ trunk/getdata/src/encoding.c 2014-05-05 21:16:59 UTC (rev 896) @@ -933,6 +933,9 @@ dtrace("0x%lX", encoding); + /* spin up ltdl if needed */ + _GD_InitialiseFramework(); + /* make sure we have a valid encoding */ if (!_GD_EncodingUnderstood(encoding)) { dreturn("%i", -1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-05 20:38:51
|
Revision: 895 http://sourceforge.net/p/getdata/code/895 Author: ketiltrout Date: 2014-05-05 20:38:45 +0000 (Mon, 05 May 2014) Log Message: ----------- * Remove GD_MAX_CARRAY_LENGTH. * Add gd_encoding_support(). Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/man/Makefile.am trunk/getdata/man/gd_add.3 trunk/getdata/man/gd_add_bit.3 trunk/getdata/man/gd_alter_spec.3 trunk/getdata/man/gd_cbopen.3 trunk/getdata/src/add.c trunk/getdata/src/encoding.c trunk/getdata/src/getdata.h.in trunk/getdata/src/mod.c trunk/getdata/src/parse.c trunk/getdata/test/Makefile.am Added Paths: ----------- trunk/getdata/man/gd_encoding_support.3 trunk/getdata/test/encode_support.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/ChangeLog 2014-05-05 20:38:45 UTC (rev 895) @@ -1,3 +1,19 @@ +2014-05-05 D. V. Wiebe <ge...@ke...> svn:895 + * src/getdata.h.in: Remove GD_MAX_CARRAY_LENGTH. + * src/add.c (_GD_Add) src/mod.c (_GD_Change) src/parse.c (_GD_ParseArray): + Remove references to GD_MAX_CARRAY_LENGTH. + + * src/add.c (gd_add_raw gd_add_lincom gd_add_clincom gd_add_linterp + gd_add_bit gd_add_sbit _GD_AddYoke gd_add_recip gd_add_crecip89 + gd_add_polynom gd_add_cpolynom gd_add_phase gd_add_window gd_add_mplex + gd_madd_lincom gd_madd_clincom gd_madd_linterp gd_madd_bit gd_madd_sbit + _GD_MAddYoke gd_madd_phase gd_madd_polynom gd_madd_cpolynom gd_madd_recip + gd_madd_crecip89 gd_madd_window gd_madd_mplex): Call _GD_Add in a slightly + less ridiculous way. + + * src/encoding.c (gd_encoding_support): Added. + * man/gd_encoding_support.3 test/encode_support.c: Added. + 2014-04-30 D. V. Wiebe <ge...@ke...> svn:890 svn:891 * bindings/cxx/test/big_test.cpp bindings/f77/test/big_test.f bindings/f77/test/big_test95.f90 bindings/idl/test/big_test.pro Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/NEWS 2014-05-05 20:38:45 UTC (rev 895) @@ -17,6 +17,13 @@ renamed field to point to the new field instead of leaving them dangle. (But see GD_REN_DANGLE). + * CARRAYs are no longer truncated to GD_MAX_CARRAY_LENGTH elements. Flushing + metadata to disk will now fail if writing a CARRAY would overflow a format + file line. (It's platform specific, but format file lines are typically + permitted to be at least 2**31 bytes long, so such an error usually + indicates something pathological happening.) The GD_MAX_CARRAY_LENGTH + symbol has been removed from the GetData header file. + * BUG FIX: The parsing of the \x and \u escape sequences are now correct. * BUG FIX: Computation of LINCOMs with complex valued input fields now @@ -135,6 +142,9 @@ gd_move(). If gd_move() is passed the field code of an alias, the alias is now moved, instead of moving the field the alias points to. + * gd_encoding_support() has been added to permit run-time determination of + supported encodings. + * BUG FIX: If the dirfile path provided cannot be resolved (due to, for instance, a symbolic link pointing to a non-existent path), gd_open() and friends now return GD_E_OPEN, as documented, instead of GD_E_RAW_IO. Modified: trunk/getdata/man/Makefile.am =================================================================== --- trunk/getdata/man/Makefile.am 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/man/Makefile.am 2014-05-05 20:38:45 UTC (rev 895) @@ -28,17 +28,17 @@ gd_alter_protection.3 gd_alter_spec.3 gd_bof.3 gd_bof64.3 \ gd_carray_len.3 gd_carrays.3 gd_cbopen.3 gd_close.3 \ gd_constants.3 gd_delete.3 gd_desync.3 gd_dirfile_standards.3 \ - gd_dirfilename.3 gd_encoding.3 gd_endianness.3 gd_entry.3 \ - gd_entry_list.3 gd_entry_type.3 gd_eof.3 gd_eof64.3 gd_error.3 \ - gd_error_count.3 gd_error_string.3 gd_flags.3 gd_flush.3 \ - gd_fragment_affixes.3 gd_fragment_index.3 gd_fragmentname.3 \ - gd_framenum_subset.3 gd_framenum_subset64.3 gd_frameoffset.3 \ - gd_frameoffset64.3 gd_free_entry_strings.3 \ - gd_get_carray_slice.3 gd_get_string.3 gd_getdata.3 \ - gd_getdata64.3 gd_hidden.3 gd_hide.3 gd_include_affix.3 \ - gd_invalid_dirfile.3 gd_linterp_tablename.3 gd_madd_bit.3 \ - gd_mcarrays.3 gd_mconstants.3 gd_metaflush.3 gd_move.3 \ - gd_mplex_lookback.3 gd_mstrings.3 gd_naliases.3 \ + gd_dirfilename.3 gd_encoding.3 gd_encoding_support.3 \ + gd_endianness.3 gd_entry.3 gd_entry_list.3 gd_entry_type.3 \ + gd_eof.3 gd_eof64.3 gd_error.3 gd_error_count.3 \ + gd_error_string.3 gd_flags.3 gd_flush.3 gd_fragment_affixes.3 \ + gd_fragment_index.3 gd_fragmentname.3 gd_framenum_subset.3 \ + gd_framenum_subset64.3 gd_frameoffset.3 gd_frameoffset64.3 \ + gd_free_entry_strings.3 gd_get_carray_slice.3 gd_get_string.3 \ + gd_getdata.3 gd_getdata64.3 gd_hidden.3 gd_hide.3 \ + gd_include_affix.3 gd_invalid_dirfile.3 gd_linterp_tablename.3 \ + gd_madd_bit.3 gd_mcarrays.3 gd_mconstants.3 gd_metaflush.3 \ + gd_move.3 gd_mplex_lookback.3 gd_mstrings.3 gd_naliases.3 \ gd_native_type.3 gd_nentries.3 gd_nfragments.3 gd_nframes.3 \ gd_nframes64.3 gd_parent_fragment.3 gd_parser_callback.3 \ gd_protection.3 gd_put_carray_slice.3 \ Modified: trunk/getdata/man/gd_add.3 =================================================================== --- trunk/getdata/man/gd_add.3 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/man/gd_add.3 2014-05-05 20:38:45 UTC (rev 895) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_add 3 "10 December 2013" "Version 0.9.0" "GETDATA" +.TH gd_add 3 "5 May 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_add, gd_madd \(em add a field to a dirfile .SH SYNOPSIS @@ -153,13 +153,6 @@ .B CARRAY entry, was invalid. .TP -.B GD_E_BOUNDS -The -.IR entry -> array_len -parameter provided with a -.B CARRAY -entry was greater than GD_MAX_CARRAY_LENGTH. -.TP .B GD_E_DUPLICATE The field name provided in .IR entry -> field @@ -199,15 +192,6 @@ A descriptive error string for the last error encountered can be obtained from a call to .BR gd_error_string (3). -.SH NOTES -GetData artificially limits the number of elements in a -.B CARRAY -to the value of the symbol GD_MAX_CARRAY_LENGTH defined in getdata.h. This is -done to be certain that the -.B CARRAY -won't overrun the line when flushed to disk. On platforms with a \fIn\fR-bit -.BR size_t , -GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. .SH SEE ALSO .BR gd_add_bit (3), Modified: trunk/getdata/man/gd_add_bit.3 =================================================================== --- trunk/getdata/man/gd_add_bit.3 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/man/gd_add_bit.3 2014-05-05 20:38:45 UTC (rev 895) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_add_bit 3 "30 September 2013" "Version 0.9.0" "GETDATA" +.TH gd_add_bit 3 "5 May 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_add_bit, gd_add_carray gd_add_clincom, gd_add_const, gd_add_cpolynom, gd_add_crecip, gd_add_divide, gd_add_lincom, gd_add_linterp, gd_add_multiply, @@ -254,13 +254,6 @@ .BR gd_add_raw "() or " gd_add_const (), was invalid. .TP -.B GD_E_BOUNDS -The -.I array_len -parameter provided to -.BR gd_add_carray () -was greater than GD_MAX_CARRAY_LENGTH. -.TP .B GD_E_DUPLICATE The .IR field_name @@ -302,15 +295,6 @@ .BR gd_error_string (3). .SH NOTES -GetData artificially limits the number of elements in a -.B CARRAY -to the value of the symbol GD_MAX_CARRAY_LENGTH defined in getdata.h. This is -done to be certain that the -.B CARRAY -won't overrun the line when flushed to disk. On platforms with a \fIn\fR-bit -.BR size_t , -GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. - The C89 GetData API provides different prototypes for .BR gd_add_clincom "(), " gd_add_cpolynom (), and Modified: trunk/getdata/man/gd_alter_spec.3 =================================================================== --- trunk/getdata/man/gd_alter_spec.3 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/man/gd_alter_spec.3 2014-05-05 20:38:45 UTC (rev 895) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_alter_spec 3 "17 August 2011" "Version 0.8.0" "GETDATA" +.TH gd_alter_spec 3 "5 May 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_spec, gd_malter_spec \(em modify a field in a dirfile .SH SYNOPSIS @@ -152,13 +152,6 @@ A descriptive error string for the last error encountered can be obtained from a call to .BR gd_error_string (3). -.SH NOTES -If a -.B CARRAY -field with more than GD_MAX_CARRAY_LENGTH elements is provided, subsequent -elements will be silently truncated. On platforms with a \fIn\fR-bit -.BR size_t , -GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. .SH SEE ALSO .BR gd_alter_bit (3), .BR gd_alter_const (3), Modified: trunk/getdata/man/gd_cbopen.3 =================================================================== --- trunk/getdata/man/gd_cbopen.3 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/man/gd_cbopen.3 2014-05-05 20:38:45 UTC (rev 895) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_cbopen 3 "3 April 2013" "Version 0.8.4" "GETDATA" +.TH gd_cbopen 3 "5 May 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_cbopen, gd_open \(em open or create a dirfile .SH SYNOPSIS @@ -716,15 +716,6 @@ .B GD_LITTLE_ENDIAN should be specified by the caller. -GetData artificially limits the size of a -.B CARRAY -field to GD_MAX_CARRAY_LENGTH elements, to be certain it is always able to -write the CARRAY back to disk without overrunning its maximum line length. -On platforms with a \fIn\fR-bit -.BR size_t , -GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. Excess elements are silently -truncated on dirfile open. - GetData's parser assumes it is running on an ASCII-compatible platform. Format specification parsing will fail gloriously on an EBCDIC platform. .SH SEE ALSO Added: trunk/getdata/man/gd_encoding_support.3 =================================================================== --- trunk/getdata/man/gd_encoding_support.3 (rev 0) +++ trunk/getdata/man/gd_encoding_support.3 2014-05-05 20:38:45 UTC (rev 895) @@ -0,0 +1,69 @@ +.\" gd_encoding_support.3. The gd_encoding_support man page. +.\" +.\" Copyright (C) 2014 D. V. Wiebe +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.\" This file is part of the GetData project. +.\" +.\" Permission is granted to copy, distribute and/or modify this document +.\" under the terms of the GNU Free Documentation License, Version 1.2 or +.\" any later version published by the Free Software Foundation; with no +.\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +.\" Texts. A copy of the license is included in the `COPYING.DOC' file +.\" as part of this distribution. +.\" +.TH gd_encoding_support 3 "5 May 2014" "Version 0.9.0" "GETDATA" +.SH NAME +gd_encoding_support \(em determine GetData library support for data encodings +.SH SYNOPSIS +.B #include <getdata.h> +.HP +.nh +.ad l +.BI "int gd_encoding_support(unsigned long " encoding ); +.hy +.ad n +.SH DESCRIPTION +The +.BR gd_encoding_support () +function reports whether the Dirfile encoding specified by +.I encoding +is supported by the GetData library. The +.I encoding +argument should be one of the following symbols, indicating the encoding type: +.IP +.nh +.ad l +.BR GD_UNENCODED ", " GD_BZIP2_ENCODED ", " GD_GZIP_ENCODED , +.BR GD_LZMA_ENCODED ", " GD_SIE_ENCODED ", " GD_SLIM_ENCODED , +.BR GD_TEXT_ENCODED ", " GD_ZZIP_ENCODED ", " GD_ZZSLIM_ENCODED . +.ad n +.hy +.PP +See +.BR gd_cbopen (3) +and dirfile-encoding(5) for the meanings of these symbols and details on the +known encoding schemes. + +.SH RETURN VALUE +The function +.BR gd_encoding_support () +returns +.B GD_RDWR +if the GetData library can read from and write to the specified encoding, +.B GD_RDONLY +if the GetData library can only read from the specified encoding, or -1 if +neither reading nor writing is supported, or if +.I encoding +was not one of the symbols listed above. +.SH NOTES +GetData's encoding support framework is more finely grained than the three-way +system reported by this function. It is possible for the library to have +partial support for reading or writing a particular encoding. This function +will only report positive support if all functions of a given class (read-only +or read-write) are supported. +.SH SEE ALSO +dirfile-encoding(5), +.BR gd_cbopen (3), +.BR gd_encoding (3) Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/src/add.c 2014-05-05 20:38:45 UTC (rev 895) @@ -500,9 +500,7 @@ == 0) { _GD_SetError(D, GD_E_BAD_TYPE, E->EN(scalar,const_type), NULL, 0, NULL); - } else if (E->EN(scalar,array_len) > GD_MAX_CARRAY_LENGTH) - _GD_SetError(D, GD_E_BOUNDS, 0, NULL, 0, NULL); - else { + } else { size_t size = GD_SIZE(_GD_ConstType(D, E->EN(scalar,const_type))) * E->EN(scalar,array_len); if (!D->error) @@ -817,7 +815,6 @@ unsigned int spf, int fragment_index) { gd_entry_t R; - int error; dtrace("%p, \"%s\", 0x%X, %i, %i", D, field_code, data_type, spf, fragment_index); @@ -834,10 +831,14 @@ R.EN(raw,spf) = spf; R.EN(raw,data_type) = data_type; R.fragment_index = fragment_index; - error = (_GD_Add(D, &R, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &R, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a LINCOM entry */ @@ -845,7 +846,7 @@ const char** in_fields, const double* m, const double* b, int fragment_index) gd_nothrow { - int i, error; + int i; gd_entry_t L; dtrace("%p, \"%s\", %i, %p, %p, %p, %i", D, field_code, n_fields, in_fields, @@ -874,10 +875,14 @@ L.EN(lincom,m)[i] = m[i]; L.EN(lincom,b)[i] = b[i]; } - error = (_GD_Add(D, &L, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &L, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a LINCOM entry with complex scalars */ @@ -885,7 +890,7 @@ const char** in_fields, const GD_DCOMPLEXP(cm), const GD_DCOMPLEXP(cb), int fragment_index) gd_nothrow { - int i, error; + int i; gd_entry_t L; dtrace("%p, \"%s\", %i, %p, %p, %p, %i", D, field_code, n_fields, in_fields, @@ -915,10 +920,14 @@ gd_ca2cs_(L.EN(lincom,cm)[i], cm, i); gd_ca2cs_(L.EN(lincom,cb)[i], cb, i); } - error = (_GD_Add(D, &L, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &L, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a LINTERP entry */ @@ -926,7 +935,6 @@ const char* table, int fragment_index) gd_nothrow { gd_entry_t L; - int error; dtrace("%p, \"%s\", \"%s\", \"%s\", %i", D, field_code, in_field, table, fragment_index); @@ -943,10 +951,14 @@ L.in_fields[0] = (char *)in_field; L.EN(linterp,table) = (char *)table; L.fragment_index = fragment_index; - error = (_GD_Add(D, &L, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &L, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a BIT entry */ @@ -954,7 +966,6 @@ int bitnum, int numbits, int fragment_index) gd_nothrow { gd_entry_t B; - int error; dtrace("%p, \"%s\", \"%s\", %i, %i, %i", D, field_code, in_field, bitnum, numbits, fragment_index); @@ -972,10 +983,14 @@ B.EN(bit,bitnum) = bitnum; B.EN(bit,numbits) = numbits; B.fragment_index = fragment_index; - error = (_GD_Add(D, &B, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &B, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a SBIT entry */ @@ -983,7 +998,6 @@ int bitnum, int numbits, int fragment_index) gd_nothrow { gd_entry_t B; - int error; dtrace("%p, \"%s\", \"%s\", %i, %i, %i", D, field_code, in_field, bitnum, numbits, fragment_index); @@ -1001,17 +1015,20 @@ B.EN(bit,bitnum) = bitnum; B.EN(bit,numbits) = numbits; B.fragment_index = fragment_index; - error = (_GD_Add(D, &B, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &B, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } static int _GD_AddYoke(DIRFILE* D, gd_entype_t t, const char* field_code, const char* in_field1, const char* in_field2, int fragment_index) gd_nothrow { gd_entry_t M; - int error; dtrace("%p, 0x%X, \"%s\", \"%s\", \"%s\", %i", D, t, field_code, in_field1, in_field2, fragment_index); @@ -1028,10 +1045,14 @@ M.in_fields[0] = (char *)in_field1; M.in_fields[1] = (char *)in_field2; M.fragment_index = fragment_index; - error = (_GD_Add(D, &M, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &M, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } int gd_add_multiply(DIRFILE* D, const char* field_code, const char* in_field1, @@ -1067,7 +1088,6 @@ double dividend, int fragment_index) gd_nothrow { gd_entry_t E; - int error; dtrace("%p, \"%s\", \"%s\", %g, %i", D, field_code, in_field, dividend, fragment_index); @@ -1084,10 +1104,14 @@ E.EN(recip,dividend) = dividend; E.in_fields[0] = (char *)in_field; E.fragment_index = fragment_index; - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } #ifndef GD_NO_C99_API @@ -1111,7 +1135,6 @@ const double cdividend[2], int fragment_index) gd_nothrow { gd_entry_t E; - int error; dtrace("%p, \"%s\", \"%s\", {%g, %g}, %i", D, field_code, in_field, cdividend[0], cdividend[1], fragment_index); @@ -1129,17 +1152,21 @@ E.flags = GD_EN_COMPSCAL; E.in_fields[0] = (char *)in_field; E.fragment_index = fragment_index; - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a POLYNOM entry */ int gd_add_polynom(DIRFILE* D, const char* field_code, int poly_ord, const char* in_field, const double* a, int fragment_index) gd_nothrow { - int i, error; + int i; gd_entry_t E; dtrace("%p, \"%s\", %i, \"%s\", %p, %i", D, field_code, poly_ord, in_field, @@ -1167,16 +1194,19 @@ for (i = 0; i <= poly_ord; ++i) E.EN(polynom,a)[i] = a[i]; - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; + if (_GD_Add(D, &E, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } - dreturn("%i", error); - return error; + dreturn("%i", 0); + return 0; } int gd_add_cpolynom(DIRFILE* D, const char* field_code, int poly_ord, const char* in_field, const GD_DCOMPLEXP(ca), int fragment_index) gd_nothrow { - int i, error; + int i; gd_entry_t E; dtrace("%p, \"%s\", %i, \"%s\", %p, %i", D, field_code, poly_ord, in_field, @@ -1205,10 +1235,13 @@ for (i = 0; i <= poly_ord; ++i) gd_ca2cs_(E.EN(polynom,ca)[i], ca, i); - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; + if (_GD_Add(D, &E, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } - dreturn("%i", error); - return error; + dreturn("%i", 0); + return 0; } /* add a PHASE entry */ @@ -1216,7 +1249,6 @@ gd_shift_t shift, int fragment_index) gd_nothrow { gd_entry_t P; - int error; dtrace("%p, \"%s\", \"%s\", %lli, %i", D, field_code, in_field, (long long)shift, fragment_index); @@ -1233,10 +1265,14 @@ P.in_fields[0] = (char *)in_field; P.EN(phase,shift) = shift; P.fragment_index = fragment_index; - error = (_GD_Add(D, &P, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &P, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a WINDOW entry */ @@ -1245,7 +1281,6 @@ int fragment_index) gd_nothrow { gd_entry_t E; - int error; dtrace("%p, \"%s\", \"%s\", \"%s\", %i, {%g,%llx,%lli}, %i", D, field_code, in_field, check_field, windop, threshold.r, @@ -1265,10 +1300,14 @@ E.in_fields[0] = (char *)in_field; E.in_fields[1] = (char *)check_field; E.fragment_index = fragment_index; - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a MPLEX entry */ @@ -1277,7 +1316,6 @@ gd_nothrow { gd_entry_t E; - int error; dtrace("%p, \"%s\", \"%s\", \"%s\", %i, %i, %i", D, field_code, in_field, count_field, count_val, period, fragment_index); @@ -1296,10 +1334,14 @@ E.in_fields[0] = (char *)in_field; E.in_fields[1] = (char *)count_field; E.fragment_index = fragment_index; - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, NULL) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a STRING entry */ @@ -1490,7 +1532,7 @@ int n_fields, const char** in_fields, const double* m, const double* b) gd_nothrow { - int i, error; + int i; gd_entry_t L; dtrace("%p, \"%s\", \"%s\", %i, %p, %p, %p", D, field_code, parent, @@ -1521,10 +1563,14 @@ L.scalar[i] = NULL; L.scalar[i + GD_MAX_LINCOM] = NULL; } - error = (_GD_Add(D, &L, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &L, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META LINCOM entry, with complex scalaras */ @@ -1532,7 +1578,7 @@ int n_fields, const char** in_fields, const GD_DCOMPLEXP(cm), const GD_DCOMPLEXP(cb)) gd_nothrow { - int i, error; + int i; gd_entry_t L; dtrace("%p, \"%s\", \"%s\", %i, %p, %p, %p", D, field_code, parent, @@ -1564,10 +1610,14 @@ L.scalar[i] = NULL; L.scalar[i + GD_MAX_LINCOM] = NULL; } - error = (_GD_Add(D, &L, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &L, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META LINTERP entry */ @@ -1575,7 +1625,6 @@ const char* field_code, const char* in_field, const char* table) gd_nothrow { gd_entry_t L; - int error; dtrace("%p, \"%s\", \"%s\", \"%s\", \"%s\"", D, field_code, parent, in_field, table); @@ -1592,10 +1641,14 @@ L.in_fields[0] = (char *)in_field; L.EN(linterp,table) = (char *)table; L.fragment_index = 0; - error = (_GD_Add(D, &L, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &L, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META BIT entry */ @@ -1603,7 +1656,6 @@ const char* in_field, int bitnum, int numbits) gd_nothrow { gd_entry_t B; - int error; dtrace("%p, \"%s\", \"%s\", \"%s\", %i, %in", D, field_code, parent, in_field, bitnum, numbits); @@ -1622,10 +1674,14 @@ B.EN(bit,numbits) = numbits; B.fragment_index = 0; B.scalar[0] = B.scalar[1] = NULL; - error = (_GD_Add(D, &B, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &B, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META SBIT entry */ @@ -1633,7 +1689,6 @@ const char* in_field, int bitnum, int numbits) gd_nothrow { gd_entry_t B; - int error; dtrace("%p, \"%s\", \"%s\", \"%s\", %i, %in", D, field_code, parent, in_field, bitnum, numbits); @@ -1652,10 +1707,14 @@ B.EN(bit,numbits) = numbits; B.fragment_index = 0; B.scalar[0] = B.scalar[1] = NULL; - error = (_GD_Add(D, &B, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &B, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } static int _GD_MAddYoke(DIRFILE* D, gd_entype_t t, const char* parent, @@ -1663,7 +1722,6 @@ gd_nothrow { gd_entry_t M; - int error; dtrace("%p, 0x%X, \"%s\", \"%s\", \"%s\", \"%s\"", D, t, field_code, parent, in_field1, in_field2); @@ -1680,10 +1738,14 @@ M.in_fields[0] = (char *)in_field1; M.in_fields[1] = (char *)in_field2; M.fragment_index = 0; - error = (_GD_Add(D, &M, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &M, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } int gd_madd_multiply(DIRFILE* D, const char *parent, const char* field_code, @@ -1697,7 +1759,6 @@ int gd_madd_phase(DIRFILE* D, const char* parent, const char* field_code, const char* in_field, gd_shift_t shift) gd_nothrow { - int error; gd_entry_t P; dtrace("%p, \"%s\", \"%s\", \"%s\", %lli", D, field_code, parent, in_field, @@ -1716,17 +1777,21 @@ P.EN(phase,shift) = shift; P.fragment_index = 0; P.scalar[0] = NULL; - error = (_GD_Add(D, &P, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &P, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META POLYNOM entry */ int gd_madd_polynom(DIRFILE* D, const char* parent, const char* field_code, int poly_ord, const char* in_field, const double* a) gd_nothrow { - int i, error; + int i; gd_entry_t E; dtrace("%p, \"%s\", \"%s\", %i, \"%s\", %p", D, field_code, parent, poly_ord, @@ -1756,17 +1821,20 @@ E.scalar[i] = NULL; } - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; + if (_GD_Add(D, &E, parent) == NULL) { + dreturn("%i", -1); + return -1; + } - dreturn("%i", error); - return error; + dreturn("%i", 0); + return 0; } /* add a META POLYNOM entry */ int gd_madd_cpolynom(DIRFILE* D, const char* parent, const char* field_code, int poly_ord, const char* in_field, const GD_DCOMPLEXP(ca)) gd_nothrow { - int i, error; + int i; gd_entry_t E; dtrace("%p, \"%s\", \"%s\", %i, \"%s\", %p", D, field_code, parent, poly_ord, @@ -1797,10 +1865,13 @@ E.scalar[i] = NULL; } - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; + if (_GD_Add(D, &E, parent) == NULL) { + dreturn("%i", -1); + return -1; + } - dreturn("%i", error); - return error; + dreturn("%i", 0); + return 0; } int gd_madd_divide(DIRFILE* D, const char *parent, const char* field_code, @@ -1828,7 +1899,6 @@ int gd_madd_recip(DIRFILE* D, const char *parent, const char* field_code, const char* in_field, double dividend) gd_nothrow { - int error; gd_entry_t E; dtrace("%p, \"%s\", \"%s\", \"%s\", %g", D, parent, field_code, in_field, @@ -1845,10 +1915,14 @@ E.field_type = GD_RECIP_ENTRY; E.EN(recip,dividend) = dividend; E.in_fields[0] = (char *)in_field; - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } #ifndef GD_NO_C99_API @@ -1872,7 +1946,6 @@ const char* in_field, const double cdividend[2]) gd_nothrow { gd_entry_t E; - int error; dtrace("%p, \"%s\", \"%s\", \"%s\", {%g, %g}", D, parent, field_code, in_field, cdividend[0], cdividend[1]); @@ -1889,10 +1962,14 @@ gd_ra2cs_(E.EN(recip,cdividend), cdividend); E.flags = GD_EN_COMPSCAL; E.in_fields[0] = (char *)in_field; - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META WINDOW entry */ @@ -1900,7 +1977,6 @@ const char *in_field, const char *check_field, gd_windop_t windop, gd_triplet_t threshold) gd_nothrow { - int error; gd_entry_t E; dtrace("%p, \"%s\", \"%s\", \"%s\", \"%s\", %i, {%g,%llx,%lli}", D, parent, @@ -1920,10 +1996,14 @@ E.EN(window,windop) = windop; E.in_fields[0] = (char *)in_field; E.in_fields[1] = (char *)check_field; - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META MPLEX entry */ @@ -1931,7 +2011,6 @@ const char *in_field, const char *count_field, int count_val, int period) gd_nothrow { - int error; gd_entry_t E; dtrace("%p, \"%s\", \"%s\", \"%s\", \"%s\", %i, %i", D, parent, field_code, @@ -1950,10 +2029,14 @@ E.EN(mplex,period) = period; E.in_fields[0] = (char *)in_field; E.in_fields[1] = (char *)count_field; - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; - dreturn("%i", error); - return error; + if (_GD_Add(D, &E, parent) == NULL) { + dreturn("%i", -1); + return -1; + } + + dreturn("%i", 0); + return 0; } /* add a META STRING entry */ Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/src/encoding.c 2014-05-05 20:38:45 UTC (rev 895) @@ -195,7 +195,8 @@ ((encoding == GD_UNENCODED || encoding == GD_SLIM_ENCODED || \ encoding == GD_GZIP_ENCODED || encoding == GD_BZIP2_ENCODED || \ encoding == GD_TEXT_ENCODED || encoding == GD_LZMA_ENCODED || \ - encoding == GD_SIE_ENCODED)) + encoding == GD_SIE_ENCODED || encoding == GD_ZZIP_ENCODED || \ + encoding == GD_ZZSLIM_ENCODED)) #ifdef USE_MODULES static void *_GD_ResolveSymbol(lt_dlhandle lib, struct encoding_t *restrict enc, @@ -920,6 +921,47 @@ return reported_encoding; } +/* report whether a particular encoding is supported */ +int gd_encoding_support(unsigned long encoding) gd_nothrow +{ + int i; + + const unsigned int read_funcs = GD_EF_NAME | GD_EF_OPEN | GD_EF_CLOSE | + GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE; + const unsigned int write_funcs = read_funcs | GD_EF_WRITE | GD_EF_SYNC | + GD_EF_MOVE | GD_EF_UNLINK; + + dtrace("0x%lX", encoding); + + /* make sure we have a valid encoding */ + if (!_GD_EncodingUnderstood(encoding)) { + dreturn("%i", -1); + return -1; + } + + /* Loop through valid subencodings checking for write support */ + for (i = 0; gd_ef_[i].scheme != GD_ENC_UNSUPPORTED; i++) + if (gd_ef_[i].scheme == encoding) { + if (!_GD_MissingFramework(i, write_funcs)) { + dreturn("%i", GD_RDWR); + return GD_RDWR; + } + } + + /* No write support; try read support */ + for (i = 0; gd_ef_[i].scheme != GD_ENC_UNSUPPORTED; i++) + if (gd_ef_[i].scheme == encoding) { + if (!_GD_MissingFramework(i, read_funcs)) { + dreturn("%i", GD_RDONLY); + return GD_RDONLY; + } + } + + /* nope */ + dreturn("%i", -1); + return -1; +} + /* This is basically the non-existant POSIX funcion mkstempat. There are two * approaches we could take here: * 1) fchdir to dirfd, use mkstemp to grab a file descriptor; fchdir back to Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/src/getdata.h.in 2014-05-05 20:38:45 UTC (rev 895) @@ -116,13 +116,6 @@ */ #define GD_MAX_LINE_LENGTH 4096 -/* maximum number of elements allowed in a CARRAY. Really the maximum should be - * whatever fits on a format file line, but that's hard to calculate. This is - * 2**(n-8)-1 on a n-bit system. - */ -#define GD_MAX_CARRAY_LENGTH (((size_t)-1) >> 8) - - /* error codes */ #define GD_E_OK 0 /* this MUST be zero */ #define GD_E_OPEN 1 @@ -717,6 +710,8 @@ extern unsigned long int gd_encoding(DIRFILE *dirfile, int fragment) gd_nothrow gd_nonnull ((1)); +extern int gd_encoding_support(unsigned long encoding) gd_nothrow; + extern unsigned long int gd_endianness(DIRFILE *dirfile, int fragment) gd_nothrow gd_nonnull((1)); Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/src/mod.c 2014-05-05 20:38:45 UTC (rev 895) @@ -926,9 +926,6 @@ _GD_SetError(D, GD_E_BAD_TYPE, Q.EN(scalar,const_type), NULL, 0, NULL); break; - } else if (Q.EN(scalar,array_len) > GD_MAX_CARRAY_LENGTH) { - _GD_SetError(D, GD_E_BOUNDS, 0, NULL, 0, NULL); - break; } type = _GD_ConstType(D, Q.EN(scalar,const_type)); @@ -965,11 +962,6 @@ if (Q.EN(scalar,array_len) != E->EN(scalar,array_len)) { modified = 1; - if (Q.EN(scalar,array_len) > GD_MAX_CARRAY_LENGTH) { - _GD_SetError(D, GD_E_BOUNDS, 0, NULL, 0, NULL); - break; - } - Qe.u.scalar.d = _GD_Realloc(D, E->e->u.scalar.d, sizeof(const char *) * Q.EN(scalar,array_len)); if (Qe.u.scalar.d == NULL) Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/src/parse.c 2014-05-05 20:38:45 UTC (rev 895) @@ -1263,6 +1263,9 @@ } for (c = first; c < n_cols; ++c) { + if (n == GD_SIZE_T_MAX) + break; + if (string) { ((const char**)data)[n++] = _GD_Strdup(D, in_cols[c]); @@ -1286,9 +1289,6 @@ return NULL; } } - - if (n == GD_MAX_CARRAY_LENGTH) - break; } if (n_cols < MAX_IN_COLS) Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/test 2014-05-05 20:38:45 UTC (rev 895) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -346,6 +346,7 ## encode_get encode_recode encode_recode_open +encode_support endian_alter endian_alter_all endian_alter_sie Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-05-03 00:06:48 UTC (rev 894) +++ trunk/getdata/test/Makefile.am 2014-05-05 20:38:45 UTC (rev 895) @@ -142,7 +142,7 @@ ELIST_TESTS=elist_alias elist_hidden elist_noalias elist_scalar ENCODE_TESTS=encode_alter encode_alter_all encode_alter_open encode_get \ - encode_recode encode_recode_open + encode_recode encode_recode_open encode_support ENDIAN_TESTS=endian_alter endian_alter_all endian_alter_sie endian_get \ endian_move Added: trunk/getdata/test/encode_support.c =================================================================== --- trunk/getdata/test/encode_support.c (rev 0) +++ trunk/getdata/test/encode_support.c 2014-05-05 20:38:45 UTC (rev 895) @@ -0,0 +1,89 @@ +/* Copyright (C) 2014 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" + +/* figure out expected support */ +#ifdef USE_SLIM +#define GD_SLIM_MODE GD_RDONLY +#else +#define GD_SLIM_MODE -1 +#endif + +#ifdef USE_GZIP +#define GD_GZIP_MODE GD_RDWR +#else +#define GD_GZIP_MODE -1 +#endif + +#ifdef USE_BZIP2 +#define GD_BZIP2_MODE GD_RDONLY +#else +#define GD_BZIP2_MODE -1 +#endif + +#ifdef USE_LZMA +#define GD_LZMA_MODE GD_RDONLY +#else +#define GD_LZMA_MODE -1 +#endif + +#ifdef USE_ZZIP +#define GD_ZZIP_MODE GD_RDONLY +#else +#define GD_ZZIP_MODE -1 +#endif + +#ifdef USE_ZZSLIM +#define GD_ZZSLIM_MODE GD_RDONLY +#else +#define GD_ZZSLIM_MODE -1 +#endif + +#define N 13 +int main(void) +{ + int i, r = 0; + struct { + unsigned long e; + int v; + } d[N] = { + { GD_AUTO_ENCODED, -1 }, /* 0 */ + { GD_UNENCODED, GD_RDWR }, /* 1 */ + { GD_TEXT_ENCODED, GD_RDWR }, /* 2 */ + { GD_SLIM_ENCODED, GD_SLIM_MODE }, /* 3 */ + { GD_GZIP_ENCODED, GD_GZIP_MODE }, /* 4 */ + { GD_BZIP2_ENCODED, GD_BZIP2_MODE }, /* 5 */ + { GD_LZMA_ENCODED, GD_LZMA_MODE }, /* 6 */ + { GD_SIE_ENCODED, GD_RDWR }, /* 7 */ + { GD_ZZIP_ENCODED, GD_ZZIP_MODE }, /* 8 */ + { GD_ZZSLIM_ENCODED, GD_ZZSLIM_MODE }, /* 9 */ + { GD_ENC_UNSUPPORTED, -1 }, /* 10 */ + { GD_ENCODING, -1 }, /* 11 */ + { 765, -1 } /* 12 */ + }; + + for (i = 0; i < N; ++i) { + int q = gd_encoding_support(d[i].e); + CHECKIi(i, q, d[i].v); + } + + return r; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-03 00:06:52
|
Revision: 894 http://sourceforge.net/p/getdata/code/894 Author: ketiltrout Date: 2014-05-03 00:06:48 +0000 (Sat, 03 May 2014) Log Message: ----------- Preliminary Getdata-0.9 support. Miscellaneous doc updates. Modified Paths: -------------- trunk/defile/Makefile.am trunk/defile/bin/net.c trunk/defile/bin/rc.c trunk/defile/doc/Makefile.am trunk/defile/doc/defile-ascii.1 trunk/defile/doc/defile-dirfile.1 trunk/defile/doc/defile-input.7 trunk/defile/doc/defile.1.in trunk/defile/doc/df_add_entry.3 trunk/defile/doc/df_add_fragment.3 trunk/defile/doc/df_add_framedef.3 trunk/defile/doc/df_add_lut.3 trunk/defile/doc/df_init.3 trunk/defile/doc/df_push_frame.3 trunk/defile/doc/df_ready.3 trunk/defile/doc/df_shell_expand.3 trunk/defile/lib/internal.h Added Paths: ----------- trunk/defile/doc/df_field_in_output.3 Removed Paths: ------------- trunk/defile/doc/df_field_in_input.3 Modified: trunk/defile/Makefile.am =================================================================== --- trunk/defile/Makefile.am 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/Makefile.am 2014-05-03 00:06:48 UTC (rev 894) @@ -18,7 +18,7 @@ # along with GetData; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -AUTOMAKE_OPTIONS = foreign dist-bzip2 check-news 1.10 +AUTOMAKE_OPTIONS = foreign dist-bzip2 check-news 1.11 ACLOCAL_AMFLAGS = -I m4 Modified: trunk/defile/bin/net.c =================================================================== --- trunk/defile/bin/net.c 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/bin/net.c 2014-05-03 00:06:48 UTC (rev 894) @@ -468,7 +468,7 @@ } break; case DF_RPC_ADD_ENTRY: - E.comp_scal = 1; + DF_SET_COMP_SCAL(E); switch (pos) { case 0: DF_GET_SDATUM(E.field); Modified: trunk/defile/bin/rc.c =================================================================== --- trunk/defile/bin/rc.c 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/bin/rc.c 2014-05-03 00:06:48 UTC (rev 894) @@ -360,8 +360,13 @@ if (rcd->name) df_iprintf(DF_PRN_CLEAR, DF_PRN_NOTE, "defile-%s input plugin v%s\n", rcd->name, rcd->version); - else + else { df_iprintf(DF_PRN_CLEAR, DF_PRN_NOTE, "%s\n", PACKAGE_STRING); +#ifdef GD_GETDATA_VERSION + df_iprintf(DF_PRN_CLEAR, DF_PRN_NOTE, "using GetData %s\n", + GD_GETDATA_VERSION); +#endif + } if (rcd->copyright) df_iprintf(DF_PRN_CLEAR, DF_PRN_NOTE, "%s\n\n", rcd->copyright); Modified: trunk/defile/doc/Makefile.am =================================================================== --- trunk/defile/doc/Makefile.am 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/Makefile.am 2014-05-03 00:06:48 UTC (rev 894) @@ -25,7 +25,7 @@ man1_MANS = defile-ascii.1 defile-dirfile.1 man7_MANS = defile-input.7 man3_MANS = df_add_alias.3 df_add_entry.3 df_add_fragment.3 df_add_framedef.3 \ - df_add_lut.3 df_check_abort.3 df_exit.3 df_field_in_input.3 \ + df_add_lut.3 df_check_abort.3 df_exit.3 df_field_in_output.3 \ df_hide.3 df_get_offset.3 df_include.3 df_init.3 df_input_name.3 \ df_mode.3 df_nframes_allowed.3 df_on_abort.3 df_push_frame.3 \ df_puts.3 df_ready.3 df_set_const.3 df_shell_expand.3 \ Modified: trunk/defile/doc/defile-ascii.1 =================================================================== --- trunk/defile/doc/defile-ascii.1 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/defile-ascii.1 2014-05-03 00:06:48 UTC (rev 894) @@ -112,7 +112,7 @@ .BR strtod (3)) separated by a semicolon .RI ( ; ), -with no intervening whitespace. This is the GetData convension; see +with no intervening whitespace. This is the Dirfile convension; see dirfile-format(5). The first floating-point number is the value of the real part of the complex number and the second is the value of the imaginary part. @@ -131,7 +131,7 @@ .BR \-\-const\-row and .BR \-\-string\-row , -which are treated in the order they are presented to defile-ascii. For each +which are handled in the order they are presented to defile-ascii. For each header line, including the field names, the line is parsed in the same manner as the rest of the data: either as fixed-width columns, or else with the same delimiters specified. By default, these header data may appear as comment lines Modified: trunk/defile/doc/defile-dirfile.1 =================================================================== --- trunk/defile/doc/defile-dirfile.1 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/defile-dirfile.1 2014-05-03 00:06:48 UTC (rev 894) @@ -119,7 +119,7 @@ in the subdirectory .I DIR under the output dirfile base directory, instead of the default "<ext>". The -directory specified must be relative. (Directive: +directory may not be an absolute path. (Directive: .BR ExtDir ) .TP .BR \-f ", " \-\-flatten @@ -164,7 +164,7 @@ in the subdirectory .I DIR under the output dirfile base directory, instead of the default "<lut>". The -directory specified must be relative. (Directive: +directory may not be an absolute path. (Directive: .BR LUTDir ) .TP .BR \-X ", " \-\-link\-extern\-frags Modified: trunk/defile/doc/defile-input.7 =================================================================== --- trunk/defile/doc/defile-input.7 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/defile-input.7 2014-05-03 00:06:48 UTC (rev 894) @@ -38,7 +38,7 @@ can be extended easily, without having to modify defile itself. Defile provides a C API for input plugins. Functions provided by the API are -described in individual manual pages in section 3 of the manual. A list of +described in individual manual pages in section 3 of this Manual. A list of these is given below in the .B API REFERENCE section. The API is defined in the C header file <defile.h>. This document @@ -48,14 +48,13 @@ .B DEFILE OPERATION below. -An input plugin is a dynamically-loaded shared library which asynchronously -reads data from a data source and passes it on to defile for output as a -dirfile. Each input plugin is identified by it's type name. The type name -identifies the type of data the input plugin is capable of reading. The type -name should consist of one or more lower case letters, numbers, or the -underscore (_) character. The type name must be unique among all defile input -plugins: defile will only ever consider the first input plugin with a given type -name that it finds. +An input plugin is a dynamically-loaded library which asynchronously reads data +from a data source and passes it on to defile for output as a dirfile. Each +input plugin is identified by it's type name. The type name identifies the type +of data the input plugin is capable of reading. The type name should consist of +one or more lower case letters, numbers, or the underscore (_) character. The +type name must be unique among all defile input plugins: defile will only ever +consider the first input plugin with a given type name that it finds. The name of the shared library must be of the form: .IP @@ -66,7 +65,7 @@ where .I anything is optional and may contain any valid filename characters (the host platform -may require a certain prefix for native dynamically loadable modules), +may require a certain prefix for native dynamically-loadable modules), .B defile- is literaly "defile" followed by a dash, .I type @@ -74,7 +73,7 @@ .I -anything contains more optional characters, separated from the type name by a dash, and .I .ext -is a file extension appropriate for native dynamically loadable modules on the +is a file extension appropriate for native dynamically-loadable modules on the host platform, if any. .PP The type name is also the value of the @@ -151,7 +150,7 @@ section below. .TP .I licence -indicates the licence type of the plugin. It affects what license boilerplate +indicates the licence type of the plugin. It affects which license boilerplate (if any) is printed along with version information. See the .B HELP AND VERSION OUTPUT section below for details. @@ -289,7 +288,7 @@ .TP .I argname the placeholder name of the argument used in usage output. For stylistic -consitency, it is recommended this consist of upper case letters only. If the +consitency, it is suggested this consist of upper case letters only. If the option is of type .BR DF_OPT_NO_ARG , this value is ignored and may be NULL. Otherwise, if this is NULL, a default @@ -300,7 +299,7 @@ usage output (see the .B HELP AND VERSION OUTPUT section below). It should contain no newlines; they will be inserted where -appropriate by defile. For stylistic consistency, it is recommended this begin +appropriate by defile. For stylistic consistency, it is suggested this begin with a lower case letter, and have independent clauses separated by semicolons. If this option record specifies neither .I sopt @@ -429,18 +428,18 @@ The input plugin's role in each state is discussed below. The input plugin's main loop may return at any time if it's job is complete, -or if it ran into an unrecoverable error. Returning a value of zero +or if it ran into an irrecoverable error. Returning a value of zero indicates to defile that the input plugin completed normally (success). Returning any other value indicates that the input plugin encountered an -unrecoverable error (failure). +irrecoverable error (failure). .SS START State Defile begins in the .B START -state. In this state, defile starts by processing the defile options. It -then determines the input plugin type to use, either as a result of an explicit -type specified by the user, or else by using automatic type detection on the +state. In this state, defile first processes the defile options. It then +determines the input plugin type to use, either as a result of an explicit type +specified by the user, or else by using automatic type detection on the specified input (see .B AUTOMATIC TYPE DETECTION for information on how to get an input plugin to participate in this). @@ -471,7 +470,9 @@ options and input directives. .TP .I value -an array of integers of length +an array of +.IR int s +of length .I n_config containing the values (see .B INPUT OPTIONS @@ -511,11 +512,9 @@ The input plugin is required to define at least one subframe (via the .BR df_add_framedef (3) call) which describes the raw data in the data objects which the input plugin -uses to communicate with defile. It may also add derived channels to the output -dirfile using +uses to communicate with defile. It may also add derived channels and other objects to the output dirfile using .BR df_add_entry (3) -and define the rest of the output dirfile metadata. -(See also the +(or similar) and define the rest of the output dirfile metadata. (See also the .B DEFILE DATA MODEL section below for an overview of how defile expects data to be marshalled.) This is also the earliest time at which the input plugin is able to determine @@ -589,13 +588,14 @@ Defile enters the .B ABORT -state in cases when an unrecoverable error occurs during operation, or else when +state in cases when an irrecoverable error occurs during operation, or else when it receives an asynchronous request to cancel (for example a keyboard interrupt). Most of the input plugin API functions check whether defile has entered this state and return .B DF_ABORT when detected (see -.BR "Standard API Return Semaphores" ). +.B Standard API Return Semaphores +below). The input should either monitor the return value of these functions to detect an unexpected transition into the .B ABORT @@ -694,7 +694,7 @@ The most common reason for this is the input plugin spending too long in the .B ABORT state, but it may happen in other exceptional circumstances. Input plugins which -disable cancelability for long periods of time may be subject to more drastic +disable cancellability for long periods of time may be subject to more drastic measures without forewarning. .SS Console I/O @@ -784,7 +784,7 @@ A careful trade-off must be made between false negatives (returning zero in cases where the input designator really does indicate something readable by the input plugin) and false positives (returning non-zero in cases where the input -designator does not, after all, indicate something readable by the plugin. +designator does not, after all, indicate something readable by the plugin). False negatives cause defile to be unable to automatically find a suitable input plugin; excessive false positives can lead to multiple input plugins claiming the input (resulting in neither being automatically given it). @@ -798,7 +798,7 @@ The following functions (some listed multiple times) are provided by the defile C API, grouped here by sequencing restrictions. See the indicated manual pages -for details. +for details on the functions themselves. .TP Functions which may be called at any time, regardless of current state: Modified: trunk/defile/doc/defile.1.in =================================================================== --- trunk/defile/doc/defile.1.in 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/defile.1.in 2014-05-03 00:06:48 UTC (rev 894) @@ -137,7 +137,7 @@ .BR +t ", " \-\-autotype ignore any previous input type specified. If no subsequent .B \-t -occurs, defile with attempt to automatically determine the input type. This +occurs, defile will attempt to automatically determine the input type. This is the default behaviour. Defile attempts to automatically determine the appropriate input plugin for the .I INPUT @@ -155,11 +155,11 @@ .SS Ouptut Location Options The path of the created dirfile is controlled by -.B \-\-dirfile +.B \-\-directory and .BR \-\-output , at least one of which must be given, unless running as a server. If -.B \-\-dirfile +.B \-\-directory is used without .BR \-\-output , the name of the output dirfile will depend on the @@ -424,8 +424,8 @@ .I HOST (with the username .IR USER , -if given) and transfer data from it using a remote defile. Change the (local) -program used to log into the remote host, see +if given) and transfer data from it using a remote defile. To change the +(local) program used to log into the remote host, see .BR \-\-rsh ; to change the program executed on the remote host, see .BR \-\-remote\-command . @@ -483,7 +483,7 @@ Use .I COMMAND as the remote shell used to log into the remote host. By default this is "ssh" (see -.BR ssh(1)), +.BR ssh (1)), and .I COMMAND must be "ssh compatible" in the sense that the second last argument passed to @@ -531,7 +531,7 @@ .BR \-\-append ", " \-\-directory ", " \-\-output ", and " \-\-async . Any output field list specified, as well as .BR \-\-clobber , -are ignored. (Directive: +are also ignored. (Directive: .BR Listen ) .TP .BR +L ", " \-\-no\-listen @@ -934,8 +934,7 @@ the default suite of defile input plugins. .SH ENVIRONMENT -Defile never modifies the environment, but may consider the following -environmental variables, if present: +Defile considers the following environmental variables, if present: .TP .B DEFILE_PLUGIN_PATH Modified: trunk/defile/doc/df_add_entry.3 =================================================================== --- trunk/defile/doc/df_add_entry.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_add_entry.3 2014-05-03 00:06:48 UTC (rev 894) @@ -73,7 +73,7 @@ If the field has been excluded from the output dirfile by the Output Field List (see .BR defile (1)), -these functions do nothing and succeeds. +these functions do nothing and succeed. .SH RETURN VALUE Upon success, .BR df_add_entry () Modified: trunk/defile/doc/df_add_fragment.3 =================================================================== --- trunk/defile/doc/df_add_fragment.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_add_fragment.3 2014-05-03 00:06:48 UTC (rev 894) @@ -44,8 +44,8 @@ may contain path elements relative to the base output dirfile directory. Subdirectories specified in .I name -will be created if they do not already exist. The new fragment will be included -in the fragment indexed by +will be created in the output dirfile if they do not already exist. The new +fragment will be included in the fragment indexed by .IR fragment , which should be zero (for the primary format file) or else a fragment index returned by a previous call to Modified: trunk/defile/doc/df_add_framedef.3 =================================================================== --- trunk/defile/doc/df_add_framedef.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_add_framedef.3 2014-05-03 00:06:48 UTC (rev 894) @@ -135,8 +135,8 @@ output in the order defined in the subframe definition, which may be different than their ordering within the subframe itself. .PP -Specifications for field which have not appeared in any previous subframe -definition will be added to the output fragment indexed by +Fields which have not appeared in any previous subframe definition will be +added to the output fragment indexed by .IR fragment , which should be either zero (for the primary fragment) or else a fragment index returned by @@ -147,8 +147,8 @@ subframe definition, and need not be the same as the fragment in which the field is actually defined. .PP -Fields which have been excluded from the output dirfile by the Output Field List -(see +Fields which have been excluded from the output dirfile by the user via the +Output Field List (see .BR defile (1)) are accepted in subframe definitions and simply ignored. .SH RETURN VALUE Modified: trunk/defile/doc/df_add_lut.3 =================================================================== --- trunk/defile/doc/df_add_lut.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_add_lut.3 2014-05-03 00:06:48 UTC (rev 894) @@ -88,6 +88,7 @@ or .I y_type was invalid. +.TP .B DF_OUTPUT An error occured attempting to create the LUT. See .BR mkdir (2), Deleted: trunk/defile/doc/df_field_in_input.3 =================================================================== --- trunk/defile/doc/df_field_in_input.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_field_in_input.3 2014-05-03 00:06:48 UTC (rev 894) @@ -1,63 +0,0 @@ -.\" df_field_in_output.3. The df_field_in_output man page. -.\" -.\" Copyright (C) 2012 D. V. Wiebe -.\" -.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.\" -.\" This file is part of the Defile package. -.\" -.\" Permission is granted to copy, distribute and/or modify this document -.\" under the terms of the GNU Free Documentation License, Version 1.2 or -.\" any later version published by the Free Software Foundation; with no -.\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover -.\" Texts. A copy of the license is included in the `COPYING.DOC' file -.\" as part of this distribution. -.\" -.TH df_field_in_output 3 "27 February 2012" "Version 0.0.1" DEFILE -.SH NAME -df_field_in_output \(em check whether defile is writing a field to its output -.SH SYNOPSIS -.nh -.ad l -.fam C -.B #include <defile.h> -.HP -.BI "int df_field_in_output(const char *" name ); -.fam -.ad -.hy -.SH DESCRIPTION -This function is part of the defile input plugin C API. See -.BR defile-input (7) -for an overview. -.PP -The -.BR df_field_in_output () -function consults defile's Output Field List (see -.BR defile (1)), -and returns non-zero if the field specified by -.I name -would be writen to the output dirfile were it to be defined at some point by -the input plugin. If the field has been excluded from the output dirfile, this -function will return zero. Note: this function only checks for the potential -for exclusion or inclusion: the returned value is not affected by whether a -field called -.I name -actually has been (or will be) defined. -.PP -It is not required that an input plugin self-exclude fields not in the output -dirfile by checking this function. Both included and excluded fields may -be defined by the input plugin. Excluded fields will be silently ignored. This -function is provided for use in rare cases where knowing a field is to be -excluded may speed or simplify the input plugin's operation. -.SH RETURN VALUE -The -.BR df_field_in_output () -function returns non-zero if a field called -.I name -would be included in the output dirfile if provided. It returns zero if a field -with such a name would be excluded from the output. -.SH SEE ALSO -.BR defile-input (7), -.BR defile (1), -.BR df_add_framedef (3). Copied: trunk/defile/doc/df_field_in_output.3 (from rev 875, trunk/defile/doc/df_field_in_input.3) =================================================================== --- trunk/defile/doc/df_field_in_output.3 (rev 0) +++ trunk/defile/doc/df_field_in_output.3 2014-05-03 00:06:48 UTC (rev 894) @@ -0,0 +1,63 @@ +.\" df_field_in_output.3. The df_field_in_output man page. +.\" +.\" Copyright (C) 2012 D. V. Wiebe +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.\" This file is part of the Defile package. +.\" +.\" Permission is granted to copy, distribute and/or modify this document +.\" under the terms of the GNU Free Documentation License, Version 1.2 or +.\" any later version published by the Free Software Foundation; with no +.\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +.\" Texts. A copy of the license is included in the `COPYING.DOC' file +.\" as part of this distribution. +.\" +.TH df_field_in_output 3 "27 February 2012" "Version 0.0.1" DEFILE +.SH NAME +df_field_in_output \(em check whether defile is writing a field to its output +.SH SYNOPSIS +.nh +.ad l +.fam C +.B #include <defile.h> +.HP +.BI "int df_field_in_output(const char *" name ); +.fam +.ad +.hy +.SH DESCRIPTION +This function is part of the defile input plugin C API. See +.BR defile-input (7) +for an overview. +.PP +The +.BR df_field_in_output () +function consults the Output Field List (see +.BR defile (1)) +specified by the user, and returns non-zero if the field specified by +.I name +would be writen to the output dirfile were it to be defined at some point by +the input plugin. If the field has been excluded from the output dirfile, this +function returns zero. Note: this function only checks for the potential for +exclusion or inclusion: the returned value is not affected by whether a field +called +.I name +actually has been (or will be) defined. +.PP +It is not required that an input plugin self-exclude fields not in the output +dirfile by checking this function. Both included and excluded fields may +be defined by the input plugin. Excluded fields will be silently dropped by +defile. This function is provided for use in rare cases where knowing a field +is to be excluded may speed up or simplify the input plugin's operation. +.SH RETURN VALUE +The +.BR df_field_in_output () +function returns non-zero if a field called +.I name +would be included in the output dirfile, if provided. It returns zero if a +field with such a name would be excluded from the output. +.SH SEE ALSO +.BR defile-input (7), +.BR defile (1), +.BR df_add_framedef (3). Modified: trunk/defile/doc/df_init.3 =================================================================== --- trunk/defile/doc/df_init.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_init.3 2014-05-03 00:06:48 UTC (rev 894) @@ -57,7 +57,7 @@ .BR df_update_length (3). .TP .I rate -the expected frame rate for live data in follow mode (see +the expected frame rate (in frames per second) for live data in follow mode (see .BR defile-input (7)). If unknown or difficult to calculate, this may be -1. This value is used to prime the IIR filter in the rate calculator in the running information provided @@ -120,7 +120,7 @@ case, if the input plugin is able, it may try calling the function again, potentially with a different .I name -argument. In case of an irrecoverable error, a subsequent call will result in +argument. In case of an irrecoverable error, a subsequent call will return .BR DF_ABORT . .IP This will @@ -128,8 +128,8 @@ be returned by .BR df_reinit () in cases where the user has specified an explicit output dirfile name -(--output) but not allowed overwriting of the output (--clobber), since in this -case, both the new and old dirfiles have the same user-specified name (ie. +(--output) but not allowed overwriting of the output (--no-clobber), since in +this case, both the new and old dirfiles have the same, user-specified name (ie. .I name is ignored), and defile will refuse to truncate the dirfile it just created. Conversely, if the user has specified both --output and --clobber, calling Modified: trunk/defile/doc/df_push_frame.3 =================================================================== --- trunk/defile/doc/df_push_frame.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_push_frame.3 2014-05-03 00:06:48 UTC (rev 894) @@ -36,7 +36,7 @@ .BR df_push_frame () function attempts to place .I nframes -frames of data into the +subframes of data into the .BR defile (1) buffer for conversion to the output dirfile. The .I data @@ -48,11 +48,11 @@ .BR gd_add_framedef (3) when the corresponding subframe was defined. .PP -If +The .I block -is one, -this call will block until all data has been transferred. Otherwise, depending -on how full defile's buffer is, fewer than +parameter should be zero or one. If it is one, this call will block until all +data has been transferred. Otherwise, depending on how full defile's buffer is, +fewer than .I nframes frames of data may actually be buffered. In synchronous mode, care should be taken with blocking calls to this function to avoid deadlocks. See Modified: trunk/defile/doc/df_ready.3 =================================================================== --- trunk/defile/doc/df_ready.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_ready.3 2014-05-03 00:06:48 UTC (rev 894) @@ -39,8 +39,8 @@ dirfile and is ready to start providing data for conversion. (That is, it signals a transition from the BUILD state into the RUN state; see .BR defile-input (7).) -If the input plugin wishes to set a reference field, it may do so now by passing -the field's name as +If the input plugin wishes to set a reference field, it should do so now by +passing the field's name as .IR reference . If this is NULL, defile will choose a reference field for the output dirfile. .PP @@ -67,7 +67,8 @@ .B DF_INPUT The field specified as .I reference -doesn't appear in any of the previously defined subframe definitions. +doesn't appear as a raw field in any of the previously defined subframe +definitions. .TP .B DF_SEQUENCE The function was called while defile was not in the Modified: trunk/defile/doc/df_shell_expand.3 =================================================================== --- trunk/defile/doc/df_shell_expand.3 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/doc/df_shell_expand.3 2014-05-03 00:06:48 UTC (rev 894) @@ -35,8 +35,8 @@ .BR df_shell_expand () function returns the result of performing shell-like word expansion on the input .IR string . -The result is returned in as a new string, which is allocated by -.BR malloc (3), +The result is returned in a new string allocated by +.BR malloc (3) and must be freed by the caller when no longer needed. For details of shell-like word expansion, see .BR wordexp (3). Modified: trunk/defile/lib/internal.h =================================================================== --- trunk/defile/lib/internal.h 2014-05-01 04:07:20 UTC (rev 893) +++ trunk/defile/lib/internal.h 2014-05-03 00:06:48 UTC (rev 894) @@ -181,6 +181,17 @@ #define DF_OOM(fac) \ df_iprintf(fac, DF_PRN_ERR, "out of memory at [%s,%i]", __FILE__, __LINE__) +/* GetData version abstraction */ +#ifndef GD_GETDATA_INT_VERSION +#define GD_GETDATA_INT_VERSION 804 /* Minimum supported version */ +#endif + +#if GD_GETDATA_INT_VERSION < 900 +#define DF_SET_COMP_SCAL(E) (E).comp_scal = 1 +#else +#define DF_SET_COMP_SCAL(E) (E).flags |= GD_EN_COMPSCAL +#endif + /* NList */ struct df_subset_ { int n; /* # of elements */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-01 04:07:23
|
Revision: 893 http://sourceforge.net/p/getdata/code/893 Author: ketiltrout Date: 2014-05-01 04:07:20 +0000 (Thu, 01 May 2014) Log Message: ----------- PHP 5.3. Modified Paths: -------------- trunk/getdata/bindings/php/getdata.c Modified: trunk/getdata/bindings/php/getdata.c =================================================================== --- trunk/getdata/bindings/php/getdata.c 2014-04-30 21:52:55 UTC (rev 892) +++ trunk/getdata/bindings/php/getdata.c 2014-05-01 04:07:20 UTC (rev 893) @@ -1887,7 +1887,7 @@ dtracephp(); - GDPHP_PARSED("ssp|l", &field_code, &field_code_len, &in_field, &in_field_len, + GDPHP_PARSED("sss|l", &field_code, &field_code_len, &in_field, &in_field_len, &table, &table_len, &index); GDPHP_RETURN_BOOL(gd_add_linterp(D, field_code, in_field, table, index)); @@ -1977,7 +1977,7 @@ dtracephp(); - GDPHP_PARSED("pll|l", &field_code, &field_code_len, &data_type, &spf, + GDPHP_PARSED("sll|l", &field_code, &field_code_len, &data_type, &spf, &index); GDPHP_RETURN_BOOL(gd_add_raw(D, field_code, data_type, spf, index)); @@ -3338,7 +3338,7 @@ GDPHP_CHECK_ERROR(D); gdphp_from_data(return_value, n, data_type, data, 0, unpack); - dreturn("%i", n); + dreturn("%" PRNsize_t, n); } PHP_FUNCTION(gd_hidden) @@ -3387,7 +3387,7 @@ dtracephp(); - GDPHP_PARSED("pl|lss", &path, &path_len, &parent, &flags, &prefix, + GDPHP_PARSED("sl|lss", &path, &path_len, &parent, &flags, &prefix, &prefix_len, &suffix, &suffix_len); i = gd_include_affix(D, path, parent, prefix, suffix, flags); @@ -3597,7 +3597,7 @@ dtracephp(); - GDPHP_PARSED("sssp", &parent, &parent_len, &field_code, &field_code_len, + GDPHP_PARSED("ssss", &parent, &parent_len, &field_code, &field_code_len, &in_field, &in_field_len, &table, &table_len); GDPHP_RETURN_BOOL(gd_madd_linterp(D, parent, field_code, in_field, table)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-30 21:53:03
|
Revision: 892 http://sourceforge.net/p/getdata/code/892 Author: ketiltrout Date: 2014-04-30 21:52:55 +0000 (Wed, 30 Apr 2014) Log Message: ----------- svn:ignore Property Changed: ---------------- trunk/getdata/test/ Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-04-30 21:51:58 UTC (rev 891) +++ trunk/getdata/test 2014-04-30 21:52:55 UTC (rev 892) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -448,6 +448,7 ## get_complex128 get_complex64 get_const +get_const_carray get_const_complex get_const_repr get_cpolynom This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-30 21:52:03
|
Revision: 891 http://sourceforge.net/p/getdata/code/891 Author: ketiltrout Date: 2014-04-30 21:51:58 +0000 (Wed, 30 Apr 2014) Log Message: ----------- Fix gd_get_const and gd_get_string. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/Makefile.am trunk/getdata/src/constant.c trunk/getdata/src/string.c trunk/getdata/test/Makefile.am Added Paths: ----------- trunk/getdata/test/get_const_carray.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-04-30 21:48:53 UTC (rev 890) +++ trunk/getdata/ChangeLog 2014-04-30 21:51:58 UTC (rev 891) @@ -1,3 +1,11 @@ +2014-04-30 D. V. Wiebe <ge...@ke...> svn:890 svn:891 + * bindings/cxx/test/big_test.cpp bindings/f77/test/big_test.f + bindings/f77/test/big_test95.f90 bindings/idl/test/big_test.pro + bindings/python/test/big_test.py: Fix test 157 for DSV 10. + * src/constant.c (gd_get_constant) src/string.c (gd_get_string): Fix call in + the case of using a [CS]ARRAY after breaking it. + * test/get_const_carray.c: Added. + 2014-04-30 D. V. Wiebe <ge...@ke...> svn:889 * test/parse_indir.c test/get_sindir.c test/alter_entry_sarray.c test/add_sindir.c test/getstr_sindir.c test/name_updb_sarray.c Modified: trunk/getdata/Makefile.am =================================================================== --- trunk/getdata/Makefile.am 2014-04-30 21:48:53 UTC (rev 890) +++ trunk/getdata/Makefile.am 2014-04-30 21:51:58 UTC (rev 891) @@ -18,7 +18,7 @@ # along with GetData; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -AUTOMAKE_OPTIONS = foreign dist-xz check-news 1.10 +AUTOMAKE_OPTIONS = foreign dist-xz check-news 1.11 EXTRA_DIST = ChangeLog Modified: trunk/getdata/src/constant.c =================================================================== --- trunk/getdata/src/constant.c 2014-04-30 21:48:53 UTC (rev 890) +++ trunk/getdata/src/constant.c 2014-04-30 21:51:58 UTC (rev 891) @@ -118,7 +118,7 @@ int gd_get_constant(DIRFILE* D, const char *field_code_in, gd_type_t return_type, void *data_out) gd_nothrow { - return gd_get_carray(D, field_code_in, return_type, data_out); + return gd_get_carray_slice(D, field_code_in, 0, 1, return_type, data_out); } size_t gd_carray_len(DIRFILE *D, const char *field_code_in) gd_nothrow Modified: trunk/getdata/src/string.c =================================================================== --- trunk/getdata/src/string.c 2014-04-30 21:48:53 UTC (rev 890) +++ trunk/getdata/src/string.c 2014-04-30 21:51:58 UTC (rev 891) @@ -121,7 +121,7 @@ dtrace("%p, \"%s\", %" PRNsize_t ", %p", D, field_code, len, data_out); /* get string */ - if (gd_get_sarray(D, field_code, &ptr)) { + if (gd_get_sarray_slice(D, field_code, 0, 1, &ptr)) { dreturn("%i", 0); return 0; } Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-04-30 21:48:53 UTC (rev 890) +++ trunk/getdata/test/Makefile.am 2014-04-30 21:51:58 UTC (rev 891) @@ -180,11 +180,11 @@ GET_TESTS=get64 get_affix get_bad_code get_bit get_carray get_carray_len \ 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_dim get_divide \ - get_divide_ccin get_divide_crin get_divide_crinr get_divide_rcin \ - get_divide_s get_endian8 get_endian16 get_endian32 get_endian64 \ - get_endian_complex128_arm get_endian_complex128_big \ + get_complex64 get_const get_const_carray get_const_complex \ + get_const_repr get_cpolynom get_cpolynom1 get_cpolynom_int get_dim \ + get_divide get_divide_ccin get_divide_crin get_divide_crinr \ + get_divide_rcin get_divide_s get_endian8 get_endian16 get_endian32 \ + get_endian64 get_endian_complex128_arm get_endian_complex128_big \ get_endian_complex128_little get_endian_complex64_arm \ get_endian_complex64_big get_endian_complex64_little \ get_endian_float32_arm get_endian_float32_big \ Added: trunk/getdata/test/get_const_carray.c =================================================================== --- trunk/getdata/test/get_const_carray.c (rev 0) +++ trunk/getdata/test/get_const_carray.c 2014-04-30 21:51:58 UTC (rev 891) @@ -0,0 +1,57 @@ +/* Copyright (C) 2014 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 <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +int main(void) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *format_data = "carray CARRAY FLOAT64 8.3 7.2 6.1 5.0 3.9 2.8 1.7\n"; + double c; + 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_constant(D, "carray", GD_FLOAT64, &c); + error = gd_error(D); + + CHECKI(error, 0); + CHECKI(n, 0); + CHECKF(c, 8.3); + + gd_discard(D); + + unlink(format); + rmdir(filedir); + + return r; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-30 21:48:59
|
Revision: 890 http://sourceforge.net/p/getdata/code/890 Author: ketiltrout Date: 2014-04-30 21:48:53 +0000 (Wed, 30 Apr 2014) Log Message: ----------- Fix binding tests for DSV 10. Fix gd_get_const and gd_get_string. Modified Paths: -------------- trunk/getdata/bindings/Makefile.am trunk/getdata/bindings/cxx/test/big_test.cpp trunk/getdata/bindings/f77/test/big_test.f trunk/getdata/bindings/f77/test/big_test95.f90 trunk/getdata/bindings/idl/getdata.c trunk/getdata/bindings/idl/test/big_test.pro trunk/getdata/bindings/python/test/big_test.py Modified: trunk/getdata/bindings/Makefile.am =================================================================== --- trunk/getdata/bindings/Makefile.am 2014-04-30 18:10:25 UTC (rev 889) +++ trunk/getdata/bindings/Makefile.am 2014-04-30 21:48:53 UTC (rev 890) @@ -55,8 +55,8 @@ make_parameters_SOURCES = make_parameters.c nodist_make_parameters_SOURCES = ../src/getdata.h ../src/gd_config.h -SUBDIRS = . ${F77_SUBDIR} ${CXX_SUBDIR} ${IDL_SUBDIR} ${MATLAB_SUBDIR} \ - ${PY_SUBDIR} ${PERL_SUBDIR} ${PHP_SUBDIR} +SUBDIRS = . ${F77_SUBDIR} ${CXX_SUBDIR} ${IDL_SUBDIR} ${PY_SUBDIR} \ + ${PERL_SUBDIR} ${MATLAB_SUBDIR} ${PHP_SUBDIR} make_parameters$(EXEEXT): $(make_parameters_SOURCES) \ $(nodist_make_parameters_SOURCES) Modified: trunk/getdata/bindings/cxx/test/big_test.cpp =================================================================== --- trunk/getdata/bindings/cxx/test/big_test.cpp 2014-04-30 18:10:25 UTC (rev 889) +++ trunk/getdata/bindings/cxx/test/big_test.cpp 2014-04-30 21:48:53 UTC (rev 890) @@ -1270,7 +1270,7 @@ // 157: Dirfile::Standards check n = d->Standards(); CHECK_OK2(157,1); - CHECK_INT(157,n,9); + CHECK_INT(157,n,GD_DIRFILE_STANDARDS_VERSION); d->Standards(0); CHECK_ERROR2(157,2,GD_E_ARGUMENT); Modified: trunk/getdata/bindings/f77/test/big_test.f =================================================================== --- trunk/getdata/bindings/f77/test/big_test.f 2014-04-30 18:10:25 UTC (rev 889) +++ trunk/getdata/bindings/f77/test/big_test.f 2014-04-30 21:48:53 UTC (rev 890) @@ -1638,7 +1638,7 @@ n = GDSV_C CALL GDSTDV(n, d) CALL CHKOK2(ne, 157, 1, d) - CALL CHKINT(ne, 157, n, 9) + CALL CHKINT(ne, 157, n, GD_DSV) n = 0 CALL GDSTDV(n, d) Modified: trunk/getdata/bindings/f77/test/big_test95.f90 =================================================================== --- trunk/getdata/bindings/f77/test/big_test95.f90 2014-04-30 18:10:25 UTC (rev 889) +++ trunk/getdata/bindings/f77/test/big_test95.f90 2014-04-30 21:48:53 UTC (rev 890) @@ -1749,7 +1749,7 @@ ! 157: fgd_dirfile_standards n = fgd_dirfile_standards(d, GD_VERSION_CURRENT) call check_ok2(ne, 157, 1, d) - call check_int(ne, 157, n, 9) + call check_int(ne, 157, n, GD_DIRFILE_STANDARDS_VERSION) n = fgd_dirfile_standards(d, 0) call check_err2(ne, 157, 2, d, GD_E_ARGUMENT) Modified: trunk/getdata/bindings/idl/getdata.c =================================================================== --- trunk/getdata/bindings/idl/getdata.c 2014-04-30 18:10:25 UTC (rev 889) +++ trunk/getdata/bindings/idl/getdata.c 2014-04-30 21:48:53 UTC (rev 890) @@ -173,38 +173,54 @@ } /* convert a GetData type code to an IDL type code */ -gd_static_inline_ UCHAR gdidl_idl_type(gd_type_t t) { +gd_static_inline_ UCHAR gdidl_idl_type(gd_type_t t) +{ + UCHAR it; + dtrace("0x%X", t); + switch (t) { case GD_UINT8: - return IDL_TYP_BYTE; + it = IDL_TYP_BYTE; + break; case GD_UINT16: - return IDL_TYP_UINT; + it = IDL_TYP_UINT; + break; case GD_INT8: /* there is no signed 8-bit type in IDL - we type promote to INT */ case GD_INT16: - return IDL_TYP_INT; + it = IDL_TYP_INT; + break; case GD_UINT32: - return IDL_TYP_ULONG; + it = IDL_TYP_ULONG; + break; case GD_INT32: - return IDL_TYP_LONG; + it = IDL_TYP_LONG; + break; case GD_UINT64: - return IDL_TYP_ULONG64; + it = IDL_TYP_ULONG64; + break; case GD_INT64: - return IDL_TYP_LONG64; + it = IDL_TYP_LONG64; + break; case GD_FLOAT32: - return IDL_TYP_FLOAT; + it = IDL_TYP_FLOAT; + break; case GD_FLOAT64: - return IDL_TYP_DOUBLE; + it = IDL_TYP_DOUBLE; + break; case GD_COMPLEX64: - return IDL_TYP_COMPLEX; + it = IDL_TYP_COMPLEX; + break; case GD_COMPLEX128: - return IDL_TYP_DCOMPLEX; + it = IDL_TYP_DCOMPLEX; + break; case GD_NULL: case GD_UNKNOWN: - ; + it = IDL_TYP_UNDEF; } - return IDL_TYP_UNDEF; + dreturn("%u", it); + return it; } /* convert an IDL type code to a GetData type code */ Modified: trunk/getdata/bindings/idl/test/big_test.pro =================================================================== --- trunk/getdata/bindings/idl/test/big_test.pro 2014-04-30 18:10:25 UTC (rev 889) +++ trunk/getdata/bindings/idl/test/big_test.pro 2014-04-30 21:48:53 UTC (rev 890) @@ -1024,7 +1024,7 @@ ; 157: gd_dirfile_standards n = gd_dirfile_standards(d, /CURRENT) nume += check_ok2(157, 1, d) -nume += check_simple(157, n, 9) +nume += check_simple(157, n, !GD.DIRFILE_STANDARDS_VERSION) n = gd_dirfile_standards(d, 0) nume += check_error2(157, 2, d, !GD.E_ARGUMENT) Modified: trunk/getdata/bindings/python/test/big_test.py =================================================================== --- trunk/getdata/bindings/python/test/big_test.py 2014-04-30 18:10:25 UTC (rev 889) +++ trunk/getdata/bindings/python/test/big_test.py 2014-04-30 21:48:53 UTC (rev 890) @@ -1321,7 +1321,7 @@ n = d.standards except: CheckOK2(157,1) -CheckSimple(157,n,9) +CheckSimple(157,n,pygetdata.DIRFILE_STANDARDS_VERSION) try: d.standards = 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-30 18:10:30
|
Revision: 889 http://sourceforge.net/p/getdata/code/889 Author: ketiltrout Date: 2014-04-30 18:10:25 +0000 (Wed, 30 Apr 2014) Log Message: ----------- Bump DSV. INDIR and SINDIR. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/src/add.c trunk/getdata/src/common.c trunk/getdata/src/del.c trunk/getdata/src/entry.c trunk/getdata/src/errors.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/fpos.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/internal.h trunk/getdata/src/legacy.c trunk/getdata/src/mod.c trunk/getdata/src/name.c trunk/getdata/src/native.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/src/spf.c trunk/getdata/src/string.c trunk/getdata/test/Makefile.am trunk/getdata/test/name_updb.c trunk/getdata/test/native_const.c trunk/getdata/test/version_9_strict.c trunk/getdata/test/version_9_write.c Added Paths: ----------- trunk/getdata/test/add_indir.c trunk/getdata/test/add_sarray_nil.c trunk/getdata/test/add_sindir.c trunk/getdata/test/alter_entry_sarray.c trunk/getdata/test/alter_indir.c trunk/getdata/test/alter_sindir.c trunk/getdata/test/get_indir.c trunk/getdata/test/get_sindir.c trunk/getdata/test/getstr_here.c trunk/getdata/test/getstr_sindir.c trunk/getdata/test/getstr_type.c trunk/getdata/test/madd_indir.c trunk/getdata/test/madd_sindir.c trunk/getdata/test/name_updb_carray.c trunk/getdata/test/name_updb_sarray.c trunk/getdata/test/parse_indir.c trunk/getdata/test/parse_sindir.c trunk/getdata/test/put_indir.c trunk/getdata/test/put_sindir.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/ChangeLog 2014-04-30 18:10:25 UTC (rev 889) @@ -1,5 +1,46 @@ -2014-04-03 D. V. Wiebe <ge...@ke...> svn:887 +2014-04-30 D. V. Wiebe <ge...@ke...> svn:889 + * test/parse_indir.c test/get_sindir.c test/alter_entry_sarray.c + test/add_sindir.c test/getstr_sindir.c test/name_updb_sarray.c + test/add_indir.c test/get_indir.c test/getstr_here.c test/alter_sindir.c + test/parse_sindir.c test/alter_indir.c test/getstr_type.c + test/name_updb_carray.c test/madd_sindir.c test/put_indir.c + test/put_sindir.c test/madd_indir.c test/add_sarray_nil.c: Added. + * test/name_updb.c test/native_const.c: Update. + * src/entry.c (_GD_FreeE _GD_CalculateEntry gd_entry gd_validate) + src/legacy.c (GetFormat) src/getdata.c (_GD_DoField gd_getdata64) src/name.c + (_GD_UpdateInputs) src/flush.c (_GD_Flush _GD_FieldSpec _GD_FindVersion) + src/native.c (_GD_NativeType) src/spf.c (_GD_GetSPF) src/putdata.c + (_GD_DoFieldOut) src/del.c (_GD_ClearDerived _GD_DeReference _GD_Delete) + src/flimits.c (_GD_GetEOF _GD_GetBOF) src/fpos.c (_GD_GetFilePos _GD_Seek) + src/parse.c (_GD_ParseFieldSpec) src/mod.c (_GD_Change) src/add.c + (_GD_InvalidEntype _GD_Add): Handle INDIR and SINDIR. + * src/getdata.c (_GD_IndirData _GD_DoIndir gd_getstrdata64 gd_getdata64) + src/parse.c (_GD_ParseYoke) src/mod.c (_GD_AlterYoke gd_alter_indir + gd_alter_sindir) src/add.c (_GD_AddYoke gd_add_indir gd_add_sindir + _GD_MAddYoke gd_madd_indir gd_madd_sindir): Added. + * src/common.c (_GD_BadInput): Add entry type parameter and allow non-vector + input fields. + + * src/parse.c (_GD_ParseDivide _GD_ParseMultiply): Deleted (merged into + _GD_ParseYoke). + * src/mod.c (gd_alter_divide gd_alter_multiply): Call _GD_AlterYoke. + * src/add.c (gd_add_multiply gd_add_divide): Call _GD_AddYoke. + * src/add.c (gd_madd_multiply gd_madd_divide): Call _GD_MAddYoke. + + * src/errors.c: Add GD_E_FIELD_FORMAT and GD_E_FIELD_STR. + + * src/native.c (_GD_NativeType): Return internal type for CONST/CARRAY not + storage type (ie. run it through _GD_ConstType). + + * src/string.c (gd_get_sarray_slice gd_get_sarray) src/mod.c (_GD_Change) + src/add.c (_GD_Add): Nilify new SARRAYs on creation, not on read. + + * src/getdata.h.in: Bump GD_DIRFILE_STANDARDS_VERSION. Add GD_INDIR_ENTRY + and GD_SINDIR_ENTRY. + +2014-04-27 D. V. Wiebe <ge...@ke...> svn:887 + * src/entry.c (_GD_FreeE _GD_CalculateEntry gd_entry gd_validate) src/legacy.c (GetFormat) src/getdata.c (_GD_DoField) src/name.c (_GD_UpdateInputs) src/flush.c (_GD_Flush _GD_FieldSpec _GD_FindVersion) src/native.c (_GD_NativeType) src/spf.c (_GD_GetSPF) src/putdata.c Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/add.c 2014-04-30 18:10:25 UTC (rev 889) @@ -28,7 +28,7 @@ t != GD_CONST_ENTRY && t != GD_POLYNOM_ENTRY && t != GD_SBIT_ENTRY && t != GD_DIVIDE_ENTRY && t != GD_RECIP_ENTRY && t != GD_WINDOW_ENTRY && t != GD_MPLEX_ENTRY && t != GD_CARRAY_ENTRY && t != GD_STRING_ENTRY && - t != GD_SARRAY_ENTRY) + t != GD_SARRAY_ENTRY && t != GD_INDIR_ENTRY && t != GD_SINDIR_ENTRY) { dreturn("%i", -1); return -1; @@ -131,6 +131,7 @@ int i, is_dot, offset; void *new_list; void *new_ref = NULL; + size_t z; unsigned int u; unsigned mask; gd_entry_t *E; @@ -364,6 +365,8 @@ break; case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], entry->fragment_index, 1) || _GD_CheckCodeAffixes(D, NULL, entry->in_fields[1], entry->fragment_index, 1)) @@ -509,17 +512,13 @@ } break; case GD_SARRAY_ENTRY: - E->EN(scalar,const_type) = GD_NULL; E->EN(scalar,array_len) = entry->EN(scalar,array_len); - if (E->EN(scalar,array_len) > GD_MAX_CARRAY_LENGTH) - _GD_SetError(D, GD_E_BOUNDS, 0, NULL, 0, NULL); - else { - size_t size = sizeof(const char *) * E->EN(scalar,array_len); - E->e->u.scalar.d = _GD_Malloc(D, size); - if (E->e->u.scalar.d) - memset(E->e->u.scalar.d, 0, size); - } + E->e->u.scalar.d = _GD_Malloc(D, + sizeof(const char *) * E->EN(scalar,array_len)); + if (E->e->u.scalar.d) + for (z = 0; z < E->EN(scalar,array_len); ++z) + ((const char**)E->e->u.scalar.d)[z] = _GD_Strdup(D, ""); break; case GD_STRING_ENTRY: E->e->u.string = _GD_Strdup(D, ""); @@ -1008,15 +1007,14 @@ return error; } -/* add a MULTIPLY entry */ -int gd_add_multiply(DIRFILE* D, const char* field_code, const char* in_field1, - const char* in_field2, int fragment_index) gd_nothrow +static int _GD_AddYoke(DIRFILE* D, gd_entype_t t, const char* field_code, + const char* in_field1, const char* in_field2, int fragment_index) gd_nothrow { gd_entry_t M; int error; - dtrace("%p, \"%s\", \"%s\", \"%s\", %i", D, field_code, in_field1, in_field2, - fragment_index); + dtrace("%p, 0x%X, \"%s\", \"%s\", \"%s\", %i", D, t, field_code, in_field1, + in_field2, fragment_index); if (D->flags & GD_INVALID) {/* don't crash */ _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -1026,7 +1024,7 @@ memset(&M, 0, sizeof(gd_entry_t)); M.field = (char *)field_code; - M.field_type = GD_MULTIPLY_ENTRY; + M.field_type = t; M.in_fields[0] = (char *)in_field1; M.in_fields[1] = (char *)in_field2; M.fragment_index = fragment_index; @@ -1036,32 +1034,32 @@ return error; } -/* add a DIVIDE entry */ +int gd_add_multiply(DIRFILE* D, const char* field_code, const char* in_field1, + const char* in_field2, int fragment_index) gd_nothrow +{ + return _GD_AddYoke(D, GD_MULTIPLY_ENTRY, field_code, in_field1, in_field2, + fragment_index); +} + int gd_add_divide(DIRFILE* D, const char* field_code, const char* in_field1, const char* in_field2, int fragment_index) gd_nothrow { - gd_entry_t E; - int error; + return _GD_AddYoke(D, GD_DIVIDE_ENTRY, field_code, in_field1, in_field2, + fragment_index); +} - dtrace("%p, \"%s\", \"%s\", \"%s\", %i", D, field_code, in_field1, in_field2, +int gd_add_indir(DIRFILE* D, const char* field_code, const char* in_field1, + const char* in_field2, int fragment_index) gd_nothrow +{ + return _GD_AddYoke(D, GD_INDIR_ENTRY, field_code, in_field1, in_field2, fragment_index); +} - if (D->flags & GD_INVALID) {/* don't crash */ - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } - - memset(&E, 0, sizeof(gd_entry_t)); - E.field = (char *)field_code; - E.field_type = GD_DIVIDE_ENTRY; - E.in_fields[0] = (char *)in_field1; - E.in_fields[1] = (char *)in_field2; - E.fragment_index = fragment_index; - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; - - dreturn("%i", error); - return error; +int gd_add_sindir(DIRFILE* D, const char* field_code, const char* in_field1, + const char* in_field2, int fragment_index) gd_nothrow +{ + return _GD_AddYoke(D, GD_SINDIR_ENTRY, field_code, in_field1, in_field2, + fragment_index); } /* add a RECIP entry */ @@ -1660,14 +1658,14 @@ return error; } -/* add a META MULTIPLY entry */ -int gd_madd_multiply(DIRFILE* D, const char* parent, const char* field_code, - const char* in_field1, const char* in_field2) gd_nothrow +static int _GD_MAddYoke(DIRFILE* D, gd_entype_t t, const char* parent, + const char* field_code, const char* in_field1, const char* in_field2) +gd_nothrow { gd_entry_t M; int error; - dtrace("%p, \"%s\", \"%s\", \"%s\", \"%s\"", D, field_code, parent, + dtrace("%p, 0x%X, \"%s\", \"%s\", \"%s\", \"%s\"", D, t, field_code, parent, in_field1, in_field2); if (D->flags & GD_INVALID) {/* don't crash */ @@ -1678,7 +1676,7 @@ memset(&M, 0, sizeof(gd_entry_t)); M.field = (char *)field_code; - M.field_type = GD_MULTIPLY_ENTRY; + M.field_type = t; M.in_fields[0] = (char *)in_field1; M.in_fields[1] = (char *)in_field2; M.fragment_index = 0; @@ -1688,6 +1686,13 @@ return error; } +int gd_madd_multiply(DIRFILE* D, const char *parent, const char* field_code, + const char* in_field1, const char* in_field2) gd_nothrow +{ + return _GD_MAddYoke(D, GD_MULTIPLY_ENTRY, parent, field_code, in_field1, + in_field2); +} + /* add a META PHASE entry */ int gd_madd_phase(DIRFILE* D, const char* parent, const char* field_code, const char* in_field, gd_shift_t shift) gd_nothrow @@ -1798,31 +1803,25 @@ return error; } -/* add a META DIVIDE entry */ int gd_madd_divide(DIRFILE* D, const char *parent, const char* field_code, const char* in_field1, const char* in_field2) gd_nothrow { - int error; - gd_entry_t E; + return _GD_MAddYoke(D, GD_DIVIDE_ENTRY, parent, field_code, in_field1, + in_field2); +} - dtrace("%p, \"%s\", \"%s\", \"%s\", \"%s\"", D, parent, field_code, in_field1, +int gd_madd_indir(DIRFILE* D, const char *parent, const char* field_code, + const char* in_field1, const char* in_field2) gd_nothrow +{ + return _GD_MAddYoke(D, GD_INDIR_ENTRY, parent, field_code, in_field1, in_field2); +} - if (D->flags & GD_INVALID) {/* don't crash */ - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } - - memset(&E, 0, sizeof(gd_entry_t)); - E.field = (char *)field_code; - E.field_type = GD_DIVIDE_ENTRY; - E.in_fields[0] = (char *)in_field1; - E.in_fields[1] = (char *)in_field2; - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; - - dreturn("%i", error); - return error; +int gd_madd_sindir(DIRFILE *D, const char *parent, const char* field_code, + const char* in_field1, const char* in_field2) gd_nothrow +{ + return _GD_MAddYoke(D, GD_SINDIR_ENTRY, parent, field_code, in_field1, + in_field2); } /* add a RECIP entry */ Modified: trunk/getdata/src/common.c =================================================================== --- trunk/getdata/src/common.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/common.c 2014-04-30 18:10:25 UTC (rev 889) @@ -855,11 +855,11 @@ } /* Ensure that an input field has been identified (with error checking) */ -int _GD_BadInput(DIRFILE *D, const gd_entry_t *E, int i, int err) +int _GD_BadInput(DIRFILE *D, const gd_entry_t *E, int i, gd_entype_t t, int err) { char *code; - dtrace("%p, %p, %i, %i", D, E, i, err); + dtrace("%p, %p, %i, 0x%X, %i", D, E, i, t, err); if (E->e->entry[i] == NULL) { E->e->entry[i] = _GD_FindFieldAndRepr(D, E->in_fields[i], &code, @@ -874,9 +874,17 @@ free(code); } - /* scalar entries not allowed */ - if (E->e->entry[i]->field_type & GD_SCALAR_ENTRY_BIT) { - _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_FORMAT, E->field, 0, + /* check field type */ + if (t == GD_NO_ENTRY) { + /* scalar entries not allowed */ + if (E->e->entry[i]->field_type & GD_SCALAR_ENTRY_BIT) { + _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_FORMAT, E->field, 0, + E->e->entry[i]->field); + dreturn("%i", 1); + return 1; + } + } else if (E->e->entry[i]->field_type != t) { + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_FORMAT, E->field, 0, E->e->entry[i]->field); dreturn("%i", 1); return 1; Modified: trunk/getdata/src/del.c =================================================================== --- trunk/getdata/src/del.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/del.c 2014-04-30 18:10:25 UTC (rev 889) @@ -42,6 +42,8 @@ case GD_DIVIDE_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: if (strcmp(E->in_fields[1], C->field) == 0) { if (check) _GD_SetError(D, GD_E_DELETE, GD_E_DEL_DERIVED, E->field, 0, @@ -214,6 +216,8 @@ case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: case GD_SARRAY_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: case GD_INDEX_ENTRY: case GD_ALIAS_ENTRY: break; @@ -308,8 +312,10 @@ if ((del_list[i]->field_type == GD_CONST_ENTRY || del_list[i]->field_type == GD_CARRAY_ENTRY) && ~flags & GD_DEL_DEREF) + { _GD_DeReference(D, D->entry[j], del_list[i], 1); - else if (del_list[i]->field_type != GD_STRING_ENTRY) + } + if (!D->error) _GD_ClearDerived(D, D->entry[j], del_list[i], 1); if (D->error) { Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/entry.c 2014-04-30 18:10:25 UTC (rev 889) @@ -55,6 +55,8 @@ break; case GD_DIVIDE_ENTRY: case GD_MULTIPLY_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: free(entry->in_fields[1]); free(entry->in_fields[0]); break; @@ -312,6 +314,8 @@ case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: case GD_SARRAY_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: case GD_INDEX_ENTRY: case GD_ALIAS_ENTRY: break; @@ -451,6 +455,8 @@ break; case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: entry->in_fields[0] = strdup(E->in_fields[0]); entry->in_fields[1] = strdup(E->in_fields[1]); break; @@ -817,13 +823,21 @@ switch (E->field_type) { case GD_LINCOM_ENTRY: for (i = 0; i < E->EN(lincom,n_fields); ++i) - _GD_BadInput(D, E, i, 1); + _GD_BadInput(D, E, i, GD_NO_ENTRY, 1); break; + case GD_INDIR_ENTRY: + _GD_BadInput(D, E, 0, GD_NO_ENTRY, 1); + _GD_BadInput(D, E, 0, GD_CARRAY_ENTRY, 1); + break; + case GD_SINDIR_ENTRY: + _GD_BadInput(D, E, 0, GD_NO_ENTRY, 1); + _GD_BadInput(D, E, 0, GD_SARRAY_ENTRY, 1); + break; case GD_DIVIDE_ENTRY: case GD_MULTIPLY_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: - _GD_BadInput(D, E, 1, 1); + _GD_BadInput(D, E, 1, GD_NO_ENTRY, 1); /* fallthrough */ case GD_LINTERP_ENTRY: case GD_BIT_ENTRY: @@ -831,7 +845,7 @@ case GD_POLYNOM_ENTRY: case GD_SBIT_ENTRY: case GD_RECIP_ENTRY: - _GD_BadInput(D, E, 0, 1); + _GD_BadInput(D, E, 0, GD_NO_ENTRY, 1); /* Fallthrough */ case GD_RAW_ENTRY: case GD_CONST_ENTRY: Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/errors.c 2014-04-30 18:10:25 UTC (rev 889) @@ -114,10 +114,13 @@ "Recursion too deep including {4} on line {3} of {2}", 0 }, /* GD_E_BAD_DIRFILE: (nothing) */ { GD_E_BAD_DIRFILE, 0, "Invalid dirfile", 0 }, - /* GD_E_BAD_FIELD_TYPE: 4 = fieldcode */ + /* GD_E_BAD_FIELD_TYPE: 2 = parent field (if any) 4 = fieldcode */ { GD_E_BAD_FIELD_TYPE, GD_E_FIELD_PUT, "No method to write field {4}", 0 }, { GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, "Invalid field type for {4}", 0 }, { GD_E_BAD_FIELD_TYPE, GD_E_FIELD_MATCH, "Field type mismatch for {4}", 0 }, + { GD_E_BAD_FIELD_TYPE, GD_E_FIELD_FORMAT, + "Bad field type for {4} in definition of {2}", 0 }, + { GD_E_BAD_FIELD_TYPE, GD_E_FIELD_STR, "Non-numeric data in {4}", 0 }, /* GD_E_ACCMODE: (nothing) */ { GD_E_ACCMODE, 0, "Dirfile has been opened read-only", 0 }, /* GD_E_UNSUPPORTED: (nothing) */ Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/flimits.c 2014-04-30 18:10:25 UTC (rev 889) @@ -216,7 +216,9 @@ case GD_SBIT_ENTRY: case GD_POLYNOM_ENTRY: case GD_RECIP_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; ns = _GD_GetEOF(D, E->e->entry[0], E->field, is_index); @@ -225,8 +227,11 @@ case GD_MULTIPLY_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: - if (_GD_BadInput(D, E, 0, 1) || _GD_BadInput(D, E, 1, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1) || + _GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) + { break; + } ns = _GD_GetEOF(D, E->e->entry[0], E->field, is_index); @@ -263,7 +268,7 @@ } break; case GD_LINCOM_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; ns = _GD_GetEOF(D, E->e->entry[0], E->field, is_index); @@ -284,7 +289,7 @@ } for (i = 1; i < E->EN(lincom,n_fields); ++i) { - if (_GD_BadInput(D, E, i, 1)) { + if (_GD_BadInput(D, E, i, GD_NO_ENTRY, 1)) { ns = -1; break; } @@ -313,7 +318,7 @@ } break; case GD_PHASE_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; ns = _GD_GetEOF(D, E->e->entry[0], E->field, is_index); @@ -423,13 +428,15 @@ case GD_LINTERP_ENTRY: case GD_POLYNOM_ENTRY: case GD_RECIP_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; bof = _GD_GetBOF(D, E->e->entry[0], E->field, spf, ds); break; case GD_PHASE_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; bof = _GD_GetBOF(D, E->e->entry[0], E->field, spf, ds); @@ -458,8 +465,11 @@ case GD_DIVIDE_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: - if (_GD_BadInput(D, E, 0, 1) || _GD_BadInput(D, E, 1, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1) || + _GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) + { break; + } bof = _GD_GetBOF(D, E->e->entry[0], E->field, spf, ds); @@ -483,7 +493,7 @@ } break; case GD_LINCOM_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; bof = _GD_GetBOF(D, E->e->entry[0], E->field, spf, ds); @@ -494,7 +504,7 @@ } for (i = 1; i < E->EN(lincom,n_fields); ++i) { - if (_GD_BadInput(D, E, i, 1)) { + if (_GD_BadInput(D, E, i, GD_NO_ENTRY, 1)) { bof = -1; break; } Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/flush.c 2014-04-30 18:10:25 UTC (rev 889) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2012 D. V. Wiebe +/* Copyright (C) 2008-2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -58,7 +58,7 @@ break; case GD_LINCOM_ENTRY: for (i = 0; i < E->EN(lincom,n_fields); ++i) { - if (!_GD_BadInput(D, E, i, 0)) + if (!_GD_BadInput(D, E, i, GD_NO_ENTRY, 0)) _GD_Flush(D, E->e->entry[i], syn, clo); } break; @@ -66,7 +66,7 @@ case GD_DIVIDE_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: - if (!_GD_BadInput(D, E, 1, 0)) + if (!_GD_BadInput(D, E, 1, GD_NO_ENTRY, 0)) _GD_Flush(D, E->e->entry[1], syn, clo); /* fallthrough */ case GD_LINTERP_ENTRY: @@ -75,7 +75,9 @@ case GD_POLYNOM_ENTRY: case GD_SBIT_ENTRY: case GD_RECIP_ENTRY: - if (!_GD_BadInput(D, E, 0, 0)) + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: + if (!_GD_BadInput(D, E, 0, GD_NO_ENTRY, 0)) _GD_Flush(D, E->e->entry[0], syn, clo); case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: @@ -731,6 +733,26 @@ } } break; + case GD_INDIR_ENTRY: + if (fprintf(stream, " INDIR%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, + D->standards, 0) < 0) + { + goto WRITE_ERR; + } + break; + case GD_SINDIR_ENTRY: + if (fprintf(stream, " SINDIR%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, + D->standards, 0) < 0) + { + goto WRITE_ERR; + } + break; case GD_INDEX_ENTRY: case GD_ALIAS_ENTRY: case GD_NO_ENTRY: @@ -1318,6 +1340,8 @@ D->av &= GD_VERS_GE_6; break; case GD_SARRAY_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: D->av &= GD_VERS_GE_10; break; case GD_BIT_ENTRY: Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/fpos.c 2014-04-30 18:10:25 UTC (rev 889) @@ -47,13 +47,13 @@ D->fragment[E->fragment_index].frame_offset; break; case GD_LINCOM_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; pos = _GD_GetFilePos(D, E->e->entry[0], -1); if (!D->error) for (i = 1; i < E->EN(lincom,n_fields); ++i) { - if (_GD_BadInput(D, E, i, 1)) { + if (_GD_BadInput(D, E, i, GD_NO_ENTRY, 1)) { pos = -1; break; } @@ -70,7 +70,9 @@ case GD_POLYNOM_ENTRY: case GD_SBIT_ENTRY: case GD_RECIP_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; pos = _GD_GetFilePos(D, E->e->entry[0], -1); break; @@ -78,8 +80,11 @@ case GD_DIVIDE_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: - if (_GD_BadInput(D, E, 0, 1) || _GD_BadInput(D, E, 1, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1) || + _GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) + { break; + } pos = _GD_GetFilePos(D, E->e->entry[0], -1); if (D->error) break; @@ -90,7 +95,7 @@ } break; case GD_PHASE_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; pos = _GD_GetFilePos(D, E->e->entry[0], -1); if (pos >= 0) @@ -280,7 +285,7 @@ break; case GD_LINCOM_ENTRY: for (i = 0; i < E->EN(lincom,n_fields); ++i) - if (!_GD_BadInput(D, E, i, 1)) + if (!_GD_BadInput(D, E, i, GD_NO_ENTRY, 1)) _GD_Seek(D, E->e->entry[i], offset, mode); else break; @@ -289,7 +294,7 @@ case GD_DIVIDE_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: - if (_GD_BadInput(D, E, 1, 1)) + if (_GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) break; if (_GD_Seek(D, E->e->entry[1], offset, mode)) break; @@ -299,11 +304,13 @@ case GD_POLYNOM_ENTRY: case GD_SBIT_ENTRY: case GD_RECIP_ENTRY: - if (!_GD_BadInput(D, E, 0, 1)) + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: + if (!_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) _GD_Seek(D, E->e->entry[0], offset, mode); break; case GD_PHASE_ENTRY: - if (!_GD_BadInput(D, E, 0, 1)) + if (!_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) _GD_Seek(D, E->e->entry[0], offset - E->EN(phase,shift), mode); break; case GD_INDEX_ENTRY: Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/getdata.c 2014-04-30 18:10:25 UTC (rev 889) @@ -983,7 +983,7 @@ /* input field checks */ for (i = 0; i < E->EN(lincom,n_fields); ++i) { - if (_GD_BadInput(D, E, i, 1)) { + if (_GD_BadInput(D, E, i, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1116,12 +1116,12 @@ num_samp, return_type, data_out); /* Check input fields */ - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } - if (_GD_BadInput(D, E, 1, 1)) { + if (_GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1209,7 +1209,7 @@ num_samp, return_type, data_out); /* Check input fields */ - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1255,7 +1255,9 @@ num_samp, return_type, data_out); /* Check input fields */ - if (_GD_BadInput(D, E, 0, 1) || _GD_BadInput(D, E, 1, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1) || + _GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) + { dreturn("%i", 0); return 0; } @@ -1350,7 +1352,7 @@ dtrace("%p, %p, %i, %lli, %" PRNsize_t ", 0x%X, %p", D, E, is_signed, (long long)first_samp, num_samp, return_type, data_out); - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1403,7 +1405,7 @@ dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, num_samp, return_type, data_out); - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1427,7 +1429,7 @@ dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, num_samp, return_type, data_out); - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1469,7 +1471,7 @@ dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, num_samp, return_type, data_out); - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1516,12 +1518,12 @@ num_samp, return_type, data_out); /* Check input fields */ - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } - if (_GD_BadInput(D, E, 1, 1)) { + if (_GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1622,12 +1624,12 @@ num_samp, return_type, data_out); /* Check input fields */ - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } - if (_GD_BadInput(D, E, 1, 1)) { + if (_GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -1789,8 +1791,7 @@ return n_read; } -/* _GD_DoConst: Read from a const. Returns number of samples read (ie. 1). -*/ +/* _GD_DoConst: Read from a const. Returns number of samples read */ static size_t _GD_DoConst(DIRFILE *restrict D, const gd_entry_t *restrict E, off64_t first, size_t len, gd_type_t return_type, void *restrict data_out) { @@ -1812,6 +1813,94 @@ return len; } +/* simple */ +static void _GD_IndirData(DIRFILE *restrict D, char *restrict cbuf, + gd_type_t ctype, const int64_t *restrict ibuf, size_t n, const void *carray, + size_t len) +{ + size_t i; + const int size = GD_SIZE(ctype); + int64_t ilen = (len > GD_INT64_MAX) ? GD_INT64_MAX : len; + + dtrace("%p, %p, 0x%X, %p, %" PRNsize_t ", %p, %" PRNsize_t, D, cbuf, ctype, + ibuf, n, carray, len); + + for (i = 0; i < n; ++i) + if (ibuf[i] < 0 || ibuf[i] >= ilen) + _GD_FillZero(cbuf + size * i, ctype, 1); + else + memcpy(cbuf + size * i, carray + size * ibuf[i], size); + + dreturnvoid(); +} + +/* _GD_DoIndir: Read from an indir. */ +static size_t _GD_DoIndir(DIRFILE *restrict D, const gd_entry_t *restrict E, + off64_t first_samp, size_t num_samp, gd_type_t return_type, + void *restrict data_out) +{ + size_t n_read; + int64_t *ibuf = NULL; + void *cbuf = NULL; + gd_type_t ctype; + + dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, + num_samp, return_type, data_out); + + /* Check input fields */ + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { + dreturn("%i", 0); + return 0; + } + + if (_GD_BadInput(D, E, 1, GD_CARRAY_ENTRY, 1)) { + dreturn("%i", 0); + return 0; + } + + /* index buffer */ + ibuf = _GD_Alloc(D, GD_INT64, num_samp); + if (D->error) { + dreturn("%i", 0); + return 0; + } + + /* read the index field and record the number of samples returned */ + n_read = _GD_DoField(D, E->e->entry[0], E->e->repr[0], first_samp, num_samp, + GD_INT64, ibuf); + + if (D->error || n_read == 0) { + free(ibuf); + dreturn("%i", 0); + return 0; + } + + /* the intermediate buffer: it has the load type of the carray */ + ctype = _GD_ConstType(D, E->e->entry[1]->EN(scalar,const_type)); + cbuf = _GD_Alloc(D, ctype, n_read); + if (D->error) { + free(ibuf); + dreturn("%i", 0); + return 0; + } + + _GD_IndirData(D, cbuf, GD_SIZE(ctype), ibuf, n_read, + E->e->entry[1]->e->u.scalar.d, E->e->entry[1]->EN(scalar,array_len)); + + free(ibuf); + + /* type convert into output buffer */ + _GD_ConvertType(D, cbuf, ctype, data_out, return_type, n_read); + + free(cbuf); + + if (D->error) + n_read = 0; + + dreturn("%" PRNsize_t, n_read); + return n_read; +} + /* _GD_DoField: Locate the field in the database and read it. */ size_t _GD_DoField(DIRFILE *restrict D, gd_entry_t *restrict E, int repr, @@ -1927,8 +2016,12 @@ case GD_CARRAY_ENTRY: n_read = _GD_DoConst(D, E, first_samp, num_samp, return_type, data_out); break; + case GD_INDIR_ENTRY: + n_read = _GD_DoIndir(D, E, first_samp, num_samp, return_type, data_out); + break; case GD_STRING_ENTRY: case GD_SARRAY_ENTRY: + case GD_SINDIR_ENTRY: case GD_ALIAS_ENTRY: case GD_NO_ENTRY: /* Can't get here */ @@ -1949,6 +2042,110 @@ return n_read; } +/* this returns string vector data (ie. SINDIR) */ +size_t gd_getstrdata64(DIRFILE *D, const char *field_code, off64_t first_frame, + off64_t first_samp, size_t num_frames, size_t num_samp, + const char **data_out) +{ + size_t i, n_read = 0; + gd_entry_t *E; + unsigned int spf; + int64_t *ibuf = NULL; + int64_t len; + + dtrace("%p, \"%s\", %lli %lli, %" PRNsize_t ", %" PRNsize_t ", %p", D, + field_code, (long long)first_frame, (long long)first_samp, num_frames, + num_samp, data_out); + + if (D->flags & GD_INVALID) { + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%i", 0); + return 0; + } + + _GD_ClearError(D); + + E = _GD_FindField(D, field_code, D->entry, D->n_entries, 1, NULL); + + if (E == NULL) { + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code); + dreturn("%i", 0); + return 0; + } + + if (E->field_type != GD_SINDIR_ENTRY) { + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + dreturn("%i", 0); + return 0; + } + + if (first_frame == GD_HERE || first_samp == GD_HERE) { + first_samp = GD_HERE; + first_frame = 0; + } + + if (first_frame > 0 || num_frames > 0) { + /* get the samples per frame */ + spf = _GD_GetSPF(D, E); + + if (D->error) { + dreturn("%i", 0); + return 0; + } + + first_samp += spf * first_frame; + num_samp += spf * num_frames; + } + + if (first_samp < 0 && (first_samp != GD_HERE || first_frame != 0)) { + _GD_SetError(D, GD_E_RANGE, GD_E_OUT_OF_RANGE, NULL, 0, NULL); + dreturn("%i", 0); + return 0; + } + + /* Check input fields */ + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { + dreturn("%i", 0); + return 0; + } + + if (_GD_BadInput(D, E, 1, GD_SARRAY_ENTRY, 1)) { + dreturn("%i", 0); + return 0; + } + + /* index buffer */ + ibuf = _GD_Alloc(D, GD_INT64, num_samp); + if (D->error) { + dreturn("%i", 0); + return 0; + } + + /* read the index field and record the number of samples returned */ + n_read = _GD_DoField(D, E->e->entry[0], E->e->repr[0], first_samp, num_samp, + GD_INT64, ibuf); + + if (D->error || n_read == 0) { + free(ibuf); + dreturn("%i", 0); + return 0; + } + + len = (E->e->entry[1]->EN(scalar,array_len) > GD_INT64_MAX) ? GD_INT64_MAX + : E->e->entry[1]->EN(scalar,array_len); + + for (i = 0; i < n_read; ++i) + if (ibuf[i] < 0 || ibuf[i] >= len) + data_out[i] = NULL; + else + data_out[i] = ((const char **)E->e->entry[1]->e->u.scalar.d)[ibuf[i]]; + + free(ibuf); + + dreturn("%" PRNsize_t, n_read); + return n_read; +} + /* this function is little more than a public boilerplate for _GD_DoField */ size_t gd_getdata64(DIRFILE* D, const char *field_code_in, off64_t first_frame, off64_t first_samp, size_t num_frames, size_t num_samp, @@ -1982,6 +2179,8 @@ if (entry->field_type & GD_SCALAR_ENTRY_BIT) _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, field_code); + else if (entry->field_type == GD_SINDIR_ENTRY) + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_STR, NULL, 0, field_code); if (field_code != field_code_in) free(field_code); @@ -2023,6 +2222,13 @@ } /* 32(ish)-bit wrapper for the 64-bit version, when needed */ +size_t gd_getstrdata(DIRFILE *D, const char *field_code, off_t first_frame, + off_t first_samp, size_t num_frames, size_t num_samp, const char **data_out) +{ + return gd_getstrdata64(D, field_code, first_frame, first_samp, num_frames, + num_samp, data_out); +} + size_t gd_getdata(DIRFILE* D, const char *field_code, off_t first_frame, off_t first_samp, size_t num_frames, size_t num_samp, gd_type_t return_type, void *data_out) Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/getdata.h.in 2014-04-30 18:10:25 UTC (rev 889) @@ -59,7 +59,7 @@ #endif /* The most recent standards version supported by this library */ -#define GD_DIRFILE_STANDARDS_VERSION 9 +#define GD_DIRFILE_STANDARDS_VERSION 10 #include <math.h> #include <sys/types.h> @@ -241,6 +241,8 @@ GD_RECIP_ENTRY = 0x0B, GD_WINDOW_ENTRY = 0x0C, GD_MPLEX_ENTRY = 0x0D, + GD_INDIR_ENTRY = 0x0E, + GD_SINDIR_ENTRY = 0x0F, GD_CONST_ENTRY = GD_SCALAR_ENTRY_BIT | 0x00, GD_STRING_ENTRY = GD_SCALAR_ENTRY_BIT | 0x01, GD_CARRAY_ENTRY = GD_SCALAR_ENTRY_BIT | 0x02, @@ -546,6 +548,10 @@ const char *in_field1, const char *in_field2, int fragment_index) gd_nothrow gd_nonnull ((1,2,3,4)); +extern int gd_add_indir(DIRFILE *dirfile, const char *field_code, + const char *in_field1, const char *in_field2, int fragment_index) +gd_nothrow gd_nonnull ((1,2,3,4)); + extern int gd_add_lincom(DIRFILE *dirfile, const char *field_code, int n_fields, const char **in_fields, const double *m, const double *b, int fragment_index) gd_nothrow gd_nonnull ((1,2,4,5,6)); @@ -582,6 +588,10 @@ const char *in_field, int bitnum, int numbits, int fragment_index) gd_nothrow gd_nonnull ((1,2,3)); +extern int gd_add_sindir(DIRFILE *dirfile, const char *field_code, + const char *in_field1, const char *in_field2, int fragment_index) +gd_nothrow gd_nonnull ((1,2,3,4)); + extern int gd_add_string(DIRFILE *dirfile, const char *field_code, const char *value, int fragment_index) gd_nothrow gd_nonnull((1,2,3)); @@ -632,6 +642,9 @@ extern int gd_alter_divide(DIRFILE *dirfile, const char *field_code, const char *in_field1, const char *in_field2) gd_nothrow gd_nonnull((1,2)); +extern int gd_alter_indir(DIRFILE *dirfile, const char *field_code, + const char *in_field1, const char *in_field2) gd_nothrow gd_nonnull((1,2)); + extern int gd_alter_lincom(DIRFILE *dirfile, const char *field_code, int n_fields, const char **in_fields, const double *m, const double *b) gd_nothrow gd_nonnull((1,2)); @@ -660,6 +673,9 @@ const char *in_field, int bitnum, int numbits) gd_nothrow gd_nonnull((1,2)); +extern int gd_alter_sindir(DIRFILE *dirfile, const char *field_code, + const char *in_field1, const char *in_field2) gd_nothrow gd_nonnull((1,2)); + extern int gd_alter_window(DIRFILE *dirfile, const char *field_code, const char *in_field, const char *check_field, gd_windop_t windop, gd_triplet_t threshold) gd_nothrow gd_nonnull((1,2)); @@ -792,6 +808,10 @@ const char *field_code, const char *in_field1, const char *in_field2) gd_nothrow gd_nonnull ((1,2,3,4,5)); +extern int gd_madd_indir(DIRFILE *dirfile, const char *parent, + const char *field_code, const char *in_field1, const char *in_field2) +gd_nothrow gd_nonnull ((1,2,3,4,5)); + extern int gd_madd_lincom(DIRFILE *dirfile, const char *parent, const char *field_code, int n_fields, const char **in_fields, const double *m, const double *b) gd_nothrow gd_nonnull((1,2,3,5,6,7)); @@ -829,6 +849,10 @@ const char *field_code, const char *in_field, int bitnum, int numbits) gd_nothrow gd_nonnull ((1,2,3,4)); +extern int gd_madd_sindir(DIRFILE *dirfile, const char *parent, + const char *field_code, const char *in_field1, const char *in_field2) +gd_nothrow gd_nonnull ((1,2,3,4,5)); + extern int gd_madd_spec(DIRFILE *dirfile, const char *line, const char *parent) gd_nothrow gd_nonnull ((1,2,3)); @@ -1041,6 +1065,10 @@ off_t first_frame, off_t first_sample, size_t num_frames, size_t num_samples, gd_type_t return_type, void *data) gd_nonnull ((1, 2)); +extern size_t gd_getstrdata(DIRFILE *dirfile, const char *field_code, + off_t first_frame, off_t first_sample, size_t num_frames, + size_t num_samples, const char **data) gd_nonnull ((1, 2)); + extern size_t gd_putdata(DIRFILE *dirfile, const char *field_code, off_t first_frame, off_t first_sample, size_t num_frames, size_t num_samples, gd_type_t data_type, const void *data) @@ -1089,6 +1117,11 @@ off_t first_frame, off_t first_samp, size_t num_frames, size_t num_samp, gd_type_t return_type, void *data), gd_getdata64) gd_nonnull ((1, 2)); +extern size_t __REDIRECT (gd_getstrdata, (DIRFILE *dirfile, + const char *field_code, off_t first_frame, off_t first_samp, + size_t num_frames, size_t num_samp, const char **data), gd_getstrdata64) +gd_nonnull ((1, 2)); + extern size_t __REDIRECT (gd_putdata, (DIRFILE *dirfile, const char *field_code, off_t first_frame, off_t first_sample, size_t num_frames, size_t num_samples, gd_type_t data_type, const void *data), @@ -1110,6 +1143,7 @@ # else # define gd_alter_frameoffset gd_alter_frameoffset64 # define gd_getdata gd_getdata64 +# define gd_getstrdata gd_getstrdata64 # define gd_putdata gd_putdata64 # define gd_nframes gd_nframes64 # define gd_eof gd_eof64 @@ -1142,6 +1176,10 @@ gd_off64_t first_frame, gd_off64_t first_samp, size_t num_frames, size_t num_samp, gd_type_t return_type, void *data) gd_nonnull ((1, 2)); +extern size_t gd_getstrdata64(DIRFILE *dirfile, const char *field_code, + gd_off64_t first_frame, gd_off64_t first_samp, size_t num_frames, + size_t num_samp, const char **data) gd_nonnull ((1, 2)); + extern size_t gd_putdata64(DIRFILE *dirfile, const char *field_code, gd_off64_t first_frame, gd_off64_t first_sample, size_t num_frames, size_t num_samples, gd_type_t data_type, const void *data) Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/internal.h 2014-04-30 18:10:25 UTC (rev 889) @@ -269,16 +269,18 @@ #define SIZEOF_UNSIGNED_INT (sizeof(unsigned int)) #endif +#define GD_INT_TYPE ((gd_type_t)(SIZEOF_INT | GD_SIGNED)) +#define GD_UINT_TYPE ((gd_type_t)(SIZEOF_UNSIGNED_INT)) + +/* a few integer limits */ #ifndef SIZEOF_SIZE_T #define SIZEOF_SIZE_T (sizeof(size_t)) #endif +#define GD_INT64_MAX ((int64_t)((uint64_t)-1>>1)) #define GD_SSIZE_T_MAX ((ssize_t)((size_t)-1>>1)) #define GD_SIZE_T_MAX ((size_t)-1) -#define GD_INT_TYPE ((gd_type_t)(SIZEOF_INT | GD_SIGNED)) -#define GD_UINT_TYPE ((gd_type_t)(SIZEOF_UNSIGNED_INT)) - /* default buffer size */ #if SIZEOF_INT < 4 #define GD_BUFFER_SIZE 32767 @@ -753,6 +755,8 @@ #define GD_E_FIELD_PUT 1 #define GD_E_FIELD_BAD 2 #define GD_E_FIELD_MATCH 3 +#define GD_E_FIELD_FORMAT 4 +#define GD_E_FIELD_STR 5 #define GD_E_ENTRY_TYPE 1 #define GD_E_ENTRY_METARAW 2 @@ -1101,7 +1105,7 @@ /* forward declarations */ void *_GD_Alloc(DIRFILE*, gd_type_t, size_t) __attribute_malloc__; -int _GD_BadInput(DIRFILE *, const gd_entry_t *, int, int); +int _GD_BadInput(DIRFILE *, const gd_entry_t *, int, gd_entype_t, int); #define _GD_BadWindop(op) \ ( \ Modified: trunk/getdata/src/legacy.c =================================================================== --- trunk/getdata/src/legacy.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/legacy.c 2014-04-30 18:10:25 UTC (rev 889) @@ -439,6 +439,8 @@ break; case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: Format.n_multiply++; break; case GD_PHASE_ENTRY: @@ -517,6 +519,8 @@ break; case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: CopyMultDivEntry(&Format.multiplyEntries[nmultiply++], D->entry[i]); break; case GD_PHASE_ENTRY: Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/mod.c 2014-04-30 18:10:25 UTC (rev 889) @@ -614,6 +614,8 @@ break; case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: j = _GD_AlterInField(D, 0, Q.in_fields, N->in_fields, E->in_fields, E->fragment_index, 0); if (j < 0) @@ -974,9 +976,9 @@ break; if (Q.EN(scalar,array_len) > E->EN(scalar,array_len)) { - memset(((char**)Qe.u.scalar.d) + E->EN(scalar,array_len), 0, - sizeof(char**) * (Q.EN(scalar,array_len) - - E->EN(scalar,array_len))); + size_t i; + for (i = E->EN(scalar,array_len); i < Q.EN(scalar,array_len); ++i) + ((const char**)Qe.u.scalar.d)[i] = _GD_Strdup(D, ""); } } else Qe.u.scalar.d = E->e->u.scalar.d; @@ -1375,13 +1377,14 @@ return ret; } -int gd_alter_divide(DIRFILE* D, const char* field_code, const char* in_field1, - const char* in_field2) gd_nothrow +static int _GD_AlterYoke(DIRFILE* D, gd_entype_t t, const char* field_code, + const char* in_field1, const char* in_field2) gd_nothrow { int ret; gd_entry_t N; - dtrace("%p, \"%s\", \"%s\", \"%s\"", D, field_code, in_field1, in_field2); + dtrace("%p, 0x%X, \"%s\", \"%s\", \"%s\"", D, t, field_code, in_field1, + in_field2); if (D->flags & GD_INVALID) {/* don't crash */ _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -1390,7 +1393,7 @@ } memset(&N, 0, sizeof(gd_entry_t)); - N.field_type = GD_DIVIDE_ENTRY; + N.field_type = t; N.in_fields[0] = (char *)in_field1; N.in_fields[1] = (char *)in_field2; @@ -1400,29 +1403,28 @@ return ret; } +int gd_alter_divide(DIRFILE* D, const char* field_code, const char* in_field1, + const char* in_field2) gd_nothrow +{ + return _GD_AlterYoke(D, GD_DIVIDE_ENTRY, field_code, in_field1, in_field2); +} + int gd_alter_multiply(DIRFILE* D, const char* field_code, const char* in_field1, const char* in_field2) gd_nothrow { - int ret; - gd_entry_t N; + return _GD_AlterYoke(D, GD_MULTIPLY_ENTRY, field_code, in_field1, in_field2); +} - dtrace("%p, \"%s\", \"%s\", \"%s\"", D, field_code, in_field1, in_field2); +int gd_alter_indir(DIRFILE* D, const char* field_code, const char* in_field1, + const char* in_field2) gd_nothrow +{ + return _GD_AlterYoke(D, GD_INDIR_ENTRY, field_code, in_field1, in_field2); +} - if (D->flags & GD_INVALID) {/* don't crash */ - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } - - memset(&N, 0, sizeof(gd_entry_t)); - N.field_type = GD_MULTIPLY_ENTRY; - N.in_fields[0] = (char *)in_field1; - N.in_fields[1] = (char *)in_field2; - - ret = _GD_Change(D, field_code, &N, 0); - - dreturn("%i", ret); - return ret; +int gd_alter_sindir(DIRFILE* D, const char* field_code, const char* in_field1, + const char* in_field2) gd_nothrow +{ + return _GD_AlterYoke(D, GD_SINDIR_ENTRY, field_code, in_field1, in_field2); } int gd_alter_phase(DIRFILE* D, const char* field_code, const char* in_field, Modified: trunk/getdata/src/name.c =================================================================== --- trunk/getdata/src/name.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/name.c 2014-04-30 18:10:25 UTC (rev 889) @@ -451,46 +451,72 @@ rdat->n_code = 0; for (u = 0; u < D->n_entries; ++u) { - if (update_vectors) - switch (D->entry[u]->field_type) { - case GD_LINCOM_ENTRY: + switch (D->entry[u]->field_type) { + case GD_LINCOM_ENTRY: + if (update_vectors) for (i = 0; i < D->entry[u]->EN(lincom,n_fields); ++i) { if (_GD_UpdateInField(D, D->entry[u], rdat, i, search_meta, mode)) { dreturn("%i", -1); return -1; } } - break; - case GD_MULTIPLY_ENTRY: - case GD_DIVIDE_ENTRY: - case GD_WINDOW_ENTRY: - case GD_MPLEX_ENTRY: + break; + case GD_MULTIPLY_ENTRY: + case GD_DIVIDE_ENTRY: + case GD_WINDOW_ENTRY: + case GD_MPLEX_ENTRY: + if (update_vectors) if (_GD_UpdateInField(D, D->entry[u], rdat, 1, search_meta, mode)) { dreturn("%i", -1); return -1; } - /* Fallthrough */ - case GD_LINTERP_ENTRY: - case GD_BIT_ENTRY: - case GD_PHASE_ENTRY: - case GD_POLYNOM_ENTRY: - case GD_RECIP_ENTRY: - case GD_SBIT_ENTRY: + /* Fallthrough */ + case GD_LINTERP_ENTRY: + case GD_BIT_ENTRY: + case GD_PHASE_ENTRY: + case GD_POLYNOM_ENTRY: + case GD_RECIP_ENTRY: + case GD_SBIT_ENTRY: + if (update_vectors) if (_GD_UpdateInField(D, D->entry[u], rdat, 0, search_meta, mode)) { dreturn("%i", -1); return -1; } - break; - case GD_INDEX_ENTRY: - case GD_RAW_ENTRY: - case GD_NO_ENTRY: - case GD_CONST_ENTRY: - case GD_CARRAY_ENTRY: - case GD_SARRAY_ENTRY: - case GD_STRING_ENTRY: - case GD_ALIAS_ENTRY: - break; - } + break; + case GD_INDIR_ENTRY: + if (update_vectors) + if (_GD_UpdateInField(D, D->entry[u], rdat, 0, search_meta, mode)) { + dreturn("%i", -1); + return -1; + } + if (rdat->E->field_type == GD_CARRAY_ENTRY || search_meta) + if (_GD_UpdateInField(D, D->entry[u], rdat, 1, search_meta, mode)) { + dreturn("%i", -1); + return -1; + } + break; + case GD_SINDIR_ENTRY: + if (update_vectors) + if (_GD_UpdateInField(D, D->entry[u], rdat, 0, search_meta, mode)) { + dreturn("%i", -1); + return -1; + } + if (rdat->E->field_type == GD_SARRAY_ENTRY || search_meta) + if (_GD_UpdateInField(D, D->entry[u], rdat, 1, search_meta, mode)) { + dreturn("%i", -1); + return -1; + } + break; + case GD_INDEX_ENTRY: + case GD_RAW_ENTRY: + case GD_NO_ENTRY: + case GD_CONST_ENTRY: + case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: + case GD_STRING_ENTRY: + case GD_ALIAS_ENTRY: + break; + } if (update_scalars) switch (D->entry[u]->field_type) { case GD_LINCOM_ENTRY: @@ -536,6 +562,8 @@ case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: case GD_SARRAY_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: case GD_ALIAS_ENTRY: break; } Modified: trunk/getdata/src/native.c =================================================================== --- trunk/getdata/src/native.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/native.c 2014-04-30 18:10:25 UTC (rev 889) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2012 D. V. Wiebe +/* Copyright (C) 2009-2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -49,7 +49,7 @@ type = GD_FLOAT64; for (i = 0; i < E->EN(lincom,n_fields); ++i) { - if (_GD_BadInput(D, E, i, 1)) + if (_GD_BadInput(D, E, i, GD_NO_ENTRY, 1)) break; if (_GD_NativeType(D, E->e->entry[i], E->e->repr[i]) & GD_COMPLEX) { @@ -70,8 +70,11 @@ break; case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: - if (_GD_BadInput(D, E, 0, 1) || _GD_BadInput(D, E, 1, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1) || + _GD_BadInput(D, E, 1, GD_NO_ENTRY, 1)) + { break; + } type = (_GD_NativeType(D, E->e->entry[0], E->e->repr[0]) & GD_COMPLEX || _GD_NativeType(D, E->e->entry[1], E->e->repr[1]) & GD_COMPLEX) @@ -81,7 +84,7 @@ if (!(E->flags & GD_EN_CALC)) _GD_CalculateEntry(D, E, 1); - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; type = ((_GD_NativeType(D, E->e->entry[0], E->e->repr[0]) & GD_COMPLEX) @@ -94,7 +97,7 @@ case GD_PHASE_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; type = _GD_NativeType(D, E->e->entry[0], E->e->repr[0]); @@ -108,7 +111,7 @@ break; } - if (_GD_BadInput(D, E, 0, 1)) + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) break; type = (_GD_NativeType(D, E->e->entry[0], E->e->repr[0]) & GD_COMPLEX) ? @@ -120,10 +123,18 @@ break; case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: - type = E->EN(scalar,const_type); + type = _GD_ConstType(D, E->EN(scalar,const_type)); break; + case GD_INDIR_ENTRY: + if (_GD_BadInput(D, E, 1, GD_CARRAY_ENTRY, 1)) + break; + + type = _GD_NativeType(D, E->e->entry[1], E->e->repr[1]); + + break; case GD_STRING_ENTRY: case GD_SARRAY_ENTRY: + case GD_SINDIR_ENTRY: type = GD_NULL; break; case GD_NO_ENTRY: Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/parse.c 2014-04-30 18:10:25 UTC (rev 889) @@ -526,9 +526,10 @@ return E; } -/* _GD_ParseMultiply: parse MULTIPLY entry in format file. +/* _GD_ParseYoke: parse a field specified by two input fields only (MULTIPLY, + * DIVIDE, INDIR, SINDIR) */ -static gd_entry_t *_GD_ParseMultiply(DIRFILE *restrict D, +static gd_entry_t *_GD_ParseYoke(DIRFILE *restrict D, gd_entype_t type, char *gd_restrict_arr in_cols[MAX_IN_COLS], int n_cols, const gd_entry_t *restrict parent, const char *restrict format_file, int line, int me, int standards, int pedantic, int *restrict is_dot) @@ -536,8 +537,8 @@ gd_entry_t *E; int offset; - dtrace("%p, %p, %i, %p, \"%s\", %i, %i, %i, %i, %p", D, in_cols, n_cols, - parent, format_file, line, me, standards, pedantic, is_dot); + dtrace("%p, 0x%X, %p, %i, %p, \"%s\", %i, %i, %i, %i, %p", D, type, in_cols, + n_cols, parent, format_file, line, me, standards, pedantic, is_dot); if (n_cols < 4) { _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_N_TOK, format_file, line, NULL); @@ -561,7 +562,7 @@ } memset(E->e, 0, sizeof(struct gd_private_entry_)); - E->field_type = GD_MULTIPLY_ENTRY; + E->field_type = type; E->in_fields[0] = E->in_fields[1] = NULL; E->e->entry[0] = E->e->entry[1] = NULL; E->flags |= GD_EN_CALC; @@ -818,69 +819,6 @@ return E; } -/* _GD_ParseDivide: parse DIVIDE entry in format file. -*/ -static gd_entry_t *_GD_ParseDivide(DIRFILE *restrict D, - char *gd_restrict_arr in_cols[MAX_IN_COLS], int n_cols, - const gd_entry_t *restrict parent, const char *restrict format_file, - int line, int me, int standards, int pedantic, int *restrict is_dot) -{ - gd_entry_t *E; - int offset; - - dtrace("%p, %p, %i, %p, \"%s\", %i, %i, %i, %i, %p", D, in_cols, n_cols, - parent, format_file, line, me, standards, pedantic, is_dot); - - if (n_cols < 4) { - _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_N_TOK, format_file, line, NULL); - dreturn("%p", NULL); - return NULL; - } - - E = (gd_entry_t *)_GD_Malloc(D, sizeof(gd_entry_t)); - if (E == NULL) { - dreturn("%p", NULL); - return NULL; - } - memset(E, 0, sizeof(gd_entry_t)); - - E->e = (struct gd_private_entry_ *)_GD_Malloc(D, - sizeof(struct gd_private_entry_)); - if (E->e == NULL) { - free(E); - dreturn("%p", NULL); - return NULL; - } - memset(E->e, 0, sizeof(struct gd_private_entry_)); - - E->field_type = GD_DIVIDE_ENTRY; - E->in_fields[0] = E->in_fields[1] = NULL; - E->e->entry[0] = E->e->entry[1] = NULL; - - E->field = _GD_MungeFromFrag(D, parent, me, in_cols[0], &offset); - if (E->field && _GD_ValidateField(E->field + offset, standards, pedantic, 0, - is_dot)) - { - _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_BAD_NAME, format_file, line, - in_cols[0]); - _GD_FreeE(D, E, 1); - dreturn("%p", NULL); - return NULL; - } - - E->in_fields[0] = _GD_MungeFromFrag(D, NULL, me, in_cols[2], &offset); - E->in_fields[1] = _GD_MungeFromFrag(D, NULL, me, in_cols[3], &offset); - - if (D->error) { - _GD_FreeE(D, E, 1); - dreturn("%p", NULL); - return NULL; - } - - dreturn("%p", E); - return E; -} - /* _GD_ParseBit: parse BIT entry in format file. */ static gd_entry_t *_GD_ParseBit(DIRFILE *restrict D, int is_signed, @@ -1602,8 +1540,8 @@ E = _GD_ParseLinterp(D, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot); else if (strcmp(in_cols[1], "MULTIPLY") == 0 && (!pedantic || standards >= 2)) - E = _GD_ParseMultiply(D, in_cols, n_cols, P, format_file, linenum, me, - standards, pedantic, &is_dot); + E = _GD_ParseYoke(D, GD_MULTIPLY_ENTRY, in_cols, n_cols, P, format_file, + linenum, me, standards, pedantic, &is_dot); else if (strcmp(in_cols[1], "BIT") == 0) E = _GD_ParseBit(D, 0, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot); @@ -1617,8 +1555,8 @@ E = _GD_ParseBit(D, 1, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot); else if (strcmp(in_cols[1], "DIVIDE") == 0 && (!pedantic || standards >= 8)) - E = _GD_ParseDivide(D, in_cols, n_cols, P, format_file, linenum, me, - standards, pedantic, &is_dot); + E = _GD_ParseYoke(D, GD_DIVIDE_ENTRY, in_cols, n_cols, P, format_file, + linenum, me, standards, pedantic, &is_dot); else if (strcmp(in_cols[1], "RECIP") == 0 && (!pedantic || standards >= 8)) E = _GD_ParseRecip(D, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot); @@ -1628,6 +1566,12 @@ else if (strcmp(in_cols[1], "MPLEX") == 0 && (!pedantic || standards >= 9)) E = _GD_ParseMplex(D, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot); + else if (strcmp(in_cols[1], "INDIR") == 0 && (!pedantic || standards >= 10)) + E = _GD_ParseYoke(D, GD_INDIR_ENTRY, in_cols, n_cols, P, format_file, + linenum, me, standards, pedantic, &is_dot); + else if (strcmp(in_cols[1], "SINDIR") == 0 && (!pedantic || standards >= 10)) + E = _GD_ParseYoke(D, GD_SINDIR_ENTRY, in_cols, n_cols, P, format_file, + linenum, me, standards, pedantic, &is_dot); else if (strcmp(in_cols[1], "CONST") == 0 && (!pedantic || standards >= 6)) E = _GD_ParseConst(D, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot); @@ -1637,7 +1581,7 @@ else if (strcmp(in_cols[1], "STRING") == 0 && (!pedantic || standards >= 6)) E = _GD_ParseString(D, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot); - else if (strcmp(in_cols[1], "SARRAY") == 0 && (!pedantic || standards >= 8)) + else if (strcmp(in_cols[1], "SARRAY") == 0 && (!pedantic || standards >= 10)) E = _GD_ParseArray(D, 1, in_cols, n_cols, P, format_file, linenum, me, standards, pedantic, &is_dot, outstring, tok_pos); else if (standards <= GD_DIRFILE_STANDARDS_VERSION || pedantic) Modified: trunk/getdata/src/putdata.c =================================================================== --- trunk/getdata/src/putdata.c 2014-04-27 21:29:36 UTC (rev 888) +++ trunk/getdata/src/putdata.c 2014-04-30 18:10:25 UTC (rev 889) @@ -116,7 +116,7 @@ dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, num_samp, data_type, data_in); - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -226,7 +226,7 @@ return 0; } - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -296,7 +296,7 @@ dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, num_samp, data_type, data_in); - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -351,7 +351,7 @@ dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, num_samp, data_type, data_in); - if (_GD_BadInput(D, E, 0, 1)) { + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { dreturn("%i", 0); return 0; } @@ -374,7 +374,7 @@ dtrace("%p, %p, %lli, %" PRNsize_t ", ... [truncated message content] |
From: <ket...@us...> - 2014-04-27 21:29:39
|
Revision: 888 http://sourceforge.net/p/getdata/code/888 Author: ketiltrout Date: 2014-04-27 21:29:36 +0000 (Sun, 27 Apr 2014) Log Message: ----------- automake-1.11 Modified Paths: -------------- trunk/getdata/test/Makefile.am Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-04-27 18:34:22 UTC (rev 887) +++ trunk/getdata/test/Makefile.am 2014-04-27 21:29:36 UTC (rev 888) @@ -18,7 +18,7 @@ # along with GetData; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -AUTOMAKE_OPTIONS = foreign serial-tests +AUTOMAKE_OPTIONS = foreign LDADD=../src/libgetdata.la INCLUDES=${GD_CC_WALL} $(GD_CC_WEXTRA) -I$(top_srcdir)/src This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-27 18:34:35
|
Revision: 887 http://sourceforge.net/p/getdata/code/887 Author: ketiltrout Date: 2014-04-27 18:34:22 +0000 (Sun, 27 Apr 2014) Log Message: ----------- SARRAY Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/man/gd_put_carray_slice.3 trunk/getdata/src/add.c trunk/getdata/src/compat.c trunk/getdata/src/constant.c trunk/getdata/src/del.c trunk/getdata/src/encoding.c trunk/getdata/src/entry.c trunk/getdata/src/errors.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/fpos.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/internal.h trunk/getdata/src/legacy.c trunk/getdata/src/mod.c trunk/getdata/src/name.c trunk/getdata/src/native.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/src/spf.c trunk/getdata/src/string.c trunk/getdata/test/Makefile.am Added Paths: ----------- trunk/getdata/test/add_sarray.c trunk/getdata/test/alter_sarray.c trunk/getdata/test/get_sarray.c trunk/getdata/test/get_sarray_len.c trunk/getdata/test/get_sarray_slice.c trunk/getdata/test/get_string.c trunk/getdata/test/madd_sarray.c trunk/getdata/test/parse_sarray.c trunk/getdata/test/parse_sarray_long.c trunk/getdata/test/put_sarray.c trunk/getdata/test/put_sarray_slice.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/ChangeLog 2014-04-27 18:34:22 UTC (rev 887) @@ -1,3 +1,44 @@ +2014-04-03 D. V. Wiebe <ge...@ke...> svn:887 + * src/entry.c (_GD_FreeE _GD_CalculateEntry gd_entry gd_validate) + src/legacy.c (GetFormat) src/getdata.c (_GD_DoField) src/name.c + (_GD_UpdateInputs) src/flush.c (_GD_Flush _GD_FieldSpec _GD_FindVersion) + src/native.c (_GD_NativeType) src/spf.c (_GD_GetSPF) src/putdata.c + (_GD_DoFieldOut) src/del.c (_GD_DeReference) src/flimits.c (_GD_GetEOF + _GD_GetBOF) src/fpos.c (_GD_GetFilePos _GD_Seek) src/mod.c (_GD_Change) + src/add.c (_GD_InvalidEntype _GD_Add): Handle GD_SARRAY_ENTRY. + * src/string.c (gd_get_sarray_slice gd_get_sarray gd_sarray_len + gd_put_sarray_slice gd_put_sarray) src/mod.c (gd_alter_sarray) src/add.c + (gd_add_sarraygd_madd_sarray): Added. + * src/string.c (_GD_PutSarraySlice): Renamed from _GD_DoStringOut and + updated to handle SARRAYs. Made static. + * src/parse.c (_GD_ParseArray): Renamed from _GD_ParseCarray and updated to + handle SARRAYs. + + * test/get_sarray.c test/add_sarray.c test/get_sarray_len.c + test/get_string.c test/get_sarray_slice.c test/alter_sarray.c + test/parse_sarray.c test/madd_sarray.c test/put_sarray.c + test/put_sarray_slice.c test/parse_sarray_long.c: Added. + + * src/add.c (gd_add_string gd_madd_string): Don't call _GD_DoStringOut to + set the value, just set it directly. + + * src/compat.c: Define AT_SYMLINK_NOFOLLOW if necessary. + + * src/mod.c (_GD_Change): Report AlterScalar errors for LINCOMs. + + * src/errors.c: Add GD_E_FLUSH_WRITE and GD_E_FLUSH_TOO_LONG. + * src/flush.c (_GD_StringEscapeise): Return -1 on error; don't write + anything if stream == NULL. + * src/flush.c (_GD_StringEscapeise _GD_WriteFieldCode _GD_WriteConst + _GD_FieldSpec _GD_FlushFragment): Report write errors. + + * src/flush.c (_GD_WriteFieldCode): Write a trailing space if requested. + + * src/flush.c (_GD_FlushFragment): Try USER if LOGNAME not available. + + * src/constant.c (gd_get_carray_slice _GD_PutCarraySlice + gd_put_carray_slice): Make first long. + 2014-04-03 D. V. Wiebe <ge...@ke...> svn:883 * src/add.c (gd_add_crecip gd_madd_crecip) src/mod.c (gd_alter_crecip): Call the ...crecip89 function. Modified: trunk/getdata/man/gd_put_carray_slice.3 =================================================================== --- trunk/getdata/man/gd_put_carray_slice.3 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/man/gd_put_carray_slice.3 2014-04-27 18:34:22 UTC (rev 887) @@ -139,9 +139,10 @@ .BR gd_open (3). .SH RETURN VALUE On success, -.BR gd_put_carray () +.BR gd_put_carray (), +.BR gd_put_carray_slice () and -.BR gd_put_carray_slice () +.BR gd_put_constant () return zero. On error, they return -1 and set the dirfile error to a non-zero value. Possible error values are: .TP 8 Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/add.c 2014-04-27 18:34:22 UTC (rev 887) @@ -27,7 +27,8 @@ t != GD_BIT_ENTRY && t != GD_MULTIPLY_ENTRY && t != GD_PHASE_ENTRY && t != GD_CONST_ENTRY && t != GD_POLYNOM_ENTRY && t != GD_SBIT_ENTRY && t != GD_DIVIDE_ENTRY && t != GD_RECIP_ENTRY && t != GD_WINDOW_ENTRY && - t != GD_MPLEX_ENTRY && t != GD_CARRAY_ENTRY && t != GD_STRING_ENTRY) + t != GD_MPLEX_ENTRY && t != GD_CARRAY_ENTRY && t != GD_STRING_ENTRY && + t != GD_SARRAY_ENTRY) { dreturn("%i", -1); return -1; @@ -507,6 +508,19 @@ memset(E->e->u.scalar.d, 0, size); } break; + case GD_SARRAY_ENTRY: + E->EN(scalar,const_type) = GD_NULL; + E->EN(scalar,array_len) = entry->EN(scalar,array_len); + + if (E->EN(scalar,array_len) > GD_MAX_CARRAY_LENGTH) + _GD_SetError(D, GD_E_BOUNDS, 0, NULL, 0, NULL); + else { + size_t size = sizeof(const char *) * E->EN(scalar,array_len); + E->e->u.scalar.d = _GD_Malloc(D, size); + if (E->e->u.scalar.d) + memset(E->e->u.scalar.d, 0, size); + } + break; case GD_STRING_ENTRY: E->e->u.string = _GD_Strdup(D, ""); break; @@ -1296,6 +1310,7 @@ { gd_entry_t *entry; gd_entry_t S; + char *ptr; dtrace("%p, \"%s\", \"%s\", %i", D, field_code, value, fragment_index); @@ -1309,14 +1324,25 @@ S.field = (char *)field_code; S.field_type = GD_STRING_ENTRY; S.fragment_index = fragment_index; + + /* duplicate early, in case of failure */ + ptr = _GD_Strdup(D, value); + if (ptr == NULL) { + dreturn("%i", -1); + return -1; + } + entry = _GD_Add(D, &S, NULL); - /* Actually store the string, now */ - if (entry) - _GD_DoStringOut(D, entry, value); + if (D->error) { + free(ptr); + dreturn("%i", -1); + return -1; + } - dreturn("%i", D->error ? -1 : 0); - return D->error ? -1 : 0; + entry->e->u.string = ptr; + dreturn("%i", 0); + return 0; } /* add a CONST entry */ @@ -1383,6 +1409,66 @@ return D->error ? -1 : 0; } +/* add a SARRAY entry */ +int gd_add_sarray(DIRFILE* D, const char* field_code, size_t array_len, + const char **values, int fragment_index) gd_nothrow +{ + size_t i; + gd_entry_t *entry; + gd_entry_t E; + char **data; + + dtrace("%p, \"%s\", %" PRNsize_t ", %p, %i", D, field_code, array_len, values, + fragment_index); + + if (D->flags & GD_INVALID) { + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + + memset(&E, 0, sizeof(gd_entry_t)); + E.field = (char *)field_code; + E.field_type = GD_SARRAY_ENTRY; + E.EN(scalar,array_len) = array_len; + E.fragment_index = fragment_index; + + /* duplicate early, in case of failure */ + data = _GD_Malloc(D, array_len * sizeof(char *)); + if (data == NULL) { + dreturn("%i", -1); + return -1; + } + + memset(data, 0, array_len * sizeof(char*)); + for (i = 0; i < array_len; ++i) + data[i] = _GD_Strdup(D, values[i]); + + if (D->error) { + for (i = 0; i < array_len; ++i) + free(data[i]); + free(data); + dreturn("%i", -1); + return -1; + } + + entry = _GD_Add(D, &E, NULL); + + if (D->error) { + for (i = 0; i < array_len; ++i) + free(data[i]); + free(data); + dreturn("%i", -1); + return -1; + } + + free(entry->e->u.scalar.d); + entry->e->u.scalar.d = data; + + dreturn("%i", 0); + return 0; +} + int gd_madd(DIRFILE* D, const gd_entry_t* entry, const char* parent) gd_nothrow { int ret; @@ -1877,6 +1963,7 @@ { gd_entry_t *entry; gd_entry_t S; + char *ptr; dtrace("%p, \"%s\", \"%s\", \"%s\"", D, parent, field_code, value); @@ -1890,14 +1977,25 @@ S.field = (char *)field_code; S.field_type = GD_STRING_ENTRY; S.fragment_index = 0; + + /* duplicate early, in case of failure */ + ptr = _GD_Strdup(D, value); + if (ptr == NULL) { + dreturn("%i", -1); + return -1; + } + entry = _GD_Add(D, &S, parent); - /* Actually store the string, now */ - if (entry) - _GD_DoStringOut(D, entry, value); + if (D->error) { + free(ptr); + dreturn("%i", -1); + return -1; + } - dreturn("%i", D->error ? -1 : 0); - return D->error ? -1 : 0; + entry->e->u.string = ptr; + dreturn("%i", 0); + return 0; } /* add a META CONST entry */ @@ -1964,6 +2062,65 @@ return D->error ? -1 : 0; } +/* Add META SARRAY */ +int gd_madd_sarray(DIRFILE* D, const char *parent, const char *field_code, + size_t array_len, const char **values) gd_nothrow +{ + size_t i; + gd_entry_t *entry; + gd_entry_t E; + char **data; + + dtrace("%p, \"%s\", \"%s\", %" PRNsize_t ", %p", D, parent, field_code, + array_len, values); + + if (D->flags & GD_INVALID) { + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + + memset(&E, 0, sizeof(gd_entry_t)); + E.field = (char *)field_code; + E.field_type = GD_SARRAY_ENTRY; + E.EN(scalar,array_len) = array_len; + + /* duplicate early, in case of failure */ + data = _GD_Malloc(D, array_len * sizeof(char *)); + if (data == NULL) { + dreturn("%i", -1); + return -1; + } + + memset(data, 0, array_len * sizeof(char*)); + for (i = 0; i < array_len; ++i) + data[i] = _GD_Strdup(D, values[i]); + + if (D->error) { + for (i = 0; i < array_len; ++i) + free(data[i]); + free(data); + dreturn("%i", -1); + return -1; + } + + entry = _GD_Add(D, &E, parent); + + if (D->error) { + for (i = 0; i < array_len; ++i) + free(data[i]); + free(data); + dreturn("%i", -1); + return -1; + } + + free(entry->e->u.scalar.d); + entry->e->u.scalar.d = data; + + dreturn("%i", 0); + return 0; +} + /* add an alias */ static int _GD_AddAlias(DIRFILE *restrict D, const char *restrict parent, const char *restrict field_code, const char *restrict target, Modified: trunk/getdata/src/compat.c =================================================================== --- trunk/getdata/src/compat.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/compat.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,4 +1,4 @@ -/* Copyright (C) 2010, 2011, 2012 D. V. Wiebe +/* Copyright (C) 2010-2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -91,6 +91,9 @@ #endif #ifndef HAVE_FSTATAT +#ifndef AT_SYMLINK_NOFOLLOW +#define AT_SYMLINK_NOFOLLOW 0 /* will never match */ +#endif int gd_StatAt(const DIRFILE* D, int dirfd, const char* name, struct stat* buf, int flags) { @@ -100,7 +103,7 @@ dtrace("%p, %i, \"%s\", %p, %x", D, dirfd, name, buf, flags); path = _GD_MakeFullPathOnly(D, dirfd, name); -#if defined(HAVE_LSTAT) && defined(AT_SYMLINK_NOFOLLOW) +#ifdef HAVE_LSTAT if (flags & AT_SYMLINK_NOFOLLOW) ret = lstat(path, buf); else Modified: trunk/getdata/src/constant.c =================================================================== --- trunk/getdata/src/constant.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/constant.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2010, 2014 D. V. Wiebe * *************************************************************************** * @@ -20,16 +20,16 @@ */ #include "internal.h" -int gd_get_carray_slice(DIRFILE* D, const char *field_code_in, - unsigned int start, size_t n, gd_type_t return_type, void *data_out) +int gd_get_carray_slice(DIRFILE *D, const char *field_code_in, + unsigned long start, size_t n, gd_type_t return_type, void *data_out) gd_nothrow { gd_entry_t *entry; char* field_code; int repr; - dtrace("%p, \"%s\", %i, %" PRNsize_t ", 0x%x, %p", D, field_code_in, - (int)start, n, return_type, data_out); + dtrace("%p, \"%s\", %lu, %" PRNsize_t ", 0x%x, %p", D, field_code_in, start, + n, return_type, data_out); if (D->flags & GD_INVALID) { _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -118,7 +118,7 @@ int gd_get_constant(DIRFILE* D, const char *field_code_in, gd_type_t return_type, void *data_out) gd_nothrow { - return gd_get_carray_slice(D, field_code_in, 0, 1, return_type, data_out); + return gd_get_carray(D, field_code_in, return_type, data_out); } size_t gd_carray_len(DIRFILE *D, const char *field_code_in) gd_nothrow @@ -166,12 +166,12 @@ } static int _GD_PutCarraySlice(DIRFILE* D, gd_entry_t *E, int repr, - unsigned int first, size_t n, gd_type_t data_type, const void *data_in) + unsigned long first, size_t n, gd_type_t data_type, const void *data_in) gd_nothrow { int i; - dtrace("%p, %p, %i, %u, %" PRNsize_t ", 0x%X, %p", D, E, repr, first, n, + dtrace("%p, %p, %i, %lu, %" PRNsize_t ", 0x%X, %p", D, E, repr, first, n, data_type, data_in); if ((D->flags & GD_ACCMODE) != GD_RDWR) { @@ -206,15 +206,15 @@ } int gd_put_carray_slice(DIRFILE* D, const char *field_code_in, - unsigned int first, size_t n, gd_type_t data_type, const void *data_in) + unsigned long first, size_t n, gd_type_t data_type, const void *data_in) gd_nothrow { gd_entry_t *entry; - int repr, r = 1; + int repr, r = -1; char* field_code; - dtrace("%p, \"%s\", %u, %" PRNsize_t ", 0x%X, %p", D, field_code_in, first, n, - data_type, data_in); + dtrace("%p, \"%s\", %lu, %" PRNsize_t ", 0x%X, %p", D, field_code_in, first, + n, data_type, data_in); if (D->flags & GD_INVALID) { _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -250,7 +250,7 @@ const void *data_in) gd_nothrow { gd_entry_t *entry; - int repr, r = 1; + int repr, r = -1; char* field_code; dtrace("%p, \"%s\", 0x%x, %p", D, field_code_in, data_type, data_in); Modified: trunk/getdata/src/del.c =================================================================== --- trunk/getdata/src/del.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/del.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2012 D. V. Wiebe +/* Copyright (C) 2008-2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -213,6 +213,7 @@ case GD_STRING_ENTRY: case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_INDEX_ENTRY: case GD_ALIAS_ENTRY: break; Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/encoding.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2013 D. V. Wiebe +/* Copyright (C) 2008-2014 D. V. Wiebe * *************************************************************************** * @@ -641,7 +641,7 @@ if (scheme == gd_ef_[i].scheme) { file->subenc = i; dreturn("0x%08lx", gd_ef_[i].scheme); - return gd_ef_[i].scheme;; + return gd_ef_[i].scheme; } } Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/entry.c 2014-04-27 18:34:22 UTC (rev 887) @@ -23,6 +23,7 @@ void _GD_FreeE(DIRFILE *restrict D, gd_entry_t *restrict entry, int priv) { int i; + size_t n; dtrace("%p, %p, %i", D, entry, priv); @@ -77,6 +78,13 @@ if (priv) free(entry->e->u.string); break; + case GD_SARRAY_ENTRY: + if (priv) { + for (n = 0; n < entry->EN(scalar,array_len); ++n) + free(((char **)entry->e->u.scalar.d)[n]); + free(entry->e->u.scalar.d); + } + break; case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: if (priv) { @@ -103,12 +111,12 @@ free(entry->in_fields[0]); free(entry->in_fields[1]); break; + case GD_ALIAS_ENTRY: + free(entry->in_fields[0]); + break; case GD_INDEX_ENTRY: case GD_NO_ENTRY: break; - default: - if (entry->field_type == GD_ALIAS_ENTRY) - free(entry->in_fields[0]); } if (priv) { @@ -303,6 +311,7 @@ case GD_STRING_ENTRY: case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_INDEX_ENTRY: case GD_ALIAS_ENTRY: break; @@ -480,6 +489,7 @@ case GD_INDEX_ENTRY: case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_STRING_ENTRY: case GD_NO_ENTRY: case GD_ALIAS_ENTRY: @@ -826,6 +836,7 @@ case GD_RAW_ENTRY: case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_STRING_ENTRY: case GD_INDEX_ENTRY: case GD_NO_ENTRY: Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/errors.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2013 D. V. Wiebe + * Copyright (C) 2005-2014 D. V. Wiebe * *************************************************************************** * @@ -199,10 +199,13 @@ { GD_E_BAD_REPR, GD_E_REPR_UNKNOWN, "Unknown field representation: .{4}", 0 }, { GD_E_BAD_REPR, GD_E_REPR_PUT, "Unable to write to field reprentation: .{4}", 0 }, - /* GD_E_FLUSH: 3 = suberror, 4 = filename */ + /* GD_E_FLUSH: 3 = suberror */ { GD_E_FLUSH, GD_E_FLUSH_MKTMP, "I/O error creating temporary file: ", 1 }, { GD_E_FLUSH, GD_E_FLUSH_OPEN, "I/O error opening temporary file: ", 1 }, { GD_E_FLUSH, GD_E_FLUSH_RENAME, "I/O error replacing format metadata: ", 1 }, + { GD_E_FLUSH, GD_E_FLUSH_WRITE, "I/O error writing format metadata: ", 1 }, + { GD_E_FLUSH, GD_E_FLUSH_TOO_LONG, "Line too long writing format metadata", + 0 }, /* GD_E_BOUNDS: (nothing) */ { GD_E_BOUNDS, 0, "CARRAY length out of bounds", 0 }, /* GD_E_LINE_TOO_LONG: 2 = fragment, 3 = line number */ Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/flimits.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2012 D. V. Wiebe +/* Copyright (C) 2008-2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -330,6 +330,7 @@ break; case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_STRING_ENTRY: if (parent) _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_FORMAT, parent, 0, E->field); @@ -520,6 +521,7 @@ break; case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_STRING_ENTRY: if (parent) _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_FORMAT, parent, 0, E->field); Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/flush.c 2014-04-27 18:34:22 UTC (rev 887) @@ -79,6 +79,7 @@ _GD_Flush(D, E->e->entry[0], syn, clo); case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_STRING_ENTRY: case GD_INDEX_ENTRY: case GD_NO_ENTRY: @@ -222,22 +223,28 @@ return ptr; } -static size_t _GD_StringEscapeise(FILE *stream, const char *in, int meta, +static ssize_t _GD_StringEscapeise(FILE *stream, const char *in, int meta, int permissive, int standards) { const char* HexDigit = "0123456789ABCDEF"; - size_t len = 0; + ssize_t len = 0; - dtrace("%p, \"%s\", %i, %i", stream, in, permissive, standards); + dtrace("%p, \"%s\", %i, %i, %i", stream, in, meta, permissive, standards); if (in == NULL || in[0] == '\0') { - fputs("\"\"", stream); + if (stream) { + if (fputs("\"\"", stream) == EOF) + goto WRITE_ERR; + } + dreturn("%i", 2); return 2; } if (!permissive && standards < 6) { - fputs(in, stream); + if (stream) + if (fputs(in, stream) == EOF) + goto WRITE_ERR; dreturn("%" PRNsize_t, strlen(in)); return strlen(in); } @@ -251,80 +258,110 @@ #if CHAR_MIN != 0 && *in >= 0x00 #endif - ) { - fputs("\\x", stream); - fputc(HexDigit[*in >> 8], stream); - fputc(HexDigit[*in & 0xF], stream); + ) + { + if (stream) { + if (fputs("\\x", stream) == EOF) + goto WRITE_ERR; + if (fputc(HexDigit[*in >> 8], stream) == EOF) + goto WRITE_ERR; + if (fputc(HexDigit[*in & 0xF], stream) == EOF) + goto WRITE_ERR; + } len += 4; } else if (meta && *in == '/') break; else { - fputc(*in, stream); + if (stream) + if (fputc(*in, stream) == EOF) + goto WRITE_ERR; len++; } } dreturn("%" PRNsize_t, len); return len; + +WRITE_ERR: + dreturn("%i", -1); + return -1; } /* write a field code, taking care of stripping off affixes; returns the length * written */ -static size_t _GD_WriteFieldCode(DIRFILE *D, FILE *stream, int me, - const char *code, int permissive, int standards) +static ssize_t _GD_WriteFieldCode(DIRFILE *D, FILE *stream, int me, + const char *code, int permissive, int standards, int space) { int dummy; - size_t len; + ssize_t len; char *ptr; - dtrace("%p, %p, %i, \"%s\", %i, %i", D, stream, me, code, permissive, - standards); + dtrace("%p, %p, %i, \"%s\", %i, %i, %i", D, stream, me, code, permissive, + standards, space); ptr = _GD_MungeCode(D, NULL, D->fragment[me].prefix, D->fragment[me].suffix, NULL, NULL, code, &dummy, 0); len = _GD_StringEscapeise(stream, ptr, 0, permissive, standards); + /* append a space */ + if (space && len > 0) { + if (fputc(' ', stream) == EOF) + len = -1; + else + len++; + } + free(ptr); - dreturn("%" PRNsize_t, len); + dreturn("%" PRNssize_t, len); return len; } /* write a field, padding to the specified length */ -static void _GD_PadField(DIRFILE *D, FILE *stream, int me, const char *in, - size_t len, int permissive, int standards) +static ssize_t _GD_PadField(DIRFILE *D, FILE *stream, int me, const char *in, + ssize_t len, int permissive, int standards) { - size_t i; + ssize_t i; dtrace("%p, %p, %i, \"%s\", %" PRNsize_t ", %i, %i", D, stream, me, in, len, permissive, standards); - for (i = _GD_WriteFieldCode(D, stream, me, in, permissive, standards); - i < len; ++i) - { - fputc(' ', stream); - } + i = _GD_WriteFieldCode(D, stream, me, in, permissive, standards, 0); - dreturnvoid(); + if (i >= 0) + for (; i < len; ++i) + if (fputc(' ', stream) == EOF) { + i = -1; + break; + } + + dreturn("%" PRNssize_t, i); + return i; } /* Write a litteral parameter or CONST name or CARRAY element */ -static void _GD_WriteConst(DIRFILE *D, FILE* stream, int me, int permissive, - int type, const void* value, const char* scalar, int index, - const char* postamble) +static int _GD_WriteConst(DIRFILE *D, FILE *stream, int me, int permissive, + int type, const void* value, const char *scalar, int index, + const char *postamble) { + int e; + dtrace("%p, %p, %i, %i, 0x%X, %p, \"%s\", %i, \"%s\"", D, stream, me, permissive, type, value, scalar, index, postamble); if (scalar != NULL) { - _GD_WriteFieldCode(D, stream, me, scalar, permissive, D->standards); + if (_GD_WriteFieldCode(D, stream, me, scalar, permissive, D->standards, 0) + < 0) + { + dreturn("%i", -1); + return -1; + } if (index == -1) fprintf(stream, "%s", postamble); else fprintf(stream, "<%i>%s", index, postamble); - } - else if (type == GD_UINT64) + } else if (type == GD_UINT64) fprintf(stream, "%" PRIu64 "%s", *(uint64_t *)value, postamble); else if (type == GD_INT64) fprintf(stream, "%" PRIi64 "%s", *(int64_t *)value, postamble); @@ -341,260 +378,393 @@ else if (type == GD_COMPLEX128) fprintf(stream, "%.15g;%.15g%s", *(double *)value, ((double *)value)[1], postamble); - else + else { _GD_InternalError(D); + dreturn("%i", -1); + return -1; + } - dreturnvoid(); + e = ferror(stream); + dreturn("%i", e); + return e; } /* Write a field specification line */ -static void _GD_FieldSpec(DIRFILE* D, FILE* stream, const gd_entry_t* E, +static int _GD_FieldSpec(DIRFILE* D, FILE* stream, const gd_entry_t* E, int me, int meta, size_t max_len, int pretty, int permissive) { int i; + char *ptr; + ssize_t len, pos; + char buffer[1000]; size_t z; - char *ptr; dtrace("%p, %p, %p, %i, %i, %" PRNsize_t ", %i, %i", D, stream, E, me, meta, max_len, pretty, permissive); /* INDEX is implicit, and it is an error to define it in the format file */ if (E->field_type == GD_INDEX_ENTRY) { - dreturnvoid(); - return; + dreturn("%i", 0); + return 0; } /* aliases */ if (E->field_type == GD_ALIAS_ENTRY) { - fputs("/ALIAS ", stream); - _GD_WriteFieldCode(D, stream, me, E->field, permissive, D->standards); - fputc(' ', stream); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc('\n', stream); + if (fputs("/ALIAS ", stream) == EOF) + goto WRITE_ERR; + if (_GD_WriteFieldCode(D, stream, me, E->field, permissive, D->standards, 1) + < 0) + { + goto WRITE_ERR; + } + if (_GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 0) < 0) + { + goto WRITE_ERR; + } + if (fputc('\n', stream) == EOF) + goto WRITE_ERR; } else { ptr = E->field; /* From Standards Version 7 and on, just use Barth-style */ if (meta && D->standards < 7) { - fputs("META ", stream); - _GD_StringEscapeise(stream, ptr, 1, permissive, D->standards); - fputc(' ', stream); + if (fputs("META ", stream) == EOF) + goto WRITE_ERR; + if (_GD_StringEscapeise(stream, ptr, 1, permissive, D->standards) < 0) + goto WRITE_ERR; + if (fputc(' ', stream) == EOF) + goto WRITE_ERR; ptr = strchr(E->field, '/') + 1; } /* field name */ - _GD_PadField(D, stream, me, ptr, max_len, permissive, D->standards); + if (_GD_PadField(D, stream, me, ptr, max_len, permissive, D->standards) < 0) + goto WRITE_ERR; switch(E->field_type) { case GD_RAW_ENTRY: - 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_UINT_TYPE, &E->EN(raw,spf), - E->scalar[0], E->scalar_ind[0], "\n"); + if (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))) < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_UINT_TYPE, + &E->EN(raw,spf), E->scalar[0], E->scalar_ind[0], "") < 0) + { + goto WRITE_ERR; + } break; case GD_LINCOM_ENTRY: - fprintf(stream, " LINCOM%s %i", pretty ? " " : "", - E->EN(lincom,n_fields)); + if (fprintf(stream, " LINCOM%s %i ", pretty ? " " : "", + E->EN(lincom,n_fields)) < 0) + { + goto WRITE_ERR; + } for (i = 0; i < E->EN(lincom,n_fields); ++i) { - fputc(' ', stream); - _GD_WriteFieldCode(D, stream, me, E->in_fields[i], permissive, - D->standards); - fputc(' ', stream); + if (_GD_WriteFieldCode(D, stream, me, E->in_fields[i], permissive, + D->standards, 1) < 0) + { + goto WRITE_ERR; + } + if (E->flags & GD_EN_COMPSCAL) { - _GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, - &E->EN(lincom,cm)[i], E->scalar[i], E->scalar_ind[i], " "); - _GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, - &E->EN(lincom,cb)[i], E->scalar[i + GD_MAX_LINCOM], - E->scalar_ind[i + GD_MAX_LINCOM], ""); + if (_GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, + &E->EN(lincom,cm)[i], E->scalar[i], E->scalar_ind[i], " ") < 0 + || _GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, + &E->EN(lincom,cb)[i], E->scalar[i + GD_MAX_LINCOM], + E->scalar_ind[i + GD_MAX_LINCOM], + i == E->EN(lincom,n_fields) - 1 ? "" : " ") < 0) + { + goto WRITE_ERR; + } } else { - _GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, - &E->EN(lincom,m)[i], E->scalar[i], E->scalar_ind[i], " "); - _GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, - &E->EN(lincom,b)[i], E->scalar[i + GD_MAX_LINCOM], - E->scalar_ind[i + GD_MAX_LINCOM], ""); + if (_GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, + &E->EN(lincom,m)[i], E->scalar[i], E->scalar_ind[i], " ") < 0 + || _GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, + &E->EN(lincom,b)[i], E->scalar[i + GD_MAX_LINCOM], + E->scalar_ind[i + GD_MAX_LINCOM], + i == E->EN(lincom,n_fields) - 1 ? "" : " ") < 0) + { + goto WRITE_ERR; + } } } - fputc('\n', stream); break; case GD_LINTERP_ENTRY: - fprintf(stream, " LINTERP%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_StringEscapeise(stream, E->EN(linterp,table), 0, permissive, - D->standards); - fputc('\n', stream); + if (fprintf(stream, " LINTERP%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_StringEscapeise(stream, E->EN(linterp,table), 0, permissive, + D->standards) < 0) + { + goto WRITE_ERR; + } break; case GD_BIT_ENTRY: - fprintf(stream, " BIT%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, - &E->EN(bit,bitnum), E->scalar[0], E->scalar_ind[0], " "); - _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, - &E->EN(bit,numbits), E->scalar[1], E->scalar_ind[1], "\n"); + if (fprintf(stream, " BIT%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, + &E->EN(bit,bitnum), E->scalar[0], E->scalar_ind[0], " ") < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, + &E->EN(bit,numbits), E->scalar[1], E->scalar_ind[1], "") < 0) + { + goto WRITE_ERR; + } break; case GD_DIVIDE_ENTRY: - fprintf(stream, " DIVIDE%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, - D->standards); - fputc('\n', stream); + if (fprintf(stream, " DIVIDE%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, + D->standards, 0) < 0) + { + goto WRITE_ERR; + } break; case GD_RECIP_ENTRY: - fprintf(stream, " RECIP%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, - &E->EN(recip,cdividend), E->scalar[0], E->scalar_ind[0], "\n"); + if (fprintf(stream, " RECIP%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, + &E->EN(recip,cdividend), E->scalar[0], E->scalar_ind[0], "") < 0) + { + goto WRITE_ERR; + } break; case GD_MULTIPLY_ENTRY: - fputs(" MULTIPLY ", stream); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, - D->standards); - fputc('\n', stream); + if (fputs(" MULTIPLY ", stream) == EOF || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, + D->standards, 0) < 0) + { + goto WRITE_ERR; + } break; case GD_PHASE_ENTRY: - fprintf(stream, " PHASE%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteConst(D, stream, me, permissive, GD_INT64, &E->EN(phase,shift), - E->scalar[0], E->scalar_ind[0], "\n"); + if (fprintf(stream, " PHASE%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_INT64, + &E->EN(phase,shift), E->scalar[0], E->scalar_ind[0], "") < 0) + { + goto WRITE_ERR; + } break; case GD_POLYNOM_ENTRY: - fprintf(stream, " POLYNOM%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); + if (fprintf(stream, " POLYNOM%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0) + { + goto WRITE_ERR; + } for (i = 0; i <= E->EN(polynom,poly_ord); ++i) - if (E->flags & GD_EN_COMPSCAL) - _GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, + if (E->flags & GD_EN_COMPSCAL) { + if (_GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, &E->EN(polynom,ca)[i], E->scalar[i], E->scalar_ind[i], - (i == E->EN(polynom,poly_ord)) ? "\n" : " "); - else - _GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, + (i == E->EN(polynom,poly_ord)) ? "" : " ") < 0) + { + goto WRITE_ERR; + } + } else { + if (_GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, &E->EN(polynom,a)[i], E->scalar[i], E->scalar_ind[i], - (i == E->EN(polynom,poly_ord)) ? "\n" : " "); + (i == E->EN(polynom,poly_ord)) ? "" : " ") < 0) + { + goto WRITE_ERR; + } + } break; case GD_SBIT_ENTRY: - fprintf(stream, " SBIT%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, - &E->EN(bit,bitnum), E->scalar[0], E->scalar_ind[0], " "); - _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, - &E->EN(bit,numbits), E->scalar[1], E->scalar_ind[1], "\n"); + if (fprintf(stream, " SBIT%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, + &E->EN(bit,bitnum), E->scalar[0], E->scalar_ind[0], " ") < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, + &E->EN(bit,numbits), E->scalar[1], E->scalar_ind[1], "") < 0) + { + goto WRITE_ERR; + } break; case GD_WINDOW_ENTRY: - fprintf(stream, " WINDOW%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, - D->standards); - fprintf(stream, " %s ", _GD_WindopName(D, E->EN(window,windop))); + if (fprintf(stream, " WINDOW%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, + D->standards, 0) < 0 || + fprintf(stream, " %s ", _GD_WindopName(D, E->EN(window,windop))) + < 0) + { + goto WRITE_ERR; + } switch (E->EN(window,windop)) { case GD_WINDOP_EQ: case GD_WINDOP_NE: - _GD_WriteConst(D, stream, me, permissive, GD_INT64, - &E->EN(window,threshold.i), E->scalar[0], E->scalar_ind[0], - "\n"); + if (_GD_WriteConst(D, stream, me, permissive, GD_INT64, + &E->EN(window,threshold.i), E->scalar[0], E->scalar_ind[0], + "") < 0) + { + goto WRITE_ERR; + } break; case GD_WINDOP_SET: case GD_WINDOP_CLR: - _GD_WriteConst(D, stream, me, permissive, GD_UINT64, + if (_GD_WriteConst(D, stream, me, permissive, GD_UINT64, &E->EN(window,threshold.u), E->scalar[0], E->scalar_ind[0], - "\n"); + "") < 0) + { + goto WRITE_ERR; + } break; default: - _GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, + if (_GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, &E->EN(window,threshold.r), E->scalar[0], E->scalar_ind[0], - "\n"); + "") < 0) + { + goto WRITE_ERR; + } break; } break; case GD_MPLEX_ENTRY: - fprintf(stream, " MPLEX%s ", pretty ? " " : ""); - _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, - D->standards); - fputc(' ', stream); - _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, - &E->EN(mplex,count_val), E->scalar[0], E->scalar_ind[0], ""); - if (E->EN(mplex,period) > 0 || E->scalar[1]) { - fputc(' ', stream); - _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, - &E->EN(mplex,period), E->scalar[1], E->scalar_ind[1], "\n"); - } else - fputc('\n', stream); + if (fprintf(stream, " MPLEX%s ", pretty ? " " : "") < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + D->standards, 1) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], permissive, + D->standards, 1) < 0 || + _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, + &E->EN(mplex,count_val), E->scalar[0], E->scalar_ind[0], " ") < 0 + || _GD_WriteConst(D, stream, me, permissive, GD_INT_TYPE, + &E->EN(mplex,period), E->scalar[1], E->scalar_ind[1], "") < 0) + { + goto WRITE_ERR; + } break; case GD_CONST_ENTRY: - fprintf(stream, " CONST%s %s ", pretty ? " " : "", _GD_TypeName(D, - E->EN(scalar,const_type))); - if (E->EN(scalar,const_type) & GD_SIGNED) - fprintf(stream, "%" PRIi64 "\n", *(int64_t*)E->e->u.scalar.d); - else if (E->EN(scalar,const_type) & GD_IEEE754) - fprintf(stream, "%.15g\n", *(double*)E->e->u.scalar.d); - else if (E->EN(scalar,const_type) & GD_COMPLEX) - fprintf(stream, "%.15g;%.15g\n", *(double*)E->e->u.scalar.d, - *((double*)E->e->u.scalar.d + 1)); - else - fprintf(stream, "%" PRIu64 "\n", *(uint64_t*)E->e->u.scalar.d); + if (fprintf(stream, " CONST%s %s ", pretty ? " " : "", _GD_TypeName(D, + E->EN(scalar,const_type))) < 0) + { + goto WRITE_ERR; + } + if (E->EN(scalar,const_type) & GD_SIGNED) { + if (fprintf(stream, "%" PRIi64, *(int64_t*)E->e->u.scalar.d) < 0) + goto WRITE_ERR; + } else if (E->EN(scalar,const_type) & GD_IEEE754) { + if (fprintf(stream, "%.15g", *(double*)E->e->u.scalar.d) < 0) + goto WRITE_ERR; + } else if (E->EN(scalar,const_type) & GD_COMPLEX) { + if (fprintf(stream, "%.15g;%.15g", *(double*)E->e->u.scalar.d, + *((double*)E->e->u.scalar.d + 1)) < 0) + { + goto WRITE_ERR; + } + } else + if (fprintf(stream, "%" PRIu64, *(uint64_t*)E->e->u.scalar.d) < 0) + goto WRITE_ERR; break; case GD_CARRAY_ENTRY: - fprintf(stream, " CARRAY%s %s", pretty ? " " : "", _GD_TypeName(D, - E->EN(scalar,const_type))); - if (E->EN(scalar,const_type) & GD_SIGNED) - for (z = 0; z < E->EN(scalar,array_len); ++z) - fprintf(stream, " %" PRIi64, ((int64_t*)E->e->u.scalar.d)[z]); - else if (E->EN(scalar,const_type) & GD_IEEE754) - for (z = 0; z < E->EN(scalar,array_len); ++z) - fprintf(stream, " %.15g", ((double*)E->e->u.scalar.d)[z]); - else if (E->EN(scalar,const_type) & GD_COMPLEX) - for (z = 0; z < E->EN(scalar,array_len); ++z) - fprintf(stream, " %.15g;%.15g", ((double*)E->e->u.scalar.d)[2 * z], + pos = fprintf(stream, " CARRAY%s %s", pretty ? " " : "", + _GD_TypeName(D, E->EN(scalar,const_type))); + if (pos < 0) + goto WRITE_ERR; + + for (z = 0; z < E->EN(scalar,array_len); ++z) { + if (E->EN(scalar,const_type) & GD_SIGNED) + len = sprintf(buffer, " %" PRIi64, ((int64_t*)E->e->u.scalar.d)[z]); + else if (E->EN(scalar,const_type) & GD_IEEE754) + len = sprintf(buffer, " %.15g", ((double*)E->e->u.scalar.d)[z]); + else if (E->EN(scalar,const_type) & GD_COMPLEX) + len = sprintf(buffer, " %.15g;%.15g", + ((double*)E->e->u.scalar.d)[2 * z], ((double*)E->e->u.scalar.d)[2 * z + 1]); - else - for (z = 0; z < E->EN(scalar,array_len); ++z) - fprintf(stream, " %" PRIu64, ((uint64_t*)E->e->u.scalar.d)[z]); - fputc('\n', stream); + else + len = sprintf(buffer, " %" PRIu64, + ((uint64_t*)E->e->u.scalar.d)[z]); + + /* don't write lines that are too long + * also, add one to length for the trailing '\n' */ + if (GD_SSIZE_T_MAX - (len + 1) <= pos) { + _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_TOO_LONG, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + if (fputs(buffer, stream) == EOF) + goto WRITE_ERR; + } break; case GD_STRING_ENTRY: - fprintf(stream, " STRING%s ", pretty ? " " : ""); - _GD_StringEscapeise(stream, E->e->u.string, 0, permissive, - D->standards); - fputc('\n', stream); + if (fprintf(stream, " STRING%s ", pretty ? " " : "") < 0) + goto WRITE_ERR; + if (_GD_StringEscapeise(stream, E->e->u.string, 0, permissive, + D->standards) < 0) + { + goto WRITE_ERR; + } break; + case GD_SARRAY_ENTRY: + pos = fprintf(stream, " SARRAY%s", pretty ? " " : ""); + if (pos < 0) + goto WRITE_ERR; + + for (z = 0; z < E->EN(scalar,array_len); ++z) { + if (fputc(' ', stream) == EOF) + goto WRITE_ERR; + pos++; + + /* compute length */ + len = _GD_StringEscapeise(NULL, ((char**)E->e->u.scalar.d)[z], 0, + permissive, D->standards); + + /* don't write lines that are too long + * also, add one to length for the trailing '\n' */ + if (GD_SSIZE_T_MAX - (len + 1) <= pos) { + _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_TOO_LONG, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + + if (_GD_StringEscapeise(stream, ((char**)E->e->u.scalar.d)[z], 0, + permissive, D->standards) < 0) + { + goto WRITE_ERR; + } + } + break; case GD_INDEX_ENTRY: case GD_ALIAS_ENTRY: case GD_NO_ENTRY: _GD_InternalError(D); - break; + dreturn("%i", -1); + return -1; } + + if (fputc('\n', stream) == EOF) + goto WRITE_ERR; } if (!D->error && (E->flags & GD_EN_HIDDEN) && (permissive || D->standards >= 9)) { - fputs("/HIDDEN ", stream); - _GD_WriteFieldCode(D, stream, me, E->field, permissive, D->standards); - fputc('\n', stream); + if (fputs("/HIDDEN ", stream) == EOF) + goto WRITE_ERR; + if (_GD_WriteFieldCode(D, stream, me, E->field, permissive, D->standards, 0) + < 0) + { + goto WRITE_ERR; + } + if (fputc('\n', stream) == EOF) + goto WRITE_ERR; } - dreturnvoid(); + dreturn("%i", 0); + return 0; + +WRITE_ERR: + if (!D->error) + _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_WRITE, NULL, errno, NULL); + dreturn("%i", -1); + return -1; } static void _GD_FlushFragment(DIRFILE* D, int i, int permissive) @@ -607,7 +777,7 @@ struct tm now; int fd, dummy; int pretty = 0; - size_t max_len = 0; + ssize_t max_len = 0; unsigned int u; #ifdef HAVE_FCHMOD mode_t mode; @@ -629,25 +799,25 @@ /* open a temporary file */ fd = _GD_MakeTempFile(D, dirfd, temp_file); if (fd == -1) { - _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_MKTMP, NULL, errno, temp_file); + _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_MKTMP, NULL, errno, NULL); dreturnvoid(); return; } stream = fdopen(fd, "wb+"); if (stream == NULL) { - _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_OPEN, NULL, errno, temp_file); + _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_OPEN, NULL, errno, NULL); dreturnvoid(); return; } if (D->flags & GD_PRETTY_PRINT) { size_t t = 0; - size_t m = 0; + ssize_t m = 0; int n = 0; pretty = 1; for (u = 0; u < D->n_entries; ++u) if (D->entry[u]->fragment_index == i && D->entry[u]->e->n_meta != -1) { - size_t l = strlen(D->entry[u]->field); + ssize_t l = strlen(D->entry[u]->field); if (m < l) m = l; t += l; @@ -664,93 +834,141 @@ t = time(NULL); strftime(buffer, GD_MAX_LINE_LENGTH, "%c", gmtime_r(&t, &now)); - fprintf(stream, "# This is a dirfile format file.\n" + if (fprintf(stream, "# This is a dirfile format file.\n" "# It was written using version %s of the GetData Library.\n" - "# Written on %s UTC", PACKAGE_VERSION, buffer); + "# Written on %s UTC", PACKAGE_VERSION, buffer) < 0) + { + goto WRITE_ERR; + } - if ((ptr = getenv("LOGNAME")) != NULL) { - fprintf(stream, " by %s", ptr); + ptr = getenv("LOGNAME"); + if (ptr == NULL) + ptr = getenv("USER"); + + if (ptr != NULL) { + if (fprintf(stream, " by %s", ptr) < 0) + goto WRITE_ERR; if ((ptr = getenv("HOSTNAME")) != NULL) - fprintf(stream, "@%s", ptr); + if (fprintf(stream, "@%s", ptr) < 0) + goto WRITE_ERR; } - fputs(".\n\n", stream); + if (fputs(".\n\n", stream) == EOF) + goto WRITE_ERR; - if (permissive) - fprintf(stream, "# WARNING: This fragment may not conform to any " - "Dirfile Standards Version.\n"); - else if (D->standards >= 5) - fprintf(stream, "/VERSION %i\n", D->standards); - else - fprintf(stream, "# This fragment conforms to " - "Dirfile Standards Version %i.\n", D->standards); + /* version */ + if (permissive) { + if (fprintf(stream, "# WARNING: This file may not conform to any " + "Dirfile Standards Version.\n") < 0) + { + goto WRITE_ERR; + } + } else if (D->standards >= 5) { + if (fprintf(stream, "/VERSION %i\n", D->standards) < 0) + goto WRITE_ERR; + } else + if (fprintf(stream, + "# This file conforms to Dirfile Standards Version %i.\n", + D->standards) < 0) + { + goto WRITE_ERR; + } /* Byte Sex */ if (permissive || D->standards >= 5) - fprintf(stream, "/ENDIAN %s%s\n", - (D->fragment[i].byte_sex & GD_LITTLE_ENDIAN) ? "little" : "big", - ((permissive || D->standards >= 8) && - (D->fragment[i].byte_sex & GD_ARM_FLAG) == GD_ARM_ENDIAN) ? " arm" : - ""); + if (fprintf(stream, "/ENDIAN %s%s\n", + (D->fragment[i].byte_sex & GD_LITTLE_ENDIAN) ? "little" : "big", + ((permissive || D->standards >= 8) && + (D->fragment[i].byte_sex & GD_ARM_FLAG) == GD_ARM_ENDIAN) ? " arm" : + "") < 0) + { + goto WRITE_ERR; + } + /* Protection */ if (permissive || D->standards >= 6) { - if (D->fragment[i].protection == GD_PROTECT_NONE) - fputs("/PROTECT none\n", stream); - else if (D->fragment[i].protection == GD_PROTECT_FORMAT) - fputs("/PROTECT format\n", stream); - else if (D->fragment[i].protection == GD_PROTECT_DATA) - fputs("/PROTECT data\n", stream); - else - fputs("/PROTECT all\n", stream); + if (D->fragment[i].protection == GD_PROTECT_NONE) { + if (fputs("/PROTECT none\n", stream) == EOF) + goto WRITE_ERR; + } else if (D->fragment[i].protection == GD_PROTECT_FORMAT) { + if (fputs("/PROTECT format\n", stream) == EOF) + goto WRITE_ERR; + } else if (D->fragment[i].protection == GD_PROTECT_DATA) { + if (fputs("/PROTECT data\n", stream) == EOF) + goto WRITE_ERR; + } else { + if (fputs("/PROTECT all\n", stream) == EOF) + goto WRITE_ERR; + } } + /* Frame offset */ if (permissive || D->standards >= 1) if (D->fragment[i].frame_offset != 0) - fprintf(stream, "%sFRAMEOFFSET %llu\n", (D->standards >= 5) ? "/" : "", - (unsigned long long)D->fragment[i].frame_offset); + if (fprintf(stream, "%sFRAMEOFFSET %llu\n", + (D->standards >= 5) ? "/" : "", + (unsigned long long)D->fragment[i].frame_offset) < 0) + { + goto WRITE_ERR; + } + /* Encoding */ if (permissive || D->standards >= 6) { + const char *encoding = NULL; + int use_encdat = 0; switch(D->fragment[i].encoding) { case GD_UNENCODED: - fputs("/ENCODING none\n", stream); + encoding = "none"; break; case GD_BZIP2_ENCODED: - fputs("/ENCODING bzip2\n", stream); + encoding = "bzip2"; break; case GD_GZIP_ENCODED: - fputs("/ENCODING gzip\n", stream); + encoding = "gzip"; break; case GD_LZMA_ENCODED: - fputs("/ENCODING lzma\n", stream); + encoding = "lzma"; break; case GD_SLIM_ENCODED: - fputs("/ENCODING slim\n", stream); + encoding = "slim"; break; case GD_TEXT_ENCODED: - fputs("/ENCODING text\n", stream); + encoding = "text"; break; case GD_SIE_ENCODED: - fputs("/ENCODING sie\n", stream); + encoding = "sie"; break; case GD_ZZIP_ENCODED: - if (D->fragment[i].enc_data) - fprintf(stream, "/ENCODING zzip %s\n", - (char*)D->fragment[i].enc_data); - else - fputs("/ENCODING zzip\n", stream); + encoding = "zzip"; + use_encdat = 1; break; case GD_ZZSLIM_ENCODED: - if (D->fragment[i].enc_data) - fprintf(stream, "/ENCODING zzslim %s\n", - (char*)D->fragment[i].enc_data); - else - fputs("/ENCODING zzslim\n", stream); + encoding = "zzslim"; + use_encdat = 1; break; case GD_AUTO_ENCODED: /* an unresolved, auto-encoded fragment */ break; default: - fprintf(stream, "/ENCODING unknown # (%lx)\n", D->fragment[i].encoding); + if (fprintf(stream, "/ENCODING unknown # (%lx)\n", + D->fragment[i].encoding) < 0) + { + goto WRITE_ERR; + } break; } + + if (encoding != NULL) { + if (use_encdat && D->fragment[i].enc_data) { + + if (fprintf(stream, "/ENCODING %s %s\n", encoding, + (char*)D->fragment[i].enc_data) < 0) + { + goto WRITE_ERR; + } + } else { + if (fprintf(stream, "/ENCODING %s\n", encoding) < 0) + goto WRITE_ERR; + } + } } /* The includes */ @@ -762,60 +980,84 @@ char *suffix = _GD_MungeCode(D, NULL, NULL, D->fragment[i].suffix, NULL, NULL, D->fragment[j].suffix, &dummy, 0); - fprintf(stream, "%sINCLUDE ", (D->standards >= 5) ? "/" : ""); - _GD_StringEscapeise(stream, D->fragment[j].ename, 0, permissive, - D->standards); + if (fprintf(stream, "%sINCLUDE ", (D->standards >= 5) ? "/" : "") < 0 || + _GD_StringEscapeise(stream, D->fragment[j].ename, 0, permissive, + D->standards) < 0) + { + goto WRITE_ERR; + } if (prefix || suffix) { - fputc(' ', stream); - _GD_StringEscapeise(stream, prefix, 0, permissive, D->standards); + if (fputc(' ', stream) == EOF || _GD_StringEscapeise(stream, prefix, + 0, permissive, D->standards) < 0) + { + goto WRITE_ERR; + } free(prefix); } if (suffix) { - fputc(' ', stream); - _GD_StringEscapeise(stream, suffix, 0, permissive, D->standards); + if (fputc(' ', stream) == EOF || _GD_StringEscapeise(stream, suffix, + 0, permissive, D->standards) < 0) + { + goto WRITE_ERR; + } free(suffix); } - fputc('\n', stream); + if (fputc('\n', stream) == EOF) + goto WRITE_ERR; } /* The fields */ for (u = 0; u < D->n_entries; ++u) if (D->entry[u]->fragment_index == i && D->entry[u]->e->n_meta != -1) { - _GD_FieldSpec(D, stream, D->entry[u], i, 0, max_len, pretty, permissive); + if (_GD_FieldSpec(D, stream, D->entry[u], i, 0, max_len, pretty, + permissive) < 0) + { + goto WRITE_ERR; + } if (permissive || D->standards >= 6) for (j = 0; j < D->entry[u]->e->n_meta; ++j) - _GD_FieldSpec(D, stream, D->entry[u]->e->p.meta_entry[j], i, 1, 0, - pretty, permissive); + if (_GD_FieldSpec(D, stream, D->entry[u]->e->p.meta_entry[j], i, 1, 0, + pretty, permissive) < 0) + { + goto WRITE_ERR; + } } /* REFERENCE is written at the end, because its effect can propagate * upwards */ if (permissive || D->standards >= 6) if (D->fragment[i].ref_name != NULL) { - fputs("/REFERENCE ", stream); - _GD_WriteFieldCode(D, stream, i, D->fragment[i].ref_name, permissive, - D->standards); - fputc('\n', stream); + if (fputs("/REFERENCE ", stream) == EOF || + _GD_WriteFieldCode(D, stream, i, D->fragment[i].ref_name, permissive, + D->standards, 0) < 0 || fputc('\n', stream) == EOF) + { + goto WRITE_ERR; + } } - /* That's all; flush, sync, and close */ - fflush(stream); - fsync(fd); + /* That's all */ #ifdef HAVE_FCHMOD - fchmod(fd, mode); + if (fchmod(fd, mode)) + goto WRITE_ERR; #endif - fclose(stream); + /* if there's no error, try closing */ + if (ferror(stream) || fclose(stream) == EOF) { +WRITE_ERR: + if (!D->error) + _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_WRITE, NULL, errno, NULL); + fclose(stream); + } + /* If no error was encountered, move the temporary file over the * old format file, otherwise abort */ /* Only assume we've synced the file if the rename succeeds */ if (D->error != GD_E_OK) - gd_UnlinkAt(D, dirfd, temp_file, 0); + ;//gd_UnlinkAt(D, dirfd, temp_file, 0); else if (gd_RenameAt(D, dirfd, temp_file, dirfd, D->fragment[i].bname)) { - _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_RENAME, NULL, errno, - D->fragment[i].cname); + _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_RENAME, NULL, errno, NULL); gd_UnlinkAt(D, dirfd, temp_file, 0); } else D->fragment[i].modified = 0; @@ -977,6 +1219,7 @@ #define GD_VERS_GE_7 0xFFFFFF80UL #define GD_VERS_GE_8 0xFFFFFF00UL #define GD_VERS_GE_9 0xFFFFFE00UL +#define GD_VERS_GE_10 0xFFFFFC00UL #define GD_VERS_LE_0 0x00000001UL #define GD_VERS_LE_1 0x00000003UL @@ -988,6 +1231,7 @@ #define GD_VERS_LE_7 0x000000ffUL #define GD_VERS_LE_8 0x000001ffUL #define GD_VERS_LE_9 0x000003ffUL +#define GD_VERS_LE_10 0x000007ffUL uint64_t _GD_FindVersion(DIRFILE *D) { @@ -1073,6 +1317,9 @@ case GD_STRING_ENTRY: D->av &= GD_VERS_GE_6; break; + case GD_SARRAY_ENTRY: + D->av &= GD_VERS_GE_10; + break; case GD_BIT_ENTRY: if (D->entry[i]->EN(bit,numbits) > 1) D->av &= GD_VERS_GE_1; Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/fpos.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011-2013 D. V. Wiebe +/* Copyright (C) 2011-2014 D. V. Wiebe * *************************************************************************** * @@ -106,6 +106,7 @@ case GD_CONST_ENTRY: case GD_STRING_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_ALIAS_ENTRY: _GD_InternalError(D); } @@ -312,6 +313,7 @@ case GD_CONST_ENTRY: case GD_STRING_ENTRY: case GD_CARRAY_ENTRY: + case GD_SARRAY_ENTRY: case GD_ALIAS_ENTRY: _GD_InternalError(D); } Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2014-04-12 19:20:16 UTC (rev 886) +++ trunk/getdata/src/getdata.c 2014-04-27 18:34:22 UTC (rev 887) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2013 D. V. Wiebe + * Copyright (C) 2005-2014 D. V. Wiebe * *************************************************************************** * @@ -1928,6 +1928,7 @@ n_read = _GD_DoConst(D, E, first_samp, num_samp, return_type, data_out); break; case GD_STRING_ENTRY: + case GD_SARRAY_ENTRY: case GD_ALIAS_ENTRY: case GD_NO_ENTRY: /* Can't get here */ Modified: trunk/getdata/src/getdata.h.in =================================================... [truncated message content] |
From: <ket...@us...> - 2014-04-12 19:20:19
|
Revision: 886 http://sourceforge.net/p/getdata/code/886 Author: ketiltrout Date: 2014-04-12 19:20:16 +0000 (Sat, 12 Apr 2014) Log Message: ----------- svn:ignore Property Changed: ---------------- trunk/getdata/ Index: trunk/getdata =================================================================== --- trunk/getdata 2014-04-12 19:19:46 UTC (rev 885) +++ trunk/getdata 2014-04-12 19:20:16 UTC (rev 886) Property changes on: trunk/getdata ___________________________________________________________________ Modified: svn:ignore ## -29,3 +29,4 ## README.txt config.lt compile +test-driver This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-12 19:19:50
|
Revision: 885 http://sourceforge.net/p/getdata/code/885 Author: ketiltrout Date: 2014-04-12 19:19:46 +0000 (Sat, 12 Apr 2014) Log Message: ----------- Bugs. Modified Paths: -------------- trunk/getdata/bindings/perl/GetData.xs Modified: trunk/getdata/bindings/perl/GetData.xs =================================================================== --- trunk/getdata/bindings/perl/GetData.xs 2014-04-12 19:19:33 UTC (rev 884) +++ trunk/getdata/bindings/perl/GetData.xs 2014-04-12 19:19:46 UTC (rev 885) @@ -284,7 +284,7 @@ croak("%s::%s() - Key 'in_fields' must be list or string in entry hash", pkg, func); } else { - int have[GD_MAX_LINCOM]; + int have[GD_MAX_LINCOM * 2]; memset(have, 0, sizeof(int) * GD_MAX_LINCOM * 2); @@ -305,7 +305,7 @@ if (n < min || n > max) { croak("%s::%s() - Bad array length (%i) for key 'in_fields' in entry hash", - n, pkg, func); + pkg, func, n); } dreturn("%i", n); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-12 19:19:37
|
Revision: 884 http://sourceforge.net/p/getdata/code/884 Author: ketiltrout Date: 2014-04-12 19:19:33 +0000 (Sat, 12 Apr 2014) Log Message: ----------- Zend engine 2.3 Modified Paths: -------------- trunk/getdata/bindings/php/getdata.c trunk/getdata/bindings/php/php_getdata.h Modified: trunk/getdata/bindings/php/getdata.c =================================================================== --- trunk/getdata/bindings/php/getdata.c 2014-04-04 00:09:31 UTC (rev 883) +++ trunk/getdata/bindings/php/getdata.c 2014-04-12 19:19:33 UTC (rev 884) @@ -32,13 +32,13 @@ #endif /* PHP globals */ -ZEND_DECLARE_MODULE_GLOBALS(getdata) - ZEND_BEGIN_MODULE_GLOBALS(getdata) zend_bool degrade_complex; zend_bool unpack; ZEND_END_MODULE_GLOBALS(getdata) +ZEND_DECLARE_MODULE_GLOBALS(getdata) + #ifdef ZTS # define GDPHP_G(v) TSRMG(getdata_globals_id, zend_getdata_globals *, v) # define dtracetsrm(fmt, ...) dtrace(fmt ", %p", __VA_ARGS__, tsrm_ls) Modified: trunk/getdata/bindings/php/php_getdata.h =================================================================== --- trunk/getdata/bindings/php/php_getdata.h 2014-04-04 00:09:31 UTC (rev 883) +++ trunk/getdata/bindings/php/php_getdata.h 2014-04-12 19:19:33 UTC (rev 884) @@ -51,6 +51,14 @@ #include "TSRM.h" #endif +#ifndef PHP_FE_END +#define PHP_FE_END ZEND_FE_END +#endif + +#ifndef ZEND_FE_END +#define ZEND_FE_END { NULL, NULL, NULL, 0, 0 } +#endif + void gdphp_register_constants(int module_number); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-04-04 00:09:37
|
Revision: 883 http://sourceforge.net/p/getdata/code/883 Author: ketiltrout Date: 2014-04-04 00:09:31 +0000 (Fri, 04 Apr 2014) Log Message: ----------- Don't duplicate code between the C99 and C89 gd_add_crecip, gd_madd_crecip, gd_alter_crecip functions. Fix calcuation of GD_MAX_CARRAY_LENGTH. Minor doc fixes. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/bindings/idl/test/getdata_idl_test_routines.pro trunk/getdata/man/gd_add.3 trunk/getdata/man/gd_add_bit.3 trunk/getdata/man/gd_alter_bit.3 trunk/getdata/man/gd_alter_spec.3 trunk/getdata/man/gd_bof64.3 trunk/getdata/man/gd_cbopen.3 trunk/getdata/man/gd_eof64.3 trunk/getdata/man/gd_framenum_subset64.3 trunk/getdata/man/gd_frameoffset64.3 trunk/getdata/man/gd_getdata64.3 trunk/getdata/man/gd_madd_bit.3 trunk/getdata/man/gd_nframes64.3 trunk/getdata/man/gd_putdata64.3 trunk/getdata/man/gd_seek64.3 trunk/getdata/man/gd_tell64.3 trunk/getdata/src/add.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/mod.c trunk/getdata/src/parse.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/ChangeLog 2014-04-04 00:09:31 UTC (rev 883) @@ -1,3 +1,9 @@ +2014-04-03 D. V. Wiebe <ge...@ke...> svn:883 + * src/add.c (gd_add_crecip gd_madd_crecip) src/mod.c (gd_alter_crecip): Call + the ...crecip89 function. + + * src/getdata.h.in: Fix GD_MAX_CARRAY_LENGTH computation. + 2014-03-20 D. V. Wiebe <ge...@ke...> svn:882 * bindings/php/getdata.c (gd_add_polynom gd_madd_polynom): Fix array size. * bindings/python/pydirfile.c (gdpy_dirfile_getentry): Fix segfault. Modified: trunk/getdata/bindings/idl/test/getdata_idl_test_routines.pro =================================================================== --- trunk/getdata/bindings/idl/test/getdata_idl_test_routines.pro 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/bindings/idl/test/getdata_idl_test_routines.pro 2014-04-04 00:09:31 UTC (rev 883) @@ -1,3 +1,25 @@ +; vim: ft=idlang +; +; Copyright (C) 2009-2011 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 + pro timed_demo_mode print,"" print,"**********************************************" Modified: trunk/getdata/man/gd_add.3 =================================================================== --- trunk/getdata/man/gd_add.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_add.3 2014-04-04 00:09:31 UTC (rev 883) @@ -205,8 +205,9 @@ to the value of the symbol GD_MAX_CARRAY_LENGTH defined in getdata.h. This is done to be certain that the .B CARRAY -won't overrun the line when flushed to disk. On a 32-bit system, this number -is 2**24. It is larger on a 64-bit system. +won't overrun the line when flushed to disk. On platforms with a \fIn\fR-bit +.BR size_t , +GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. .SH SEE ALSO .BR gd_add_bit (3), Modified: trunk/getdata/man/gd_add_bit.3 =================================================================== --- trunk/getdata/man/gd_add_bit.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_add_bit.3 2014-04-04 00:09:31 UTC (rev 883) @@ -307,8 +307,9 @@ to the value of the symbol GD_MAX_CARRAY_LENGTH defined in getdata.h. This is done to be certain that the .B CARRAY -won't overrun the line when flushed to disk. On a 32-bit system, this number -is 2**24. It is larger on a 64-bit system. +won't overrun the line when flushed to disk. On platforms with a \fIn\fR-bit +.BR size_t , +GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. The C89 GetData API provides different prototypes for .BR gd_add_clincom "(), " gd_add_cpolynom (), @@ -317,6 +318,7 @@ .PP .nf .B #define GD_C89_API +.br .B #include <getdata.h> .fi .HP @@ -328,10 +330,10 @@ .HP .BI "int gd_add_cpolynom(DIRFILE *" dirfile ", const char *" field_name , .BI "int " poly_ord ", const char *" in_fields ", const double *" ca , -.BI int " fragment_index ); +.BI "int " fragment_index ); .HP .BI "int gd_add_crecip(DIRFILE *" dirfile ", const char *" field_name , -.BI "const char *" in_field ", const double " cdividend [2], +.BI "const char *" in_field ", const double " cdividend\fR[2] , .BI "int " fragment_index ); .hy .ad n @@ -341,7 +343,7 @@ or .IR ca should have twice as many (purely real) elements, consisting of alternating -real and imaginary parts for the complex data. For example, +real and imaginary parts for the complex data. That is, for example, .IR ca [0] should be the real part of the first co-efficient, .IR ca [1] Modified: trunk/getdata/man/gd_alter_bit.3 =================================================================== --- trunk/getdata/man/gd_alter_bit.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_alter_bit.3 2014-04-04 00:09:31 UTC (rev 883) @@ -289,6 +289,7 @@ .PP .nf .B #define GD_C89_API +.br .B #include <getdata.h> .fi .HP @@ -302,7 +303,7 @@ .BI "int " poly_ord ", const char *" in_fields ", const double *" ca ); .HP .BI "int gd_alter_crecip(DIRFILE *" dirfile ", const char *" field_code , -.BI "const char *" in_field ", const double " cdividend [2]); +.BI "const char *" in_field ", const double " cdividend\fR[2] ); .hy .ad n .PP @@ -311,7 +312,7 @@ or .IR ca should have twice as many (purely real) elements, consisting of alternating -real and imaginary parts for the complex data. For example, +real and imaginary parts for the complex data. That is, for example, .IR ca [0] should be the real part of the first co-efficient, .IR ca [1] Modified: trunk/getdata/man/gd_alter_spec.3 =================================================================== --- trunk/getdata/man/gd_alter_spec.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_alter_spec.3 2014-04-04 00:09:31 UTC (rev 883) @@ -152,12 +152,13 @@ A descriptive error string for the last error encountered can be obtained from a call to .BR gd_error_string (3). -.SH BUGS +.SH NOTES If a .B CARRAY field with more than GD_MAX_CARRAY_LENGTH elements is provided, subsequent -elements will be silently truncated. GD_MAX_CARRAY_LENGTH is 2**24 on 32-bit -systems. It is larger on 64-bit systems. +elements will be silently truncated. On platforms with a \fIn\fR-bit +.BR size_t , +GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. .SH SEE ALSO .BR gd_alter_bit (3), .BR gd_alter_const (3), Modified: trunk/getdata/man/gd_bof64.3 =================================================================== --- trunk/getdata/man/gd_bof64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_bof64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -18,7 +18,7 @@ gd_bof64 \(em retrieve data from a dirfile database, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_cbopen.3 =================================================================== --- trunk/getdata/man/gd_cbopen.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_cbopen.3 2014-04-04 00:09:31 UTC (rev 883) @@ -720,8 +720,10 @@ .B CARRAY field to GD_MAX_CARRAY_LENGTH elements, to be certain it is always able to write the CARRAY back to disk without overrunning its maximum line length. -On 32-bit systems, GD_MAX_CARRAY_LENGTH is 2**24. It is larger on 64-bit -systems. Excess elements are silently truncated on dirfile open. +On platforms with a \fIn\fR-bit +.BR size_t , +GD_MAX_CARRAY_LENGTH is 2**(\fIn\fR-8)-1. Excess elements are silently +truncated on dirfile open. GetData's parser assumes it is running on an ASCII-compatible platform. Format specification parsing will fail gloriously on an EBCDIC platform. Modified: trunk/getdata/man/gd_eof64.3 =================================================================== --- trunk/getdata/man/gd_eof64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_eof64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -18,7 +18,7 @@ gd_eof64 \(em retrieve data from a dirfile database, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_framenum_subset64.3 =================================================================== --- trunk/getdata/man/gd_framenum_subset64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_framenum_subset64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -19,7 +19,7 @@ field, with largefile support. .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_frameoffset64.3 =================================================================== --- trunk/getdata/man/gd_frameoffset64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_frameoffset64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -19,7 +19,7 @@ offset of fields in a dirfile, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_getdata64.3 =================================================================== --- trunk/getdata/man/gd_getdata64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_getdata64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -18,7 +18,7 @@ gd_getdata64 \(em retrieve data from a dirfile database, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_madd_bit.3 =================================================================== --- trunk/getdata/man/gd_madd_bit.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_madd_bit.3 2014-04-04 00:09:31 UTC (rev 883) @@ -260,6 +260,7 @@ .BR gd_madd_crecip (): .PP .B #define GD_C89_API +.br .B #include <getdata.h> .HP .nh @@ -283,7 +284,7 @@ or .IR ca should have twice as many (purely real) elements, consisting of alternating -real and imaginary parts for the complex data. For example, +real and imaginary parts for the complex data. That is, for example, .IR ca [0] should be the real part of the first co-efficient, .IR ca [1] Modified: trunk/getdata/man/gd_nframes64.3 =================================================================== --- trunk/getdata/man/gd_nframes64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_nframes64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -18,7 +18,7 @@ gd_nframes64 \(em report the size of a dirfile, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_putdata64.3 =================================================================== --- trunk/getdata/man/gd_putdata64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_putdata64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -18,7 +18,7 @@ gd_putdata64 \(em write data to a dirfile database, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_seek64.3 =================================================================== --- trunk/getdata/man/gd_seek64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_seek64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -18,7 +18,7 @@ gd_seek64 \(em retrieve data from a dirfile database, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/man/gd_tell64.3 =================================================================== --- trunk/getdata/man/gd_tell64.3 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/man/gd_tell64.3 2014-04-04 00:09:31 UTC (rev 883) @@ -18,7 +18,7 @@ gd_tell64 \(em retrieve data from a dirfile database, with largefile support .SH SYNOPSIS .B #define GD_64BIT_API - +.br .B #include <getdata.h> .HP .nh Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/src/add.c 2014-04-04 00:09:31 UTC (rev 883) @@ -1087,22 +1087,9 @@ dtrace("%p, \"%s\", \"%s\", %g;%g, %i", D, field_code, in_field, creal(cdividend), cimag(cdividend), fragment_index); - if (D->flags & GD_INVALID) {/* don't crash */ - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } + error = gd_add_crecip89(D, field_code, in_field, (const double*)(&cdividend), + fragment_index); - gd_entry_t E; - memset(&E, 0, sizeof(gd_entry_t)); - E.field = (char *)field_code; - E.field_type = GD_RECIP_ENTRY; - E.EN(recip,cdividend) = cdividend; - E.flags = GD_EN_COMPSCAL; - E.in_fields[0] = (char *)in_field; - E.fragment_index = fragment_index; - error = (_GD_Add(D, &E, NULL) == NULL) ? -1 : 0; - dreturn("%i", error); return error; } @@ -1788,21 +1775,9 @@ dtrace("%p, \"%s\", \"%s\", \"%s\", %g;%g", D, parent, field_code, in_field, creal(cdividend), cimag(cdividend)); - if (D->flags & GD_INVALID) {/* don't crash */ - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } + error = gd_madd_crecip89(D, parent, field_code, in_field, + (const double*)(&cdividend)); - gd_entry_t E; - memset(&E, 0, sizeof(gd_entry_t)); - E.field = (char *)field_code; - E.field_type = GD_RECIP_ENTRY; - E.EN(recip,cdividend) = cdividend; - E.flags = GD_EN_COMPSCAL; - E.in_fields[0] = (char *)in_field; - error = (_GD_Add(D, &E, parent) == NULL) ? -1 : 0; - dreturn("%i", error); return error; } Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/src/getdata.c 2014-04-04 00:09:31 UTC (rev 883) @@ -1808,7 +1808,7 @@ return 0; } - dreturn("%i", len); + dreturn("%zu", len); return len; } Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/src/getdata.h.in 2014-04-04 00:09:31 UTC (rev 883) @@ -120,7 +120,7 @@ * whatever fits on a format file line, but that's hard to calculate. This is * 2**(n-8)-1 on a n-bit system. */ -#define GD_MAX_CARRAY_LENGTH ((int)(((unsigned int)-1) >> 8)) +#define GD_MAX_CARRAY_LENGTH (((size_t)-1) >> 8) /* error codes */ Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/src/mod.c 2014-04-04 00:09:31 UTC (rev 883) @@ -1303,26 +1303,12 @@ double complex cdividend) { int ret; - gd_entry_t N; dtrace("%p, \"%s\", \"%s\", %g;%g", D, field_code, in_field, creal(cdividend), cimag(cdividend)); - if (D->flags & GD_INVALID) {/* don't crash */ - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } + ret = gd_alter_crecip89(D, field_code, in_field, (const double*)(&cdividend)); - memset(&N, 0, sizeof(gd_entry_t)); - N.field_type = GD_RECIP_ENTRY; - N.in_fields[0] = (char *)in_field; - N.scalar[0] = (cdividend == 0) ? "" : NULL; - N.EN(recip,cdividend) = cdividend; - N.flags = GD_EN_COMPSCAL; - - ret = _GD_Change(D, field_code, &N, 0); - dreturn("%i", ret); return ret; } @@ -1334,7 +1320,7 @@ int ret; gd_entry_t N; - dtrace("%p, \"%s\", \"%s\", {%g, %g}", D, field_code, in_field, + dtrace("%p, \"%s\", \"%s\", %p={%g, %g}", D, field_code, in_field, cdividend, (cdividend == NULL) ? 0 : cdividend[0], (cdividend == NULL) ? 0 : cdividend[1]); Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2014-03-21 00:08:01 UTC (rev 882) +++ trunk/getdata/src/parse.c 2014-04-04 00:09:31 UTC (rev 883) @@ -1242,7 +1242,8 @@ int pedantic, int *restrict is_dot, char **outstring, const char *tok_pos) { unsigned dummy; - int offset, c, first, n, new_z, s, z; + int offset, c, first, new_z, s, z; + size_t n; gd_type_t t; char* ptr; void *data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-03-21 00:08:05
|
Revision: 882 http://sourceforge.net/p/getdata/code/882 Author: ketiltrout Date: 2014-03-21 00:08:01 +0000 (Fri, 21 Mar 2014) Log Message: ----------- Minor bug fixes. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/Makefile.am trunk/getdata/NEWS trunk/getdata/bindings/php/getdata.c trunk/getdata/bindings/php/test/big_test.php trunk/getdata/bindings/python/pydirfile.c trunk/getdata/test/zzslim_get.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-03-11 23:26:25 UTC (rev 881) +++ trunk/getdata/ChangeLog 2014-03-21 00:08:01 UTC (rev 882) @@ -1,3 +1,8 @@ +2014-03-20 D. V. Wiebe <ge...@ke...> svn:882 + * bindings/php/getdata.c (gd_add_polynom gd_madd_polynom): Fix array size. + * bindings/python/pydirfile.c (gdpy_dirfile_getentry): Fix segfault. + * test/zzslim_get.c: Fix. + 2014-03-10 D. V. Wiebe <ge...@ke...> svn:880 * bindings/matlab/gd_move_alias.c: Deleted. * bindings/matlab/test/big_test/m: Delete test 224. Modified: trunk/getdata/Makefile.am =================================================================== --- trunk/getdata/Makefile.am 2014-03-11 23:26:25 UTC (rev 881) +++ trunk/getdata/Makefile.am 2014-03-21 00:08:01 UTC (rev 882) @@ -1,4 +1,4 @@ -# Copyright (C) 2008, 2011 D. V. Wiebe +# Copyright (C) 2008, 2011, 2014 D. V. Wiebe # ########################################################################## # @@ -18,7 +18,7 @@ # along with GetData; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -AUTOMAKE_OPTIONS = foreign dist-bzip2 check-news 1.10 +AUTOMAKE_OPTIONS = foreign dist-xz check-news 1.10 EXTRA_DIST = ChangeLog @@ -131,9 +131,9 @@ rm -rf crlf_export # package lists -PACKAGES=$(distdir).tar.gz $(distdir).tar.bz2 idl_$(distdir).tar.gz \ - idl_$(distdir).tar.bz2 getdata_win-$(PACKAGE_VERSION).zip \ - matlab_$(distdir).tar.gz matlab_$(distdir).tar.bz2 +PACKAGES=$(distdir).tar.gz $(distdir).tar.xz idl_$(distdir).tar.gz \ + idl_$(distdir).tar.xz getdata_win-$(PACKAGE_VERSION).zip \ + matlab_$(distdir).tar.gz matlab_$(distdir).tar.xz SIGS=$(addsuffix .sig,$(PACKAGES)) # release stuff Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-03-11 23:26:25 UTC (rev 881) +++ trunk/getdata/NEWS 2014-03-21 00:08:01 UTC (rev 882) @@ -114,7 +114,8 @@ * The comp_scal member of the gd_entry_t object has been replaced with a flags member, containing a flag (GD_EN_COMPSCAL) with the meaning of the former comp_scal member. There are also flags for hiddenness (GD_EN_HIDDEN) and - whether the scalar entries have been computed (GD_EN_CALC). + whether the scalar entry codes in the field definition have been + dereferenced (GD_EN_CALC). * gd_[m]add() and gd_alter_entry() can now be used to set or change the hiddenness of a field by setting or clearing the GD_EN_HIDDEN bit in the Modified: trunk/getdata/bindings/php/getdata.c =================================================================== --- trunk/getdata/bindings/php/getdata.c 2014-03-11 23:26:25 UTC (rev 881) +++ trunk/getdata/bindings/php/getdata.c 2014-03-21 00:08:01 UTC (rev 882) @@ -1949,7 +1949,7 @@ long index = 0; zval *za; - double a[GD_MAX_POLYORD + 1]; + double a[2 * (GD_MAX_POLYORD + 1)]; int o; DIRFILE *D; @@ -3657,7 +3657,7 @@ int field_code_len, in_field_len, parent_len; zval *za; - double a[GD_MAX_POLYORD + 1]; + double a[2 * (GD_MAX_POLYORD + 1)]; int o; DIRFILE *D; Modified: trunk/getdata/bindings/php/test/big_test.php =================================================================== --- trunk/getdata/bindings/php/test/big_test.php 2014-03-11 23:26:25 UTC (rev 881) +++ trunk/getdata/bindings/php/test/big_test.php 2014-03-21 00:08:01 UTC (rev 882) @@ -1,5 +1,5 @@ <?php -# Copyright (C) 2013 D. V. Wiebe +# Copyright (C) 2013, 2014 D. V. Wiebe # ########################################################################## # Modified: trunk/getdata/bindings/python/pydirfile.c =================================================================== --- trunk/getdata/bindings/python/pydirfile.c 2014-03-11 23:26:25 UTC (rev 881) +++ trunk/getdata/bindings/python/pydirfile.c 2014-03-21 00:08:01 UTC (rev 882) @@ -751,7 +751,6 @@ if ((e = gd_error(self->D))) { PYGD_REPORT_ERROR(self->D,e); - gd_free_entry_strings(E); free(E); dreturn("%p", NULL); return NULL; Modified: trunk/getdata/test/zzslim_get.c =================================================================== --- trunk/getdata/test/zzslim_get.c 2014-03-11 23:26:25 UTC (rev 881) +++ trunk/getdata/test/zzslim_get.c 2014-03-21 00:08:01 UTC (rev 882) @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2013 D. V. Wiebe +/* Copyright (C) 2012-2014 D. V. Wiebe * *************************************************************************** * @@ -36,7 +36,7 @@ uint16_t c[8]; char command[4096]; uint16_t data_data[256]; - int fd, n, error, r = 0; + int i, fd, n, error, r = 0; DIRFILE *D; memset(c, 0, 8); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-03-11 23:26:27
|
Revision: 881 http://sourceforge.net/p/getdata/code/881 Author: ketiltrout Date: 2014-03-11 23:26:25 +0000 (Tue, 11 Mar 2014) Log Message: ----------- Fix stand-alone IDL package. Modified Paths: -------------- trunk/getdata/bindings/idl/getdata.c trunk/getdata/bindings/idl/makedlm.sh.in Modified: trunk/getdata/bindings/idl/getdata.c =================================================================== --- trunk/getdata/bindings/idl/getdata.c 2014-03-11 01:12:26 UTC (rev 880) +++ trunk/getdata/bindings/idl/getdata.c 2014-03-11 23:26:25 UTC (rev 881) @@ -44,6 +44,7 @@ # define gd_colclear() # define GD_INT_TYPE ((gd_type_t)(SIZEOF_INT | GD_SIGNED)) # define GD_UINT_TYPE ((gd_type_t)(SIZEOF_UNSIGNED_INT)) +# define gd_static_inline_ static inline #else # include "../../src/internal.h" #endif Modified: trunk/getdata/bindings/idl/makedlm.sh.in =================================================================== --- trunk/getdata/bindings/idl/makedlm.sh.in 2014-03-11 01:12:26 UTC (rev 880) +++ trunk/getdata/bindings/idl/makedlm.sh.in 2014-03-11 23:26:25 UTC (rev 881) @@ -45,7 +45,7 @@ DESCRIPTION IDL GetData bindings VERSION @VERSION@ BUILD_DATE $BUILD_DATE -SOURCE The GetData Project <@PACKAGE_BUGREPORT@> +SOURCE The GetData Project <@PACKAGE_URL@> STRUCTURE GD_ENTRY EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-03-11 01:12:32
|
Revision: 880 http://sourceforge.net/p/getdata/code/880 Author: ketiltrout Date: 2014-03-11 01:12:26 +0000 (Tue, 11 Mar 2014) Log Message: ----------- Fix matlab bindings. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/bindings/matlab/Makefile.am trunk/getdata/bindings/matlab/matlab.c trunk/getdata/bindings/matlab/test/big_test.m trunk/getdata/m4/matlab.m4 Removed Paths: ------------- trunk/getdata/bindings/matlab/gd_move_alias.c Property Changed: ---------------- trunk/getdata/bindings/matlab/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-03-05 22:25:36 UTC (rev 879) +++ trunk/getdata/ChangeLog 2014-03-11 01:12:26 UTC (rev 880) @@ -1,3 +1,7 @@ +2014-03-10 D. V. Wiebe <ge...@ke...> svn:880 + * bindings/matlab/gd_move_alias.c: Deleted. + * bindings/matlab/test/big_test/m: Delete test 224. + 2014-02-14 D. V. Wiebe <ge...@ke...> svn:877 * bindings/cxx/entry.cpp (Entry::Entry): Zero E if gd_entry call fails. Index: trunk/getdata/bindings/matlab =================================================================== --- trunk/getdata/bindings/matlab 2014-03-05 22:25:36 UTC (rev 879) +++ trunk/getdata/bindings/matlab 2014-03-11 01:12:26 UTC (rev 880) Property changes on: trunk/getdata/bindings/matlab ___________________________________________________________________ Modified: svn:ignore ## -53,6 +53,7 ## gd_get_string.m gd_hidden.m gd_hide.m +gd_include.m gd_include_affix.m gd_invalid_dirfile.m gd_linterp_tablename.m ## -66,7 +67,6 ## gd_mcarrays.m gd_mconstants.m gd_metaflush.m -gd_move_alias.m gd_move.m gd_mplex_lookback.m gd_mstrings.m Modified: trunk/getdata/bindings/matlab/Makefile.am =================================================================== --- trunk/getdata/bindings/matlab/Makefile.am 2014-03-05 22:25:36 UTC (rev 879) +++ trunk/getdata/bindings/matlab/Makefile.am 2014-03-11 01:12:26 UTC (rev 880) @@ -62,7 +62,7 @@ gd_linterp_tablename gd_madd gd_madd_alias \ gd_madd_carray gd_madd_const gd_madd_spec gd_madd_string \ gd_malter_spec gd_mcarrays \ - gd_mconstants gd_metaflush gd_move gd_move_alias gd_mplex_lookback \ + gd_mconstants gd_metaflush gd_move gd_mplex_lookback \ gd_mstrings gd_naliases gd_native_type gd_nentries gd_nfragments \ gd_nframes gd_open gd_parent_fragment gd_protection \ gd_put_carray_slice \ Deleted: trunk/getdata/bindings/matlab/gd_move_alias.c =================================================================== --- trunk/getdata/bindings/matlab/gd_move_alias.c 2014-03-05 22:25:36 UTC (rev 879) +++ trunk/getdata/bindings/matlab/gd_move_alias.c 2014-03-11 01:12:26 UTC (rev 880) @@ -1,55 +0,0 @@ -/* 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 "gd_matlab.h" - -/* - % GD_MOVE_ALIAS Move an alias between fragments - % - % GD_MOVE_ALIAS(DIRFILE,NAME,NEW_FRAGMENT) - % moves the alias called NAME to the fragment indexed by - % NEW_FRAGMENT. - % - % The DIRFILE object should have previously been created with GD_OPEN. - % - % See the documentation on the C API function gd_move_alias(3) in - % section 3 of the UNIX manual for more details. - % - % See also GD_MOVE, GD_OPEN - */ - -void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) -{ - DIRFILE *D; - char *field_code; - int new_frag; - - GDMX_NO_LHS; - GDMX_CHECK_RHS(3); - - D = gdmx_to_dirfile(prhs[0]); - field_code = gdmx_to_string(prhs, 1, 0); - new_frag = gdmx_to_int(prhs, 2); - - gd_move_alias(D, field_code, new_frag); - - mxFree(field_code); - gdmx_err(D, 0); -} Modified: trunk/getdata/bindings/matlab/matlab.c =================================================================== --- trunk/getdata/bindings/matlab/matlab.c 2014-03-05 22:25:36 UTC (rev 879) +++ trunk/getdata/bindings/matlab/matlab.c 2014-03-11 01:12:26 UTC (rev 880) @@ -954,7 +954,7 @@ mxSetField(lhs, 0, "in_fields", gdmx_from_nstring_list((const char**)E->in_fields, E->EN(lincom,n_fields))); - if (E->comp_scal) { + if (E->flags & GD_EN_COMPSCAL) { mxSetField(lhs, 0, "m", gdmx_from_data(E->EN(lincom,cm), GD_COMPLEX128, E->EN(lincom,n_fields))); mxSetField(lhs, 0, "b", gdmx_from_data(E->EN(lincom,cb), GD_COMPLEX128, @@ -990,7 +990,7 @@ break; case GD_POLYNOM_ENTRY: mxSetField(lhs, 0, "in_fields", mxCreateString(E->in_fields[0])); - if (E->comp_scal) { + if (E->flags & GD_EN_COMPSCAL) { mxSetField(lhs, 0, "a", gdmx_from_data(E->EN(polynom,ca), GD_COMPLEX128, E->EN(polynom,poly_ord) + 1)); } else { @@ -1006,7 +1006,7 @@ break; case GD_RECIP_ENTRY: mxSetField(lhs, 0, "in_fields", mxCreateString(E->in_fields[0])); - if (E->comp_scal) + if (E->flags & GD_EN_COMPSCAL) mxSetField(lhs, 0, "dividend", gdmx_from_cdouble((double*)&E->EN(recip,cdividend))); else @@ -1285,7 +1285,7 @@ break; case GD_LINCOM_ENTRY: E->EN(lincom,n_fields) = gdmx_convert_in_fields(rhs[n], &ctx, E); - E->comp_scal = 1; + E->flags |= GD_EN_COMPSCAL; gdmx_convert_entry_array(rhs[n], &ctx, "m", E->EN(lincom,cm), E->EN(lincom,n_fields)); gdmx_convert_entry_array(rhs[n], &ctx, "b", E->EN(lincom,cb), @@ -1309,7 +1309,7 @@ break; case GD_POLYNOM_ENTRY: gdmx_convert_in_fields(rhs[n], &ctx, E); - E->comp_scal = 1; + E->flags |= GD_EN_COMPSCAL; E->EN(polynom,poly_ord) = gdmx_convert_entry_array(rhs[n], &ctx, "a", E->EN(polynom,ca), GD_MAX_POLYORD + 1) - 1; break; @@ -1322,7 +1322,7 @@ break; case GD_RECIP_ENTRY: gdmx_convert_in_fields(rhs[n], &ctx, E); - E->comp_scal = 1; + E->flags |= GD_EN_COMPSCAL; gdmx_convert_struct_scalar(rhs[n], &ctx, "dividend", GD_COMPLEX128, &E->EN(recip,cdividend)); break; Modified: trunk/getdata/bindings/matlab/test/big_test.m =================================================================== --- trunk/getdata/bindings/matlab/test/big_test.m 2014-03-05 22:25:36 UTC (rev 879) +++ trunk/getdata/bindings/matlab/test/big_test.m 2014-03-11 01:12:26 UTC (rev 880) @@ -1809,29 +1809,15 @@ ne = ne + check_ok2(exc, 41, 1); end - % 224: move_alias - try - gd_move_alias(D, 'new20', 1); - catch exc - ne = ne + check_ok2(exc, 224, 1); - end - - try - d = gd_fragment_index(D, 'Anew20Z'); - ne = ne + check_num(224, d, 1); - catch exc - ne = ne + check_ok2(exc, 224, 2); - end - % 225: delete_alias try - gd_delete_alias(D, 'Anew20Z'); + gd_delete_alias(D, 'new20'); catch exc ne = ne + check_ok2(exc, 225, 1); end try - d = gd_fragment_index(D, 'Anew20Z'); + d = gd_fragment_index(D, 'new20'); catch exc ne = ne + check_exc2(exc, 225, 2, 'BadCode'); end Modified: trunk/getdata/m4/matlab.m4 =================================================================== --- trunk/getdata/m4/matlab.m4 2014-03-05 22:25:36 UTC (rev 879) +++ trunk/getdata/m4/matlab.m4 2014-03-11 01:12:26 UTC (rev 880) @@ -38,12 +38,18 @@ dnl try to find mex MEX="not found" if test "x$user_mex" != "x"; then - AC_MSG_CHECKING([if $user_mex is a MATLAB mex compiler]) - mex_out=`$user_mex 2>&1` + MEX=$user_mex +else + AC_PATH_PROG([MEX], [mex], [not found]) +fi + +if test "x$MEX" != "xnot found"; then + AC_MSG_CHECKING([if $MEX is a MATLAB mex compiler]) + mex_out=`$MEX 2>&1` mex_status=$? if test $mex_status -eq 1; then - if echo $mex_out | grep -q 'consult the MATLAB External Interfaces Guide'; then - MEX=$user_mex + if ! echo $mex_out | grep -q 'consult the MATLAB External Interfaces Guide'; then + MEX="not found"; fi fi if test "x$MEX" = "xnot found"; then @@ -51,14 +57,13 @@ else AC_MSG_RESULT([yes]) fi -else - AC_PATH_PROG([MEX], [mex], [not found]) fi if test "x$MEX" = "xnot found"; then have_matlab="no" MEX= fi + AC_SUBST([MEX]) ]) @@ -107,21 +112,23 @@ dnl find matlab if test "x${have_matlab}" != "xno"; then dnl try to find matlab - MATLAB="not found" if test "x$user_matlab" != "x"; then - AC_MSG_CHECKING([if $user_matlab is a MATLAB interpreter]) - GD_MATLAB_EVAL([matlab_ver], [version], [$user_matlab]) - if test "x$matlab_ver" = "x"; then - AC_MSG_RESULT([no]) - else - AC_MSG_RESULT([yes]) - MATLAB=$user_matlab - MATLAB_VERSION=$matlab_ver - fi + MATLAB=$user_matlab; else AC_PATH_PROG([MATLAB], [matlab], [not found]) fi + if test "x$MATLAB" != "xnot found"; then + AC_MSG_CHECKING([$MATLAB version]) + GD_MATLAB_EVAL([MATLAB_VERSION], [version], [$MATLAB]) + if test "x$MATLAB_VERSION" = "x"; then + AC_MSG_RESULT([none]) + MATLAB="not found" + else + AC_MSG_RESULT([$MATLAB_VERSION]) + fi + fi + if test "x$MATLAB" = "xnot found"; then have_matlab=no MATLAB= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-03-05 22:25:40
|
Revision: 879 http://sourceforge.net/p/getdata/code/879 Author: ketiltrout Date: 2014-03-05 22:25:36 +0000 (Wed, 05 Mar 2014) Log Message: ----------- More verbosity Modified Paths: -------------- trunk/getdata/configure.ac Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2014-02-20 01:14:38 UTC (rev 878) +++ trunk/getdata/configure.ac 2014-03-05 22:25:36 UTC (rev 879) @@ -156,7 +156,7 @@ make_matlabbindings="yes" make_phpbindings="yes" AC_ARG_ENABLE(bindings, AS_HELP_STRING([--disable-bindings], - [don't build any bindings, just build the C library]), + [don't build any bindings; just build the C library]), [ if test "x${enableval}" = "xno"; then make_cxxbindings="no" @@ -389,6 +389,12 @@ esac ], [gd_unaligned_override="check"]) +m4_divert_once([HELP_ENABLE], AS_HELP_STRING([--disable-fast-unaligned], + [don't use fast loads and stores with non-aligned data, ]dnl' + [even if it looks like they should work. This is always ] + [safe, but can result in significant slow-down.] + [ [default: autodetect]])) + AC_MSG_CHECKING([whether ${host} supports fast unaligned memory access]) if test "x$gd_unaligned_override" = "xyes"; then gd_unaligned_ok=yes @@ -421,6 +427,7 @@ [ The directory separator between path elements ]) AC_MSG_RESULT([$GD_FDIRSEP]) +AC_MSG_CHECKING([for extra LDFLAGS needed on ${host}]) case "${host}" in *-pc-mingw*) NO_UNDEFINED=" -no-undefined" @@ -431,6 +438,19 @@ *) NO_DLOPEN_TESTS=0 ;; esac +if test "x${NO_UNDEFINED}" = "x"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT([${NO_UNDEFINED}]) +fi + +AC_MSG_CHECKING([whether the test suite can dynamically load objects]) +if test "x${NO_DLOPEN_TESTS}" = "x1"; then + AC_MSG_RESULT([no]) +else + AC_MSG_RESULT([yes]) +fi + echo echo "*** Checking C compiler characteristics" echo This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-02-20 01:14:41
|
Revision: 878 http://sourceforge.net/p/getdata/code/878 Author: ketiltrout Date: 2014-02-20 01:14:38 +0000 (Thu, 20 Feb 2014) Log Message: ----------- Typo. Modified Paths: -------------- trunk/getdata/bindings/python/pydirfile.c Modified: trunk/getdata/bindings/python/pydirfile.c =================================================================== --- trunk/getdata/bindings/python/pydirfile.c 2014-02-19 00:22:56 UTC (rev 877) +++ trunk/getdata/bindings/python/pydirfile.c 2014-02-20 01:14:38 UTC (rev 878) @@ -749,8 +749,8 @@ gd_entry(self->D, field_code, E); - if ((e = gd_error(D))) { - PYGD_REPORT_ERROR(D,e); + if ((e = gd_error(self->D))) { + PYGD_REPORT_ERROR(self->D,e); gd_free_entry_strings(E); free(E); dreturn("%p", NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-02-19 00:22:59
|
Revision: 877 http://sourceforge.net/p/getdata/code/877 Author: ketiltrout Date: 2014-02-19 00:22:56 +0000 (Wed, 19 Feb 2014) Log Message: ----------- Fix bugs reported by Coverity Scan. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/cxx/entry.cpp trunk/getdata/bindings/cxx/fragment.cpp trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/idl/getdata.c trunk/getdata/bindings/make_parameters.c trunk/getdata/bindings/php/getdata.c trunk/getdata/bindings/python/pydirfile.c trunk/getdata/bindings/python/pyentry.c trunk/getdata/bindings/python/pygetdata.h trunk/getdata/src/add.c trunk/getdata/src/bzip.c trunk/getdata/src/common.c trunk/getdata/src/entry.c trunk/getdata/src/getdata.h.in trunk/getdata/src/gzip.c trunk/getdata/src/include.c trunk/getdata/src/lzma.c trunk/getdata/src/mod.c trunk/getdata/src/name.c trunk/getdata/src/open.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/src/sie.c trunk/getdata/src/types.c trunk/getdata/test/add_alias.c trunk/getdata/test/add_alias_affix.c trunk/getdata/test/add_alias_meta.c trunk/getdata/test/add_resolv.c trunk/getdata/test/add_spec_resolv.c trunk/getdata/test/alias_num.c trunk/getdata/test/alias_num_alias.c trunk/getdata/test/alias_num_missing.c trunk/getdata/test/madd_alias.c trunk/getdata/test/madd_alias_affix.c trunk/getdata/test/madd_spec_resolv.c trunk/getdata/util/checkdirfile.c trunk/getdata/util/dirfile2ascii.c Added Paths: ----------- trunk/getdata/doc/cov_mod.c Property Changed: ---------------- trunk/getdata/ Index: trunk/getdata =================================================================== --- trunk/getdata 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata 2014-02-19 00:22:56 UTC (rev 877) Property changes on: trunk/getdata ___________________________________________________________________ Modified: svn:ignore ## -7,6 +7,7 ## config.status config.sub configure +cov-int depcomp getdata_win-*.zip getdata_win-*.sig Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/ChangeLog 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,58 @@ -2014-02-21 D. V. Wiebe <ge...@ke...> svn:876 +2014-02-14 D. V. Wiebe <ge...@ke...> svn:877 + * bindings/cxx/entry.cpp (Entry::Entry): Zero E if gd_entry call fails. + + * bindings/cxx/fragment.cpp (Fragment::Fragment): Handle error in + gd_fragment_affixes call. + + * bindings/f77/fgetdata.c (GDASCA): Handle error in gd_entry call. + + * bindings/php/getdata.c (gdphp_data_to_array): Add missing break. + + * bindings/php/getdata.c (gd_error_string): Handle error in gd_error_string + call. + + * bindings/python/pygetdata.h (PYGD_REPORT_ERROR): Added. + + * bindings/python/pydirfile.c (gdpy_dirfile_getentry gdpy_dirfile_getstring + gdpy_dirfile_putcarray gdpy_dirfile_putdata) src/include.c (_GD_Include) + src/name.c (_GD_PrepareRename) src/putdata.c (_GD_DoMplexOut) src/sie.c + (_GD_SampIndWrite) src/types.c (_GD_ConvertType): Deallocate buffers on error. + + * bindings/python/pyentry.c (gdpy_entry_seta): Set a[i] if the pyobj is + complex. + + * src/bzip.c (_GD_Bzip2Size): Free ptr only after we're done with it. + + * src/common.c (_GD_CanonicalPath): Don't let readlink overrun the buffer. + Also fix double free. + + * src/entry.c (_GD_FreeE): Fix overrun on zeroing of in_fields. + + * src/entry.c (gd_linterp_tablename): Don't use field_code after free. + + * src/getdata.h.in: Remove __nonnull__ from parameter two of + gd_verbose_prefix. + + * src/gzip.c (_GD_GzipOpen): Check that _GD_MakeTempFile() worked. + + * src/open.c (_GD_CreateDirfile _GD_Open): Close descriptors on error. + + * src/parse.c (_GD_ParseCarray): Return on error. + + * src/parse.c (_GD_ParseFieldSpec): Only resize the dot_list when necessary. + Also, clean up if the resize doesn't work. + + * util/dirfile2ascii.c (main): Fix check for too many fields. + + * src/entry.c (gd_naliases): Return unsigned int and zero on error per + documentation. + * bindings/idl/getdata.c (gdidl_naliases) src/entry.c (gd_aliases) + test/add_alias.c test/add_alias_affix.c test/add_alias_meta.c + test/add_resolv.c test/add_spec_resolv.c test/alias_num.c + test/alias_num_alias.c test/alias_num_missing.c test/madd_alias.c + test/madd_alias_affix.c test/madd_spec_resolv.c: Handle unsigned gd_naliases. + +2014-02-13 D. V. Wiebe <ge...@ke...> svn:876 * bindings/python/pyfragment.c (gdpy_fragment_init): Fix typo in keyword names. Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/NEWS 2014-02-19 00:22:56 UTC (rev 877) @@ -6,6 +6,17 @@ semicolon) when the parameter is purely real. However, a non-zero imaginary part is still an error. + * gd_free_entry_strings() now NULLs pointers after freeing them. + + * gd_entry() now returns entry metadata when they contain scalar field codes + which do not exist. In this case the GD_EN_CALC flag in the object will + not be set. Previously, on such entries, this function would fail with the + error GD_E_BAD_SCALAR, and return nothing. + + * gd_rename() now by default updates the target of ALIASes pointing to a + renamed field to point to the new field instead of leaving them dangle. + (But see GD_REN_DANGLE). + * BUG FIX: The parsing of the \x and \u escape sequences are now correct. * BUG FIX: Computation of LINCOMs with complex valued input fields now @@ -26,7 +37,7 @@ Previously they would store these invalid field codes, causing problems later. - * BUG FIX: Returning complex-valued CARRAYs as purely real now works. + * BUG FIX: Returning complex-valued CARRAYs as purely real data now works. Previously only the first element requested would be returned, the remaining output buffer containing uninitialised data. @@ -34,10 +45,10 @@ entry is no longer ignored by gd_[m]add(). * BUG FIX: Entry members spf, bitnum, numbits, and period are now completely - ignored by gd_[m]add() when corresponding named scalars are specified. + ignored by gd_[m]add() if 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. + being rejected, even though the invalid value was immediately discarded + when the field was added. * BUG FIX: gd_[m]add() no longer rejects MPLEX fields with negative count_val. @@ -47,58 +58,19 @@ * BUG FIX: reading a LINTERP table with fewer than two lines no longer results in a segfault on close/discard. - * BUG FIX: DIVIDE fields with complex valued divisors are now properly + * BUG FIX: DIVIDE fields with complex-valued divisors are now properly computed. * BUG FIX: Complex-valued DIVIDE, POLYNOM, and RECIP fields are now computed properly when the library is built in ANSI C mode. - * BUG FIX: Writing complex MPLEX fields no longer corrupts the stored data. + * BUG FIX: Writing complex-valued MPLEX fields no longer corrupts the stored + data. * BUG FIX: Several fixes have been made to the sample index encoding (SIE) engine, which should now produce properly encoded data when performing random writes. - API Changes: - - * gd_free_entry_strings() now NULLs pointers after freeing them. - - * The comp_scal member of the gd_entry_t object has been replaced with a flags - member, containing a flag (GD_EN_COMPSCAL) with the meaning of the former - comp_scal member. There are also flags for hiddenness (GD_EN_HIDDEN) and - whether the scalar entries have been computed (GD_EN_CALC). - - * gd_entry() now returns entry metadata when they contain scalar field codes - which do not exist. In this case the GD_EN_CALC flag in the object will - not be set. Previously, on such entries, this function would fail with the - error GD_E_BAD_SCALAR and return nothing. - - * gd_[m]add() and gd_alter_entry() can now be used to set or change the - hiddenness of a field by setting or clearing the GD_EN_HIDDEN bit in the - supplied gd_entry_t object. - - * Two new rename flags have been added: - - GD_REN_DANGLE which indicates the library shouldn't update ALIASes whose - target has been renamed (turning them into dangling aliases) - - GD_REN_FORCE which causes the library to skip updating field codes which - would be invalid due to affixes instead of failing. - - * gd_rename() now by default updates the target of ALIASes pointing to a - renamed field to point to the new field instead of leaving them dangle. - (But see GD_REN_DANGLE). - - * The move_data argument of gd_move() has been replaced with a flags argument - which accepts the GD_REN_* flags, which have the same meaning as they do - with gd_rename(). - - * gd_move_alias() has been deleted: its function is now performed by - gd_move(). If gd_move() is passed the field code of an alias, the alias is - now moved, instead of moving the field the alias points to. - - * BUG FIX: If the dirfile path provided cannot be resolved (due to, for - instance, a symbolic link pointing to a non-existent path), gd_open() and - friends now return GD_E_OPEN, as documented, instead of GD_E_RAW_IO. - * BUG FIX: gd_bof() now returns the correct number (i.e.: zero) when reporting the beginning of field of derived fields shifted to before the start of the dirfile. Previously, this function incorrectly returned values ranging from @@ -134,11 +106,41 @@ of the affected fragment; previously, these old, cached filenames could lead to I/O errors when reading and writing the re-encoded RAW data files. - Legacy API Changes: + * BUG FIX: Calling the Legacy API function GetFormat() on a Dirfile with MPLEX + or WINDOW fields no longer results in a segmentation fault. - * BUG FIX: Calling GetFormat on a Dirfile with MPLEX or WINDOW fields no - longer results in a segmentation fault. + API Changes: + * The comp_scal member of the gd_entry_t object has been replaced with a flags + member, containing a flag (GD_EN_COMPSCAL) with the meaning of the former + comp_scal member. There are also flags for hiddenness (GD_EN_HIDDEN) and + whether the scalar entries have been computed (GD_EN_CALC). + + * gd_[m]add() and gd_alter_entry() can now be used to set or change the + hiddenness of a field by setting or clearing the GD_EN_HIDDEN bit in the + supplied gd_entry_t object. + + * Two new rename flags have been added: + - GD_REN_DANGLE which indicates the library shouldn't update ALIASes whose + target has been renamed (turning them into dangling aliases) + - GD_REN_FORCE which causes the library to skip updating field codes which + would be invalid due to affixes instead of failing. + + * The move_data argument of gd_move() has been replaced with a flags argument + which accepts the GD_REN_* flags, which have the same meaning as they do + with gd_rename(). + + * gd_move_alias() has been deleted: its function is now performed by + gd_move(). If gd_move() is passed the field code of an alias, the alias is + now moved, instead of moving the field the alias points to. + + * BUG FIX: If the dirfile path provided cannot be resolved (due to, for + instance, a symbolic link pointing to a non-existent path), gd_open() and + friends now return GD_E_OPEN, as documented, instead of GD_E_RAW_IO. + + * BUG FIX: gd_naliases() now returns an unsigned int, and zero on error, + as documented. + Bindings Changes: * PHP bindings have been added. @@ -240,10 +242,6 @@ Library Changes: - * The count_max member of the gd_entry_t object has been renamed to period. - The corresponding dummy argument in various function prototypes has been - similarly renamed. - * BUG FIX: The library no longer incorrectly rejects negative count_val MPLEX parameters. Furthermore, a count_val of -1 in gd_alter_entry or gd_[m]alter_mplex calls is not a special value: it just sets count_val to @@ -273,6 +271,12 @@ included with affixes is no longer corrupted by spurious application of the affixes when the subfragment's metadata are (re-)written. Reported by Seth. + API Changes: + + * The count_max member of the gd_entry_t object has been renamed to period. + The corresponding dummy argument in various function prototypes has been + similarly renamed. + Bindings Changes: * C++: The Entry and MplexEntry member functions CountMax and SetCountMax have @@ -340,6 +344,9 @@ Library Changes: + * gd_dirfilename() now returns a fully canonicalised version of the dirfile + path. + * BUG FIX: A segfault when negotiating symbolic links in file paths, typically manifesting in gd_open calls, has been fixed. @@ -358,6 +365,13 @@ the current Standards Version, potentially leading to rejected valid dirfiles. Reported by Daniel Flanigan. + * BUG FIX: gd_alter_entry() and gd_madd_alias() weren't clearing the Dirfile + error before operation, resulting in them failing erroneously in certain + situations. + + * BUG FIX: When including an existing fragment which itself has subfragments, + gd_include() no longer returns the wrong fragment index. + * WIN32 BUG FIX: On Windows, the parser can now properly handle hexadecimal floating point. @@ -368,21 +382,11 @@ suffix, if any, which should remove the need to do manual affix bookkeeping when reading metadata. The other side to this change is that when modifying metdata (gd_add(), gd_alter_entry(), &c.), supplied field codes must also - contain the appropriate suffixes. + contain the appropriate affixes. - * gd_dirfilename() now returns a fully canonicalised version of the dirfile - path. - * A new function, gd_linterp_tablename() has been added which returns a fully canonicalised version of the look-up table pathname for a LINTERP. - * BUG FIX: gd_alter_entry() and gd_madd_alias() weren't clearing the Dirfile - error before operation, resulting in them failing erroneously in certain - situations. - - * BUG FIX: When including an existing fragment which itself has subfragments, - gd_include() no longer returns the wrong fragment index. - Bindings Changes: * F77 BUG FIX: A memory leak has been fixed in GDALLC. @@ -537,6 +541,9 @@ documentation indicates it should) and checks the protection of the fragment containing the parent field. + * BUG FIX: calling gd_putdata() with num_frames and num_samples both zero + no longer confuses GetData: instead it simply does nothing. + API Changes: * Functions which add fields (gd_add(), gd_add_<type>(), &c.) can now be @@ -640,9 +647,6 @@ * C89 API: Passing NULL to gd_alter_crecip() for cdividend is now treated as if it were passed zero (ie. it indicates no change for cdividend). - * BUG FIX: calling gd_putdata() with num_frames and num_samples both zero - no longer confuses GetData: instead it simply does nothing. - * BUG FIX: gd_spf() now returns GD_E_DIMENSION when passed a scalar field code, as the documentation says it should. Previously it returned GD_E_BAD_FIELD_TYPE. @@ -799,6 +803,7 @@ Bindings Changes: * F77 BUG FIX: A memory leak in GDASCA has been fixed. + * Python BUG FIX: The first element of a python list (instead of a NumPy array) is no longer dropped when passed to pygetdata on 64-bit systems. Modified: trunk/getdata/bindings/cxx/entry.cpp =================================================================== --- trunk/getdata/bindings/cxx/entry.cpp 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/cxx/entry.cpp 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -// Copyright (C) 2008-2012 D. V. Wiebe +// Copyright (C) 2008-2012, 2014 D. V. Wiebe // /////////////////////////////////////////////////////////////////////////// // @@ -31,7 +31,8 @@ Entry::Entry(const GetData::Dirfile *dirfile, const char* field_code) { D = dirfile; - gd_entry(D->D, field_code, &E); + if (gd_entry(D->D, field_code, &E)) + memset(&E, 0, sizeof(E)); } Entry::~Entry() @@ -101,6 +102,19 @@ if (E.field == NULL) { E.field = strdup(new_name); } else { + /* this buffer is used if E is a metafield, in which case we'll + * replace the subfield name in E.field with new_name. The length + * of the new code is + * + * strlen(E.field) - strlen(<subfield-name>) + strlen(new_name) + * + 1 (for the trailing NUL). + * + * The subfield name in E.field must be at least one character long, so + * the length of the new code is at most: + * + * strlen(E.field) - 1 + strlen(new_name) + 1 + * = strlen(E.field) + strlen(new_name) + */ char* nn = (char*)malloc(strlen(E.field) + strlen(new_name)); strcpy(nn, E.field); ptr = strchr(nn, '/'); Modified: trunk/getdata/bindings/cxx/fragment.cpp =================================================================== --- trunk/getdata/bindings/cxx/fragment.cpp 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/cxx/fragment.cpp 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -// Copyright (C) 2008, 2010, 2011 D. V. Wiebe +// Copyright (C) 2008, 2010, 2011, 2014 D. V. Wiebe // /////////////////////////////////////////////////////////////////////////// // @@ -35,8 +35,10 @@ prot = gd_protection(D->D, index); name = gd_fragmentname(D->D, index); parent = (index == 0) ? -1 : gd_parent_fragment(D->D, index); - gd_fragment_affixes(D->D, index, &prefix, &suffix); + if (gd_fragment_affixes(D->D, index, &prefix, &suffix) == -1) + prefix = suffix = NULL; + dreturnvoid(); } Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/f77/fgetdata.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2013 D. V. Wiebe +/* Copyright (C) 2008-2014 D. V. Wiebe * ************************************************************************* * @@ -3142,7 +3142,10 @@ return; } - gd_entry(D, _GDF_CString(&fc, field_code, *field_code_l), &E); + if (gd_entry(D, _GDF_CString(&fc, field_code, *field_code_l), &E) == -1) { + dreturnvoid(); + return; + } switch (E.field_type) { case GD_NO_ENTRY: Modified: trunk/getdata/bindings/idl/getdata.c =================================================================== --- trunk/getdata/bindings/idl/getdata.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/idl/getdata.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2013 D. V. Wiebe +/* Copyright (C) 2009-2014 D. V. Wiebe * *************************************************************************** * @@ -5466,7 +5466,7 @@ { dtraceidl(); - int nalias; + unsigned int nalias; GDIDL_KW_ONLY_ERROR; @@ -5479,7 +5479,7 @@ IDL_KW_FREE; - IDL_VPTR r = IDL_GettmpLong(nalias); + IDL_VPTR r = IDL_GettmpUInt(nalias); dreturn("%p", r); return r; } Modified: trunk/getdata/bindings/make_parameters.c =================================================================== --- trunk/getdata/bindings/make_parameters.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/make_parameters.c 2014-02-19 00:22:56 UTC (rev 877) @@ -470,7 +470,7 @@ printf("s/@PARAMLIST@/"); for (i = 0; constant_list[i].lname != NULL; ++i) - printf("%s ", constant_list[i].sname, constant_list[i].value); + printf("%s ", constant_list[i].sname); printf("/\n"); } Modified: trunk/getdata/bindings/php/getdata.c =================================================================== --- trunk/getdata/bindings/php/getdata.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/php/getdata.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 D. V. Wiebe +/* Copyright (C) 2013, 2014 D. V. Wiebe * *************************************************************************** * @@ -1560,6 +1560,7 @@ for (i = 0; i < n; ++i) add_index_zval(a, i, gdphp_from_complex(NULL, ((float*)(data))[i * 2], ((float*)(data))[i * 2 + 1])); + break; case GD_COMPLEX128: for (i = 0; i < n; ++i) add_index_zval(a, i, gdphp_from_complex(NULL, ((double*)(data))[i * 2], @@ -3017,9 +3018,12 @@ s = gd_error_string(D, NULL, 0); - RETVAL_STRING(s, 1); - free(s); - dreturn("\"%s\"", s); + if (s) { + RETVAL_STRING(s, 1); + dreturn("\"%s\"", s); + free(s); + } else + GDPHP_RETURN_F; } PHP_FUNCTION(gd_field_list) Modified: trunk/getdata/bindings/python/pydirfile.c =================================================================== --- trunk/getdata/bindings/python/pydirfile.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/python/pydirfile.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2013 D. V. Wiebe +/* Copyright (C) 2009-2014 D. V. Wiebe * *************************************************************************** * @@ -728,6 +728,7 @@ const char *field_code; struct gdpy_entry_t *obj; gd_entry_t *E; + int e; dtrace("%p, %p, %p", self, args, keys); @@ -748,12 +749,20 @@ gd_entry(self->D, field_code, E); - PYGD_CHECK_ERROR(self->D, NULL); + if ((e = gd_error(D))) { + PYGD_REPORT_ERROR(D,e); + gd_free_entry_strings(E); + free(E); + dreturn("%p", NULL); + return NULL; + } obj = (struct gdpy_entry_t*)gdpy_entry.tp_alloc(&gdpy_entry, 0); if (obj == NULL) { PyErr_NoMemory(); + gd_free_entry_strings(E); + free(E); dreturn("%p", NULL); return NULL; } @@ -1682,7 +1691,7 @@ gd_get_string(self->D, field_code, len, data); - PYGD_CHECK_ERROR(self->D, NULL); + PYGD_CHECK_ERROR2(self->D, NULL, free(data)); pyobj = PyString_FromString(data); @@ -1848,6 +1857,7 @@ if (type == GD_UNKNOWN) { PyErr_SetString(PyExc_ValueError, "pygetdata.dirfile.put_carray() unknown data type for argument 2."); + free(data); dreturn ("%p", NULL); return NULL; } @@ -1961,6 +1971,7 @@ if (type == GD_UNKNOWN) { PyErr_SetString(PyExc_ValueError, "pygetdata.dirfile.putdata() unknown data type for argument 2."); + free(data); dreturn ("%p", NULL); return NULL; } Modified: trunk/getdata/bindings/python/pyentry.c =================================================================== --- trunk/getdata/bindings/python/pyentry.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/python/pyentry.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2013 D. V. Wiebe +/* Copyright (C) 2009-2014 D. V. Wiebe * *************************************************************************** * @@ -1828,6 +1828,8 @@ PyObject *obj = PyTuple_GetItem(value, i); if (PyComplex_Check(obj)) { comp_scal = GD_EN_COMPSCAL; + gdpy_as_complex(gd_csp_(ca[i]), obj); + a[i] = creal(ca[i]); scalar[i] = NULL; } else if (comp_scal) { gdpy_set_scalar_from_pyobj(obj, GD_COMPLEX128, scalar + i, ca + i); Modified: trunk/getdata/bindings/python/pygetdata.h =================================================================== --- trunk/getdata/bindings/python/pygetdata.h 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/bindings/python/pygetdata.h 2014-02-19 00:22:56 UTC (rev 877) @@ -69,17 +69,26 @@ #define PYGD_CHECK_ERROR2(D,R,E) \ do { \ - int the_error; \ - if ((the_error = gd_error(D))) { \ - char buffer[GD_MAX_LINE_LENGTH]; \ - PyErr_SetString(gdpy_exceptions[the_error], gd_error_string((D), \ - buffer, GD_MAX_LINE_LENGTH)); \ + int e; \ + if ((e = gd_error(D))) { \ + PYGD_REPORT_ERROR(D,e); \ E; \ dreturnvoid(); \ return (R); \ } \ } while(0) +#define PYGD_REPORT_ERROR(D,e) \ + do { \ + char *buffer = gd_error_string((D), NULL, 0); \ + if (buffer) { \ + PyErr_SetString(gdpy_exceptions[e], buffer); \ + free(buffer); \ + } else \ + PyErr_SetString(gdpy_exceptions[e], "Unspecified error"); \ + } while (0) + + extern PyObject *gdpy_exceptions[GD_N_ERROR_CODES]; extern PyTypeObject gdpy_dirfile; extern PyTypeObject gdpy_entry; Added: trunk/getdata/doc/cov_mod.c =================================================================== --- trunk/getdata/doc/cov_mod.c (rev 0) +++ trunk/getdata/doc/cov_mod.c 2014-02-19 00:22:56 UTC (rev 877) @@ -0,0 +1,87 @@ +/* This is the GetData model file for Coverity Scan. It provides hints to + * Coverity Scan's static code analysis. + * + * Although this looks like a C source file, it isn't meant to be compiled. + * Expect to see stack variables being used without initialisation. + */ + +#define assert(...) /* */ +typedef struct {int error;} DIRFILE; +typedef struct {} gd_entry_t; + +/* sets D->error to non-zero when it returns zero */ +unsigned int _GD_GetSPF(DIRFILE *D, gd_entry_t *E) +{ + unsigned int spf; + + if (spf == 0) { + assert(D->error != 0); + } + return spf; +} + +/* only allocates memory if supplied no buffer */ +char *gd_error_string(const DIRFILE *D, char *buffer, size_t buflen) +{ + if (buffer == 0) + __coverity_alloc__(buffer); + + return buffer; +} + + +/* sets D->error to non-zero when it returns NULL */ +char *_GD_MungeFrag(DIRFILE *D, const gd_entry_t *P, int me, const char *code, + int *offset) +{ + char *new_code; + if (new_code == 0) { + assert(D->error != 0); + } + return new_code; +} + +/* sets D->error to non-zero when it returns NULL */ +gd_entry_t *_GD_FindField(const DIRFILE *D, const char *field_code, + gd_entry_t *const *list, unsigned int u, int dealias, unsigned int *index) +{ + gd_entry_t *E; + if (E == 0) { + assert(D->error != 0); + } + return E; +} + +/* either sets D->error to non-zero and returns NULL or else allocates memory */ +void *_GD_Malloc(DIRFILE *D, size_t size) +{ + void *ptr; + + __coverity_alloc__(ptr); + if (ptr == 0) { + assert(D->error != 0); + } + return ptr; +} + +/* When fdopendir returns non-NULL, it has stolen the descriptor */ +typedef struct {int fd} DIR; +DIR *fdopendir(int fd) +{ + DIR *d; + if (d) { + d->fd = fd; + } + return d; +} + +int closedir(DIR *d) +{ + __coverity_close__(d->fd); +} + +/* doesn't return */ +void zend_error(int type, const char *format, ...) +{ + __coverity_panic__(); +} Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/add.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2013 D. V. Wiebe +/* Copyright (C) 2008-2014 D. V. Wiebe * *************************************************************************** * @@ -2037,25 +2037,25 @@ offset = strlen(parent) + 1; munged_code = (char *)_GD_Malloc(D, offset + strlen(field_code) + 1); - if (munged_code) { - strcpy(munged_code, parent); - munged_code[offset - 1] = '/'; - strcpy(munged_code + offset, field_code); - } - } else + if (munged_code == NULL) + goto add_alias_error; + + strcpy(munged_code, parent); + munged_code[offset - 1] = '/'; + strcpy(munged_code + offset, field_code); + } else { /* this will check for affixes and take care of detecting Barth-style * metafield definitions */ P = _GD_FixName(D, &munged_code, field_code, fragment_index, &offset); - if (D->error) - goto add_alias_error; + if (D->error) + goto add_alias_error; + } /* check alias name */ - if (munged_code && _GD_ValidateField(munged_code + offset, D->standards, 1, 0, - NULL)) - { + if (_GD_ValidateField(munged_code + offset, D->standards, 1, 0, NULL)) _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_INVALID, NULL, 0, field_code); - } else if (_GD_FindField(D, munged_code, D->entry, D->n_entries, 1, &u)) + else if (_GD_FindField(D, munged_code, D->entry, D->n_entries, 1, &u)) _GD_SetError(D, GD_E_DUPLICATE, 0, NULL, 0, munged_code); else _GD_CheckCodeAffixes(D, NULL, target, fragment_index, 1); /* check target */ Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/bzip.c 2014-02-19 00:22:56 UTC (rev 877) @@ -268,9 +268,9 @@ ptr->pos = 0; ptr->end = n; } else { - free(ptr); BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); fclose(ptr->stream); + free(ptr); dreturn("%i", -1); return -1; } Modified: trunk/getdata/src/common.c =================================================================== --- trunk/getdata/src/common.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/common.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2013 D. V. Wiebe + * Copyright (C) 2005-2014 D. V. Wiebe * *************************************************************************** * @@ -1024,7 +1024,6 @@ work = (char*)malloc(PATH_MAX); if (res == NULL || work == NULL) { free(res); - free(res); dreturn("%p", NULL); return NULL; } @@ -1164,7 +1163,7 @@ } /* get the link target */ - slen = readlink(res, target, PATH_MAX); + slen = readlink(res, target, PATH_MAX - 1); if (slen == -1) { free(res); free(work); Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/entry.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2013 D. V. Wiebe +/* Copyright (C) 2008-2014 D. V. Wiebe * *************************************************************************** * @@ -127,7 +127,7 @@ free(entry); } else { entry->field = NULL; - memset(entry->in_fields, 0, sizeof(char*) * GD_MAX_LINCOM * 2); + memset(entry->in_fields, 0, sizeof(char*) * GD_MAX_LINCOM); memset(entry->scalar, 0, sizeof(char*) * GD_MAX_LINCOM * 2); } @@ -523,8 +523,8 @@ const char **gd_aliases(DIRFILE *D, const char *field_code) gd_nothrow { gd_entry_t *E; - int n, j = 1; - unsigned u; + int j = 1; + unsigned u, n; dtrace("%p, \"%s\"", D, field_code); @@ -573,26 +573,25 @@ return E->e->alias_list; } -int gd_naliases(DIRFILE *D, const char *field_code) gd_nothrow +unsigned int gd_naliases(DIRFILE *D, const char *field_code) gd_nothrow { gd_entry_t *E; - int n = 1; - unsigned u; + unsigned u, n = 1; dtrace("%p, \"%s\"", D, field_code); if (D->flags & GD_INVALID) { _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; + dreturn("%u", 0); + return 0; } E = _GD_FindField(D, field_code, D->entry, D->n_entries, 1, NULL); if (E == NULL) { _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code); - dreturn("%i", -1); - return -1; + dreturn("%u", 0); + return 0; } for (u = 0; u < D->n_entries; ++u) @@ -602,7 +601,7 @@ n++; } - dreturn("%i", n); + dreturn("%u", n); return n; } @@ -870,7 +869,8 @@ free(field_code); if (E->field_type != GD_LINTERP_ENTRY) { - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, + field_code_in); dreturn("%p", NULL); return NULL; } Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/getdata.h.in 2014-02-19 00:22:56 UTC (rev 877) @@ -1,6 +1,6 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield * Copyright (C) 2003-2005 Theodore Kisner - * Copyright (C) 2005-2013 D. V. Wiebe + * Copyright (C) 2005-2014 D. V. Wiebe * *************************************************************************** * @@ -855,8 +855,8 @@ extern const char *gd_dirfilename(DIRFILE *dirfile) gd_nothrow gd_nonnull ((1)); -extern int gd_naliases(DIRFILE *dirfile, const char *field_code) gd_nothrow -gd_nonnull ((1,2)); +extern unsigned int gd_naliases(DIRFILE *dirfile, + const char *field_code) gd_nothrow gd_nonnull ((1,2)); extern gd_type_t gd_native_type(DIRFILE *dirfile, const char *field_code) gd_nothrow gd_nonnull ((1,2)); @@ -921,7 +921,7 @@ gd_nonnull((1,2)); extern int gd_verbose_prefix(DIRFILE *D, const char *prefix) gd_nothrow -gd_nonnull ((1,2)); +gd_nonnull ((1)); extern const char **gd_vector_list(DIRFILE *dirfile) gd_nothrow gd_nonnull((1)); Modified: trunk/getdata/src/gzip.c =================================================================== --- trunk/getdata/src/gzip.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/gzip.c 2014-02-19 00:22:56 UTC (rev 877) @@ -45,11 +45,6 @@ if (mode & GD_FILE_READ) { file->idata = gd_OpenAt(file->D, fd, file->name, O_RDONLY | O_BINARY, 0666); - - if (file->idata == -1) { - dreturn("%i", 1); - return 1; - } gzmode = "r"; } else if (mode & GD_FILE_TEMP) { file->idata = _GD_MakeTempFile(file->D, fd, file->name); @@ -59,6 +54,11 @@ return 1; } + if (file->idata == -1) { + dreturn("%i", 1); + return 1; + } + file->edata = gzdopen(file->idata, gzmode); if (file->edata == NULL) { Modified: trunk/getdata/src/include.c =================================================================== --- trunk/getdata/src/include.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/include.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2011 D. V. Wiebe +/* Copyright (C) 2008-2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -197,6 +197,7 @@ ptr = _GD_Realloc(D, D->fragment, (++D->n_fragment) * sizeof(struct gd_fragment_t)); if (ptr == NULL) { + fclose(new_fp); _GD_ReleaseDir(D, dirfd); D->n_fragment--; goto include_error; Modified: trunk/getdata/src/lzma.c =================================================================== --- trunk/getdata/src/lzma.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/lzma.c 2014-02-19 00:22:56 UTC (rev 877) @@ -110,11 +110,9 @@ int _GD_LzmaOpen(int dirfd, struct gd_raw_file_* file, int swap gd_unused_, unsigned int mode gd_unused_) { - struct gd_lzmadata *ptr; - dtrace("%i, %p, <unused>, <unused>", dirfd, file); - file->edata = ptr = _GD_LzmaDoOpen(dirfd, file); + file->edata = _GD_LzmaDoOpen(dirfd, file); if (file->edata == NULL) { dreturn("%i", 1); Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/mod.c 2014-02-19 00:22:56 UTC (rev 877) @@ -112,8 +112,6 @@ *(int32_t *)lout = *(int32_t *)lin; else if (type == GD_UINT32) *(uint32_t *)lout = *(uint32_t *)lin; - else if (type == GD_INT64) - *(int64_t *)lout = *(int64_t *)lin; else if (type == GD_UINT64) *(uint64_t *)lout = *(uint64_t *)lin; else Modified: trunk/getdata/src/name.c =================================================================== --- trunk/getdata/src/name.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/name.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2013 D. V. Wiebe +/* Copyright (C) 2008-2014 D. V. Wiebe * *************************************************************************** * @@ -694,6 +694,7 @@ * fails */ rdat->meta_name = (char**)_GD_Malloc(D, sizeof(char *) * rdat->n_meta); if (!rdat->meta_name) { + _GD_CleanUpRename(rdat, 1); dreturn("%p", NULL); return NULL; } Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/open.c 2014-02-19 00:22:56 UTC (rev 877) @@ -347,6 +347,10 @@ _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_FORMAT, format_file, errno, NULL); free(dirfile); free(format_file); +#ifndef GD_NO_DIR_OPEN + if (dirfd >= 0) + close(dirfd); +#endif dreturn("%p", NULL); return NULL; } @@ -364,6 +368,10 @@ free(dirfile); free(format_file); close(fd); +#ifndef GD_NO_DIR_OPEN + if (dirfd >= 0) + close(dirfd); +#endif dreturn("%p", NULL); return NULL; } @@ -459,7 +467,8 @@ if (D == NULL) { free(dirfile); #ifndef GD_NO_DIR_OPEN - close(dirfd); + if (dirfd >= 0) + close(dirfd); #endif dreturn("%p", NULL); return NULL; @@ -482,7 +491,8 @@ if (dirfile == NULL) { _GD_SetError(D, GD_E_OPEN, GD_E_OPEN_IO, filedir, dirfd_error, NULL); #ifndef GD_NO_DIR_OPEN - close(dirfd); + if (dirfd >= 0) + close(dirfd); #endif dreturn("%p", D); return D; @@ -524,7 +534,8 @@ if ((fp = _GD_CreateDirfile(D, dirfd, dirfd_error, dirfile, &mtime)) == NULL) { #ifndef GD_NO_DIR_OPEN - close(dirfd); + if (dirfd >= 0) + close(dirfd); #endif D->name = NULL; /* so a subsequent gd_discard() doesn't go awry. */ dreturn("%p", D); @@ -536,6 +547,7 @@ D->name = strdup(filedir); if (D->name == NULL) { + fclose(fp); _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); dreturn("%p", D); return D; Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/parse.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2013 D. V. Wiebe + * Copyright (C) 2005-2014 D. V. Wiebe * *************************************************************************** * @@ -1335,6 +1335,8 @@ _GD_FreeE(D, E, 1); _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, in_cols[c]); + dreturn("%p", NULL); + return NULL; } } @@ -1626,15 +1628,6 @@ _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_BAD_LINE, format_file, linenum, NULL); - if (is_dot) { - ptr = _GD_Realloc(D, D->dot_list, (D->n_dot + 1) * sizeof(gd_entry_t*)); - if (ptr == NULL) { - dreturn ("%p", NULL); - return NULL; - } - D->dot_list = (gd_entry_t **)ptr; - } - if (insert && D->error == GD_E_OK && E != NULL) { /* the Format file fragment index */ unsigned int u; @@ -1651,6 +1644,16 @@ return NULL; } + if (is_dot) { + ptr = _GD_Realloc(D, D->dot_list, (D->n_dot + 1) * sizeof(gd_entry_t*)); + if (ptr == NULL) { + _GD_FreeE(D, E, 1); + dreturn ("%p", NULL); + return NULL; + } + D->dot_list = (gd_entry_t **)ptr; + } + /* Initialse the meta counts */ if (P != NULL) { E->e->n_meta = -1; @@ -1663,6 +1666,9 @@ dreturn ("%p", NULL); return NULL; } + + /* Nothing may fail from now on */ + P->e->p.meta_entry = (gd_entry_t **)ptr; P->e->p.meta_entry[P->e->n_meta++] = E; } Modified: trunk/getdata/src/putdata.c =================================================================== --- trunk/getdata/src/putdata.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/putdata.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,6 +1,6 @@ /* Copyright (C) 2003-2005 C. Barth Netterfield * Copyright (C) 2003-2005 Theodore Kisner - * Copyright (C) 2005-2013 D. V. Wiebe + * Copyright (C) 2005-2014 D. V. Wiebe * *************************************************************************** * @@ -574,6 +574,7 @@ cntbuf = (int*)_GD_Alloc(D, GD_INT_TYPE, num_samp2); if (tmpbuf == NULL || cntbuf == NULL) { + free(cntbuf); free(tmpbuf); dreturn("%i", 0); return 0; Modified: trunk/getdata/src/sie.c =================================================================== --- trunk/getdata/src/sie.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/sie.c 2014-02-19 00:22:56 UTC (rev 877) @@ -335,7 +335,7 @@ f->p += nelem - count; count = nelem; } else { - cur = _GD_Duplicate(cur, f->d + 1, GD_SIZE(data_type), f->s - f->p + 1); + _GD_Duplicate(cur, f->d + 1, GD_SIZE(data_type), f->s - f->p + 1); count += f->s - f->p + 1; f->p = f->s + 1; } @@ -569,6 +569,7 @@ /* truncate the file if necessary */ if (rin < rout) { if (gd_truncate(fileno(f->fp), (nrec - rout + rin) * size)) { + free(p); dreturn("%i", -1); return -1; } Modified: trunk/getdata/src/types.c =================================================================== --- trunk/getdata/src/types.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/src/types.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2010 D. V. Wiebe + * Copyright (C) 2005-2010, 2014 D. V. Wiebe * *************************************************************************** * @@ -633,6 +633,7 @@ _GD_SetError(D, GD_E_BAD_TYPE, out_type, NULL, 0, NULL); break; } + break; case GD_COMPLEX128: switch (out_type) { case GD_INT8: Modified: trunk/getdata/test/add_alias.c =================================================================== --- trunk/getdata/test/add_alias.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/add_alias.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 D. V. Wiebe +/* Copyright (C) 2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -26,7 +26,8 @@ const char *format = "dirfile/format"; const char *data = "dirfile/data"; const char *target; - int error, i, n, r = 0; + int error, i, r = 0; + unsigned int n; DIRFILE *D; rmdirfile(); @@ -51,7 +52,7 @@ CHECKI(error, GD_E_OK); CHECKI(i, 0); - CHECKI(n, 2); + CHECKU(n, 2); return r; } Modified: trunk/getdata/test/add_alias_affix.c =================================================================== --- trunk/getdata/test/add_alias_affix.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/add_alias_affix.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 D. V. Wiebe +/* Copyright (C) 2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -27,7 +27,8 @@ const char *format1 = "dirfile/format"; const char *data = "dirfile/data"; const char *target; - int e1, e2, e3, i, n, r = 0; + int e1, e2, e3, i, r = 0; + unsigned int n; DIRFILE *D; rmdirfile(); @@ -60,7 +61,7 @@ CHECKI(e2, GD_E_BAD_CODE); CHECKI(e3, GD_E_OK); CHECKI(i, 1); - CHECKI(n, 2); + CHECKU(n, 2); return r; } Modified: trunk/getdata/test/add_alias_meta.c =================================================================== --- trunk/getdata/test/add_alias_meta.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/add_alias_meta.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 D. V. Wiebe +/* Copyright (C) 2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -26,8 +26,9 @@ const char *format = "dirfile/format"; const char *data = "dirfile/data"; const char *target; - int error, i, n, r = 0; + int error, i, r = 0; DIRFILE *D; + unsigned int n; rmdirfile(); @@ -51,7 +52,7 @@ CHECKI(error, GD_E_OK); CHECKI(i, 0); - CHECKI(n, 2); + CHECKU(n, 2); return r; } Modified: trunk/getdata/test/add_resolv.c =================================================================== --- trunk/getdata/test/add_resolv.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/add_resolv.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 D. V. Wiebe +/* Copyright (C) 2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -25,7 +25,8 @@ const char *filedir = "dirfile"; const char *format = "dirfile/format"; const char *data = "dirfile/data"; - int error, i, n, r = 0; + int error, i, r = 0; + unsigned int n; DIRFILE *D; const char *target; @@ -51,7 +52,7 @@ CHECKI(error, GD_E_OK); CHECKI(i, 0); - CHECKI(n, 2); + CHECKU(n, 2); return r; } Modified: trunk/getdata/test/add_spec_resolv.c =================================================================== --- trunk/getdata/test/add_spec_resolv.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/add_spec_resolv.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 D. V. Wiebe +/* Copyright (C) 2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -25,7 +25,8 @@ const char *filedir = "dirfile"; const char *format = "dirfile/format"; const char *data = "dirfile/data"; - int error, i, n, r = 0; + int error, i, r = 0; + unsigned int n; DIRFILE *D; const char *target; @@ -51,7 +52,7 @@ CHECKI(error, GD_E_OK); CHECKI(i, 0); - CHECKI(n, 2); + CHECKU(n, 2); return r; } Modified: trunk/getdata/test/alias_num.c =================================================================== --- trunk/getdata/test/alias_num.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/alias_num.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011, 2013 D. V. Wiebe +/* Copyright (C) 2011, 2013, 2014 D. V. Wiebe * *************************************************************************** * @@ -31,7 +31,8 @@ "/ALIAS c d\n" "/ALIAS d f\n" "f CONST UINT8 1\n"; - int fd, e, n, r = 0; + int fd, e, r = 0; + unsigned int n; DIRFILE *D; rmdirfile(); @@ -47,7 +48,7 @@ e = gd_error(D); CHECKI(e, GD_E_OK); - CHECKI(n, 6); + CHECKU(n, 6); gd_discard(D); unlink(format); Modified: trunk/getdata/test/alias_num_alias.c =================================================================== --- trunk/getdata/test/alias_num_alias.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/alias_num_alias.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011, 2013 D. V. Wiebe +/* Copyright (C) 2011, 2013, 2014 D. V. Wiebe * *************************************************************************** * @@ -31,7 +31,8 @@ "/ALIAS c d\n" "/ALIAS d f\n" "f CONST UINT8 1\n"; - int fd, e, n, r = 0; + int fd, e, r = 0; + unsigned int n; DIRFILE *D; rmdirfile(); @@ -47,7 +48,7 @@ e = gd_error(D); CHECKI(e, GD_E_OK); - CHECKI(n, 6); + CHECKU(n, 6); gd_discard(D); unlink(format); Modified: trunk/getdata/test/alias_num_missing.c =================================================================== --- trunk/getdata/test/alias_num_missing.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/alias_num_missing.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011, 2013 D. V. Wiebe +/* Copyright (C) 2011, 2013, 2014 D. V. Wiebe * *************************************************************************** * @@ -30,7 +30,8 @@ "/ALIAS b d\n" "/ALIAS c d\n" "/ALIAS d f\n"; - int fd, e, n, r = 0; + int fd, e, r = 0; + unsigned n; DIRFILE *D; rmdirfile(); @@ -46,7 +47,7 @@ e = gd_error(D); CHECKI(e, GD_E_BAD_CODE); - CHECKI(n, -1); + CHECKU(n, 0); gd_discard(D); unlink(format); Modified: trunk/getdata/test/madd_alias.c =================================================================== --- trunk/getdata/test/madd_alias.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/madd_alias.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 D. V. Wiebe +/* Copyright (C) 2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -25,8 +25,9 @@ const char *filedir = "dirfile"; const char *format = "dirfile/format"; const char *data = "dirfile/data"; - int error, i, n, r = 0; + int error, i, r = 0; DIRFILE *D; + unsigned int n; const char *target; rmdirfile(); @@ -51,7 +52,7 @@ CHECKI(error, GD_E_OK); CHECKI(i, 0); - CHECKI(n, 2); + CHECKU(n, 2); return r; } Modified: trunk/getdata/test/madd_alias_affix.c =================================================================== --- trunk/getdata/test/madd_alias_affix.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/madd_alias_affix.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 D. V. Wiebe +/* Copyright (C) 2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -27,7 +27,8 @@ const char *format1 = "dirfile/format"; const char *data = "dirfile/data"; const char *target1, *target2; - int e1, e2, e3, e4, e5, i, n, r = 0; + int e1, e2, e3, e4, e5, i, r = 0; + unsigned int n; DIRFILE *D; rmdirfile(); @@ -69,7 +70,7 @@ CHECKI(e4, GD_E_OK); CHECKI(e5, GD_E_OK); CHECKI(i, 1); - CHECKI(n, 4); + CHECKU(n, 4); return r; } Modified: trunk/getdata/test/madd_spec_resolv.c =================================================================== --- trunk/getdata/test/madd_spec_resolv.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/test/madd_spec_resolv.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 D. V. Wiebe +/* Copyright (C) 2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -25,7 +25,8 @@ const char *filedir = "dirfile"; const char *format = "dirfile/format"; const char *data = "dirfile/data"; - int error, i, n, r = 0; + int error, i, r = 0; + unsigned int n; DIRFILE *D; const char *target; @@ -52,7 +53,7 @@ CHECKI(error, GD_E_OK); CHECKI(i, 0); - CHECKI(n, 2); + CHECKU(n, 2); return r; } Modified: trunk/getdata/util/checkdirfile.c =================================================================== --- trunk/getdata/util/checkdirfile.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/util/checkdirfile.c 2014-02-19 00:22:56 UTC (rev 877) @@ -82,7 +82,8 @@ return 1; } - /* open the dirfile */ + /* open the dirfile -- the callback will print syntax errors as + * found, and return the number of lines with errors in ne. */ puts("Checking syntax..."); dirfile = gd_cbopen(argv[1], GD_RDONLY, callback, &ne); @@ -107,6 +108,10 @@ printf(" Syntax OK.\n\n"); + /* Run through every known standards version and check whether the dirfile + * is conformant by trying to set the loaded dirfile's version to that + * value + */ for (i = 0; i <= GD_DIRFILE_STANDARDS_VERSION; ++i) { if (gd_dirfile_standards(dirfile, i) == i) { vers[i] = 1; @@ -121,6 +126,7 @@ printf("Dirfile conforms to Standards %s ", (nvers == 1) ? "Version" : "Versions"); + /* pretty-print the list of conformed versions */ for (i = 0; i <= GD_DIRFILE_STANDARDS_VERSION; ++i) { if (vers[i]) { if (first == -1) @@ -161,7 +167,7 @@ } - /* Check the validity of each field defined */ + /* Check the validity of each entry defined */ ne = 0; puts("\nChecking fields..."); flist = gd_entry_list(dirfile, NULL, 0, GD_ENTRIES_HIDDEN | @@ -186,6 +192,8 @@ nfields++; } + /* ferret out dangling meta ALIASes by first collecting a list + * of all of them, and then trying to use them as field codes */ mflist = gd_entry_list(dirfile, flist[i], GD_ALIAS_ENTRIES, GD_ENTRIES_HIDDEN); for (j = 0; mflist[j] != NULL; ++j) { @@ -205,7 +213,8 @@ } } - /* look for dangling aliases */ + /* ferret out dangling ALIASes by first collecting a list + * of all of them, and then trying to use them as field codes */ flist = gd_entry_list(dirfile, NULL, GD_ALIAS_ENTRIES, GD_ENTRIES_HIDDEN); for (i = 0; flist[i] != NULL; ++i) { if (gd_entry_type(dirfile, flist[i]) == GD_NO_ENTRY) { Modified: trunk/getdata/util/dirfile2ascii.c =================================================================== --- trunk/getdata/util/dirfile2ascii.c 2014-02-13 21:26:18 UTC (rev 876) +++ trunk/getdata/util/dirfile2ascii.c 2014-02-19 00:22:56 UTC (rev 877) @@ -1,5 +1,5 @@ /* Copyright (C) 2010, 2011 Matthew Truch - * Copyright (C) 2010 D. V. Wiebe + * Copyright (C) 2010, 2014 D. V. Wiebe * *************************************************************************** * @@ -61,7 +61,7 @@ void version(void) { printf("dirfile2ascii (%s)\n" - "Copyright (C) 2010 Matthew Truch\n\n" + "Copyright (C) 2010, 2011, 2014 Matthew Truch and others\n\n" "Please send reports of bugs and other communication to:\n %s\n\n" "This program comes with NO WARRANTY, not even for MERCHANTABILITY " "or FITNESS\n" @@ -236,7 +236,7 @@ if (dirfile_name == NULL) { dirfile_name = optarg; } else { /* Standard output field */ - if (numfields > BUF_LEN) { + if (numfields >= BUF_LEN) { fprintf(stderr, "Error: Too many fields!\n"); exit(-2); } @@ -260,7 +260,7 @@ case 'F': case 'A': case 'a': - if (numfields > BUF_LEN) { + if (numfields >= BUF_LEN) { fprintf(stderr, "Error: Too many fields!\n"); exit(-2); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-02-13 21:26:21
|
Revision: 876 http://sourceforge.net/p/getdata/code/876 Author: ketiltrout Date: 2014-02-13 21:26:18 +0000 (Thu, 13 Feb 2014) Log Message: ----------- Typos. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/python/pyfragment.c trunk/getdata/doc/README.f77 Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2013-12-17 23:55:22 UTC (rev 875) +++ trunk/getdata/ChangeLog 2014-02-13 21:26:18 UTC (rev 876) @@ -1,3 +1,7 @@ +2014-02-21 D. V. Wiebe <ge...@ke...> svn:876 + * bindings/python/pyfragment.c (gdpy_fragment_init): Fix typo in keyword + names. + 2013-12-17 D. V. Wiebe <ge...@ke...> svn:875 * src/add.c (_GD_Add) src/fpos.c (_GD_GetFilePos _GD_WriteSeek _GD_Seek) src/getdata.c (_GD_DoRaw) src/mod.c (_GD_Change) src/move.c @@ -3067,7 +3071,7 @@ * util/dirfile2ascii.c util/checkdirfile.c: Update for new function names. - * util/checkdirifle.c: Report standards version compliance. + * util/checkdirfile.c: Report standards version compliance. * bindings/python/test/big_test.py bindings/cxx/test/big_test.cpp bindings/f77/test/big_test.f bindings/f77/test/big_test95.f90 Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2013-12-17 23:55:22 UTC (rev 875) +++ trunk/getdata/NEWS 2014-02-13 21:26:18 UTC (rev 876) @@ -20,7 +20,7 @@ * BUG FIX: When performing a metadata update due to a renamed field, the field codes containing subfields of the renamed field are now also updated, - including field codes specifying meta subfield which do not exist. + including field codes specifying meta subfields which do not exist. * BUG FIX: The gd_[m]add() functions now ignore zero-length scalar strings. Previously they would store these invalid field codes, causing problems @@ -117,8 +117,8 @@ field_end which is beyond the end of field, and then is required to extrapolate outside of the specified frame range. - * BUG FIX: gd_add_polynom() and similar now produce the correct error string - when encountering a poly_ord out of range. + * BUG FIX: gd_error_string() now produces the correct string when reporting + an out-of-range poly_ord encountered by gd_add_polynom() and similar. * BUG FIX: gd_alter_raw() and similar no longer fail when asked to re-encode the data file of a RAW field which has not been previously accessed. @@ -182,6 +182,9 @@ * IDL BUG FIX: the /UPDATEDB flag to gd_rename now operates as expected. Previously it would act like /MOVE_DATA. + * PYTHON BUG FIX: The keyword for the "dirfile" parameter in the + getdata.fragment constructor is now properly spelled. + |==============================================================================| New in verison 0.8.5: @@ -1442,7 +1445,7 @@ Miscellaneous: - * BUG FIX: The dirifle_madd_bit(3) manual page has been corrected to show + * BUG FIX: The dirfile_madd_bit(3) manual page has been corrected to show the correct order or parameters for all the dirfile_madd_<field_type> functions. Modified: trunk/getdata/bindings/python/pyfragment.c =================================================================== --- trunk/getdata/bindings/python/pyfragment.c 2013-12-17 23:55:22 UTC (rev 875) +++ trunk/getdata/bindings/python/pyfragment.c 2014-02-13 21:26:18 UTC (rev 876) @@ -50,7 +50,7 @@ static int gdpy_fragment_init(struct gdpy_fragment_t *self, PyObject *args, PyObject *keys) { - char *keywords[] = {"dirifle", "index", NULL}; + char *keywords[] = {"dirfile", "index", NULL}; dtrace("%p, %p, %p", self, args, keys); Modified: trunk/getdata/doc/README.f77 =================================================================== --- trunk/getdata/doc/README.f77 2013-12-17 23:55:22 UTC (rev 875) +++ trunk/getdata/doc/README.f77 2014-02-13 21:26:18 UTC (rev 876) @@ -677,9 +677,9 @@ Input: INTEGER dirfile_unit - This wraps diriflename(3). The name of the dirfile will be returned in name. - If the name of the dirfile is longer than name_len, it will return the actual - length of the name in name_len and not modify the name argument. + This wraps gd_dirfilename(3). The name of the dirfile will be returned in + name. If the name of the dirfile is longer than name_len, it will return the + actual length of the name in name_len and not modify the name argument. * GDREFE(name, name_len, dirfile_unit, field_code, field_code_len) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2013-12-17 23:55:25
|
Revision: 875 http://sourceforge.net/p/getdata/code/875 Author: ketiltrout Date: 2013-12-17 23:55:22 +0000 (Tue, 17 Dec 2013) Log Message: ----------- Make subdirfiles work again. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/man/gd_error_count.3 trunk/getdata/src/add.c trunk/getdata/src/encoding.c trunk/getdata/src/errors.c trunk/getdata/src/fpos.c trunk/getdata/src/getdata.c trunk/getdata/src/internal.h trunk/getdata/src/mod.c trunk/getdata/src/move.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/test/Makefile.am Added Paths: ----------- trunk/getdata/test/add_raw_sub.c trunk/getdata/test/ascii_get_sub.c trunk/getdata/test/gzip_put_sub.c trunk/getdata/test/put_sub.c trunk/getdata/test/seek_sub.c trunk/getdata/test/tell_sub.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/ChangeLog 2013-12-17 23:55:22 UTC (rev 875) @@ -1,3 +1,13 @@ +2013-12-17 D. V. Wiebe <ge...@ke...> svn:875 + * src/add.c (_GD_Add) src/fpos.c (_GD_GetFilePos _GD_WriteSeek _GD_Seek) + src/getdata.c (_GD_DoRaw) src/mod.c (_GD_Change) src/move.c + (_GD_MogrifyFile) src/parse.c (_GD_ParseFieldSpec) src/putdata.c + (_GD_InitRawIO): Call _GD_InitRawIO with fragment = -1. + * test/add_raw_sub.c test/ascii_get_sub.c test/gzip_put_sub.c test/put_sub.c + test/seek_sub.c test/tell_sub.c: Added. + + * src/errors.c src/internal.h: Add GD_E_UNCLEAN_CALL suberror. + 2013-12-12 D. V. Wiebe <ge...@ke...> svn:874 * src/endian.c (_GD_CheckByteSex): Added. * src/endian.c (_GD_FileSwapBytes): Added (replacing macro in internal.h). Modified: trunk/getdata/man/gd_error_count.3 =================================================================== --- trunk/getdata/man/gd_error_count.3 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/man/gd_error_count.3 2013-12-17 23:55:22 UTC (rev 875) @@ -1,6 +1,6 @@ .\" gd_error_count.3. The gd_error_count man page. .\" -.\" Copyright (C) 2011 D. V. Wiebe +.\" Copyright (C) 2011, 2013 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_error_count 3 "18 August 2011" "Version 0.8.0" "GETDATA" +.TH gd_error_count 3 "17 December 2013" "Version 0.9.0" "GETDATA" .SH NAME gd_error_count \(em report the number of errors encountered by the GetData library @@ -22,7 +22,7 @@ .HP .nh .ad l -.BI "int gd_error_check(DIRFILE *" dirfile ); +.BI "int gd_error_count(DIRFILE *" dirfile ); .hy .ad n .SH DESCRIPTION @@ -31,14 +31,15 @@ is called with the DIRFILE object .IR dirfile , it returns the number of errors encountered by the GetData library while -operating on the specified DIRFILE object, since the DIRFILE's creation. -Calling this function resets the internal count, so that subsequent calls to +operating on +.I dirfile +since its creation. Calling this function resets the internal count, so +that subsequent calls to .BR gd_error_count () return the number of errors encountered only since the previous call to this function, for the specified DIRFILE. -The errors themselves are not cached by the library. The error status of -the +The errors themselves are not cached by the library. The error status of the .I last library call on .I dirfile Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/add.c 2013-12-17 23:55:22 UTC (rev 875) @@ -297,7 +297,7 @@ 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); - else if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, + else if (_GD_InitRawIO(D, E, NULL, -1, NULL, 0, GD_FILE_WRITE | GD_FILE_TOUCH, _GD_FileSwapBytes(D, E))) { ; Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/encoding.c 2013-12-17 23:55:22 UTC (rev 875) @@ -340,7 +340,8 @@ file[1].name = NULL; } errno = move_errno; - _GD_SetError(D, GD_E_UNCLEAN_DB, 0, D->fragment[fragment].cname, 0, NULL); + _GD_SetError(D, GD_E_UNCLEAN_DB, GD_E_UNCLEAN_CALL, + D->fragment[fragment].cname, errno, "gd_RenameAt"); D->flags |= GD_INVALID; dreturn("%i", -1); return -1; Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/errors.c 2013-12-17 23:55:22 UTC (rev 875) @@ -185,9 +185,11 @@ { GD_E_CALLBACK, 0, "Unrecognised response from callback function: {3}", 0 }, /* GD_E_ExISTS: (nothing) */ { GD_E_EXISTS, 0, "Dirfile exists", 0 }, - /* GD_E_UNCLEAN_DB: 3 = fragment */ + /* GD_E_UNCLEAN_DB: 2 = fragment, 3 = errno; 4 = call */ + { GD_E_UNCLEAN_DB, GD_E_UNCLEAN_CALL, + "Unexpected system error processing {2}; database unclean: {4}: ", 1 }, { GD_E_UNCLEAN_DB, 0, - "Unexpected system error processing {3}; database unclean", 0 }, + "Unexpected system error processing {2}; database unclean", 0 }, /* GD_E_DOMAIN: (nothing) */ { GD_E_DOMAIN, GD_E_DOMAIN_COMPLEX, "Improper domain: complex valued", 0 }, { GD_E_DOMAIN, GD_E_DOMAIN_EMPTY, "Improper domain: empty set", 0 }, Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/fpos.c 2013-12-17 23:55:22 UTC (rev 875) @@ -38,7 +38,7 @@ case GD_RAW_ENTRY: /* We must open the file to know its starting offset */ if (E->e->u.raw.file[0].idata < 0) - if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_READ, + if (_GD_InitRawIO(D, E, NULL, -1, NULL, 0, GD_FILE_READ, _GD_FileSwapBytes(D, E))) { break; @@ -174,7 +174,7 @@ if (_GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_KEEP)) { dreturn("%i", -1); return -1; - } else if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK, GD_FILE_WRITE, + } else if (_GD_InitRawIO(D, E, NULL, -1, NULL, GD_EF_SEEK, GD_FILE_WRITE, _GD_FileSwapBytes(D, E))) { dreturn("%i", -1); @@ -254,7 +254,7 @@ switch (E->field_type) { case GD_RAW_ENTRY: /* open/create the file, if necessary */ - if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK, mode, + if (_GD_InitRawIO(D, E, NULL, -1, NULL, GD_EF_SEEK, mode, _GD_FileSwapBytes(D, E))) { break; Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/getdata.c 2013-12-17 23:55:22 UTC (rev 875) @@ -284,7 +284,7 @@ if (ns > 0) { /** open the file (and cache the fp) if it hasn't been opened yet. */ - if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK | GD_EF_READ, + if (_GD_InitRawIO(D, E, NULL, -1, NULL, GD_EF_SEEK | GD_EF_READ, GD_FILE_READ, _GD_FileSwapBytes(D, E))) { free(databuffer); Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/internal.h 2013-12-17 23:55:22 UTC (rev 875) @@ -782,6 +782,8 @@ #define GD_E_REPR_UNKNOWN 1 #define GD_E_REPR_PUT 2 +#define GD_E_UNCLEAN_CALL 1 + #define GD_E_DOMAIN_COMPLEX 1 #define GD_E_DOMAIN_EMPTY 2 #define GD_E_DOMAIN_ANTITONIC 3 Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/mod.c 2013-12-17 23:55:22 UTC (rev 875) @@ -334,7 +334,7 @@ enc = gd_ef_ + E->e->u.raw.file[0].subenc; /* open the old file */ - if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_READ, + if (_GD_InitRawIO(D, E, NULL, -1, NULL, 0, GD_FILE_READ, _GD_FileSwapBytes(D, E))) { break; Modified: trunk/getdata/src/move.c =================================================================== --- trunk/getdata/src/move.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/move.c 2013-12-17 23:55:22 UTC (rev 875) @@ -146,7 +146,7 @@ } /* Open the input file, if necessary */ - if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_READ, + if (_GD_InitRawIO(D, E, NULL, -1, NULL, 0, GD_FILE_READ, _GD_FileSwapBytes(D, E))) { free(new_filebase); Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/parse.c 2013-12-17 23:55:22 UTC (rev 875) @@ -1572,7 +1572,7 @@ /* If the encoding scheme is unsupported, we can't add the field */ _GD_SetError(D, GD_E_UNSUPPORTED, 0, NULL, 0, NULL); else - _GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_WRITE | GD_FILE_TOUCH, + _GD_InitRawIO(D, E, NULL, -1, NULL, 0, GD_FILE_WRITE | GD_FILE_TOUCH, _GD_FileSwapBytes(D, E)); } Modified: trunk/getdata/src/putdata.c =================================================================== --- trunk/getdata/src/putdata.c 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/src/putdata.c 2013-12-17 23:55:22 UTC (rev 875) @@ -73,7 +73,7 @@ D->fragment[E->fragment_index].byte_sex); /* write data to file. */ - if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_WRITE, + if (_GD_InitRawIO(D, E, NULL, -1, NULL, 0, GD_FILE_WRITE, _GD_FileSwapBytes(D, E))) { free(databuffer); Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/test 2013-12-17 23:55:22 UTC (rev 875) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -53,6 +53,7 ## add_raw_invalid add_raw_spf add_raw_spf_scalar +add_raw_sub add_raw_type add_rdonly add_recip ## -141,6 +142,7 ## ascii_get ascii_get_complex ascii_get_get +ascii_get_sub ascii_nframes ascii_put ascii_sync ## -564,6 +566,7 ## gzip_put_back gzip_put_endian gzip_put_get +gzip_put_sub gzip_sync header_complex hide ## -960,6 +963,7 ## put_ss put_string put_string_protect +put_sub put_type put_uint16 put_uint32 ## -998,6 +1002,7 ## seek_neg seek_phase seek_set +seek_sub sie_get_big sie_get_little sie_move_from ## -1042,6 +1047,7 ## tell tell64 tell_multidiv +tell_sub tok_arg tok_escape tok_quote Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2013-12-17 02:04:49 UTC (rev 874) +++ trunk/getdata/test/Makefile.am 2013-12-17 23:55:22 UTC (rev 875) @@ -35,8 +35,8 @@ 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_raw_sub 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 \ add_string add_string_affix add_type add_window add_window_op @@ -60,8 +60,8 @@ alter_recip alter_recip_zero alter_scalar_affix alter_spec \ alter_spec_affix alter_spec_meta alter_spec_polynom alter_window -ASCII_TESTS=ascii_add ascii_get ascii_get_complex ascii_get_get ascii_nframes \ - ascii_put ascii_sync +ASCII_TESTS=ascii_add ascii_get ascii_get_complex ascii_get_get ascii_get_sub \ + ascii_nframes ascii_put ascii_sync BOF_TESTS=bof bof_bit bof_index bof_lincom bof_phase bof_phase_neg @@ -209,7 +209,7 @@ GZIP_TESTS=gzip_add gzip_del gzip_get gzip_get_get gzip_get_get2 gzip_get_put \ gzip_move_from gzip_move_to gzip_nframes gzip_put gzip_put_back \ - gzip_put_endian gzip_put_get gzip_sync + gzip_put_endian gzip_put_get gzip_put_sub gzip_sync HEADER_TESTS=header_complex @@ -337,7 +337,7 @@ put_multiply put_null put_off64 put_phase put_phase_noin \ put_polynom1 put_polynom2 put_polynom_noin put_protect put_rdonly \ put_recip put_recurse put_repr put_rofs put_sbit put_sf put_ss \ - put_string put_string_protect put_type put_uint16 put_uint32 \ + put_string put_string_protect put_sub put_type put_uint16 put_uint32 \ put_uint64 put_window put_zero REF_TESTS=ref ref_none ref_two @@ -348,7 +348,7 @@ repr_uint64 repr_uint8 SEEK_TESTS=seek64 seek_cur seek_end seek_foffs seek_index seek_lincom \ - seek_mult seek_neg seek_phase seek_set + seek_mult seek_neg seek_phase seek_set seek_sub SIE_TESTS=sie_get_big sie_get_little sie_move_from sie_move_to sie_nframes_big \ sie_nframes_little sie_put_append sie_put_append2 sie_put_back \ @@ -365,7 +365,7 @@ TABLE_TESTS=table table_code table_type -TELL_TESTS=tell tell64 tell_multidiv +TELL_TESTS=tell tell64 tell_multidiv tell_sub TOK_TESTS=tok_arg tok_escape tok_quote Added: trunk/getdata/test/add_raw_sub.c =================================================================== --- trunk/getdata/test/add_raw_sub.c (rev 0) +++ trunk/getdata/test/add_raw_sub.c 2013-12-17 23:55:22 UTC (rev 875) @@ -0,0 +1,85 @@ +/* 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 <stdio.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <errno.h> + +int main(void) +{ + const char *filedir = "dirfile"; + const char *subdir = "dirfile/sub"; + const char *format = "dirfile/format"; + const char *format1 = "dirfile/sub/format1"; + const char *data = "dirfile/sub/data"; + const char *format_data = "/INCLUDE sub/format1\n"; + const char *format1_data = "#\n"; + gd_entry_t e; + int error, fd, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + mkdir(subdir, 0777); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format1_data, strlen(format1_data)); + close(fd); + + D = gd_open(filedir, GD_RDWR | GD_VERBOSE | GD_UNENCODED); + gd_add_raw(D, "data", GD_UINT8, 2, 1); + 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, 1); + CHECKI(e.EN(raw,spf), 2); + CHECKI(e.EN(raw,data_type), GD_UINT8); + gd_free_entry_strings(&e); + } + + gd_discard(D); + + if (unlink(data)) { + perror("unlink"); + r = 1; + } + unlink(format1); + unlink(format); + rmdir(subdir); + rmdir(filedir); + + CHECKI(error, GD_E_OK); + return r; +} Added: trunk/getdata/test/ascii_get_sub.c =================================================================== --- trunk/getdata/test/ascii_get_sub.c (rev 0) +++ trunk/getdata/test/ascii_get_sub.c 2013-12-17 23:55:22 UTC (rev 875) @@ -0,0 +1,82 @@ +/* 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 <stdio.h> +#include <errno.h> + +int main(void) +{ + const char *filedir = "dirfile"; + const char *subdir = "dirfile/sub"; + const char *format = "dirfile/format"; + const char *format1 = "dirfile/sub/format1"; + const char *data = "dirfile/sub/data.txt"; + const char *format1_data = "data RAW UINT8 8\n"; + const char *format_data = "/INCLUDE sub/format1\n"; + unsigned char c[8]; + int fd, i, n, error, r = 0; + DIRFILE *D; + FILE* stream; + + memset(c, 0, 8); + rmdirfile(); + + mkdir(filedir, 0777); + mkdir(subdir, 0777); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format1_data, strlen(format1_data)); + close(fd); + + stream = fopen(data, "w"); + for (i = 0; i < 256; ++i) + fprintf(stream, "%i\n", i); + fclose(stream); + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + n = gd_getdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + error = gd_error(D); + + CHECKI(error, 0); + CHECKI(n, 8); + for (i = 0; i < 8; ++i) + CHECKIi(i,c[i], 40 + i); + + gd_discard(D); + + unlink(data); + unlink(format); + unlink(format1); + rmdir(subdir); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/gzip_put_sub.c =================================================================== --- trunk/getdata/test/gzip_put_sub.c (rev 0) +++ trunk/getdata/test/gzip_put_sub.c 2013-12-17 23:55:22 UTC (rev 875) @@ -0,0 +1,120 @@ +/* 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 <inttypes.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <errno.h> +#include <stdio.h> + +int main(void) +{ +#if ! (defined TEST_GZIP) || ! (defined USE_GZIP) + return 77; +#else + const char *filedir = "dirfile"; + const char *subdir = "dirfile/sub"; + const char *format = "dirfile/format"; + const char *format1 = "dirfile/sub/format1"; + const char *data_gz = "dirfile/sub/data.gz"; + const char *data = "dirfile/sub/data"; + const char *format_data = "/INCLUDE sub/format1\n"; + const char *format1_data = "data RAW UINT8 8\n"; + uint8_t c[8]; + char command[4096]; + uint8_t d; + struct stat buf; + int fd, i, n1, n2, e1, e2, e3, stat_data, unlink_data, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 0777); + mkdir(subdir, 0777); + + for (i = 0; i < 8; ++i) + c[i] = (uint8_t)(40 + i); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format1_data, strlen(format1_data)); + close(fd); + + D = gd_open(filedir, GD_RDWR | GD_GZIP_ENCODED | GD_VERBOSE); + n1 = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + e1 = gd_error(D); + CHECKI(e1, GD_E_OK); + CHECKI(n1, 8); + + n2 = gd_putdata(D, "data", 0, 0, 1, 0, GD_UINT8, c); + e2 = gd_error(D); + CHECKI(e2, GD_E_OK); + CHECKI(n2, 8); + + e3 = gd_close(D); + CHECKI(e3, 0); + + stat_data = stat(data_gz, &buf); + if (stat_data) { + perror("stat"); + } + CHECKI(stat_data, 0); + + /* uncompress */ + snprintf(command, 4096, "%s -f %s > /dev/null", GUNZIP, data); + if (gd_system(command)) { + r = 1; + } else { + fd = open(data, O_RDONLY | O_BINARY); + if (fd >= 0) { + i = 0; + while (read(fd, &d, sizeof(uint8_t))) { + if (i < 8) { + CHECKIi(i, d, i + 40); + } else if (i < 40 || i > 48) { + CHECKIi(i, d, 0); + } else + CHECKIi(i, d, i); + i++; + } + CHECKI(i, 48); + close(fd); + } + } + + unlink_data = unlink(data); + unlink(format1); + unlink(format); + rmdir(subdir); + rmdir(filedir); + + CHECKI(unlink_data, 0); + + return r; +#endif +} Added: trunk/getdata/test/put_sub.c =================================================================== --- trunk/getdata/test/put_sub.c (rev 0) +++ trunk/getdata/test/put_sub.c 2013-12-17 23:55:22 UTC (rev 875) @@ -0,0 +1,98 @@ +/* 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 <inttypes.h> +#include <stdlib.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 *subdir = "dirfile/sub"; + const char *format = "dirfile/format"; + const char *format1 = "dirfile/sub/format1"; + const char *data = "dirfile/sub/data"; + const char *format_data = "/INCLUDE sub/format1\n"; + const char *format1_data = "data RAW UINT8 8\n"; + uint8_t c[8], d; + int fd, i, n, e1, e2, r = 0; + DIRFILE *D; + struct stat buf; + + for (i = 0; i < 8; ++i) + c[i] = (uint8_t)(40 + i); + + rmdirfile(); + mkdir(filedir, 0777); + mkdir(subdir, 0777); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format1_data, strlen(format1_data)); + close(fd); + + D = gd_open(filedir, GD_RDWR | GD_UNENCODED | GD_VERBOSE); + n = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + e1 = gd_error(D); + CHECKI(n,8); + CHECKI(e1, 0); + + e2 = gd_close(D); + CHECKI(e2, 0); + + if (stat(data, &buf)) { + perror("stat"); + r = 1; + } else + CHECKI(buf.st_size, 48 * sizeof(uint8_t)); + + fd = open(data, O_RDONLY | O_BINARY); + if (fd < 0) { + perror("open"); + r = 1; + } else { + i = 0; + while (read(fd, &d, sizeof(uint8_t))) { + if (i < 40 || i > 48) { + CHECKUi(i,d,0); + } else + CHECKUi(i,d,i); + i++; + } + close(fd); + } + + unlink(data); + unlink(format1); + unlink(format); + rmdir(subdir); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/seek_sub.c =================================================================== --- trunk/getdata/test/seek_sub.c (rev 0) +++ trunk/getdata/test/seek_sub.c 2013-12-17 23:55:22 UTC (rev 875) @@ -0,0 +1,83 @@ +/* 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> + +int main(void) +{ + const char *filedir = "dirfile"; + const char *subdir = "dirfile/sub"; + const char *format = "dirfile/format"; + const char *format1 = "dirfile/sub/format1"; + const char *data = "dirfile/sub/data"; + const char *format_data = "/INCLUDE sub/format1\n"; + const char *format1_data = "data RAW UINT8 8\n"; + unsigned char data_data[256]; + int fd, e1, e2, r = 0; + off_t m, n; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + mkdir(subdir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_data[fd] = (unsigned char)fd; + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format1_data, strlen(format1_data)); + close(fd); + + fd = open(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256); + close(fd); + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + m = gd_seek(D, "data", 6, 0, GD_SEEK_SET); + e1 = gd_error(D); + CHECKI(e1, 0); + CHECKI(m, 48); + + n = gd_tell(D, "data"); + e2 = gd_error(D); + CHECKI(e2, 0); + CHECKI(n, 48); + + gd_discard(D); + + unlink(data); + unlink(format); + unlink(format1); + rmdir(subdir); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/tell_sub.c =================================================================== --- trunk/getdata/test/tell_sub.c (rev 0) +++ trunk/getdata/test/tell_sub.c 2013-12-17 23:55:22 UTC (rev 875) @@ -0,0 +1,78 @@ +/* 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> + +int main(void) +{ + const char *filedir = "dirfile"; + const char *subdir = "dirfile/sub"; + const char *format = "dirfile/format"; + const char *format1 = "dirfile/sub/format1"; + const char *data = "dirfile/sub/data"; + const char *format_data = "/INCLUDE sub/format1\n"; + const char *format1_data = "data RAW UINT8 8\nFRAMEOFFSET 6\n"; + unsigned char data_data[256]; + int fd, e1, r = 0; + off_t n; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + mkdir(subdir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_data[fd] = (unsigned char)fd; + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(format1, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format1_data, strlen(format1_data)); + close(fd); + + fd = open(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256); + close(fd); + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + n = gd_tell(D, "data"); + e1 = gd_error(D); + CHECKI(e1, 0); + CHECKI(n, 48); + + gd_discard(D); + + unlink(data); + unlink(format1); + unlink(format); + rmdir(subdir); + rmdir(filedir); + + return r; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2013-12-17 02:04:56
|
Revision: 874 http://sourceforge.net/p/getdata/code/874 Author: ketiltrout Date: 2013-12-17 02:04:49 +0000 (Tue, 17 Dec 2013) Log Message: ----------- Perform all the endianness-correction detection logic in one place (_GD_CheckByteSex) instead of duplicating it all over the place; unrelated doc updates. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/man/gd_add_bit.3 trunk/getdata/man/gd_alter_bit.3 trunk/getdata/src/add.c trunk/getdata/src/encoding.c trunk/getdata/src/endian.c trunk/getdata/src/flimits.c trunk/getdata/src/fpos.c trunk/getdata/src/getdata.c trunk/getdata/src/internal.h trunk/getdata/src/mod.c trunk/getdata/src/move.c trunk/getdata/src/nframes.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/ChangeLog 2013-12-17 02:04:49 UTC (rev 874) @@ -1,3 +1,13 @@ +2013-12-12 D. V. Wiebe <ge...@ke...> svn:874 + * src/endian.c (_GD_CheckByteSex): Added. + * src/endian.c (_GD_FileSwapBytes): Added (replacing macro in internal.h). + * src/endian.c (_GD_FixEndianness): Call _GD_CheckByteSex() to check wether + correction is needed. + + * src/getdata.c (_GD_DoRaw) src/move.c (_GD_MogrifyFile) src/putdata.c + (_GD_DoRawOut): Let _GD_FixEndianness and _GD_CheckByteSex do the endianness + logic. + 2013-12-12 D. V. Wiebe <ge...@ke...> svn:872 * configure.ac: Disable PHP bindings if we don't have a C99 compiler. Modified: trunk/getdata/man/gd_add_bit.3 =================================================================== --- trunk/getdata/man/gd_add_bit.3 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/man/gd_add_bit.3 2013-12-17 02:04:49 UTC (rev 874) @@ -311,7 +311,7 @@ is 2**24. It is larger on a 64-bit system. The C89 GetData API provides different prototypes for -.BR gd_add_clincom ()", " gd_add_cpolynom (), +.BR gd_add_clincom "(), " gd_add_cpolynom (), and .BR gd_add_crecip (): .PP @@ -331,7 +331,7 @@ .BI int " fragment_index ); .HP .BI "int gd_add_crecip(DIRFILE *" dirfile ", const char *" field_name , -.BI "const char *" in_field ", double " cdividend [2], +.BI "const char *" in_field ", const double " cdividend [2], .BI "int " fragment_index ); .hy .ad n Modified: trunk/getdata/man/gd_alter_bit.3 =================================================================== --- trunk/getdata/man/gd_alter_bit.3 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/man/gd_alter_bit.3 2013-12-17 02:04:49 UTC (rev 874) @@ -302,7 +302,7 @@ .BI "int " poly_ord ", const char *" in_fields ", const double *" ca ); .HP .BI "int gd_alter_crecip(DIRFILE *" dirfile ", const char *" field_code , -.BI "const char *" in_field ", double " cdividend [2]); +.BI "const char *" in_field ", const double " cdividend [2]); .hy .ad n .PP @@ -337,7 +337,10 @@ .BR gd_alter_crecip () is always available, and may be accessed as .BR gd_alter_crecip89 (), -with the C89 prototype, in both the C99 and C89 APIs. +with the C89 prototype, in both the C99 and C89 APIs. Passing NULL as +.I cdividend +is equivalent to specifying a dividend of zero: it indicates no change to the +dividend parameter. .SH SEE ALSO .BR gd_alter_entry (3), Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/add.c 2013-12-17 02:04:49 UTC (rev 874) @@ -298,8 +298,7 @@ GD_SIZE(E->EN(raw,data_type))) == 0) _GD_SetError(D, GD_E_BAD_TYPE, entry->EN(raw,data_type), NULL, 0, NULL); else if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, - GD_FILE_WRITE | GD_FILE_TOUCH, - _GD_FileSwapBytes(D, E->fragment_index))) + GD_FILE_WRITE | GD_FILE_TOUCH, _GD_FileSwapBytes(D, E))) { ; } else if (D->fragment[E->fragment_index].ref_name == NULL) { Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/encoding.c 2013-12-17 02:04:49 UTC (rev 874) @@ -36,6 +36,7 @@ NULL #define GD_EF_GENERIC_SET &_GD_GenericName, NULL, NULL, NULL, NULL, NULL, \ NULL, NULL, &_GD_GenericMove, &_GD_GenericUnlink + #ifdef USE_MODULES #define GD_EXT_ENCODING_NULL(sc,ex,ec,af,ff) \ { sc,ex,ec,af,ff,GD_EF_PROVIDES,GD_EF_NULL_SET } Modified: trunk/getdata/src/endian.c =================================================================== --- trunk/getdata/src/endian.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/endian.c 2013-12-17 02:04:49 UTC (rev 874) @@ -63,7 +63,7 @@ break; /* if the field's data type is one byte long, and no in-framework - * byte-swapping is required, do nothing */ + * byte-swapping is performed, do nothing */ if (D->entry[i]->e->u.raw.size == 1 && !(gd_ef_[D->entry[i]->e->u.raw.file[0].subenc].flags & GD_EF_SWAP)) continue; @@ -174,40 +174,164 @@ return D->fragment[fragment].byte_sex; } -void _GD_ArmEndianise(uint64_t* databuffer, int is_complex, size_t ns) +static void _GD_ArmEndianise(uint64_t* databuffer, size_t ns) { uint64_t *p; - dtrace("%p, %i, %zi", databuffer, is_complex, ns); + dtrace("%p, %zi", databuffer, ns); - if (is_complex) - ns *= 2; - for (p = databuffer; p < databuffer + ns; ++p) *p = ((*p & 0xffffffff) << 32) | ((*p & 0xffffffff00000000ULL) >> 32); dreturnvoid(); } -void _GD_FixEndianness(void* databuffer, size_t size, size_t ns) +/* determine byte sex flags for the machine endianness */ +#ifdef FLOATS_BIGENDIAN +#define GD_FLOAT_SEX GD_BIG_ENDIAN +#else +#define GD_FLOAT_SEX GD_LITTLE_ENDIAN +#endif + +#ifdef WORDS_BIGENDIAN +#define GD_INT_SEX GD_BIG_ENDIAN +#else +#define GD_INT_SEX GD_LITTLE_ENDIAN +#endif + +/* returns non-zero if sex1 and sex2 imply byte sex correction is required, and + * sets *arm_fix if middle-ended double correction is needed; returns + */ +int _GD_CheckByteSex(gd_type_t type, unsigned sex1, unsigned sex2, + int skip_bytes, int *restrict arm_fix) { + int endian_fix = 0; + + dtrace("0x%X, 0x%X, 0x%X, %p", type, sex1, sex2, arm_fix); + + /* the trivial case */ + if (GD_SIZE(type) < 1 || (skip_bytes && GD_SIZE(type) == 1)) { + if (arm_fix) + *arm_fix = 0; + dreturn("%i/%i", 0, 0); + return 0; + } + + /* ensure we have exactly one of GD_BIG_ENDIAN or GD_LITTLE_ENDIAN set in + * both bitfields */ + if (type & (GD_IEEE754 | GD_COMPLEX)) { + /* arm check */ + if (arm_fix) { + if (type == GD_FLOAT64 || type == GD_COMPLEX128) + *arm_fix = ((sex1 & GD_ARM_FLAG) != (sex2 & GD_ARM_FLAG)); + else + *arm_fix = 0; + } + + switch (sex1 & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)) { + case 0: + sex1 |= GD_FLOAT_SEX; + break; + case GD_LITTLE_ENDIAN | GD_BIG_ENDIAN: + sex1 &= ~GD_FLOAT_SEX; + break; + default: + break; /* bits are okay */ + } + switch (sex2 & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)) { + case 0: + sex2 |= GD_FLOAT_SEX; + break; + case GD_LITTLE_ENDIAN | GD_BIG_ENDIAN: + sex2 &= ~GD_FLOAT_SEX; + break; + default: + break; /* bits are okay */ + } + } else { + if (arm_fix) + *arm_fix = 0; + + switch (sex1 & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)) { + case 0: + sex1 |= GD_INT_SEX; + break; + case GD_LITTLE_ENDIAN | GD_BIG_ENDIAN: + sex1 &= ~GD_INT_SEX; + break; + default: + break; /* bits are okay */ + } + switch (sex2 & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)) { + case 0: + sex2 |= GD_INT_SEX; + break; + case GD_LITTLE_ENDIAN | GD_BIG_ENDIAN: + sex2 &= ~GD_INT_SEX; + break; + default: + break; /* bits are okay */ + } + } + + /* endianness check */ + endian_fix = ((sex1 & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)) != + (sex2 & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN))); + + dreturn("%i/%i", endian_fix, arm_fix ? *arm_fix : -1); + return endian_fix; +} + +/* returns non-zero if the byte sex of RAW entry E is different than the native + * machine endianness */ +int _GD_FileSwapBytes(const DIRFILE *restrict D, const gd_entry_t *restrict E) +{ + int swap; + + dtrace("%p, %p", D, E); + + swap = _GD_CheckByteSex(E->EN(raw,data_type), + D->fragment[E->fragment_index].byte_sex, 0, 0, NULL); + + dreturn("%i", swap); + return swap; +} + +void _GD_FixEndianness(void* databuffer, size_t ns, gd_type_t type, unsigned + old_sex, unsigned new_sex) +{ size_t i; + int endian_fix, arm_fix; - dtrace("%p, %zu, %" PRNsize_t, databuffer, size, ns); + dtrace("%p, %" PRNsize_t ", 0x%X, 0x%X, 0x%X", databuffer, ns, type, old_sex, + new_sex); - switch (size) { - case 2: - for (i = 0; i < ns; ++i) - ((uint16_t*)databuffer)[i] = gd_swap16(((uint16_t*)databuffer)[i]); - break; - case 4: - for (i = 0; i < ns; ++i) - ((uint32_t*)databuffer)[i] = gd_swap32(((uint32_t*)databuffer)[i]); - break; - case 8: - for (i = 0; i < ns; ++i) - ((uint64_t*)databuffer)[i] = gd_swap64(((uint64_t*)databuffer)[i]); - break; + /* compare byte sexes */ + endian_fix = _GD_CheckByteSex(type, old_sex, new_sex, 1, &arm_fix); + + /* complex data - treat as twice as many floating point */ + if (type & GD_COMPLEX) { + ns *= 2; + type = (GD_SIZE(type) >> 1) | GD_IEEE754; } + if (arm_fix) + _GD_ArmEndianise(databuffer, ns); + + if (endian_fix) + switch (GD_SIZE(type)) { + case 2: + for (i = 0; i < ns; ++i) + ((uint16_t*)databuffer)[i] = gd_swap16(((uint16_t*)databuffer)[i]); + break; + case 4: + for (i = 0; i < ns; ++i) + ((uint32_t*)databuffer)[i] = gd_swap32(((uint32_t*)databuffer)[i]); + break; + case 8: + for (i = 0; i < ns; ++i) + ((uint64_t*)databuffer)[i] = gd_swap64(((uint64_t*)databuffer)[i]); + break; + } + dreturnvoid(); } Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/flimits.c 2013-12-17 02:04:49 UTC (rev 874) @@ -201,7 +201,7 @@ ns = (*gd_ef_[E->e->u.raw.file[0].subenc].size)( D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, - E->EN(raw,data_type), _GD_FileSwapBytes(D, E->fragment_index)); + E->EN(raw,data_type), _GD_FileSwapBytes(D, E)); if (ns < 0) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/fpos.c 2013-12-17 02:04:49 UTC (rev 874) @@ -39,7 +39,7 @@ /* We must open the file to know its starting offset */ if (E->e->u.raw.file[0].idata < 0) if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_READ, - _GD_FileSwapBytes(D, E->fragment_index))) + _GD_FileSwapBytes(D, E))) { break; } @@ -175,7 +175,7 @@ dreturn("%i", -1); return -1; } else if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK, GD_FILE_WRITE, - _GD_FileSwapBytes(D, E->fragment_index))) + _GD_FileSwapBytes(D, E))) { dreturn("%i", -1); return -1; @@ -255,7 +255,7 @@ case GD_RAW_ENTRY: /* open/create the file, if necessary */ if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK, mode, - _GD_FileSwapBytes(D, E->fragment_index))) + _GD_FileSwapBytes(D, E))) { break; } Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/getdata.c 2013-12-17 02:04:49 UTC (rev 874) @@ -253,8 +253,8 @@ static size_t _GD_DoRaw(DIRFILE *restrict D, gd_entry_t *restrict E, off64_t s0, size_t ns, gd_type_t return_type, void *restrict data_out) { - size_t n_read = 0; - ssize_t samples_read; + size_t n_read, zeroed_samples = 0; + ssize_t samples_read = 0; char *databuffer; size_t zero_pad = 0; @@ -274,11 +274,10 @@ } if (zero_pad > 0) { - n_read = _GD_FillZero(databuffer, E->EN(raw,data_type), (zero_pad > ns) ? - ns : - zero_pad); - ns -= n_read; - E->e->u.raw.file[0].pos = s0 + n_read - E->EN(raw,spf) * + zeroed_samples = _GD_FillZero(databuffer, E->EN(raw,data_type), + (zero_pad > ns) ? ns : zero_pad); + ns -= zeroed_samples; + E->e->u.raw.file[0].pos = s0 + zeroed_samples - E->EN(raw,spf) * D->fragment[E->fragment_index].frame_offset; s0 = 0; } @@ -286,7 +285,7 @@ if (ns > 0) { /** open the file (and cache the fp) if it hasn't been opened yet. */ if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK | GD_EF_READ, - GD_FILE_READ, _GD_FileSwapBytes(D, E->fragment_index))) + GD_FILE_READ, _GD_FileSwapBytes(D, E))) { free(databuffer); dreturn("%i", 0); @@ -302,9 +301,9 @@ return 0; } - samples_read = - (*gd_ef_[E->e->u.raw.file[0].subenc].read)(E->e->u.raw.file, - databuffer + n_read * E->e->u.raw.size, E->EN(raw,data_type), ns); + samples_read = (*gd_ef_[E->e->u.raw.file[0].subenc].read)(E->e->u.raw.file, + databuffer + zeroed_samples * E->e->u.raw.size, E->EN(raw,data_type), + ns); if (samples_read == -1) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -313,35 +312,15 @@ return 0; } - if (gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_ECOR) { - /* convert to/from middle-ended doubles */ - if ((E->EN(raw,data_type) == GD_FLOAT64 || - E->EN(raw,data_type) == GD_COMPLEX128) && - D->fragment[E->fragment_index].byte_sex & GD_ARM_FLAG) - { - _GD_ArmEndianise((uint64_t *)(databuffer + n_read * E->e->u.raw.size), - E->EN(raw,data_type) & GD_COMPLEX, samples_read); - } + if (gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_ECOR) + _GD_FixEndianness(databuffer + zeroed_samples * E->e->u.raw.size, + samples_read, E->EN(raw,data_type), + D->fragment[E->fragment_index].byte_sex, 0); - if (D->fragment[E->fragment_index].byte_sex & -#ifdef WORDS_BIGENDIAN - GD_LITTLE_ENDIAN -#else - GD_BIG_ENDIAN -#endif - ) - { - if (E->EN(raw,data_type) & GD_COMPLEX) - _GD_FixEndianness(databuffer + n_read * E->e->u.raw.size, - E->e->u.raw.size / 2, samples_read * 2); - else - _GD_FixEndianness(databuffer + n_read * E->e->u.raw.size, - E->e->u.raw.size, samples_read); - } - } + } - n_read += samples_read; - } + n_read = samples_read + zeroed_samples; + _GD_ConvertType(D, databuffer, E->EN(raw,data_type), data_out, return_type, n_read); Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/internal.h 2013-12-17 02:04:49 UTC (rev 874) @@ -807,7 +807,12 @@ #define GD_E_ARG_NO_VERS 5 #define GD_E_ARG_BAD_VERS 6 +/* the size of the memory buffer used for various bulk I/O operations */ +#define BUFFER_SIZE 9000000 +/* number of lines chunked-in from a LINTERP table at a time */ +#define GD_LUT_CHUNK 100 + /* I/O flags */ #define GD_FILE_READ 0x1 #define GD_FILE_WRITE 0x2 @@ -899,20 +904,19 @@ } u; }; -#define GD_ENC_NONE 0 -#define GD_ENC_SLIM 1 -#define GD_ENC_GZ_RAW 2 -#define GD_ENC_BZ2_RAW 3 -#define GD_ENC_ASCII 4 -#define GD_ENC_LZMA_RAW 5 -#define GD_ENC_XZ_RAW 6 -#define GD_ENC_SIE 7 -#define GD_ENC_ZZIP 8 -#define GD_ENC_ZZSLIM 9 -#define GD_ENC_UNKNOWN 10 +/* _GD_FiniRawIO flags */ +#define GD_FINIRAW_KEEP 0x0 +#define GD_FINIRAW_DISCARD 0x1 +#define GD_FINIRAW_DEFER 0x2 +#define GD_FINIRAW_CLOTEMP 0x4 -#define GD_N_SUBENCODINGS (GD_ENC_UNKNOWN + 1) +/* number of subencodings (ie. the length of the gd_ef_ array */ +#define GD_N_SUBENCODINGS 11 +/* the last record of the gd_ef_ array is always the unknown encoding */ +#define GD_ENC_UNKNOWN (GD_N_SUBENCODINGS - 1) + +/* external module function provides flags */ #define GD_EF_NAME 0x0001 #define GD_EF_OPEN 0x0002 #define GD_EF_CLOSE 0x0004 @@ -924,21 +928,7 @@ #define GD_EF_MOVE 0x0100 #define GD_EF_UNLINK 0x0200 -#define GD_FINIRAW_KEEP 0x0 -#define GD_FINIRAW_DISCARD 0x1 -#define GD_FINIRAW_DEFER 0x2 -#define GD_FINIRAW_CLOTEMP 0x4 - -#define BUFFER_SIZE 9000000 - -#define GD_LUT_CHUNK 100 - -/* helper macro */ -#if defined ARM_ENDIAN_FLOATS || \ - ((defined WORDS_BIGENDIAN) ^ (defined FLOATS_BIGENDIAN)) -# define SCREWY_FLOATS -#endif - +/* encoding scheme method prototypes */ typedef int (*gd_ef_name_t)(DIRFILE *D, const char *, struct gd_raw_file_*, const char*, int, int); typedef int (*gd_ef_open_t)(int, struct gd_raw_file_*, int, unsigned int); @@ -955,17 +945,38 @@ /* Encoding scheme flags */ #define GD_EF_ECOR 0x1 /* post-framework byte-sex correction required */ -#define GD_EF_SWAP 0x2 /* in-framework byte-sex metadata correction required */ +#define GD_EF_SWAP 0x2 /* in-framework byte-sex metadata correction occurs */ #define GD_EF_OOP 0x4 /* writes occur out-of-place */ #define GD_EF_EDAT 0x8 /* The /ENCODING datum is used */ + +/* Just so we're clear on the difference between GD_EF_ECOR and GD_EF_SWAP: + * + * - ECOR means the data returned by the encoding framework has the byte sex of + * the fragment; GetData needs to swap bytes around after the framework + * finishes if this is different than the machine endianness. Most binary + * formats set ECOR, but TEXT doesn't, since sscanf() puts stuff into the + * machine endianness. + * + * - SWAP means that internal workings of the encoding needs to know whether + * the byte sex of the fragment is different than the machine endianness. + * This is set by SIE since its sample indices are stored in the fragment + * endianness, which need to be converted by within the encoding scheme itself + * to be able to read opposite endian data files. + * + * Note: any encoding scheme could set SWAP instead of ECOR and then perform its + * own byte sex correction to hide it from GetData proper, but this should be + * avoided because it can lead to more byte swapping than necessary. + */ + /* Encoding schemes */ extern struct encoding_t { - unsigned long int scheme; - const char* ext; - unsigned int flags; /* flags */ - const char* affix; - const char* ffname; - unsigned int provides; + unsigned long int scheme; /* scheme number (the gd_open() flag value) */ + const char* ext; /* filename extension */ + unsigned int flags; /* encoding flags */ + const char* affix; /* function name prefix (NULL for internal scheme)*/ + const char* ffname; /* /ENCODING directive name */ + unsigned int provides; /* bitfield of functions provided by external + module (0 for internal scheme) */ gd_ef_name_t name; gd_ef_open_t open; gd_ef_close_t close; @@ -980,14 +991,10 @@ /* Format file fragment metadata */ struct gd_fragment_t { - /* Canonical name (full path) */ - char* cname; - /* Subdirectory name */ - char* sname; - /* basename */ - char *bname; - /* External name (the one that appears in the format file) */ - char* ename; + char* cname; /* Canonical name (full path) */ + char* sname; /* Subdirectory name (path relative to dirfile or absolute) */ + char *bname; /* basename (filename) */ + char* ename; /* External name (the one that appears in the format file) */ void *enc_data; int modified; int parent; @@ -1011,7 +1018,7 @@ int rc; }; -/* internal flags */ +/* internal dirfile flags */ #define GD_MULTISTANDARD 0x20000000 /* have multiple standards in format */ #define GD_HAVE_VERSION 0x40000000 /* have computed the version */ #define GD_INVALID 0x80000000 /* the dirfile is invalid */ @@ -1023,6 +1030,7 @@ #define GD_REPR_MOD 'm' #define GD_REPR_ARG 'a' +/* the implicit representation */ #define GD_REPR_AUTO GD_REPR_REAL /* The DIRFILE struct. */ @@ -1089,7 +1097,6 @@ /* forward declarations */ void *_GD_Alloc(DIRFILE*, gd_type_t, size_t) __attribute_malloc__; -void _GD_ArmEndianise(uint64_t*, int, size_t); int _GD_BadInput(DIRFILE *, const gd_entry_t *, int, int); #define _GD_BadWindop(op) \ @@ -1101,6 +1108,7 @@ int _GD_CalculateEntry(DIRFILE *restrict, gd_entry_t *restrict, int); char *_GD_CanonicalPath(const char *restrict, const char *restrict); +int _GD_CheckByteSex(gd_type_t, unsigned, unsigned, int, int *restrict); gd_entry_t *_GD_CheckParent(DIRFILE *restrict D, char **restrict name, int me, int linenum); int _GD_CheckCodeAffixes(DIRFILE *D, const gd_entry_t *P, @@ -1131,12 +1139,8 @@ gd_entry_t *_GD_FindFieldAndRepr(DIRFILE *restrict, const char *restrict, char **restrict, int *restrict, unsigned int *restrict, int, int); uint64_t _GD_FindVersion(DIRFILE *D); -void _GD_FixEndianness(void* databuffer, size_t size, size_t ns); -#ifdef WORDS_BIGENDIAN -#define _GD_FileSwapBytes(D,i) ((D)->fragment[i].byte_sex & GD_LITTLE_ENDIAN) -#else -#define _GD_FileSwapBytes(D,i) ((D)->fragment[i].byte_sex & GD_BIG_ENDIAN) -#endif +void _GD_FixEndianness(void*, size_t, gd_type_t, unsigned, unsigned); +int _GD_FileSwapBytes(const DIRFILE *restrict, const gd_entry_t *restrict); int _GD_FiniRawIO(DIRFILE*, const gd_entry_t*, int, int); void _GD_Flush(DIRFILE *restrict, gd_entry_t *restrict, int, int); void _GD_FlushMeta(DIRFILE* D, int fragment, int force); @@ -1347,6 +1351,7 @@ # define gd_nothrow #endif +/* deal with GD_ANON */ #ifdef GD_C89_API # define EN(t,v) u.t.v #else Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/mod.c 2013-12-17 02:04:49 UTC (rev 874) @@ -335,7 +335,7 @@ /* open the old file */ if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_READ, - _GD_FileSwapBytes(D, E->fragment_index))) + _GD_FileSwapBytes(D, E))) { break; } else if ((*enc->seek)(E->e->u.raw.file, 0, E->EN(raw,data_type), @@ -350,7 +350,7 @@ /* Create a temporary file and open it */ if (_GD_InitRawIO(D, E, NULL, -1, enc, 0, GD_FILE_WRITE | GD_FILE_TEMP, - _GD_FileSwapBytes(D, E->fragment_index))) + _GD_FileSwapBytes(D, E))) break; else if (_GD_WriteSeek(D, E, enc, 0, GD_FILE_WRITE | GD_FILE_TEMP) == -1) Modified: trunk/getdata/src/move.c =================================================================== --- trunk/getdata/src/move.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/move.c 2013-12-17 02:04:49 UTC (rev 874) @@ -30,7 +30,7 @@ ssize_t nread, nwrote; int subencoding = GD_ENC_UNKNOWN; int i, ef_swap; - int arm_endianise; + int arm_fix = 0, endian_fix = 0; void *buffer; dtrace("%p, %p, %lu, %lu, %lli, %i, %i, %p", D, E, encoding, byte_sex, @@ -92,33 +92,41 @@ enc_in = gd_ef_ + E->e->u.raw.file[0].subenc; - /* Need to do the ARM thing? */ - arm_endianise = (((byte_sex & GD_ARM_FLAG) && (enc_out->flags & GD_EF_ECOR)) ^ - ((D->fragment[E->fragment_index].byte_sex & GD_ARM_FLAG) && - (enc_in->flags & GD_EF_ECOR))) && (E->EN(raw,data_type) == GD_FLOAT64 || - E->EN(raw,data_type) == GD_COMPLEX128); + /* if neither encoding scheme does internal byte swapping, and the data + * type can't be endianness swapped, sex differences can't matter */ + if (GD_SIZE(E->e->u.raw.size) != 1 || (enc_in->flags & GD_EF_SWAP) || + (enc_out->flags & GD_EF_SWAP)) + { + /* figure out whether endianness correction is required */ + if ((enc_in->flags & GD_EF_ECOR) || (enc_in->flags & GD_EF_ECOR)) { + unsigned in_sex = D->fragment[E->fragment_index].byte_sex; + unsigned out_sex = byte_sex; - /* Normalise endiannesses */ -#ifdef WORDS_BIGENDIAN - ef_swap = (byte_sex & GD_LITTLE_ENDIAN) ? 1 : 0; - byte_sex = ((byte_sex & GD_LITTLE_ENDIAN) && - (enc_out->flags & (GD_EF_ECOR | GD_EF_SWAP))) ^ - ((D->fragment[E->fragment_index].byte_sex & GD_LITTLE_ENDIAN) && - (enc_in->flags & (GD_EF_ECOR | GD_EF_SWAP))); -#else - ef_swap = (byte_sex & GD_BIG_ENDIAN) ? 1 : 0; - byte_sex = ((byte_sex & GD_BIG_ENDIAN) && - (enc_out->flags & (GD_EF_ECOR | GD_EF_SWAP))) ^ - ((D->fragment[E->fragment_index].byte_sex & GD_BIG_ENDIAN) && - (enc_in->flags & (GD_EF_ECOR | GD_EF_SWAP))); -#endif - /* Now byte_sex is true if endianness conversion is required. */ + /* fix endian flags for encoding behaviour */ + if (!(enc_in->flags & (GD_EF_SWAP | GD_EF_ECOR))) { + in_sex = (in_sex & ~(GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)) | + (out_sex & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)); + if (!(enc_in->flags & GD_EF_ECOR)) + in_sex = (in_sex & ~GD_ARM_FLAG) | (out_sex & GD_ARM_FLAG); + } + if (!(enc_out->flags & (GD_EF_SWAP | GD_EF_ECOR))) { + out_sex = (out_sex & ~(GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)) | + (in_sex & (GD_LITTLE_ENDIAN | GD_BIG_ENDIAN)); + if (!(enc_out->flags & GD_EF_ECOR)) + out_sex = (out_sex & ~GD_ARM_FLAG) | (in_sex | GD_ARM_FLAG); + } + + endian_fix = _GD_CheckByteSex(E->EN(raw,data_type), in_sex, out_sex, 0, + &arm_fix); + } + } + /* If all that's changing is the byte sex, but we don't need to do * endianness conversion, don't do anything */ if (offset == 0 && encoding == D->fragment[E->fragment_index].encoding && - !byte_sex && !arm_endianise && strcmp(new_filebase, - E->e->u.raw.filebase) == 0 && D->fragment[new_fragment].dirfd == + !endian_fix && !arm_fix && strcmp(new_filebase, E->e->u.raw.filebase) == 0 + && D->fragment[new_fragment].dirfd == D->fragment[E->fragment_index].dirfd) { free(new_filebase); @@ -139,13 +147,16 @@ /* Open the input file, if necessary */ if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_READ, - _GD_FileSwapBytes(D, E->fragment_index))) + _GD_FileSwapBytes(D, E))) { free(new_filebase); dreturn("%i", -1); return -1; } + /* set ef_swap, the output encoding in-framework endian correction flag */ + ef_swap = _GD_CheckByteSex(E->EN(raw,data_type), byte_sex, 0, 0, NULL); + /* Create the output file and open it. If we're changing encodings, we * could write to the new file directly. However, we use a temporary file * anyway just to keep things clean. */ @@ -202,18 +213,9 @@ if (nread == 0) break; - /* fix army-ness, if required */ - if (arm_endianise) - _GD_ArmEndianise((uint64_t *)buffer, E->EN(raw,data_type) & GD_COMPLEX, - nread); - /* swap endianness, if required */ - if (byte_sex) { - if (E->EN(raw,data_type) & GD_COMPLEX) - _GD_FixEndianness((char *)buffer, E->e->u.raw.size / 2, nread * 2); - else - _GD_FixEndianness((char *)buffer, E->e->u.raw.size, nread); - } + _GD_FixEndianness(buffer, nread, E->EN(raw,data_type), + D->fragment[E->fragment_index].byte_sex, byte_sex); nwrote = _GD_WriteOut(E, enc_out, buffer, E->EN(raw,data_type), nread, 1); Modified: trunk/getdata/src/nframes.c =================================================================== --- trunk/getdata/src/nframes.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/nframes.c 2013-12-17 02:04:49 UTC (rev 874) @@ -57,9 +57,8 @@ nf = (*gd_ef_[D->reference_field->e->u.raw.file[0].subenc].size)( D->fragment[D->reference_field->fragment_index].dirfd, - D->reference_field->e->u.raw.file, - D->reference_field->EN(raw,data_type), _GD_FileSwapBytes(D, - D->reference_field->fragment_index)); + D->reference_field->e->u.raw.file, D->reference_field->EN(raw,data_type), + _GD_FileSwapBytes(D, D->reference_field)); if (nf < 0) { _GD_SetError(D, GD_E_RAW_IO, 0, D->reference_field->e->u.raw.file[0].name, Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/parse.c 2013-12-17 02:04:49 UTC (rev 874) @@ -1573,7 +1573,7 @@ _GD_SetError(D, GD_E_UNSUPPORTED, 0, NULL, 0, NULL); else _GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_WRITE | GD_FILE_TOUCH, - _GD_FileSwapBytes(D, E->fragment_index)); + _GD_FileSwapBytes(D, E)); } /* Is this the first raw field ever defined? */ Modified: trunk/getdata/src/putdata.c =================================================================== --- trunk/getdata/src/putdata.c 2013-12-13 00:43:41 UTC (rev 873) +++ trunk/getdata/src/putdata.c 2013-12-17 02:04:49 UTC (rev 874) @@ -67,34 +67,14 @@ return 0; } - if (gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_ECOR) { - /* convert to/from middle-ended doubles */ - if ((E->EN(raw,data_type) == GD_FLOAT64 || E->EN(raw,data_type) == - GD_COMPLEX128) && - D->fragment[E->fragment_index].byte_sex & GD_ARM_FLAG) - { - _GD_ArmEndianise((uint64_t*)databuffer, E->EN(raw,data_type) & GD_COMPLEX, - ns); - } + /* fix endianness, if necessary */ + if (gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_ECOR) + _GD_FixEndianness(databuffer, ns, E->EN(raw,data_type), 0, + D->fragment[E->fragment_index].byte_sex); - if (D->fragment[E->fragment_index].byte_sex & -#ifdef WORDS_BIGENDIAN - GD_LITTLE_ENDIAN -#else - GD_BIG_ENDIAN -#endif - ) - { - if (E->EN(raw,data_type) & GD_COMPLEX) - _GD_FixEndianness((char *)databuffer, E->e->u.raw.size / 2, ns * 2); - else - _GD_FixEndianness((char *)databuffer, E->e->u.raw.size, ns); - } - } /* write data to file. */ - if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_WRITE, - _GD_FileSwapBytes(D, E->fragment_index))) + _GD_FileSwapBytes(D, E))) { free(databuffer); dreturn("%i", 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2013-12-13 00:43:44
|
Revision: 873 http://sourceforge.net/p/getdata/code/873 Author: ketiltrout Date: 2013-12-13 00:43:41 +0000 (Fri, 13 Dec 2013) Log Message: ----------- A very old typo. Modified Paths: -------------- trunk/getdata/src/getdata.h.in Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2013-12-12 03:33:54 UTC (rev 872) +++ trunk/getdata/src/getdata.h.in 2013-12-13 00:43:41 UTC (rev 873) @@ -412,7 +412,7 @@ typedef struct gd_unified_entry_ gd_entry_t; -/* The dirifle object */ +/* The dirfile object */ typedef struct gd_dirfile_ DIRFILE; /* Parser callback objects */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2013-12-12 03:33:58
|
Revision: 872 http://sourceforge.net/p/getdata/code/872 Author: ketiltrout Date: 2013-12-12 03:33:54 +0000 (Thu, 12 Dec 2013) Log Message: ----------- ANSI C fixes. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/perl/GetData.xs trunk/getdata/configure.ac trunk/getdata/src/common.c trunk/getdata/src/entry.c trunk/getdata/src/getdata.c trunk/getdata/src/internal.h trunk/getdata/src/mod.c trunk/getdata/src/name.c trunk/getdata/test/alter_clincom.c trunk/getdata/test/alter_cpolynom_null.c trunk/getdata/test/alter_entry_recode_recalc.c trunk/getdata/test/alter_entry_scalar1.c trunk/getdata/test/alter_entry_scalar3c.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/ChangeLog 2013-12-12 03:33:54 UTC (rev 872) @@ -1,3 +1,15 @@ +2013-12-12 D. V. Wiebe <ge...@ke...> svn:872 + * configure.ac: Disable PHP bindings if we don't have a C99 compiler. + + * src/common.c (_GD_CInvertData): Correct algebra in C89 INVERT macro. + * src/getdata.c (_GD_PolynomData): Implement correct C89 POLYNOMC macro. + * src/getdata.c (_GD_CDivideData): Correct algebra in C89 DIVIDEC macro. + + * src/entry.c (_GD_CalculateEntry): Return success or failure separately + from Dirfile error. + + * src/internal.h: Fix pointer arithmetic in C89 gd_cap_ macro. + 2013-12-10 D. V. Wiebe <ge...@ke...> svn:868 * src/getdata.h.in src/internal.h: Merge gd_entry_t members 'comp_scal' and 'hidden', plus private member 'calculated' into (public) member 'flags', and Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/NEWS 2013-12-12 03:33:54 UTC (rev 872) @@ -50,6 +50,9 @@ * BUG FIX: DIVIDE fields with complex valued divisors are now properly computed. + * BUG FIX: Complex-valued DIVIDE, POLYNOM, and RECIP fields are now computed + properly when the library is built in ANSI C mode. + * BUG FIX: Writing complex MPLEX fields no longer corrupts the stored data. * BUG FIX: Several fixes have been made to the sample index encoding (SIE) Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/bindings/f77/fgetdata.c 2013-12-12 03:33:54 UTC (rev 872) @@ -141,10 +141,10 @@ /* create a gd_triple_t value */ static gd_triplet_t _GDF_SetTriplet(gd_windop_t op, const void *data) { + gd_triplet_t t; + dtrace("%i, %p", op, data); - gd_triplet_t t; - switch(op) { case GD_WINDOP_EQ: case GD_WINDOP_NE: @@ -3253,11 +3253,13 @@ const int32_t *return_type, const int32_t *field_num) { const void *v; + DIRFILE *D; + unsigned int nfields; dtrace("%p, %i, 0x%x, %i", value, *dirfile, *return_type, *field_num); - DIRFILE *D = _GDF_GetDirfile(*dirfile); - unsigned int nfields = gd_nfields_by_type(D, GD_CONST_ENTRY); + D = _GDF_GetDirfile(*dirfile); + nfields = gd_nfields_by_type(D, GD_CONST_ENTRY); if (!gd_error(D) && (*field_num > 0) && (*field_num <= (int)nfields)) { v = gd_constants(D, (gd_type_t)*return_type); @@ -3301,11 +3303,13 @@ const int32_t *dirfile, const int32_t *field_num) { const char **v; + DIRFILE *D; + unsigned int nfields; dtrace("%p, %i, %i, %i", value, *value_l, *dirfile, *field_num); - DIRFILE *D = _GDF_GetDirfile(*dirfile); - unsigned int nfields = gd_nfields_by_type(D, GD_STRING_ENTRY); + D = _GDF_GetDirfile(*dirfile); + nfields = gd_nfields_by_type(D, GD_STRING_ENTRY); if (!gd_error(D) && (*field_num > 0) && (*field_num <= (int)nfields)) { v = gd_strings(D); @@ -3347,13 +3351,16 @@ /* Return the maximum string value length */ void F77_FUNC(gdstrx, GDSTRX) (int32_t *max, const int32_t *dirfile) { - dtrace("%p, %i", max, *dirfile); - const char **v; size_t len = 0; - DIRFILE *D = _GDF_GetDirfile(*dirfile); - unsigned int i, nfields = gd_nfields_by_type(D, GD_STRING_ENTRY); + DIRFILE *D; + unsigned int i, nfields; + dtrace("%p, %i", max, *dirfile); + + D = _GDF_GetDirfile(*dirfile); + nfields = gd_nfields_by_type(D, GD_STRING_ENTRY); + if (!gd_error(D)) { v = gd_strings(D); @@ -3553,10 +3560,11 @@ size_t len = 0; char *fc; unsigned int i, nalias; + DIRFILE *D; dtrace("%p, %i, %p, %i", max, *dirfile, field_code, *field_code_l); - DIRFILE* D = _GDF_GetDirfile(*dirfile); + D = _GDF_GetDirfile(*dirfile); _GDF_CString(&fc, field_code, *field_code_l); nalias = gd_naliases(D, fc); @@ -3598,11 +3606,12 @@ const char **al; char *fc; unsigned int nalias; + DIRFILE *D; dtrace("%p, %i, %i, %p, %i, %i", alias, *alias_l, *dirfile, field_code, *field_code_l, *num); - DIRFILE* D = _GDF_GetDirfile(*dirfile); + D = _GDF_GetDirfile(*dirfile); _GDF_CString(&fc, field_code, *field_code_l); nalias = gd_naliases(D, fc); @@ -4079,8 +4088,8 @@ GDF_SCIND_F2C(E.scalar_ind[0], *m1_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[0 + GD_MAX_LINCOM], *b1_scalar_ind); - E.m[0] = *m1; - E.b[0] = *b1; + E.EN(lincom,m[0]) = *m1; + E.EN(lincom,b[0]) = *b1; if (n > 1) { _GDF_CString(E.in_fields + 1, in_field2, *in_field2_l); @@ -4089,8 +4098,8 @@ GDF_SCIND_F2C(E.scalar_ind[1], *m2_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[1 + GD_MAX_LINCOM], *b2_scalar_ind); - E.m[1] = *m2; - E.b[1] = *b2; + E.EN(lincom,m[1]) = *m2; + E.EN(lincom,b[1]) = *b2; } if (n > 2) { @@ -4100,8 +4109,8 @@ GDF_SCIND_F2C(E.scalar_ind[2], *m3_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[2 + GD_MAX_LINCOM], *b3_scalar_ind); - E.m[2] = *m3; - E.b[2] = *b3; + E.EN(lincom,m[2]) = *m3; + E.EN(lincom,b[2]) = *b3; } gd_add(_GDF_GetDirfile(*dirfile), &E); @@ -4137,13 +4146,13 @@ dtrace("%i, %p, %i, %i, %p, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %p, " "%i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %p, %i, %g;%g, %p, %i, %i, " "%g;%g, %p, %i, %i, %i", *dirfile, field_code, *field_code_l, *n_fields, - in_field1, *in_field1_l, creal(*m1), cimag(*m1), m1_scalar, *m1_scalar_l, - *m1_scalar_ind, creal(*b1), cimag(*b1), b1_scalar, *b1_scalar_l, - *b1_scalar_ind, in_field2, *in_field2_l, creal(*m2), cimag(*m2), - m2_scalar, *m2_scalar_l, *m2_scalar_ind, creal(*b2), cimag(*b2), + in_field1, *in_field1_l, crealp(m1), cimagp(m1), m1_scalar, *m1_scalar_l, + *m1_scalar_ind, crealp(b1), cimagp(b1), b1_scalar, *b1_scalar_l, + *b1_scalar_ind, in_field2, *in_field2_l, crealp(m2), cimagp(m2), + m2_scalar, *m2_scalar_l, *m2_scalar_ind, crealp(b2), cimagp(b2), b2_scalar, *b2_scalar_l, *b2_scalar_ind, in_field3, *in_field3_l, - creal(*m3), cimag(*m3), m3_scalar, *m3_scalar_l, *m3_scalar_ind, - creal(*b3), cimag(*b3), b3_scalar, *b3_scalar_l, *b3_scalar_ind, + crealp(m3), cimagp(m3), m3_scalar, *m3_scalar_l, *m3_scalar_ind, + crealp(b3), cimagp(b3), b3_scalar, *b3_scalar_l, *b3_scalar_ind, *fragment_index); memset(&E, 0, sizeof(E)); @@ -4159,8 +4168,8 @@ GDF_SCIND_F2C(E.scalar_ind[0], *m1_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[0 + GD_MAX_LINCOM], *b1_scalar_ind); - gd_cp2ca_(E.cm, 0, m1); - gd_cp2ca_(E.cb, 0, b1); + gd_cp2cs_(E.EN(lincom,cm)[0], m1); + gd_cp2cs_(E.EN(lincom,cb)[0], b1); if (n > 1) { _GDF_CString(E.in_fields + 1, in_field2, *in_field2_l); @@ -4169,8 +4178,8 @@ GDF_SCIND_F2C(E.scalar_ind[1], *m2_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[1 + GD_MAX_LINCOM], *b2_scalar_ind); - gd_cp2ca_(E.cm, 1, m2); - gd_cp2ca_(E.cb, 1, b2); + gd_cp2cs_(E.EN(lincom,cm)[1], m2); + gd_cp2cs_(E.EN(lincom,cb)[1], b2); } if (n > 2) { @@ -4180,8 +4189,8 @@ GDF_SCIND_F2C(E.scalar_ind[2], *m3_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[2 + GD_MAX_LINCOM], *b3_scalar_ind); - gd_cp2ca_(E.cm, 2, m3); - gd_cp2ca_(E.cb, 2, b3); + gd_cp2cs_(E.EN(lincom,cm)[2], m3); + gd_cp2cs_(E.EN(lincom,cb)[2], b3); } gd_add(_GDF_GetDirfile(*dirfile), &E); @@ -4237,30 +4246,30 @@ case 5: _GDF_CString(E.scalar + 5, a5_scalar, *a5_scalar_l); GDF_SCIND_F2C(E.scalar_ind[5], *a5_scalar_ind); - E.a[5] = *a5; + E.EN(polynom,a[5]) = *a5; /* fallthrough */ case 4: _GDF_CString(E.scalar + 4, a4_scalar, *a4_scalar_l); GDF_SCIND_F2C(E.scalar_ind[4], *a4_scalar_ind); - E.a[4] = *a4; + E.EN(polynom,a[4]) = *a4; /* fallthrough */ case 3: _GDF_CString(E.scalar + 3, a3_scalar, *a3_scalar_l); GDF_SCIND_F2C(E.scalar_ind[3], *a3_scalar_ind); - E.a[3] = *a3; + E.EN(polynom,a[3]) = *a3; /* fallthrough */ case 2: _GDF_CString(E.scalar + 2, a2_scalar, *a2_scalar_l); GDF_SCIND_F2C(E.scalar_ind[2], *a2_scalar_ind); - E.a[2] = *a2; + E.EN(polynom,a[2]) = *a2; /* fallthrough */ default: _GDF_CString(E.scalar + 1, a1_scalar, *a1_scalar_l); GDF_SCIND_F2C(E.scalar_ind[1], *a1_scalar_ind); - E.a[1] = *a1; + E.EN(polynom,a[1]) = *a1; _GDF_CString(E.scalar + 0, a0_scalar, *a0_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *a0_scalar_ind); - E.a[0] = *a0; + E.EN(polynom,a[0]) = *a0; } gd_add(_GDF_GetDirfile(*dirfile), &E); @@ -4292,12 +4301,12 @@ dtrace("%i, %p, %i, %i, %p, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %g;%g, " "%p, %i, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %i", *dirfile, field_code, *field_code_l, *poly_ord, in_field, *in_field_l, - creal(*a0), cimag(*a0), a0_scalar, *a0_scalar_l, *a0_scalar_ind, - creal(*a1), cimag(*a1), a1_scalar, *a1_scalar_l, *a1_scalar_ind, - creal(*a2), cimag(*a2), a2_scalar, *a2_scalar_l, *a2_scalar_ind, - creal(*a3), cimag(*a3), a3_scalar, *a3_scalar_l, *a3_scalar_ind, - creal(*a4), cimag(*a4), a4_scalar, *a4_scalar_l, *a4_scalar_ind, - creal(*a5), cimag(*a5), a5_scalar, *a5_scalar_l, *a5_scalar_ind, + crealp(a0), cimagp(a0), a0_scalar, *a0_scalar_l, *a0_scalar_ind, + crealp(a1), cimagp(a1), a1_scalar, *a1_scalar_l, *a1_scalar_ind, + crealp(a2), cimagp(a2), a2_scalar, *a2_scalar_l, *a2_scalar_ind, + crealp(a3), cimagp(a3), a3_scalar, *a3_scalar_l, *a3_scalar_ind, + crealp(a4), cimagp(a4), a4_scalar, *a4_scalar_l, *a4_scalar_ind, + crealp(a5), cimagp(a5), a5_scalar, *a5_scalar_l, *a5_scalar_ind, *fragment_index); memset(&E, 0, sizeof(E)); @@ -4317,30 +4326,30 @@ case 5: _GDF_CString(E.scalar + 5, a5_scalar, *a5_scalar_l); GDF_SCIND_F2C(E.scalar_ind[5], *a5_scalar_ind); - gd_cp2ca_(E.ca, 5, a5); + gd_cp2cs_(E.EN(polynom,ca)[5], a5); /* fallthrough */ case 4: _GDF_CString(E.scalar + 4, a4_scalar, *a4_scalar_l); GDF_SCIND_F2C(E.scalar_ind[4], *a4_scalar_ind); - gd_cp2ca_(E.ca, 4, a4); + gd_cp2cs_(E.EN(polynom,ca)[4], a4); /* fallthrough */ case 3: _GDF_CString(E.scalar + 3, a3_scalar, *a3_scalar_l); GDF_SCIND_F2C(E.scalar_ind[3], *a3_scalar_ind); - gd_cp2ca_(E.ca, 3, a3); + gd_cp2cs_(E.EN(polynom,ca)[3], a3); /* fallthrough */ case 2: _GDF_CString(E.scalar + 2, a2_scalar, *a2_scalar_l); GDF_SCIND_F2C(E.scalar_ind[2], *a2_scalar_ind); - gd_cp2ca_(E.ca, 2, a2); + gd_cp2cs_(E.EN(polynom,ca)[2], a2); /* fallthrough */ default: _GDF_CString(E.scalar + 1, a1_scalar, *a1_scalar_l); GDF_SCIND_F2C(E.scalar_ind[1], *a1_scalar_ind); - gd_cp2ca_(E.ca, 1, a1); + gd_cp2cs_(E.EN(polynom,ca)[1], a1); _GDF_CString(E.scalar + 0, a0_scalar, *a0_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *a0_scalar_ind); - gd_cp2ca_(E.ca, 0, a0); + gd_cp2cs_(E.EN(polynom,ca)[0], a0); } gd_add(_GDF_GetDirfile(*dirfile), &E); @@ -4431,7 +4440,7 @@ _GDF_CString(&E.field, field_code, *field_code_l); _GDF_CString(&E.in_fields[0], in_field, *in_field_l); E.fragment_index = *fragment_index; - gd_li2cs_(E.EN(recip,dividend), dividend[0], dividend[1]); + gd_li2cs_(E.EN(recip,cdividend), dividend[0], dividend[1]); _GDF_CString(E.scalar + 0, dividend_scalar, *dividend_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *dividend_scalar_ind); @@ -4464,8 +4473,8 @@ _GDF_CString(&E.in_fields[0], in_field, *in_field_l); _GDF_CString(&E.in_fields[1], check_field, *check_field_l); E.fragment_index = *fragment_index; - E.windop = *windop; - E.threshold = _GDF_SetTriplet(E.windop, threshold); + E.EN(window,windop) = *windop; + E.EN(window,threshold) = _GDF_SetTriplet(E.EN(window,windop), threshold); _GDF_CString(E.scalar + 0, threshold_scalar, *threshold_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *threshold_scalar_ind); @@ -4502,8 +4511,8 @@ _GDF_CString(&E.in_fields[0], in_field, *in_field_l); _GDF_CString(&E.in_fields[1], count_field, *count_field_l); E.fragment_index = *fragment_index; - E.count_val = *val; - E.period = *period; + E.EN(mplex,count_val) = *val; + E.EN(mplex,period) = *period; _GDF_CString(E.scalar + 0, val_scalar, *val_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *val_scalar_ind); _GDF_CString(E.scalar + 1, period_scalar, *period_scalar_l); @@ -4647,12 +4656,12 @@ dtrace("%i, %p, %i, %i, %p, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %g;%g, " "%p, %i, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i", *dirfile, field_code, *field_code_l, *poly_ord, in_field, *in_field_l, - creal(*a0), cimag(*a0), a0_scalar, *a0_scalar_l, *a0_scalar_ind, - creal(*a1), cimag(*a1), a1_scalar, *a1_scalar_l, *a1_scalar_ind, - creal(*a2), cimag(*a2), a2_scalar, *a2_scalar_l, *a2_scalar_ind, - creal(*a3), cimag(*a3), a3_scalar, *a3_scalar_l, *a3_scalar_ind, - creal(*a4), cimag(*a4), a4_scalar, *a4_scalar_l, *a4_scalar_ind, - creal(*a5), cimag(*a5), a5_scalar, *a5_scalar_l, *a5_scalar_ind); + crealp(a0), cimagp(a0), a0_scalar, *a0_scalar_l, *a0_scalar_ind, + crealp(a1), cimagp(a1), a1_scalar, *a1_scalar_l, *a1_scalar_ind, + crealp(a2), cimagp(a2), a2_scalar, *a2_scalar_l, *a2_scalar_ind, + crealp(a3), cimagp(a3), a3_scalar, *a3_scalar_l, *a3_scalar_ind, + crealp(a4), cimagp(a4), a4_scalar, *a4_scalar_l, *a4_scalar_ind, + crealp(a5), cimagp(a5), a5_scalar, *a5_scalar_l, *a5_scalar_ind); memset(&E, 0, sizeof(E)); E.field_type = GD_POLYNOM_ENTRY; @@ -4669,30 +4678,30 @@ case 5: _GDF_CString(E.scalar + 5, a5_scalar, *a5_scalar_l); GDF_SCIND_F2C(E.scalar_ind[5], *a5_scalar_ind); - gd_cp2ca_(E.ca, 5, a5); + gd_cp2cs_(E.EN(polynom,ca)[5], a5); /* fallthrough */ case 4: _GDF_CString(E.scalar + 4, a4_scalar, *a4_scalar_l); GDF_SCIND_F2C(E.scalar_ind[4], *a4_scalar_ind); - gd_cp2ca_(E.ca, 4, a4); + gd_cp2cs_(E.EN(polynom,ca)[4], a4); /* fallthrough */ case 3: _GDF_CString(E.scalar + 3, a3_scalar, *a3_scalar_l); GDF_SCIND_F2C(E.scalar_ind[3], *a3_scalar_ind); - gd_cp2ca_(E.ca, 3, a3); + gd_cp2cs_(E.EN(polynom,ca)[3], a3); /* fallthrough */ case 2: _GDF_CString(E.scalar + 2, a2_scalar, *a2_scalar_l); GDF_SCIND_F2C(E.scalar_ind[2], *a2_scalar_ind); - gd_cp2ca_(E.ca, 2, a2); + gd_cp2cs_(E.EN(polynom,ca)[2], a2); /* fallthrough */ default: _GDF_CString(E.scalar + 1, a1_scalar, *a1_scalar_l); GDF_SCIND_F2C(E.scalar_ind[1], *a1_scalar_ind); - gd_cp2ca_(E.ca, 1, a1); + gd_cp2cs_(E.EN(polynom,ca)[1], a1); _GDF_CString(E.scalar + 0, a0_scalar, *a0_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *a0_scalar_ind); - gd_cp2ca_(E.ca, 0, a0); + gd_cp2cs_(E.EN(polynom,ca)[0], a0); } gd_alter_entry(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, @@ -4725,8 +4734,8 @@ E.field_type = GD_WINDOW_ENTRY; _GDF_CString(&E.in_fields[0], in_field, *in_field_l); _GDF_CString(&E.in_fields[1], check_field, *check_field_l); - E.windop = *windop; - E.threshold = _GDF_SetTriplet(E.windop, threshold); + E.EN(window,windop) = *windop; + E.EN(window,threshold) = _GDF_SetTriplet(E.EN(window,windop), threshold); _GDF_CString(E.scalar + 0, threshold_scalar, *threshold_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *threshold_scalar_ind); @@ -4937,8 +4946,8 @@ GDF_SCIND_F2C(E.scalar_ind[0], *m1_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[0 + GD_MAX_LINCOM], *b1_scalar_ind); - E.m[0] = *m1; - E.b[0] = *b1; + E.EN(lincom,m[0]) = *m1; + E.EN(lincom,b[0]) = *b1; if (n > 1) { _GDF_CString(E.in_fields + 1, in_field2, *in_field2_l); @@ -4947,8 +4956,8 @@ GDF_SCIND_F2C(E.scalar_ind[1], *m2_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[1 + GD_MAX_LINCOM], *b2_scalar_ind); - E.m[1] = *m2; - E.b[1] = *b2; + E.EN(lincom,m[1]) = *m2; + E.EN(lincom,b[1]) = *b2; } if (n > 2) { @@ -4958,8 +4967,8 @@ GDF_SCIND_F2C(E.scalar_ind[2], *m3_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[2 + GD_MAX_LINCOM], *b3_scalar_ind); - E.m[2] = *m3; - E.b[2] = *b3; + E.EN(lincom,m[2]) = *m3; + E.EN(lincom,b[2]) = *b3; } gd_alter_entry(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, @@ -4997,13 +5006,13 @@ dtrace("%i, %p, %i, %i, %p, %i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %p, " "%i, %g;%g, %p, %i, %i, %g;%g, %p, %i, %i, %p, %i, %g;%g, %p, %i, %i, " "%g;%g, %p, %i, %i", *dirfile, field_code, *field_code_l, *n_fields, - in_field1, *in_field1_l, creal(*m1), cimag(*m1), m1_scalar, *m1_scalar_l, - *m1_scalar_ind, creal(*b1), cimag(*b1), b1_scalar, *b1_scalar_l, - *b1_scalar_ind, in_field2, *in_field2_l, creal(*m2), cimag(*m2), - m2_scalar, *m2_scalar_l, *m2_scalar_ind, creal(*b2), cimag(*b2), + in_field1, *in_field1_l, crealp(m1), cimagp(m1), m1_scalar, *m1_scalar_l, + *m1_scalar_ind, crealp(b1), cimagp(b1), b1_scalar, *b1_scalar_l, + *b1_scalar_ind, in_field2, *in_field2_l, crealp(m2), cimagp(m2), + m2_scalar, *m2_scalar_l, *m2_scalar_ind, crealp(b2), cimagp(b2), b2_scalar, *b2_scalar_l, *b2_scalar_ind, in_field3, *in_field3_l, - creal(*m3), cimag(*m3), m3_scalar, *m3_scalar_l, *m3_scalar_ind, - creal(*b3), cimag(*b3), b3_scalar, *b3_scalar_l, *b3_scalar_ind); + crealp(m3), cimagp(m3), m3_scalar, *m3_scalar_l, *m3_scalar_ind, + crealp(b3), cimagp(b3), b3_scalar, *b3_scalar_l, *b3_scalar_ind); memset(&E, 0, sizeof(E)); E.field_type = GD_LINCOM_ENTRY; @@ -5016,8 +5025,8 @@ GDF_SCIND_F2C(E.scalar_ind[0], *m1_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[0 + GD_MAX_LINCOM], *b1_scalar_ind); - gd_cp2ca_(E.cm, 0, m1); - gd_cp2ca_(E.cb, 0, b1); + gd_cp2cs_(E.EN(lincom,cm)[0], m1); + gd_cp2cs_(E.EN(lincom,cb)[0], b1); if (n > 1) { _GDF_CString(E.in_fields + 1, in_field2, *in_field2_l); @@ -5026,8 +5035,8 @@ GDF_SCIND_F2C(E.scalar_ind[1], *m2_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[1 + GD_MAX_LINCOM], *b2_scalar_ind); - gd_cp2ca_(E.cm, 1, m2); - gd_cp2ca_(E.cb, 1, b2); + gd_cp2cs_(E.EN(lincom,cm)[1], m2); + gd_cp2cs_(E.EN(lincom,cb)[1], b2); } if (n > 2) { @@ -5037,8 +5046,8 @@ GDF_SCIND_F2C(E.scalar_ind[2], *m3_scalar_ind); GDF_SCIND_F2C(E.scalar_ind[2 + GD_MAX_LINCOM], *b3_scalar_ind); - gd_cp2ca_(E.cm, 2, m3); - gd_cp2ca_(E.cb, 2, b3); + gd_cp2cs_(E.EN(lincom,cm)[2], m3); + gd_cp2cs_(E.EN(lincom,cb)[2], b3); } gd_alter_entry(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, @@ -5163,8 +5172,8 @@ E.field_type = GD_MPLEX_ENTRY; _GDF_CString(&E.in_fields[0], in_field, *in_field_l); _GDF_CString(&E.in_fields[1], count_field, *count_field_l); - E.count_val = *val; - E.period = *period; + E.EN(mplex,count_val) = *val; + E.EN(mplex,period) = *period; _GDF_CString(E.scalar + 0, val_scalar, *val_scalar_l); GDF_SCIND_F2C(E.scalar_ind[0], *val_scalar_ind); _GDF_CString(E.scalar + 1, period_scalar, *period_scalar_l); Modified: trunk/getdata/bindings/perl/GetData.xs =================================================================== --- trunk/getdata/bindings/perl/GetData.xs 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/bindings/perl/GetData.xs 2013-12-12 03:33:54 UTC (rev 872) @@ -1359,7 +1359,8 @@ GDP_PUSHrvavcmp(E.EN(lincom,cm), E.EN(lincom,n_fields)); GDP_PUSHpvn("b"); GDP_PUSHrvavcmp(E.EN(lincom,cb), E.EN(lincom,n_fields)); - sp = gdp_store_scalars(sp, &E, ((1 << E.EN(lincom,n_fields)) - 1) * 9); + sp = gdp_store_scalars(sp, &E, + ((1 << E.EN(lincom,n_fields)) - 1) * 9); break; case GD_LINTERP_ENTRY: GDP_PUSHpvn("in_fields"); Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/configure.ac 2013-12-12 03:33:54 UTC (rev 872) @@ -929,11 +929,20 @@ fi fi -dnl matlab +dnl php if test "x$make_phpbindings" = "xyes"; then echo echo "*** Configuring PHP bindings" echo + AC_MSG_CHECKING([whether C99 is supported]) + if test "x$disable_c99" = "xno"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + make_phpbindings=no + fi +fi +if test "x$make_phpbindings" = "xyes"; then GD_PHP if test "x$have_php" = "xno"; then make_phpbindings=no Modified: trunk/getdata/src/common.c =================================================================== --- trunk/getdata/src/common.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/src/common.c 2013-12-12 03:33:54 UTC (rev 872) @@ -764,7 +764,7 @@ for (i = 0; i < n_read; i++) { \ const t d = ((t *)data)[2 * i] * ((t *)data)[2 * i] + \ ((t *)data)[2 * i + 1] * ((t *)data)[2 * i + 1]; \ - ((t *)data)[2 * i] = (t)((dividend[0] * ((t *)data)[2 * i] - \ + ((t *)data)[2 * i] = (t)((dividend[0] * ((t *)data)[2 * i] + \ dividend[1] * ((t *)data)[2 * i + 1]) / d); \ ((t *)data)[2 * i + 1] = (t)((dividend[1] * ((t *)data)[2 * i] - \ dividend[0] * ((t *)data)[2 * i]) / d); \ Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/src/entry.c 2013-12-12 03:33:54 UTC (rev 872) @@ -209,21 +209,24 @@ /* resolve non-literal scalars */ int _GD_CalculateEntry(DIRFILE *restrict D, gd_entry_t *restrict E, int err) { - int i, cs = 0; + int i, e = 0, cs = 0; dtrace("%p, %p, %i", D, E, err); switch(E->field_type) { case GD_RAW_ENTRY: - _GD_GetScalar(D, E, 0, GD_UINT_TYPE, &E->EN(raw,spf), err); + e = _GD_GetScalar(D, E, 0, GD_UINT_TYPE, &E->EN(raw,spf), err); break; case GD_POLYNOM_ENTRY: for (i = 0; i <= E->EN(polynom,poly_ord); ++i) { - _GD_GetScalar(D, E, i, GD_COMPLEX128, &E->EN(polynom,ca)[i], err); - E->EN(polynom,a)[i] = creal(E->EN(polynom,ca)[i]); + if (_GD_GetScalar(D, E, i, GD_COMPLEX128, &E->EN(polynom,ca)[i], err)) + e = 1; + else { + E->EN(polynom,a)[i] = creal(E->EN(polynom,ca)[i]); - if (!cs && cimag(E->EN(polynom,ca)[i])) - cs = 1; + if (!cs && cimag(E->EN(polynom,ca)[i])) + cs = 1; + } if (D->error) break; @@ -231,55 +234,67 @@ break; case GD_LINCOM_ENTRY: for (i = 0; i < E->EN(lincom,n_fields); ++i) { - _GD_GetScalar(D, E, i, GD_COMPLEX128, &E->EN(lincom,cm)[i], err); - E->EN(lincom,m)[i] = creal(E->EN(lincom,cm)[i]); + if (_GD_GetScalar(D, E, i, GD_COMPLEX128, &E->EN(lincom,cm)[i], err)) + e = 1; + else { + E->EN(lincom,m)[i] = creal(E->EN(lincom,cm)[i]); - if (!cs && cimag(E->EN(lincom,cm)[i])) - cs = 1; + if (!cs && cimag(E->EN(lincom,cm)[i])) + cs = 1; + } - _GD_GetScalar(D, E, i + GD_MAX_LINCOM, GD_COMPLEX128, - &E->EN(lincom,cb)[i], err); - E->EN(lincom,b)[i] = creal(E->EN(lincom,cb)[i]); + if (_GD_GetScalar(D, E, i + GD_MAX_LINCOM, GD_COMPLEX128, + &E->EN(lincom,cb)[i], err)) + { + e = 1; + } else { + E->EN(lincom,b)[i] = creal(E->EN(lincom,cb)[i]); - if (!cs && cimag(E->EN(lincom,cb)[i])) - cs = 1; + if (!cs && cimag(E->EN(lincom,cb)[i])) + cs = 1; + } if (D->error) break; } break; case GD_RECIP_ENTRY: - _GD_GetScalar(D, E, 0, GD_COMPLEX128, &E->EN(recip,cdividend), err); - E->EN(recip,dividend) = creal(E->EN(recip,cdividend)); - if (cimag(E->EN(recip,cdividend))) - cs = 1; + if (_GD_GetScalar(D, E, 0, GD_COMPLEX128, &E->EN(recip,cdividend), err)) + e = 1; + else { + E->EN(recip,dividend) = creal(E->EN(recip,cdividend)); + if (cimag(E->EN(recip,cdividend))) + cs = 1; + } break; case GD_BIT_ENTRY: case GD_SBIT_ENTRY: - _GD_GetScalar(D, E, 0, GD_INT_TYPE, &E->EN(bit,bitnum), err); - _GD_GetScalar(D, E, 1, GD_INT_TYPE, &E->EN(bit,numbits), err); + e = _GD_GetScalar(D, E, 0, GD_INT_TYPE, &E->EN(bit,bitnum), err); + e |= _GD_GetScalar(D, E, 1, GD_INT_TYPE, &E->EN(bit,numbits), err); break; case GD_PHASE_ENTRY: - _GD_GetScalar(D, E, 0, GD_INT64, &E->EN(phase,shift), err); + e = _GD_GetScalar(D, E, 0, GD_INT64, &E->EN(phase,shift), err); break; case GD_WINDOW_ENTRY: switch (E->EN(window,windop)) { case GD_WINDOP_EQ: case GD_WINDOP_NE: - _GD_GetScalar(D, E, 0, GD_INT64, &E->EN(window,threshold.i), err); + e = _GD_GetScalar(D, E, 0, GD_INT64, &E->EN(window,threshold.i), err); break; case GD_WINDOP_SET: case GD_WINDOP_CLR: - _GD_GetScalar(D, E, 0, GD_UINT64, &E->EN(window,threshold.u), err); + e = _GD_GetScalar(D, E, 0, GD_UINT64, &E->EN(window,threshold.u), + err); break; default: - _GD_GetScalar(D, E, 0, GD_FLOAT64, &E->EN(window,threshold.r), err); + e = _GD_GetScalar(D, E, 0, GD_FLOAT64, &E->EN(window,threshold.r), + err); break; } break; case GD_MPLEX_ENTRY: - _GD_GetScalar(D, E, 0, GD_INT_TYPE, &E->EN(mplex,count_val), err); - _GD_GetScalar(D, E, 1, GD_INT_TYPE, &E->EN(mplex,period), err); + e = _GD_GetScalar(D, E, 0, GD_INT_TYPE, &E->EN(mplex,count_val), err); + e |= _GD_GetScalar(D, E, 1, GD_INT_TYPE, &E->EN(mplex,period), err); break; case GD_NO_ENTRY: case GD_LINTERP_ENTRY: @@ -293,7 +308,7 @@ break; } - if (!D->error) + if (!e) E->flags |= GD_EN_CALC; if (cs) @@ -301,8 +316,8 @@ else E->flags &= ~GD_EN_COMPSCAL; - dreturn("%i", (E->flags & GD_EN_CALC) ? 1 : 0); - return (E->flags & GD_EN_CALC) ? 1 : 0; + dreturn("%i", !e); + return !e; } char* gd_raw_filename(DIRFILE* D, const char* field_code_in) gd_nothrow Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/src/getdata.c 2013-12-12 03:33:54 UTC (rev 872) @@ -386,12 +386,90 @@ #ifdef GD_NO_C99_API #define POLYNOMC(t) \ switch (n) { \ - case 2: POLYNOM2(t,2 * npts); break; \ - case 3: POLYNOM3(t,2 * npts); break; \ - case 4: POLYNOM4(t,2 * npts); break; \ - case 5: POLYNOM5(t,2 * npts); break; \ + case 2: POLYNOMC2(t,npts); break; \ + case 3: POLYNOMC3(t,npts); break; \ + case 4: POLYNOMC4(t,npts); break; \ + case 5: POLYNOMC5(t,npts); break; \ default: _GD_InternalError(D); \ } + +#define POLYNOMC5(t,npts) \ + do { \ + for (i = 0; i < npts; i++) { \ + const double x = ((t*)data)[2 * i]; \ + const double x2 = x * x; \ + const double x3 = x2 * x; \ + const double x4 = x3 * x; \ + const double x5 = x4 * x; \ + const double y = ((t*)data)[2 * i + 1]; \ + const double y2 = y * y; \ + const double y3 = y2 * y; \ + const double y4 = y3 * y; \ + const double y5 = y4 * y; \ + ((t*)data)[2 * i] = (t)( \ + a[5] * (x5 - 10 * x3 * y2 + 5 * x * y4) \ + - a[4] * (x4 - 6 * x2 * y2 + y4) - a[3] * (x3 - 3 * x * y2) \ + + a[2] * (x2 - y2) + a[1] * x + a[0] \ + ); \ + ((t*)data)[2 * i + 1] = (t)( \ + a[5] * (5 * x4 * y - 10 * x3 * y2 + y5) \ + + a[4] * (4 * x3 * y - 4 * x * y3) + a[3] * (3 * x2 * y - y3) \ + + a[2] * 2 * x * y + a[1] * y \ + ); \ + } \ + } while (0) + +#define POLYNOMC4(t,npts) \ + do { \ + for (i = 0; i < npts; i++) { \ + const double x = ((t*)data)[2 * i]; \ + const double x2 = x * x; \ + const double x3 = x2 * x; \ + const double x4 = x3 * x; \ + const double y = ((t*)data)[2 * i + 1]; \ + const double y2 = y * y; \ + const double y3 = y2 * y; \ + const double y4 = y3 * y; \ + ((t*)data)[2 * i] = (t)( \ + a[4] * (x4 - 6 * x2 * y2 + y4) + a[3] * (x3 - 3 * x * y2) \ + + a[2] * (x2 - y2) + a[1] * x + a[0] \ + ); \ + ((t*)data)[2 * i + 1] = (t)( \ + a[4] * (4 * x3 * y - 4 * x * y3) + a[3] * (3 * x2 * y - y3) \ + + a[2] * 2 * x * y + a[1] * y \ + ); \ + } \ + } while (0) + +#define POLYNOMC3(t,npts) \ + do { \ + for (i = 0; i < npts; i++) { \ + const double x = ((t*)data)[2 * i]; \ + const double x2 = x * x; \ + const double x3 = x2 * x; \ + const double y = ((t*)data)[2 * i + 1]; \ + const double y2 = y * y; \ + const double y3 = y2 * y; \ + ((t*)data)[2 * i] = (t)( \ + a[3] * (x3 - 3 * x * y2) + a[2] * (x2 - y2) + a[1] * x + a[0] \ + ); \ + ((t*)data)[2 * i + 1] = (t)( \ + a[3] * (3 * x2 * y - y3) + a[2] * 2 * x * y + a[1] * y \ + ); \ + } \ + } while (0) + +#define POLYNOMC2(t,npts) \ + do { \ + for (i = 0; i < npts; i++) { \ + const double x = ((t*)data)[2 * i]; \ + const double x2 = x * x; \ + const double y = ((t*)data)[2 * i + 1]; \ + const double y2 = y * y; \ + ((t*)data)[2 * i] = (t)(a[2] * (x2 - y2) + a[1] * x + a[0]); \ + ((t*)data)[2 * i + 1] = (t)(a[2] * 2 * x * y + a[1] * y); \ + } \ + } while (0) #else #define POLYNOMC(t) POLYNOM(complex t) #endif @@ -442,7 +520,11 @@ } #ifdef GD_NO_C99_API -#undef POLYNOMC +#undef POLYNOMC5 +#undef POLYNOMC4 +#undef POLYNOMC3 +#undef POLYNOMC2 +#undef POLYNOMC1 #define POLYNOMC5(t,npts) \ do { \ @@ -545,15 +627,6 @@ ); \ } \ } while (0) - -#define POLYNOMC(t) \ - switch (n) { \ - case 2: POLYNOMC2(t,npts); break; \ - case 3: POLYNOMC3(t,npts); break; \ - case 4: POLYNOMC4(t,npts); break; \ - case 5: POLYNOMC5(t,npts); break; \ - default: _GD_InternalError(D); \ - } #endif @@ -743,9 +816,9 @@ const int i2 = 2 * (i * spfB / spfA); \ const t x = ((t*)A)[2 * i]; \ const t y = ((t*)A)[2 * i + 1]; \ - const double d = B[i2] * B[i2] - B[i2 + 1] * B[i2 + 1]; \ + const double d = B[i2] * B[i2] + B[i2 + 1] * B[i2 + 1]; \ ((t*)A)[2 * i] = (t)((x * B[i2] + y * B[i2 + 1]) / d); \ - ((t*)A)[2 * i + 1] = (t)((x * B[i2] - y * B[i2 + 1]) / d); \ + ((t*)A)[2 * i + 1] = (t)((y * B[i2] - x * B[i2 + 1]) / d); \ } \ } while (0) Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/src/internal.h 2013-12-12 03:33:54 UTC (rev 872) @@ -155,13 +155,15 @@ /* imaginary part of (*z) */ # define cimagp(z) cimag(z) /* a pointer to element i of GD_DCOMPLEXP_t array a */ -# define gd_cap_(a,i) ((GD_DCOMPLEXP_t)(a + 2 * i)) +# define gd_cap_(a,i) (((GD_DCOMPLEXP_t)(a)) + 2 * i) /* a pointer to a complex scalar */ # define gd_csp_(a) ((GD_DCOMPLEXP_t)a) /* assign real two-element array b to scalar a */ # define gd_ra2cs_(a,b) gd_cs2cs_(a,b) /* assign scalar b to scalar a */ # define gd_cs2cs_(a,b) do { (a)[0] = (b)[0]; (a)[1] = (b)[1]; } while(0) +/* assign scalar *b to scalar a */ +# define gd_cp2cs_(a,b) gd_cs2cs_(a,b) /* assign scalar b to scalar (*a) */ # define gd_cs2cp_(a,b) gd_cs2cs_(a,b) /* assign b[i] to scalar a */ @@ -206,15 +208,16 @@ # define gd_csp_(a) (&(a)) # define gd_ra2cs_(a,b) a = *((double complex*)(b)) # define gd_cs2cs_(a,b) a = b -# define gd_cs2cp_(a,b) *a = b +# define gd_cp2cs_(a,b) a = *(b) +# define gd_cs2cp_(a,b) *(a) = b # define gd_ca2cs_(a,b,i) a = b[i] # define gd_cp2ca_(a,i,b) (a)[i] = *(b) # define gd_li2cs_(a,x,y) a = (x + _Complex_I * y) -# define gd_li2cp_(a,x,y) *a = (x + _Complex_I * y) +# define gd_li2cp_(a,x,y) *(a) = (x + _Complex_I * y) # define gd_po2cs_(a,r,p) a = (r) * cexp(p) -# define gd_po2cp_(a,r,p) *a = (r) * cexp(p) +# define gd_po2cp_(a,r,p) *(a) = (r) * cexp(p) # define gd_rs2cs_(a,b) a = b -# define gd_rs2cp_(a,b) *a = b +# define gd_rs2cp_(a,b) *(a) = b # define gd_cs2ca_(a,i,b,t) ((complex t*)a)[i] = (complex t)(b) # define gd_rs2ca_(a,i,b,t) gd_cs2ca_(a,i,b,t) # define gd_ccmpl_(a,x,y) (a == (x + _Complex_I * y)) Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/src/mod.c 2013-12-12 03:33:54 UTC (rev 872) @@ -123,7 +123,7 @@ if (D->error) r |= GD_AS_ERROR; - dreturn("%i", r); + dreturn("0x%X", r); return r; } Modified: trunk/getdata/src/name.c =================================================================== --- trunk/getdata/src/name.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/src/name.c 2013-12-12 03:33:54 UTC (rev 872) @@ -428,8 +428,6 @@ unsigned u; int i; - dtrace("%p, %p, %i", D, rdat, perform); - /* look for meta fields */ const int search_meta = (rdat->E->e->n_meta != -1); @@ -447,6 +445,8 @@ const int amode = (update_aliases ? GD_UPDU : 0) | (perform ? 0 : GD_UPDI); + dtrace("%p, %p, %i", D, rdat, perform); + /* reset the code count */ rdat->n_code = 0; @@ -454,7 +454,7 @@ if (update_vectors) switch (D->entry[u]->field_type) { case GD_LINCOM_ENTRY: - for (i = 0; i < D->entry[u]->n_fields; ++i) { + for (i = 0; i < D->entry[u]->EN(lincom,n_fields); ++i) { if (_GD_UpdateInField(D, D->entry[u], rdat, i, search_meta, mode)) { dreturn("%i", -1); return -1; Modified: trunk/getdata/test/alter_clincom.c =================================================================== --- trunk/getdata/test/alter_clincom.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/test/alter_clincom.c 2013-12-12 03:33:54 UTC (rev 872) @@ -68,7 +68,7 @@ gd_entry(D, "lincom", &E); CHECKX(E.flags, GD_EN_COMPSCAL | GD_EN_CALC); - CHECKI(E.n_fields, 2); + CHECKI(E.EN(lincom,n_fields), 2); #ifdef GD_NO_C99_API CHECKC(E.EN(lincom,cm)[0], m); CHECKC(E.EN(lincom,cm)[1], m + 2); Modified: trunk/getdata/test/alter_cpolynom_null.c =================================================================== --- trunk/getdata/test/alter_cpolynom_null.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/test/alter_cpolynom_null.c 2013-12-12 03:33:54 UTC (rev 872) @@ -38,7 +38,7 @@ "polynom POLYNOM data 1;2 2;3 1;9\n"; int fd, i, ret, error, n, error2, r = 0; gd_entry_t E; -#ifdef GD_NO_C89_API +#ifdef GD_NO_C99_API const double a[2][2] = {{1, 2}, {2, 3}}; #endif DIRFILE *D; Modified: trunk/getdata/test/alter_entry_recode_recalc.c =================================================================== --- trunk/getdata/test/alter_entry_recode_recalc.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/test/alter_entry_recode_recalc.c 2013-12-12 03:33:54 UTC (rev 872) @@ -70,6 +70,9 @@ ret = gd_alter_entry(D, "data", &E, 1); error = gd_error(D); n = gd_nframes(D); + CHECKI(error, 0); + CHECKI(n, 32); + CHECKI(ret, 0); gd_discard(D); @@ -87,13 +90,9 @@ r = 1; } -// unlink(data); + unlink(data); unlink(format); rmdir(filedir); - CHECKI(error, 0); - CHECKI(n, 32); - CHECKI(ret, 0); - return r; } Modified: trunk/getdata/test/alter_entry_scalar1.c =================================================================== --- trunk/getdata/test/alter_entry_scalar1.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/test/alter_entry_scalar1.c 2013-12-12 03:33:54 UTC (rev 872) @@ -48,8 +48,8 @@ memset(&E, 0, sizeof(E)); E.field_type = GD_BIT_ENTRY; - E.bitnum = 4; - E.numbits = 3; + E.EN(bit,bitnum) = 4; + E.EN(bit,numbits) = 3; E.in_fields[0] = "in"; E.scalar[0] = ""; Modified: trunk/getdata/test/alter_entry_scalar3c.c =================================================================== --- trunk/getdata/test/alter_entry_scalar3c.c 2013-12-11 22:35:43 UTC (rev 871) +++ trunk/getdata/test/alter_entry_scalar3c.c 2013-12-12 03:33:54 UTC (rev 872) @@ -48,8 +48,8 @@ memset(&E, 0, sizeof(E)); E.field_type = GD_BIT_ENTRY; - E.bitnum = -1; - E.numbits = 3; + E.EN(bit,bitnum) = -1; + E.EN(bit,numbits) = 3; E.in_fields[0] = "in"; ret = gd_alter_entry(D, "data", &E, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |