getdata-commits Mailing List for GetData (Page 2)
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-07-30 20:01:07
|
Revision: 921 http://sourceforge.net/p/getdata/code/921 Author: ketiltrout Date: 2014-07-30 20:00:59 +0000 (Wed, 30 Jul 2014) Log Message: ----------- Delete gd_delete_alias(). Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/cxx/dirfile.cpp trunk/getdata/bindings/cxx/getdata/dirfile.h trunk/getdata/bindings/cxx/test/big_test.cpp trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/f77/fgetdata.h trunk/getdata/bindings/f77/getdata.f90.in 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/matlab/Makefile.am trunk/getdata/bindings/matlab/test/big_test.m trunk/getdata/bindings/perl/simple_funcs.xsin trunk/getdata/bindings/perl/t/big_test.t trunk/getdata/bindings/php/getdata.c trunk/getdata/bindings/php/test/big_test.php trunk/getdata/bindings/python/pydirfile.c trunk/getdata/bindings/python/test/big_test.py trunk/getdata/doc/list.tests trunk/getdata/man/dirfile.5 trunk/getdata/man/gd_delete.3 trunk/getdata/src/del.c trunk/getdata/src/getdata.h.in trunk/getdata/test/del_alias.c Removed Paths: ------------- trunk/getdata/bindings/matlab/gd_delete_alias.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/ChangeLog 2014-07-30 20:00:59 UTC (rev 921) @@ -1,3 +1,22 @@ +2014-07-30 D. V. Wiebe <g et...@ke...> svn:921 + * src/del.c (gd_delete_alias): Deleted. + * src/del.c (gd_delete): Don't dereference the field code. + + * bindings/f77/fgetdata.c (GDDELA) bindings/f77/getdata.f90.in + (fgd_delete_alias) bindings/cxx/dirfile.cpp (Dirfile::DeleteAlias) + bindings/php/getdata.c (gd_delete_alias) bindings/python/pydirfile.c + (gdpy_dirfile_deletealias): Deleted. + * bindings/matlab/gd_delete_alias.c: Deleted. + * bindings/perl/simple_funcs.xsin: Deleted delete_alias. + * bindings/idl/getdata.c (gdidl_delete): Removed the /ALIAS keyword. + + * 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/matlab/test/big_test.m bindings/perl/t/big_test.t + bindings/php/test/big_test.php bindings/python/test/big_test.py: Deleted + test 225. + + 2014-07-25 D. V. Wiebe <g et...@ke...> svn:915 * Makefile.am: Auotmake version bumped to 1.13. * configure.ac: Autoconf version bumped to 2.65. Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/NEWS 2014-07-30 20:00:59 UTC (rev 921) @@ -187,9 +187,10 @@ 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. + * gd_move_alias() and gd_delete_alias() have been deleted: their functions are + now performed by gd_move() and gd_delete(), which now operate on the alias + itself when given the field code to an alias, rather than the field the alias + points to. * gd_encoding_support() has been added to permit run-time determination of supported encodings. @@ -262,7 +263,7 @@ general, most people building GetData from a source release don't need the tools to build GetData; the autotools are only needed if changes need to be made to the configure script or Makefile input files provided in the - release. + release or if building from the repository. |==============================================================================| Modified: trunk/getdata/bindings/cxx/dirfile.cpp =================================================================== --- trunk/getdata/bindings/cxx/dirfile.cpp 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/cxx/dirfile.cpp 2014-07-30 20:00:59 UTC (rev 921) @@ -494,11 +494,6 @@ return gd_alias_target(D, field_code); } -int Dirfile::DeleteAlias(const char* field_code, int flags) const -{ - return gd_delete_alias(D, field_code, flags); -} - int Dirfile::Hide(const char* field_code) const { return gd_hide(D, field_code); Modified: trunk/getdata/bindings/cxx/getdata/dirfile.h =================================================================== --- trunk/getdata/bindings/cxx/getdata/dirfile.h 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/cxx/getdata/dirfile.h 2014-07-30 20:00:59 UTC (rev 921) @@ -129,8 +129,6 @@ int Delete(const char* field_code, int flags = 0) const; - int DeleteAlias(const char* field_code, int flags = 0) const; - int DeSync(unsigned int flags = 0); int Discard(); Modified: trunk/getdata/bindings/cxx/test/big_test.cpp =================================================================== --- trunk/getdata/bindings/cxx/test/big_test.cpp 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/cxx/test/big_test.cpp 2014-07-30 20:00:59 UTC (rev 921) @@ -1587,14 +1587,6 @@ d->IncludeAffix("format1", 0, "A", "Z", GD_CREAT | GD_EXCL); CHECK_OK(223); - // 225: gd_delete_alias check - d->DeleteAlias("new20", 0); - CHECK_OK2(225, 1); - - n = d->FragmentIndex("new20"); - CHECK_ERROR2(225, 2, GD_E_BAD_CODE); - CHECK_INT(225, n, -1); - // 226: gd_fragment_affixes check frag = d->Fragment(1); Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/f77/fgetdata.c 2014-07-30 20:00:59 UTC (rev 921) @@ -3963,21 +3963,6 @@ dreturnvoid(); } -/* gd_delete_alias */ -void F77_FUNC(gddela, GDDELA) (const int32_t *dirfile, const char *field_code, - const int32_t *field_code_l, const int32_t *flags) -{ - char *fc; - - dtrace("%i, %p, %i, %i", *dirfile, field_code, *field_code_l, *flags); - - gd_delete_alias(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, - *field_code_l), (unsigned int)*flags); - - free(fc); - dreturnvoid(); -} - /* gd_fragment_affixes */ void F77_FUNC(gdfraf, GDFRAF) (char *prefix, int32_t *prefix_l, char *suffix, int32_t *suffix_l, const int32_t *dirfile, const int32_t *index) Modified: trunk/getdata/bindings/f77/fgetdata.h =================================================================== --- trunk/getdata/bindings/f77/fgetdata.h 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/f77/fgetdata.h 2014-07-30 20:00:59 UTC (rev 921) @@ -679,9 +679,6 @@ void F77_FUNC(gdfraf, GDFRAF) (char *prefix, int32_t *prefix_l, char *suffix, int32_t *suffix_l, const int32_t *dirfile, const int32_t *index); -void F77_FUNC(gddela, GDDELA) (const int32_t *dirfile, const char *field_code, - const int32_t *field_code_l, const int32_t *flags); - void F77_FUNC(gdaafx, GDAAFX) (const int32_t *dirfile, const int32_t *index, const char *prefix, const int32_t *prefix_l, const char *suffix, const int32_t *suffix_l); Modified: trunk/getdata/bindings/f77/getdata.f90.in =================================================================== --- trunk/getdata/bindings/f77/getdata.f90.in 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/f77/getdata.f90.in 2014-07-30 20:00:59 UTC (rev 921) @@ -2873,13 +2873,6 @@ end if end subroutine -subroutine fgd_delete_alias (dirfile, field_code, flags) - integer, intent(in) :: dirfile, flags - character (len=*), intent(in) :: field_code - - call gddela(dirfile, TRIM(field_code), LEN_TRIM(field_code), flags) -end subroutine - function fgd_hidden (dirfile, field_code) integer :: fgd_hidden integer, intent(in) :: dirfile Modified: trunk/getdata/bindings/f77/test/big_test.f =================================================================== --- trunk/getdata/bindings/f77/test/big_test.f 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/f77/test/big_test.f 2014-07-30 20:00:59 UTC (rev 921) @@ -2000,14 +2000,6 @@ CALL GDINCA(d, 'format1', 7, 0, 'A', 1, 'Z', 1, GD_CR + GD_EX) CALL CHKEOK(ne, 223, d) -C 225: GDDELA check - CALL GDDELA(d, 'new20', 7, 0) - CALL CHKOK2(ne, 225, 1, d) - - CALL GDFRGI(n, d, 'new20', 7) - CALL CHKER2(ne, 225, 2, d, GD_EBC) - CALL CHKINT(ne, 225, n, -1) - C 226: GDFRAF check l = flen n = flen Modified: trunk/getdata/bindings/f77/test/big_test95.f90 =================================================================== --- trunk/getdata/bindings/f77/test/big_test95.f90 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/f77/test/big_test95.f90 2014-07-30 20:00:59 UTC (rev 921) @@ -2406,14 +2406,6 @@ call fgd_include_affix(d, 'format1', 0, 'A', 'Z', GD_CREAT + GD_EXCL) call check_ok(ne, 223, d) -! 225: fgd_delete_alias check - call fgd_delete_alias(d, 'new20', 0) - call check_ok2(ne, 225, 1, d) - - n = fgd_fragment_index(d, 'new20') - call check_err2(ne, 225, 2, d, GD_E_BAD_CODE) - call check_int(ne, 225, n, -1) - ! 226: fgd_fragment_affixes check l = flen n = flen Modified: trunk/getdata/bindings/idl/getdata.c =================================================================== --- trunk/getdata/bindings/idl/getdata.c 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/idl/getdata.c 2014-07-30 20:00:59 UTC (rev 921) @@ -3057,18 +3057,16 @@ typedef struct { IDL_KW_RESULT_FIRST_FIELD; GDIDL_KW_RESULT_ERROR; - int alias; int data; int deref; int force; } KW_RESULT; KW_RESULT kw; - kw.alias = kw.data = kw.deref = kw.force = 0; + kw.data = kw.deref = kw.force = 0; GDIDL_KW_INIT_ERROR; static IDL_KW_PAR kw_pars[] = { - { "ALIAS", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(alias) }, { "DEL_DATA", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(data) }, { "DEREF", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(deref) }, GDIDL_KW_PAR_ERROR, @@ -3082,12 +3080,8 @@ DIRFILE* D = gdidl_get_dirfile(IDL_LongScalar(argv[0])); const char* field_code = IDL_VarGetString(argv[1]); - if (kw.alias) - gd_delete_alias(D, field_code, (kw.deref ? GD_DEL_DEREF : 0) | - (kw.force) ? GD_DEL_FORCE : 0); - else - gd_delete(D, field_code, (kw.data ? GD_DEL_DATA : 0) | - (kw.deref ? GD_DEL_DEREF : 0) | (kw.force) ? GD_DEL_FORCE : 0); + gd_delete(D, field_code, (kw.data ? GD_DEL_DATA : 0) | + (kw.deref ? GD_DEL_DEREF : 0) | (kw.force) ? GD_DEL_FORCE : 0); GDIDL_SET_ERROR(D); Modified: trunk/getdata/bindings/idl/test/big_test.pro =================================================================== --- trunk/getdata/bindings/idl/test/big_test.pro 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/idl/test/big_test.pro 2014-07-30 20:00:59 UTC (rev 921) @@ -1263,14 +1263,6 @@ gd_include, d, 'format1', prefix='A', suffix='Z', /CREAT, /EXCL nume += check_ok(223, d) -; 225: gd_delete_alias check -gd_delete, d, 'new20', /ALIAS -nume += check_ok2(225, 1, d) - -n = gd_fragment_index(d, 'new20') -nume += check_error2(225, 2, d, !GD.E_BAD_CODE) -nume += check_simple(225, n, -1) - ; 226: gd_fragment_affixes check n = gd_fragment_affixes(d, fragment=1) nume += check_ok(226, d) Modified: trunk/getdata/bindings/matlab/Makefile.am =================================================================== --- trunk/getdata/bindings/matlab/Makefile.am 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/matlab/Makefile.am 2014-07-30 20:00:59 UTC (rev 921) @@ -51,7 +51,7 @@ gd_alter_encoding gd_alter_endianness gd_alter_entry \ gd_alter_frameoffset \ gd_alter_protection gd_alter_spec gd_bof gd_array_len gd_carrays \ - gd_close gd_constants gd_delete gd_delete_alias gd_desync \ + gd_close gd_constants gd_delete gd_desync \ gd_dirfilename gd_dirfile_standards \ gd_discard gd_encoding gd_encoding_support gd_endianness \ gd_entry gd_entry_list gd_entry_type gd_eof \ Deleted: trunk/getdata/bindings/matlab/gd_delete_alias.c =================================================================== --- trunk/getdata/bindings/matlab/gd_delete_alias.c 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/matlab/gd_delete_alias.c 2014-07-30 20:00:59 UTC (rev 921) @@ -1,57 +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_DELETE_ALIAS Delete an alias from a dirfile - % - % GD_DELETE_ALIAS(DIRFILE,NAME[,FLAGS]) - % deletes the alias called NAME from the dirfile DIRFILE. If - % given, FLAGS should be a bitwise or'd collection of zero or more - % of the GD.DEL_... flags provided by GETDATA_CONSTANTS. - % - % The DIRFILE object should have previously been created with GD_OPEN. - % - % See the documentation on the C API function gd_delete_alias(3) in - % section 3 of the UNIX manual for more details. - % - % See also GD_DELETE, GD_OPEN, GETDATA_CONSTANTS - */ - -void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) -{ - DIRFILE *D; - char *field_code; - unsigned int flags = 0; - - GDMX_NO_LHS; - GDMX_CHECK_RHS2(2, 3); - - D = gdmx_to_dirfile(prhs[0]); - field_code = gdmx_to_string(prhs, 1, 0); - if (nrhs > 2) - flags = gdmx_to_uint(prhs, 2); - - gd_delete_alias(D, field_code, flags); - - mxFree(field_code); - gdmx_err(D, 0); -} Modified: trunk/getdata/bindings/matlab/test/big_test.m =================================================================== --- trunk/getdata/bindings/matlab/test/big_test.m 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/matlab/test/big_test.m 2014-07-30 20:00:59 UTC (rev 921) @@ -1815,19 +1815,6 @@ ne = ne + check_ok2(exc, 41, 1); end - % 225: delete_alias - try - gd_delete_alias(D, 'new20'); - catch exc - ne = ne + check_ok2(exc, 225, 1); - end - - try - d = gd_fragment_index(D, 'new20'); - catch exc - ne = ne + check_exc2(exc, 225, 2, 'BadCode'); - end - % 226: fragment_affixes try d = gd_fragment_affixes(D, 1); Modified: trunk/getdata/bindings/perl/simple_funcs.xsin =================================================================== --- trunk/getdata/bindings/perl/simple_funcs.xsin 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/perl/simple_funcs.xsin 2014-07-30 20:00:59 UTC (rev 921) @@ -123,7 +123,6 @@ int hidden(DIRFILE *dirfile, const char *field_code) int unhide(DIRFILE *dirfile, const char *field_code) int sync(DIRFILE *dirfile, const char *field_code) -int delete_alias(DIRFILE *dirfile, const char *field_code, unsigned int flags=0) const char *alias_target(DIRFILE *dirfile, const char *field_code) int add_alias(DIRFILE *dirfile, const char *field_code, const char *target, int fragment_index=0) Modified: trunk/getdata/bindings/perl/t/big_test.t =================================================================== --- trunk/getdata/bindings/perl/t/big_test.t 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/perl/t/big_test.t 2014-07-30 20:00:59 UTC (rev 921) @@ -22,7 +22,7 @@ use GetData; use Math::Complex; use strict; -use Test::More tests => 1729; +use Test::More tests => 1727; my $ne = 0; my ($s, @a, %h); @@ -1605,13 +1605,6 @@ $s = $_->include('format1', 0, $GetData::CREAT | $GetData::EXCL, 'A', 'Z'); CheckOK(223); -# 225: gd_delete_alias check -$s = $_->delete_alias('new20', 0); -CheckOK2(225, 1); - -$_->fragment_index('new20'); -CheckError2(225, 2, $GetData::E_BAD_CODE); - # 226: gd_fragment_affixes check @a = $_->fragment_affixes(1); CheckOK(226); Modified: trunk/getdata/bindings/php/getdata.c =================================================================== --- trunk/getdata/bindings/php/getdata.c 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/php/getdata.c 2014-07-30 20:00:59 UTC (rev 921) @@ -3005,21 +3005,6 @@ GDPHP_RETURN_BOOL(gd_delete(D, field_code, flags)); } -PHP_FUNCTION(gd_delete_alias) -{ - char *field_code; - int field_code_len; - long flags = 0; - - DIRFILE *D; - - dtracephp(); - - GDPHP_PARSED("s|l", &field_code, &field_code_len, &flags); - - GDPHP_RETURN_BOOL(gd_delete_alias(D, field_code, flags)); -} - PHP_FUNCTION(gd_desync) { long flags = 0; @@ -5176,7 +5161,6 @@ PHP_FE(gd_close, NULL) PHP_FE(gd_constants, NULL) PHP_FE(gd_delete, NULL) - PHP_FE(gd_delete_alias, NULL) PHP_FE(gd_desync, NULL) PHP_FE(gd_dirfile_standards, NULL) PHP_FE(gd_dirfilekey, NULL) Modified: trunk/getdata/bindings/php/test/big_test.php =================================================================== --- trunk/getdata/bindings/php/test/big_test.php 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/php/test/big_test.php 2014-07-30 20:00:59 UTC (rev 921) @@ -1362,15 +1362,6 @@ check_ok2(223, 0, $D); check_var2(223, 1, $v, 1); -# 225: delete alias -$v = gd_delete_alias($D, 'new20'); -check_ok2(225, 0, $D); -check_var2(225, 1, $v, TRUE); - -$v = gd_fragment_index($D, 'new20'); -check_error2(225, 2, $D, GD_E_BAD_CODE); -check_var2(225, 3, $v, FALSE); - # 226: fragment affixes $v = gd_fragment_affixes($D, 1); check_ok(226, $D); Modified: trunk/getdata/bindings/python/pydirfile.c =================================================================== --- trunk/getdata/bindings/python/pydirfile.c 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/python/pydirfile.c 2014-07-30 20:00:59 UTC (rev 921) @@ -2630,31 +2630,6 @@ return pyobj; } -static PyObject *gdpy_dirfile_deletealias(struct gdpy_dirfile_t *self, - void *args, void *keys) -{ - char *keywords[] = {"field_code", "flags", NULL}; - const char *field_code; - unsigned flags = 0; - - dtrace("%p, %p, %p", self, args, keys); - - if (!PyArg_ParseTupleAndKeywords(args, keys, - "s|I:pygetdata.dirfile.delete", keywords, &field_code, &flags)) - { - dreturn("%p", NULL); - return NULL; - } - - gd_delete_alias(self->D, field_code, flags); - - PYGD_CHECK_ERROR(self->D, NULL); - - Py_INCREF(Py_None); - dreturn("%p", Py_None); - return Py_None; -} - static PyObject *gdpy_dirfile_aliaslist(struct gdpy_dirfile_t *self, void *args, void *keys) { @@ -3606,15 +3581,6 @@ "field. If field_code is valid, this will be at least one. See\n" "gd_naliases(3)." }, - {"delete_alias", (PyCFunction)gdpy_dirfile_deletealias, - METH_VARARGS | METH_KEYWORDS, - "delete_alias(field_code[, flags])\n\n" - "Delete the alias 'field_code' from the database. If 'flags' is\n" - "omitted, it is assumed to be zero. Otherwise, 'flags' should be a\n" - "bitwise or'd collection of the pygetdata.DEL_* symbols, whose\n" - "meanings are described in the gd_delete manual page. See\n" - "gd_delete_alias(3)." - }, {"alias_target", (PyCFunction)gdpy_dirfile_aliastarget, METH_VARARGS | METH_KEYWORDS, "alias_target(field_code)\n\n" Modified: trunk/getdata/bindings/python/test/big_test.py =================================================================== --- trunk/getdata/bindings/python/test/big_test.py 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/bindings/python/test/big_test.py 2014-07-30 20:00:59 UTC (rev 921) @@ -1798,17 +1798,6 @@ except: CheckOK(223) -# 225: gd_delete_alias check -try: - d.delete_alias('new20', 0) -except: - CheckOK2(225, 1) - -try: - n = d.fragment_index('new20') -except: - CheckException2(255, 2, pygetdata.BadCodeError) - # 226: gd_fragment_affixes check try: n = d.fragment(1).prefix Modified: trunk/getdata/doc/list.tests =================================================================== --- trunk/getdata/doc/list.tests 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/doc/list.tests 2014-07-30 20:00:59 UTC (rev 921) @@ -223,7 +223,7 @@ 222 F9CIpPmh gd_aliases 223 F9CIpPmh gd_include_affix 224 ........ (unused) -225 F9CIpPmh gd_delete_alias +225 ........ (unused) 226 F9CIpPmh gd_fragment_affixes 227 F9CIpPmh gd_alter_affixes 228 F9CIpPmh gd_entry (MPLEX) Modified: trunk/getdata/man/dirfile.5 =================================================================== --- trunk/getdata/man/dirfile.5 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/man/dirfile.5 2014-07-30 20:00:59 UTC (rev 921) @@ -115,7 +115,7 @@ To aid in using complex valued data, dirfile field codes may contain a .I representation suffix -which specifies a norm to apply to the complex valued data to convert it into +which specifies a function to apply to the complex valued data to map it into purely real data. See .BR dirfile\-format (5). Modified: trunk/getdata/man/gd_delete.3 =================================================================== --- trunk/getdata/man/gd_delete.3 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/man/gd_delete.3 2014-07-30 20:00:59 UTC (rev 921) @@ -13,9 +13,9 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_delete 3 "1 January 2012" "Version 0.8.0" "GETDATA" +.TH gd_delete 3 "30 July 2014" "Version 0.9.0" "GETDATA" .SH NAME -gd_delete, gd_delete_alias \(em remove an entry from a dirfile +gd_delete \(em remove an entry from a dirfile .SH SYNOPSIS .B #include <getdata.h> .HP @@ -23,15 +23,12 @@ .ad l .BI "int gd_delete(DIRFILE *" dirfile ", const char *" field_code , .BI "unsigned int " flags ); -.HP -.BI "int gd_delete_alias(DIRFILE *" dirfile ", const char *" alias_name , -.BI "unsigned int " flags ); .hy .ad n .SH DESCRIPTION The .BR gd_delete () -function attempts to delete the field specified by +function attempts to delete the field or alias specified by .I field_code in the dirfile specified by .IR dirfile . @@ -40,18 +37,6 @@ should not contain a representation suffix. The -.BR gd_delete_alias () -function behaves similarly, but deletes the alias specified by -.I alias_name -instead. (This function is needed, since passing -.I alias_name -to -.BR gd_delete () -as -.I field_code -would have resulted in the field pointed to by the alias being deleted instead.) - -The .I flags argument influences how the deletion attempt occurs. It may be zero, for the default behaviour, or else one or more of the following flags, bitwise or'd @@ -65,8 +50,7 @@ specified a .B RAW field and this flag is not specified, the field will still be deleted but the -binary file will be left untouched. Ignored by -.BR gd_delete_alias (). +binary file will be left untouched. .TP .B GD_DEL_DEREF If the field to be deleted is a @@ -88,8 +72,7 @@ those, too. If the field has metafields and this flag is not specified, the call will fail with the .B GD_E_DELETE -error. Ignored by -.BR gd_delete_alias (). +error. .SH RETURN VALUE On successful deletion, zero is returned. On error, -1 is returned and the dirfile error is set to a non-zero error value. Possible error values are: Modified: trunk/getdata/src/del.c =================================================================== --- trunk/getdata/src/del.c 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/src/del.c 2014-07-30 20:00:59 UTC (rev 921) @@ -73,15 +73,15 @@ case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: case GD_STRING_ENTRY: + case GD_SARRAY_ENTRY: break; - default: - if (E->field_type == GD_ALIAS_ENTRY) - if (E->e->entry[0] == C) { - if (check) - _GD_SetError(D, GD_E_DELETE, GD_E_DEL_ALIAS, E->field, 0, C->field); - else - E->e->entry[0] = NULL; - } + case GD_ALIAS_ENTRY: + if (E->e->entry[0] == C) { + if (check) + _GD_SetError(D, GD_E_DELETE, GD_E_DEL_ALIAS, E->field, 0, C->field); + else + E->e->entry[0] = NULL; + } } dreturnvoid(); @@ -305,7 +305,7 @@ for (i = 0; i < E->e->n_meta; ++i) del_list[n_del++] = E->e->p.meta_entry[i]; - /* Check for clients and derived fields */ + /* Check for clients, derived fields, and inbound aliases */ if (~flags & GD_DEL_FORCE) for (j = 0; j < D->n_entries; ++j) for (i = 0; i < n_del; ++i) { @@ -496,50 +496,15 @@ return 0; } -int gd_delete(DIRFILE *D, const char *field_code_in, unsigned int flags) +int gd_delete(DIRFILE *D, const char *field_code, unsigned int flags) { unsigned index; - int repr, ret; - char *field_code; - gd_entry_t *E; - - dtrace("%p, \"%s\", 0x%X", D, field_code_in, flags); - - if (D->flags & GD_INVALID) {/* don't crash */ - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } - - _GD_ClearError(D); - - E = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, &index, 1, 1); - - if (field_code != field_code_in) - free(field_code); - - if (D->error) { - dreturn("%i", -1); - return -1; - } - - ret = _GD_Delete(D, E, index, flags); - - dreturn("%i", ret); - return ret; -} - - -int gd_delete_alias(DIRFILE *D, const char *field_code, unsigned int flags) - gd_nothrow -{ - unsigned index; int ret; gd_entry_t *E; dtrace("%p, \"%s\", 0x%X", D, field_code, flags); - if (D->flags & GD_INVALID) { + if (D->flags & GD_INVALID) {/* don't crash */ _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); dreturn("%i", -1); return -1; @@ -549,18 +514,11 @@ E = _GD_FindField(D, field_code, D->entry, D->n_entries, 0, &index); - if (!E) { - _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code); + if (D->error) { dreturn("%i", -1); return -1; } - if (E->field_type != GD_ALIAS_ENTRY) { - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); - dreturn("%i", -1); - return -1; - } - ret = _GD_Delete(D, E, index, flags); dreturn("%i", ret); Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/src/getdata.h.in 2014-07-30 20:00:59 UTC (rev 921) @@ -683,9 +683,6 @@ extern size_t gd_carray_len(DIRFILE *dirfile, const char *field_code) gd_nothrow gd_nonnull((1,2)) gd_deprecated; -extern int gd_delete_alias(DIRFILE *dirfile, const char *field_code, - unsigned int flags) gd_nothrow gd_nonnull ((1,2)); - extern int gd_get_carray(DIRFILE *dirfile, const char *field_code, gd_type_t return_type, void *data_out) gd_nothrow gd_nonnull((1,2)); Modified: trunk/getdata/test/del_alias.c =================================================================== --- trunk/getdata/test/del_alias.c 2014-07-30 01:50:28 UTC (rev 920) +++ trunk/getdata/test/del_alias.c 2014-07-30 20:00:59 UTC (rev 921) @@ -49,7 +49,7 @@ D = gd_open(filedir, GD_RDWR); t1 = gd_entry_type(D, "alias"); error1 = gd_error(D); - ret = gd_delete_alias(D, "alias", 0); + ret = gd_delete(D, "alias", 0); error2 = gd_error(D); t2 = gd_entry_type(D, "alias"); error3 = gd_error(D); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-30 01:50:40
|
Revision: 920 http://sourceforge.net/p/getdata/code/920 Author: ketiltrout Date: 2014-07-30 01:50:28 +0000 (Wed, 30 Jul 2014) Log Message: ----------- More portability fixes. Libtool bumped to 2.2.7b. Modified Paths: -------------- trunk/getdata/NEWS trunk/getdata/bindings/f77/fgetdata.h trunk/getdata/bindings/matlab/gd_matlab.h trunk/getdata/bindings/python/pygetdata.c trunk/getdata/configure.ac trunk/getdata/src/bzip.c trunk/getdata/src/encoding.c trunk/getdata/src/gzip.c trunk/getdata/src/internal.h trunk/getdata/src/lzma.c trunk/getdata/src/slim.c trunk/getdata/src/zzip.c trunk/getdata/src/zzslim.c trunk/html/download.html.in Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/NEWS 2014-07-30 01:50:28 UTC (rev 920) @@ -254,6 +254,16 @@ * PYTHON BUG FIX: The keyword for the "dirfile" parameter in the getdata.fragment constructor is now properly spelled. + Miscellaneous: + + * The minimum autotools versions have been bumped. Autoconf-2.65 or newer, + automake-1.13 or newer, and libtool-2.2.7b or newer are now required to + rebuild the configure script and associated build environment. NOTE: In + general, most people building GetData from a source release don't need the + tools to build GetData; the autotools are only needed if changes need to be + made to the configure script or Makefile input files provided in the + release. + |==============================================================================| New in verison 0.8.5: Modified: trunk/getdata/bindings/f77/fgetdata.h =================================================================== --- trunk/getdata/bindings/f77/fgetdata.h 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/bindings/f77/fgetdata.h 2014-07-30 01:50:28 UTC (rev 920) @@ -1015,6 +1015,78 @@ const int32_t *first_frame, const int32_t *first_sample, const int32_t *num_frames, const int32_t *num_samples); +void F77_FUNC(gdaspn, GDASPN) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const int32_t *poly_ord, const char *in_field, + const int32_t *in_field_l, const double *a0, const char *a0_scalar, + const int32_t *a0_scalar_l, const int32_t *a0_scalar_ind, const double *a1, + const char *a1_scalar, const int32_t *a1_scalar_l, + const int32_t *a1_scalar_ind, const double *a2, const char *a2_scalar, + const int32_t *a2_scalar_l, const int32_t *a2_scalar_ind, const double *a3, + const char *a3_scalar, const int32_t *a3_scalar_l, + const int32_t *a3_scalar_ind, const double *a4, const char *a4_scalar, + const int32_t *a4_scalar_l, const int32_t *a4_scalar_ind, const double *a5, + const char *a5_scalar, const int32_t *a5_scalar_l, + const int32_t *a5_scalar_ind, const int32_t *fragment_index); + +void F77_FUNC(gdascp, GDASCP) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const int32_t *poly_ord, const char *in_field, + const int32_t *in_field_l, const GD_DCOMPLEXP(a0), const char *a0_scalar, + const int32_t *a0_scalar_l, const int32_t *a0_scalar_ind, + const GD_DCOMPLEXP(a1), const char *a1_scalar, const int32_t *a1_scalar_l, + const int32_t *a1_scalar_ind, const GD_DCOMPLEXP(a2), const char *a2_scalar, + const int32_t *a2_scalar_l, const int32_t *a2_scalar_ind, + const GD_DCOMPLEXP(a3), const char *a3_scalar, const int32_t *a3_scalar_l, + const int32_t *a3_scalar_ind, const GD_DCOMPLEXP(a4), const char *a4_scalar, + const int32_t *a4_scalar_l, const int32_t *a4_scalar_ind, + const GD_DCOMPLEXP(a5), const char *a5_scalar, const int32_t *a5_scalar_l, + const int32_t *a5_scalar_ind, const int32_t *fragment_index); + +void F77_FUNC(gdassb, GDASSB) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const char *in_field, + const int32_t *in_field_l, const int32_t *bitnum, const char *bitnum_scalar, + const int32_t *bitnum_scalar_l, const int32_t *bitnum_scalar_ind, + const int32_t *numbits, const char *numbits_scalar, + const int32_t *numbits_scalar_l, const int32_t *numbits_scalar_ind, + const int32_t *fragment_index); + +void F77_FUNC(gdlspn, GDLSPN) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const int32_t *poly_ord, const char *in_field, + const int32_t *in_field_l, const double *a0, const char *a0_scalar, + const int32_t *a0_scalar_l, const int32_t *a0_scalar_ind, + const double *a1, const char *a1_scalar, const int32_t *a1_scalar_l, + const int32_t *a1_scalar_ind, const double *a2, const char *a2_scalar, + const int32_t *a2_scalar_l, const int32_t *a2_scalar_ind, + const double *a3, const char *a3_scalar, const int32_t *a3_scalar_l, + const int32_t *a3_scalar_ind, const double *a4, const char *a4_scalar, + const int32_t *a4_scalar_l, const int32_t *a4_scalar_ind, + const double *a5, const char *a5_scalar, const int32_t *a5_scalar_l, + const int32_t *a5_scalar_ind); + +void F77_FUNC(gdlscp, GDLSCP) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const int32_t *poly_ord, const char *in_field, + const int32_t *in_field_l, const GD_DCOMPLEXP(a0), const char *a0_scalar, + const int32_t *a0_scalar_l, const int32_t *a0_scalar_ind, + const GD_DCOMPLEXP(a1), const char *a1_scalar, const int32_t *a1_scalar_l, + const int32_t *a1_scalar_ind, const GD_DCOMPLEXP(a2), const char *a2_scalar, + const int32_t *a2_scalar_l, const int32_t *a2_scalar_ind, + const GD_DCOMPLEXP(a3), const char *a3_scalar, const int32_t *a3_scalar_l, + const int32_t *a3_scalar_ind, const GD_DCOMPLEXP(a4), const char *a4_scalar, + const int32_t *a4_scalar_l, const int32_t *a4_scalar_ind, + const GD_DCOMPLEXP(a5), const char *a5_scalar, const int32_t *a5_scalar_l, + const int32_t *a5_scalar_ind); + +void F77_FUNC(gdlssb, GDLSSB) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const char *in_field, + const int32_t *in_field_l, const int32_t *bitnum, const char *bitnum_scalar, + const int32_t *bitnum_scalar_l, const int32_t *bitnum_scalar_ind, + const int32_t *numbits, const char *numbits_scalar, + const int32_t *numbits_scalar_l, const int32_t *numbits_scalar_ind); + +void F77_FUNC(gdxstp, GDXSTP) (char *value, int32_t *value_l, const char *data, + const int32_t *index); + +void F77_FUNC(gddstp, GDDSTP) (char *data); + #ifdef __cplusplus } #endif Modified: trunk/getdata/bindings/matlab/gd_matlab.h =================================================================== --- trunk/getdata/bindings/matlab/gd_matlab.h 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/bindings/matlab/gd_matlab.h 2014-07-30 01:50:28 UTC (rev 920) @@ -67,6 +67,10 @@ #define gdmx_from_entype gdmx_from_int #define gdmx_from_windop gdmx_from_int +#ifdef __cplusplus +extern "C" { +#endif + void gdmx_err(DIRFILE *, int); mxClassID gdmx_classid(gd_type_t); void gdmx_free_entry(gd_entry_t *); @@ -91,6 +95,7 @@ mxArray *gdmx_from_carrays(const gd_carray_t *, gd_type_t); mxArray *gdmx_from_sarrays(const char ***); mxArray *gdmx_vector(gd_type_t, size_t, void**); +void gdmx_fix_vector(mxArray *, gd_type_t, size_t, void*); /* convert from MATLAB type */ DIRFILE *gdmx_to_dirfile(const mxArray *); @@ -115,4 +120,8 @@ void gdmx_to_sdata(const char***, size_t*, const mxArray*, int); void gdmx_free_sdata(const char**, size_t); +#ifdef __cplusplus +} #endif + +#endif Modified: trunk/getdata/bindings/python/pygetdata.c =================================================================== --- trunk/getdata/bindings/python/pygetdata.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/bindings/python/pygetdata.c 2014-07-30 01:50:28 UTC (rev 920) @@ -433,6 +433,7 @@ if (PyList_Append(pyobj, gdpy_from_complexp(((double*)data) + 2 * i))) return NULL; break; + case GD_STRING: case GD_NULL: case GD_UNKNOWN: /* prevent compiler warning */ break; @@ -489,6 +490,7 @@ case GD_COMPLEX128: pyobj = gdpy_from_complexp((double*)data); break; + case GD_STRING: case GD_UNKNOWN: /* prevent compiler warning */ break; } Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/configure.ac 2014-07-30 01:50:28 UTC (rev 920) @@ -47,7 +47,7 @@ AC_PREREQ([2.65]) AC_CONFIG_MACRO_DIR([m4]) -LT_PREREQ([2.2.6b]) +LT_PREREQ([2.2.7b]) AC_ARG_VAR([BUILDCC], [C compiler command targetting the build system ] Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/bzip.c 2014-07-30 01:50:28 UTC (rev 920) @@ -24,16 +24,6 @@ #include <bzlib.h> #endif -#ifdef USE_MODULES -#define _GD_Bzip2Open libgetdatabzip2_LTX_GD_Bzip2Open -#define _GD_Bzip2Seek libgetdatabzip2_LTX_GD_Bzip2Seek -#define _GD_Bzip2Read libgetdatabzip2_LTX_GD_Bzip2Read -#define _GD_Bzip2Write libgetdatabzip2_LTX_GD_Bzip2Write -#define _GD_Bzip2Sync libgetdatabzip2_LTX_GD_Bzip2Sync -#define _GD_Bzip2Close libgetdatabzip2_LTX_GD_Bzip2Close -#define _GD_Bzip2Size libgetdatabzip2_LTX_GD_Bzip2Size -#endif - #if SIZEOF_INT < 4 #define GD_BZIP_BUFFER_SIZE 32767 #else Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/encoding.c 2014-07-30 01:50:28 UTC (rev 920) @@ -230,8 +230,8 @@ dtrace("%p, %p, \"%s\"", lib, enc, name); /* create the symbol name */ - sprintf(symbol, "libgetdata%s_LTX_GD_%s%s", enc->affix, enc->affix, name); - symbol[10] -= 'A' - 'a'; + sprintf(symbol, "lt_libgetdata%s_LTX_GD_%s%s", enc->affix, enc->affix, name); + symbol[13] -= 'A' - 'a'; func = lt_dlsym(lib, symbol); dreturn("%p", func); Modified: trunk/getdata/src/gzip.c =================================================================== --- trunk/getdata/src/gzip.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/gzip.c 2014-07-30 01:50:28 UTC (rev 920) @@ -24,16 +24,6 @@ #include <zlib.h> #endif -#ifdef USE_MODULES -#define _GD_GzipOpen libgetdatagzip_LTX_GD_GzipOpen -#define _GD_GzipSeek libgetdatagzip_LTX_GD_GzipSeek -#define _GD_GzipRead libgetdatagzip_LTX_GD_GzipRead -#define _GD_GzipWrite libgetdatagzip_LTX_GD_GzipWrite -#define _GD_GzipSync libgetdatagzip_LTX_GD_GzipSync -#define _GD_GzipClose libgetdatagzip_LTX_GD_GzipClose -#define _GD_GzipSize libgetdatagzip_LTX_GD_GzipSize -#endif - /* The gzip encoding scheme uses edata as a gzFile object. If a file is * open, idata >= 0 otherwise idata = -1. Writes occur out-of-place. */ Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/internal.h 2014-07-30 01:50:28 UTC (rev 920) @@ -370,10 +370,21 @@ /* debugging macros */ #ifdef GETDATA_DEBUG #define GD_COL_SIZE 100 -const char* gd_colnil(void); -const char* gd_coladd(void); -const char* gd_colsub(void); -void gd_colclear(void); + +#ifdef __cplusplus +extern "C" { +#endif + + const char* gd_colnil(void); + const char* gd_coladd(void); + const char* gd_colsub(void); + void gd_colclear(void); + +#ifdef __cplusplus +} +#endif + + #define dtracevoid() printf("%s %s()\n", gd_coladd(), __func__) #define dtrace(fmt, ...) printf("%s %s(" fmt ")\n", gd_coladd(), \ __func__, ##__VA_ARGS__) @@ -1182,18 +1193,29 @@ int _GD_ListEntry(const gd_entry_t *E, int meta, int hidden, int noalias, int special, gd_entype_t type); char *_GD_MakeFullPath(DIRFILE *restrict, int, const char *restrict, int); + #ifdef USE_MODULES #define _GD_MakeFullPathOnly gd_MakeFullPathOnly +#define _GD_MakeTempFile gd_MakeTempFile + +#ifdef __cplusplus +extern "C" { +#endif + #else #define gd_MakeFullPathOnly _GD_MakeFullPathOnly +#define gd_MakeTempFile _GD_MakeTempFile #endif + char *_GD_MakeFullPathOnly(const DIRFILE *D, int dirfd, const char *name); +int _GD_MakeTempFile(const DIRFILE*, int, char*); + #ifdef USE_MODULES -#define _GD_MakeTempFile gd_MakeTempFile -#else -#define gd_MakeTempFile _GD_MakeTempFile +#ifdef __cplusplus +} #endif -int _GD_MakeTempFile(const DIRFILE*, int, char*); +#endif + void *_GD_Malloc(DIRFILE *D, size_t size); int _GD_MissingFramework(int encoding, unsigned int funcs); int _GD_MogrifyFile(DIRFILE *restrict, gd_entry_t *restrict, unsigned long int, @@ -1272,6 +1294,70 @@ off64_t _GD_AsciiSize(int, struct gd_raw_file_* file, gd_type_t data_type, int swap); +/* SIE I/O methods */ +int _GD_SampIndOpen(int, struct gd_raw_file_* file, int swap, + unsigned int); +off64_t _GD_SampIndSeek(struct gd_raw_file_* file, off64_t count, + gd_type_t data_type, unsigned int); +ssize_t _GD_SampIndRead(struct gd_raw_file_ *restrict, void *restrict, + gd_type_t, size_t); +ssize_t _GD_SampIndWrite(struct gd_raw_file_ *restrict, const void *restrict, + gd_type_t, size_t); +int _GD_SampIndSync(struct gd_raw_file_* file); +int _GD_SampIndClose(struct gd_raw_file_* file); +off64_t _GD_SampIndSize(int, struct gd_raw_file_* file, gd_type_t data_type, + int swap); + +#ifdef USE_MODULES +#define _GD_Bzip2Open lt_libgetdatabzip2_LTX_GD_Bzip2Open +#define _GD_Bzip2Seek lt_libgetdatabzip2_LTX_GD_Bzip2Seek +#define _GD_Bzip2Read lt_libgetdatabzip2_LTX_GD_Bzip2Read +#define _GD_Bzip2Write lt_libgetdatabzip2_LTX_GD_Bzip2Write +#define _GD_Bzip2Sync lt_libgetdatabzip2_LTX_GD_Bzip2Sync +#define _GD_Bzip2Close lt_libgetdatabzip2_LTX_GD_Bzip2Close +#define _GD_Bzip2Size lt_libgetdatabzip2_LTX_GD_Bzip2Size + +#define _GD_GzipOpen lt_libgetdatagzip_LTX_GD_GzipOpen +#define _GD_GzipSeek lt_libgetdatagzip_LTX_GD_GzipSeek +#define _GD_GzipRead lt_libgetdatagzip_LTX_GD_GzipRead +#define _GD_GzipWrite lt_libgetdatagzip_LTX_GD_GzipWrite +#define _GD_GzipSync lt_libgetdatagzip_LTX_GD_GzipSync +#define _GD_GzipClose lt_libgetdatagzip_LTX_GD_GzipClose +#define _GD_GzipSize lt_libgetdatagzip_LTX_GD_GzipSize + +#define _GD_LzmaOpen lt_libgetdatalzma_LTX_GD_LzmaOpen +#define _GD_LzmaSeek lt_libgetdatalzma_LTX_GD_LzmaSeek +#define _GD_LzmaRead lt_libgetdatalzma_LTX_GD_LzmaRead +#define _GD_LzmaWrite lt_libgetdatalzma_LTX_GD_LzmaWrite +#define _GD_LzmaSync lt_libgetdatalzma_LTX_GD_LzmaSync +#define _GD_LzmaClose lt_libgetdatalzma_LTX_GD_LzmaClose +#define _GD_LzmaSize lt_libgetdatalzma_LTX_GD_LzmaSize + +#define _GD_SlimOpen lt_libgetdataslim_LTX_GD_SlimOpen +#define _GD_SlimSeek lt_libgetdataslim_LTX_GD_SlimSeek +#define _GD_SlimRead lt_libgetdataslim_LTX_GD_SlimRead +#define _GD_SlimClose lt_libgetdataslim_LTX_GD_SlimClose +#define _GD_SlimSize lt_libgetdataslim_LTX_GD_SlimSize + +#define _GD_ZzipName lt_libgetdatazzip_LTX_GD_ZzipName +#define _GD_ZzipOpen lt_libgetdatazzip_LTX_GD_ZzipOpen +#define _GD_ZzipSeek lt_libgetdatazzip_LTX_GD_ZzipSeek +#define _GD_ZzipRead lt_libgetdatazzip_LTX_GD_ZzipRead +#define _GD_ZzipClose lt_libgetdatazzip_LTX_GD_ZzipClose +#define _GD_ZzipSize lt_libgetdatazzip_LTX_GD_ZzipSize + +#define _GD_ZzslimName lt_libgetdatazzslim_LTX_GD_ZzslimName +#define _GD_ZzslimOpen lt_libgetdatazzslim_LTX_GD_ZzslimOpen +#define _GD_ZzslimSeek lt_libgetdatazzslim_LTX_GD_ZzslimSeek +#define _GD_ZzslimRead lt_libgetdatazzslim_LTX_GD_ZzslimRead +#define _GD_ZzslimClose lt_libgetdatazzslim_LTX_GD_ZzslimClose +#define _GD_ZzslimSize lt_libgetdatazzslim_LTX_GD_ZzslimSize + +#ifdef __cplusplus +extern "C" { +#endif +#endif + /* bzip I/O methods */ int _GD_Bzip2Open(int, struct gd_raw_file_* file, int swap, unsigned int); off64_t _GD_Bzip2Seek(struct gd_raw_file_* file, off64_t count, @@ -1320,20 +1406,6 @@ off64_t _GD_SlimSize(int, struct gd_raw_file_* file, gd_type_t data_type, int swap); -/* SIE I/O methods */ -int _GD_SampIndOpen(int, struct gd_raw_file_* file, int swap, - unsigned int); -off64_t _GD_SampIndSeek(struct gd_raw_file_* file, off64_t count, - gd_type_t data_type, unsigned int); -ssize_t _GD_SampIndRead(struct gd_raw_file_ *restrict, void *restrict, - gd_type_t, size_t); -ssize_t _GD_SampIndWrite(struct gd_raw_file_ *restrict, const void *restrict, - gd_type_t, size_t); -int _GD_SampIndSync(struct gd_raw_file_* file); -int _GD_SampIndClose(struct gd_raw_file_* file); -off64_t _GD_SampIndSize(int, struct gd_raw_file_* file, gd_type_t data_type, - int swap); - /* zzip I/O methods */ int _GD_ZzipName(DIRFILE *restrict, const char *restrict, struct gd_raw_file_ *restrict, const char *restrict, int, int); @@ -1358,6 +1430,12 @@ off64_t _GD_ZzslimSize(int, struct gd_raw_file_* file, gd_type_t data_type, int swap); +#ifdef USE_MODULES +#ifdef __cplusplus +} +#endif +#endif + #ifndef __cplusplus # undef gd_nothrow # define gd_nothrow Modified: trunk/getdata/src/lzma.c =================================================================== --- trunk/getdata/src/lzma.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/lzma.c 2014-07-30 01:50:28 UTC (rev 920) @@ -24,16 +24,6 @@ #include <lzma.h> #endif -#ifdef USE_MODULES -#define _GD_LzmaOpen libgetdatalzma_LTX_GD_LzmaOpen -#define _GD_LzmaSeek libgetdatalzma_LTX_GD_LzmaSeek -#define _GD_LzmaRead libgetdatalzma_LTX_GD_LzmaRead -#define _GD_LzmaWrite libgetdatalzma_LTX_GD_LzmaWrite -#define _GD_LzmaSync libgetdatalzma_LTX_GD_LzmaSync -#define _GD_LzmaClose libgetdatalzma_LTX_GD_LzmaClose -#define _GD_LzmaSize libgetdatalzma_LTX_GD_LzmaSize -#endif - #if SIZEOF_INT < 4 #define GD_LZMA_DATA_OUT 32767 #else Modified: trunk/getdata/src/slim.c =================================================================== --- trunk/getdata/src/slim.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/slim.c 2014-07-30 01:50:28 UTC (rev 920) @@ -24,14 +24,6 @@ #include <slimlib.h> #endif -#ifdef USE_MODULES -#define _GD_SlimOpen libgetdataslim_LTX_GD_SlimOpen -#define _GD_SlimSeek libgetdataslim_LTX_GD_SlimSeek -#define _GD_SlimRead libgetdataslim_LTX_GD_SlimRead -#define _GD_SlimClose libgetdataslim_LTX_GD_SlimClose -#define _GD_SlimSize libgetdataslim_LTX_GD_SlimSize -#endif - /* The slim encoding scheme uses edata as a slimfile pointer. If a file is * open, idata = 0 otherwise idata = -1. */ Modified: trunk/getdata/src/zzip.c =================================================================== --- trunk/getdata/src/zzip.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/zzip.c 2014-07-30 01:50:28 UTC (rev 920) @@ -24,15 +24,6 @@ #include <zzip/lib.h> #endif -#ifdef USE_MODULES -#define _GD_ZzipName libgetdatazzip_LTX_GD_ZzipName -#define _GD_ZzipOpen libgetdatazzip_LTX_GD_ZzipOpen -#define _GD_ZzipSeek libgetdatazzip_LTX_GD_ZzipSeek -#define _GD_ZzipRead libgetdatazzip_LTX_GD_ZzipRead -#define _GD_ZzipClose libgetdatazzip_LTX_GD_ZzipClose -#define _GD_ZzipSize libgetdatazzip_LTX_GD_ZzipSize -#endif - /* The zzip encoding scheme looks just like the regular ol' C IO. */ int _GD_ZzipName(DIRFILE *restrict D, const char *restrict enc_data, Modified: trunk/getdata/src/zzslim.c =================================================================== --- trunk/getdata/src/zzslim.c 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/getdata/src/zzslim.c 2014-07-30 01:50:28 UTC (rev 920) @@ -24,15 +24,6 @@ #include <slimlib.h> #endif -#ifdef USE_MODULES -#define _GD_ZzslimName libgetdatazzslim_LTX_GD_ZzslimName -#define _GD_ZzslimOpen libgetdatazzslim_LTX_GD_ZzslimOpen -#define _GD_ZzslimSeek libgetdatazzslim_LTX_GD_ZzslimSeek -#define _GD_ZzslimRead libgetdatazzslim_LTX_GD_ZzslimRead -#define _GD_ZzslimClose libgetdatazzslim_LTX_GD_ZzslimClose -#define _GD_ZzslimSize libgetdatazzslim_LTX_GD_ZzslimSize -#endif - /* The zzslim encoding scheme uses edata as a slimfile pointer. If a file is * open, idata = 0 otherwise idata = -1. */ Modified: trunk/html/download.html.in =================================================================== --- trunk/html/download.html.in 2014-07-29 23:25:09 UTC (rev 919) +++ trunk/html/download.html.in 2014-07-30 01:50:28 UTC (rev 920) @@ -117,7 +117,7 @@ href="http://www.gnu.org/software/autoconf/">Autoconf</a> 2.65, or newer, <a href="http://www.gnu.org/software/automake/">automake</a> 1.13, or newer, and <a - href="http://www.gnu.org/software/libtool/">libtool</a> 2.2.6b, or + href="http://www.gnu.org/software/libtool/">libtool</a> 2.2.7b, or better, are required. You should only have to do this when you check out a new copy of the repository. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-29 23:25:16
|
Revision: 919 http://sourceforge.net/p/getdata/code/919 Author: ketiltrout Date: 2014-07-29 23:25:09 +0000 (Tue, 29 Jul 2014) Log Message: ----------- C89 Modified Paths: -------------- trunk/getdata/test/flush_amb_code.c Modified: trunk/getdata/test/flush_amb_code.c =================================================================== --- trunk/getdata/test/flush_amb_code.c 2014-07-29 23:24:49 UTC (rev 918) +++ trunk/getdata/test/flush_amb_code.c 2014-07-29 23:25:09 UTC (rev 919) @@ -35,7 +35,7 @@ memset(&E, 0, sizeof(E)); E.field = "pathological"; E.field_type = GD_POLYNOM_ENTRY; - E.poly_ord = 5; + E.EN(polynom,poly_ord) = 5; E.in_fields[0] = "INDEX"; E.scalar[0] = code[0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-29 23:24:57
|
Revision: 918 http://sourceforge.net/p/getdata/code/918 Author: ketiltrout Date: 2014-07-29 23:24:49 +0000 (Tue, 29 Jul 2014) Log Message: ----------- Revert debugging // Modified Paths: -------------- trunk/getdata/src/flush.c Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2014-07-29 22:45:26 UTC (rev 917) +++ trunk/getdata/src/flush.c 2014-07-29 23:24:49 UTC (rev 918) @@ -1099,7 +1099,7 @@ /* 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, NULL); gd_UnlinkAt(D, dirfd, temp_file, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-29 22:45:29
|
Revision: 917 http://sourceforge.net/p/getdata/code/917 Author: ketiltrout Date: 2014-07-29 22:45:26 +0000 (Tue, 29 Jul 2014) Log Message: ----------- Fix VPATH builds. Modified Paths: -------------- trunk/getdata/bindings/f77/Makefile.am trunk/getdata/bindings/matlab/Makefile.am Modified: trunk/getdata/bindings/f77/Makefile.am =================================================================== --- trunk/getdata/bindings/f77/Makefile.am 2014-07-25 21:32:11 UTC (rev 916) +++ trunk/getdata/bindings/f77/Makefile.am 2014-07-29 22:45:26 UTC (rev 917) @@ -29,7 +29,6 @@ endif FCFLAGS += $(GD_FC_WALL) $(GD_FC_WEXTRA) -AM_CPPFLAGS = -I$(top_srcdir)/src EXTRA_DIST=getdata.f.in getdata.f90.in SUBDIRS = test @@ -40,7 +39,7 @@ nodist_include_HEADERS=getdata.f $(F95_INC) lib_LTLIBRARIES=libfgetdata.la $(F95_LIB) -libfgetdata_la_CPPFLAGS = ${GD_CC_WALL} $(GD_CC_WEXTRA) +libfgetdata_la_CPPFLAGS = ${GD_CC_WALL} $(GD_CC_WEXTRA) -I$(top_srcdir)/src libfgetdata_la_SOURCES = fgetdata.c fgetdata.h libfgetdata_la_LIBADD=../../src/libgetdata.la libfgetdata_la_LDFLAGS = -version-info @FGETDATA_VERSION@ Modified: trunk/getdata/bindings/matlab/Makefile.am =================================================================== --- trunk/getdata/bindings/matlab/Makefile.am 2014-07-25 21:32:11 UTC (rev 916) +++ trunk/getdata/bindings/matlab/Makefile.am 2014-07-29 22:45:26 UTC (rev 917) @@ -86,10 +86,6 @@ lib_LTLIBRARIES=libgetdata-matlab.la -libgetdata_matlab_la_SOURCES=matlab.c gd_matlab.h -libgetdata_matlab_la_CPPFLAGS=${MATLAB_CPPFLAGS} -libgetdata_matlab_la_LDFLAGS=-version-info @MATLABGETDATA_VERSION@ - if GD_EXTERNAL libgetdata_matlab_la_LIBADD=$(GETDATA_LIBS) AM_CPPFLAGS=$(GETDATA_CFLAGS) @@ -100,6 +96,10 @@ GDMX_LIBS=-L../../src/.libs -lgetdata endif +libgetdata_matlab_la_SOURCES=matlab.c gd_matlab.h +libgetdata_matlab_la_CPPFLAGS=${MATLAB_CPPFLAGS} ${AM_CPPFLAGS} +libgetdata_matlab_la_LDFLAGS=-version-info @MATLABGETDATA_VERSION@ + %.m: %.c ${srcdir}/doc.tail ${GREP} '^ %' $< | ${SED} -e 's/^ //' > $@ cat ${srcdir}/doc.tail >> $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-25 21:32:14
|
Revision: 916 http://sourceforge.net/p/getdata/code/916 Author: ketiltrout Date: 2014-07-25 21:32:11 +0000 (Fri, 25 Jul 2014) Log Message: ----------- Update autotools version. Modified Paths: -------------- trunk/html/download.html.in Modified: trunk/html/download.html.in =================================================================== --- trunk/html/download.html.in 2014-07-25 21:29:37 UTC (rev 915) +++ trunk/html/download.html.in 2014-07-25 21:32:11 UTC (rev 916) @@ -114,9 +114,9 @@ autoreconf -vifs </div> from the directory containing <code>configure.ac</code>. <a - href="http://www.gnu.org/software/autoconf/">Autoconf</a> 2.63, + href="http://www.gnu.org/software/autoconf/">Autoconf</a> 2.65, or newer, <a href="http://www.gnu.org/software/automake/">automake</a> - 1.11.2, or newer, and <a + 1.13, or newer, and <a href="http://www.gnu.org/software/libtool/">libtool</a> 2.2.6b, or better, are required. You should only have to do this when you check out a new copy of the repository. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-25 21:29:47
|
Revision: 915 http://sourceforge.net/p/getdata/code/915 Author: ketiltrout Date: 2014-07-25 21:29:37 +0000 (Fri, 25 Jul 2014) Log Message: ----------- Bump minimum automake to 1.13 and autoconf to 2.65. Also all the other stuff that should have been in the last commit. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/Makefile.am trunk/getdata/NEWS trunk/getdata/bindings/cxx/Makefile.am trunk/getdata/bindings/cxx/test/Makefile.am trunk/getdata/bindings/f77/Makefile.am trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/f77/test/Makefile.am trunk/getdata/bindings/idl/test/Makefile.am trunk/getdata/bindings/matlab/Makefile.am trunk/getdata/bindings/matlab/test/Makefile.am trunk/getdata/bindings/php/test/Makefile.am trunk/getdata/bindings/python/test/Makefile.am trunk/getdata/configure.ac trunk/getdata/test/Makefile.am trunk/getdata/test/get_const_carray.c trunk/getdata/test/get_sindir_type.c trunk/getdata/util/Makefile.am Added Paths: ----------- trunk/getdata/test/add_amb_code7.c trunk/getdata/test/alter_entry_scalar_amb.c trunk/getdata/test/flush_amb_code.c trunk/getdata/test/parse_scalar1.c trunk/getdata/test/parse_scalar2.c trunk/getdata/test/parse_scalar_repr.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/ChangeLog 2014-07-25 21:29:37 UTC (rev 915) @@ -1,3 +1,31 @@ +2014-07-25 D. V. Wiebe <g et...@ke...> svn:915 + * Makefile.am: Auotmake version bumped to 1.13. + * configure.ac: Autoconf version bumped to 2.65. + +2014-07-25 D. V. Wiebe <g et...@ke...> svn:914 + * src/parse.c (_GD_TokToNum): Added. + * src/parse.c (_GD_SetScalar): Call _GD_TokToNum to parse numbers. + + * src/errors.c: Add GD_E_CODE_AMBIGUOUS suberror. + * src/flush.c (_GD_WriteFieldCode): Append "<0>" when necessary to avoid + otherwise ambiguous scalar field codes. Replaced "space" with "flags" + parameter. Add "index" parameter. + * src/add.c (_GD_CopyScalars) src/mod.c (_GD_AlterScalar): Reject ambiguous + field codes when the format file writer won't be able to deal with them. + + * src/internal.h: Alias GD_PERMISSIVE to GD_NOSTANDARD for legibility. + + * src/common.c (_GD_GetRepr): Add .z (we'll want that later). + + * src/parse.c (_GD_ConstType): Handle GD_STRING. + + * src/parse.c (_GD_ParseRaw): Don't set GD_E_FORMAT more than once. + + * src/parse.c (_GD_SetScalar): Check for the closing > with CARRAY indices. + + * test/add_amb_code7.c test/alter_entry_scalar_amb.c test/flush_amb_code.c + test/parse_scalar1.c test/parse_scalar2.c test/parse_scalar_repr.c: Added. + 2014-07-17 D. V. Wiebe <g et...@ke...> svn:912 * bindings/f77/fgetdata.c (_GDF_SetDirfile): Don't abort on error, just return -1 (optionally discarding the dirfile first). Modified: trunk/getdata/Makefile.am =================================================================== --- trunk/getdata/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -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.11 +AUTOMAKE_OPTIONS = foreign dist-xz check-news 1.13 EXTRA_DIST = ChangeLog Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/NEWS 2014-07-25 21:29:37 UTC (rev 915) @@ -34,8 +34,31 @@ number of problems with reading LZMA files has been fixed, which should result in fewer segmentaion faults. + * BUG FIX: The parser no longer silently appends a closing > to scalar field + codes that contain an umatched opening < (e.g. "scalar<3"). This is now + interpreted as a simple field code (which may be rejected later due to the + presence of the invalid '<' character). + * BUG FIX: The parsing of the \x and \u escape sequences is now correct. + * BUG FIX: The parser no-longer interprets various numbers as field codes + when it shouldn't (e.g. when specifying a PHASE shift as "1." instead of + "1"). + + * BUG FIX: When writing scalar field codes to disk which could be interpreted + as a number (e.g. the field code "1"), the library now forces the + interpretation of these field codes as codes rather than numbers by + appending a scalar index (making, e.g., "1<0>"), which is harmless. + Previously, these were written as-is, resulting in misinterpretation the + next time the Dirfile was opened. This only happens with Standards Version + 8 or later, see the following for earlier versions. + + * BUG FIX: If the current Standards Version in effect is 7 or earlier, + ambiguous field codes (e.g., "1"), are now rejected by gd_[m]add() and + gd_alter_entry() with the error GD_E_BAD_CODE, since they can't be + represented in the metadata on disk. For the behaviour with later Versions, + and in permissive mode, see the previous. + * BUG FIX: Computation of LINCOMs with complex valued input fields now correctly happens in the complex plane. As a side effect, gd_native_type() now also correctly reports such LINCOM fields to be complex valued. @@ -50,11 +73,11 @@ codes containing subfields of the renamed field are now also updated, including field codes specifying meta subfields which do not exist. - * BUG FIX: The gd_[m]add() functions now ignore zero-length scalar strings - (i.e., they treat them as if they were NULL). Previously they would store - these invalid field codes, causing problems later. + * BUG FIX: The gd_[m]add() functions now ignore zero-length strings in the + scalar[] member (i.e., they treat them as if they were NULL). Previously + they would store these invalid field codes, causing problems later. - * BUG FIX: Returning complex-valued CARRAYs as purely real data now works. + * BUG FIX: Fetching 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. @@ -112,9 +135,10 @@ * 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. - * BUG FIX: A previously-read LINTERP table is now always deleted when changing - table paths with gd_alter_linterp() or similar. Previously these obsolete, - cached LUTs would sometimes linger, causing incorrect LINTERP computation. + * BUG FIX: A previously-read LINTERP table is now always discarded when + changing table paths with gd_alter_linterp() or similar. Previously these + obsolete, cached LUTs would sometimes linger, causing incorrect LINTERP + computation. * BUG FIX: gd_[m]alter_spec() no longer ignore co-efficients specified for POLYNOM entries. @@ -472,11 +496,11 @@ * Three new encoding schemes are available. The first is the Sample- Index Encoding (SIE), similar to run-length encoding, useful for - compressing data which changes very rarely varying data. Like the - ASCII encoding, GetData implements it internally, so it's always - available. The other two schemes (zzip and zzslim) are based around - the ZZip library, an access library for PKWARE ZIP files. These are - unusual in that they store all raw data in the same ZIP archive. + compressing data which changes very rarely. Like the ASCII encoding, + GetData implements it internally, so it's always available. The other + two schemes (zzip and zzslim) are based around the ZZip library, an + access library for PKWARE ZIP files. These are unusual in that they + store all raw data in the same ZIP archive. * The /ENCODING directive takes an optional second token. The zzip and zzslim encoding schemes optionally use this token to specify the name @@ -946,7 +970,6 @@ sort them, if needed. As a side-effect of this, tables are no longer read twice when loading, leading to potential speed-up. - * BUG FIX: The library wasn't properly checking that the second and higher input fields in LINCOM and MULTIPLY fields were, in fact, vectors, leading to possible segfaults. Modified: trunk/getdata/bindings/cxx/Makefile.am =================================================================== --- trunk/getdata/bindings/cxx/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/cxx/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -21,7 +21,7 @@ AUTOMAKE_OPTIONS = foreign getdata_includedir = ${includedir}/getdata -INCLUDES = ${GD_CXX_WALL} $(GD_CXX_WEXTRA) -I$(top_srcdir)/src +AM_CPPFLAGS = ${GD_CXX_WALL} $(GD_CXX_WEXTRA) -I$(top_srcdir)/src LIBS= SUBDIRS=test Modified: trunk/getdata/bindings/cxx/test/Makefile.am =================================================================== --- trunk/getdata/bindings/cxx/test/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/cxx/test/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -18,9 +18,9 @@ # 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 +AUTOMAKE_OPTIONS = foreign serial-tests -INCLUDES = ${GD_CXX_WALL} $(GD_CXX_WEXTRA) -I$(srcdir)/.. -I$(top_srcdir)/src +AM_CPPFLAGS = ${GD_CXX_WALL} $(GD_CXX_WEXTRA) -I$(srcdir)/.. -I$(top_srcdir)/src LDADD=../libgetdata++.la TESTS=big_test Modified: trunk/getdata/bindings/f77/Makefile.am =================================================================== --- trunk/getdata/bindings/f77/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/f77/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -29,7 +29,7 @@ endif FCFLAGS += $(GD_FC_WALL) $(GD_FC_WEXTRA) -INCLUDES = -I$(top_srcdir)/src +AM_CPPFLAGS = -I$(top_srcdir)/src EXTRA_DIST=getdata.f.in getdata.f90.in SUBDIRS = test Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/f77/fgetdata.c 2014-07-25 21:29:37 UTC (rev 915) @@ -109,7 +109,7 @@ { int i; - dtrace("%p, %i", D); + dtrace("%p, %i", D, close); if (!f77dirfiles_initialised) _GDF_InitDirfiles(); Modified: trunk/getdata/bindings/f77/test/Makefile.am =================================================================== --- trunk/getdata/bindings/f77/test/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/f77/test/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -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 +AUTOMAKE_OPTIONS = foreign serial-tests if MAKE_F95BINDINGS F95TESTS=big_test95 Modified: trunk/getdata/bindings/idl/test/Makefile.am =================================================================== --- trunk/getdata/bindings/idl/test/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/idl/test/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -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 +AUTOMAKE_OPTIONS = foreign serial-tests if TEST_IDL TESTS_ENVIRONMENT=${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../../src/.libs IDL_PATH="${srcdir}" IDL_DLM_PATH=../.libs ${IDL} Modified: trunk/getdata/bindings/matlab/Makefile.am =================================================================== --- trunk/getdata/bindings/matlab/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/matlab/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -20,10 +20,6 @@ # AUTOMAKE_OPTIONS = foreign -if GETDATA_DEBUG -DEBUG_C = ../../src/debug.c -endif - SUBDIRS=test matlabdir=$(matlabbasedir)/getdata @@ -91,17 +87,16 @@ lib_LTLIBRARIES=libgetdata-matlab.la libgetdata_matlab_la_SOURCES=matlab.c gd_matlab.h -nodist_libgetdata_matlab_la_SOURCES=$(DEBUG_C) libgetdata_matlab_la_CPPFLAGS=${MATLAB_CPPFLAGS} libgetdata_matlab_la_LDFLAGS=-version-info @MATLABGETDATA_VERSION@ if GD_EXTERNAL libgetdata_matlab_la_LIBADD=$(GETDATA_LIBS) -INCLUDES=$(GETDATA_CFLAGS) +AM_CPPFLAGS=$(GETDATA_CFLAGS) GDMX_LIBS=$(GETDATA_LIBS) else libgetdata_matlab_la_LIBADD=../../src/libgetdata.la -INCLUDES=-I${top_srcdir}/src -I../../src +AM_CPPFLAGS=-I${top_srcdir}/src -I../../src GDMX_LIBS=-L../../src/.libs -lgetdata endif @@ -110,7 +105,7 @@ cat ${srcdir}/doc.tail >> $@ %.@mexext@: %.c libgetdata-matlab.la - ${MEX} ${INCLUDES} -L.libs -lgetdata-matlab $(GDMX_LIBS) $< + ${MEX} ${AM_CPPFLAGS} -L.libs -lgetdata-matlab $(GDMX_LIBS) $< Contents.m: ${srcdir}/Contents.m.head make_contents.sh $(matlabfiles) \ $(matlabdocfiles) ${srcdir}/doc.tail Modified: trunk/getdata/bindings/matlab/test/Makefile.am =================================================================== --- trunk/getdata/bindings/matlab/test/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/matlab/test/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -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 +AUTOMAKE_OPTIONS = foreign serial-tests if TEST_MATLAB TESTS_ENVIRONMENT=${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../../src/.libs:../.libs MATLABPATH=${srcdir}:..:${srcdir}/.. ${srcdir}/test.sh ${MATLAB} Modified: trunk/getdata/bindings/php/test/Makefile.am =================================================================== --- trunk/getdata/bindings/php/test/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/php/test/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -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 +AUTOMAKE_OPTIONS = foreign serial-tests if TEST_PHP TESTS_ENVIRONMENT=${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../../src/.libs \ Modified: trunk/getdata/bindings/python/test/Makefile.am =================================================================== --- trunk/getdata/bindings/python/test/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/bindings/python/test/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -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 +AUTOMAKE_OPTIONS = foreign serial-tests if TEST_PYTHON TESTS_ENVIRONMENT=${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../../src/.libs PYTHONPATH=.. ${PYTHON} Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/configure.ac 2014-07-25 21:29:37 UTC (rev 915) @@ -44,7 +44,7 @@ AC_SUBST([GETDATA_REVISION], [getdata_revision]) AC_SUBST([GETDATA_VERSION_SUFFIX], [getdata_extra]) -AC_PREREQ([2.63]) +AC_PREREQ([2.65]) AC_CONFIG_MACRO_DIR([m4]) LT_PREREQ([2.2.6b]) Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/test 2014-07-25 21:29:37 UTC (rev 915) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -12,6 +12,7 ## add_alias add_alias_affix add_alias_meta +add_amb_code7 add_bit add_bit_bitnum add_bit_bitsize ## -116,6 +117,7 ## alter_entry_scalar3 alter_entry_scalar3c alter_entry_scalar4 +alter_entry_scalar_amb alter_index alter_indir alter_lincom_23 ## -419,6 +421,7 ## flist_type_meta_hidden flist_type_meta_invalid flush_all +flush_amb_code flush_bad_code flush_flush flush_invalid ## -924,6 +927,9 ## parse_sarray parse_sarray_long parse_sbit +parse_scalar1 +parse_scalar2 +parse_scalar_repr parse_sindir parse_sort parse_string Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/test/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -18,24 +18,25 @@ # 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 +AUTOMAKE_OPTIONS = foreign serial-tests LDADD=../src/libgetdata.la -INCLUDES=${GD_CC_WALL} $(GD_CC_WEXTRA) -I$(top_srcdir)/src +AM_CPPFLAGS=${GD_CC_WALL} $(GD_CC_WEXTRA) -I$(top_srcdir)/src EXTRA_DIST=test.h -ADD_TESTS=add_add add_affix add_alias add_alias_affix add_alias_meta add_bit \ - add_bit_bitnum add_bit_bitsize add_bit_invalid add_bit_numbits \ - add_bit_scalars add_carray add_clincom add_code add_const \ - add_cpolynom add_crecip add_crecip89 add_divide add_divide_invalid \ - add_dot add_duplicate add_format add_indir add_invalid add_lincom \ - add_lincom_affix add_lincom_invalid add_lincom_nfields add_linterp \ - add_linterp_invalid add_meta add_meta_alias add_mplex \ - add_mplex_scalars add_multiply add_multiply_invalid add_phase \ - add_phase_invalid add_polynom add_polynom_scalar add_protect add_raw \ - add_raw_include add_raw_invalid add_raw_spf add_raw_spf_scalar \ - add_raw_sub add_raw_type add_rdonly add_recip add_resolv add_sarray \ +ADD_TESTS=add_add add_affix add_alias add_alias_affix add_alias_meta \ + add_amb_code7 add_bit add_bit_bitnum add_bit_bitsize add_bit_invalid \ + add_bit_numbits add_bit_scalars add_carray add_clincom add_code \ + add_const add_cpolynom add_crecip add_crecip89 add_divide \ + add_divide_invalid add_dot add_duplicate add_format add_indir \ + add_invalid add_lincom add_lincom_affix add_lincom_invalid \ + add_lincom_nfields add_linterp add_linterp_invalid add_meta \ + add_meta_alias add_mplex add_mplex_scalars add_multiply \ + add_multiply_invalid add_phase add_phase_invalid add_polynom \ + add_polynom_scalar add_protect add_raw add_raw_include \ + add_raw_invalid add_raw_spf add_raw_spf_scalar add_raw_sub \ + add_raw_type add_rdonly add_recip add_resolv add_sarray \ add_sarray_nil add_sbit add_scalar add_scalar_carray \ add_scalar_carray_bad add_sindir add_sort add_spec \ add_spec_directive add_spec_invalid add_spec_meta add_spec_resolv \ @@ -53,15 +54,15 @@ alter_entry_lincom alter_entry_recode alter_entry_recode_recalc \ alter_entry_sarray alter_entry_scalar1 alter_entry_scalar2a \ alter_entry_scalar2n alter_entry_scalar3 alter_entry_scalar3c \ - alter_entry_scalar4 alter_index alter_indir alter_lincom_23 \ - alter_lincom_32 alter_lincom_affix alter_lincom_input \ - alter_lincom_offset alter_lincom_slope alter_linterp \ - alter_linterp_move alter_mplex alter_mspec alter_mspec_affix \ - alter_multiply alter_phase alter_polynom_coeff alter_polynom_input \ - alter_polynom_ord alter_raw_spf alter_raw_type alter_recip \ - alter_recip_zero alter_sarray alter_scalar_affix alter_sindir \ - alter_spec alter_spec_affix alter_spec_meta alter_spec_polynom \ - alter_window + alter_entry_scalar4 alter_entry_scalar_amb alter_index alter_indir \ + alter_lincom_23 alter_lincom_32 alter_lincom_affix \ + alter_lincom_input alter_lincom_offset alter_lincom_slope \ + alter_linterp alter_linterp_move alter_mplex alter_mspec \ + alter_mspec_affix alter_multiply alter_phase alter_polynom_coeff \ + alter_polynom_input alter_polynom_ord alter_raw_spf alter_raw_type \ + alter_recip alter_recip_zero alter_sarray alter_scalar_affix \ + alter_sindir 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_get_sub \ ascii_nframes ascii_put ascii_sync @@ -170,9 +171,9 @@ flist_type_hidden flist_type_invalid flist_type_meta \ flist_type_meta_hidden flist_type_meta_invalid -FLUSH_TESTS=flush_all flush_bad_code flush_flush flush_invalid flush_lincom \ - flush_lincom1 flush_meta flush_mult flush_raw_close flush_ref \ - flush_spec flush_string flush_sync +FLUSH_TESTS=flush_all flush_amb_code flush_bad_code flush_flush flush_invalid \ + flush_lincom flush_lincom1 flush_meta flush_mult flush_raw_close \ + flush_ref flush_spec flush_string flush_sync FOFFS_TESTS=foffs_alter foffs_alter_all foffs_get foffs_move @@ -326,7 +327,8 @@ parse_quote_mismatch parse_raw parse_raw_char parse_raw_char_bad \ parse_raw_ncols parse_raw_scalar parse_raw_spf parse_raw_type \ parse_recip parse_ref parse_ref_nonexistent parse_sarray \ - parse_sarray_long parse_sbit parse_sindir parse_sort parse_string \ + parse_sarray_long parse_sbit parse_scalar1 parse_scalar2 \ + parse_scalar_repr parse_sindir parse_sort parse_string \ parse_string_ncols parse_string_null parse_utf8 parse_utf8_invalid \ parse_utf8_zero parse_version parse_version_89 parse_version_98 \ parse_version_include parse_version_permissive parse_version_p8 \ Added: trunk/getdata/test/add_amb_code7.c =================================================================== --- trunk/getdata/test/add_amb_code7.c (rev 0) +++ trunk/getdata/test/add_amb_code7.c 2014-07-25 21:29:37 UTC (rev 915) @@ -0,0 +1,54 @@ +/* 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" + +int main(void) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + int e1, r = 0; + DIRFILE *D; + gd_entry_t E; + + memset(&E, 0, sizeof(E)); + E.field = "pathological"; + E.field_type = GD_PHASE_ENTRY; + E.in_fields[0] = "INDEX"; + + /* this is a valid field code, sadly */ + E.scalar[0] = "1"; + E.scalar_ind[0] = -1; + + rmdirfile(); + D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_TRUNC); + gd_dirfile_standards(D, 7); + + gd_add(D, &E); + e1 = gd_error(D); + CHECKI(e1, GD_E_BAD_CODE); + + gd_discard(D); + + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/alter_entry_scalar_amb.c =================================================================== --- trunk/getdata/test/alter_entry_scalar_amb.c (rev 0) +++ trunk/getdata/test/alter_entry_scalar_amb.c 2014-07-25 21:29:37 UTC (rev 915) @@ -0,0 +1,65 @@ +/* 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 <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) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *format_data = "/VERSION 7\nphase PHASE INDEX c\n"; + int fd, ret, error, n, r = 0; + DIRFILE *D; + gd_entry_t E; + + 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_RDWR); + gd_entry(D, "phase", &E); + free(E.scalar[0]); + E.scalar[0] = "2"; + ret = gd_alter_entry(D, "phase", &E, 0); + error = gd_error(D); + CHECKI(ret, -1); + CHECKI(error, GD_E_BAD_CODE); + + E.scalar[0] = NULL; + gd_free_entry_strings(&E); + + gd_discard(D); + + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/flush_amb_code.c =================================================================== --- trunk/getdata/test/flush_amb_code.c (rev 0) +++ trunk/getdata/test/flush_amb_code.c 2014-07-25 21:29:37 UTC (rev 915) @@ -0,0 +1,78 @@ +/* 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" + +int main(void) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + int e1, e2, i = 0, r = 0; + DIRFILE *D; + gd_entry_t E; + + /* For no good, but long standing, reason, these are all valid field names, + * I guess... */ + char *code[] = {"0", "0x1", "02", "3.00", "4e0", "0x5p0"}; + + memset(&E, 0, sizeof(E)); + E.field = "pathological"; + E.field_type = GD_POLYNOM_ENTRY; + E.poly_ord = 5; + E.in_fields[0] = "INDEX"; + + E.scalar[0] = code[0]; + E.scalar[1] = code[1]; + E.scalar[2] = code[2]; + E.scalar[3] = code[3]; + E.scalar[4] = code[4]; + E.scalar[5] = code[5]; + + E.scalar_ind[0] = -1; + E.scalar_ind[1] = -1; + E.scalar_ind[2] = -1; + E.scalar_ind[3] = -1; + E.scalar_ind[4] = -1; + E.scalar_ind[5] = -1; + + rmdirfile(); + D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_TRUNC | GD_VERBOSE); + + gd_add(D, &E); + e1 = gd_error(D); + CHECKI(e1, 0); + + gd_close(D); + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + gd_entry(D, "pathological", &E); + e2 = gd_error(D); + CHECKI(e2, 0); + + for (i = 0; i < 6; ++i) + CHECKSi(i, E.scalar[i], code[i]); + + gd_discard(D); + + unlink(format); + rmdir(filedir); + + return r; +} Modified: trunk/getdata/test/get_const_carray.c =================================================================== --- trunk/getdata/test/get_const_carray.c 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/test/get_const_carray.c 2014-07-25 21:29:37 UTC (rev 915) @@ -28,9 +28,10 @@ { 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"; + 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; + int fd, n, error, r = 0; DIRFILE *D; rmdirfile(); Modified: trunk/getdata/test/get_sindir_type.c =================================================================== --- trunk/getdata/test/get_sindir_type.c 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/test/get_sindir_type.c 2014-07-25 21:29:37 UTC (rev 915) @@ -35,7 +35,7 @@ "data RAW UINT8 8\n"; const char *c[8]; unsigned char data_data[256]; - int fd, i, n, error, r = 0; + int fd, n, error, r = 0; DIRFILE *D; rmdirfile(); Added: trunk/getdata/test/parse_scalar1.c =================================================================== --- trunk/getdata/test/parse_scalar1.c (rev 0) +++ trunk/getdata/test/parse_scalar1.c 2014-07-25 21:29:37 UTC (rev 915) @@ -0,0 +1,55 @@ +/* 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 <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 *format = "dirfile/format"; + const char *format_data = "/VERSION 9\ndata RAW UINT8 scalar<3>\n"; + int fd, 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); + error = gd_error(D); + CHECKI(error,GD_E_OK); + + gd_discard(D); + + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/parse_scalar2.c =================================================================== --- trunk/getdata/test/parse_scalar2.c (rev 0) +++ trunk/getdata/test/parse_scalar2.c 2014-07-25 21:29:37 UTC (rev 915) @@ -0,0 +1,59 @@ +/* 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 <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 *format = "dirfile/format"; + const char *format_data = "/VERSION 9\ndata RAW UINT8 scalar<3\n"; + int fd, error, r = 0; + DIRFILE *D; + gd_entry_t E; + + 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); + error = gd_error(D); + CHECKI(error,0); + + gd_entry(D, "data", &E); + CHECKS(E.scalar[0], "scalar<3"); + + gd_discard(D); + + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/parse_scalar_repr.c =================================================================== --- trunk/getdata/test/parse_scalar_repr.c (rev 0) +++ trunk/getdata/test/parse_scalar_repr.c 2014-07-25 21:29:37 UTC (rev 915) @@ -0,0 +1,55 @@ +/* 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 <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 *format = "dirfile/format"; + const char *format_data = "data RAW UINT8 scalar.r\n"; + int fd, 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); + error = gd_error(D); + CHECKI(error,GD_E_OK); + + gd_discard(D); + + unlink(format); + rmdir(filedir); + + return r; +} Modified: trunk/getdata/util/Makefile.am =================================================================== --- trunk/getdata/util/Makefile.am 2014-07-25 03:17:52 UTC (rev 914) +++ trunk/getdata/util/Makefile.am 2014-07-25 21:29:37 UTC (rev 915) @@ -21,7 +21,7 @@ AUTOMAKE_OPTIONS = foreign LDADD=../src/libgetdata.la -INCLUDES=${GD_CC_WALL} $(GD_CC_WEXTRA) -I$(top_srcdir)/src +AM_CPPFLAGS=${GD_CC_WALL} $(GD_CC_WEXTRA) -I$(top_srcdir)/src bin_PROGRAMS=checkdirfile dirfile2ascii checkdirfile_SOURCES=checkdirfile.c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-25 03:18:04
|
Revision: 914 http://sourceforge.net/p/getdata/code/914 Author: ketiltrout Date: 2014-07-25 03:17:52 +0000 (Fri, 25 Jul 2014) Log Message: ----------- Deal with ambiguous field codes. Modified Paths: -------------- trunk/getdata/src/add.c trunk/getdata/src/ascii.c trunk/getdata/src/common.c trunk/getdata/src/endian.c trunk/getdata/src/errors.c trunk/getdata/src/flush.c trunk/getdata/src/globals.c trunk/getdata/src/index.c trunk/getdata/src/internal.h trunk/getdata/src/mod.c trunk/getdata/src/open.c trunk/getdata/src/parse.c trunk/getdata/src/sie.c Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/add.c 2014-07-25 03:17:52 UTC (rev 914) @@ -108,11 +108,26 @@ { E->scalar[i] = NULL; } else { - if (_GD_CheckCodeAffixes(D, NULL, entry->scalar[i], - entry->fragment_index, 1)) + /* check for correct affixes */ + if (_GD_CheckCodeAffixes(D, NULL, entry->scalar[i], entry->fragment_index, + 1)) { break; } + + /* when using early Standards, reject ambiguous field codes */ + if (entry->scalar_ind[i] == -1 && !(D->flags & GD_NOSTANDARD) && + D->standards <= 7) + { + if (_GD_TokToNum(entry->scalar[i], D->standards, 1, NULL, NULL, NULL, + NULL) != -1) + { + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_AMBIGUOUS, NULL, 0, + entry->scalar[i]); + break; + } + } + E->scalar[i] = _GD_Strdup(D, entry->scalar[i]); E->scalar_ind[i] = entry->scalar_ind[i]; mask_out |= (1 << i); @@ -704,7 +719,7 @@ /* start parsing */ n_cols = _GD_Tokenise(D, line, &outstring, &tok_pos, MAX_IN_COLS, in_cols, - "dirfile_madd_spec()", 0, D->standards, D->flags & GD_PERMISSIVE); + "dirfile_madd_spec()", 0, D->standards, D->flags & GD_NOSTANDARD); /* Directive parsing is skipped -- The Field Spec parser will add the field */ if (!D->error) @@ -769,7 +784,7 @@ /* start parsing */ n_cols = _GD_Tokenise(D, line, &outstring, &tok_pos, MAX_IN_COLS, in_cols, - "dirfile_add_spec()", 0, D->standards, D->flags & GD_PERMISSIVE); + "dirfile_add_spec()", 0, D->standards, D->flags & GD_NOSTANDARD); /* Directive parsing is skipped -- The Field Spec parser will add the field */ if (!D->error) Modified: trunk/getdata/src/ascii.c =================================================================== --- trunk/getdata/src/ascii.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/ascii.c 2014-07-25 03:17:52 UTC (rev 914) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2011 D. V. Wiebe +/* Copyright (C) 2008-2013 D. V. Wiebe * *************************************************************************** * Modified: trunk/getdata/src/common.c =================================================================== --- trunk/getdata/src/common.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/common.c 2014-07-25 03:17:52 UTC (rev 914) @@ -836,6 +836,9 @@ case 'a': repr = GD_REPR_ARG; break; + case 'z': + repr = GD_REPR_NONE; + break; default: if (err) _GD_SetError(D, GD_E_BAD_REPR, GD_E_REPR_UNKNOWN, NULL, 0, Modified: trunk/getdata/src/endian.c =================================================================== --- trunk/getdata/src/endian.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/endian.c 2014-07-25 03:17:52 UTC (rev 914) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2011 D. V. Wiebe +/* Copyright (C) 2008-2011, 2013 D. V. Wiebe * *************************************************************************** * Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/errors.c 2014-07-25 03:17:52 UTC (rev 914) @@ -89,6 +89,7 @@ /* GD_E_BAD_CODE: 4 = field code */ { GD_E_BAD_CODE, GD_E_CODE_MISSING, "Field not found: {4}", 0 }, { GD_E_BAD_CODE, GD_E_CODE_INVALID, "Bad field name: {4}", 0 }, + { GD_E_BAD_CODE, GD_E_CODE_AMBIGUOUS, "Ambiguous field code: {4}", 0 }, /* GD_E_BAD_TYPE: 1 = data type */ { GD_E_BAD_TYPE, 0, "Bad data type: {1}", 0 }, /* GD_E_RAW_IO: 2 = filename, 3 = errno */ Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/flush.c 2014-07-25 03:17:52 UTC (rev 914) @@ -291,21 +291,42 @@ /* write a field code, taking care of stripping off affixes; returns the length * written */ +#define GD_WFC_SPACE 0x1 +#define GD_WFC_SCALAR 0x2 static ssize_t _GD_WriteFieldCode(DIRFILE *D, FILE *stream, int me, - const char *code, int permissive, int standards, int space) + const char *code, int index, int permissive, int standards, unsigned flags) { int dummy; ssize_t len; char *ptr; - dtrace("%p, %p, %i, \"%s\", %i, %i, %i", D, stream, me, code, permissive, - standards, space); + const int scalar = flags & GD_WFC_SCALAR; + const int space = flags & GD_WFC_SPACE; + dtrace("%p, %p, %i, \"%s\", %i, %i, %i, 0x%X", D, stream, me, code, index, + permissive, standards, flags); + 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); + /* If a scalar field code could be interpreted as a number, we must force + * interpretation as a field code by appending a <0> scalar index, which is + * valid for both CARRAY and CONST fields. + */ + if (len > 0 && scalar && index == -1) + if (_GD_TokToNum(ptr, standards, !permissive, NULL, NULL, NULL, NULL) != -1) + { + if (permissive || standards >= 8) { + if (fputs("<0>", stream) == EOF) + len = -1; + else + len += 3; + } else + _GD_InternalError(D); + } + /* append a space */ if (space && len > 0) { if (fputc(' ', stream) == EOF) @@ -329,7 +350,7 @@ dtrace("%p, %p, %i, \"%s\", %" PRNsize_t ", %i, %i", D, stream, me, in, len, permissive, standards); - i = _GD_WriteFieldCode(D, stream, me, in, permissive, standards, 0); + i = _GD_WriteFieldCode(D, stream, me, in, 0, permissive, standards, 0); if (i >= 0) for (; i < len; ++i) @@ -353,8 +374,8 @@ permissive, type, value, scalar, index, postamble); if (scalar != NULL) { - if (_GD_WriteFieldCode(D, stream, me, scalar, permissive, D->standards, 0) - < 0) + if (_GD_WriteFieldCode(D, stream, me, scalar, index, permissive, + D->standards, GD_WFC_SCALAR) < 0) { dreturn("%i", -1); return -1; @@ -379,7 +400,7 @@ fprintf(stream, "%.15g%s", *(double *)value, postamble); else if (type == GD_COMPLEX128) fprintf(stream, "%.15g;%.15g%s", *(double *)value, ((double *)value)[1], - postamble); + postamble); else { _GD_InternalError(D); dreturn("%i", -1); @@ -414,12 +435,12 @@ if (E->field_type == GD_ALIAS_ENTRY) { if (fputs("/ALIAS ", stream) == EOF) goto WRITE_ERR; - if (_GD_WriteFieldCode(D, stream, me, E->field, permissive, D->standards, 1) - < 0) + if (_GD_WriteFieldCode(D, stream, me, E->field, 0, permissive, D->standards, + GD_WFC_SPACE) < 0) { goto WRITE_ERR; } - if (_GD_WriteFieldCode(D, stream, me, E->in_fields[0], permissive, + if (_GD_WriteFieldCode(D, stream, me, E->in_fields[0], 0, permissive, D->standards, 0) < 0) { goto WRITE_ERR; @@ -457,21 +478,21 @@ break; case GD_LINCOM_ENTRY: if (fprintf(stream, " LINCOM%s %i ", pretty ? " " : "", - E->EN(lincom,n_fields)) < 0) + E->EN(lincom,n_fields)) < 0) { goto WRITE_ERR; } for (i = 0; i < E->EN(lincom,n_fields); ++i) { - if (_GD_WriteFieldCode(D, stream, me, E->in_fields[i], permissive, - D->standards, 1) < 0) + if (_GD_WriteFieldCode(D, stream, me, E->in_fields[i], 0, permissive, + D->standards, GD_WFC_SPACE) < 0) { goto WRITE_ERR; } if (E->flags & GD_EN_COMPSCAL) { 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,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) @@ -493,8 +514,8 @@ break; case GD_LINTERP_ENTRY: if (fprintf(stream, " LINTERP%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[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || _GD_StringEscapeise(stream, E->EN(linterp,table), 0, permissive, D->standards) < 0) { @@ -503,8 +524,8 @@ break; case GD_BIT_ENTRY: if (fprintf(stream, " BIT%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[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 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, @@ -515,9 +536,9 @@ break; case GD_DIVIDE_ENTRY: 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, + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], 0, permissive, D->standards, 0) < 0) { goto WRITE_ERR; @@ -525,8 +546,8 @@ break; case GD_RECIP_ENTRY: if (fprintf(stream, " RECIP%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[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || _GD_WriteConst(D, stream, me, permissive, GD_COMPLEX128, &E->EN(recip,cdividend), E->scalar[0], E->scalar_ind[0], "") < 0) { @@ -535,9 +556,9 @@ break; case GD_MULTIPLY_ENTRY: 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, + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], 0, permissive, D->standards, 0) < 0) { goto WRITE_ERR; @@ -545,8 +566,8 @@ break; case GD_PHASE_ENTRY: if (fprintf(stream, " PHASE%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[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || _GD_WriteConst(D, stream, me, permissive, GD_INT64, &E->EN(phase,shift), E->scalar[0], E->scalar_ind[0], "") < 0) { @@ -555,23 +576,23 @@ break; case GD_POLYNOM_ENTRY: if (fprintf(stream, " POLYNOM%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[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0) { goto WRITE_ERR; } for (i = 0; i <= E->EN(polynom,poly_ord); ++i) 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)) ? "" : " ") < 0) + &E->EN(polynom,ca)[i], E->scalar[i], E->scalar_ind[i], + (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)) ? "" : " ") < 0) + &E->EN(polynom,a)[i], E->scalar[i], E->scalar_ind[i], + (i == E->EN(polynom,poly_ord)) ? "" : " ") < 0) { goto WRITE_ERR; } @@ -579,8 +600,8 @@ break; case GD_SBIT_ENTRY: if (fprintf(stream, " SBIT%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[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 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, @@ -591,9 +612,9 @@ break; case GD_WINDOW_ENTRY: 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, + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], 0, permissive, D->standards, 0) < 0 || fprintf(stream, " %s ", _GD_WindopName(D, E->EN(window,windop))) < 0) @@ -613,7 +634,7 @@ case GD_WINDOP_SET: case GD_WINDOP_CLR: if (_GD_WriteConst(D, stream, me, permissive, GD_UINT64, - &E->EN(window,threshold.u), E->scalar[0], E->scalar_ind[0], + &E->EN(window,threshold.u), E->scalar[0], E->scalar_ind[0], "") < 0) { goto WRITE_ERR; @@ -621,7 +642,7 @@ break; default: if (_GD_WriteConst(D, stream, me, permissive, GD_FLOAT64, - &E->EN(window,threshold.r), E->scalar[0], E->scalar_ind[0], + &E->EN(window,threshold.r), E->scalar[0], E->scalar_ind[0], "") < 0) { goto WRITE_ERR; @@ -631,10 +652,10 @@ break; case GD_MPLEX_ENTRY: 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_WriteFieldCode(D, stream, me, E->in_fields[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], 0, permissive, + D->standards, GD_WFC_SPACE) < 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, @@ -645,7 +666,7 @@ break; case GD_CONST_ENTRY: if (fprintf(stream, " CONST%s %s ", pretty ? " " : "", _GD_TypeName(D, - E->EN(scalar,const_type))) < 0) + E->EN(scalar,const_type))) < 0) { goto WRITE_ERR; } @@ -657,7 +678,7 @@ 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) + *((double*)E->e->u.scalar.d + 1)) < 0) { goto WRITE_ERR; } @@ -735,9 +756,9 @@ 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, + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], 0, permissive, D->standards, 0) < 0) { goto WRITE_ERR; @@ -745,9 +766,9 @@ 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, + _GD_WriteFieldCode(D, stream, me, E->in_fields[0], 0, permissive, + D->standards, GD_WFC_SPACE) < 0 || + _GD_WriteFieldCode(D, stream, me, E->in_fields[1], 0, permissive, D->standards, 0) < 0) { goto WRITE_ERR; @@ -770,8 +791,8 @@ { if (fputs("/HIDDEN ", stream) == EOF) goto WRITE_ERR; - if (_GD_WriteFieldCode(D, stream, me, E->field, permissive, D->standards, 0) - < 0) + if (_GD_WriteFieldCode(D, stream, me, E->field, 0, permissive, D->standards, + 0) < 0) { goto WRITE_ERR; } @@ -857,8 +878,8 @@ strftime(buffer, GD_MAX_LINE_LENGTH, "%c", gmtime_r(&t, &now)); 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) < 0) + "# It was written using version %s of the GetData Library.\n" + "# Written on %s UTC", PACKAGE_VERSION, buffer) < 0) { goto WRITE_ERR; } @@ -880,7 +901,7 @@ /* version */ if (permissive) { if (fprintf(stream, "# WARNING: This file may not conform to any " - "Dirfile Standards Version.\n") < 0) + "Dirfile Standards Version.\n") < 0) { goto WRITE_ERR; } @@ -890,7 +911,7 @@ } else if (fprintf(stream, "# This file conforms to Dirfile Standards Version %i.\n", - D->standards) < 0) + D->standards) < 0) { goto WRITE_ERR; } @@ -982,7 +1003,7 @@ if (use_encdat && D->fragment[i].enc_data) { if (fprintf(stream, "/ENCODING %s %s\n", encoding, - (char*)D->fragment[i].enc_data) < 0) + (char*)D->fragment[i].enc_data) < 0) { goto WRITE_ERR; } @@ -1051,8 +1072,9 @@ if (permissive || D->standards >= 6) if (D->fragment[i].ref_name != NULL) { if (fputs("/REFERENCE ", stream) == EOF || - _GD_WriteFieldCode(D, stream, i, D->fragment[i].ref_name, permissive, - D->standards, 0) < 0 || fputc('\n', stream) == EOF) + _GD_WriteFieldCode(D, stream, i, D->fragment[i].ref_name, 0, + permissive, D->standards, 0) < 0 || + fputc('\n', stream) == EOF) { goto WRITE_ERR; } @@ -1100,9 +1122,9 @@ if (fragment == GD_ALL_FRAGMENTS) { for (i = 0; i < D->n_fragment; ++i) if (force || D->fragment[i].modified) - _GD_FlushFragment(D, i, D->flags & GD_PERMISSIVE); + _GD_FlushFragment(D, i, D->flags & GD_NOSTANDARD); } else if (force || D->fragment[fragment].modified) - _GD_FlushFragment(D, fragment, D->flags & GD_PERMISSIVE); + _GD_FlushFragment(D, fragment, D->flags & GD_NOSTANDARD); dreturnvoid(); } Modified: trunk/getdata/src/globals.c =================================================================== --- trunk/getdata/src/globals.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/globals.c 2014-07-25 03:17:52 UTC (rev 914) @@ -115,7 +115,7 @@ } /* the mask of allowed flags */ -#define GD_FLAG_MASK ( GD_VERBOSE | GD_PRETTY_PRINT) +#define GD_FLAG_MASK (GD_VERBOSE | GD_PRETTY_PRINT) unsigned long gd_flags(DIRFILE *D, unsigned long set, unsigned long reset) gd_nothrow { Modified: trunk/getdata/src/index.c =================================================================== --- trunk/getdata/src/index.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/index.c 2014-07-25 03:17:52 UTC (rev 914) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2012 D. V. Wiebe +/* Copyright (C) 2009-2013 D. V. Wiebe * *************************************************************************** * Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/internal.h 2014-07-25 03:17:52 UTC (rev 914) @@ -736,6 +736,7 @@ #define GD_E_CODE_MISSING 1 #define GD_E_CODE_INVALID 2 +#define GD_E_CODE_AMBIGUOUS 3 #define GD_E_LINFILE_LENGTH 1 #define GD_E_LINFILE_OPEN 2 @@ -1024,6 +1025,10 @@ #define GD_HAVE_VERSION 0x40000000 /* have computed the version */ #define GD_INVALID 0x80000000 /* the dirfile is invalid */ +/* This has been the meaning of GD_PERMISSIVE post-open for a while; let's + * alias it to avoid confusing ourselves */ +#define GD_NOSTANDARD GD_PERMISSIVE /* dirfile conforms to no standard */ + /* representation suffixes */ #define GD_REPR_NONE 0 #define GD_REPR_REAL 'r' @@ -1226,6 +1231,8 @@ int _GD_Tokenise(DIRFILE *restrict, const char *restrict, char **, const char **, int, char **, const char *restrict, int linenum, int standards, int pedantic); +int _GD_TokToNum(const char *restrict, int, int, double*, double*, uint64_t*, + int64_t*); void _GD_UpdateAliases(DIRFILE*, int); int _GD_ValidateField(const char*, int, int, int, int*); off64_t _GD_WriteSeek(DIRFILE *restrict, gd_entry_t *restrict, Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/mod.c 2014-07-25 03:17:52 UTC (rev 914) @@ -89,7 +89,14 @@ /* 2: set a new CONST field from sout; if this is a RAW field, and we've * been asked to move the raw file, _GD_Change is going to need to * recalculate the entry; no need to change lout: it's ignored. */ - if (!_GD_CheckCodeAffixes(D, NULL, sin, fragment_index, 1)) { + if (_GD_CheckCodeAffixes(D, NULL, sin, fragment_index, 1)) + ; /* reject codes with bad affixes */ + else if (iin == -1 && !(D->flags & GD_NOSTANDARD) && D->standards <= 7 && + _GD_TokToNum(sin, D->standards, 1, NULL, NULL, NULL, NULL) != -1) + { + /* when using early Standards, reject ambiguous field codes */ + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_AMBIGUOUS, NULL, 0, sin); + } else { r = GD_AS_FREE_SCALAR | GD_AS_NEED_RECALC | GD_AS_MODIFIED; *sout = _GD_Strdup(D, sin); *iout = iin; @@ -1724,7 +1731,7 @@ /* start parsing */ n_cols = _GD_Tokenise(D, line, &outstring, &tok_pos, MAX_IN_COLS, in_cols, - "dirfile_alter_spec()", 0, standards, D->flags & GD_PERMISSIVE); + "dirfile_alter_spec()", 0, standards, D->flags & GD_NOSTANDARD); if (D->error) { free(outstring); @@ -1824,7 +1831,7 @@ /* start parsing */ n_cols = _GD_Tokenise(D, line, &outstring, &tok_pos, MAX_IN_COLS, in_cols, - "dirfile_malter_spec()", 0, standards, D->flags & GD_PERMISSIVE); + "dirfile_malter_spec()", 0, standards, D->flags & GD_NOSTANDARD); if (!D->error) { /* Let the parser compose the entry */ Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/open.c 2014-07-25 03:17:52 UTC (rev 914) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2012 D. V. Wiebe + * Copyright (C) 2005-2014 D. V. Wiebe * *************************************************************************** * @@ -632,12 +632,12 @@ if (_GD_FindVersion(D)) { /* conforms to some standard, use the latest */ gd_dirfile_standards(D, GD_VERSION_LATEST); /* can't fail */ - D->flags &= ~GD_PERMISSIVE; + D->flags &= ~GD_NOSTANDARD; } else /* non-conformant dirfile, flag it */ - D->flags |= GD_PERMISSIVE; + D->flags |= GD_NOSTANDARD; } else - D->flags &= ~GD_PERMISSIVE; + D->flags &= ~GD_NOSTANDARD; dreturn("%p", D); return D; Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/parse.c 2014-07-25 03:17:52 UTC (rev 914) @@ -110,34 +110,168 @@ return o; } +/* Convert a string to a number. The non-NULL pointers provided dictate the + * returned type. Returns -1 if it wasn't a number or -2 if it was but was + * out of range */ +int _GD_TokToNum(const char *restrict token, int standards, int pedantic, + double *re, double *im, uint64_t *u, int64_t *i) +{ + long long ir = 0, ii = 0; + unsigned long long ur = 0, ui = 0; + double dr = 0, di = 0; + char *endptr = NULL; + gd_type_t rt = GD_UNKNOWN, it = GD_UNKNOWN; + const int base = (!pedantic || standards >= 9) ? 0 : 10; + + dtrace("\"%s\", %i, %i, %p, %p, %p, %p", token, standards, pedantic, re, im, + u, i); + + /* we have to run the token through both strtod and strtol because neither of + * these handles all the allowed syntax */ + + /* the real part */ + errno = 0; + ir = gd_strtoll(token, &endptr, base); + if (!errno && (*endptr == '\0' || *endptr == ';')) + rt = GD_INT64; + + if (rt == GD_UNKNOWN && errno == ERANGE) { + /* could be a uint64 > 2**63 */ + errno = 0; + ur = gd_strtoull(token, &endptr, base); + if (!errno && (*endptr == '\0' || *endptr == ';')) + rt = GD_UINT64; + } + + if (rt == GD_UNKNOWN) { /* all that's left to try */ + errno = 0; + dr = gd_strtod(token, &endptr); + + if (!errno && (*endptr == '\0' || *endptr == ';')) + rt = GD_FLOAT64; + } + + /* check for real-part success */ + if (rt == GD_UNKNOWN) { + dreturn("%i", -1); + return -1; + } + + /* if there's no semicolon, set the imaginary part to zero */ + if (*endptr == '\0') { + it = GD_NULL; + } else { + /* convert imaginary part the same way */ + token = endptr + 1; + errno = 0; + ii = gd_strtoll(token, &endptr, base); + if (!errno && *endptr == '\0') + it = (ii == 0) ? GD_NULL : GD_INT64; + + if (it == GD_UNKNOWN && errno == ERANGE) { + /* could be a uint64 > 2**63 */ + errno = 0; + ui = gd_strtoull(token, &endptr, base); + if (!errno && *endptr == '\0') + it = (ui == 0) ? GD_NULL : GD_UINT64; + } + + if (it == GD_UNKNOWN) { /* all that's left to try */ + errno = 0; + di = gd_strtod(token, &endptr); + + if (!errno && *endptr == '\0') + it = (di == 0) ? GD_NULL : GD_FLOAT64; + } + + /* check for imaginary-part success */ + if (it == GD_UNKNOWN) { + dreturn("%i", -1); + return -1; + } + + if (!im && it != GD_NULL) { /* reject unwanted complex value */ + dreturn("%i", -2); + return -2; + } + } + + /* return the desired value, if possible */ + if (re) { /* float or complex */ + if (rt == GD_FLOAT64) + *re = dr; + else if (rt == GD_INT64) + *re = ir; + else + *re = ur; + + if (im) { /* complex */ + if (it == GD_NULL) + *im = 0; + else if (it == GD_FLOAT64) + *im = di; + else if (it == GD_INT64) + *im = ii; + else if (it == GD_UINT64) + *im = ui; + } + } else if (u) { /* unsigned int -- reject negative values */ + if (rt == GD_UINT64) + *u = ur; + else if (rt == GD_INT64) { + if (ir < 0) { + dreturn("%i", -2); + return -2; + } + *u = ir; + } else { + if (dr < 0) { + dreturn("%i", -2); + return -2; + } + *u = dr; + } + } else if (i) { /* int */ + if (rt == GD_INT64) + *i = ir; + else if (rt == GD_FLOAT64) + *i = dr; + else { /* this must be an overflow */ + dreturn("%i", -2); + return -2; + } + } + + dreturn("%i", 0); + return 0; +} + /* Returns a newly malloc'd string containing the scalar field name, or NULL on * numeric literal or error */ static char *_GD_SetScalar(DIRFILE *restrict D, const char *restrict token, - void *restrict data, int type, int me, const char *restrict format_file, - int line, int *restrict index, unsigned *restrict flags, int standards, - int pedantic) + void *restrict data, gd_type_t type, int me, + const char *restrict format_file, int line, int *restrict index, + unsigned *restrict flags, int standards, int pedantic) { - char *ptr = NULL; - char *lt; - int dummy; - const char *semicolon; + char *lt, *ptr; + int i; dtrace("%p, \"%s\", %p, 0x%X, \"%s\", %i, %p, %p, %i, %i", D, token, data, type, format_file, line, index, flags, standards, pedantic); - /* check for a complex value -- look for the semicolon */ - for (semicolon = token; *semicolon; ++semicolon) - if (*semicolon == ';') - break; + /* try a numerical conversion */ + if (type & GD_COMPLEX) { + double re, im; - if (type & (GD_COMPLEX | GD_IEEE754)) { - /* try to convert to double */ - double i = 0; - double d = gd_strtod(token, &ptr); + i = _GD_TokToNum(token, standards, pedantic, &re, &im, NULL, NULL); - /* there were trailing characters in the double or real part of complex */ - if (ptr != semicolon) { - ptr = _GD_Strdup(D, token); + if (i == -2) { /* malformed number */ + _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, + token); + dreturn("%p", NULL); + return NULL; + } else if (i == -1) { /* assume it's a field name */ + ptr = _GD_MungeFromFrag(D, NULL, me, token, &i); if (D->error) { dreturn("%p", NULL); return NULL; @@ -145,51 +279,57 @@ goto carray_check; } - /* If there was a semicolon, try to extract the imaginary part */ - if (*semicolon == ';') { - i = gd_strtod(semicolon + 1, &ptr); + /* flag */ + if (im) + *flags |= GD_EN_COMPSCAL; - /* there were trailing characters in the imaginary part of complex -- this - * can't be a valid field name, since ; is prohibited */ - if (*ptr != '\0') { - _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, - token); - dreturn("%p", NULL); - return NULL; - } + /* store the number */ + if (type == GD_COMPLEX128) { + *(double *)data = re; + *((double *)data + 1) = im; + } else if (type == GD_COMPLEX64) { + *(float *)data = (float)re; + *((float *)data + 1) = (float)im; + } else + _GD_InternalError(D); + } else if (type & GD_IEEE754) { + double d; - /* if a complex value is not permitted, complain */ - if (i && !(type & GD_COMPLEX)) { - _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, - token); + i = _GD_TokToNum(token, standards, pedantic, &d, NULL, NULL, NULL); + + if (i == -2) { /* malformed number */ + _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, + token); + dreturn("%p", NULL); + return NULL; + } else if (i == -1) { /* assume it's a field name */ + ptr = _GD_MungeFromFrag(D, NULL, me, token, &i); + if (D->error) { dreturn("%p", NULL); return NULL; } - - if (i) - *flags |= GD_EN_COMPSCAL; + goto carray_check; } - if (type == GD_COMPLEX128) { + /* store the number */ + if (type == GD_FLOAT64) *(double *)data = d; - *((double *)data + 1) = i; - } else if (type == GD_COMPLEX64) { - *(float *)data = (float)d; - *((float *)data + 1) = (float)i; - } else if (type == GD_FLOAT64) - *(double *)data = d; else if (type == GD_FLOAT32) *(float *)data = (float)d; else _GD_InternalError(D); } else if (type & GD_SIGNED) { - /* try to convert to long long int */ - long long int lli = gd_strtoll(token, &ptr, - (!pedantic || standards >= 9) ? 0 : 10); + int64_t lli; - /* there were trailing characters in the long long int */ - if (ptr != semicolon) { - ptr = _GD_MungeFromFrag(D, NULL, me, token, &dummy); + i = _GD_TokToNum(token, standards, pedantic, NULL, NULL, NULL, &lli); + + if (i == -2) { /* malformed number */ + _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, + token); + dreturn("%p", NULL); + return NULL; + } else if (i == -1) { /* assume it's a field name */ + ptr = _GD_MungeFromFrag(D, NULL, me, token, &i); if (D->error) { dreturn("%p", NULL); return NULL; @@ -197,19 +337,6 @@ goto carray_check; } - /* if this is a complex number, a zero imaginary part is permitted */ - if (*semicolon == ';') { - long long int i = gd_strtoll(semicolon + 1, &ptr, - (!pedantic || standards >= 9) ? 0 : 10); - - if (i || *ptr != '\0') { - _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, - token); - dreturn("%p", NULL); - return NULL; - } - } - if (type == GD_INT64) *(int64_t *)data = (int64_t)lli; else if (type == GD_INT32) @@ -221,13 +348,17 @@ else _GD_InternalError(D); } else { - /* try to convert to unsigned long long int */ - unsigned long long int ulli = gd_strtoull(token, &ptr, - (!pedantic || standards >= 9) ? 0 : 10); + uint64_t ulli; - /* there were trailing characters in the unsigned long long int */ - if (ptr != semicolon) { - ptr = _GD_MungeFromFrag(D, NULL, me, token, &dummy); + i = _GD_TokToNum(token, standards, pedantic, NULL, NULL, &ulli, NULL); + + if (i == -2) { /* malformed number */ + _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, + token); + dreturn("%p", NULL); + return NULL; + } else if (i == -1) { /* assume it's a field name */ + ptr = _GD_MungeFromFrag(D, NULL, me, token, &i); if (D->error) { dreturn("%p", NULL); return NULL; @@ -235,19 +366,6 @@ goto carray_check; } - /* if this is a complex number, a zero imaginary part is permitted */ - if (*semicolon == ';') { - long long unsigned i = gd_strtoull(semicolon + 1, &ptr, - (!pedantic || standards >= 9) ? 0 : 10); - - if (i || *ptr != '\0') { - _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_LITERAL, format_file, line, - token); - dreturn("%p", NULL); - return NULL; - } - } - if (type == GD_UINT64) *(uint64_t *)data = (uint64_t)ulli; else if (type == GD_UINT32) @@ -264,15 +382,24 @@ return NULL; carray_check: - /* look for a < delimeter */ + /* look a < > delimeters */ *index = -1; - for (lt = ptr; *lt; ++lt) + for (lt = ptr; *lt; ++lt) { if (*lt == '<') { + char *endptr = NULL; + *lt = '\0'; - *index = atoi(lt + 1); - break; + *index = (int)strtol(lt + 1, &endptr, 0); + + if (*endptr != '>') { + /* invalid CARRAY index, undo the elision */ + *lt = '<'; + *index = -1; + } else + break; } - + } + dreturn("\"%s\" (%i)", ptr, *index); return ptr; } @@ -347,7 +474,7 @@ pedantic)) == NULL) { E->flags |= GD_EN_CALC; - if (E->EN(raw,spf) <= 0) + if (!D->error && E->EN(raw,spf) <= 0) _GD_SetError(D, GD_E_FORMAT, GD_E_FORMAT_BAD_SPF, format_file, line, in_cols[3]); } @@ -1075,6 +1202,7 @@ return GD_COMPLEX128; case GD_NULL: case GD_UNKNOWN: + case GD_STRING: _GD_InternalError(D); } Modified: trunk/getdata/src/sie.c =================================================================== --- trunk/getdata/src/sie.c 2014-07-19 02:16:17 UTC (rev 913) +++ trunk/getdata/src/sie.c 2014-07-25 03:17:52 UTC (rev 914) @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 D. V. Wiebe +/* Copyright (C) 2011, 2012, 2013 D. V. Wiebe * *************************************************************************** * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-19 02:16:27
|
Revision: 913 http://sourceforge.net/p/getdata/code/913 Author: ketiltrout Date: 2014-07-19 02:16:17 +0000 (Sat, 19 Jul 2014) Log Message: ----------- Too soon. Removed Paths: ------------- branches/getdata-multi/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-17 02:12:30
|
Revision: 912 http://sourceforge.net/p/getdata/code/912 Author: ketiltrout Date: 2014-07-17 02:12:26 +0000 (Thu, 17 Jul 2014) Log Message: ----------- Be less rude when running out of space in the Fortran bindings. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/doc/README.f77 trunk/getdata/doc/README.f95 Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-07-17 01:48:12 UTC (rev 911) +++ trunk/getdata/ChangeLog 2014-07-17 02:12:26 UTC (rev 912) @@ -1,4 +1,11 @@ -2014-07-16 D. V. Wiebe <ge...@ke...> svn:911 +2014-07-17 D. V. Wiebe <g et...@ke...> svn:912 + * bindings/f77/fgetdata.c (_GDF_SetDirfile): Don't abort on error, just + return -1 (optionally discarding the dirfile first). + + * bindings/f77/fgetdata.c (_GDF_Callback GDCOPN): Handle running out of + DUNs. + +2014-07-17 D. V. Wiebe <g et...@ke...> svn:911 * src/getdata.c (_GD_DoSindir): Renamed from gd_getstrdata64 and internalised. Do return_type checks, and handle num_samp = 0. * src/getdata.c (gd_getstrdata): Deleted. Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-07-17 01:48:12 UTC (rev 911) +++ trunk/getdata/NEWS 2014-07-17 02:12:26 UTC (rev 912) @@ -185,6 +185,9 @@ * PHP bindings have been added. + * F77 and F95: The bindings no longer raise SIGABRT when the dirfile space is + exhausted. Instead they simply return an invalid dirfile unit number. + * F77: Functions to add fields with named scalar parameters have been added (GDASBT GDASCL GDASCP GDASCR GDASLC GDASMX GDASPH GDASPN GDASRC GDASRW GDASSB GDASWD), but only for those field types which permit named scalars. Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2014-07-17 01:48:12 UTC (rev 911) +++ trunk/getdata/bindings/f77/fgetdata.c 2014-07-17 02:12:26 UTC (rev 912) @@ -105,11 +105,11 @@ } /* convert a new DIRFILE* into an int */ -static int _GDF_SetDirfile(DIRFILE* D) +static int _GDF_SetDirfile(DIRFILE* D, int close) { int i; - dtrace("%p", D); + dtrace("%p, %i", D); if (!f77dirfiles_initialised) _GDF_InitDirfiles(); @@ -122,9 +122,11 @@ return i; } - /* out of f77dirfiles space: complain and abort */ + /* out of f77dirfiles space: complain */ fputs("libfgetdata: DIRFILE space exhausted.", stderr); - abort(); + if (close) + gd_discard(D); + return -1; } /* delete the supplied dirfile */ @@ -207,7 +209,11 @@ dtrace("%p, %p", pdata, f77_callback); if (c != NULL && c->func != NULL) { - unit = _GDF_SetDirfile((DIRFILE*)pdata->dirfile); + unit = _GDF_SetDirfile((DIRFILE*)pdata->dirfile, 0); + if (unit < 0) { + dreturn("%i", r); + return r; + } (c->func)(&r, &unit, &pdata->suberror, pdata->line, &pdata->linenum, pdata->filename); @@ -230,7 +236,7 @@ dtrace("%p, %p, %i, %i", dirfile, dirfilename, *dirfilename_l, *flags); *dirfile = _GDF_SetDirfile(gd_open(_GDF_CString(&out, dirfilename, - *dirfilename_l), *flags)); + *dirfilename_l), *flags), 1); free(out); @@ -2535,12 +2541,14 @@ _GDF_CString(&out, dirfilename, *dirfilename_l); D = gd_cbopen(out, *flags, _GDF_Callback, (void*)&temp); - *dirfile = _GDF_SetDirfile(D); + *dirfile = _GDF_SetDirfile(D, 1); - /* save the callback */ - f77callbacks[*dirfile].func = callback; - /* and tell getdata its new location */ - gd_parser_callback(D, _GDF_Callback, f77callbacks + *dirfile); + if (*dirfile >= 0) { + /* save the callback */ + f77callbacks[*dirfile].func = callback; + /* and tell getdata its new location */ + gd_parser_callback(D, _GDF_Callback, f77callbacks + *dirfile); + } free(out); dreturn("%i", *dirfile); @@ -3466,7 +3474,7 @@ { dtrace("%p", dirfile); - *dirfile = _GDF_SetDirfile(gd_invalid_dirfile()); + *dirfile = _GDF_SetDirfile(gd_invalid_dirfile(), 1); dreturn("%i", *dirfile); } Modified: trunk/getdata/doc/README.f77 =================================================================== --- trunk/getdata/doc/README.f77 2014-07-17 01:48:12 UTC (rev 911) +++ trunk/getdata/doc/README.f77 2014-07-17 02:12:26 UTC (rev 912) @@ -17,10 +17,10 @@ dirfile unit number is used. Space is available in the compatibility library for only 1023 dirfile units. If an application attempts to open more than 1023 dirfiles simultaneously, the compatibility library will emit an error message -on standard error and raise SIGABRT. Passing an invalid dirfile unit number to -a subroutines which requires one as input (other than GDCLOS, which will simply -ignore it) will result in the call failing with error code GD_EBD -(= GD_E_BAD_DIRFILE, see below). +on standard error and return an invalid dirfile unit number. Passing an invalid +dirfile unit number to a subroutines which requires one as input (other than +GDCLOS, which will simply ignore it) will result in the call failing with error +code GD_EBD (= GD_E_BAD_DIRFILE, see below). Including getdata.f (which will be installed in the same directory as getdata.h) will define several convenient parameters including the DIRFILE flags, the data @@ -58,7 +58,8 @@ This wraps gd_open(3), with the same input arguments (dirfilename_len should contain the string length of dirfilename). It returns the dirfile unit number in dirfile_unit. The flags should be a bitwise "or"d list of flag parameters - (see below). This behaves analogously to gd_open() itself: it returns a valid + (see below). If no more dirfile unit numbers are available, it returns -1, + otherwise, this behaves analogously to gd_open() itself: it returns a valid dirfile unit even in case of error. * GDCOPN(dirfile_unit, dirfilename, dirfilename_len, flags, sehandler) @@ -117,7 +118,8 @@ INTEGER dirfile_unit This wraps gd_invalid_dirfile(3), and returns the unit number of a - newly-created, invalid dirfile. + newly-created, invalid dirfile. If no dirfile unit numbers were available, + it returns -1. * GDCLOS(dirfile_unit) Modified: trunk/getdata/doc/README.f95 =================================================================== --- trunk/getdata/doc/README.f95 2014-07-17 01:48:12 UTC (rev 911) +++ trunk/getdata/doc/README.f95 2014-07-17 02:12:26 UTC (rev 912) @@ -15,10 +15,10 @@ numbers, which are internally converted to the C API DIRFILE pointers. Space is available in the compatibility library for only 1023 dirfile units. If an application attempts to open more than 1023 dirfiles simultaneously, the -compatibility library will emit an error message on standard error and raise -SIGABRT. Passing an invalid dirfile unit number to a procedure which requires -one as input (other than fgd_close, which will simply ignore it) will -result in the call failing with error code GD_E_BAD_DIRFILE. +compatibility library will emit an error message on standard error and return +and invalid dirfile unit number. Passing an invalid dirfile unit number to a +procedure which requires one as input (other than fgd_close, which will simply +ignore it) will result in the call failing with error code GD_E_BAD_DIRFILE. The "getdata" module, which these bindings define, is described in `getdata.mod', which will be installed in the same directory as getdata.h. The This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-17 01:48:23
|
Revision: 911 http://sourceforge.net/p/getdata/code/911 Author: ketiltrout Date: 2014-07-17 01:48:12 +0000 (Thu, 17 Jul 2014) Log Message: ----------- Merge getstrdata() into getdata() via the new data type code GD_STRING. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/cxx/dirfile.cpp trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/idl/getdata.c trunk/getdata/bindings/make_parameters.c trunk/getdata/bindings/matlab/Makefile.am trunk/getdata/bindings/matlab/gd_getdata.c trunk/getdata/bindings/matlab/test/big_test.m trunk/getdata/bindings/perl/GetData.xs trunk/getdata/bindings/php/getdata.c trunk/getdata/bindings/php/test/big_test.php trunk/getdata/bindings/python/pydirfile.c trunk/getdata/configure.ac trunk/getdata/src/errors.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/legacy.c trunk/getdata/src/native.c trunk/getdata/test/Makefile.am trunk/getdata/test/native_string.c Added Paths: ----------- trunk/getdata/test/get_none.c trunk/getdata/test/get_sindir.c trunk/getdata/test/get_sindir_none.c trunk/getdata/test/get_sindir_null.c trunk/getdata/test/get_sindir_type.c trunk/getdata/test/get_type_string.c Removed Paths: ------------- trunk/getdata/bindings/matlab/gd_getstrdata.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 Property Changed: ---------------- trunk/getdata/src/ trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/ChangeLog 2014-07-17 01:48:12 UTC (rev 911) @@ -1,3 +1,32 @@ +2014-07-16 D. V. Wiebe <ge...@ke...> svn:911 + * src/getdata.c (_GD_DoSindir): Renamed from gd_getstrdata64 and + internalised. Do return_type checks, and handle num_samp = 0. + * src/getdata.c (gd_getstrdata): Deleted. + * src/getdata.h.in: Add GD_STRING. + + * src/native.c (_GD_NativeType): Return GD_STRING for string types. + + * bindings/make_parameters.c: Add GD_STRING. + + * bindings/cxx/dirfile.cpp (Dirfile::GetData) bindings/f77/fgetdata.c + (GDGSTD GDGSTP) bindings/idl/getdata.c (gdidl_getdata) + bindings/perl/GetData.xs (getdata) bindings/python/pydirfile.c + (gdpy_dirfile_getdata): Convert gd_getstrdata call to gd_getdata. + * bindings/matlab/gd_getdata.c: Handle SINDIR. + * bindings/matlab/gd_getstrdata.c: Deleted. + * bindings/php/getdata.c (gd_getdata): Handle SINDIR; made return_type + optional. + * bindings/php/getdata.c (gd_getstrdata): Deleted. + + * test/get_none.c: Added. + * test/get_sindir.c: Replaced by renaming getstr_sindir.c. + * test/get_sindir_none.c test/get_sindir_null.c: Added. + * test/get_sindir_type.c: Replaced. + * test/getstr_here.c test: Deleted. + + * configure.ac: Renamed the intermediate getdata.h file from getdata.ah to + getdata.in2. + 2014-07-16 D. V. Wiebe <ge...@ke...> svn:908 * bindings/cxx/dirfile.cpp (GetData::EncodingSupport Dirfile::ArrayLen Dirfile::GetData(..., const char** data_out) Dirfile::GetSarray Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/NEWS 2014-07-17 01:48:12 UTC (rev 911) @@ -130,7 +130,19 @@ in an I/O error, but successfully returns no data. API Changes: + + * CLARIFICATION: The macro GD_SIZE() declared in getdata.h is indeed part of + the public API. It returns the size in bytes of a sample of data of a given + type (e.g. GD_SIZE(GD_COMPLEX64) returns 8). It has been around since + GetData-0.3.0, but has only been documented since GetData-0.8.3. + * A new data type code, GD_STRING, has been declared. It is needed in + gd_getdata() calls to retrieve SINDIR data. Purely for convenience, it has + the property: GD_SIZE(GD_STRING) == sizeof(char*). + + * get_native_type() now returns GD_STRING for string type fields (STRING, + SARRAY, SINDIR). Formerly it would return GD_NULL. + * 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 Modified: trunk/getdata/bindings/cxx/dirfile.cpp =================================================================== --- trunk/getdata/bindings/cxx/dirfile.cpp 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/cxx/dirfile.cpp 2014-07-17 01:48:12 UTC (rev 911) @@ -317,8 +317,8 @@ gd_off64_t first_sample, size_t num_frames, size_t num_samples, const char** data_out) const { - return gd_getstrdata64(D, field_code, first_frame, first_sample, num_frames, - num_samples, data_out); + return gd_getdata64(D, field_code, first_frame, first_sample, num_frames, + num_samples, GD_STRING, data_out); } size_t Dirfile::GetString(const char *field_code, size_t len, char* data_out) Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/f77/fgetdata.c 2014-07-17 01:48:12 UTC (rev 911) @@ -5609,7 +5609,7 @@ dreturnvoid(); } -/* gd_getstrdata wrapper -- this only returns one sample */ +/* gd_getdata wrapper for SINDIRs -- this only returns one sample */ void F77_FUNC(gdgstd, GDGSTD) (char *value, int32_t *value_l, const int32_t *dirfile, const char *field_code, const int32_t *field_code_l, const int32_t *first_frame, const int32_t *first_sample) @@ -5621,9 +5621,9 @@ dtrace("%p, %p, %i, %p, %i, %i, %i", value, value_l, *dirfile, field_code, *field_code_l, *first_frame, *first_sample); - n_read = gd_getstrdata(_GDF_GetDirfile(*dirfile), + n_read = gd_getdata(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, *field_code_l), *first_frame, - *first_sample, 0, 1, datum); + *first_sample, 0, 1, GD_STRING, datum); free(fc); if (n_read == 0) *value_l = 0; @@ -5633,8 +5633,8 @@ dreturn("%i", *value_l); } -/* gd_getstrdata wrapper -- this returns an opaquely packed array; see also - * GDXSTP and GDDSTP */ +/* gd_getdata wrapper for SINDIRs-- this returns an opaquely packed array of + * strings; see also GDXSTP and GDDSTP */ void F77_FUNC(gdgstp, GDGSTP) (int32_t *n_read, char *data, const int32_t *dirfile, const char *field_code, const int32_t *field_code_l, const int32_t *first_frame, const int32_t *first_sample, @@ -5677,7 +5677,8 @@ return; } - *n_read = gd_getstrdata(D, fc, *first_frame, *first_sample, 0, ns, buffer); + *n_read = gd_getdata(D, fc, *first_frame, *first_sample, 0, ns, GD_STRING, + buffer); free(fc); if (*n_read == 0) { Modified: trunk/getdata/bindings/idl/getdata.c =================================================================== --- trunk/getdata/bindings/idl/getdata.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/idl/getdata.c 2014-07-17 01:48:12 UTC (rev 911) @@ -304,6 +304,7 @@ v.cmp.r = creal(dc); v.cmp.i = cimag(dc); break; + case GD_STRING: case GD_NULL: case GD_UNKNOWN: ; @@ -712,6 +713,7 @@ switch (dtype) { case GD_NULL: case GD_UNKNOWN: + case GD_STRING: break; case GD_UINT8: GDIDL_CONVERT_ENTRY_ELEMENT(*(( uint8_t*)dst), src, key, offset, stype); @@ -3679,8 +3681,8 @@ if (t == GD_SINDIR_ENTRY) { const char **data = malloc(kw.n_samples * sizeof(*data)); - n = gd_getstrdata64(D, field_code, kw.first_frame, kw.first_sample, 0, - kw.n_samples, data); + n = gd_getdata64(D, field_code, kw.first_frame, kw.first_sample, 0, + kw.n_samples, GD_STRING, data); if (n == 0) r = IDL_GettmpInt(0); Modified: trunk/getdata/bindings/make_parameters.c =================================================================== --- trunk/getdata/bindings/make_parameters.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/make_parameters.c 2014-07-17 01:48:12 UTC (rev 911) @@ -163,6 +163,7 @@ CONSTANT(FLOAT64, "GD_F64", 4), CONSTANT(COMPLEX64, "GD_C64", 4), CONSTANT(COMPLEX128, "GDC128", 4), + CONSTANT(STRING, "GD_STR", 4), CONSTANT(DEL_META, "GDD_MT", 5), CONSTANT(DEL_DATA, "GDD_DT", 5), Modified: trunk/getdata/bindings/matlab/Makefile.am =================================================================== --- trunk/getdata/bindings/matlab/Makefile.am 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/matlab/Makefile.am 2014-07-17 01:48:12 UTC (rev 911) @@ -62,7 +62,7 @@ gd_error gd_error_string gd_flags gd_flush gd_fragment_affixes \ gd_fragment_index gd_fragmentname \ gd_framenum gd_frameoffset gd_get_carray gd_get_carray_slice \ - gd_getdata gd_get_sarray gd_get_sarray_slice gd_getstrdata \ + gd_getdata gd_get_sarray gd_get_sarray_slice \ gd_get_string gd_hidden gd_hide gd_include gd_invalid_dirfile \ gd_linterp_tablename gd_madd gd_madd_alias \ gd_madd_carray gd_madd_const gd_madd_sarray \ Modified: trunk/getdata/bindings/matlab/gd_getdata.c =================================================================== --- trunk/getdata/bindings/matlab/gd_getdata.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/matlab/gd_getdata.c 2014-07-17 01:48:12 UTC (rev 911) @@ -43,7 +43,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { DIRFILE *D; - void *data; char *field_code; long long first_frame, first_samp; size_t nsamp; @@ -63,13 +62,28 @@ gdmx_err(D, 0); } - plhs[0] = gdmx_vector(type, nsamp, &data); + if (gd_entry_type(D, field_code) == GD_SINDIR_ENTRY) { + const char **data = mxMalloc(sizeof(*data) * nsamp); - gd_getdata64(D, field_code, (gd_off64_t)first_frame, (gd_off64_t)first_samp, - 0, nsamp, type, data); + nsamp = gd_getdata64(D, field_code, (gd_off64_t)first_frame, + (gd_off64_t)first_samp, 0, nsamp, GD_STRING, data); - mxFree(field_code); - gdmx_err(D, 0); + mxFree(field_code); + gdmx_err(D, 0); - gdmx_fix_vector(plhs[0], type, nsamp, data); + plhs[0] = gdmx_from_nstring_list(data, nsamp); + mxFree(data); + } else { + void *data; + + plhs[0] = gdmx_vector(type, nsamp, &data); + + nsamp = gd_getdata64(D, field_code, (gd_off64_t)first_frame, + (gd_off64_t)first_samp, 0, nsamp, type, data); + + mxFree(field_code); + gdmx_err(D, 0); + + gdmx_fix_vector(plhs[0], type, nsamp, data); + } } Deleted: trunk/getdata/bindings/matlab/gd_getstrdata.c =================================================================== --- trunk/getdata/bindings/matlab/gd_getstrdata.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/matlab/gd_getstrdata.c 2014-07-17 01:48:12 UTC (rev 911) @@ -1,65 +0,0 @@ -/* 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 "gd_matlab.h" - -/* - % GD_GETSTRDATA Retrieve string vector data - % - % V = GD_GETSTRDATA(DIRFILE,FIELD_CODE,FIRST_FRAME,FIRST_SAMP,NFRAMES,NSAMP) - % retrieves a cell array, V, of NFRAMES frames plus NSAMPLES - % samples of string data from the SINDIR vector field FIELD_CODE - % starting FIRST_SAMP samples past the start of FIRST_FRAME. - % - % The DIRFILE object should have previously been created with GD_OPEN. - % - % See the documentation on the C API function gd_getstrdata(3) in - % section 3 of the UNIX manual for more details. - % - % See also GD_PUTDATA, GD_OPEN - */ - -void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) -{ - DIRFILE *D; - const char **data; - char *field_code; - long long first_frame, first_samp; - size_t nsamp; - - GDMX_CHECK_RHS(6); - - D = gdmx_to_dirfile(prhs[0]); - field_code = gdmx_to_string(prhs, 1, 0); - first_frame = gdmx_to_llong(prhs, 2); - first_samp = gdmx_to_llong(prhs, 3); - nsamp = gdmx_to_nsamp(D, field_code, prhs, 4, 5); - - data = mxMalloc(sizeof(*data) * nsamp); - - gd_getstrdata64(D, field_code, (gd_off64_t)first_frame, - (gd_off64_t)first_samp, 0, nsamp, data); - - mxFree(field_code); - gdmx_err(D, 0); - - plhs[0] = gdmx_from_nstring_list(data, nsamp); - mxFree(data); -} Modified: trunk/getdata/bindings/matlab/test/big_test.m =================================================================== --- trunk/getdata/bindings/matlab/test/big_test.m 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/matlab/test/big_test.m 2014-07-17 01:48:12 UTC (rev 911) @@ -2275,9 +2275,9 @@ ne = ne + check_ok2(exc, 294, 2); end - % 295: gd_getstrdata + % 295: gd_getdata (SINDIR) try - d = gd_getstrdata(D, 'sindir', 0, 0, 1, 0); + d = gd_getdata(D, 'sindir', 0, 0, 1, 0); ne = ne + check_sarray(295, d, ... {'eka'; 'eka'; 'eka'; 'eka'; 'eka'; 'eka'; 'eka'; 'eka';}); catch exc Modified: trunk/getdata/bindings/perl/GetData.xs =================================================================== --- trunk/getdata/bindings/perl/GetData.xs 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/perl/GetData.xs 2014-07-17 01:48:12 UTC (rev 911) @@ -1747,8 +1747,8 @@ if (t == GD_SINDIR_ENTRY) { const char **data_out = safemalloc(sizeof(*data_out) * num_samp); - len = gdp64(gd_getstrdata)(dirfile, field_code, first_frame, first_samp, - 0, num_samp, data_out); + len = gdp64(gd_getdata)(dirfile, field_code, first_frame, first_samp, + 0, num_samp, GD_STRING, data_out); GDP_UNDEF_ON_ERROR(safefree(data_out)); Modified: trunk/getdata/bindings/php/getdata.c =================================================================== --- trunk/getdata/bindings/php/getdata.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/php/getdata.c 2014-07-17 01:48:12 UTC (rev 911) @@ -3582,13 +3582,13 @@ PHP_FUNCTION(gd_getdata) { - long first_frame, first_sample, num_frames, num_samples, data_type; + long first_frame, first_sample, num_frames, num_samples; char *field_code; int field_code_len; size_t ns; zval *zunpack = NULL; - void *data = NULL; + long data_type = GD_UNKNOWN; DIRFILE *D; zend_bool unpack; size_t n = 0; @@ -3596,7 +3596,7 @@ dtracephp(); - GDPHP_PARSED("slllll|z", &field_code, &field_code_len, &first_frame, + GDPHP_PARSED("sllll|lz", &field_code, &field_code_len, &first_frame, &first_sample, &num_frames, &num_samples, &data_type, &zunpack); unpack = gdphp_unpack(zunpack); @@ -3610,56 +3610,37 @@ } else ns = num_samples; - /* allocate a buffer */ - gdphp_validate_type(data_type, &ctx); - data = emalloc(ns * GD_SIZE(data_type)); + /* get the type, if needed */ + if (data_type == GD_UNKNOWN) + data_type = gd_native_type(D, field_code); - n = gd_getdata(D, field_code, first_frame, first_sample, 0, ns, data_type, - data); + if (gd_entry_type(D, field_code) == GD_SINDIR_ENTRY) { + const char **data = emalloc(ns * sizeof(*data)); - GDPHP_CHECK_ERROR(D); + n = gd_getdata(D, field_code, first_frame, first_sample, 0, ns, GD_STRING, + data); - gdphp_from_data(return_value, n, data_type, data, 0, unpack); - dreturn("%" PRNsize_t, n); -} + if (gd_error(D)) { + efree(data); + GDPHP_RETURN_F; + } -PHP_FUNCTION(gd_getstrdata) -{ - long first_frame, first_sample, num_frames, num_samples; - char *field_code; - int field_code_len; - size_t ns; + gdphp_to_string_array(return_value, data, n); + efree(data); + } else { + void *data; - const char **data = NULL; - DIRFILE *D; - size_t n = 0; - GDPHP_CONTEXTp(ctx,6); + /* allocate a buffer */ + gdphp_validate_type(data_type, &ctx); + data = emalloc(ns * GD_SIZE(data_type)); - dtracephp(); + n = gd_getdata(D, field_code, first_frame, first_sample, 0, ns, data_type, + data); - GDPHP_PARSED("sllll", &field_code, &field_code_len, &first_frame, - &first_sample, &num_frames, &num_samples); + GDPHP_CHECK_ERROR(D); - /* figure out how much data we have */ - if (num_frames > 0) { - unsigned spf = gd_spf(D, field_code); - if (spf == 0) - GDPHP_RETURN_F; - ns = num_frames * spf + num_samples; - } else - ns = num_samples; - - /* allocate a buffer */ - data = emalloc(ns * sizeof(*data)); - - n = gd_getstrdata(D, field_code, first_frame, first_sample, 0, ns, data); - - if (gd_error(D)) { - efree(data); - GDPHP_RETURN_F; + gdphp_from_data(return_value, n, data_type, data, 0, unpack); } - - gdphp_to_string_array(return_value, data, n); dreturn("%" PRNsize_t, n); } @@ -5224,7 +5205,6 @@ PHP_FE(gd_get_sarray, NULL) PHP_FE(gd_get_string, NULL) PHP_FE(gd_getdata, NULL) - PHP_FE(gd_getstrdata, NULL) PHP_FE(gd_hidden, NULL) PHP_FE(gd_hide, NULL) PHP_FE(gd_include, NULL) Modified: trunk/getdata/bindings/php/test/big_test.php =================================================================== --- trunk/getdata/bindings/php/test/big_test.php 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/php/test/big_test.php 2014-07-17 01:48:12 UTC (rev 911) @@ -1838,8 +1838,8 @@ 'field_type' => GD_SINDIR_ENTRY, 'fragment_index' => 0, 'in_fields' => array('in1', 'in3'))); -# 295: getstrdata -$v = gd_getstrdata($D, 'sindir', 0, 0, 1, 0); +# 295: getdata (SINDIR) +$v = gd_getdata($D, 'sindir', 0, 0, 1, 0); check_ok(295, $D); check_var(295, $v, array('eka', 'eka', 'eka', 'eka', 'eka', 'eka', 'eka', 'eka')); Modified: trunk/getdata/bindings/python/pydirfile.c =================================================================== --- trunk/getdata/bindings/python/pydirfile.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/bindings/python/pydirfile.c 2014-07-17 01:48:12 UTC (rev 911) @@ -708,18 +708,16 @@ PYGD_CHECK_ERROR(self->D, NULL); - if (!is_sindir) { - /* get return type */ - if (return_type_obj) { - return_type = (gd_type_t)PyInt_AsLong(return_type_obj); - if (PyErr_Occurred()) { - dreturn("%p", NULL); - return NULL; - } - } else { - return_type = gd_native_type(self->D, field_code); - PYGD_CHECK_ERROR(self->D, NULL); + /* get return type */ + if (return_type_obj) { + return_type = (gd_type_t)PyInt_AsLong(return_type_obj); + if (PyErr_Occurred()) { + dreturn("%p", NULL); + return NULL; } + } else { + return_type = gd_native_type(self->D, field_code); + PYGD_CHECK_ERROR(self->D, NULL); } if (num_frames_obj) { @@ -780,8 +778,8 @@ } else if (is_sindir) { const char** data = malloc(num_samples * sizeof(*data)); - ns = gd_getstrdata(self->D, field_code, first_frame, first_sample, 0, - (size_t)num_samples, data); + ns = gd_getdata(self->D, field_code, first_frame, first_sample, 0, + (size_t)num_samples, return_type, data); pyobj = PyList_New(ns); for (i = 0; i < ns; ++i) Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/configure.ac 2014-07-17 01:48:12 UTC (rev 911) @@ -1117,8 +1117,8 @@ AC_CONFIG_FILES([src/Makefile]) dnl This doubling allows us to build getdata.h as a normal AC_CONFIG_FILE, but dnl use AC_CONFIG_HEADERS to check whether it has changed. -AC_CONFIG_FILES([src/getdata.ah:src/getdata.h.in]) -AC_CONFIG_HEADERS([src/getdata.h:src/getdata.ah], [chmod a-w src/getdata.h]) +AC_CONFIG_FILES([src/getdata.h.in2:src/getdata.h.in]) +AC_CONFIG_HEADERS([src/getdata.h:src/getdata.h.in2], [chmod a-w src/getdata.h]) AC_CONFIG_FILES([src/getdata.pc]) AC_CONFIG_FILES([test/Makefile]) AC_CONFIG_FILES([util/Makefile]) Index: trunk/getdata/src =================================================================== --- trunk/getdata/src 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/src 2014-07-17 01:48:12 UTC (rev 911) Property changes on: trunk/getdata/src ___________________________________________________________________ Modified: svn:ignore ## -10,4 +10,4 ## *.lo *.la *.swp -getdata.ah +getdata.h.in2 Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/src/errors.c 2014-07-17 01:48:12 UTC (rev 911) @@ -90,7 +90,7 @@ { GD_E_BAD_CODE, GD_E_CODE_MISSING, "Field not found: {4}", 0 }, { GD_E_BAD_CODE, GD_E_CODE_INVALID, "Bad field name: {4}", 0 }, /* GD_E_BAD_TYPE: 1 = data type */ - { GD_E_BAD_TYPE, 0, "Unsupported data type: {1}", 0 }, + { GD_E_BAD_TYPE, 0, "Bad data type: {1}", 0 }, /* GD_E_RAW_IO: 2 = filename, 3 = errno */ { GD_E_RAW_IO, 0, "Error accessing {2}: ", 1 }, /* GD_E_OPEN_FRAGMENT: 1 = errno, 2 = format file, 3 = line, 4 = includefile*/ Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/src/getdata.c 2014-07-17 01:48:12 UTC (rev 911) @@ -2045,78 +2045,42 @@ 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) +/* this returns string vector data; it is called for SINDIRs instead of making + * a call to DoField */ +static size_t _GD_DoSindir(DIRFILE *D, gd_entry_t *E, off64_t first_samp, + size_t num_samp, gd_type_t return_type, 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); + dtrace("%p, %p, %lli, %" PRNsize_t ", 0x%X, %p", D, E, (long long)first_samp, + num_samp, return_type, data_out); - if (D->flags & GD_INVALID) { - _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + /* Check input fields */ + if (_GD_BadInput(D, E, 0, GD_NO_ENTRY, 1)) { 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); + if (_GD_BadInput(D, E, 1, GD_SARRAY_ENTRY, 1)) { 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); + /* check return type */ + if (return_type != GD_STRING && return_type != GD_NULL) { + _GD_SetError(D, GD_E_BAD_TYPE, return_type, NULL, 0, NULL); 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); + /* short circuit: no data requested */ + if (num_samp == 0) { 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) { @@ -2134,6 +2098,12 @@ return 0; } + if (return_type == GD_NULL) { + free(ibuf); + dreturn("%" PRNsize_t, n_read); + return n_read; + } + len = #if SIZEOF_SIZE_T == 8 (E->e->entry[1]->EN(scalar,array_len) > GD_INT64_MAX) ? GD_INT64_MAX : @@ -2185,8 +2155,6 @@ 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); @@ -2220,21 +2188,18 @@ return 0; } - n_read = _GD_DoField(D, entry, repr, first_samp, num_samp, return_type, - data_out); + if (entry->field_type == GD_SINDIR_ENTRY) + n_read = _GD_DoSindir(D, entry, first_samp, num_samp, return_type, + data_out); + else + n_read = _GD_DoField(D, entry, repr, first_samp, num_samp, return_type, + data_out); dreturn("%" PRNsize_t, n_read); return n_read; } /* 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-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/src/getdata.h.in 2014-07-17 01:48:12 UTC (rev 911) @@ -296,6 +296,7 @@ #define GD_SIGNED 0x020 #define GD_IEEE754 0x080 #define GD_COMPLEX 0x100 +#define GD_CHAR 0x200 typedef enum { GD_NULL = 0, @@ -311,8 +312,11 @@ GD_FLOAT32 = GD_SIZE32 | GD_IEEE754, GD_FLOAT64 = GD_SIZE64 | GD_IEEE754, GD_COMPLEX64 = GD_SIZE64 | GD_COMPLEX, - GD_COMPLEX128 = GD_SIZE128 | GD_COMPLEX + GD_COMPLEX128 = GD_SIZE128 | GD_COMPLEX, + GD_STRING = (sizeof(char*)) | GD_CHAR } gd_type_t; + + /* deprecated type aliases */ #define GD_FLOAT GD_FLOAT32 #define GD_DOUBLE GD_FLOAT64 @@ -1065,10 +1069,6 @@ 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) @@ -1117,11 +1117,6 @@ 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), @@ -1143,7 +1138,6 @@ # 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 @@ -1176,10 +1170,6 @@ 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/legacy.c =================================================================== --- trunk/getdata/src/legacy.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/src/legacy.c 2014-07-17 01:48:12 UTC (rev 911) @@ -49,7 +49,7 @@ NULL, /* GD_E_TRUNC */ NULL, /* GD_E_CREAT */ "Bad field code", /* GD_E_BAD_CODE */ - "Unrecognized data type", /* GD_E_BAD_TYPE */ + "Bad data type", /* GD_E_BAD_TYPE */ "I/O error accessing field file", /* GD_E_RAW_IO */ "Could not open fragment", /* GD_E_OPEN_FRAGMENT */ "Internal error", /* GD_E_INTERNAL_ERROR */ Modified: trunk/getdata/src/native.c =================================================================== --- trunk/getdata/src/native.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/src/native.c 2014-07-17 01:48:12 UTC (rev 911) @@ -135,7 +135,7 @@ case GD_STRING_ENTRY: case GD_SARRAY_ENTRY: case GD_SINDIR_ENTRY: - type = GD_NULL; + type = GD_STRING; break; case GD_NO_ENTRY: case GD_ALIAS_ENTRY: Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/test 2014-07-17 01:48:12 UTC (rev 911) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -538,6 +538,7 ## get_multiply_rcin get_multiply_s get_neg +get_none get_nonexistent get_null get_off64 ## -556,9 +557,13 ## get_sbit get_sf get_sindir +get_sindir_none +get_sindir_null +get_sindir_type get_ss get_string get_type +get_type_string get_uint16 get_uint32 get_uint64 ## -575,9 +580,6 ## get_zero get_zero_complex get_zero_float -getstr_here -getstr_sindir -getstr_type global_flags global_name global_ref Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/test/Makefile.am 2014-07-17 01:48:12 UTC (rev 911) @@ -203,18 +203,17 @@ get_mplex_bof get_mplex_complex get_mplex_lb get_mplex_lball \ get_mplex_nolb get_mplex_s get_mplex_saved get_multiply \ get_multiply_ccin get_multiply_crin get_multiply_crinr \ - get_multiply_noin get_multiply_rcin get_multiply_s get_neg \ + get_multiply_noin get_multiply_rcin get_multiply_s get_neg get_none \ get_nonexistent get_null get_off64 get_phase get_phase_affix \ get_polynom get_polynom_cmpin get_polynom_noin get_recip \ get_recip_const get_recurse get_rofs get_sarray get_sarray_len \ - get_sarray_slice get_sbit get_sf get_sindir get_ss get_string \ - get_type get_uint16 get_uint32 get_uint64 get_window get_window_clr \ - get_window_complex get_window_ge get_window_gt get_window_le \ - get_window_lt get_window_ne get_window_s get_window_set get_zero \ - get_zero_complex get_zero_float + get_sarray_slice get_sbit get_sf get_sindir get_sindir_none \ + get_sindir_null get_sindir_type get_ss get_string \ + get_type get_type_string get_uint16 get_uint32 get_uint64 get_window \ + get_window_clr get_window_complex get_window_ge get_window_gt \ + get_window_le get_window_lt get_window_ne get_window_s \ + get_window_set get_zero get_zero_complex get_zero_float -GETSTR_TESTS=getstr_here getstr_sindir getstr_type - GLOBAL_TESTS=global_flags global_name global_ref global_ref_empty global_ref_set GZIP_TESTS=gzip_add gzip_del gzip_get gzip_get_far gzip_get_get gzip_get_get2 \ @@ -410,16 +409,16 @@ $(DESYNC_TESTS) $(ELIST_TESTS) $(ENCODE_TESTS) $(ENDIAN_TESTS) \ $(ENTRY_TESTS) $(EOF_TESTS) $(ERROR_TESTS) $(FILE_TESTS) \ $(FLIST_TESTS) $(FLUSH_TESTS) $(FOFFS_TESTS) $(FRAGMENT_TESTS) \ - $(GET_TESTS) $(GETSTR_TESTS) $(GLOBAL_TESTS) $(GZIP_TESTS) \ - $(HEADER_TESTS) $(HIDE_TESTS) $(INCLUDE_TESTS) $(INDEX_TESTS) \ - $(LEGACY_TESTS) $(LZMA_TESTS) $(MADD_TESTS) $(MOVE_TESTS) \ - $(NAME_TESTS) $(NATIVE_TESTS) $(NENTRIES_TESTS) $(NFIELDS_TESTS) \ - $(NFRAMES_TESTS) $(NMETA_TESTS) $(OPEN_TESTS) $(PARSE_TESTS) \ - $(PROTECT_TESTS) $(PUT_TESTS) $(REF_TESTS) $(REPR_TESTS) \ - $(SEEK_TESTS) $(SIE_TESTS) $(SLIM_TESTS) $(SPF_TESTS) \ - $(SVLIST_TESTS) $(TABLE_TESTS) $(TELL_TESTS) $(TOK_TESTS) \ - $(TRUNC_TESTS) $(UNCLUDE_TESTS) $(VERSION_TESTS) $(VLIST_TESTS) \ - $(ZZIP_TESTS) $(ZZSLIM_TESTS) + $(GET_TESTS) $(GLOBAL_TESTS) $(GZIP_TESTS) $(HEADER_TESTS) \ + $(HIDE_TESTS) $(INCLUDE_TESTS) $(INDEX_TESTS) $(LEGACY_TESTS) \ + $(LZMA_TESTS) $(MADD_TESTS) $(MOVE_TESTS) $(NAME_TESTS) \ + $(NATIVE_TESTS) $(NENTRIES_TESTS) $(NFIELDS_TESTS) $(NFRAMES_TESTS) \ + $(NMETA_TESTS) $(OPEN_TESTS) $(PARSE_TESTS) $(PROTECT_TESTS) \ + $(PUT_TESTS) $(REF_TESTS) $(REPR_TESTS) $(SEEK_TESTS) \ + $(SIE_TESTS) $(SLIM_TESTS) $(SPF_TESTS) $(SVLIST_TESTS) \ + $(TABLE_TESTS) $(TELL_TESTS) $(TOK_TESTS) $(TRUNC_TESTS) \ + $(UNCLUDE_TESTS) $(VERSION_TESTS) $(VLIST_TESTS) $(ZZIP_TESTS) \ + $(ZZSLIM_TESTS) check_PROGRAMS=$(TESTS) Added: trunk/getdata/test/get_none.c =================================================================== --- trunk/getdata/test/get_none.c (rev 0) +++ trunk/getdata/test/get_none.c 2014-07-17 01:48:12 UTC (rev 911) @@ -0,0 +1,68 @@ +/* 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 <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 *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n"; + unsigned char data_data[256]; + int fd, n, error, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 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(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_getdata(D, "data", 5, 0, 0, 0, GD_UINT8, NULL); + error = gd_error(D); + + gd_discard(D); + + unlink(data); + unlink(format); + rmdir(filedir); + + CHECKI(error, 0); + CHECKI(n, 0); + + return r; +} Deleted: trunk/getdata/test/get_sindir.c =================================================================== --- trunk/getdata/test/get_sindir.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/test/get_sindir.c 2014-07-17 01:48:12 UTC (rev 911) @@ -1,69 +0,0 @@ -/* 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 *data = "dirfile/data"; - const char *format_data = - "sindir SINDIR data sarray\n" - "sarray SARRAY a b c d e f g h i j k l m n o p q r s t u v w x y z\n" - "data RAW UINT8 8\n"; - int32_t c[8]; - unsigned char data_data[256]; - int fd, n, error, r = 0; - DIRFILE *D; - - rmdirfile(); - mkdir(filedir, 0777); - - for (fd = 0; fd < 256; ++fd) - data_data[fd] = (unsigned char)(fd + 2); - - fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); - write(fd, format_data, strlen(format_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); - n = gd_getdata(D, "sindir", 1, 0, 1, 0, GD_INT32, &c); - error = gd_error(D); - - CHECKI(error, GD_E_BAD_FIELD_TYPE); - CHECKI(n, 0); - - gd_discard(D); - - unlink(data); - unlink(format); - rmdir(filedir); - - return r; -} Copied: trunk/getdata/test/get_sindir.c (from rev 910, trunk/getdata/test/getstr_sindir.c) =================================================================== --- trunk/getdata/test/get_sindir.c (rev 0) +++ trunk/getdata/test/get_sindir.c 2014-07-17 01:48:12 UTC (rev 911) @@ -0,0 +1,77 @@ +/* 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 *data = "dirfile/data"; + const char *format_data = + "sindir SINDIR data sarray\n" + "sarray SARRAY a b c d e f g h i j k l m n o\n" + "data RAW UINT8 8\n"; + const char *c[8]; + unsigned char data_data[256]; + int fd, i, n, error, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_data[fd] = (unsigned char)(fd + 2); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_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); + n = gd_getdata(D, "sindir", 1, 0, 1, 0, GD_STRING, c); + error = gd_error(D); + + CHECKI(error, 0); + CHECKI(n, 8); + for (i = 0; i < 8; ++i) { + if (i < 5) { + CHECKPNi(i, c[i]); + CHECKXi(i, c[i][0], 'k' + i); + } else { + CHECKPi(i, c[i]); + } + } + + gd_discard(D); + + unlink(data); + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/get_sindir_none.c =================================================================== --- trunk/getdata/test/get_sindir_none.c (rev 0) +++ trunk/getdata/test/get_sindir_none.c 2014-07-17 01:48:12 UTC (rev 911) @@ -0,0 +1,68 @@ +/* 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 *data = "dirfile/data"; + const char *format_data = + "sindir SINDIR data sarray\n" + "sarray SARRAY a b c d e f g h i j k l m n o\n" + "data RAW UINT8 8\n"; + unsigned char data_data[256]; + int fd, n, error, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_data[fd] = (unsigned char)(fd + 2); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_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); + n = gd_getdata(D, "sindir", 1, 0, 0, 0, GD_STRING, NULL); + error = gd_error(D); + + CHECKI(error, 0); + CHECKI(n, 0); + + gd_discard(D); + + unlink(data); + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/get_sindir_null.c =================================================================== --- trunk/getdata/test/get_sindir_null.c (rev 0) +++ trunk/getdata/test/get_sindir_null.c 2014-07-17 01:48:12 UTC (rev 911) @@ -0,0 +1,68 @@ +/* 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 *data = "dirfile/data"; + const char *format_data = + "sindir SINDIR data sarray\n" + "sarray SARRAY a b c d e f g h i j k l m n o\n" + "data RAW UINT8 8\n"; + unsigned char data_data[256]; + int fd, n, error, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_data[fd] = (unsigned char)(fd + 2); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_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); + n = gd_getdata(D, "sindir", 1, 0, 1, 0, GD_NULL, NULL); + error = gd_error(D); + + CHECKI(error, 0); + CHECKI(n, 8); + + gd_discard(D); + + unlink(data); + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/get_sindir_type.c =================================================================== --- trunk/getdata/test/get_sindir_type.c (rev 0) +++ trunk/getdata/test/get_sindir_type.c 2014-07-17 01:48:12 UTC (rev 911) @@ -0,0 +1,69 @@ +/* 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 *data = "dirfile/data"; + const char *format_data = + "sindir SINDIR data sarray\n" + "sarray SARRAY a b c d e f g h i j k l m n o\n" + "data RAW UINT8 8\n"; + const char *c[8]; + unsigned char data_data[256]; + int fd, i, n, error, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_data[fd] = (unsigned char)(fd + 2); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_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); + n = gd_getdata(D, "sindir", 1, 0, 1, 0, GD_INT64, c); + error = gd_error(D); + + CHECKI(error, GD_E_BAD_TYPE); + CHECKI(n, 0); + + gd_discard(D); + + unlink(data); + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/get_type_string.c =================================================================== --- trunk/getdata/test/get_type_string.c (rev 0) +++ trunk/getdata/test/get_type_string.c 2014-07-17 01:48:12 UTC (rev 911) @@ -0,0 +1,71 @@ +/* Copyright (C) 2008-2011, 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 *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n"; + unsigned char c[8]; + unsigned char data_data[256]; + int fd, n, error, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 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(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256); + close(fd); + + D = gd_open(filedir, GD_RDONLY); + n = gd_getdata(D, "data", 5, 0, 1, 0, GD_STRING, c); + + error = gd_error(D); + + gd_discard(D); + + unlink(data); + unlink(format); + rmdir(filedir); + + CHECKI(n, 0); + CHECKI(error, GD_E_BAD_TYPE); + + return r; +} Deleted: trunk/getdata/test/getstr_here.c =================================================================== --- trunk/getdata/test/getstr_here.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/test/getstr_here.c 2014-07-17 01:48:12 UTC (rev 911) @@ -1,75 +0,0 @@ -/* Copyright (C) 2008-2011, 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 <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -int main(void) -{ - const char *filedir = "dirfile"; - const char *format = "dirfile/format"; - const char *data = "dirfile/data"; - const char *format_data = - "sindir SINDIR data sarray\n" - "sarray SARRAY a b c d e f g h i j k l m n o p\n" - "data RAW UINT8 8\n"; - const char *d[8]; - const char *val[8] = {"i", "j", "k", "l", "m", "n", "o", "p"}; - unsigned char data_data[256]; - int fd, i, m, n, error, r = 0; - DIRFILE *D; - - rmdirfile(); - mkdir(filedir, 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(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, "sindir", 1, 0, GD_SEEK_SET); - CHECKI(m, 8); - - n = gd_getstrdata(D, "sindir", GD_HERE, 0, 0, 8, d); - error = gd_error(D); - CHECKI(error, 0); - CHECKI(n, 8); - - for (i = 0; i < 8; ++i) - CHECKSi(i, d[i], val[i]); - - gd_discard(D); - - unlink(data); - unlink(format); - rmdir(filedir); - - return r; -} Deleted: trunk/getdata/test/getstr_sindir.c =================================================================== --- trunk/getdata/test/getstr_sindir.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/test/getstr_sindir.c 2014-07-17 01:48:12 UTC (rev 911) @@ -1,77 +0,0 @@ -/* 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 *data = "dirfile/data"; - const char *format_data = - "sindir SINDIR data sarray\n" - "sarray SARRAY a b c d e f g h i j k l m n o\n" - "data RAW UINT8 8\n"; - const char *c[8]; - unsigned char data_data[256]; - int fd, i, n, error, r = 0; - DIRFILE *D; - - rmdirfile(); - mkdir(filedir, 0777); - - for (fd = 0; fd < 256; ++fd) - data_data[fd] = (unsigned char)(fd + 2); - - fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); - write(fd, format_data, strlen(format_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); - n = gd_getstrdata(D, "sindir", 1, 0, 1, 0, c); - error = gd_error(D); - - CHECKI(error, 0); - CHECKI(n, 8); - for (i = 0; i < 8; ++i) { - if (i < 5) { - CHECKPNi(i, c[i]); - CHECKXi(i, c[i][0], 'k' + i); - } else { - CHECKPi(i, c[i]); - } - } - - gd_discard(D); - - unlink(data); - unlink(format); - rmdir(filedir); - - return r; -} Deleted: trunk/getdata/test/getstr_type.c =================================================================== --- trunk/getdata/test/getstr_type.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/test/getstr_type.c 2014-07-17 01:48:12 UTC (rev 911) @@ -1,66 +0,0 @@ -/* 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 *data = "dirfile/data"; - const char *format_data = "data RAW UINT8 8\n"; - const char *c[8]; - unsigned char data_data[256]; - int fd, n, error, r = 0; - DIRFILE *D; - - rmdirfile(); - mkdir(filedir, 0777); - - for (fd = 0; fd < 256; ++fd) - data_data[fd] = (unsigned char)(fd + 2); - - fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); - write(fd, format_data, strlen(format_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); - n = gd_getstrdata(D, "data", 1, 0, 1, 0, c); - error = gd_error(D); - - CHECKI(error, GD_E_BAD_FIELD_TYPE); - CHECKI(n, 0); - - gd_discard(D); - - unlink(data); - unlink(format); - rmdir(filedir); - - return r; -} Modified: trunk/getdata/test/native_string.c =================================================================== --- trunk/getdata/test/native_string.c 2014-07-16 22:59:53 UTC (rev 910) +++ trunk/getdata/test/native_string.c 2014-07-17 01:48:12 UTC (rev 911) @@ -40,7 +40,7 @@ type = gd_native_type(D, "string"); error = gd_error(D); - CHECKU(type, GD_NULL); + CHECKU(type, GD_STRING); CHECKI(error, 0); gd_discard(D); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-16 22:59:54
|
Revision: 910 http://sourceforge.net/p/getdata/code/910 Author: ketiltrout Date: 2014-07-16 22:59:53 +0000 (Wed, 16 Jul 2014) Log Message: ----------- Branch from trunk. Added Paths: ----------- branches/getdata-multi/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-07-16 02:11:58
|
Revision: 909 http://sourceforge.net/p/getdata/code/909 Author: ketiltrout Date: 2014-07-16 02:11:54 +0000 (Wed, 16 Jul 2014) Log Message: ----------- Bindings for INDIR, SINDIR, SARRAY, gd_getstrdata, gd_encoding_support. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/cxx/Makefile.am trunk/getdata/bindings/cxx/dirfile.cpp trunk/getdata/bindings/cxx/entry.cpp trunk/getdata/bindings/cxx/getdata/dirfile.h trunk/getdata/bindings/cxx/getdata/entry.h trunk/getdata/bindings/cxx/internal.h trunk/getdata/bindings/cxx/test/big_test.cpp trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/f77/fgetdata.h trunk/getdata/bindings/f77/getdata.f.in trunk/getdata/bindings/f77/getdata.f90.in 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/make_parameters.c trunk/getdata/bindings/matlab/Makefile.am trunk/getdata/bindings/matlab/gd_add_carray.c trunk/getdata/bindings/matlab/gd_add_const.c trunk/getdata/bindings/matlab/gd_get_carray.c trunk/getdata/bindings/matlab/gd_madd_carray.c trunk/getdata/bindings/matlab/gd_madd_const.c trunk/getdata/bindings/matlab/gd_matlab.h trunk/getdata/bindings/matlab/gd_put_carray.m trunk/getdata/bindings/matlab/gd_put_carray_slice.c trunk/getdata/bindings/matlab/gd_putdata.c trunk/getdata/bindings/matlab/matlab.c trunk/getdata/bindings/matlab/test/big_test.m trunk/getdata/bindings/perl/GetData.xs trunk/getdata/bindings/perl/simple_funcs.xsin trunk/getdata/bindings/perl/t/big_test.t trunk/getdata/bindings/perl/typemap trunk/getdata/bindings/php/getdata.c trunk/getdata/bindings/php/test/big_test.php trunk/getdata/bindings/python/Makefile.am trunk/getdata/bindings/python/pydirfile.c trunk/getdata/bindings/python/pyentry.c trunk/getdata/bindings/python/pygetdata.c trunk/getdata/bindings/python/test/big_test.py trunk/getdata/doc/README.php trunk/getdata/doc/list.tests trunk/getdata/man/dirfile-encoding.5 trunk/getdata/man/gd_encoding_support.3 trunk/getdata/man/gd_getdata.3 trunk/getdata/src/field_list.c trunk/getdata/src/internal.h trunk/getdata/src/string.c Added Paths: ----------- trunk/getdata/bindings/cxx/getdata/indirentry.h trunk/getdata/bindings/cxx/getdata/sarrayentry.h trunk/getdata/bindings/cxx/getdata/sindirentry.h trunk/getdata/bindings/cxx/indirentry.cpp trunk/getdata/bindings/cxx/sarrayentry.cpp trunk/getdata/bindings/cxx/sindirentry.cpp trunk/getdata/bindings/matlab/gd_add_indir.m trunk/getdata/bindings/matlab/gd_add_sarray.c trunk/getdata/bindings/matlab/gd_add_sindir.m trunk/getdata/bindings/matlab/gd_alter_indir.m trunk/getdata/bindings/matlab/gd_alter_sarray.m trunk/getdata/bindings/matlab/gd_alter_sindir.m trunk/getdata/bindings/matlab/gd_array_len.c trunk/getdata/bindings/matlab/gd_carray_len.m trunk/getdata/bindings/matlab/gd_encoding_support.c trunk/getdata/bindings/matlab/gd_get_sarray.c trunk/getdata/bindings/matlab/gd_get_sarray_slice.c trunk/getdata/bindings/matlab/gd_getstrdata.c trunk/getdata/bindings/matlab/gd_madd_indir.m trunk/getdata/bindings/matlab/gd_madd_sarray.c trunk/getdata/bindings/matlab/gd_madd_sindir.m trunk/getdata/bindings/matlab/gd_msarrays.c trunk/getdata/bindings/matlab/gd_put_sarray.m trunk/getdata/bindings/matlab/gd_put_sarray_slice.c trunk/getdata/bindings/matlab/gd_sarrays.c Removed Paths: ------------- trunk/getdata/bindings/cxx/indexentry.cpp trunk/getdata/bindings/matlab/gd_carray_len.c Property Changed: ---------------- trunk/getdata/bindings/matlab/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/ChangeLog 2014-07-16 02:11:54 UTC (rev 909) @@ -1,3 +1,69 @@ +2014-07-16 D. V. Wiebe <ge...@ke...> svn:908 + * bindings/cxx/dirfile.cpp (GetData::EncodingSupport Dirfile::ArrayLen + Dirfile::GetData(..., const char** data_out) Dirfile::GetSarray + Dirfile::Sarrays Dirfile::MSarrays Dirfile::PutSarray): Added. + * bindings/cxx/getdata/sindirentry.h bindings/cxx/getdata/indirentry.h + bindings/cxx/getdata/sarrayentry.h bindings/cxx/indirentry.cpp + bindings/cxx/sarrayentry.cpp bindings/cxx/sindirentry.cpp + + * bindings/cxx/indexentry.cpp: Deleted. + + * bindings/f77/fgetdata.c (_GDF_GetEntryYoke GDGEID GDGESD GDGESA GDADID + GDADSD GDMDID GDMDSD GDADSA GDMDSA GDALID GDALSD GDENCS GDSARX GDMSAX GDARLN + GDGTSA GDPTSA GDALSA GDGSTD GDGSTP GDXSTP GDDSTP): Added. + * bindings/f77/getdata.f90.in (fgd_array_len fgd_encoding_support + fgd_sarray_value_max fgd_msarray_value_max fgd_get_sarray + fgd_get_sarray_slice fgd_put_sarray fgd_put_sarray_slice fgd_add_sarray + fgd_madd_sarray fgd_alter_sarray fgd_add_indir fgd_add_sindir fgd_madd_indir + fgd_madd_sindir fgd_alter_indir fgd_alter_sindir fgd_getstrdata): Added. + + * bindings/idl/getdata.c (gdidl_add_yoke_ gdidl_alter_yoke_ + gdidl_encoding_support gdidl_add_sarray gdidl_get_sarray gdidl_alter_sarray + gdidl_put_sarray gdidl_add_indir gdidl_alter_indir gdidl_add_sindir + gdidl_alter_sindir): Added. + * bindings/idl/getdata.c (gdidl_array_len): Renamed from gdidl_carray_len. + * bindings/idl/getdata.c (gdidl_getdata): Support gd_getstrdata, too. + + * bindings/matlab/gd_add_indir.m bindings/matlab/gd_add_sarray.c + bindings/matlab/gd_add_sindir.m bindings/matlab/gd_alter_indir.m + bindings/matlab/gd_alter_sarray.m bindings/matlab/gd_alter_sindir.m + bindings/matlab/gd_carray_len.m bindings/matlab/gd_encoding_support.c + bindings/matlab/gd_get_sarray.c bindings/matlab/gd_get_sarray_slice.c + bindings/matlab/gd_getstrdata.c bindings/matlab/gd_madd_indir.m + bindings/matlab/gd_madd_sarray.c bindings/matlab/gd_madd_sindir.m + bindings/matlab/gd_msarrays.c bindings/matlab/gd_put_sarray.m + bindings/matlab/gd_put_sarray_slice.c bindings/matlab/gd_sarrays.c: Added. + * bindings/matlab/gd_array_len.c: Renamed from gd_carray_len.c. + * bindings/matlab/matlab.c (gdmx_from_sarrays gdmx_to_sdata + gdmx_free_sdata): Added. + + * bindings/perl/GetData.xs (gdp_convert_const_avpv gdp_convert_strarr + gdp_newRVavpv0 array_len get_sarray get_sarray_slice sarrays put_sarray + put_sarray_slice add_sarray madd_sarray msarrays): Added. + * bindings/perl/simple_funcs.xsin (array_len alter_sarray add_indir + add_sindir alter_indir alter_sindir madd_indir madd_sindir): Added. + + * bindings/php/getdata.c (gdphp_convert_sarray gdphp_convert_nsarray + gd_add_sarray gd_add_indir gd_add_sindir gd_alter_sarray gd_alter_indir + gd_alter_sindir gd_array_len gd_sarrays gd_get_sarray gd_getstrdata + gd_madd_sarray gd_madd_indir gd_madd_sindir gd_msarrays gd_put_sarray + gd_encoding_support): Added. + + * bindings/python/pydirfile.c (gdpy_dirfile_getsarray gdpy_dirfile_arraylen + gdpy_dirfile_sarrays gdpy_dirfile_msarrays gdpy_dirfile_putsarray): Added. + * bindings/python/pyentry.c: Handle SARRAY, INDIR, SINDIR + * bindings/python/pygetdata.c (gdpy_encoding_support): Added. + + * 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/matlab/test/big_test.m bindings/perl/t/big_test.t + bindings/php/test/big_test.php bindings/python/test/big_test.py: Added tests + 271 through 298. + + * src/field_list.c (_GD_EntryIndex): Handle SARRAY, INDIR, SINDIR + + * gd_get_sarray_slice (gd_get_sarray_slice): Fix return for GD_INVALID. + 2014-05-27 D. V. Wiebe <ge...@ke...> svn:907 * src/constant.c (gd_array_len): Added. * src/constant.c (gd_carray_len): Replaced with a gd_array_len() call and Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/NEWS 2014-07-16 02:11:54 UTC (rev 909) @@ -34,7 +34,7 @@ number of problems with reading LZMA files has been fixed, which should result in fewer segmentaion faults. - * BUG FIX: The parsing of the \x and \u escape sequences are now correct. + * BUG FIX: The parsing of the \x and \u escape sequences is now correct. * BUG FIX: Computation of LINCOMs with complex valued input fields now correctly happens in the complex plane. As a side effect, gd_native_type() @@ -50,9 +50,9 @@ codes containing subfields of the renamed field are now also updated, 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 - later. + * BUG FIX: The gd_[m]add() functions now ignore zero-length scalar strings + (i.e., they treat them as if they were NULL). Previously they would store + these invalid field codes, causing problems later. * BUG FIX: Returning complex-valued CARRAYs as purely real data now works. Previously only the first element requested would be returned, the remaining Modified: trunk/getdata/bindings/cxx/Makefile.am =================================================================== --- trunk/getdata/bindings/cxx/Makefile.am 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/Makefile.am 2014-07-16 02:11:54 UTC (rev 909) @@ -34,16 +34,19 @@ getdata/sbitentry.h getdata/polynomentry.h \ getdata/fragment.h getdata/divideentry.h \ getdata/recipentry.h getdata/carrayentry.h \ - getdata/windowentry.h getdata/mplexentry.h + getdata/windowentry.h getdata/mplexentry.h \ + getdata/sarrayentry.h getdata/indirentry.h \ + getdata/sindirentry.h lib_LTLIBRARIES=libgetdata++.la libgetdata___la_SOURCES = dirfile.cpp bitentry.cpp carrayentry.cpp \ constentry.cpp divideentry.cpp entry.cpp \ - fragment.cpp indexentry.cpp lincomentry.cpp \ + fragment.cpp indirentry.cpp lincomentry.cpp \ linterpentry.cpp mplexentry.cpp multiplyentry.cpp \ phaseentry.cpp polynomentry.cpp rawentry.cpp \ - recipentry.cpp sbitentry.cpp stringentry.cpp \ - windowentry.cpp ${getdata_include_HEADERS} internal.h + recipentry.cpp sarrayentry.cpp sbitentry.cpp \ + sindirentry.cpp stringentry.cpp windowentry.cpp + ${getdata_include_HEADERS} internal.h libgetdata___la_LIBADD=../../src/libgetdata.la libgetdata___la_LDFLAGS = -version-info @GETDATAXX_VERSION@ Modified: trunk/getdata/bindings/cxx/dirfile.cpp =================================================================== --- trunk/getdata/bindings/cxx/dirfile.cpp 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/dirfile.cpp 2014-07-16 02:11:54 UTC (rev 909) @@ -20,6 +20,12 @@ // #include "internal.h" +// This is not part of the Dirfile class, but it's convenient to put it here +int GetData::EncodingSupport(unsigned long encoding) +{ + return gd_encoding_support(encoding); +} + Dirfile::Dirfile() { D = gd_invalid_dirfile(); @@ -105,12 +111,18 @@ return new GetData::CarrayEntry(this, field_code); case StringEntryType: return new GetData::StringEntry(this, field_code); + case SarrayEntryType: + return new GetData::SarrayEntry(this, field_code); case IndexEntryType: return new GetData::IndexEntry(this, field_code); case WindowEntryType: return new GetData::WindowEntry(this, field_code); case MplexEntryType: return new GetData::MplexEntry(this, field_code); + case IndirEntryType: + return new GetData::IndirEntry(this, field_code); + case SindirEntryType: + return new GetData::SindirEntry(this, field_code); case NoEntryType: break; } @@ -198,9 +210,14 @@ return gd_carrays(D, (gd_type_t)type); } +size_t Dirfile::ArrayLen(const char *field_code) const +{ + return gd_array_len(D, field_code); +} + size_t Dirfile::CarrayLen(const char *field_code) const { - return gd_carray_len(D, field_code); + return ArrayLen(field_code); } const void *Dirfile::Constants(DataType type) const @@ -296,6 +313,14 @@ num_samples, (gd_type_t)type, data_out); } +size_t Dirfile::GetData(const char* field_code, gd_off64_t first_frame, + gd_off64_t first_sample, size_t num_frames, size_t num_samples, + const char** data_out) const +{ + return gd_getstrdata64(D, field_code, first_frame, first_sample, num_frames, + num_samples, data_out); +} + size_t Dirfile::GetString(const char *field_code, size_t len, char* data_out) const { @@ -566,3 +591,31 @@ { return gd_linterp_tablename(D, field_code); } + +int Dirfile::GetSarray(const char *field_code, const char **data_out, + unsigned int start, size_t len) const +{ + if (len == 0) + return gd_get_sarray(D, field_code, data_out); + else + return gd_get_sarray_slice(D, field_code, start, len, data_out); +} + +const char*** Dirfile::Sarrays() const +{ + return gd_sarrays(D); +} + +const char*** Dirfile::MSarrays(const char* parent) const +{ + return gd_msarrays(D, parent); +} + +int Dirfile::PutSarray(const char *field_code, const char **data_in, + unsigned int start, size_t len) const +{ + if (len == 0) + return gd_put_sarray(D, field_code, data_in); + else + return gd_put_sarray_slice(D, field_code, start, len, data_in); +} Modified: trunk/getdata/bindings/cxx/entry.cpp =================================================================== --- trunk/getdata/bindings/cxx/entry.cpp 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/entry.cpp 2014-07-16 02:11:54 UTC (rev 909) @@ -50,6 +50,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: @@ -60,6 +61,8 @@ break; case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: case GD_WINDOW_ENTRY: case GD_MPLEX_ENTRY: if (index > 2) @@ -182,9 +185,12 @@ case GD_LINTERP_ENTRY: case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: + case GD_INDIR_ENTRY: + case GD_SINDIR_ENTRY: 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: Modified: trunk/getdata/bindings/cxx/getdata/dirfile.h =================================================================== --- trunk/getdata/bindings/cxx/getdata/dirfile.h 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/getdata/dirfile.h 2014-07-16 02:11:54 UTC (rev 909) @@ -53,17 +53,22 @@ #include <getdata/constentry.h> #include <getdata/carrayentry.h> #include <getdata/stringentry.h> +#include <getdata/sarrayentry.h> #include <getdata/mplexentry.h> #include <getdata/multiplyentry.h> #include <getdata/divideentry.h> #include <getdata/recipentry.h> #include <getdata/windowentry.h> +#include <getdata/indirentry.h> +#include <getdata/sindirentry.h> namespace GetData { class Entry; class RawEntry; + int EncodingSupport(unsigned long encoding); + class Dirfile { friend class Entry; friend class RawEntry; @@ -78,8 +83,11 @@ friend class PolynomEntry; friend class WindowEntry; friend class MplexEntry; + friend class IndirEntry; + friend class SindirEntry; friend class ConstEntry; friend class CarrayEntry; + friend class SarrayEntry; friend class StringEntry; friend class IndexEntry; friend class Fragment; @@ -107,9 +115,11 @@ int AlterSpec(const char* spec, int recode = 0) const; + size_t ArrayLen(const char *field_code) const; + gd_off64_t BoF(const char *field_code) const; - size_t CarrayLen(const char *field_code) const; + size_t CarrayLen(const char *field_code) const gd_deprecated; const gd_carray_t *Carrays(DataType type = Float64) const; @@ -164,6 +174,13 @@ gd_off64_t first_sample, size_t num_frames, size_t num_samples, DataType type, void* data_out) const; + size_t GetData(const char *field_code, gd_off64_t first_frame, + gd_off64_t first_sample, size_t num_frames, size_t num_samples, + const char** data_out) const; + + int GetSarray(const char *field_code, const char**data_out, + unsigned int start = 0, size_t len = 0) const; + size_t GetString(const char *field_code, size_t len, char *data_out) const; @@ -203,6 +220,8 @@ void MplexLookback(int lookback) const; + const char*** MSarrays(const char *parent) const; + const char **MStrings(const char *parent) const; const char **MVectorList(const char *parent) const; @@ -242,6 +261,9 @@ gd_off64_t first_sample, size_t num_frames, size_t num_samples, DataType type, const void* data_in) const; + int PutSarray(const char *field_code, const char **data_in, + unsigned int start = 0, size_t len = 0) const; + size_t PutString(const char *field_code, const char *data_in) const; int RawClose(const char *field_code = NULL) const; @@ -252,6 +274,8 @@ unsigned int SamplesPerFrame(const char *field_code) const; + const char*** Sarrays() const; + gd_off64_t Seek(const char* field_code, gd_off64_t frame_num, gd_off64_t sample_num, int flags) const; Modified: trunk/getdata/bindings/cxx/getdata/entry.h =================================================================== --- trunk/getdata/bindings/cxx/getdata/entry.h 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/getdata/entry.h 2014-07-16 02:11:54 UTC (rev 909) @@ -56,7 +56,10 @@ DivideEntryType = GD_DIVIDE_ENTRY, RecipEntryType = GD_RECIP_ENTRY, WindowEntryType = GD_WINDOW_ENTRY, - MplexEntryType = GD_MPLEX_ENTRY + MplexEntryType = GD_MPLEX_ENTRY, + SarrayEntryType = GD_SARRAY_ENTRY, + IndirEntryType = GD_INDIR_ENTRY, + SindirEntryType = GD_SINDIR_ENTRY, }; enum WindOpType { Added: trunk/getdata/bindings/cxx/getdata/indirentry.h =================================================================== --- trunk/getdata/bindings/cxx/getdata/indirentry.h (rev 0) +++ trunk/getdata/bindings/cxx/getdata/indirentry.h 2014-07-16 02:11:54 UTC (rev 909) @@ -0,0 +1,52 @@ +// Copyright (C) 2010 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 +// + +#ifndef GETDATA_INDIRENTRY_H +#define GETDATA_INDIRENTRY_H + +#include <getdata/entry.h> + +namespace GetData { + + class Dirfile; + + class IndirEntry : public Entry { + friend class Dirfile; + + public: + IndirEntry() : Entry() { E.field_type = GD_INDIR_ENTRY; }; + + IndirEntry(const char* field_code, const char* in_field1, + const char* in_field2, int fragment_index = 0); + + virtual const char *Input(int index = 0) const { + return E.in_fields[(index == 0) ? 0 : 1]; + }; + + int SetInput(const char* field, int index); + + private: + IndirEntry(const GetData::Dirfile *dirfile, const char* field_code) : + Entry(dirfile, field_code) { }; + }; +} + +#endif Added: trunk/getdata/bindings/cxx/getdata/sarrayentry.h =================================================================== --- trunk/getdata/bindings/cxx/getdata/sarrayentry.h (rev 0) +++ trunk/getdata/bindings/cxx/getdata/sarrayentry.h 2014-07-16 02:11:54 UTC (rev 909) @@ -0,0 +1,50 @@ +// Copyright (C) 2010 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 +// + +#ifndef GETDATA_SARRAYENTRY_H +#define GETDATA_SARRAYENTRY_H + +#include <getdata/entry.h> + +namespace GetData { + + class Dirfile; + + class SarrayEntry : public Entry { + friend class Dirfile; + + public: + SarrayEntry() : Entry() { E.field_type = GD_SARRAY_ENTRY; }; + + SarrayEntry(const char* field_code, size_t array_len, + int fragment_index = 0); + + virtual size_t ArrayLen() const { return E.u.scalar.array_len; } + + int SetArrayLen(size_t array_len); + + private: + SarrayEntry(const GetData::Dirfile *dirfile, const char* field_code) : + Entry(dirfile, field_code) { }; + }; +} + +#endif Added: trunk/getdata/bindings/cxx/getdata/sindirentry.h =================================================================== --- trunk/getdata/bindings/cxx/getdata/sindirentry.h (rev 0) +++ trunk/getdata/bindings/cxx/getdata/sindirentry.h 2014-07-16 02:11:54 UTC (rev 909) @@ -0,0 +1,52 @@ +// Copyright (C) 2010 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 +// + +#ifndef GETDATA_SINDIRENTRY_H +#define GETDATA_SINDIRENTRY_H + +#include <getdata/entry.h> + +namespace GetData { + + class Dirfile; + + class SindirEntry : public Entry { + friend class Dirfile; + + public: + SindirEntry() : Entry() { E.field_type = GD_SINDIR_ENTRY; }; + + SindirEntry(const char* field_code, const char* in_field1, + const char* in_field2, int fragment_index = 0); + + virtual const char *Input(int index = 0) const { + return E.in_fields[(index == 0) ? 0 : 1]; + }; + + int SetInput(const char* field, int index); + + private: + SindirEntry(const GetData::Dirfile *dirfile, const char* field_code) : + Entry(dirfile, field_code) { }; + }; +} + +#endif Deleted: trunk/getdata/bindings/cxx/indexentry.cpp =================================================================== --- trunk/getdata/bindings/cxx/indexentry.cpp 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/indexentry.cpp 2014-07-16 02:11:54 UTC (rev 909) @@ -1,21 +0,0 @@ -// Copyright (C) 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 -// -#include "internal.h" Added: trunk/getdata/bindings/cxx/indirentry.cpp =================================================================== --- trunk/getdata/bindings/cxx/indirentry.cpp (rev 0) +++ trunk/getdata/bindings/cxx/indirentry.cpp 2014-07-16 02:11:54 UTC (rev 909) @@ -0,0 +1,52 @@ +// 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 "internal.h" + +using namespace GetData; + +IndirEntry::IndirEntry(const char* field_code, const char* in_field1, + const char* in_field2, int fragment_index) : Entry() +{ + E.field = strdup(field_code); + E.field_type = GD_INDIR_ENTRY; + E.in_fields[0] = strdup(in_field1); + E.in_fields[1] = strdup(in_field2); + E.fragment_index = fragment_index; +} + +int IndirEntry::SetInput(const char* field, int index) +{ + if (index < 0 || index > 1) + return -1; + + char* ptr = strdup(field); + + if (ptr == NULL) + return -1; + + free(E.in_fields[index]); + E.in_fields[index] = ptr; + + if (D != NULL) + return gd_alter_entry(D->D, E.field, &E, 0); + + return 0; +} Modified: trunk/getdata/bindings/cxx/internal.h =================================================================== --- trunk/getdata/bindings/cxx/internal.h 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/internal.h 2014-07-16 02:11:54 UTC (rev 909) @@ -34,14 +34,14 @@ extern "C" const char* gd_colnil(void); extern "C" const char* gd_coladd(void); extern "C" const char* gd_colsub(void); -#define dtracevoid() printf("%s %s()\n", gd_coladd(), __FUNCTION__) +#define dtracevoid() printf("%s %s()\n", gd_coladd(), __func__) #define dtrace(fmt, ...) printf("%s %s(" fmt ")\n", gd_coladd(), \ - __FUNCTION__, ##__VA_ARGS__) + __func__, ##__VA_ARGS__) #define dprintf(fmt, ...) printf("%s %s:%i " fmt "\n", gd_colnil(), \ - __FUNCTION__, __LINE__, ##__VA_ARGS__) -#define dreturnvoid() printf("%s %s = (nil)\n", gd_colsub(), __FUNCTION__) + __func__, __LINE__, ##__VA_ARGS__) +#define dreturnvoid() printf("%s %s = (nil)\n", gd_colsub(), __func__) #define dreturn(fmt, ...) printf("%s %s = " fmt "\n", gd_colsub(), \ - __FUNCTION__, ##__VA_ARGS__) + __func__, ##__VA_ARGS__) #define dwatch(fmt, v) printf("%s %s = " fmt "\n", gd_colnil(), #v, v) #else #define dtracevoid() Added: trunk/getdata/bindings/cxx/sarrayentry.cpp =================================================================== --- trunk/getdata/bindings/cxx/sarrayentry.cpp (rev 0) +++ trunk/getdata/bindings/cxx/sarrayentry.cpp 2014-07-16 02:11:54 UTC (rev 909) @@ -0,0 +1,40 @@ +// 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 "internal.h" + +SarrayEntry::SarrayEntry(const char* field_code, size_t array_len, + int fragment_index) +{ + E.field = strdup(field_code); + E.field_type = GD_SARRAY_ENTRY; + E.u.scalar.array_len = array_len; + E.fragment_index = fragment_index; +} + +int SarrayEntry::SetArrayLen(size_t array_len) +{ + E.u.scalar.array_len = array_len; + + if (D != NULL) + return gd_alter_entry(D->D, E.field, &E, 0); + + return 0; +} Added: trunk/getdata/bindings/cxx/sindirentry.cpp =================================================================== --- trunk/getdata/bindings/cxx/sindirentry.cpp (rev 0) +++ trunk/getdata/bindings/cxx/sindirentry.cpp 2014-07-16 02:11:54 UTC (rev 909) @@ -0,0 +1,52 @@ +// 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 "internal.h" + +using namespace GetData; + +SindirEntry::SindirEntry(const char* field_code, const char* in_field1, + const char* in_field2, int fragment_index) : Entry() +{ + E.field = strdup(field_code); + E.field_type = GD_SINDIR_ENTRY; + E.in_fields[0] = strdup(in_field1); + E.in_fields[1] = strdup(in_field2); + E.fragment_index = fragment_index; +} + +int SindirEntry::SetInput(const char* field, int index) +{ + if (index < 0 || index > 1) + return -1; + + char* ptr = strdup(field); + + if (ptr == NULL) + return -1; + + free(E.in_fields[index]); + E.in_fields[index] = ptr; + + if (D != NULL) + return gd_alter_entry(D->D, E.field, &E, 0); + + return 0; +} Modified: trunk/getdata/bindings/cxx/test/big_test.cpp =================================================================== --- trunk/getdata/bindings/cxx/test/big_test.cpp 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/cxx/test/big_test.cpp 2014-07-16 02:11:54 UTC (rev 909) @@ -96,9 +96,10 @@ #define CHECK_OK2(t,n) CHECK_ERROR2(t,n,GD_E_OK) #define CHECK_NONNULL(t,v) CheckT<const void*>('p', -1, t, -1, v, NULL, !(v)) +#define CHECK_NONNULL2(t,n,v) CheckT<const void*>('p', -1, t, n, v, NULL, !(v)) -#define CHECK_NULL(t,v) CheckT<const void*>('p', -1, t, -1, v, NULL, v) -#define CHECK_NULL2(t,n,v) CheckT<const void*>('p', -1, t, n, v, NULL, v) +#define CHECK_NULL(t,v) CheckT<const void*>('p', -1, t, -1, v, NULL, !!(v)) +#define CHECK_NULL2(t,n,v) CheckT<const void*>('p', -1, t, n, v, NULL, !!(v)) #define CHECK_INT(t,v,g) CheckInt(-1, t, -1, v, g) #define CHECK_INT2(t,n,v,g) CheckInt(-1, t, n, v, g) @@ -112,8 +113,9 @@ #define CHECK_DOUBLE_ARRAY(t,n,m,v,g) \ for (i = 0; i < m; ++i) CheckFloat<double>('d', i, t, n, v, g) -#define CHECK_STRING(t,v,g) \ - CheckT<const char*>('s', -1, t, -1, v, g, (strcmp((v), (g)))) +#define CHECK_STRINGi(t,i,v,g) \ + CheckT<const char*>('s', i, t, -1, v, g, (strcmp((v), (g)))) +#define CHECK_STRING(t,v,g) CHECK_STRINGi(t,-1,v,g) #define CHECK_STRING2(t,n,v,g) \ CheckT<const char*>('s', -1, t, n, v, g, (strcmp((v), (g)))) @@ -130,7 +132,7 @@ #define CHECK_COMPLEX_ARRAY(t,m,v,g) \ for (i = 0; i < m; ++i) CheckFloat<complex<double> >('c', i, t, -1, v, g) -int main(void) +void run_tests(void) { const char* filedir = "dirfile"; const char* format = "dirfile/format"; @@ -159,13 +161,17 @@ "phase PHASE data 11\n" "window WINDOW linterp mult LT 4.1\n" "/ALIAS alias data\n" - "string STRING \"Zaphod Beeblebrox\"\n"; + "string STRING \"Zaphod Beeblebrox\"\n" + "sarray SARRAY one two three four five six seven\n" + "data/msarray SARRAY eight nine ten eleven twelve\n" + "indir INDIR data carray\n" + "sindir SINDIR data sarray\n"; const char* form2_data = "const2 CONST INT8 -19\n"; - const int nfields = 17; + const int nfields = 20; unsigned char c[8]; unsigned char data_data[80]; signed char sc; - int m, n, i; + int m, n, i, j; float fl; double dp, p[6], q[6]; const double *qp; @@ -191,16 +197,20 @@ StringEntry gent; WindowEntry went, *wep; MplexEntry xent, *xep; + SarrayEntry saent, *saep; + IndirEntry ient, *iep; + SindirEntry sient, *siep; Fragment *frag; gd_triplet_t thresh; const gd_carray_t *carrays; + const char*** sarrays; char* fields[nfields + 9] = {(char*)"INDEX", (char*)"alias", (char*)"bit", (char*)"carray", (char*)"const", (char*)"data", (char*)"div", - (char*)"lincom", (char*)"linterp", (char*)"mplex", (char*)"mult", - (char*)"phase", (char*)"polynom", (char*)"recip", (char*)"sbit", - (char*)"string", (char*)"window", NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL}; + (char*)"indir", (char*)"lincom", (char*)"linterp", (char*)"mplex", + (char*)"mult", (char*)"phase", (char*)"polynom", (char*)"recip", + (char*)"sarray", (char*)"sbit", (char*)"sindir", (char*)"string", + (char*)"window", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; char *strings[3]; unlink(data); @@ -262,13 +272,14 @@ // 26: Dirfile::NFields check n = d->NMFields("data"); CHECK_OK(26); - CHECK_INT(26,n,4); + CHECK_INT(26,n,5); // 27: Dirfile::MFieldList check fields[0] = (char*)"mstr"; fields[1] = (char*)"mconst"; fields[2] = (char*)"mcarray"; fields[3] = (char*)"mlut"; + fields[4] = (char*)"msarray"; list = d->MFieldList("data"); CHECK_OK(27); CHECK_STRING_ARRAY(27,n,list[i],fields[i]); @@ -671,7 +682,7 @@ // 69: Dirfile::NVectors check n = d->NVectors(); CHECK_OK(69); - CHECK_INT(69,n,24); + CHECK_INT(69,n,26); // 70: Dirfile::VectorList check fields[0] = (char*)"INDEX"; @@ -679,25 +690,27 @@ fields[2] = (char*)"bit"; fields[3] = (char*)"data"; fields[4] = (char*)"div"; - fields[5] = (char*)"lincom"; - fields[6] = (char*)"linterp"; - fields[7] = (char*)"mplex"; - fields[8] = (char*)"mult"; - fields[9] = (char*)"new1"; - fields[10] = (char*)"new10"; - fields[11] = (char*)"new2"; - fields[12] = (char*)"new3"; - fields[13] = (char*)"new4"; - fields[14] = (char*)"new5"; - fields[15] = (char*)"new6"; - fields[16] = (char*)"new7"; - fields[17] = (char*)"new8"; - fields[18] = (char*)"new9"; - fields[19] = (char*)"phase"; - fields[20] = (char*)"polynom"; - fields[21] = (char*)"recip"; - fields[22] = (char*)"sbit"; - fields[23] = (char*)"window"; + fields[5] = (char*)"indir"; + fields[6] = (char*)"lincom"; + fields[7] = (char*)"linterp"; + fields[8] = (char*)"mplex"; + fields[9] = (char*)"mult"; + fields[10] = (char*)"new1"; + fields[11] = (char*)"new10"; + fields[12] = (char*)"new2"; + fields[13] = (char*)"new3"; + fields[14] = (char*)"new4"; + fields[15] = (char*)"new5"; + fields[16] = (char*)"new6"; + fields[17] = (char*)"new7"; + fields[18] = (char*)"new8"; + fields[19] = (char*)"new9"; + fields[20] = (char*)"phase"; + fields[21] = (char*)"polynom"; + fields[22] = (char*)"recip"; + fields[23] = (char*)"sbit"; + fields[24] = (char*)"sindir"; + fields[25] = (char*)"window"; list = d->VectorList(); CHECK_OK(70); CHECK_STRING_ARRAY(70,n,list[i],fields[i]); @@ -1274,19 +1287,19 @@ d->Standards(0); CHECK_ERROR2(157,2,GD_E_ARGUMENT); - // 158 gd_get_carray + // 158: gd_get_carray n = d->GetCarray("carray", Float64, p); CHECK_OK(158); CHECK_INT(158,n,0); CHECK_DOUBLE_ARRAY(158,1,6,p[i],1.1 * (i + 1)); - // 159 gd_get_carray_slice (INT8) + // 159: gd_get_carray_slice (INT8) n = d->GetCarray("carray", Float64, p, 2, 2); CHECK_OK(159); CHECK_INT(159,n,0); CHECK_DOUBLE_ARRAY(159,1,2,p[i],1.1 * (i + 3)); - // 167 gd_carrays + // 167: gd_carrays carrays = d->Carrays(Float64); CHECK_OK(167); CHECK_NONNULL(167,carrays); @@ -1294,7 +1307,7 @@ CHECK_DOUBLE_ARRAY(167,2,6,((double*)carrays[0].d)[i],1.1 * (i + 1)); CHECK_INT2(167,2,carrays[1].n,0); - // 168 gd_put_carray + // 168: gd_put_carray p[0] = 9.6; p[1] = 8.5; p[2] = 7.4; @@ -1309,7 +1322,7 @@ CHECK_INT(168,n,0); CHECK_DOUBLE_ARRAY(168,1,6,q[i],9.6 - i * 1.1); - // 169 gd_put_carray_slice (INT8) + // 169: gd_put_carray_slice (INT8) p[0] = 2.2; p[1] = 3.3; n = d->PutCarray("carray", Float64, p, 2, 2); @@ -1320,20 +1333,21 @@ CHECK_INT(168,n,0); CHECK_DOUBLE_ARRAY(168,1,6,q[i],(i == 2 || i == 3) ? i * 1.1 : 9.6 - i * 1.1); - // 177 gd_carray_len - n = (int)d->CarrayLen("carray"); + // 177: gd_array_len + n = (int)d->ArrayLen("carray"); CHECK_OK(177); CHECK_INT(177,n,6); - // 178 gd_entry (CARRAY) - ent = d->Entry("const"); + // 178: gd_entry (CARRAY) + ent = d->Entry("carray"); CHECK_OK(178); - CHECK_INT2(178,1,ent->Type(),ConstEntryType); + CHECK_INT2(178,1,ent->Type(),CarrayEntryType); CHECK_INT2(178,2,ent->FragmentIndex(),0); CHECK_INT2(178,3,ent->ConstType(),Float64); + CHECK_INT2(178,4,ent->ArrayLen(),6); delete ent; - // 179 gd_add_carray + // 179: gd_add_carray aent.SetName("new17"); aent.SetFragmentIndex(0); aent.SetType(Float64); @@ -1420,7 +1434,7 @@ CHECK_OK2(203,0); m = d->GetData("data", GD_HERE, 0, 1, 0, UInt8, c); CHECK_OK2(203,1); - CHECK_INT2(203,0,n,280); + CHECK_INT2(203,0,n,35 * 8); CHECK_INT2(203,1,m,8); CHECK_INT_ARRAY(203,8,c[i],17 + i); @@ -1700,39 +1714,41 @@ n = d->NEntries("data", GD_SCALAR_ENTRIES, GD_ENTRIES_HIDDEN | GD_ENTRIES_NOALIAS); CHECK_OK2(237, 1); - CHECK_INT2(237, 1, n, 4); + CHECK_INT2(237, 1, n, 5); n = d->NEntries(NULL, GD_VECTOR_ENTRIES, GD_ENTRIES_HIDDEN | GD_ENTRIES_NOALIAS); CHECK_OK2(237, 2); - CHECK_INT2(237, 2, n, 26); + CHECK_INT2(237, 2, n, 28); // 239: gd_entry_list fields[0] = (char*)"INDEX"; fields[1] = (char*)"bit"; fields[2] = (char*)"data"; fields[3] = (char*)"div"; - fields[4] = (char*)"lincom"; - fields[5] = (char*)"linterp"; - fields[6] = (char*)"mplex"; - fields[7] = (char*)"mult"; - fields[8] = (char*)"new1"; - fields[9] = (char*)"new14"; - fields[10] = (char*)"new15"; - fields[11] = (char*)"new16"; - fields[12] = (char*)"new18"; - fields[13] = (char*)"new2"; - fields[14] = (char*)"new21"; - fields[15] = (char*)"new3"; - fields[16] = (char*)"new4"; - fields[17] = (char*)"new5"; - fields[18] = (char*)"new6"; - fields[19] = (char*)"new7"; - fields[20] = (char*)"new8"; - fields[21] = (char*)"phase"; - fields[22] = (char*)"polynom"; - fields[23] = (char*)"recip"; - fields[24] = (char*)"sbit"; - fields[25] = (char*)"window"; + fields[4] = (char*)"indir"; + fields[5] = (char*)"lincom"; + fields[6] = (char*)"linterp"; + fields[7] = (char*)"mplex"; + fields[8] = (char*)"mult"; + fields[9] = (char*)"new1"; + fields[10] = (char*)"new14"; + fields[11] = (char*)"new15"; + fields[12] = (char*)"new16"; + fields[13] = (char*)"new18"; + fields[14] = (char*)"new2"; + fields[15] = (char*)"new21"; + fields[16] = (char*)"new3"; + fields[17] = (char*)"new4"; + fields[18] = (char*)"new5"; + fields[19] = (char*)"new6"; + fields[20] = (char*)"new7"; + fields[21] = (char*)"new8"; + fields[22] = (char*)"phase"; + fields[23] = (char*)"polynom"; + fields[24] = (char*)"recip"; + fields[25] = (char*)"sbit"; + fields[26] = (char*)"sindir"; + fields[27] = (char*)"window"; list = d->EntryList(NULL, GD_VECTOR_ENTRIES, GD_ENTRIES_HIDDEN | GD_ENTRIES_NOALIAS); CHECK_OK(239); @@ -1759,12 +1775,233 @@ CHECK_DOUBLE_ARRAY(242,4,2,((double*)carrays[1].d)[i],0); CHECK_INT2(242,5,carrays[2].n,0); + // 271: gd_encoding_support + n = EncodingSupport(GD_SIE_ENCODED); + CHECK_INT(271, n, GD_RDWR); + // 274: gd_entry (SARRAY) + ent = d->Entry("sarray"); + CHECK_OK(274); + CHECK_INT2(274,1,ent->Type(),SarrayEntryType); + CHECK_INT2(274,2,ent->FragmentIndex(),0); + CHECK_INT2(274,3,ent->ArrayLen(),7); + delete ent; + // 275: gd_get_sarray + fields[0] = (char*)"one"; + fields[1] = (char*)"two"; + fields[2] = (char*)"three"; + fields[3] = (char*)"four"; + fields[4] = (char*)"five"; + fields[5] = (char*)"six"; + fields[6] = (char*)"seven"; + n = d->GetSarray("sarray", list); + CHECK_OK(275); + CHECK_INT(275,n,0); + CHECK_STRING_ARRAY(275,7,list[i],fields[i]); + // 276: gd_get_sarray_slice + n = d->GetSarray("sarray", list, 4, 3); + CHECK_OK(276); + CHECK_INT(276,n,0); + CHECK_STRING_ARRAY(276,3,list[i],fields[i+4]); + // 277: gd_sarrays + sarrays = d->Sarrays(); + CHECK_OK(277); + CHECK_NONNULL(277,sarrays); + for (i = 0; sarrays[i] != NULL; ++i) { + for (j = 0; sarrays[i][j] != NULL; ++j) + CHECK_STRINGi(277, i * 1000 + j, sarrays[i][j], fields[j]); + CHECK_INT2(277, i + 1, j, 7); + } + CHECK_INT2(277, 0, i, 1); + // 278: gd_put_sarray + fields[0] = (char*)"eka"; + fields[1] = (char*)"dvi"; + fields[2] = (char*)"tri"; + fields[3] = (char*)"catur"; + fields[4] = (char*)"panca"; + fields[5] = (char*)"sas"; + fields[6] = (char*)"sapta"; + n = d->PutSarray("sarray", (const char**)fields); + CHECK_OK2(278, 1); + n = d->GetSarray("sarray", list); + CHECK_OK2(278,2); + CHECK_INT(278,n,0); + CHECK_STRING_ARRAY(278,7,list[i],fields[i]); + + // 279: gd_put_sarray_slice + fields[4] = (char*)"asta"; + fields[5] = (char*)"nava"; + n = d->PutSarray("sarray", (const char**)fields + 4, 4, 2); + CHECK_OK2(279, 1); + + n = d->GetSarray("sarray", list); + CHECK_OK2(279,2); + CHECK_INT(279,n,0); + CHECK_STRING_ARRAY(279,7,list[i],fields[i]); + + // 280: gd_add_sarray + saent.SetName("new280"); + saent.SetFragmentIndex(0); + saent.SetArrayLen(4); + d->Add(saent); + CHECK_OK2(280,1); + + ent = d->Entry("new280"); + CHECK_OK2(280,2); + CHECK_INT2(280,1,ent->Type(),SarrayEntryType); + CHECK_INT2(280,2,ent->FragmentIndex(),0); + CHECK_INT2(280,4,ent->ArrayLen(),4); + delete ent; + + // 282: gd_madd_sarray + saent.Dissociate(); + saent.SetName("mnew282"); + saent.SetFragmentIndex(0); + saent.SetArrayLen(2); + d->MAdd(saent, "data"); + CHECK_OK2(282,1); + + ent = d->Entry("data/mnew282"); + CHECK_OK2(282,2); + CHECK_INT2(282,1,ent->Type(),SarrayEntryType); + CHECK_INT2(282,2,ent->FragmentIndex(),0); + CHECK_INT2(282,4,ent->ArrayLen(),2); + delete ent; + + // 283: gd_alter_sarray + saep = reinterpret_cast<SarrayEntry*>(d->Entry("new280")); + CHECK_OK2(283,1); + saep->SetArrayLen(12); + CHECK_OK2(283,2); + delete saep; + + ent = d->Entry("new280"); + CHECK_OK2(283,3); + CHECK_INT2(283,1,ent->Type(),SarrayEntryType); + CHECK_INT2(283,2,ent->FragmentIndex(),0); + CHECK_INT2(283,4,ent->ArrayLen(),12); + delete ent; + + // 284: gd_msarrays + fields[0] = (char*)"eight"; + fields[1] = (char*)"nine"; + fields[2] = (char*)"ten"; + fields[3] = (char*)"eleven"; + fields[4] = (char*)"twelve"; + sarrays = d->MSarrays("data"); + CHECK_OK(284); + CHECK_NONNULL2(284,0,sarrays); + CHECK_NONNULL2(284,1,sarrays[0]); + for (j = 0; sarrays[0][j] != NULL; ++j) + CHECK_STRINGi(284, j, sarrays[0][j], fields[j]); + CHECK_INT2(284, 1, j, 5); + + fields[0] = (char*)""; + fields[1] = (char*)""; + CHECK_NONNULL2(284,2,sarrays[1]); + for (j = 0; sarrays[1][j] != NULL; ++j) + CHECK_STRINGi(284, 1000 + j, sarrays[1][j], fields[j]); + CHECK_INT2(284, 3, j, 2); + CHECK_NULL2(284,4,sarrays[2]); + + // 285: Dirfile::Entry / IndirEntry check + ent = d->Entry("indir"); + CHECK_OK(285); + CHECK_INT2(285,1,ent->Type(),IndirEntryType); + CHECK_INT2(285,2,ent->FragmentIndex(),0); + CHECK_STRING2(285,3,ent->Input(0),"data"); + CHECK_STRING2(285,4,ent->Input(1),"carray"); + delete ent; + + // 286: Dirfile::Add / IndirEntry check + ient.SetName("new286"); + ient.SetFragmentIndex(0); + ient.SetInput("in1", 0); + ient.SetInput("in2", 1); + d->Add(ient); + CHECK_OK2(286,1); + + ent = d->Entry("new286"); + CHECK_OK2(286,2); + CHECK_INT2(286,1,ent->Type(),IndirEntryType); + CHECK_INT2(286,2,ent->FragmentIndex(),0); + CHECK_STRING2(286,3,ent->Input(0),"in1"); + CHECK_STRING2(286,4,ent->Input(1),"in2"); + + // 289: IndirEntry check + iep = reinterpret_cast<IndirEntry*>(d->Entry("new286")); + CHECK_OK2(289,1); + iep->SetInput("in4",0); + CHECK_OK2(289,2); + iep->SetInput("in5",1); + CHECK_OK2(289,3); + delete iep; + + ent = d->Entry("new286"); + CHECK_OK2(289,2); + CHECK_INT2(289,1,ent->Type(),IndirEntryType); + CHECK_INT2(289,2,ent->FragmentIndex(),0); + CHECK_STRING2(289,3,ent->Input(0),"in4"); + CHECK_STRING2(289,4,ent->Input(1),"in5"); + + // 290: Dirfile::Entry / SindirEntry check + ent = d->Entry("sindir"); + CHECK_OK(290); + CHECK_INT2(290,1,ent->Type(),SindirEntryType); + CHECK_INT2(290,2,ent->FragmentIndex(),0); + CHECK_STRING2(290,3,ent->Input(0),"data"); + CHECK_STRING2(290,4,ent->Input(1),"sarray"); + delete ent; + + // 291: Dirfile::Add / SindirEntry check + sient.SetName("new291"); + sient.SetFragmentIndex(0); + sient.SetInput("in1", 0); + sient.SetInput("in2", 1); + d->Add(sient); + CHECK_OK2(291,1); + + ent = d->Entry("new291"); + CHECK_OK2(291,2); + CHECK_INT2(291,1,ent->Type(),SindirEntryType); + CHECK_INT2(291,2,ent->FragmentIndex(),0); + CHECK_STRING2(291,3,ent->Input(0),"in1"); + CHECK_STRING2(291,4,ent->Input(1),"in2"); + + // 294: SindirEntry check + siep = reinterpret_cast<SindirEntry*>(d->Entry("new291")); + CHECK_OK2(294,1); + siep->SetInput("in4",0); + CHECK_OK2(294,2); + siep->SetInput("in5",1); + CHECK_OK2(294,3); + delete siep; + + ent = d->Entry("new291"); + CHECK_OK2(294,2); + CHECK_INT2(294,1,ent->Type(),SindirEntryType); + CHECK_INT2(294,2,ent->FragmentIndex(),0); + CHECK_STRING2(294,3,ent->Input(0),"in4"); + CHECK_STRING2(294,4,ent->Input(1),"in5"); + delete ent; + + // 295: gd_getstrdata + n = d->GetData("sindir", 0, 0, 1, 0, list); + CHECK_OK(295); + CHECK_INT(295,n,8); + CHECK_STRING_ARRAY(295,8,list[i],"eka"); + + + + + + + // =================================================================== d->Discard(); delete d; @@ -1774,7 +2011,12 @@ unlink(format1); unlink(form2); rmdir(filedir); +} +int main(void) +{ + run_tests(); + if (ne) { cerr << "ne = " << ne << endl; return 1; Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2014-07-15 01:36:02 UTC (rev 908) +++ trunk/getdata/bindings/f77/fgetdata.c 2014-07-16 02:11:54 UTC (rev 909) @@ -278,7 +278,7 @@ { char *out; - dtrace("%p, %i, %p, %i, %i, %i, %i, %i, 0x%x, %p", n_read, *dirfile, + dtrace("%p, %i, %p, %i, %i, %i, %i, %i, 0x%X, %p", n_read, *dirfile, field_code, *field_code_l, *first_frame, *first_sample, *num_frames, *num_samples, *return_type, data_out); @@ -454,7 +454,7 @@ const int32_t *data_type, const void *data_in) { char *out; - dtrace("%p, %i, %p, %i, %i, %i, %i, %i, 0x%x, %p", n_wrote, *dirfile, + dtrace("%p, %i, %p, %i, %i, %i, %i, %i, 0x%X, %p", n_wrote, *dirfile, field_code, *field_code_l, *first_frame, *first_sample, *num_frames, *num_samples, *data_type, data_in); @@ -799,20 +799,20 @@ dreturnvoid(); } -/* gd_entry wrapper for MULTIPLY */ -void F77_FUNC(gdgemt, GDGEMT) (char *in_field1, int32_t *in_field1_l, +static void _GDF_GetEntryYoke(char *in_field1, int32_t *in_field1_l, char *in_field2, int32_t *in_field2_l, int32_t *fragment_index, - const int32_t *dirfile, const char *field_code, const int32_t *field_code_l) + const int32_t *dirfile, const char *field_code, const int32_t *field_code_l, + gd_entype_t type) { char *out; gd_entry_t E; - dtrace("%p, %i, %p, %i, %p, %i, %p, %i", in_field1, *in_field1_l, + dtrace("%p, %i, %p, %i, %p, %i, %p, %i, 0x%X", in_field1, *in_field1_l, in_field2, *in_field2_l, fragment_index, *dirfile, field_code, - *field_code_l); + *field_code_l, type); if (gd_entry(_GDF_GetDirfile(*dirfile), _GDF_CString(&out, field_code, - *field_code_l), &E) || E.field_type != GD_MULTIPLY_ENTRY) + *field_code_l), &E) || E.field_type != type) *in_field1_l = 0; else { _GDF_FString(in_field1, in_field1_l, E.in_fields[0]); @@ -825,30 +825,63 @@ dreturnvoid(); } +/* gd_entry wrapper for MULTIPLY */ +void F77_FUNC(gdgemt, GDGEMT) (char *in_field1, int32_t *in_field1_l, + char *in_field2, int32_t *in_field2_l, int32_t *fragment_index, + const int32_t *dirfile, const char *field_code, const int32_t *field_code_l) +{ + dtrace("%p, %i, %p, %i, %p, %i, %p, %i", in_field1, *in_field1_l, + in_field2, *in_field2_l, fragment_index, *dirfile, field_code, + *field_code_l); + + _GDF_GetEntryYoke(in_field1, in_field1_l, in_field2, in_field2_l, + fragment_index, dirfile, field_code, field_code_l, GD_MULTIPLY_ENTRY); + + dreturnvoid(); +} + /* gd_entry wrapper for DIVIDE */ void F77_FUNC(gdgedv, GDGEDV) (char *in_field1, int32_t *in_field1_l, char *in_field2, int32_t *in_field2_l, int32_t *fragment_index, const int32_t *dirfile, const char *field_code, const int32_t *field_code_l) { - char *out; - gd_entry_t E; + dtrace("%p, %i, %p, %i, %p, %i, %p, %i", in_field1, *in_field1_l, + in_field2, *in_field2_l, fragment_index, *dirfile, field_code, + *field_code_l); + _GDF_GetEntryYoke(in_field1, in_field1_l, in_field2, in_field2_l, + fragment_index, dirfile, field_code, field_code_l, GD_DIVIDE_ENTRY); + + dreturnvoid(); +} + +/* gd_entry wrapper for INDIR */ +void F77_FUNC(gdgeid, GDGEID) (char *in_field1, int32_t *in_field1_l, + char *in_field2, int32_t *in_field2_l, int32_t *fragment_index, + const int32_t *dirfile, const char *field_code, const int32_t *field_code_l) +{ dtrace("%p, %i, %p, %i, %p, %i, %p, %i", in_field1, *in_field1_l, in_field2, *in_field2_l, fragment_index, *dirfile, field_code, *field_code_l); - if (gd_entry(_GDF_GetDirfile(*dirfile), _GDF_CString(&out, field_code, - *field_code_l), &E) || E.field_type != GD_DIVIDE_ENTRY) - *in_field1_l = 0; - else { - _GDF_FString(in_field1, in_field1_l, E.in_fields[0]); - _GDF_FString(in_field2, in_field2_l, E.in_fields[1]); - *fragment_index = E.fragment_index; - gd_free_entry_strings(&E); - } + _GDF_GetEntryYoke(in_field1, in_field1_l, in_field2, in_field2_l, + fragment_index, dirfile, field_code, field_code_l, GD_INDIR_ENTRY); - free(out); + dreturnvoid(); +} +/* gd_entry wrapper for SINDIR */ +void F77_FUNC(gdgesd, GDGESD) (char *in_field1, int32_t *in_field1_l, + char *in_field2, int32_t *in_field2_l, int32_t *fragment_index, + const int32_t *dirfile, const char *field_code, const int32_t *field_code_l) +{ + dtrace("%p, %i, %p, %i, %p, %i, %p, %i", in_field1, *in_field1_l, + in_field2, *in_field2_l, fragment_index, *dirfile, field_code, + *field_code_l); + + _GDF_GetEntryYoke(in_field1, in_field1_l, in_field2, in_field2_l, + fragment_index, dirfile, field_code, field_code_l, GD_SINDIR_ENTRY); + dreturnvoid(); } @@ -1048,6 +1081,29 @@ dreturnvoid(); } +/* gd_entry wrapper for SARRAY */ +void F77_FUNC(gdgesa, GDGESA) (int32_t *array_len, int32_t *fragment_index, + const int32_t *dirfile, const char *field_code, const int32_t *field_code_l) +{ + char *out; + gd_entry_t E; + + dtrace("%p, %p, %i, %p, %i", array_len, fragment_index, *dirfile, field_code, + *field_code_l); + + if (gd_entry(_GDF_GetDirfile(*dirfile), _GDF_CString(&out, field_code, + *field_code_l), &E) || E.field_type != GD_SARRAY_ENTRY) + *array_len = -1; + else { + *array_len = E.EN(scalar,array_len); + *fragment_index = E.fragment_index; + gd_free_entry_strings(&E); + } + + free(out); + dreturnvoid(); +} + /* gd_fragment_index wrapper */ void F77_FUNC(gdfrgi, GDFRGI) (int32_t *fragment_index, const int32_t *dirfile, const char *field_code, const int32_t *field_code_l) @@ -1357,6 +1413,50 @@ dreturnvoid(); } +/* gd_add_indir wrapper */ +void F77_FUNC(gdadid, GDADID) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const char *in_field1, + const int32_t *in_field1_l, const char *in_field2, + const int32_t *in_field2_l, const int32_t *fragment_index) +{ + char *fc, *in1, *in2; + + dtrace("%i, %p, %i, %p, %i, %p, %i, %i", *dirfile, field_code, *field_code_l, + in_field1, *in_field1_l, in_field2, *in_field2_l, *fragment_index); + + gd_add_indir(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, + *field_code_l), _GDF_CString(&in1, in_field1, *in_field1_l), + _GDF_CString(&in2, in_field2, *in_field2_l), *fragment_index); + + free(fc); + free(in1); + free(in2); + + dreturnvoid(); +} + +/* gd_add_sindir wrapper */ +void F77_FUNC(gdadsd, GDADSD) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, const char *in_field1, + const int32_t *in_field1_l, const char *in_field2, + const int32_t *in_field2_l, const int32_t *fragment_index) +{ + char *fc, *in1, *in2; + + dtrace("%i, %p, %i, %p, %i, %p, %i, %i", *dirfile, field_code, *field_code_l, + in_field1, *in_field1_l, in_field2, *in_field2_l, *fragment_index); + + gd_add_sindir(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, + *field_code_l), _GDF_CString(&in1, in_field1, *in_field1_l), + _GDF_CString(&in2, in_field2, *in_field2_l), *fragment_index); + + free(fc); + free(in1); + free(in2); + + dreturnvoid(); +} + /* gd_add_recip wrapper */ void F77_FUNC(gdadrc, GDADRC) (const int32_t *dirfile, const char *field_code, const int32_t *field_code_l, const char *in_field, @@ -1474,7 +1574,7 @@ void F77_FUNC(gdnfdt, GDNFDT) (int32_t *nfields, const int32_t *dirfile, const int32_t *type) { - dtrace("%p, %i, 0x%x", nfields, *dirfile, *type); + dtrace("%p, %i, 0x%X", nfields, *dirfile, *type); *nfields = gd_nfields_by_type(_GDF_GetDirfile(*dirfile), (gd_entype_t)*type); @@ -1883,6 +1983,58 @@ dreturnvoid(); } +/* gd_madd_indir wrapper */ +void F77_FUNC(gdmdid, GDMDID) (const int32_t *dirfile, const char *parent, + const int32_t *parent_l, const char *field_code, + const int32_t *field_code_l, const char *in_field1, + const int32_t *in_field1_l, const char *in_field2, + const int32_t *in_field2_l) +{ + char *pa, *fc, *in1, *in2; + + dtrace("%i, %p, %i, %p, %i, %p, %i, %p, %i", *dirfile, parent, *parent_l, + field_code, *field_code_l, in_field1, *in_field1_l, in_field2, + *in_field2_l); + + gd_madd_indir(_GDF_GetDirfile(*dirfile), _GDF_CString(&pa, parent, + *parent_l), _GDF_CString(&fc, field_code, *field_code_l), + _GDF_CString(&in1, in_field1, *in_field1_l), _GDF_CString(&in2, in_field2, + *in_field2_l)); + + free(pa); + free(fc); + free(in1); + free(in2); + + dreturnvoid(); +} + +/* gd_madd_sindir wrapper */ +void F77_FUNC(gdmdsd, GDMDSD) (const int32_t *dirfile, const char *parent, + const int32_t *parent_l, const char *field_code, + const int32_t *field_code_l, const char *in_field1, + const int32_t *in_field1_l, const char *in_field2, + const int32_t *in_field2_l) +{ + char *pa, *fc, *in1, *in2; + + dtrace("%i, %p, %i, %p, %i, %p, %i, %p, %i", *dirfile, parent, *parent_l, + field_code, *field_code_l, in_field1, *in_field1_l, in_field2, + *in_field2_l); + + gd_madd_sindir(_GDF_GetDirfile(*dirfile), _GDF_CString(&pa, parent, + *parent_l), _GDF_CString(&fc, field_code, *field_code_l), + _GDF_CString(&in1, in_field1, *in_field1_l), _GDF_CString(&in2, in_field2, + *in_field2_l)); + + free(pa); + free(fc); + free(in1); + free(in2); + + dreturnvoid(); +} + /* gd_madd_recip wrapper */ void F77_FUNC(gdmdrc, GDMDRC) (const int32_t *dirfile, const char *parent, const int32_t *parent_l, const char *field_code, @@ -1999,7 +2151,7 @@ { char *fc; - dtrace("%i, %p, %i, %x, %i, %x, %p, %i", *dirfile, field_code, + dtrace("%i, %p, %i, 0x%X, %i, 0x%X, %p, %i", *dirfile, field_code, *field_code_l, *const_type, *array_len, *data_type, value, *fragment_index); @@ -2011,6 +2163,34 @@ dreturnvoid(); } +/* gd_add_sarray wrapper -- values are intialised to nil */ +void F77_FUNC(gdadsa, GDADSA) (const int32_t *dirfile, const char *field_code, + const int32_t *field_code_l, int32_t *array_len, + const int32_t *fragment_index) +{ + char *fc; + const char **nils; + int32_t i; + + dtrace("%i, %p, %i, %i, %i", *dirfile, field_code, *field_code_l, *array_len, + *fragment_index); + + nils = malloc(*array_len * sizeof(*nils)); + if (nils == NULL) { /* XXX error reporting? */ + dreturnvoid(); + return; + } + for (i = 0; i < *array_len; ++i) + nils[i] = ""; + + gd_add_sarray(_GDF_GetDirfile(*dirfile), _GDF_CString(&fc, field_code, + *field_code_l), *array_len, nils, *fragment_index); + + free(fc); + free(nils); + dreturnvoid(); +} + /* gd_madd_carray wrapper */ void F77_FUNC(gdmdca, GDMDCA) (const int32_t *dirfile, const char *parent, const int32_t *parent_l, const char *field_code, @@ -2019,7 +2199,7 @@ { char *pa, *fc; - dtrace("%i, %p, %i, %p, %i, %x, %i, %x, %p", *dirfile, parent, *parent_l, + dtrace("%i, %p, %i, %p, %i, 0x%X, %i, 0x%X, %p", *dirfile, parent, *parent_l, field_code, *field_code_l, *const_type, *array_len, *data_type, value); gd_madd_carray(_GDF_GetDirfile(*dirfile), _GDF_CString(&pa, parent, @@ -2031,6 +2211,36 @@ dreturnvoid(); } +/* gd_madd_sarray wrapper -- values are intialised to nil */ +void F77_FUNC(gdmdsa, GDMDSA) (const int32_t *dirfile, const char *parent, + const int32_t *parent_l, const char *field_code, + const int32_t *field_code_l, const int32_t *array_len) +{ + char *pa, *fc; + const char **nils; + int32_t i; + + dtrace("%i, %p, %i, %p, %i, %i", *dirfile, parent, *parent_l, field_code, + *field_code_l, *array_len); + + nils = malloc(*array_len * sizeof(*nils)); + if (nils == NULL) { /* XXX error reporting? */ + dreturnvoid(); + return; + } + for (i = 0; i < *array_len; ++i) + nils[i] = ""; + + gd_madd_sarray(_GDF_GetDirfile(*dirfile), _GDF_CString(&pa, parent, + *parent_l), _GDF_CString(&fc, field_code, *field_code_l), *array_len, + nils); + + free(pa); + free(fc); + free(nils); + dreturnvoid(); ... [truncated message content] |
From: <ket...@us...> - 2014-07-15 01:36:05
|
Revision: 908 http://sourceforge.net/p/getdata/code/908 Author: ketiltrout Date: 2014-07-15 01:36:02 +0000 (Tue, 15 Jul 2014) Log Message: ----------- C++11 Modified Paths: -------------- trunk/getdata/man/dirfile.5 Modified: trunk/getdata/man/dirfile.5 =================================================================== --- trunk/getdata/man/dirfile.5 2014-05-27 21:15:33 UTC (rev 907) +++ trunk/getdata/man/dirfile.5 2014-07-15 01:36:02 UTC (rev 908) @@ -1,6 +1,6 @@ .\" dirfile.5. The dirfile man page. .\" -.\" Copyright (C) 2005, 2006, 2008, 2009 D. V. Wiebe +.\" Copyright (C) 2005, 2006, 2008, 2009, 2014 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 dirfile 5 "1 April 2012" "Standards Version 9" "DATA FORMATS" +.TH dirfile 5 "15 July 2014" "Standards Version 9" "DATA FORMATS" .SH NAME dirfile \(em a filesystem-based database format for time-ordered binary data .SH DESCRIPTION @@ -111,12 +111,7 @@ with the IEEE-754 real part followed by the IEEE-754 imaginary part. The specified endianness of the two components follows that of purely real floating point numbers. Endianness does not affect the ordering of the real and -imaginary parts. This format also conforms to the C99 standard. The latest -C++ standard (C++98) does not specify a standard storage format for native -complex numbers, but the upcoming standard, (C++0x) is intended to specify the -above format for compatibility with C99 -.RI ( see : -ISO/IEC JTC1/SC22/WG21/N1388). +imaginary parts. This format also conforms to the C99 and C++11 standards. To aid in using complex valued data, dirfile field codes may contain a .I representation suffix This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-27 21:15:37
|
Revision: 907 http://sourceforge.net/p/getdata/code/907 Author: ketiltrout Date: 2014-05-27 21:15:33 +0000 (Tue, 27 May 2014) Log Message: ----------- Merge gd_carray_len and gd_sarray_len into gd_array_len. gd_carray_len remains as a deprecated alias with runtime linkage. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/man/Makefile.am trunk/getdata/src/constant.c trunk/getdata/src/getdata.h.in trunk/getdata/src/string.c trunk/getdata/test/add_carray.c trunk/getdata/test/add_sarray.c trunk/getdata/test/add_sarray_nil.c trunk/getdata/test/alter_carray_len.c trunk/getdata/test/alter_carray_type.c trunk/getdata/test/alter_sarray.c trunk/getdata/test/get_carray_len.c trunk/getdata/test/get_sarray_len.c trunk/getdata/test/madd_carray.c trunk/getdata/test/madd_sarray.c Added Paths: ----------- trunk/getdata/man/gd_array_len.3 Removed Paths: ------------- trunk/getdata/man/gd_carray_len.3 Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/ChangeLog 2014-05-27 21:15:33 UTC (rev 907) @@ -1,3 +1,10 @@ +2014-05-27 D. V. Wiebe <ge...@ke...> svn:907 + * src/constant.c (gd_array_len): Added. + * src/constant.c (gd_carray_len): Replaced with a gd_array_len() call and + marked deprecated. + * src/string.c (gd_sarray_len): Deleted. + * man/gd_array_len.3: Renamed from man/gd_carray_len.3 + 2014-05-23 D. V. Wiebe <ge...@ke...> svn:906 * src/field_list.c (gd_sarrays gd_msarrays): Added. * src/close.c (_GD_FreeD) src/entry.c (_GD_FreeE): Free sarray_value_list. Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/NEWS 2014-05-27 21:15:33 UTC (rev 907) @@ -127,7 +127,7 @@ or WINDOW fields no longer results in a segmentation fault. * BUG FIX: Attempts to read past the EOF of a gzipped field no longer results - in an I/O errorr, but successfully returns no data. + in an I/O error, but successfully returns no data. API Changes: @@ -158,6 +158,10 @@ * gd_encoding_support() has been added to permit run-time determination of supported encodings. + * gd_array_len() is the new name for gd_carray_len(). It now also handles + STRING and SARRAY field types. The gd_carray_len() name remains in the + library, but has been marked deprecated. + * 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-23 19:55:31 UTC (rev 906) +++ trunk/getdata/man/Makefile.am 2014-05-27 21:15:33 UTC (rev 907) @@ -25,9 +25,9 @@ dist_man_MANS = checkdirfile.1 dirfile2ascii.1 gd_add.3 gd_add_alias.3 \ gd_add_bit.3 gd_add_spec.3 gd_alias_target.3 gd_aliases.3 \ gd_alter_affixes.3 gd_alter_bit.3 gd_alter_entry.3 \ - 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_alter_protection.3 gd_alter_spec.3 gd_array_len.3 gd_bof.3 \ + gd_bof64.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_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 \ @@ -95,7 +95,8 @@ gd_entry_list.3:gd_field_list.3 gd_entry_list.3:gd_field_list_by_type.3 \ gd_entry_list.3:gd_mfield_list.3 gd_entry_list.3:gd_mfield_list_by_type.3 \ gd_entry_list.3:gd_nmvectore.3 gd_entry_list.3:gd_vector_list.3 \ - gd_frameoffset64.3:gd_alter_frameoffset64.3 + gd_frameoffset64.3:gd_alter_frameoffset64.3 \ + gd_array_len.3:gd_carray_len.3 #man conversion HTMLMANS=$(addsuffix .html,${nodist_man_MANS}) \ Copied: trunk/getdata/man/gd_array_len.3 (from rev 906, trunk/getdata/man/gd_carray_len.3) =================================================================== --- trunk/getdata/man/gd_array_len.3 (rev 0) +++ trunk/getdata/man/gd_array_len.3 2014-05-27 21:15:33 UTC (rev 907) @@ -0,0 +1,91 @@ +.\" gd_array_len.3. The gd_array_len man page. +.\" +.\" Copyright (C) 2010, 2011, 2012, 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_array_len 3 "27 May 2014" "Version 0.9.0" "GETDATA" +.SH NAME +gd_array_len \(em returns the length of a CARRAY or SARRAY field in a dirfile +.SH SYNOPSIS +.B #include <getdata.h> +.HP +.nh +.ad l +.BI "size_t gd_array_len(DIRFILE *" dirfile ", const char *" field_code ); +.hy +.ad n +.SH DESCRIPTION +The +.BR gd_array_len () +function queries a dirfile(5) database specified by +.I dirfile +and returns the number of length of the +.BR CARRAY ", " CONST ", " STRING , +or +.B SARRAY +field called +.IR field_code . +If +.I field_code +contains a valid representation suffix, it will be ignored. + +The +.I dirfile +argument must point to a valid DIRFILE object previously created by a call to +.BR gd_open (3). + +.SH RETURN VALUE +Upon successful completion, +.BR gd_array_len () +returns the array length of the field specified. (The length of a +.B CONST +or a +.B STRING +field is always 1.) On error, it returns zero and sets the dirfile error to a +non-zero error value. Possible error values are: +.TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP +.B GD_E_BAD_CODE +The field specified by +.I field_code +was not found in the database. +.TP +.B GD_E_BAD_DIRFILE +The supplied dirfile was invalid. +.TP +.B GD_E_BAD_FIELD_TYPE +The field specified by +.I field_code +was not of one of the field types listed above. +.TP +.B GD_E_BAD_REPR +The representation suffix specified in +.I field_code +was not recognised. +.PP +The dirfile error may be retrieved by calling +.BR gd_error (3). +A descriptive error string for the last error encountered can be obtained from +a call to +.BR gd_error_string (3). +.SH NOTES +This function used to be called +.BR gd_carray_len (). +This name can still be used, but it has been marked deprecated. +.SH SEE ALSO +.BR dirfile (5), +.BR gd_open (3), +.BR gd_error (3), +.BR gd_error_string (3) Deleted: trunk/getdata/man/gd_carray_len.3 =================================================================== --- trunk/getdata/man/gd_carray_len.3 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/man/gd_carray_len.3 2014-05-27 21:15:33 UTC (rev 907) @@ -1,88 +0,0 @@ -.\" gd_carray_len.3. The gd_carray_len man page. -.\" -.\" Copyright (C) 2010, 2011, 2012 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_carray_len 3 "4 July 2012" "Version 0.8.0" "GETDATA" -.SH NAME -gd_carray_len \(em returns the length of a CARRAY field in a dirfile -.SH SYNOPSIS -.B #include <getdata.h> -.HP -.nh -.ad l -.BI "size_t gd_carray_len(DIRFILE *" dirfile ", const char *" field_code ); -.hy -.ad n -.SH DESCRIPTION -The -.BR gd_carray_len () -function queries a dirfile(5) database specified by -.I dirfile -and returns the number of length of the -.B CONST -or -.B CARRAY -field -.IR field_code . -If -.I field_code -contains a valid representation suffix, it will be ignored. - -The -.I dirfile -argument must point to a valid DIRFILE object previously created by a call to -.BR gd_open (3). - -.SH RETURN VALUE -Upon successful completion, -.BR gd_carray_len () -returns the array length of the field specified. (The length of a -.B CONST -field is always 1.) On error, it returns zero and sets the dirfile error to a -non-zero error value. Possible error values are: -.TP 8 -.B GD_E_ALLOC -The library was unable to allocate memory. -.TP -.B GD_E_BAD_CODE -The field specified by -.I field_code -was not found in the database. -.TP -.B GD_E_BAD_DIRFILE -The supplied dirfile was invalid. -.TP -.B GD_E_BAD_FIELD_TYPE -The field specified by -.I field_code -was not a -.B CONST -or -.BR CARRAY . -.TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised. -.PP -The dirfile error may be retrieved by calling -.BR gd_error (3). -A descriptive error string for the last error encountered can be obtained from -a call to -.BR gd_error_string (3). -.SH SEE ALSO -.BR dirfile (5), -.BR gd_open (3), -.BR gd_error (3), -.BR gd_error_string (3) Modified: trunk/getdata/src/constant.c =================================================================== --- trunk/getdata/src/constant.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/src/constant.c 2014-05-27 21:15:33 UTC (rev 907) @@ -121,11 +121,12 @@ 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 +size_t gd_array_len(DIRFILE *D, const char *field_code_in) gd_nothrow { gd_entry_t *entry; char* field_code; int repr; + size_t len = 0; dtrace("%p, \"%s\"", D, field_code_in); @@ -145,24 +146,28 @@ return 0; } - if (entry->field_type != GD_CARRAY_ENTRY && - entry->field_type != GD_CONST_ENTRY) + if (entry->field_type == GD_CARRAY_ENTRY || + entry->field_type == GD_SARRAY_ENTRY) { + len = entry->EN(scalar,array_len); + } else if (entry->field_type == GD_CONST_ENTRY || + entry->field_type == GD_STRING_ENTRY) + { + len = 1; + } else _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); - } if (field_code != field_code_in) free(field_code); - if (D->error) { - dreturn("%i", 0); - return 0; - } + dreturn("%" PRNsize_t, len); + return len; +} - dreturn("%" PRNsize_t, (entry->field_type == GD_CONST_ENTRY) ? 1 : - entry->EN(scalar,array_len)); - return (entry->field_type == GD_CONST_ENTRY) ? 1 : - entry->EN(scalar,array_len); +/* Deprecated alias */ +size_t gd_carray_len(DIRFILE *D, const char *field_code) gd_nothrow +{ + return gd_array_len(D, field_code); } static int _GD_PutCarraySlice(DIRFILE* D, gd_entry_t *E, int repr, Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/src/getdata.h.in 2014-05-27 21:15:33 UTC (rev 907) @@ -673,9 +673,12 @@ const char *in_field, const char *check_field, gd_windop_t windop, gd_triplet_t threshold) gd_nothrow gd_nonnull((1,2)); -extern size_t gd_carray_len(DIRFILE *dirfile, const char *field_code) gd_nothrow +extern size_t gd_array_len(DIRFILE *dirfile, const char *field_code) gd_nothrow gd_nonnull((1,2)); +extern size_t gd_carray_len(DIRFILE *dirfile, const char *field_code) gd_nothrow +gd_nonnull((1,2)) gd_deprecated; + extern int gd_delete_alias(DIRFILE *dirfile, const char *field_code, unsigned int flags) gd_nothrow gd_nonnull ((1,2)); @@ -941,9 +944,6 @@ unsigned long start, size_t n, const char **data_out) gd_nothrow gd_nonnull((1,2)); -extern size_t gd_sarray_len(DIRFILE *dirfile, const char *field_code) gd_nothrow -gd_nonnull((1,2)); - extern int gd_put_sarray(DIRFILE *dirfile, const char *field_code, const char **data_in) gd_nothrow gd_nonnull((1,2,3)); Modified: trunk/getdata/src/string.c =================================================================== --- trunk/getdata/src/string.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/src/string.c 2014-05-27 21:15:33 UTC (rev 907) @@ -136,41 +136,6 @@ return n_read; } -size_t gd_sarray_len(DIRFILE *D, const char *field_code) gd_nothrow -{ - gd_entry_t *E; - - dtrace("%p, \"%s\"", D, field_code); - - 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", -1); - return -1; - } - - if (E->field_type == GD_STRING_ENTRY) { - dreturn("%i", 1); - return 1; - } else if (E->field_type == GD_SARRAY_ENTRY) { - dreturn("%" PRNsize_t, E->EN(scalar,array_len)); - return E->EN(scalar,array_len); - } - - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); - dreturn("%i", 0); - return 0; -} - static size_t _GD_PutSarraySlice(DIRFILE *restrict D, gd_entry_t *restrict E, unsigned long first, size_t n, const char **data_in) { Modified: trunk/getdata/test/add_carray.c =================================================================== --- trunk/getdata/test/add_carray.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/add_carray.c 2014-05-27 21:15:33 UTC (rev 907) @@ -56,7 +56,7 @@ CHECKI(e.EN(scalar,const_type), GD_UINT8); gd_free_entry_strings(&e); } - n = (int)gd_carray_len(D, "data"); + n = (int)gd_array_len(D, "data"); CHECKI(n, 5); gd_get_carray(D, "data", GD_UINT8, &data); for (n = 0; n < 5; ++n) Modified: trunk/getdata/test/add_sarray.c =================================================================== --- trunk/getdata/test/add_sarray.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/add_sarray.c 2014-05-27 21:15:33 UTC (rev 907) @@ -56,7 +56,7 @@ CHECKI(e.fragment_index, 0); gd_free_entry_strings(&e); } - n = (int)gd_sarray_len(D, "data"); + n = (int)gd_array_len(D, "data"); CHECKI(n, 6); gd_get_sarray(D, "data", data); Modified: trunk/getdata/test/add_sarray_nil.c =================================================================== --- trunk/getdata/test/add_sarray_nil.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/add_sarray_nil.c 2014-05-27 21:15:33 UTC (rev 907) @@ -55,7 +55,7 @@ CHECKI(E.fragment_index, 0); gd_free_entry_strings(&E); } - n = (int)gd_sarray_len(D, "data"); + n = (int)gd_array_len(D, "data"); CHECKI(n, 6); gd_get_sarray(D, "data", data); Modified: trunk/getdata/test/alter_carray_len.c =================================================================== --- trunk/getdata/test/alter_carray_len.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/alter_carray_len.c 2014-05-27 21:15:33 UTC (rev 907) @@ -50,7 +50,7 @@ D = gd_open(filedir, GD_RDWR | GD_VERBOSE); ret = gd_alter_carray(D, "carray", GD_NULL, 5); error = gd_error(D); - z = gd_carray_len(D, "carray"); + z = gd_array_len(D, "carray"); n = gd_get_carray(D, "carray", GD_FLOAT64, &d); gd_discard(D); Modified: trunk/getdata/test/alter_carray_type.c =================================================================== --- trunk/getdata/test/alter_carray_type.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/alter_carray_type.c 2014-05-27 21:15:33 UTC (rev 907) @@ -50,7 +50,7 @@ D = gd_open(filedir, GD_RDWR | GD_VERBOSE); ret = gd_alter_carray(D, "carray", GD_UINT8, 0); error = gd_error(D); - z = gd_carray_len(D, "carray"); + z = gd_array_len(D, "carray"); n = gd_get_carray(D, "carray", GD_FLOAT64, &d); gd_discard(D); Modified: trunk/getdata/test/alter_sarray.c =================================================================== --- trunk/getdata/test/alter_sarray.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/alter_sarray.c 2014-05-27 21:15:33 UTC (rev 907) @@ -53,7 +53,7 @@ CHECKI(error, 0); CHECKI(ret, 0); - z = gd_sarray_len(D, "sarray"); + z = gd_array_len(D, "sarray"); CHECKU(z, 5); n = gd_get_sarray(D, "sarray", d); Modified: trunk/getdata/test/get_carray_len.c =================================================================== --- trunk/getdata/test/get_carray_len.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/get_carray_len.c 2014-05-27 21:15:33 UTC (rev 907) @@ -46,7 +46,7 @@ close(fd); D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); - n = gd_carray_len(D, "carray"); + n = gd_array_len(D, "carray"); error = gd_error(D); gd_discard(D); Modified: trunk/getdata/test/get_sarray_len.c =================================================================== --- trunk/getdata/test/get_sarray_len.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/get_sarray_len.c 2014-05-27 21:15:33 UTC (rev 907) @@ -45,7 +45,7 @@ close(fd); D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); - n = gd_sarray_len(D, "sarray"); + n = gd_array_len(D, "sarray"); error = gd_error(D); CHECKI(error, 0); Modified: trunk/getdata/test/madd_carray.c =================================================================== --- trunk/getdata/test/madd_carray.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/madd_carray.c 2014-05-27 21:15:33 UTC (rev 907) @@ -55,7 +55,7 @@ CHECKI(e.EN(scalar,const_type), GD_UINT8); gd_free_entry_strings(&e); } - n = (int)gd_carray_len(D, "new/data"); + n = (int)gd_array_len(D, "new/data"); CHECKI(n, 5); gd_get_carray(D, "new/data", GD_UINT8, &data); for (n = 0; n < 5; ++n) Modified: trunk/getdata/test/madd_sarray.c =================================================================== --- trunk/getdata/test/madd_sarray.c 2014-05-23 19:55:31 UTC (rev 906) +++ trunk/getdata/test/madd_sarray.c 2014-05-27 21:15:33 UTC (rev 907) @@ -55,7 +55,7 @@ CHECKI(e.field_type, GD_SARRAY_ENTRY); gd_free_entry_strings(&e); } - n = (int)gd_sarray_len(D, "new/data"); + n = (int)gd_array_len(D, "new/data"); CHECKI(n, 6); gd_get_sarray(D, "new/data", data); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-23 19:55:36
|
Revision: 906 http://sourceforge.net/p/getdata/code/906 Author: ketiltrout Date: 2014-05-23 19:55:31 +0000 (Fri, 23 May 2014) Log Message: ----------- Added gd_sarrays and gd_msarrays. Random, minor efficiency improvements. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/src/close.c trunk/getdata/src/encoding.c trunk/getdata/src/entry.c trunk/getdata/src/field_list.c trunk/getdata/src/getdata.h.in trunk/getdata/src/include.c trunk/getdata/src/internal.h trunk/getdata/src/open.c trunk/getdata/src/zzslim.c trunk/getdata/test/Makefile.am Added Paths: ----------- trunk/getdata/test/svlist_array.c trunk/getdata/test/svlist_array_meta.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/ChangeLog 2014-05-23 19:55:31 UTC (rev 906) @@ -1,3 +1,15 @@ +2014-05-23 D. V. Wiebe <ge...@ke...> svn:906 + * src/field_list.c (gd_sarrays gd_msarrays): Added. + * src/close.c (_GD_FreeD) src/entry.c (_GD_FreeE): Free sarray_value_list. + * test/svlist_array.c test/svlist_array_meta.c: Added. + + * src/field_list.c (gd_mstrings): Don't use realloc to skip the unnecessary + potential memcpy. + + * src/include.c (_GD_SetFieldAffixes) src/open.c (_GD_CreateDirfile) + src/zzslim.c (_GD_ZzslimName): Use sprintf instead of convolutions of strcpy + and strcat for efficiency's sake. + 2014-05-22 D. V. Wiebe <ge...@ke...> svn:905 * src/slim.c (_GD_SlimOpen _GD_SlimSize): Disable the slimdopen and slimdrawsize stuff to avoid a slimlib bug. Modified: trunk/getdata/src/close.c =================================================================== --- trunk/getdata/src/close.c 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/close.c 2014-05-23 19:55:31 UTC (rev 906) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2012 D. V. Wiebe +/* Copyright (C) 2008-2012, 2014 D. V. Wiebe * *************************************************************************** * @@ -53,10 +53,19 @@ free(D->entry_list[j]); free(D->string_value_list); free(D->const_value_list); - if (D->carray_value_list) + + if (D->carray_value_list) { for (i = 0; D->carray_value_list[i].n != 0; ++i) free(D->carray_value_list[i].d); - free(D->carray_value_list); + free(D->carray_value_list); + } + + if (D->sarray_value_list) { + for (i = 0; D->sarray_value_list[i] != NULL; ++i) + free(D->sarray_value_list[i]); + free(D->sarray_value_list); + } + free(D->fragment); free(D->name); for (i = 0; i < D->ndir; ++i) Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/encoding.c 2014-05-23 19:55:31 UTC (rev 906) @@ -239,6 +239,7 @@ } #endif +#define GETDATA_MODULEPREFIX GETDATA_MODULEDIR "/libgetdata" int _GD_MissingFramework(int encoding, unsigned int funcs) { int ret; @@ -267,10 +268,13 @@ return 1; } - strcat(strcat(strcpy(library, GETDATA_MODULEDIR "/libgetdata"), - _GD_ef[encoding].affix), "-" PACKAGE_VERSION); - library[sizeof(GETDATA_MODULEDIR) + 10] -= 'A' - 'a'; + sprintf(library, GETDATA_MODULEPREFIX "%s-" PACKAGE_VERSION, + _GD_ef[encoding].affix); + /* affix starts with a capital letter, we need to lowercasify it -- + * also, sizeof includes the trailing NUL in its count */ + library[sizeof(GETDATA_MODULEPREFIX) - 1] -= 'A' - 'a'; + /* open */ if ((lib = lt_dlopenext(library)) == NULL) { /* if that didn't work, look for it in the search path */ @@ -643,7 +647,7 @@ if (!candidate) continue; - strcat(strcpy(candidate, name), _GD_ef[i].ext); + sprintf(candidate, "%s%s", name, _GD_ef[i].ext); } else { if (_GD_MissingFramework(i, GD_EF_NAME)) continue; @@ -733,8 +737,8 @@ return -1; } - strcat(strcpy(file->name, base), temp ? "_XXXXXX" : - _GD_ef[file->subenc].ext); + sprintf(file->name, "%s%s", base, + temp ? "_XXXXXX" : _GD_ef[file->subenc].ext); } dreturn("%i (%s)", 0, file->name); Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/entry.c 2014-05-23 19:55:31 UTC (rev 906) @@ -127,10 +127,19 @@ free(entry->e->entry_list[i]); free(entry->e->string_value_list); free(entry->e->const_value_list); - if (entry->e->carray_value_list) + + if (entry->e->carray_value_list) { for (i = 0; entry->e->carray_value_list[i].n != 0; ++i) free(entry->e->carray_value_list[i].d); - free(entry->e->carray_value_list); + free(entry->e->carray_value_list); + } + + if (entry->e->sarray_value_list) { + for (i = 0; entry->e->sarray_value_list[i] != NULL; ++i) + free(entry->e->sarray_value_list[i]); + free(entry->e->sarray_value_list); + } + if (entry->e->n_meta > -1) free(entry->e->p.meta_entry); free(entry->e); Modified: trunk/getdata/src/field_list.c =================================================================== --- trunk/getdata/src/field_list.c 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/field_list.c 2014-05-23 19:55:31 UTC (rev 906) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2013 D. V. Wiebe +/* Copyright (C) 2008-2014 D. V. Wiebe * *************************************************************************** * @@ -209,7 +209,7 @@ return zero_list; } - el = (char **)_GD_Malloc(D, sizeof(const char*) * (n + 1)); + el = _GD_Malloc(D, sizeof(*el) * (n + 1)); if (el == NULL) { dreturn("%p", NULL); @@ -338,7 +338,7 @@ return zero_carrays; } - fl = (gd_carray_t *)_GD_Malloc(D, sizeof(gd_carray_t) * (n + 1)); + fl = _GD_Malloc(D, sizeof(*fl) * (n + 1)); if (fl == NULL) { dreturn("%p", NULL); @@ -395,7 +395,7 @@ return D->string_value_list; } - fl = (char **)_GD_Malloc(D, sizeof(const char*) * (n + 1)); + fl = _GD_Malloc(D, sizeof(*fl) * (n + 1)); if (fl == NULL) { dreturn("%p", NULL); @@ -538,7 +538,7 @@ return zero_carrays; } - fl = (gd_carray_t *)_GD_Malloc(D, sizeof(gd_carray_t) * (n + 1)); + fl = _GD_Malloc(D, sizeof(*fl) * (n + 1)); if (fl == NULL) { dreturn("%p", NULL); @@ -603,8 +603,7 @@ return zero_list; } - fl = (char **)_GD_Realloc(D, (char **)e->string_value_list, - sizeof(const char*) * (n + 1)); + fl = _GD_Malloc(D, sizeof(*fl) * (n + 1)); if (fl == NULL) { dreturn("%p", NULL); @@ -616,6 +615,7 @@ fl[n++] = e->p.meta_entry[i]->e->u.string; fl[n] = NULL; + free(e->string_value_list); e->string_value_list = (const char **)fl; dreturn("%p", e->string_value_list); @@ -652,3 +652,125 @@ dreturn("%p", el); return el; } + +const char ***gd_sarrays(DIRFILE* D) gd_nothrow +{ + unsigned int i, n; + const char ***fl; + + dtrace("%p", D); + + if (D->flags & GD_INVALID) { + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%p", NULL); + return NULL; + } + + _GD_ClearError(D); + + if ((n = _GD_NEntries(D, NULL, GD_SARRAY_ENTRY, 0)) == 0) { + dreturn("%p", zero_list); + return (const char ***)zero_list; + } + + if (D->value_list_validity & GD_LIST_VALID_SARRAY_VALUE) { + /* list already made */ + dreturn("%p", D->sarray_value_list); + return D->sarray_value_list; + } + + fl = _GD_Malloc(D, sizeof(*fl) * (n + 1)); + + if (fl == NULL) { + dreturn("%p", NULL); + return NULL; + } + + for (i = n = 0; i < D->n_entries; ++i) { + if (_GD_ListEntry(D->entry[i], 0, 0, 0, 0, GD_SARRAY_ENTRY)) { + /* We do it this way so we can append a NULL */ + fl[n] = _GD_Malloc(D, + sizeof(**fl) * (D->entry[i]->EN(scalar,array_len) + 1)); + if (fl[n] == NULL) { + dreturn("%p", NULL); + return NULL; + } + + memcpy(fl[n], D->entry[i]->e->u.scalar.d, + sizeof(char*) * D->entry[i]->EN(scalar,array_len)); + fl[n++][D->entry[i]->EN(scalar,array_len)] = NULL; + } + } + fl[n] = NULL; + + free(D->sarray_value_list); + D->sarray_value_list = fl; + D->value_list_validity |= GD_LIST_VALID_SARRAY_VALUE; + + dreturn("%p", D->sarray_value_list); + return D->sarray_value_list; +} + +const char ***gd_msarrays(DIRFILE* D, const char* parent) gd_nothrow +{ + int i, n; + const char ***fl; + gd_entry_t *P; + struct gd_private_entry_ *e; + + dtrace("%p, \"%s\"", D, parent); + + if (D->flags & GD_INVALID) { + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%p", NULL); + return NULL; + } + + _GD_ClearError(D); + + P = _GD_FindField(D, parent, D->entry, D->n_entries, 1, NULL); + + if (P == NULL || P->e->n_meta == -1) { + _GD_SetError(D, GD_E_BAD_CODE, P ? GD_E_CODE_INVALID : GD_E_CODE_MISSING, + NULL, 0, parent); + dreturn("%p", NULL); + return NULL; + } + + e = P->e; + + if ((n = gd_nmfields_by_type(D, parent, GD_SARRAY_ENTRY)) == 0) { + dreturn("%p", zero_list); + return (const char***)zero_list; + } + + fl = _GD_Malloc(D, sizeof(*fl) * (n + 1)); + + if (fl == NULL) { + dreturn("%p", NULL); + return NULL; + } + + for (i = n = 0; i < e->n_meta; ++i) { + if (_GD_ListEntry(e->p.meta_entry[i], 1, 0, 0, 0, GD_SARRAY_ENTRY)) { + /* We do it this way so we can append a NULL */ + fl[n] = _GD_Malloc(D, + sizeof(**fl) * (e->p.meta_entry[i]->EN(scalar,array_len) + 1)); + if (fl[n] == NULL) { + dreturn("%p", NULL); + return NULL; + } + + memcpy(fl[n], e->p.meta_entry[i]->e->u.scalar.d, + sizeof(char*) * e->p.meta_entry[i]->EN(scalar,array_len)); + fl[n++][e->p.meta_entry[i]->EN(scalar,array_len)] = NULL; + } + } + fl[n] = NULL; + + free(e->sarray_value_list); + e->sarray_value_list = fl; + + dreturn("%p", e->sarray_value_list); + return e->sarray_value_list; +} Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/getdata.h.in 2014-05-23 19:55:31 UTC (rev 906) @@ -573,7 +573,7 @@ const char *in_field, double dividend, int fragment_index) gd_nothrow gd_nonnull ((1,2,3)); -extern int gd_add_sarray(DIRFILE *dirfile, const char* field_code, +extern int gd_add_sarray(DIRFILE *dirfile, const char *field_code, size_t array_len, const char **values, int fragment_index) gd_nothrow gd_nonnull ((1,2,4)); @@ -659,7 +659,7 @@ extern int gd_alter_recip(DIRFILE *dirfile, const char *field_code, const char *in_field, double cdividend) gd_nothrow gd_nonnull((1,2)); -extern int gd_alter_sarray(DIRFILE* D, const char* field_code, +extern int gd_alter_sarray(DIRFILE *dirfile, const char *field_code, size_t array_len) gd_nothrow gd_nonnull((1,2)); extern int gd_alter_sbit(DIRFILE *dirfile, const char *field_code, @@ -718,8 +718,8 @@ extern int gd_entry(DIRFILE *dirfile, const char *field_code, gd_entry_t *entry) gd_nothrow gd_nonnull ((1, 2)); -extern const char **gd_entry_list(DIRFILE* D, const char *parent, int type, - unsigned int flags) gd_nothrow gd_nonnull ((1)); +extern const char **gd_entry_list(DIRFILE *dirfile, const char *parent, + int type, unsigned int flags) gd_nothrow gd_nonnull ((1)); extern gd_entype_t gd_entry_type(DIRFILE *dirfile, const char *field_code) gd_nothrow gd_nonnull ((1)); @@ -878,6 +878,9 @@ extern void gd_mplex_lookback(DIRFILE *dirfile, int lookback) gd_nothrow gd_nonnull((1)); +extern const char ***gd_msarrays(DIRFILE *dirfile, + const char *parent) gd_nothrow gd_nonnull ((1,2)); + extern const char **gd_mstrings(DIRFILE *dirfile, const char *parent) gd_nothrow gd_nonnull((1,2)); @@ -957,6 +960,8 @@ extern size_t gd_put_string(DIRFILE *dirfile, const char *field_code, const char *data) gd_nothrow gd_nonnull ((1, 2, 3)); +const char ***gd_sarrays(DIRFILE *dirfile) gd_nothrow gd_nonnull ((1)); + extern const char **gd_strings(DIRFILE *dirfile) gd_nothrow gd_nonnull ((1)); extern char *gd_strtok(DIRFILE *D, const char *string) gd_nothrow Modified: trunk/getdata/src/include.c =================================================================== --- trunk/getdata/src/include.c 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/include.c 2014-05-23 19:55:31 UTC (rev 906) @@ -45,7 +45,7 @@ *suffix = (char*)_GD_Malloc(D, strlen(D->fragment[me].suffix) + strlen(suffix_in) + 1); if (*suffix) - strcat(strcpy(*suffix, suffix_in), D->fragment[me].suffix); + sprintf(*suffix, "%s%s", suffix_in, D->fragment[me].suffix); } } else if (D->fragment[me].suffix) *suffix = _GD_Strdup(D, D->fragment[me].suffix); @@ -71,7 +71,7 @@ *prefix = (char*)_GD_Malloc(D, strlen(D->fragment[me].prefix) + strlen(prefix_in) + 1); if (*prefix) - strcat(strcpy(*prefix, D->fragment[me].prefix), prefix_in); + sprintf(*prefix, "%s%s", D->fragment[me].prefix, prefix_in); } } else if (D->fragment[me].prefix) *prefix = _GD_Strdup(D, D->fragment[me].prefix); Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/internal.h 2014-05-23 19:55:31 UTC (rev 906) @@ -823,6 +823,7 @@ #define GD_N_ENTRY_LISTS (GD_N_ENTYPES + 4) #define GD_LIST_VALID_STRING_VALUE 0x01 +#define GD_LIST_VALID_SARRAY_VALUE 0x02 /* database metadata update data for a field rename */ struct gd_rename_data_ { @@ -868,7 +869,8 @@ const char **alias_list; const char **entry_list[GD_N_ENTRY_LISTS]; unsigned int entry_list_flags[GD_N_ENTRY_LISTS]; - const char** string_value_list; + const char **string_value_list; + const char ***sarray_value_list; void *const_value_list; gd_carray_t *carray_value_list; uint32_t value_list_validity; @@ -1084,6 +1086,7 @@ const char **entry_list[GD_N_ENTRY_LISTS]; unsigned int entry_list_flags[GD_N_ENTRY_LISTS]; const char **string_value_list; + const char ***sarray_value_list; void *const_value_list; gd_carray_t *carray_value_list; uint32_t value_list_validity; Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/open.c 2014-05-23 19:55:31 UTC (rev 906) @@ -343,7 +343,7 @@ (format_trunc ? O_TRUNC : O_EXCL), 0666)) < 0) { char *format_file = (char *)malloc(strlen(dirfile) + 8); - strcat(strcpy(format_file, dirfile), "/format"); + sprintf(dirfile, "%s/format", dirfile); _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_FORMAT, format_file, errno, NULL); free(dirfile); free(format_file); @@ -363,7 +363,7 @@ /* associate a stream with the format file */ if ((fp = fdopen(fd, "rb")) == NULL) { char *format_file = (char *)malloc(strlen(dirfile) + 8); - strcat(strcpy(format_file, dirfile), "/format"); + sprintf(dirfile, "%s/format", dirfile); _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_FORMAT, format_file, errno, NULL); free(dirfile); free(format_file); Modified: trunk/getdata/src/zzslim.c =================================================================== --- trunk/getdata/src/zzslim.c 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/src/zzslim.c 2014-05-23 19:55:31 UTC (rev 906) @@ -67,7 +67,7 @@ strcpy(file->name, enc_data); file->name[enc_len] = '/'; - strcat(strcpy(file->name + enc_len + 1, base), ".slm"); + sprintf(file->name + enc_len + 1, "%s.slm", base); } dreturn("%i (%s)", 0, file->name); Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/test 2014-05-23 19:55:31 UTC (rev 906) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -1095,6 +1095,8 ## svlist svlist0 svlist2 +svlist_array +svlist_array_meta svlist_hidden svlist_invalid svlist_meta Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-05-22 21:39:16 UTC (rev 905) +++ trunk/getdata/test/Makefile.am 2014-05-23 19:55:31 UTC (rev 906) @@ -373,7 +373,8 @@ SLIM_TESTS=slim_get slim_nframes -SVLIST_TESTS=svlist svlist0 svlist2 svlist_hidden svlist_invalid svlist_meta \ +SVLIST_TESTS=svlist svlist0 svlist2 svlist_array svlist_array_meta \ + svlist_hidden svlist_invalid svlist_meta \ svlist_meta0 svlist_meta_hidden svlist_meta_invalid SPF_TESTS=spf_alias spf_alias_missing spf_alias_meta spf_divide spf_lincom \ Added: trunk/getdata/test/svlist_array.c =================================================================== --- trunk/getdata/test/svlist_array.c (rev 0) +++ trunk/getdata/test/svlist_array.c 2014-05-23 19:55:31 UTC (rev 906) @@ -0,0 +1,78 @@ +/* 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" + +int main(void) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *format_data = + "data1 SARRAY one two\n" + "data2 SARRAY three four five\n" + "data3 STRING six\n" + "data4 CONST UINT8 1\n"; + int fd, i, j, error, r = 0; + const char ***l; + const char *d1[] = {"one", "two"}; + const char *d2[] = {"three", "four", "five"}; + const char **d[] = {d1, d2}; + const int n[] = {2, 3}; + 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); + l = gd_sarrays(D); + + error = gd_error(D); + CHECKI(error, 0); + CHECKPN(l); + + for (i = 0; l[i]; ++i) { + if (i >= 2) { + i++; + break; + } + + for (j = 0; l[i][j]; ++j) { + if (j >= n[i]) { + j++; + break; + } + + CHECKSi(i * 1000 + j, l[i][j], d[i][j]); + } + CHECKIi(i,j,n[i]); + } + + CHECKI(i,2); + + gd_discard(D); + unlink(format); + rmdir(filedir); + + return r; +} Added: trunk/getdata/test/svlist_array_meta.c =================================================================== --- trunk/getdata/test/svlist_array_meta.c (rev 0) +++ trunk/getdata/test/svlist_array_meta.c 2014-05-23 19:55:31 UTC (rev 906) @@ -0,0 +1,78 @@ +/* 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" + +int main(void) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *format_data = + "parent SARRAY alfa bravo charlie\n" + "parent/data1 SARRAY alpha beta gamma\n" + "parent/data2 SARRAY aleph bet gimel\n" + "parent/data3 SARRAY alif ba' gim\n"; + int fd, i, j, error, r = 0; + const char ***l; + const char *d1[] = {"alpha", "beta", "gamma"}; + const char *d2[] = {"aleph", "bet", "gimel"}; + const char *d3[] = {"alif", "ba'", "gim"}; + const char **d[] = {d1, d2, d3}; + 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); + l = gd_msarrays(D, "parent"); + + error = gd_error(D); + CHECKI(error, 0); + CHECKPN(l); + + for (i = 0; l[i]; ++i) { + if (i >= 3) { + i++; + break; + } + + for (j = 0; l[i][j]; ++j) { + if (j >= 3) { + j++; + break; + } + + CHECKSi(i * 1000 + j, l[i][j], d[i][j]); + } + CHECKIi(i,j,3); + } + + CHECKI(i,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-05-22 21:39:20
|
Revision: 905 http://sourceforge.net/p/getdata/code/905 Author: ketiltrout Date: 2014-05-22 21:39:16 +0000 (Thu, 22 May 2014) Log Message: ----------- Disable the slimdopen stuff to avoid a libslim bug (that might be my fault). Some re-arrangement to get modules working again. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/src/bzip.c trunk/getdata/src/debug.c trunk/getdata/src/encoding.c trunk/getdata/src/getdata.h.in trunk/getdata/src/gzip.c trunk/getdata/src/lzma.c trunk/getdata/src/slim.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/ChangeLog 2014-05-22 21:39:16 UTC (rev 905) @@ -1,3 +1,13 @@ +2014-05-22 D. V. Wiebe <ge...@ke...> svn:905 + * src/slim.c (_GD_SlimOpen _GD_SlimSize): Disable the slimdopen and + slimdrawsize stuff to avoid a slimlib bug. + + * src/bzip.c src/lzma.c: Re-order some functions to get modules working + again. + + * src/encoding.c (_GD_InitialiseFramework): Don't try to lock the mutex if + it's not needed. + 2014-05-19 D. V. Wiebe <ge...@ke...> svn:904 * src/lzma.c: Rewritten with better understanding of liblzma. Includes write support. @@ -13,6 +23,10 @@ * src/bzip.c: Remove unnecessary .write member. +2014-05-10 D. V. Wiebe <ge...@ke...> svn:903 + * src/slim.c (_GD_SlimOpen _GD_SlimSize): Use slimdopen and slimdrawsize if + available to reduce race conditions. + 2014-05-06 D. V. Wiebe <ge...@ke...> svn:901 * src/encoding.c: Add bzip2 OOP write support. * src/bzip.c (_GD_Bzip2DoOpen _GD_Bzip2Open _GD_Bzip2Seek _GD_Bzip2Close Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/src/bzip.c 2014-05-22 21:39:16 UTC (rev 905) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2011 D. V. Wiebe +/* Copyright (C) 2008-2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -136,6 +136,90 @@ return 0; } +ssize_t _GD_Bzip2Read(struct gd_raw_file_ *restrict file, void *restrict data, + gd_type_t data_type, size_t nmemb) +{ + char* output = (char*)data; + struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; + unsigned long long nbytes = nmemb * GD_SIZE(data_type); + + dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); + + while (nbytes > (unsigned long long)(ptr->end - ptr->pos)) { + int n; + + memcpy(output, ptr->data + ptr->pos, ptr->end - ptr->pos); + output += ptr->end - ptr->pos; + nbytes -= ptr->end - ptr->pos; + ptr->pos = ptr->end; + + if (ptr->stream_end) { + dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); + return nmemb - nbytes / GD_SIZE(data_type); + } + + ptr->bzerror = 0; + n = BZ2_bzRead(&ptr->bzerror, ptr->bzfile, ptr->data, + GD_BZIP_BUFFER_SIZE); + + if (ptr->bzerror == BZ_OK || ptr->bzerror == BZ_STREAM_END) { + ptr->base += ptr->end; + ptr->pos = 0; + ptr->end = n; + } else { + dreturn("%i", -1); + return -1; + } + + /* eof */ + if (ptr->bzerror != BZ_OK) { + ptr->stream_end = 1; + break; + } + } + + if (nbytes > (unsigned long long)(ptr->end - ptr->pos)) { + memcpy(output, ptr->data + ptr->pos, ptr->end - ptr->pos); + ptr->pos = ptr->end; + nbytes -= ptr->end; + } else { + memcpy(output, ptr->data + ptr->pos, nbytes); + ptr->pos += nbytes; + nbytes = 0; + } + + file->pos = (ptr->base + ptr->pos) / GD_SIZE(data_type); + + dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); + return nmemb - nbytes / GD_SIZE(data_type); +} + +ssize_t _GD_Bzip2Write(struct gd_raw_file_ *file, const void *data, + gd_type_t data_type, size_t nmemb) +{ + struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; + ssize_t n; + + dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); + + n = GD_SIZE(data_type) * nmemb; + if (n > INT_MAX) + n = INT_MAX; + + BZ2_bzWrite(&ptr->bzerror, ptr->bzfile, (void*)data, (int)n); + + if (ptr->bzerror) + n = -1; + else { + ptr->base += n; + n /= GD_SIZE(data_type); + file->pos += n; + } + + dreturn("%" PRNssize_t, n); + return n; +} + off64_t _GD_Bzip2Seek(struct gd_raw_file_* file, off64_t count, gd_type_t data_type, unsigned int mode) { @@ -223,90 +307,6 @@ return file->pos;; } -ssize_t _GD_Bzip2Read(struct gd_raw_file_ *restrict file, void *restrict data, - gd_type_t data_type, size_t nmemb) -{ - char* output = (char*)data; - struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; - unsigned long long nbytes = nmemb * GD_SIZE(data_type); - - dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); - - while (nbytes > (unsigned long long)(ptr->end - ptr->pos)) { - int n; - - memcpy(output, ptr->data + ptr->pos, ptr->end - ptr->pos); - output += ptr->end - ptr->pos; - nbytes -= ptr->end - ptr->pos; - ptr->pos = ptr->end; - - if (ptr->stream_end) { - dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); - return nmemb - nbytes / GD_SIZE(data_type); - } - - ptr->bzerror = 0; - n = BZ2_bzRead(&ptr->bzerror, ptr->bzfile, ptr->data, - GD_BZIP_BUFFER_SIZE); - - if (ptr->bzerror == BZ_OK || ptr->bzerror == BZ_STREAM_END) { - ptr->base += ptr->end; - ptr->pos = 0; - ptr->end = n; - } else { - dreturn("%i", -1); - return -1; - } - - /* eof */ - if (ptr->bzerror != BZ_OK) { - ptr->stream_end = 1; - break; - } - } - - if (nbytes > (unsigned long long)(ptr->end - ptr->pos)) { - memcpy(output, ptr->data + ptr->pos, ptr->end - ptr->pos); - ptr->pos = ptr->end; - nbytes -= ptr->end; - } else { - memcpy(output, ptr->data + ptr->pos, nbytes); - ptr->pos += nbytes; - nbytes = 0; - } - - file->pos = (ptr->base + ptr->pos) / GD_SIZE(data_type); - - dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); - return nmemb - nbytes / GD_SIZE(data_type); -} - -ssize_t _GD_Bzip2Write(struct gd_raw_file_ *file, const void *data, - gd_type_t data_type, size_t nmemb) -{ - struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; - ssize_t n; - - dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); - - n = GD_SIZE(data_type) * nmemb; - if (n > INT_MAX) - n = INT_MAX; - - BZ2_bzWrite(&ptr->bzerror, ptr->bzfile, (void*)data, (int)n); - - if (ptr->bzerror) - n = -1; - else { - ptr->base += n; - n /= GD_SIZE(data_type); - file->pos += n; - } - - dreturn("%" PRNssize_t, n); - return n; -} - /* This function does nothing */ int _GD_Bzip2Sync(struct gd_raw_file_ *file gd_unused_) { Modified: trunk/getdata/src/debug.c =================================================================== --- trunk/getdata/src/debug.c 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/src/debug.c 2014-05-22 21:39:16 UTC (rev 905) @@ -40,7 +40,7 @@ const char* gd_colsub(void) { static char buffer[GD_COL_SIZE + 1]; - strcpy(buffer, gd_colnil()); + strcpy(buffer, gd_debug_col); if (gd_col_count > 0) gd_debug_col[--gd_col_count] = '\0'; Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/src/encoding.c 2014-05-22 21:39:16 UTC (rev 905) @@ -195,16 +195,20 @@ void _GD_InitialiseFramework(void) { dtracevoid(); + #ifdef USE_MODULES #ifdef USE_PTHREAD - pthread_mutex_lock(&gd_mutex_); + if (!framework_initialised) { + pthread_mutex_lock(&gd_mutex_); #endif - if (!framework_initialised) { - framework_initialised = 1; - lt_dlinit(); + /* check again */ + if (!framework_initialised) { + framework_initialised = 1; + lt_dlinit(); + } +#ifdef USE_PTHREAD + pthread_mutex_unlock(&gd_mutex_); } -#ifdef USE_PTHREAD - pthread_mutex_unlock(&gd_mutex_); #endif #endif dreturnvoid(); Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/src/getdata.h.in 2014-05-22 21:39:16 UTC (rev 905) @@ -246,7 +246,7 @@ } gd_entype_t; /* GD_NO_ENTRY and GD_ALIAS_ENTRY are not part of this count */ -#define GD_N_ENTYPES 16 +#define GD_N_ENTYPES 19 /* Special types for gd_nentries(3) and gd_entry_list(3) */ #define GD_ALL_ENTRIES 0 Modified: trunk/getdata/src/gzip.c =================================================================== --- trunk/getdata/src/gzip.c 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/src/gzip.c 2014-05-22 21:39:16 UTC (rev 905) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2011 D. V. Wiebe +/* Copyright (C) 2008-2011, 2014 D. V. Wiebe * *************************************************************************** * Modified: trunk/getdata/src/lzma.c =================================================================== --- trunk/getdata/src/lzma.c 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/src/lzma.c 2014-05-22 21:39:16 UTC (rev 905) @@ -28,6 +28,8 @@ #define _GD_LzmaOpen libgetdatalzma_LTX_GD_LzmaOpen #define _GD_LzmaSeek libgetdatalzma_LTX_GD_LzmaSeek #define _GD_LzmaRead libgetdatalzma_LTX_GD_LzmaRead +#define _GD_LzmaWrite libgetdatalzma_LTX_GD_LzmaWrite +#define _GD_LzmaSync libgetdatalzma_LTX_GD_LzmaSync #define _GD_LzmaClose libgetdatalzma_LTX_GD_LzmaClose #define _GD_LzmaSize libgetdatalzma_LTX_GD_LzmaSize #endif @@ -222,6 +224,66 @@ dreturnvoid(); } +/* flush the output buffer to the stream */ +static int _GD_LzmaFlush(struct gd_lzmadata *lzd) +{ + uint8_t *ptr; + + dtrace("%p", lzd); + + ptr = lzd->data_out; + while (NOUT(*lzd) > 0) { + ssize_t nw = fwrite(ptr, 1, NOUT(*lzd), lzd->stream); + if (nw == 0 && ferror(lzd->stream)) { + dreturn("%i", 1); + return 1; + } + + ptr += nw; + lzd->xz.avail_out += nw; + } + + /* reset output buffer */ + lzd->xz.next_out = lzd->data_out; + + dreturn("%i", 0); + return 0; +} + +ssize_t _GD_LzmaWrite(struct gd_raw_file_ *file, const void *data, + gd_type_t data_type, size_t nmemb) +{ + lzma_ret e; + size_t n; + struct gd_lzmadata *lzd = (struct gd_lzmadata *)file->edata; + + dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); + + n = nmemb * GD_SIZE(data_type); + + /* We let liblzma read directly from the caller's buffer */ + lzd->xz.next_in = data; + lzd->xz.avail_in = n; + + /* code */ + while (lzd->xz.avail_in > 0) { + e = lzma_code(&lzd->xz, LZMA_RUN); + if (e != LZMA_OK) { + dreturn("%i", -1); + return -1; + } + + if (_GD_LzmaFlush(lzd)) { + dreturn("%i", -1); + return -1; + } + } + + /* we always write all the input, if successful */ + dreturn("%" PRNssize_t, (ssize_t)nmemb); + return nmemb; +} + off64_t _GD_LzmaSeek(struct gd_raw_file_* file, off64_t count, gd_type_t data_type, unsigned int mode) { @@ -356,66 +418,6 @@ return nread; } -/* flush the output buffer to the stream */ -static int _GD_LzmaFlush(struct gd_lzmadata *lzd) -{ - uint8_t *ptr; - - dtrace("%p", lzd); - - ptr = lzd->data_out; - while (NOUT(*lzd) > 0) { - ssize_t nw = fwrite(ptr, 1, NOUT(*lzd), lzd->stream); - if (nw == 0 && ferror(lzd->stream)) { - dreturn("%i", 1); - return 1; - } - - ptr += nw; - lzd->xz.avail_out += nw; - } - - /* reset output buffer */ - lzd->xz.next_out = lzd->data_out; - - dreturn("%i", 0); - return 0; -} - -ssize_t _GD_LzmaWrite(struct gd_raw_file_ *file, const void *data, - gd_type_t data_type, size_t nmemb) -{ - lzma_ret e; - size_t n; - struct gd_lzmadata *lzd = (struct gd_lzmadata *)file->edata; - - dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); - - n = nmemb * GD_SIZE(data_type); - - /* We let liblzma read directly from the caller's buffer */ - lzd->xz.next_in = data; - lzd->xz.avail_in = n; - - /* code */ - while (lzd->xz.avail_in > 0) { - e = lzma_code(&lzd->xz, LZMA_RUN); - if (e != LZMA_OK) { - dreturn("%i", -1); - return -1; - } - - if (_GD_LzmaFlush(lzd)) { - dreturn("%i", -1); - return -1; - } - } - - /* we always write all the input, if successful */ - dreturn("%" PRNssize_t, (ssize_t)nmemb); - return nmemb; -} - int _GD_LzmaClose(struct gd_raw_file_ *file) { lzma_ret e; Modified: trunk/getdata/src/slim.c =================================================================== --- trunk/getdata/src/slim.c 2014-05-19 19:46:21 UTC (rev 904) +++ trunk/getdata/src/slim.c 2014-05-22 21:39:16 UTC (rev 905) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008, 2010, 2011 D. V. Wiebe +/* Copyright (C) 2008, 2010, 2011, 2014 D. V. Wiebe * *************************************************************************** * @@ -40,7 +40,10 @@ { dtrace("%i, %p, <unused>, <unused>", dirfd, file); -#ifdef HAVE_SLIMDOPEN + /* slimdopen in slimlib-2.6.7 and earlier contains a bug resulting in a SEGV, + * so disable this for now */ +#if 0 + /* #ifdef HAVE_SLIMDOPEN */ { int fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); if (fd < 0) { @@ -138,7 +141,10 @@ dtrace("%i, %p, 0x%X", dirfd, file, data_type); -#ifdef HAVE_SLIMDRAWSIZE + /* slimdrawsize in slimlib-2.6.7 and earlier contains a bug resulting in a + * SEGV, so disable this for now */ +#if 0 + /* #ifdef HAVE_SLIMDRAWSIZE */ { int fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); if (fd < 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-19 19:46:25
|
Revision: 904 http://sourceforge.net/p/getdata/code/904 Author: ketiltrout Date: 2014-05-19 19:46:21 +0000 (Mon, 19 May 2014) Log Message: ----------- LZMA write support and bug fixing. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/src/bzip.c trunk/getdata/src/encoding.c trunk/getdata/src/internal.h trunk/getdata/src/lzma.c trunk/getdata/src/raw.c trunk/getdata/test/Makefile.am trunk/getdata/test/encode_support.c Added Paths: ----------- trunk/getdata/test/lzma_put.c trunk/getdata/test/lzma_xz_add.c trunk/getdata/test/lzma_xz_get.c trunk/getdata/test/lzma_xz_get_far.c trunk/getdata/test/lzma_xz_get_get.c trunk/getdata/test/lzma_xz_get_get2.c trunk/getdata/test/lzma_xz_get_put.c trunk/getdata/test/lzma_xz_move_to.c trunk/getdata/test/lzma_xz_nframes.c trunk/getdata/test/lzma_xz_put.c trunk/getdata/test/lzma_xz_put_back.c trunk/getdata/test/lzma_xz_put_endian.c trunk/getdata/test/lzma_xz_put_get.c trunk/getdata/test/lzma_xz_put_pad.c trunk/getdata/test/lzma_xz_sync.c Removed Paths: ------------- trunk/getdata/test/xz_get.c trunk/getdata/test/xz_nframes.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/ChangeLog 2014-05-19 19:46:21 UTC (rev 904) @@ -1,3 +1,18 @@ +2014-05-19 D. V. Wiebe <ge...@ke...> svn:904 + * src/lzma.c: Rewritten with better understanding of liblzma. Includes + write support. + * src/encoding.c: LZMA write support. + * test/lzma_xz_get_get.c test/lzma_xz_get_get2.c test/lzma_xz_put.c + test/lzma_xz_get_put.c test/lzma_xz_add.c test/lzma_xz_sync.c + test/lzma_xz_move_to.c test/lzma_put.c test/lzma_xz_get_far.c + test/lzma_xz_put_pad.c test/lzma_xz_put_endian.c test/lzma_xz_put_back.c + test/lzma_xz_put_get.c: Added. + * test/lzma_xz_get.c test/lzma_xz_nframes.c: Renamed from + xz_{get|nframes}.c. + * test/encode_support.c: Update for LZMA writes. + + * src/bzip.c: Remove unnecessary .write member. + 2014-05-06 D. V. Wiebe <ge...@ke...> svn:901 * src/encoding.c: Add bzip2 OOP write support. * src/bzip.c (_GD_Bzip2DoOpen _GD_Bzip2Open _GD_Bzip2Seek _GD_Bzip2Close Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/NEWS 2014-05-19 19:46:21 UTC (rev 904) @@ -24,10 +24,16 @@ indicates something pathological happening.) The GD_MAX_CARRAY_LENGTH symbol has been removed from the GetData header file. - * Write support for bzip2-encoded data has been added. This works identically - to how writing gzip-encoded data is written. See the gzip discussion in the - 0.8.0 section below for important notes. + * Write support for bzip2-encoded and lzma-encoded data has been added. LZMA + write support is only available for .xz files, not the obsolete .lzma + format. The write support occurs out-of-place, just like how writing + gzip-encoded data works. See the gzip discussion in the 0.8.0 section below + for important notes. + * BUG FIX: In addition to the addition of write support mentioned above, a + number of problems with reading LZMA files has been fixed, which should + result in fewer segmentaion faults. + * 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 Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/src/bzip.c 2014-05-19 19:46:21 UTC (rev 904) @@ -44,7 +44,6 @@ BZFILE* bzfile; FILE* stream; int bzerror; - int write; int stream_end; int pos, end; off64_t base; @@ -95,10 +94,8 @@ ptr->bzerror = ptr->stream_end = 0; if (mode & GD_FILE_READ) { ptr->bzfile = BZ2_bzReadOpen(&ptr->bzerror, stream, 0, 0, NULL, 0); - ptr->write = 0; } else { ptr->bzfile = BZ2_bzWriteOpen(&ptr->bzerror, stream, 9, 0, 30); - ptr->write = 1; memset(ptr->data, 0, GD_BZIP_BUFFER_SIZE); } @@ -325,10 +322,10 @@ dtrace("%p", file); ptr->bzerror = 0; - if (ptr->write) + if (file->mode & GD_FILE_READ) + BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); + else BZ2_bzWriteClose(&ptr->bzerror, ptr->bzfile, 0, NULL, NULL); - else - BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); if (ptr->bzerror || fclose(ptr->stream)) { dreturn("%i", 1); Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/src/encoding.c 2014-05-19 19:46:21 UTC (rev 904) @@ -106,18 +106,35 @@ #undef GD_EF_PROVIDES +/* We only provide write support for .xz files, not .lzma */ #ifdef USE_LZMA #define GD_EF_PROVIDES \ - GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE + GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE | \ + GD_EF_WRITE | GD_EF_SYNC #define GD_INT_FUNCS \ &_GD_GenericName, &_GD_LzmaOpen, &_GD_LzmaClose, &_GD_LzmaSeek, \ + &_GD_LzmaRead, &_GD_LzmaSize, &_GD_LzmaWrite, &_GD_LzmaSync, \ + &_GD_GenericMove, &_GD_GenericUnlink +#else +#define GD_INT_FUNCS GD_EF_NULL_SET +#define GD_EF_PROVIDES 0 +#endif + GD_EXT_ENCODING_GEN(GD_LZMA_ENCODED, ".xz", GD_EF_ECOR | GD_EF_OOP, "Lzma", + "lzma"), +#undef GD_INT_FUNCS +#undef GD_EF_PROVIDES + +#ifdef USE_LZMA +#define GD_EF_PROVIDES \ + GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE +#define GD_INT_FUNCS \ + &_GD_GenericName, &_GD_LzmaOpen, &_GD_LzmaClose, &_GD_LzmaSeek, \ &_GD_LzmaRead, &_GD_LzmaSize, NULL /* WRITE */, NULL /* SYNC */, \ &_GD_GenericMove, &_GD_GenericUnlink #else #define GD_INT_FUNCS GD_EF_NULL_SET #define GD_EF_PROVIDES 0 #endif - GD_EXT_ENCODING_GEN(GD_LZMA_ENCODED, ".xz", GD_EF_ECOR, "Lzma", "lzma"), GD_EXT_ENCODING_GEN(GD_LZMA_ENCODED, ".lzma", GD_EF_ECOR, "Lzma", "lzma"), #undef GD_INT_FUNCS #undef GD_EF_PROVIDES Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/src/internal.h 2014-05-19 19:46:21 UTC (rev 904) @@ -1282,7 +1282,7 @@ size_t); ssize_t _GD_GzipWrite(struct gd_raw_file_ *restrict, const void *restrict, gd_type_t, size_t); -int _GD_GzipSync(struct gd_raw_file_* file); +int _GD_GzipSync(struct gd_raw_file_*); int _GD_GzipClose(struct gd_raw_file_* file); off64_t _GD_GzipSize(int, struct gd_raw_file_* file, gd_type_t data_type, int swap); @@ -1293,7 +1293,10 @@ gd_type_t data_type, unsigned int); ssize_t _GD_LzmaRead(struct gd_raw_file_ *restrict, void *restrict, gd_type_t, size_t); +ssize_t _GD_LzmaWrite(struct gd_raw_file_ *restrict, const void *restrict, + gd_type_t, size_t); int _GD_LzmaClose(struct gd_raw_file_* file); +int _GD_LzmaSync(struct gd_raw_file_ *file); off64_t _GD_LzmaSize(int, struct gd_raw_file_* file, gd_type_t data_type, int swap); Modified: trunk/getdata/src/lzma.c =================================================================== --- trunk/getdata/src/lzma.c 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/src/lzma.c 2014-05-19 19:46:21 UTC (rev 904) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2011 D. V. Wiebe +/* Copyright (C) 2014 D. V. Wiebe * *************************************************************************** * @@ -33,200 +33,277 @@ #endif #if SIZEOF_INT < 4 -#define GD_LZMA_BUFFER_SIZE 32767 +#define GD_LZMA_DATA_OUT 32767 #else -#define GD_LZMA_BUFFER_SIZE 1000000 +#define GD_LZMA_DATA_OUT 1000000 #endif +#define GD_LZMA_DATA_IN 4096 +#define GD_LZMA_LOOKBACK 4096 struct gd_lzmadata { - lzma_stream xzfile; + lzma_stream xz; FILE* stream; - int xzerror; - int stream_end; /* uncompressed file ran out of data */ - int input_eof; /* compressed file ran out of data */ - int read_in; /* location of the end of valid data in data_in */ - int out_pos; /* library's current position relative to the start of - data_out */ - int end; /* location of the end of valid data in data_out */ - off64_t base; /* position of the start of data_out in the uncompressed - stream */ - uint8_t data_in[GD_LZMA_BUFFER_SIZE]; - uint8_t data_out[GD_LZMA_BUFFER_SIZE]; + int stream_end; + int input_eof; + int offset; + uint8_t data_in[GD_LZMA_DATA_IN]; + uint8_t data_out[GD_LZMA_DATA_OUT]; }; -/* The bzip encoding scheme uses edata as a gd_lzmadata pointer. If a file is +/* total bytes in the output buffer */ +#define NOUT(p) (GD_LZMA_DATA_OUT - (p).xz.avail_out) + +/* byte position of the start of the output buffer */ +#define BASE(p) ((p).xz.total_out - NOUT(p)) + +/* bytes of unused data in output buffer */ +#define READY(p) (NOUT(p) - (p).offset) + +/* At EOF */ +#define LZEOF(p) ((p).stream_end || (p).input_eof) + +/* The lzma encoding scheme uses edata as a gd_lzmadata pointer. If a file is * open, idata = 0 otherwise idata = -1. */ -static struct gd_lzmadata *_GD_LzmaDoOpen(int dirfd, struct gd_raw_file_* file) +static struct gd_lzmadata *_GD_LzmaDoOpen(int dirfd, struct gd_raw_file_* file, + unsigned int mode) { - struct gd_lzmadata *ptr; + struct gd_lzmadata *lzd; int fd; + lzma_ret e; + const char *fdmode = "rb"; + FILE *stream; + const lzma_stream stream_init = LZMA_STREAM_INIT; - dtrace("%i, %p", dirfd, file); + dtrace("%i, %p, %i", dirfd, file, mode); - if ((ptr = (struct gd_lzmadata *)malloc(sizeof(struct gd_lzmadata))) == NULL) - { + if (mode & GD_FILE_READ) { + fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); + } else if (mode & GD_FILE_TEMP) { + fd = _GD_MakeTempFile(file->D, dirfd, file->name); + fdmode = "wb"; + } else { /* internal error */ + errno = EINVAL; /* I guess ... ? */ dreturn("%p", NULL); return NULL; } - if ((fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666)) - == -1) - { - free(ptr); + if (fd < 0) { dreturn("%p", NULL); return NULL; } - if ((ptr->stream = fdopen(fd, "rb")) == NULL) { + if ((stream = fdopen(fd, fdmode)) == NULL) { close(fd); - free(ptr); dreturn("%p", NULL); return NULL; } - memset(&ptr->xzfile, 0, sizeof(lzma_stream)); - ptr->xzfile.next_in = ptr->data_in; - ptr->xzfile.next_out = ptr->data_out; - ptr->xzfile.avail_in = 0; - ptr->xzfile.avail_out = GD_LZMA_BUFFER_SIZE; - ptr->xzerror = lzma_auto_decoder(&ptr->xzfile, 1000000000, 0); - ptr->xzfile.total_in = 0; + if ((lzd = (struct gd_lzmadata *)malloc(sizeof(struct gd_lzmadata))) == NULL) + { + dreturn("%p", NULL); + return NULL; + } + memset(lzd, 0, sizeof(*lzd)); - if (ptr->xzerror != LZMA_OK) { - fclose(ptr->stream); - free(ptr); + lzd->xz = stream_init; + lzd->stream = stream; + lzd->xz.next_in = lzd->data_in; + lzd->xz.next_out = lzd->data_out; + lzd->xz.avail_out = GD_LZMA_DATA_OUT; + if (mode & GD_FILE_READ) + e = lzma_auto_decoder(&lzd->xz, UINT64_MAX, 0); + else { + e = lzma_easy_encoder(&lzd->xz, 9, LZMA_CHECK_CRC64); + memset(lzd->data_in, 0, GD_LZMA_DATA_IN); + } + + if (e != LZMA_OK) { + fclose(lzd->stream); + free(lzd); dreturn("%p", NULL); return NULL; } - ptr->read_in = ptr->out_pos = ptr->end = 0; - ptr->base = ptr->stream_end = ptr->input_eof = 0; - - dreturn("%p", ptr); - return ptr; + dreturn("%p", lzd); + return lzd; } int _GD_LzmaOpen(int dirfd, struct gd_raw_file_* file, int swap gd_unused_, - unsigned int mode gd_unused_) + unsigned int mode) { - dtrace("%i, %p, <unused>, <unused>", dirfd, file); + dtrace("%i, %p, <unused>, 0x%X", dirfd, file, mode); - file->edata = _GD_LzmaDoOpen(dirfd, file); + file->edata = _GD_LzmaDoOpen(dirfd, file, mode); if (file->edata == NULL) { dreturn("%i", 1); return 1; } - file->mode = GD_FILE_READ; + file->mode = mode; file->pos = 0; file->idata = 0; dreturn("%i", 0); return 0; } -/* Read as much data as possible, and then run the converter on it, leaving - * unused input at the front of the input buffer, and updating read_in as - * appropriate. Returns -1 on error */ -static int _GD_LzmaDecode(struct gd_lzmadata *ptr) +/* Read and decode until the there's enough data ready in the output buffer, or + * it's full, or we hit EOF. Returns -1 on error, data ready size otherwise. + * + * This doesn't update next_out, so we don't have to worry about updating + * offset. + */ +static int _GD_LzmaReady(struct gd_lzmadata *lzd, size_t nreq) { - int n = 0; + lzma_ret e; + int ready = READY(*lzd); - dtrace("%p", ptr); + dtrace("%p, %" PRNsize_t, lzd, nreq); - if (!ptr->input_eof) { - n = fread(ptr->data_in + ptr->read_in, 1, GD_LZMA_BUFFER_SIZE - - ptr->read_in, ptr->stream); + /* already have enough data, or no more data to read */ + if (LZEOF(*lzd) || (size_t)ready >= nreq) { + dreturn("%i", ready); + return ready; + } - if (n < GD_LZMA_BUFFER_SIZE - ptr->read_in) { - if (feof(ptr->stream)) - ptr->input_eof = 1; - else { - dreturn("%i", -1); - return -1; + /* coding loop */ + while (lzd->xz.avail_out > 0 && (size_t)ready < nreq) { + /* No input data, so read some */ + if (lzd->xz.avail_in == 0) { + size_t n = fread(lzd->data_in, 1, GD_LZMA_DATA_IN, lzd->stream); + if (n == 0) { + if (ferror(lzd->stream)) { + dreturn("%i", -1); + return -1; + } + /* end of input */ + lzd->input_eof = 1; + break; } + lzd->xz.avail_in = n; + lzd->xz.next_in = lzd->data_in; } - } - ptr->xzfile.avail_in = ptr->read_in + n; + /* code */ + e = lzma_code(&lzd->xz, LZMA_RUN); + if (e != LZMA_OK && e != LZMA_STREAM_END) { + dreturn("%i", -1); + return -1; + } - /* no more data to convert -- end of stream reached */ - if (ptr->xzfile.avail_in == 0) { - ptr->stream_end = 1; - dreturn("%i", 0); - return 0; + ready = READY(*lzd); + if (e == LZMA_STREAM_END) { + lzd->stream_end = 1; + break; + } } - /* amount of data = amount already in buffer + amount just now read */ - ptr->xzerror = lzma_code(&ptr->xzfile, LZMA_RUN); + dreturn("%i", ready); + return ready; +} - if (ptr->xzerror == LZMA_OK || ptr->xzerror == LZMA_STREAM_END) { - ptr->base += ptr->end; - ptr->end = ptr->xzfile.total_out; - /* shift unused input to start of buffer */ - memmove(ptr->data_in, ptr->data_in + ptr->xzfile.total_in, - ptr->xzfile.avail_in); - ptr->read_in = ptr->xzfile.avail_in; - } else { - dreturn("%i", -1); - return -1; - } +/* clear the output buffer, retaining a bit of data for lookback purposes */ +static void _GD_LzmaClear(struct gd_lzmadata *lzd) +{ + int n; - dreturn("%i", 0); - return 0; + dtrace("%p", lzd); + + /* amount of data to keep */ + n = NOUT(*lzd); + if (n > GD_LZMA_LOOKBACK) + n = GD_LZMA_LOOKBACK; + + memmove(lzd->data_out, lzd->xz.next_out - n, n); + lzd->xz.next_out = lzd->data_out + n; + lzd->xz.avail_out = GD_LZMA_DATA_OUT - n; + + dreturnvoid(); } off64_t _GD_LzmaSeek(struct gd_raw_file_* file, off64_t count, - gd_type_t data_type, unsigned int mode gd_unused_) + gd_type_t data_type, unsigned int mode) { - struct gd_lzmadata *ptr = (struct gd_lzmadata *)file->edata; + struct gd_lzmadata *lzd; + lzma_ret e; + uint64_t bcount; - dtrace("%p, %lli, 0x%X, <unused>", file, (long long)count, data_type); + dtrace("%p, %lli, 0x%X, 0x%X", file, (long long)count, data_type, mode); - count *= GD_SIZE(data_type); + bcount = count * GD_SIZE(data_type); - /* the easy case */ - if (file->pos == count) { - dreturn("%lli", (long long)count); - return count; + if (mode == GD_FILE_WRITE) + lzd = (struct gd_lzmadata *)file[1].edata; + else + lzd = (struct gd_lzmadata *)file[0].edata; + + /* the easy case -- position is somewhere within our current output buffer */ + if (bcount < lzd->xz.total_out && bcount >= BASE(*lzd)) { + lzd->offset = bcount - BASE(*lzd); + file->pos = count; + + dreturn("%lli", (long long)(file->pos)); + return file->pos; } - if (ptr->base > count) { - /* a backwards seek -- rewind to the beginning */ - lzma_end(&ptr->xzfile); - ptr->xzfile.avail_in = 0; - ptr->xzfile.avail_out = GD_LZMA_BUFFER_SIZE; - ptr->xzerror = lzma_auto_decoder(&ptr->xzfile, 1000000000, 0); - ptr->xzfile.total_in = GD_LZMA_BUFFER_SIZE; - if (ptr->xzerror != LZMA_OK) { - file->idata = -1; - fclose(ptr->stream); - dreturn("%i", 1); - return 1; + if (mode != GD_FILE_WRITE) { + if (BASE(*lzd) > bcount) { + /* a backwards seek -- rewind to the beginning */ + lzd->xz.avail_in = 0; + lzd->xz.avail_out = GD_LZMA_DATA_OUT; + lzd->xz.total_in = lzd->xz.total_out = 0; + lzd->xz.next_in = lzd->data_in; + lzd->xz.next_out = lzd->data_out; + e = lzma_auto_decoder(&lzd->xz, UINT64_MAX, 0); + if (e != LZMA_OK) { + file->idata = -1; + free(lzd); + file->edata = NULL; + fclose(lzd->stream); + dreturn("%i", 1); + return 1; + } + rewind(lzd->stream); + lzd->input_eof = lzd->stream_end = 0; } - rewind(ptr->stream); - ptr->read_in = ptr->out_pos = ptr->end = 0; - ptr->base = ptr->input_eof = ptr->stream_end = 0; - } - /* seek forward the slow way */ - while (ptr->base + ptr->end < count) { - if (_GD_LzmaDecode(ptr)) { - dreturn("%i", -1); - return -1; + /* seek forward the slow way */ + while (lzd->xz.total_out < bcount) { + /* discard output */ + _GD_LzmaClear(lzd); + + if (_GD_LzmaReady(lzd, lzd->xz.avail_out) < 0) { + dreturn("%i", -1); + return -1; + } + + /* eof */ + if (LZEOF(*lzd)) + break; } - /* eof */ - if (ptr->stream_end) - break; + if (lzd->xz.total_out < bcount) { + /* ran out of data */ + lzd->offset = NOUT(*lzd); + file->pos = lzd->xz.total_out / GD_SIZE(data_type); + } else { + lzd->offset = bcount - BASE(*lzd); + file->pos = count; + } + } else { + /* we only get here when we need to pad */ + while (lzd->xz.total_in < bcount) { + int n = bcount - lzd->xz.total_in; + if (n > GD_LZMA_DATA_IN) + n = GD_LZMA_DATA_IN; + + _GD_LzmaWrite(file + 1, lzd->data_in, GD_UINT8, n); + } + lzd->offset = 0; + file->pos = lzd->xz.total_in / GD_SIZE(data_type); } - ptr->out_pos = (ptr->stream_end && count >= ptr->base + ptr->end) ? ptr->end - : count - ptr->base; - - file->pos = (ptr->base + ptr->out_pos) / GD_SIZE(data_type); - dreturn("%lli", (long long)(file->pos)); return file->pos; } @@ -234,103 +311,205 @@ ssize_t _GD_LzmaRead(struct gd_raw_file_ *file, void *data, gd_type_t data_type, size_t nmemb) { - char* output = (char *)data; - struct gd_lzmadata *ptr = (struct gd_lzmadata *)file->edata; - uint64_t nbytes = nmemb * GD_SIZE(data_type); + uint64_t bcount; + struct gd_lzmadata *lzd = (struct gd_lzmadata *)file->edata; + ssize_t nread = 0; dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); - /* this loops over chunks of uncompressed data of size data_out until we - * have as much data as we need in data_out, or until EOF */ - while (nbytes > (uint64_t)(ptr->end - ptr->out_pos)) { - memcpy(output, ptr->data_out + ptr->out_pos, ptr->end - ptr->out_pos); - output += ptr->end - ptr->out_pos; - nbytes -= ptr->end - ptr->out_pos; - ptr->out_pos = ptr->end; + if (nmemb > GD_SSIZE_T_MAX / GD_SIZE(data_type)) + nmemb = GD_SSIZE_T_MAX / GD_SIZE(data_type); + bcount = nmemb * GD_SIZE(data_type); - if (ptr->stream_end) { - dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); - return nmemb - nbytes / GD_SIZE(data_type); - } + /* decoding loop */ + while (bcount > 0) { + int bready, nready; - if (_GD_LzmaDecode(ptr)) { + /* clear the output buffer if it's full */ + if (lzd->xz.avail_out == 0) + _GD_LzmaClear(lzd); + + bready = _GD_LzmaReady(lzd, bcount); + if (bready < 0) { dreturn("%i", -1); return -1; } - /* eof */ - if (ptr->stream_end) + /* copy whole samples */ + nready = bready / GD_SIZE(data_type); + if (nready > (ssize_t)nmemb) + nready = nmemb; + + bready = nready * GD_SIZE(data_type); + + memcpy(data, lzd->data_out + lzd->offset, bready); + lzd->offset += bready; + bcount -= bready; + data += bready; + nread += nready; + + if (LZEOF(*lzd)) break; } - /* If we still have more data than we need (no EOF), copy it all, otherwise - * (reached EOF) copy as much as we have */ - if (nbytes > (uint64_t)(ptr->end - ptr->out_pos)) { - memcpy(output, ptr->data_out + ptr->out_pos, ptr->end - ptr->out_pos); - ptr->out_pos = ptr->end; - nbytes -= ptr->end; - } else { - memcpy(output, ptr->data_out + ptr->out_pos, nbytes); - ptr->out_pos += nbytes; - nbytes = 0; + dreturn("%" PRNssize_t, nread); + return nread; +} + +/* flush the output buffer to the stream */ +static int _GD_LzmaFlush(struct gd_lzmadata *lzd) +{ + uint8_t *ptr; + + dtrace("%p", lzd); + + ptr = lzd->data_out; + while (NOUT(*lzd) > 0) { + ssize_t nw = fwrite(ptr, 1, NOUT(*lzd), lzd->stream); + if (nw == 0 && ferror(lzd->stream)) { + dreturn("%i", 1); + return 1; + } + + ptr += nw; + lzd->xz.avail_out += nw; } - file->pos += nmemb - nbytes / GD_SIZE(data_type); + /* reset output buffer */ + lzd->xz.next_out = lzd->data_out; - dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); - return nmemb - nbytes / GD_SIZE(data_type); + dreturn("%i", 0); + return 0; } +ssize_t _GD_LzmaWrite(struct gd_raw_file_ *file, const void *data, + gd_type_t data_type, size_t nmemb) +{ + lzma_ret e; + size_t n; + struct gd_lzmadata *lzd = (struct gd_lzmadata *)file->edata; + + dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); + + n = nmemb * GD_SIZE(data_type); + + /* We let liblzma read directly from the caller's buffer */ + lzd->xz.next_in = data; + lzd->xz.avail_in = n; + + /* code */ + while (lzd->xz.avail_in > 0) { + e = lzma_code(&lzd->xz, LZMA_RUN); + if (e != LZMA_OK) { + dreturn("%i", -1); + return -1; + } + + if (_GD_LzmaFlush(lzd)) { + dreturn("%i", -1); + return -1; + } + } + + /* we always write all the input, if successful */ + dreturn("%" PRNssize_t, (ssize_t)nmemb); + return nmemb; +} + int _GD_LzmaClose(struct gd_raw_file_ *file) { - struct gd_lzmadata *ptr = (struct gd_lzmadata *)file->edata; + lzma_ret e; + struct gd_lzmadata *lzd = (struct gd_lzmadata *)file->edata; dtrace("%p", file); - ptr->xzerror = 0; - lzma_end(&ptr->xzfile); - if (fclose(ptr->stream)) { + /* finialise */ + if (!(file->mode & GD_FILE_READ)) { + /* ensure we don't read any more data */ + lzd->xz.avail_in = 0; + for (;;) { + e = lzma_code(&lzd->xz, LZMA_FINISH); + if (e != LZMA_OK && e != LZMA_STREAM_END) { + dreturn("%i", 1); + return 1; + } + + if (_GD_LzmaFlush(lzd)) { + dreturn("%i", 1); + return 1; + } + + if (e == LZMA_STREAM_END) + break; + } + } + + /* shutdown */ + lzma_end(&lzd->xz); + if (fclose(lzd->stream)) { dreturn("%i", 1); return 1; } file->idata = -1; - file->mode = 0; free(file->edata); + file->edata = NULL; dreturn("%i", 0); return 0; } +/* We don't flush the encoder since it may degrade compression, but we can + * flush the stdio buffer */ +int _GD_LzmaSync(struct gd_raw_file_ *file) +{ + int r = 0; + dtrace("%p", file); + + if (file->mode & GD_FILE_WRITE) { + struct gd_lzmadata *lzd = (struct gd_lzmadata *)file[1].edata; + + r = fflush(lzd->stream); + } + + dreturn("%i", r); + return r; +} + off64_t _GD_LzmaSize(int dirfd, struct gd_raw_file_ *file, gd_type_t data_type, int swap gd_unused_) { - struct gd_lzmadata *ptr; - off_t n; + struct gd_lzmadata *lzd; + off64_t n; dtrace("%i, %p, 0x%X, <unused>", dirfd, file, data_type); - ptr = _GD_LzmaDoOpen(dirfd, file); + lzd = _GD_LzmaDoOpen(dirfd, file, GD_FILE_READ); - if (ptr == NULL) { + if (lzd == NULL) { dreturn("%i", -1); return -1; } - /* seek forward the slow way to the end */ - while (!ptr->stream_end) { - if (_GD_LzmaDecode(ptr)) { - lzma_end(&ptr->xzfile); - fclose(ptr->stream); + /* read until EOF */ + while (!LZEOF(*lzd)) { + if (_GD_LzmaReady(lzd, GD_LZMA_DATA_OUT) < 0) { dreturn("%i", -1); return -1; } + + /* discard output */ + lzd->xz.next_out = lzd->data_out; + lzd->xz.avail_out = GD_LZMA_DATA_OUT; } - lzma_end(&ptr->xzfile); - fclose(ptr->stream); - n = (ptr->base + ptr->end) / GD_SIZE(data_type); - free(ptr); + /* liblzma very graciously does the bookkeeping for us */ + n = lzd->xz.total_out / GD_SIZE(data_type); + lzma_end(&lzd->xz); + fclose(lzd->stream); + + free(lzd); + dreturn("%lli", (long long)n); return n; } Modified: trunk/getdata/src/raw.c =================================================================== --- trunk/getdata/src/raw.c 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/src/raw.c 2014-05-19 19:46:21 UTC (rev 904) @@ -110,7 +110,14 @@ int _GD_RawSync(struct gd_raw_file_ *file) { - return fsync(file->idata); + int r; + + dtrace("%p", file); + + r = fsync(file->idata); + + dreturn("%i", r); + return r; } int _GD_RawClose(struct gd_raw_file_ *file) Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/test 2014-05-19 19:46:21 UTC (rev 904) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -635,6 +635,21 ## legacy_spf lzma_get lzma_nframes +lzma_put +lzma_xz_add +lzma_xz_get +lzma_xz_get_far +lzma_xz_get_get +lzma_xz_get_get2 +lzma_xz_get_put +lzma_xz_move_to +lzma_xz_nframes +lzma_xz_put +lzma_xz_put_back +lzma_xz_put_endian +lzma_xz_put_get +lzma_xz_put_pad +lzma_xz_sync madd madd_affix madd_alias ## -1137,8 +1152,6 ## vlist_meta vlist_meta_hidden vlist_meta_invalid -xz_get -xz_nframes zzip_data zzip_get zzip_get_get Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/test/Makefile.am 2014-05-19 19:46:21 UTC (rev 904) @@ -239,7 +239,10 @@ legacy_spf endif -LZMA_TESTS=lzma_get lzma_nframes +LZMA_TESTS=lzma_get lzma_nframes lzma_put lzma_xz_add lzma_xz_get \ + lzma_xz_get_far lzma_xz_get_get lzma_xz_get_get2 lzma_xz_get_put \ + lzma_xz_move_to lzma_xz_nframes lzma_xz_put lzma_xz_put_back \ + lzma_xz_put_endian lzma_xz_put_get lzma_xz_put_pad lzma_xz_sync MADD_TESTS=madd madd_affix madd_alias madd_alias_affix madd_bit \ madd_bit_invalid madd_carray madd_clincom madd_const madd_cpolynom \ @@ -396,8 +399,6 @@ VLIST_TESTS=vlist vlist_alias vlist_hidden vlist_invalid vlist_meta \ vlist_meta_hidden vlist_meta_invalid -XZ_TESTS=xz_get xz_nframes - ZZIP_TESTS=zzip_data zzip_get zzip_get_get zzip_nframes ZZSLIM_TESTS=zzslim_get zzslim_nframes @@ -417,7 +418,7 @@ $(SEEK_TESTS) $(SIE_TESTS) $(SLIM_TESTS) $(SPF_TESTS) \ $(SVLIST_TESTS) $(TABLE_TESTS) $(TELL_TESTS) $(TOK_TESTS) \ $(TRUNC_TESTS) $(UNCLUDE_TESTS) $(VERSION_TESTS) $(VLIST_TESTS) \ - $(XZ_TESTS) $(ZZIP_TESTS) $(ZZSLIM_TESTS) + $(ZZIP_TESTS) $(ZZSLIM_TESTS) check_PROGRAMS=$(TESTS) Modified: trunk/getdata/test/encode_support.c =================================================================== --- trunk/getdata/test/encode_support.c 2014-05-10 01:21:54 UTC (rev 903) +++ trunk/getdata/test/encode_support.c 2014-05-19 19:46:21 UTC (rev 904) @@ -40,7 +40,7 @@ #endif #ifdef USE_LZMA -#define GD_LZMA_MODE GD_RDONLY +#define GD_LZMA_MODE GD_RDWR #else #define GD_LZMA_MODE -1 #endif Added: trunk/getdata/test/lzma_put.c =================================================================== --- trunk/getdata/test/lzma_put.c (rev 0) +++ trunk/getdata/test/lzma_put.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,73 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_LZMA + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_lzma = "dirfile/data.lzma"; + const char *data = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n"; + uint8_t c[8] = {40, 41, 42, 43, 44, 45, 46, 47}; + uint8_t data_data[256]; + char command[4096]; + int fd, n, e1, e2, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_data[fd] = (uint8_t)fd; + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256 * sizeof(uint16_t)); + close(fd); + + /* compress */ + snprintf(command, 4096, "%s -F lzma -f %s > /dev/null", XZ, data); + if (gd_system(command)) + return 1; + + D = gd_open(filedir, GD_RDWR); + n = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + e1 = gd_error(D); + CHECKI(e1, GD_E_UNSUPPORTED); + CHECKI(n, 0); + + e2 = gd_discard(D); + CHECKI(e2, 0); + + unlink(data_lzma); + unlink(format); + rmdir(filedir); + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_add.c =================================================================== --- trunk/getdata/test/lzma_xz_add.c (rev 0) +++ trunk/getdata/test/lzma_xz_add.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,77 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_LZMA + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data.xz"; + gd_entry_t e; + int e1, e2, e3, unlink_data, r = 0; + DIRFILE *D; + + rmdirfile(); +#ifdef USE_LZMA + D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE | GD_LZMA_ENCODED); +#else + D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_LZMA_ENCODED); +#endif + gd_add_raw(D, "data", GD_UINT8, 2, 0); + e1 = gd_error(D); + + /* check */ + e2 = gd_entry(D, "data", &e); +#ifdef USE_LZMA + CHECKI(e2, 0); + if (e2 == 0) { + CHECKI(e.field_type, GD_RAW_ENTRY); + CHECKI(e.fragment_index, 0); + CHECKI(e.EN(raw,spf), 2); + CHECKI(e.EN(raw,data_type), GD_UINT8); + gd_free_entry_strings(&e); + } +#else + CHECKI(e2, -1); +#endif + + e3 = gd_close(D); + CHECKI(e3, 0); + + unlink_data = unlink(data); + +#ifdef USE_LZMA + CHECKI(unlink_data, 0); + CHECKI(e1, GD_E_OK); +#else + CHECKI(unlink_data, -1); + CHECKI(e1, GD_E_UNSUPPORTED); +#endif + + unlink(format); + rmdir(filedir); + + return r; +#endif +} Copied: trunk/getdata/test/lzma_xz_get.c (from rev 903, trunk/getdata/test/xz_get.c) =================================================================== --- trunk/getdata/test/lzma_xz_get.c (rev 0) +++ trunk/getdata/test/lzma_xz_get.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,88 @@ +/* Copyright (C) 2009-2011, 2013 D. V. Wiebe + * + *************************************************************************** + * + * This file is part of the GetData project. + * + * GetData is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your + * option) any later version. + * + * GetData is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with GetData; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "test.h" + +int main(void) +{ +#ifndef TEST_LZMA + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *xzdata = "dirfile/data.xz"; + const char *format_data = "data RAW UINT16 8\n"; + uint16_t c[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + char command[4096]; + uint16_t data_data[256]; +#ifdef USE_LZMA + int i; +#endif + int fd, n, error, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 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(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256 * sizeof(uint16_t)); + close(fd); + + /* compress */ + snprintf(command, 4096, "%s -f %s > /dev/null", XZ, data); + if (gd_system(command)) + return 1; + +#ifdef USE_LZMA + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDONLY); +#endif + n = gd_getdata(D, "data", 5, 0, 1, 0, GD_UINT16, c); + error = gd_error(D); + + gd_discard(D); + + unlink(xzdata); + unlink(format); + rmdir(filedir); + +#ifdef USE_LZMA + CHECKI(error,0); + CHECKI(n,8); + for (i = 0; i < 8; ++i) + CHECKXi(i,c[i],40 + i); +#else + CHECKI(error,GD_E_UNSUPPORTED); + CHECKI(n,0); +#endif + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_get_far.c =================================================================== --- trunk/getdata/test/lzma_xz_get_far.c (rev 0) +++ trunk/getdata/test/lzma_xz_get_far.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,82 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_LZMA + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *xzdata = "dirfile/data.xz"; + const char *format_data = "data RAW UINT16 8\n"; + uint16_t c[8]; + char command[4096]; + uint16_t data_data[256]; + int fd, n, error, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 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(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256 * sizeof(uint16_t)); + close(fd); + + /* compress */ + snprintf(command, 4096, "%s -f %s > /dev/null", XZ, data); + if (gd_system(command)) + return 1; + +#ifdef USE_LZMA + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDONLY); +#endif + n = gd_getdata(D, "data", 1000, 0, 1, 0, GD_UINT16, c); + error = gd_error(D); + + gd_discard(D); + + unlink(xzdata); + unlink(format); + rmdir(filedir); + +#ifdef USE_LZMA + CHECKI(error, 0); +#else + CHECKI(error, GD_E_UNSUPPORTED); +#endif + CHECKI(n, 0); + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_get_get.c =================================================================== --- trunk/getdata/test/lzma_xz_get_get.c (rev 0) +++ trunk/getdata/test/lzma_xz_get_get.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,87 @@ +/* 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" + +int main(void) +{ +#if !defined USE_LZMA || !defined TEST_LZMA + return 77; /* skip test */ +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *xzdata = "dirfile/data.xz"; + const char *format_data = "data RAW UINT16 8\n"; + uint16_t c1[8], c2[8]; + char command[4096]; + uint16_t data_data[256]; + int fd, i, n1, e1, e2, n2, e3, r = 0; + DIRFILE *D; + + memset(c1, 0, 16); + memset(c2, 0, 16); + rmdirfile(); + mkdir(filedir, 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(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256 * sizeof(uint16_t)); + close(fd); + + /* compress */ + snprintf(command, 4096, "%s -f %s > /dev/null", XZ, data); + if (gd_system(command)) + return 1; + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + n1 = gd_getdata(D, "data", 5, 0, 1, 0, GD_UINT16, c1); + CHECKI(n1, 8); + e1 = gd_error(D); + CHECKI(e1, 0); + + e2 = gd_close(D); + CHECKI(e2, 0); + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + n2 = gd_getdata(D, "data", 5, 0, 1, 0, GD_UINT16, c2); + e3 = gd_error(D); + CHECKI(e3, 0); + CHECKI(n2, 8); + for (i = 0; i < 8; ++i) { + CHECKIi(i,c1[i], 40 + i); + CHECKIi(i,c2[i], 40 + i); + } + + gd_discard(D); + + unlink(xzdata); + unlink(format); + rmdir(filedir); + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_get_get2.c =================================================================== --- trunk/getdata/test/lzma_xz_get_get2.c (rev 0) +++ trunk/getdata/test/lzma_xz_get_get2.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,82 @@ +/* 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" + +int main(void) +{ +#if !defined USE_LZMA || !defined TEST_LZMA + return 77; /* skip test */ +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *xzdata = "dirfile/data.xz"; + const char *format_data = "data RAW UINT16 8\n"; + uint16_t c1[8], c2[8]; + char command[4096]; + uint16_t data_data[256]; + int fd, i, n1, error1, n2, error2, r = 0; + DIRFILE *D; + + memset(c1, 0, 16); + memset(c2, 0, 16); + rmdirfile(); + mkdir(filedir, 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(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256 * sizeof(uint16_t)); + close(fd); + + /* compress */ + snprintf(command, 4096, "%s -f %s > /dev/null", XZ, data); + if (gd_system(command)) + return 1; + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + n1 = gd_getdata(D, "data", 0, 0, 1, 0, GD_UINT16, c1); + error1 = gd_error(D); + n2 = gd_getdata(D, "data", 0, 0, 1, 0, GD_UINT16, c2); + error2 = gd_error(D); + gd_discard(D); + + unlink(xzdata); + unlink(format); + rmdir(filedir); + + CHECKI(error1, 0); + CHECKI(error2, 0); + CHECKI(n1, 8); + CHECKI(n2, 8); + for (i = 0; i < 8; ++i) { + CHECKUi(i,c1[i], i); + CHECKUi(i,c2[i], i); + } + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_get_put.c =================================================================== --- trunk/getdata/test/lzma_xz_get_put.c (rev 0) +++ trunk/getdata/test/lzma_xz_get_put.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,154 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_LZMA + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_xz = "dirfile/data.xz"; + const char *data = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n"; + const unsigned char xzdata[300] = { + 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04, + 0xe6, 0xd6, 0xb4, 0x46, 0x02, 0x00, 0x21, 0x01, + 0x16, 0x00, 0x00, 0x00, 0x74, 0x2f, 0xe5, 0xa3, + 0xe0, 0x00, 0xff, 0x00, 0xea, 0x5d, 0x00, 0x00, + 0x00, 0x52, 0x50, 0x0a, 0x84, 0xf9, 0x9b, 0xb2, + 0x80, 0x21, 0xa9, 0x69, 0xd6, 0x27, 0xe0, 0x3e, + 0x06, 0x5a, 0x5f, 0x04, 0x8d, 0x53, 0xd4, 0x04, + 0xba, 0x39, 0x57, 0x05, 0x09, 0xc1, 0x55, 0x24, + 0xde, 0x9d, 0xb8, 0x71, 0x59, 0x31, 0x60, 0xa1, + 0x9f, 0xf9, 0x6f, 0x49, 0x73, 0xf2, 0xc8, 0xea, + 0x8c, 0xba, 0x1a, 0x8b, 0x29, 0x69, 0x21, 0x80, + 0xfe, 0x33, 0x83, 0x66, 0xaf, 0x46, 0x6d, 0xec, + 0x9e, 0x89, 0x8a, 0x0b, 0x83, 0xf0, 0x3c, 0x0e, + 0x89, 0x8e, 0x3f, 0xed, 0x5f, 0xe7, 0x9e, 0x90, + 0xd9, 0x1c, 0xff, 0x32, 0xf4, 0xb2, 0xe0, 0x39, + 0x51, 0xb2, 0xd2, 0x14, 0x15, 0xb4, 0xc5, 0x71, + 0xba, 0xdb, 0x06, 0xe3, 0x79, 0x9a, 0x9f, 0xbb, + 0x38, 0xc1, 0xb0, 0x00, 0xac, 0x93, 0x0b, 0xaa, + 0x06, 0x19, 0x03, 0x12, 0x08, 0x15, 0x5b, 0x9b, + 0xc8, 0x48, 0xf0, 0x32, 0x2e, 0xfe, 0x2d, 0xa0, + 0x87, 0xc8, 0xf0, 0xa4, 0xe0, 0xd2, 0x51, 0xeb, + 0x8d, 0x67, 0x56, 0x92, 0xb2, 0x4d, 0x84, 0xc5, + 0xf1, 0x86, 0x31, 0xdf, 0x6a, 0x62, 0x5b, 0xc2, + 0x79, 0x2d, 0xd9, 0xf7, 0x3c, 0x73, 0xba, 0x74, + 0x74, 0x07, 0xd8, 0x3c, 0xa9, 0x56, 0x22, 0x24, + 0xa1, 0x66, 0xf8, 0x5a, 0x84, 0x5f, 0x30, 0x67, + 0xd2, 0xf6, 0x4b, 0x49, 0x2e, 0x7f, 0x20, 0xeb, + 0xdb, 0xf8, 0x10, 0x0e, 0x94, 0x78, 0x77, 0xc7, + 0x3f, 0x6b, 0xef, 0xb4, 0xcd, 0x95, 0xe2, 0x6f, + 0xf6, 0x44, 0x6e, 0x06, 0xcf, 0x0b, 0x82, 0x1a, + 0xcb, 0xdb, 0x7a, 0xf0, 0x57, 0x8d, 0x98, 0xff, + 0x90, 0xc0, 0x3e, 0xe6, 0xc1, 0x12, 0x41, 0x75, + 0xee, 0x03, 0x28, 0x96, 0xeb, 0x09, 0x37, 0x0e, + 0x1e, 0x00, 0x00, 0x00, 0xb0, 0x3a, 0xdb, 0x65, + 0x2f, 0x4b, 0x41, 0x72, 0x00, 0x01, 0x86, 0x02, + 0x80, 0x02, 0x00, 0x00, 0x2d, 0x12, 0xa1, 0x9f, + 0xb1, 0xc4, 0x67, 0xfb, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x59, 0x5a + }; + uint8_t b, c[8], d[8]; + char command[4096]; + int fd, i, m, n, e1, e2, e3, unlink_data, unlink_dataxz, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 0777); + + for (i = 0; i < 8; ++i) + d[i] = (uint8_t)(80 + i); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(data_xz, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, xzdata, 300); + close(fd); + +#ifdef USE_LZMA + D = gd_open(filedir, GD_RDWR | GD_LZMA_ENCODED | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR | GD_LZMA_ENCODED); +#endif + n = gd_getdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + e1 = gd_error(D); + m = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, d); + e2 = gd_error(D); + + e3 = gd_close(D); + CHECKI(e3, 0); + +#ifdef USE_LZMA + /* uncompress */ + snprintf(command, 4096, "%s --decompress -f %s > /dev/null", XZ, data_xz); + if (gd_system(command)) { + r = 1; + } else { + fd = open(data, O_RDONLY | O_BINARY); + if (fd >= 0) { + i = 0; + while (read(fd, &b, sizeof(uint8_t))) { + if (i < 40 || i >= 48) { + CHECKIi(i, b, i); + } else + CHECKIi(i, b, i + 40); + i++; + } + CHECKI(i, 256); + close(fd); + } + } + + for (i = 0; i < 8; ++i) + CHECKIi(i, c[i], 40 + i); +#endif + + unlink_data = unlink(data); + unlink_dataxz = unlink(data_xz); + unlink(format); + rmdir(filedir); + +#ifdef USE_LZMA + CHECKI(unlink_data, 0); + CHECKI(unlink_dataxz, -1); + CHECKI(e1, GD_E_OK); + CHECKI(e2, GD_E_OK); + CHECKI(n, 8); + CHECKI(m, 8); +#else + CHECKI(unlink_data, -1); + CHECKI(unlink_dataxz, 0); + CHECKI(e1, GD_E_UNSUPPORTED); + CHECKI(e2, GD_E_UNSUPPORTED); + CHECKI(n, 0); + CHECKI(m, 0); +#endif + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_move_to.c =================================================================== --- trunk/getdata/test/lzma_xz_move_to.c (rev 0) +++ trunk/getdata/test/lzma_xz_move_to.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,111 @@ +/* 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" + +int main(void) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_xz = "dirfile/data.xz"; + const char *data_raw = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n/ENCODING none\n/ENDIAN little\n"; + uint8_t data_in[256]; + DIRFILE *D; +#ifdef USE_LZMA + uint8_t d; + char command[4096]; + int i; +#endif + int fd, e1, e2, unlink_raw, r = 0; + struct stat buf; + + rmdirfile(); + mkdir(filedir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_in[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(data_raw, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_in, 256); + close(fd); + +#ifdef USE_LZMA + D = gd_open(filedir, GD_RDWR | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR); +#endif + gd_alter_encoding(D, GD_LZMA_ENCODED, 0, 1); + e1 = gd_error(D); + + e2 = gd_close(D); + CHECKI(e2, 0); + +#ifdef USE_LZMA + if (stat(data_xz, &buf)) { + perror("stat"); + r = 1; + } + CHECKI(stat(data_raw, &buf), -1); +#else + if (stat(data_raw, &buf)) { + perror("stat"); + r = 1; + } + CHECKI(stat(data_xz, &buf), -1); +#endif + +#ifdef USE_LZMA + /* uncompress */ + snprintf(command, 4096, "%s --decompress -f %s > /dev/null", XZ, data_xz); + if (gd_system(command)) { + fprintf(stderr, "command failed: %s\n", command); + r = 1; + } else { + fd = open(data_raw, O_RDONLY | O_BINARY); + if (fd >= 0) { + i = 0; + while (read(fd, &d, sizeof(uint8_t))) { + CHECKIi(i, d, i); + i++; + } + CHECKI(i, 256); + close(fd); + } + } +#endif + + unlink_raw = unlink(data_raw); + unlink(format); + rmdir(filedir); + + CHECKI(unlink_raw, 0); +#ifdef USE_LZMA + CHECKI(e1, GD_E_OK); +#else + CHECKI(e1, GD_E_UNSUPPORTED); +#endif + + return r; +} Copied: trunk/getdata/test/lzma_xz_nframes.c (from rev 903, trunk/getdata/test/xz_nframes.c) =================================================================== --- trunk/getdata/test/lzma_xz_nframes.c (rev 0) +++ trunk/getdata/test/lzma_xz_nframes.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,90 @@ +/* Copyright (C) 2009-2011, 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 + */ +/* Retrieving the number of frames should succeed cleanly */ +#include "test.h" + +#include <stdlib.h> +#include <sys/types.h> +#include <stdio.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <inttypes.h> + +int main(void) +{ +#ifndef TEST_LZMA + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *xzdata = "dirfile/data.xz"; + const char *format_data = "data RAW UINT16 1\n"; + char command[4096]; + uint16_t data_data[256]; + int i, error, r = 0; + DIRFILE *D; + size_t n; + + rmdirfile(); + mkdir(filedir, 0777); + + for (i = 0; i < 256; ++i) + data_data[i] = (uint16_t)i; + + i = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(i, format_data, strlen(format_data)); + close(i); + + i = open(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(i, data_data, 256 * sizeof(uint16_t)); + close(i); + + /* compress */ + snprintf(command, 4096, "%s -f %s > /dev/null", XZ, data); + if (gd_system(command)) + return 1; + +#ifdef USE_LZMA + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDONLY); +#endif + n = gd_nframes(D); + error = gd_error(D); + gd_discard(D); + + unlink(xzdata); + unlink(format); + rmdir(filedir); + +#ifdef USE_LZMA + CHECKI(error,0); + CHECKI(n,256); +#else + CHECKI(error,GD_E_UNSUPPORTED); + CHECKI(n,0); +#endif + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_put.c =================================================================== --- trunk/getdata/test/lzma_xz_put.c (rev 0) +++ trunk/getdata/test/lzma_xz_put.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,115 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_LZMA + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_xz = "dirfile/data.xz"; + const char *data = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n"; + uint8_t c[8]; +#ifdef USE_LZMA + char command[4096]; + uint8_t d; +#endif + struct stat buf; + int fd, i, n, e1, e2, stat_data, unlink_data, unlink_xz, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 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); + +#ifdef USE_LZMA + D = gd_open(filedir, GD_RDWR | GD_LZMA_ENCODED | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR | GD_LZMA_ENCODED); +#endif + n = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + e1 = gd_error(D); + + e2 = gd_close(D); + CHECKI(e2, 0); + + stat_data = stat(data_xz, &buf); +#ifdef USE_LZMA + if (stat_data) { + perror("stat"); + } + CHECKI(stat_data, 0); +#else + CHECKI(stat_data, -1); +#endif + +#ifdef USE_LZMA + /* uncompress */ + snprintf(command, 4096, "%s --decompress -f %s > /dev/null", XZ, data_xz); + 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 < 40 || i > 48) { + CHECKIi(i, d, 0); + } else + CHECKIi(i, d, i); + i++; + } + CHECKI(i, 48); + close(fd); + } + } +#endif + + unlink_xz = unlink(data_xz); + CHECKI(unlink_xz, -1); + + unlink_data = unlink(data); + unlink(format); + rmdir(filedir); + +#ifdef USE_LZMA + CHECKI(unlink_data, 0); + CHECKI(e1, GD_E_OK); + CHECKI(n, 8); +#else + CHECKI(unlink_data, -1); + CHECKI(e1, GD_E_UNSUPPORTED); + CHECKI(n, 0); +#endif + + return r; +#endif +} Added: trunk/getdata/test/lzma_xz_put_back.c =================================================================== --- trunk/getdata/test/lzma_xz_put_back.c (rev 0) +++ trunk/getdata/test/lzma_xz_put_back.c 2014-05-19 19:46:21 UTC (rev 904) @@ -0,0 +1,101 @@ +/* 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" + +int main(void) +{ +#if ! (defined TEST_LZMA) || ! (defined USE_LZMA) + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_xz = "dirfile/data.xz"; + const char *data = "dirfile/data"; + const char *format_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); + + 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); + + D = gd_open(filedir, GD_RDWR | GD_LZMA_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 = ... [truncated message content] |
From: <ket...@us...> - 2014-05-10 01:22:00
|
Revision: 903 http://sourceforge.net/p/getdata/code/903 Author: ketiltrout Date: 2014-05-10 01:21:54 +0000 (Sat, 10 May 2014) Log Message: ----------- Use slimdopen and slimdrawsize when available. Modified Paths: -------------- trunk/getdata/configure.ac trunk/getdata/src/slim.c Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2014-05-07 19:49:19 UTC (rev 902) +++ trunk/getdata/configure.ac 2014-05-10 01:21:54 UTC (rev 903) @@ -981,7 +981,7 @@ GD_CHECK_ENCODING([gzip],[z],[gzopen],[zlib.h],[gzip],[gunzip],[]) GD_CHECK_ENCODING([lzma],[lzma],[lzma_auto_decoder],[lzma.h],[xz],[],[]) GD_CHECK_ENCODING([slim],[slim],[slimopen],[slimlib.h], [slim slimdata], - [unslim],[slimdopen]) + [unslim],[slimdopen slimdrawsize]) GD_CHECK_ENCODING([zzip],[zzip],[zzip_open],[zzip/lib.h],[zip],[unzip],[]) dnl zzslim hackery -- there's no easy way to check whether slim supports zzip Modified: trunk/getdata/src/slim.c =================================================================== --- trunk/getdata/src/slim.c 2014-05-07 19:49:19 UTC (rev 902) +++ trunk/getdata/src/slim.c 2014-05-10 01:21:54 UTC (rev 903) @@ -38,24 +38,43 @@ int _GD_SlimOpen(int dirfd, struct gd_raw_file_* file, int swap gd_unused_, unsigned int mode gd_unused_) { - char *filepath; - dtrace("%i, %p, <unused>, <unused>", dirfd, file); - /* this is easily broken, but the best we can do for now... */ - filepath = gd_MakeFullPathOnly(file->D, dirfd, file->name); - if (filepath == NULL) { - dreturn("%i", 1); - return 1; +#ifdef HAVE_SLIMDOPEN + { + int fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); + if (fd < 0) { + dreturn("%i", -1); + return -1; + } + + file->edata = slimdopen(fd, "r"); + + if (file->edata == NULL) { + close(fd); + dreturn("%i", 1); + return 1; + } } +#else + { + char *filepath; + /* this is easily broken, but the best we can do in this case */ + filepath = gd_MakeFullPathOnly(file->D, dirfd, file->name); + if (filepath == NULL) { + dreturn("%i", 1); + return 1; + } - file->edata = slimopen(filepath, "r"); - free(filepath); + file->edata = slimopen(filepath, "r"); + free(filepath); - if (file->edata == NULL) { - dreturn("%i", 1); - return 1; + if (file->edata == NULL) { + dreturn("%i", 1); + return 1; + } } +#endif file->mode = GD_RDONLY; file->idata = 0; @@ -115,20 +134,34 @@ off64_t _GD_SlimSize(int dirfd, struct gd_raw_file_ *file, gd_type_t data_type, int swap gd_unused_) { - char *filepath; off64_t size; dtrace("%i, %p, 0x%X", dirfd, file, data_type); - /* this is easily broken, but the best we can do for now... */ - filepath = gd_MakeFullPathOnly(file->D, dirfd, file->name); - if (filepath == NULL) { - dreturn("%i", 1); - return 1; +#ifdef HAVE_SLIMDRAWSIZE + { + int fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); + if (fd < 0) { + dreturn("%i", -1); + return -1; + } + + size = slimdrawsize(fd); + close(fd); } +#else + { + /* this is easily broken, but the best we can do in this case */ + char *filepath = gd_MakeFullPathOnly(file->D, dirfd, file->name); + if (filepath == NULL) { + dreturn("%i", -1); + return -1; + } - size = slimrawsize(filepath); - free(filepath); + size = slimrawsize(filepath); + free(filepath); + } +#endif if (size < 0) { 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-07 19:49:22
|
Revision: 902 http://sourceforge.net/p/getdata/code/902 Author: ketiltrout Date: 2014-05-07 19:49:19 +0000 (Wed, 07 May 2014) Log Message: ----------- Update. Modified Paths: -------------- trunk/getdata/test/encode_support.c Modified: trunk/getdata/test/encode_support.c =================================================================== --- trunk/getdata/test/encode_support.c 2014-05-07 18:03:39 UTC (rev 901) +++ trunk/getdata/test/encode_support.c 2014-05-07 19:49:19 UTC (rev 902) @@ -34,7 +34,7 @@ #endif #ifdef USE_BZIP2 -#define GD_BZIP2_MODE GD_RDONLY +#define GD_BZIP2_MODE GD_RDWR #else #define GD_BZIP2_MODE -1 #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-07 18:03:44
|
Revision: 901 http://sourceforge.net/p/getdata/code/901 Author: ketiltrout Date: 2014-05-07 18:03:39 +0000 (Wed, 07 May 2014) Log Message: ----------- Bzip2 write support. Also fixed seeking past the EOF of a gzipped file. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/matlab/matlab.c trunk/getdata/bindings/perl/GetData.xs trunk/getdata/src/bzip.c trunk/getdata/src/compat.c trunk/getdata/src/encoding.c trunk/getdata/src/fpos.c trunk/getdata/src/gzip.c trunk/getdata/src/internal.h trunk/getdata/src/sie.c trunk/getdata/test/Makefile.am trunk/getdata/test/bzip_put.c trunk/getdata/test/test.h Added Paths: ----------- trunk/getdata/test/bzip_add.c trunk/getdata/test/bzip_get_far.c trunk/getdata/test/bzip_get_get2.c trunk/getdata/test/bzip_get_put.c trunk/getdata/test/bzip_move_to.c trunk/getdata/test/bzip_put_back.c trunk/getdata/test/bzip_put_endian.c trunk/getdata/test/bzip_put_get.c trunk/getdata/test/bzip_put_pad.c trunk/getdata/test/bzip_put_sub.c trunk/getdata/test/bzip_sync.c trunk/getdata/test/gzip_get_far.c trunk/getdata/test/gzip_put_pad.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/ChangeLog 2014-05-07 18:03:39 UTC (rev 901) @@ -1,3 +1,26 @@ +2014-05-06 D. V. Wiebe <ge...@ke...> svn:901 + * src/encoding.c: Add bzip2 OOP write support. + * src/bzip.c (_GD_Bzip2DoOpen _GD_Bzip2Open _GD_Bzip2Seek _GD_Bzip2Close + _GD_Bzip2Read): Handle writes. Properly clean up on error. Track file->pos. + * src/bzip.c (_GD_Bzip2Write _GD_Bzip2Sync): Added. + * test/bzip_add.c test/bzip_put_back.c test/bzip_move_to.c + test/bzip_get_far.c test/bzip_put_pad.c test/bzip_put_sub.c + test/bzip_get_get2.c test/bzip_put_get.c test/bzip_put_endian.c + test/bzip_sync.c test/bzip_get_put.c: Added. + * test/bzip_put.c: Replaced with a working test. + + * src/fpos.c (_GD_WriteSeek): Fix offset in the seek call. + * src/gzip.c (_GD_GzipSeek): Handle seeks past the EOF while reading. + * test/gzip_get_far.c test/gzip_put_pad.c: Added. + + * test/test.h: Remove unnecessary include statements. + + * src/encoding.c (_GD_MoveOver): Don't attempt to change mode if not needed. + + * bindings/matlab/matlab.c (gdmx_from_string_list): Use mxFree. + + * bindings/perl/GetData.xs (gdp_get_type): Fix undef check. + 2014-05-05 D. V. Wiebe <ge...@ke...> svn:896 * src/encoding.c (gd_encoding_support): Call _GD_InitialiseFramework(). Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/NEWS 2014-05-07 18:03:39 UTC (rev 901) @@ -15,7 +15,7 @@ * 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). + (But see GD_REN_DANGLE in the API section below). * 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 @@ -24,6 +24,10 @@ indicates something pathological happening.) The GD_MAX_CARRAY_LENGTH symbol has been removed from the GetData header file. + * Write support for bzip2-encoded data has been added. This works identically + to how writing gzip-encoded data is written. See the gzip discussion in the + 0.8.0 section below for important notes. + * 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 @@ -116,6 +120,9 @@ * 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: Attempts to read past the EOF of a gzipped field no longer results + in an I/O errorr, but successfully returns no data. + API Changes: * The comp_scal member of the gd_entry_t object has been replaced with a flags @@ -130,7 +137,7 @@ * 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) + target has been renamed (instead it will turn 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. Modified: trunk/getdata/bindings/matlab/matlab.c =================================================================== --- trunk/getdata/bindings/matlab/matlab.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/bindings/matlab/matlab.c 2014-05-07 18:03:39 UTC (rev 901) @@ -799,7 +799,7 @@ for (i = 0; l[i]; ++i) { ptr = (mxArray **)mxRealloc(s, sizeof(mxArray*) * (i + 1)); if (ptr == NULL) { - free(s); + mxFree(s); mexErrMsgIdAndTxt("GetData:GDMX:Alloc", "Out of memory."); } s = ptr; Modified: trunk/getdata/bindings/perl/GetData.xs =================================================================== --- trunk/getdata/bindings/perl/GetData.xs 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/bindings/perl/GetData.xs 2014-05-07 18:03:39 UTC (rev 901) @@ -96,7 +96,7 @@ { dtrace("%p, \"%s\", \"%s\"", sv, pkg, func); - if (sv == NULL && *sv == undef) + if (sv == NULL || *sv == undef) croak("%s::%s() - Value may not be undef", pkg, func); if (sv_isa(*sv, "Math::Complex")) { @@ -867,6 +867,8 @@ SV *ret, **dummy; int n, sem = GD_SYNTAX_ABORT; int was_rv = 0; + AV *av; + int len; /* local stack pointer */ dSP; @@ -919,56 +921,53 @@ /* ferret out response */ switch (SvTYPE(ret)) { - AV *av; - int len; - case SVt_IV: - sem = SvIV(ret); - break; + sem = SvIV(ret); + break; case SVt_PVAV: - av = (AV *)ret; - len = av_len(av); - if (len < 0) { - croak("GetData: parser callback returned empty array."); - return GD_SYNTAX_ABORT; /* ca'n't get here */ - } else if (len > 1) { - croak("GetData: too many elements in array returned by parser " - "callback."); - return GD_SYNTAX_ABORT; /* ca'n't get here */ - } else if (len == 0) { - SV **val = av_fetch(av, 0, 0); - if (val == NULL || SvROK(*val)) { - croak("GetData: bad data type in array returned by parser callback."); + av = (AV *)ret; + len = av_len(av); + if (len < 0) { + croak("GetData: parser callback returned empty array."); return GD_SYNTAX_ABORT; /* ca'n't get here */ - } - - if (SvTYPE(*val) == SVt_IV) { - sem = SvIV(*val); - } else if (SvTYPE(*val) == SVt_PV) { - pdata->line = strdup(SvPV_nolen(*val)); - sem = GD_SYNTAX_RESCAN; - } else { - croak("GetData: bad data type in array returned by parser callback."); + } else if (len > 1) { + croak("GetData: too many elements in array returned by parser " + "callback."); return GD_SYNTAX_ABORT; /* ca'n't get here */ - } - } else { /* len == 1 */ - SV **val0 = av_fetch(av, 0, 0); - SV **val1 = av_fetch(av, 1, 0); + } else if (len == 0) { + SV **val = av_fetch(av, 0, 0); + if (val == NULL || SvROK(*val)) { + croak("GetData: bad data type in array returned by parser callback."); + return GD_SYNTAX_ABORT; /* ca'n't get here */ + } - if (val0 == NULL || SvROK(*val0) || val1 == NULL || SvROK(*val1)) { - croak("GetData: bad data type in array returned by parser callback."); - return GD_SYNTAX_ABORT; /* ca'n't get here */ - } + if (SvTYPE(*val) == SVt_IV) { + sem = SvIV(*val); + } else if (SvTYPE(*val) == SVt_PV) { + pdata->line = strdup(SvPV_nolen(*val)); + sem = GD_SYNTAX_RESCAN; + } else { + croak("GetData: bad data type in array returned by parser callback."); + return GD_SYNTAX_ABORT; /* ca'n't get here */ + } + } else { /* len == 1 */ + SV **val0 = av_fetch(av, 0, 0); + SV **val1 = av_fetch(av, 1, 0); - if (SvTYPE(*val0) == SVt_IV && SvTYPE(*val1) == SVt_PV) { - sem = SvIV(*val0); - pdata->line = strdup(SvPV_nolen(*val1)); - } else { - croak("GetData: bad data type in array returned by parser callback."); - return GD_SYNTAX_ABORT; /* ca'n't get here */ + if (val0 == NULL || SvROK(*val0) || val1 == NULL || SvROK(*val1)) { + croak("GetData: bad data type in array returned by parser callback."); + return GD_SYNTAX_ABORT; /* ca'n't get here */ + } + + if (SvTYPE(*val0) == SVt_IV && SvTYPE(*val1) == SVt_PV) { + sem = SvIV(*val0); + pdata->line = strdup(SvPV_nolen(*val1)); + } else { + croak("GetData: bad data type in array returned by parser callback."); + return GD_SYNTAX_ABORT; /* ca'n't get here */ + } } - } - break; + break; case SVt_PV: pdata->line = strdup(SvPV_nolen(ret)); sem = GD_SYNTAX_RESCAN; Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/src/bzip.c 2014-05-07 18:03:39 UTC (rev 901) @@ -28,6 +28,8 @@ #define _GD_Bzip2Open libgetdatabzip2_LTX_GD_Bzip2Open #define _GD_Bzip2Seek libgetdatabzip2_LTX_GD_Bzip2Seek #define _GD_Bzip2Read libgetdatabzip2_LTX_GD_Bzip2Read +#define _GD_Bzip2Write libgetdatabzip2_LTX_GD_Bzip2Write +#define _GD_Bzip2Sync libgetdatabzip2_LTX_GD_Bzip2Sync #define _GD_Bzip2Close libgetdatabzip2_LTX_GD_Bzip2Close #define _GD_Bzip2Size libgetdatabzip2_LTX_GD_Bzip2Size #endif @@ -42,6 +44,7 @@ BZFILE* bzfile; FILE* stream; int bzerror; + int write; int stream_end; int pos, end; off64_t base; @@ -51,36 +54,60 @@ /* The bzip encoding scheme uses edata as a gd_bzdata pointer. If a file is * open, idata = 0 otherwise idata = -1. */ -static struct gd_bzdata *_GD_Bzip2DoOpen(int dirfd, struct gd_raw_file_* file) +static struct gd_bzdata *_GD_Bzip2DoOpen(int dirfd, struct gd_raw_file_* file, + unsigned int mode) { int fd; struct gd_bzdata *ptr; + FILE *stream; + const char *fdmode = "rb"; - dtrace("%i, %p", dirfd, file); + dtrace("%i, %p, 0x%X", dirfd, file, mode); - if ((ptr = (struct gd_bzdata *)malloc(sizeof(struct gd_bzdata))) == NULL) { + if (mode & GD_FILE_READ) { + fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); + } else if (mode & GD_FILE_TEMP) { + fd = _GD_MakeTempFile(file->D, dirfd, file->name); + fdmode = "wb"; + } else { /* internal error */ + errno = EINVAL; /* I guess ... ? */ dreturn("%p", NULL); return NULL; } - if ((fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY, 0666)) == -1) { - free(ptr); + if (fd < 0) { dreturn("%p", NULL); return NULL; } - if ((ptr->stream = fdopen(fd, "rb")) == NULL) { + if ((stream = fdopen(fd, fdmode)) == NULL) { close(fd); - free(ptr); dreturn("%p", NULL); return NULL; } + if ((ptr = (struct gd_bzdata *)malloc(sizeof(struct gd_bzdata))) == NULL) { + dreturn("%p", NULL); + return NULL; + } + + ptr->stream = stream; ptr->bzerror = ptr->stream_end = 0; - ptr->bzfile = BZ2_bzReadOpen(&ptr->bzerror, ptr->stream, 0, 0, NULL, 0); + if (mode & GD_FILE_READ) { + ptr->bzfile = BZ2_bzReadOpen(&ptr->bzerror, stream, 0, 0, NULL, 0); + ptr->write = 0; + } else { + ptr->bzfile = BZ2_bzWriteOpen(&ptr->bzerror, stream, 9, 0, 30); + ptr->write = 1; + memset(ptr->data, 0, GD_BZIP_BUFFER_SIZE); + } - if (ptr->bzfile == NULL || ptr->bzerror != BZ_OK) { - fclose(ptr->stream); + if (ptr->bzerror != BZ_OK) { + if (mode & GD_FILE_READ) + BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); + else + BZ2_bzWriteClose(&ptr->bzerror, ptr->bzfile, 0, NULL, NULL); + fclose(stream); free(ptr); dreturn("%p", NULL); return NULL; @@ -88,81 +115,115 @@ ptr->pos = ptr->end = 0; ptr->base = 0; + file->pos = 0; dreturn("%p", ptr); return ptr; } int _GD_Bzip2Open(int dirfd, struct gd_raw_file_* file, int swap gd_unused_, - unsigned int mode gd_unused_) + unsigned int mode) { - dtrace("%i, %p, <unused>, <unused>", dirfd, file); + dtrace("%i, %p, <unused>, 0x%X", dirfd, file, mode); - file->edata = _GD_Bzip2DoOpen(dirfd, file); + file->edata = _GD_Bzip2DoOpen(dirfd, file, mode); if (file->edata == NULL) { dreturn("%i", 1); return 1; } - file->mode = GD_FILE_READ; + file->mode = mode; file->idata = 0; dreturn("%i", 0); return 0; } off64_t _GD_Bzip2Seek(struct gd_raw_file_* file, off64_t count, - gd_type_t data_type, unsigned int mode gd_unused_) + gd_type_t data_type, unsigned int mode) { - struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; + struct gd_bzdata *ptr; - dtrace("%p, %lli, 0x%X, <unused>", file, (long long)count, data_type); + dtrace("%p, %lli, 0x%X, 0x%X", file, (long long)count, data_type, mode); + ptr = (struct gd_bzdata *)(file[(mode == GD_FILE_WRITE) ? 1 : 0].edata); + + /* nothing to do */ + if (ptr->base + ptr->pos == count * GD_SIZE(data_type)) { + dreturn("%lli", (long long)count); + return count; + } + count *= GD_SIZE(data_type); - if (ptr->base > count) { - /* a backwards seek -- reopen the file */ - ptr->bzerror = 0; - BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); - ptr->bzfile = BZ2_bzReadOpen(&ptr->bzerror, ptr->stream, 0, 0, NULL, 0); + if (mode == GD_FILE_WRITE) { + /* we only get here when we need to pad */ + count -= file->pos * GD_SIZE(data_type); + while (ptr->base < count) { + int n; + if (count > GD_BZIP_BUFFER_SIZE) + n = GD_BZIP_BUFFER_SIZE; + else + n = count; - if (ptr->bzfile == NULL || ptr->bzerror != BZ_OK) { - fclose(ptr->stream); - dreturn("%i", -1); - return -1; + _GD_Bzip2Write(file + 1, ptr->data, GD_UINT8, n); + count -= n; } - ptr->pos = ptr->end = 0; - ptr->base = ptr->stream_end = 0; - } + } else { + if (ptr->base > count) { + /* a backwards seek: reopen the file */ + ptr->bzerror = 0; + BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); + if (ptr->bzerror != BZ_OK) { + fclose(ptr->stream); + dreturn("%i", -1); + return -1; + } - /* seek forward the slow way */ - while (ptr->base + ptr->end < count) { - int n; + rewind(ptr->stream); + ptr->bzfile = BZ2_bzReadOpen(&ptr->bzerror, ptr->stream, 0, 0, NULL, 0); - ptr->bzerror = 0; - n = BZ2_bzRead(&ptr->bzerror, ptr->bzfile, ptr->data, - GD_BZIP_BUFFER_SIZE); + if (ptr->bzerror != BZ_OK) { + BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); + fclose(ptr->stream); + dreturn("%i", -1); + return -1; + } + ptr->pos = ptr->end = 0; + ptr->base = ptr->stream_end = 0; + } - if (ptr->bzerror == BZ_OK || ptr->bzerror == BZ_STREAM_END) { - ptr->base += ptr->end; - ptr->end = n; - } else { - dreturn("%i", -1); - return -1; + /* seek forward the slow way */ + while (ptr->base + ptr->end < count) { + int n; + + /* eof */ + if (ptr->stream_end) + break; + + ptr->bzerror = 0; + n = BZ2_bzRead(&ptr->bzerror, ptr->bzfile, ptr->data, + GD_BZIP_BUFFER_SIZE); + + if (ptr->bzerror == BZ_OK || ptr->bzerror == BZ_STREAM_END) { + ptr->base += ptr->end; + ptr->end = n; + if (ptr->bzerror == BZ_STREAM_END) + ptr->stream_end = 1; + } else { + dreturn("%i", -1); + return -1; + } } - /* eof */ - if (ptr->bzerror != BZ_OK) { - ptr->stream_end = 1; - break; - } + ptr->pos = (ptr->stream_end && count >= ptr->base + ptr->end) ? ptr->end : + count - ptr->base; } + + file->pos = (ptr->base + ptr->pos) / GD_SIZE(data_type); - ptr->pos = (ptr->bzerror == BZ_STREAM_END && count >= ptr->base + ptr->end) ? - ptr->end : count - ptr->base; - - dreturn("%lli", (long long)((ptr->base + ptr->pos) / GD_SIZE(data_type))); - return (ptr->base + ptr->pos) / GD_SIZE(data_type); + dreturn("%lli", (long long)file->pos); + return file->pos;; } ssize_t _GD_Bzip2Read(struct gd_raw_file_ *restrict file, void *restrict data, @@ -217,18 +278,59 @@ nbytes = 0; } + file->pos = (ptr->base + ptr->pos) / GD_SIZE(data_type); + dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); return nmemb - nbytes / GD_SIZE(data_type); } +ssize_t _GD_Bzip2Write(struct gd_raw_file_ *file, const void *data, + gd_type_t data_type, size_t nmemb) +{ + struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; + ssize_t n; + + dtrace("%p, %p, 0x%X, %" PRNsize_t, file, data, data_type, nmemb); + + n = GD_SIZE(data_type) * nmemb; + if (n > INT_MAX) + n = INT_MAX; + + BZ2_bzWrite(&ptr->bzerror, ptr->bzfile, (void*)data, (int)n); + + if (ptr->bzerror) + n = -1; + else { + ptr->base += n; + n /= GD_SIZE(data_type); + file->pos += n; + } + + dreturn("%" PRNssize_t, n); + return n; +} + +/* This function does nothing */ +int _GD_Bzip2Sync(struct gd_raw_file_ *file gd_unused_) +{ + dtrace("<unused>"); + + dreturn("%i", 0); + return 0; +} + int _GD_Bzip2Close(struct gd_raw_file_ *file) { struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; dtrace("%p", file); ptr->bzerror = 0; - BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); - if (fclose(ptr->stream)) { + if (ptr->write) + BZ2_bzWriteClose(&ptr->bzerror, ptr->bzfile, 0, NULL, NULL); + else + BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); + + if (ptr->bzerror || fclose(ptr->stream)) { dreturn("%i", 1); return 1; } @@ -248,14 +350,14 @@ dtrace("%i, %p, 0x%X, <unused>", dirfd, file, data_type); - ptr = _GD_Bzip2DoOpen(dirfd, file); + ptr = _GD_Bzip2DoOpen(dirfd, file, GD_FILE_READ); if (ptr == NULL) { dreturn("%i", -1); return -1; } - /* seek forward the slow way to the end */ + /* seek forward the slow way to the end */ while (ptr->bzerror != BZ_STREAM_END) { int n; Modified: trunk/getdata/src/compat.c =================================================================== --- trunk/getdata/src/compat.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/src/compat.c 2014-05-07 18:03:39 UTC (rev 901) @@ -49,7 +49,7 @@ int ret; char *path; - dtrace("%p, %i, \"%s\", %x, 0%o", D, dirfd, name, flags, mode); + dtrace("%p, %i, \"%s\", 0x%X, 0%o", D, dirfd, name, flags, mode); path = _GD_MakeFullPathOnly(D, dirfd, name); ret = open(path, flags | O_BINARY, mode); @@ -100,7 +100,7 @@ int ret; char *path; - dtrace("%p, %i, \"%s\", %p, %x", D, dirfd, name, buf, flags); + dtrace("%p, %i, \"%s\", %p, 0x%X", D, dirfd, name, buf, flags); path = _GD_MakeFullPathOnly(D, dirfd, name); #ifdef HAVE_LSTAT Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/src/encoding.c 2014-05-07 18:03:39 UTC (rev 901) @@ -74,16 +74,18 @@ #ifdef USE_BZIP2 #define GD_EF_PROVIDES \ - GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE + GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE | \ + GD_EF_WRITE | GD_EF_SYNC #define GD_INT_FUNCS \ &_GD_GenericName, &_GD_Bzip2Open, &_GD_Bzip2Close, &_GD_Bzip2Seek, \ - &_GD_Bzip2Read, &_GD_Bzip2Size, NULL /* WRITE */, NULL /* SYNC */, \ + &_GD_Bzip2Read, &_GD_Bzip2Size, &_GD_Bzip2Write, &_GD_Bzip2Sync, \ &_GD_GenericMove, &_GD_GenericUnlink #else #define GD_INT_FUNCS GD_EF_NULL_SET #define GD_EF_PROVIDES 0 #endif - GD_EXT_ENCODING_GEN(GD_BZIP2_ENCODED, ".bz2", GD_EF_ECOR, "Bzip2", "bzip2"), + GD_EXT_ENCODING_GEN(GD_BZIP2_ENCODED, ".bz2", GD_EF_ECOR | GD_EF_OOP, "Bzip2", + "bzip2"), #undef GD_INT_FUNCS #undef GD_EF_PROVIDES @@ -323,13 +325,18 @@ #ifdef HAVE_FCHMOD int fd; struct stat stat_buf; - mode_t mode; + mode_t mode, tmode; #endif dtrace("%p, %i, %p", D, fragment, file); #ifdef HAVE_FCHMOD + if (gd_StatAt(D, dirfd, file[1].name, &stat_buf, 0)) + tmode = 0644; + else + tmode = stat_buf.st_mode; + if (gd_StatAt(D, dirfd, file[0].name, &stat_buf, 0)) - mode = 0644; + mode = tmode; else mode = stat_buf.st_mode; #endif @@ -349,9 +356,11 @@ } #ifdef HAVE_FCHMOD - fd = gd_OpenAt(file->D, dirfd, file[0].name, O_RDONLY, 0666); - fchmod(fd, mode); - close(fd); + if (tmode != mode) { + fd = gd_OpenAt(file->D, dirfd, file[0].name, O_RDONLY, 0666); + fchmod(fd, mode); + close(fd); + } #endif dreturn("%i", 0); Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/src/fpos.c 2014-05-07 18:03:39 UTC (rev 901) @@ -176,63 +176,65 @@ dtrace("%p, %p, %p, %lli, 0x%X", D, E, enc, (long long)offset, mode); /* in this case we need to close and then re-open the file */ - if ((offset < E->e->u.raw.file[which].pos) && oop_write) { - if (_GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_KEEP)) { - dreturn("%i", -1); - return -1; - } else if (_GD_InitRawIO(D, E, NULL, -1, NULL, GD_EF_SEEK, GD_FILE_WRITE, - _GD_FileSwapBytes(D, E))) - { - dreturn("%i", -1); - return -1; + if (oop_write) { + if (offset < E->e->u.raw.file[which].pos) { + if (_GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_KEEP)) { + dreturn("%i", -1); + return -1; + } else if (_GD_InitRawIO(D, E, NULL, -1, NULL, GD_EF_SEEK, GD_FILE_WRITE, + _GD_FileSwapBytes(D, E))) + { + dreturn("%i", -1); + return -1; + } } - } - if (oop_write && E->e->u.raw.file[0].idata >= 0) { - /* read from the old file until we reach the point we're interested in or - * run out of data */ - char buffer[GD_BUFFER_SIZE]; - ssize_t n_read, n_wrote; + if (E->e->u.raw.file[0].idata >= 0) { + /* read from the old file until we reach the point we're interested in or + * run out of data */ + char buffer[GD_BUFFER_SIZE]; + ssize_t n_read, n_wrote; - while (offset * GD_SIZE(E->EN(raw,data_type)) > GD_BUFFER_SIZE) { - n_read = (*enc->read)(E->e->u.raw.file, buffer, E->EN(raw,data_type), + while (offset * GD_SIZE(E->EN(raw,data_type)) > GD_BUFFER_SIZE) { + n_read = (*enc->read)(E->e->u.raw.file, buffer, E->EN(raw,data_type), GD_BUFFER_SIZE); - if (n_read > 0) { - n_wrote = (*enc->write)(E->e->u.raw.file + 1, buffer, - E->EN(raw,data_type), n_read); - if (n_wrote != n_read) { + if (n_read > 0) { + n_wrote = (*enc->write)(E->e->u.raw.file + 1, buffer, + E->EN(raw,data_type), n_read); + if (n_wrote != n_read) { + dreturn("%i", -1); + return -1; + } + offset -= n_wrote; + pos += n_wrote; + } else if (n_read < 0) { dreturn("%i", -1); return -1; } - offset -= n_wrote; - pos += n_wrote; - } else if (n_read < 0) { - dreturn("%i", -1); - return -1; } - } - if (offset > 0) { - n_read = (*enc->read)(E->e->u.raw.file, buffer, E->EN(raw,data_type), + if (offset > 0) { + n_read = (*enc->read)(E->e->u.raw.file, buffer, E->EN(raw,data_type), offset); - if (n_read > 0) { - n_wrote = (*enc->write)(E->e->u.raw.file + 1, buffer, - E->EN(raw,data_type), n_read); - if (n_wrote != n_read) { + if (n_read > 0) { + n_wrote = (*enc->write)(E->e->u.raw.file + 1, buffer, + E->EN(raw,data_type), n_read); + if (n_wrote != n_read) { + dreturn("%i", -1); + return -1; + } + offset -= n_wrote; + pos += n_wrote; + } else if (n_read < 0) { dreturn("%i", -1); return -1; } - offset -= n_wrote; - pos += n_wrote; - } else if (n_read < 0) { - dreturn("%i", -1); - return -1; } } } - pos += (*enc->seek)(E->e->u.raw.file + which, offset, E->EN(raw,data_type), - mode); + pos = (*enc->seek)(E->e->u.raw.file + which, pos + offset, + E->EN(raw,data_type), mode); dreturn("%lli", (long long)pos); return pos; @@ -331,7 +333,7 @@ } /* Set the I/O position of the given field - */ +*/ off64_t gd_seek64(DIRFILE *D, const char *field_code_in, off64_t frame_num, off64_t sample_num, int whence) { Modified: trunk/getdata/src/gzip.c =================================================================== --- trunk/getdata/src/gzip.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/src/gzip.c 2014-05-07 18:03:39 UTC (rev 901) @@ -93,8 +93,13 @@ (off_t)count, SEEK_SET); if (n == -1) { - dreturn("%i", -1); - return -1; + /* gzseek returns error on attempts to seek past the EOF in read mode */ + if (mode != GD_FILE_WRITE && gzeof((gzFile)file[0].edata)) + n = gztell((gzFile)file[0].edata); + else { + dreturn("%i", -1); + return -1; + } } n /= GD_SIZE(data_type); Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/src/internal.h 2014-05-07 18:03:39 UTC (rev 901) @@ -96,6 +96,9 @@ #ifdef HAVE_DIRECT_H #include <direct.h> #endif +#ifdef HAVE_IO_H +#include <io.h> +#endif /* MSVC types */ #ifdef _MSC_VER @@ -326,18 +329,6 @@ #endif #endif -/* For the C99 integer types */ -#ifdef HAVE_INTTYPES_H -# ifndef __STDC_FORMAT_MACROS -# define __STDC_FORMAT_MACROS -# endif -#include <inttypes.h> -#endif - -#ifdef HAVE_IO_H -# include <io.h> -#endif - #define GD_ARM_FLAG (GD_ARM_ENDIAN | GD_NOT_ARM_ENDIAN) /* Internal type conventions: @@ -1277,9 +1268,11 @@ gd_type_t data_type, unsigned int); ssize_t _GD_Bzip2Read(struct gd_raw_file_ *restrict, void *restrict, gd_type_t, size_t); -int _GD_Bzip2Close(struct gd_raw_file_* file); -off64_t _GD_Bzip2Size(int, struct gd_raw_file_* file, gd_type_t data_type, - int swap); +ssize_t _GD_Bzip2Write(struct gd_raw_file_ *restrict, const void *restrict, + gd_type_t, size_t); +int _GD_Bzip2Sync(struct gd_raw_file_*); +int _GD_Bzip2Close(struct gd_raw_file_*); +off64_t _GD_Bzip2Size(int, struct gd_raw_file_*, gd_type_t, int); /* gzip I/O methods */ int _GD_GzipOpen(int, struct gd_raw_file_* file, int swap, unsigned int); Modified: trunk/getdata/src/sie.c =================================================================== --- trunk/getdata/src/sie.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/src/sie.c 2014-05-07 18:03:39 UTC (rev 901) @@ -495,7 +495,7 @@ rin++; for (i = 0; i < (size_t)rin; ++i) { - dprintf_sie("%i: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", + dprintf_sie("%zu: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X", i, ((char*)p)[size * i + 0], ((char*)p)[size * i + 1], ((char*)p)[size * i + 2], ((char*)p)[size * i + 3], ((char*)p)[size * i + 4], ((char*)p)[size * i + 5], Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/test 2014-05-07 18:03:39 UTC (rev 901) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -160,11 +160,22 ## bof_lincom bof_phase bof_phase_neg +bzip_add bzip_get +bzip_get_far bzip_get_get +bzip_get_get2 +bzip_get_put bzip_move_from +bzip_move_to bzip_nframes bzip_put +bzip_put_back +bzip_put_endian +bzip_put_get +bzip_put_pad +bzip_put_sub +bzip_sync close_bad close_close close_discard ## -575,6 +586,7 ## gzip_add gzip_del gzip_get +gzip_get_far gzip_get_get gzip_get_get2 gzip_get_put ## -585,6 +597,7 ## gzip_put_back gzip_put_endian gzip_put_get +gzip_put_pad gzip_put_sub gzip_sync header_complex Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/test/Makefile.am 2014-05-07 18:03:39 UTC (rev 901) @@ -68,7 +68,10 @@ BOF_TESTS=bof bof_bit bof_index bof_lincom bof_phase bof_phase_neg -BZIP_TESTS=bzip_get bzip_get_get bzip_move_from bzip_nframes +BZIP_TESTS=bzip_add bzip_get bzip_get_far bzip_get_get bzip_get_get2 \ + bzip_get_put bzip_move_from bzip_move_to bzip_nframes bzip_put \ + bzip_put_back bzip_put_endian bzip_put_get bzip_put_pad \ + bzip_put_sub bzip_sync CVLIST_TESTS=cvlist cvlist_array cvlist_array0 cvlist_array_free \ cvlist_array_hidden cvlist_array_meta cvlist_array_meta0 \ @@ -214,9 +217,10 @@ GLOBAL_TESTS=global_flags global_name global_ref global_ref_empty global_ref_set -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_put_sub gzip_sync +GZIP_TESTS=gzip_add gzip_del gzip_get gzip_get_far 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_put_pad \ + gzip_put_sub gzip_sync HEADER_TESTS=header_complex Added: trunk/getdata/test/bzip_add.c =================================================================== --- trunk/getdata/test/bzip_add.c (rev 0) +++ trunk/getdata/test/bzip_add.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,77 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_BZIP2 + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data.bz2"; + gd_entry_t e; + int e1, e2, e3, unlink_data, r = 0; + DIRFILE *D; + + rmdirfile(); +#ifdef USE_BZIP2 + D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE | GD_BZIP2_ENCODED); +#else + D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_BZIP2_ENCODED); +#endif + gd_add_raw(D, "data", GD_UINT8, 2, 0); + e1 = gd_error(D); + + /* check */ + e2 = gd_entry(D, "data", &e); +#ifdef USE_BZIP2 + CHECKI(e2, 0); + if (e2 == 0) { + CHECKI(e.field_type, GD_RAW_ENTRY); + CHECKI(e.fragment_index, 0); + CHECKI(e.EN(raw,spf), 2); + CHECKI(e.EN(raw,data_type), GD_UINT8); + gd_free_entry_strings(&e); + } +#else + CHECKI(e2, -1); +#endif + + e3 = gd_close(D); + CHECKI(e3, 0); + + unlink_data = unlink(data); + +#ifdef USE_BZIP2 + CHECKI(unlink_data, 0); + CHECKI(e1, GD_E_OK); +#else + CHECKI(unlink_data, -1); + CHECKI(e1, GD_E_UNSUPPORTED); +#endif + + unlink(format); + rmdir(filedir); + + return r; +#endif +} Added: trunk/getdata/test/bzip_get_far.c =================================================================== --- trunk/getdata/test/bzip_get_far.c (rev 0) +++ trunk/getdata/test/bzip_get_far.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,82 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_BZIP2 + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *bz2data = "dirfile/data.bz2"; + const char *format_data = "data RAW UINT16 8\n"; + uint16_t c[8]; + char command[4096]; + uint16_t data_data[256]; + int fd, n, error, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 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(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256 * sizeof(uint16_t)); + close(fd); + + /* compress */ + snprintf(command, 4096, "%s -f %s > /dev/null", BZIP2, data); + if (gd_system(command)) + return 1; + +#ifdef USE_BZIP2 + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDONLY); +#endif + n = gd_getdata(D, "data", 1000, 0, 1, 0, GD_UINT16, c); + error = gd_error(D); + + gd_discard(D); + + unlink(bz2data); + unlink(format); + rmdir(filedir); + +#ifdef USE_BZIP2 + CHECKI(error, 0); +#else + CHECKI(error, GD_E_UNSUPPORTED); +#endif + CHECKI(n, 0); + + return r; +#endif +} Added: trunk/getdata/test/bzip_get_get2.c =================================================================== --- trunk/getdata/test/bzip_get_get2.c (rev 0) +++ trunk/getdata/test/bzip_get_get2.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,82 @@ +/* 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" + +int main(void) +{ +#if !defined USE_BZIP2 || !defined TEST_BZIP2 + return 77; /* skip test */ +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data"; + const char *bz2data = "dirfile/data.bz2"; + const char *format_data = "data RAW UINT16 8\n"; + uint16_t c1[8], c2[8]; + char command[4096]; + uint16_t data_data[256]; + int fd, i, n1, error1, n2, error2, r = 0; + DIRFILE *D; + + memset(c1, 0, 16); + memset(c2, 0, 16); + rmdirfile(); + mkdir(filedir, 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(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_data, 256 * sizeof(uint16_t)); + close(fd); + + /* compress */ + snprintf(command, 4096, "%s -f %s > /dev/null", BZIP2, data); + if (gd_system(command)) + return 1; + + D = gd_open(filedir, GD_RDONLY | GD_VERBOSE); + n1 = gd_getdata(D, "data", 0, 0, 1, 0, GD_UINT16, c1); + error1 = gd_error(D); + n2 = gd_getdata(D, "data", 0, 0, 1, 0, GD_UINT16, c2); + error2 = gd_error(D); + gd_discard(D); + + unlink(bz2data); + unlink(format); + rmdir(filedir); + + CHECKI(error1, 0); + CHECKI(error2, 0); + CHECKI(n1, 8); + CHECKI(n2, 8); + for (i = 0; i < 8; ++i) { + CHECKUi(i,c1[i], i); + CHECKUi(i,c2[i], i); + } + + return r; +#endif +} Added: trunk/getdata/test/bzip_get_put.c =================================================================== --- trunk/getdata/test/bzip_get_put.c (rev 0) +++ trunk/getdata/test/bzip_get_put.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,170 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_BZIP2 + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_bz2 = "dirfile/data.bz2"; + const char *data = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n"; + const unsigned char bz2data[425] = { + 0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, + 0x53, 0x59, 0xb6, 0xb5, 0xee, 0x95, 0x00, 0x00, + 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xb0, 0x00, 0xc5, 0x52, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x30, 0x09, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x04, + 0xc0, 0x04, 0x98, 0x00, 0x26, 0x00, 0x02, 0x60, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x4c, 0x00, 0x13, 0x00, + 0x01, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x08, + 0x0c, 0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, + 0x2c, 0x30, 0x34, 0x38, 0x3c, 0x40, 0x44, 0x48, + 0x4c, 0x50, 0x54, 0x58, 0x5c, 0x60, 0x64, 0x68, + 0x6c, 0x70, 0x74, 0x78, 0x7c, 0x80, 0x84, 0x88, + 0x8c, 0x90, 0x94, 0x98, 0x9c, 0xa0, 0xa4, 0xa8, + 0xac, 0xb0, 0xb4, 0xb8, 0xbc, 0xc0, 0xc4, 0xc8, + 0xcc, 0xd0, 0xd4, 0xd8, 0xdc, 0xe0, 0xe4, 0xe8, + 0xec, 0xf0, 0xf4, 0xf8, 0xfd, 0x01, 0x05, 0x09, + 0x0d, 0x11, 0x15, 0x19, 0x1d, 0x21, 0x25, 0x29, + 0x2d, 0x31, 0x35, 0x39, 0x3d, 0x41, 0x45, 0x49, + 0x4d, 0x51, 0x55, 0x59, 0x5d, 0x61, 0x65, 0x69, + 0x6d, 0x71, 0x75, 0x79, 0x7d, 0x81, 0x85, 0x89, + 0x8d, 0x91, 0x85, 0x89, 0x8d, 0x91, 0x95, 0x99, + 0x9d, 0xa1, 0xa5, 0xa9, 0xad, 0xb1, 0xb5, 0xb9, + 0xbd, 0xc1, 0xc5, 0xc9, 0xcd, 0xd1, 0xd5, 0xd9, + 0xdd, 0xe1, 0xe5, 0xe9, 0xed, 0xf1, 0xf5, 0xf9, + 0xfe, 0x02, 0x06, 0x0a, 0x0e, 0x12, 0x16, 0x1a, + 0x1e, 0x22, 0x26, 0x2a, 0x2e, 0x32, 0x36, 0x3a, + 0x3e, 0x42, 0x46, 0x4a, 0x56, 0x5a, 0x5e, 0x62, + 0x66, 0x6a, 0x6e, 0x72, 0x76, 0x7a, 0x7e, 0x82, + 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e, 0xa2, + 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe, 0xc2, + 0xc6, 0xca, 0xce, 0xd2, 0xd6, 0xda, 0xde, 0xe2, + 0xe6, 0xea, 0xee, 0xf2, 0xf6, 0xfa, 0xff, 0x03, + 0x07, 0x0b, 0x0f, 0x13, 0x17, 0x1b, 0x17, 0x1b, + 0x1f, 0x23, 0x27, 0x2b, 0x2f, 0x33, 0x37, 0x3b, + 0x3f, 0x43, 0x47, 0x4b, 0x4f, 0x53, 0x57, 0x5b, + 0x5f, 0x63, 0x67, 0x6b, 0x6f, 0x73, 0x77, 0x7b, + 0x7f, 0x83, 0x87, 0x8b, 0x8f, 0x93, 0x97, 0x9b, + 0x9f, 0xa3, 0xa7, 0xab, 0xaf, 0xb3, 0xb7, 0xbb, + 0xbf, 0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7, 0xdb, + 0xdf, 0xe3, 0xe7, 0xeb, 0xef, 0xf3, 0xf4, 0x5d, + 0xc9, 0x14, 0xe1, 0x42, 0x42, 0xda, 0xd7, 0xba, + 0x54 + }; + uint8_t b, c[8], d[8]; + char command[4096]; + int fd, i, m, n, e1, e2, e3, unlink_data, unlink_databz2, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 0777); + + for (i = 0; i < 8; ++i) + d[i] = (uint8_t)(80 + i); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + + fd = open(data_bz2, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, bz2data, 425); + close(fd); + +#ifdef USE_BZIP2 + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED); +#endif + n = gd_getdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + e1 = gd_error(D); + m = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, d); + e2 = gd_error(D); + + e3 = gd_close(D); + CHECKI(e3, 0); + +#ifdef USE_BZIP2 + /* uncompress */ + snprintf(command, 4096, "%s -f %s > /dev/null", BUNZIP2, data_bz2); + if (gd_system(command)) { + r = 1; + } else { + fd = open(data, O_RDONLY | O_BINARY); + if (fd >= 0) { + i = 0; + while (read(fd, &b, sizeof(uint8_t))) { + if (i < 40 || i >= 48) { + CHECKIi(i, b, i); + } else + CHECKIi(i, b, i + 40); + i++; + } + CHECKI(i, 256); + close(fd); + } + } + + for (i = 0; i < 8; ++i) + CHECKIi(i, c[i], 40 + i); +#endif + + unlink_data = unlink(data); + unlink_databz2 = unlink(data_bz2); + unlink(format); + rmdir(filedir); + +#ifdef USE_BZIP2 + CHECKI(unlink_data, 0); + CHECKI(unlink_databz2, -1); + CHECKI(e1, GD_E_OK); + CHECKI(e2, GD_E_OK); + CHECKI(n, 8); + CHECKI(m, 8); +#else + CHECKI(unlink_data, -1); + CHECKI(unlink_databz2, 0); + CHECKI(e1, GD_E_UNSUPPORTED); + CHECKI(e2, GD_E_UNSUPPORTED); + CHECKI(n, 0); + CHECKI(m, 0); +#endif + + return r; +#endif +} Added: trunk/getdata/test/bzip_move_to.c =================================================================== --- trunk/getdata/test/bzip_move_to.c (rev 0) +++ trunk/getdata/test/bzip_move_to.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,111 @@ +/* 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" + +int main(void) +{ + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_bz2 = "dirfile/data.bz2"; + const char *data_raw = "dirfile/data"; + const char *format_data = "data RAW UINT8 8\n/ENCODING none\n/ENDIAN little\n"; + uint8_t data_in[256]; + DIRFILE *D; +#ifdef USE_BZIP2 + uint8_t d; + char command[4096]; + int i; +#endif + int fd, e1, e2, unlink_raw, r = 0; + struct stat buf; + + rmdirfile(); + mkdir(filedir, 0777); + + for (fd = 0; fd < 256; ++fd) + data_in[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(data_raw, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666); + write(fd, data_in, 256); + close(fd); + +#ifdef USE_BZIP2 + D = gd_open(filedir, GD_RDWR | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR); +#endif + gd_alter_encoding(D, GD_BZIP2_ENCODED, 0, 1); + e1 = gd_error(D); + + e2 = gd_close(D); + CHECKI(e2, 0); + +#ifdef USE_BZIP2 + if (stat(data_bz2, &buf)) { + perror("stat"); + r = 1; + } + CHECKI(stat(data_raw, &buf), -1); +#else + if (stat(data_raw, &buf)) { + perror("stat"); + r = 1; + } + CHECKI(stat(data_bz2, &buf), -1); +#endif + +#ifdef USE_BZIP2 + /* uncompress */ + snprintf(command, 4096, "%s -f %s > /dev/null", BUNZIP2, data_bz2); + if (gd_system(command)) { + fprintf(stderr, "command failed: %s\n", command); + r = 1; + } else { + fd = open(data_raw, O_RDONLY | O_BINARY); + if (fd >= 0) { + i = 0; + while (read(fd, &d, sizeof(uint8_t))) { + CHECKIi(i, d, i); + i++; + } + CHECKI(i, 256); + close(fd); + } + } +#endif + + unlink_raw = unlink(data_raw); + unlink(format); + rmdir(filedir); + + CHECKI(unlink_raw, 0); +#ifdef USE_BZIP2 + CHECKI(e1, GD_E_OK); +#else + CHECKI(e1, GD_E_UNSUPPORTED); +#endif + + return r; +} Modified: trunk/getdata/test/bzip_put.c =================================================================== --- trunk/getdata/test/bzip_put.c 2014-05-06 23:43:33 UTC (rev 900) +++ trunk/getdata/test/bzip_put.c 2014-05-07 18:03:39 UTC (rev 901) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2011, 2013 D. V. Wiebe +/* Copyright (C) 2014 D. V. Wiebe * *************************************************************************** * @@ -18,29 +18,25 @@ * along with GetData; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* Attempt to write UINT8 */ #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) { - return 77; /* writing not supported */ -#if 0 +#ifndef TEST_BZIP2 + return 77; +#else const char *filedir = "dirfile"; const char *format = "dirfile/format"; - const char *data = "dirfile/data.txt"; + const char *data_bz2 = "dirfile/data.bz2"; + const char *data = "dirfile/data"; const char *format_data = "data RAW UINT8 8\n"; - uint8_t c[8], d; - int fd, n, error, i; + uint8_t c[8]; +#ifdef USE_BZIP2 + char command[4096]; + uint8_t d; +#endif struct stat buf; + int fd, i, n, e1, e2, stat_data, unlink_data, unlink_bz2, r = 0; DIRFILE *D; memset(c, 0, 8); @@ -54,36 +50,66 @@ write(fd, format_data, strlen(format_data)); close(fd); - D = gd_open(filedir, GD_RDWR | GD_TEXT_ENCODED | GD_VERBOSE); +#ifdef USE_BZIP2 + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED); +#endif n = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); - error = gd_error(D); + e1 = gd_error(D); - gd_discard(D); + e2 = gd_close(D); + CHECKI(e2, 0); - if (stat(data, &buf)) - return 1; + stat_data = stat(data_bz2, &buf); +#ifdef USE_BZIP2 + if (stat_data) { + perror("stat"); + } + CHECKI(stat_data, 0); +#else + CHECKI(stat_data, -1); +#endif - fd = open(data, O_RDONLY | O_BINARY); - i = 0; - while (read(fd, &d, sizeof(uint8_t))) { - if (i < 40 || i > 48) { - if (d != 0) - return 1; - } else if (d != i) - return 1; - i++; +#ifdef USE_BZIP2 + /* uncompress */ + snprintf(command, 4096, "%s -f %s > /dev/null", BUNZIP2, data_bz2); + 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 < 40 || i > 48) { + CHECKIi(i, d, 0); + } else + CHECKIi(i, d, i); + i++; + } + CHECKI(i, 48); + close(fd); + } } - fclose(stream); +#endif - unlink(data); + unlink_bz2 = unlink(data_bz2); + CHECKI(unlink_bz2, -1); + + unlink_data = unlink(data); unlink(format); rmdir(filedir); - if (error) - return 1; - if (n != 8) - return 1; +#ifdef USE_BZIP2 + CHECKI(unlink_data, 0); + CHECKI(e1, GD_E_OK); + CHECKI(n, 8); +#else + CHECKI(unlink_data, -1); + CHECKI(e1, GD_E_UNSUPPORTED); + CHECKI(n, 0); +#endif - return 0; + return r; #endif } Added: trunk/getdata/test/bzip_put_back.c =================================================================== --- trunk/getdata/test/bzip_put_back.c (rev 0) +++ trunk/getdata/test/bzip_put_back.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,101 @@ +/* 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" + +int main(void) +{ +#if ! (defined TEST_BZIP2) || ! (defined USE_BZIP2) + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_bz2 = "dirfile/data.bz2"; + const char *data = "dirfile/data"; + const char *format_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); + + 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); + + D = gd_open(filedir, GD_RDWR | GD_BZIP2_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_bz2, &buf); + if (stat_data) { + perror("stat"); + } + CHECKI(stat_data, 0); + + /* uncompress */ + snprintf(command, 4096, "%s -f %s > /dev/null", BUNZIP2, data_bz2); + 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(format); + rmdir(filedir); + + CHECKI(unlink_data, 0); + + return r; +#endif +} Added: trunk/getdata/test/bzip_put_endian.c =================================================================== --- trunk/getdata/test/bzip_put_endian.c (rev 0) +++ trunk/getdata/test/bzip_put_endian.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,117 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_BZIP2 + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_bz2 = "dirfile/data.bz2"; + const char *data = "dirfile/data"; + const char *format_data = "data RAW UINT16 8\n" +#ifdef WORDS_BIGENDIAN + "ENDIAN little\n"; +#else + "ENDIAN big\n"; +#endif + uint16_t c[8]; +#ifdef USE_BZIP2 + char command[4096]; + uint16_t d; +#endif + struct stat buf; + int fd, i, n, e1, e2, stat_data, unlink_data, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 0777); + + for (i = 0; i < 8; ++i) + c[i] = (uint16_t)(0x102 * i); + + fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666); + write(fd, format_data, strlen(format_data)); + close(fd); + +#ifdef USE_BZIP2 + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED); +#endif + n = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT16, c); + e1 = gd_error(D); + + e2 = gd_close(D); + CHECKI(e2, 0); + + stat_data = stat(data_bz2, &buf); +#ifdef USE_BZIP2 + if (stat_data) { + perror("stat"); + } + CHECKI(stat_data, 0); +#else + CHECKI(stat_data, -1); +#endif + +#ifdef USE_BZIP2 + /* uncompress */ + snprintf(command, 4096, "%s -f %s > /dev/null", BUNZIP2, data_bz2); + if (gd_system(command)) { + r = 1; + } else { + fd = open(data, O_RDONLY | O_BINARY); + if (fd >= 0) { + i = 0; + while (read(fd, &d, sizeof(uint16_t))) { + if (i < 40 || i > 48) { + CHECKIi(i, d, 0); + } else + CHECKIi(i, d, 0x201 * (i - 40)); + i++; + } + CHECKI(i, 48); + close(fd); + } + } +#endif + + unlink_data = unlink(data); + unlink(format); + rmdir(filedir); + +#ifdef USE_BZIP2 + CHECKI(unlink_data, 0); + CHECKI(e1, GD_E_OK); + CHECKI(n, 8); +#else + CHECKI(unlink_data, -1); + CHECKI(e1, GD_E_UNSUPPORTED); + CHECKI(n, 0); +#endif + + return r; +#endif +} Added: trunk/getdata/test/bzip_put_get.c =================================================================== --- trunk/getdata/test/bzip_put_get.c (rev 0) +++ trunk/getdata/test/bzip_put_get.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,83 @@ +/* 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" + +int main(void) +{ +#ifndef TEST_BZIP2 + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data = "dirfile/data.bz2"; + const char *format_data = "data RAW UINT8 8\n"; + uint8_t c[8], d[8]; + int fd, i, m, n, e1, e2, e3, unlink_data, r = 0; + DIRFILE *D; + + memset(c, 0, 8); + rmdirfile(); + mkdir(filedir, 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); + +#ifdef USE_BZIP2 + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR | GD_BZIP2_ENCODED); +#endif + n = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); + e1 = gd_error(D); + m = gd_getdata(D, "data", 5, 0, 1, 0, GD_UINT8, d); + e2 = gd_error(D); + + for (i = 0; i < m; ++i) + CHECKIi(i, d[i], c[i]); + + e3 = gd_close(D); + CHECKI(e3, 0); + + unlink_data = unlink(data); + unlink(format); + rmdir(filedir); + +#ifdef USE_BZIP2 + CHECKI(unlink_data, 0); + CHECKI(e1, GD_E_OK); + CHECKI(e2, GD_E_OK); + CHECKI(n, 8); + CHECKI(m, 8); +#else + CHECKI(unlink_data, -1); + CHECKI(e1, GD_E_UNSUPPORTED); + CHECKI(e2, GD_E_UNSUPPORTED); + CHECKI(n, 0); + CHECKI(m, 0); +#endif + + return r; +#endif +} Added: trunk/getdata/test/bzip_put_pad.c =================================================================== --- trunk/getdata/test/bzip_put_pad.c (rev 0) +++ trunk/getdata/test/bzip_put_pad.c 2014-05-07 18:03:39 UTC (rev 901) @@ -0,0 +1,103 @@ +/* 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" + +int main(void) +{ +#if ! (defined TEST_BZIP2) || ! (defined USE_BZIP2) + return 77; +#else + const char *filedir = "dirfile"; + const char *format = "dirfile/format"; + const char *data_bz2 = "dirfile/data.bz2"; + const char *data = "dirfile/data"; + const char *format_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); + + for (i = 0; i < 8; ++i) + c[i] = (uint8_t)(40 +... [truncated message content] |
From: <ket...@us...> - 2014-05-06 23:43:37
|
Revision: 900 http://sourceforge.net/p/getdata/code/900 Author: ketiltrout Date: 2014-05-06 23:43:33 +0000 (Tue, 06 May 2014) Log Message: ----------- Cross-compile conveniences. Modified Paths: -------------- trunk/getdata/configure.ac Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2014-05-06 22:47:46 UTC (rev 899) +++ trunk/getdata/configure.ac 2014-05-06 23:43:33 UTC (rev 900) @@ -515,6 +515,12 @@ if test -z "$BUILDCC"; then AC_CHECK_PROGS([BUILDCC], [gcc cc cl]) fi + # bindings requiring interpreters aren't built when cross compiling + make_idlbindings=no + make_phpbindings=no + make_pybindings=no + make_perlbindings=no + make_matlabbindings=no else BUILDCC=$CC AC_SUBST([BUILDCC]) @@ -1219,6 +1225,9 @@ echo echo "Configuration summary: " +if test "x${cross_compiling}" != "xno"; then + echo " Cross compiling for: ${host}" +fi echo " ANSI C compatibility mode: ${disable_c99}" echo " Legacy API: ${include_legacy_api}" echo " Verbose debugging: ${enable_debug}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-06 22:47:51
|
Revision: 899 http://sourceforge.net/p/getdata/code/899 Author: ketiltrout Date: 2014-05-06 22:47:46 +0000 (Tue, 06 May 2014) Log Message: ----------- * Fix compiler warnings * Fix test/gzip_del Modified Paths: -------------- trunk/getdata/bindings/python/pygetdata.c trunk/getdata/src/getdata.c trunk/getdata/test/gzip_del.c Modified: trunk/getdata/bindings/python/pygetdata.c =================================================================== --- trunk/getdata/bindings/python/pygetdata.c 2014-05-06 02:33:52 UTC (rev 898) +++ trunk/getdata/bindings/python/pygetdata.c 2014-05-06 22:47:46 UTC (rev 899) @@ -362,14 +362,14 @@ dtrace("%p, %02x, %zi", data, type, ns); - if (type != GD_NULL) - pyobj = PyList_New(0); + if (type == GD_NULL) { + Py_INCREF(Py_None); + dreturn("%p", Py_None); + return Py_None; + } + pyobj = PyList_New(0); switch(type) { - case GD_NULL: - Py_INCREF(Py_None); - dreturn("%p", Py_None); - return Py_None; case GD_UINT8: for (i = 0; i < ns; ++i) if (PyList_Append(pyobj, PyInt_FromLong((long)((uint8_t*)data)[i]))) @@ -433,6 +433,7 @@ if (PyList_Append(pyobj, gdpy_from_complexp(((double*)data) + 2 * i))) return NULL; break; + case GD_NULL: case GD_UNKNOWN: /* prevent compiler warning */ break; } Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2014-05-06 02:33:52 UTC (rev 898) +++ trunk/getdata/src/getdata.c 2014-05-06 22:47:46 UTC (rev 899) @@ -1814,16 +1814,19 @@ } /* 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) +static void _GD_IndirData(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; + int64_t ilen = +#if SIZEOF_SIZE_T == 8 + (len > GD_INT64_MAX) ? GD_INT64_MAX : +#endif + len; - dtrace("%p, %p, 0x%X, %p, %" PRNsize_t ", %p, %" PRNsize_t, D, cbuf, ctype, - ibuf, n, carray, len); + dtrace("%p, 0x%X, %p, %" PRNsize_t ", %p, %" PRNsize_t, cbuf, ctype, ibuf, n, + carray, len); for (i = 0; i < n; ++i) if (ibuf[i] < 0 || ibuf[i] >= ilen) @@ -1884,7 +1887,7 @@ return 0; } - _GD_IndirData(D, cbuf, GD_SIZE(ctype), ibuf, n_read, + _GD_IndirData(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); @@ -2131,8 +2134,11 @@ 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); + len = +#if SIZEOF_SIZE_T == 8 + (E->e->entry[1]->EN(scalar,array_len) > GD_INT64_MAX) ? GD_INT64_MAX : +#endif + E->e->entry[1]->EN(scalar,array_len); for (i = 0; i < n_read; ++i) if (ibuf[i] < 0 || ibuf[i] >= len) Modified: trunk/getdata/test/gzip_del.c =================================================================== --- trunk/getdata/test/gzip_del.c 2014-05-06 02:33:52 UTC (rev 898) +++ trunk/getdata/test/gzip_del.c 2014-05-06 22:47:46 UTC (rev 899) @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 D. V. Wiebe +/* Copyright (C) 2013, 2014 D. V. Wiebe * *************************************************************************** * @@ -20,14 +20,6 @@ */ #include "test.h" -#include <inttypes.h> -#include <stdlib.h> -#include <sys/types.h> -#include <fcntl.h> -#include <string.h> -#include <errno.h> -#include <stdio.h> - /* this tests discarding OOP-writable (also temporary) RAW files */ int main(void) { @@ -54,16 +46,30 @@ write(fd, format_data, strlen(format_data)); close(fd); +#if defined USE_GZIP D = gd_open(filedir, GD_RDWR | GD_GZIP_ENCODED | GD_VERBOSE); +#else + D = gd_open(filedir, GD_RDWR | GD_GZIP_ENCODED); +#endif n = gd_putdata(D, "data", 5, 0, 1, 0, GD_UINT8, c); e1 = gd_error(D); +#if defined USE_GZIP CHECKI(n, 8); CHECKI(e1, GD_E_OK); +#else + CHECKI(n, 0); + CHECKI(e1, GD_E_UNSUPPORTED); +#endif ret = gd_delete(D, "data", GD_DEL_DATA); e2 = gd_error(D); +#if defined USE_GZIP CHECKI(ret, 0); CHECKI(e2, GD_E_OK); +#else + CHECKI(ret, -1); + CHECKI(e2, GD_E_UNSUPPORTED); +#endif e3 = gd_close(D); CHECKI(e3, 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-06 02:33:55
|
Revision: 898 http://sourceforge.net/p/getdata/code/898 Author: ketiltrout Date: 2014-05-06 02:33:52 +0000 (Tue, 06 May 2014) Log Message: ----------- VPATH build fixes. Modified Paths: -------------- trunk/getdata/Makefile.am trunk/getdata/bindings/php/Makefile.am trunk/getdata/bindings/python/Makefile.am trunk/getdata/bindings/python/setup.py.in Modified: trunk/getdata/Makefile.am =================================================================== --- trunk/getdata/Makefile.am 2014-05-05 23:50:42 UTC (rev 897) +++ trunk/getdata/Makefile.am 2014-05-06 02:33:52 UTC (rev 898) @@ -36,6 +36,7 @@ DISTCHECK_CONFIGURE_FLAGS = --with-idl-dlm-dir="$$dc_install_base/idl" \ --with-perl-dir="$$dc_install_base/perl" \ + --with-php-dir="$$dc_install_base/php" \ --with-python-module-dir="$$dc_install_base/python" # matlab-only package Modified: trunk/getdata/bindings/php/Makefile.am =================================================================== --- trunk/getdata/bindings/php/Makefile.am 2014-05-05 23:50:42 UTC (rev 897) +++ trunk/getdata/bindings/php/Makefile.am 2014-05-06 02:33:52 UTC (rev 898) @@ -20,7 +20,7 @@ # php_LTLIBRARIES = getdata.la AM_CFLAGS = ${WALL} ${WEXTRA} -AM_CPPFLAGS = ${CPPFLAGS} ${PHP_CPPFLAGS} +AM_CPPFLAGS = -I$(top_srcdir)/src ${CPPFLAGS} ${PHP_CPPFLAGS} getdata_la_LDFLAGS = -module -avoid-version -shared ${PHP_LDFLAGS} getdata_la_LIBADD = ${PHP_LIBS} ../../src/libgetdata.la getdata_la_SOURCES = getdata.c php_getdata.h Modified: trunk/getdata/bindings/python/Makefile.am =================================================================== --- trunk/getdata/bindings/python/Makefile.am 2014-05-05 23:50:42 UTC (rev 897) +++ trunk/getdata/bindings/python/Makefile.am 2014-05-06 02:33:52 UTC (rev 898) @@ -26,6 +26,8 @@ BUILT_SOURCES = pyconstants.c +EXTRA_DIST = pydirfile.c pygetdata.c pyentry.c pygetdata.h pyfragment.c + distutils_path=build/lib.${PYTHON_PLATFORM}-${PYTHON_VERSION} pygetdata.so: ${distutils_path}/pygetdata.so cp $< $@ Modified: trunk/getdata/bindings/python/setup.py.in =================================================================== --- trunk/getdata/bindings/python/setup.py.in 2014-05-05 23:50:42 UTC (rev 897) +++ trunk/getdata/bindings/python/setup.py.in 2014-05-06 02:33:52 UTC (rev 898) @@ -23,7 +23,9 @@ from distutils.core import setup from distutils.extension import Extension from distutils.command.clean import clean as clean +from distutils.command.build import build as build from os.path import join +from os.path import exists from os import unlink from shutil import copy @@ -52,20 +54,25 @@ unlink(x) clean.run(self) +class gd_build(build): + def run(self): + # if we don't do this, the object files will end up in + # @top_builddir@/bindings/bindings/python, + # instead of + # @builddir@/build/temp.<whatever> + # like they're supposed to. It seems to work, but it's a little crazier + # than we're willing to deal with. + for x in sources: + if not exists(x): + copy(join(srcdir, x), x) + build.run(self) + # deal with out-of-place (VPATH) builds if srcdir != '.': includes.append(srcdir) # to find pygetdata.h - # if we don't do this, the object files will end up in - # @top_builddir@/bindings/bindings/python, - # instead of - # @builddir@/build/temp.<whatever> - # like they're supposed to. It seems to work, but it's a little crazier - # than we're willing to deal with. - for x in sources: - copy(join(srcdir, x), x) - - # handle clean up + # handle set up and clean up + cmdclass['build'] = gd_build cmdclass['clean'] = gd_clean # now add this built source; it always ends up where distutils wants it to be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2014-05-05 23:50:45
|
Revision: 897 http://sourceforge.net/p/getdata/code/897 Author: ketiltrout Date: 2014-05-05 23:50:42 +0000 (Mon, 05 May 2014) Log Message: ----------- Don't export gd_ef_. Modified Paths: -------------- trunk/getdata/src/del.c trunk/getdata/src/encoding.c trunk/getdata/src/endian.c trunk/getdata/src/entry.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.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/name.c trunk/getdata/src/nframes.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c Modified: trunk/getdata/src/del.c =================================================================== --- trunk/getdata/src/del.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/del.c 2014-05-05 23:50:42 UTC (rev 897) @@ -350,7 +350,7 @@ return -1; } - if ((*gd_ef_[E->e->u.raw.file[0].subenc].name)(D, + if ((*_GD_ef[E->e->u.raw.file[0].subenc].name)(D, (const char*)D->fragment[E->fragment_index].enc_data, E->e->u.raw.file, E->e->u.raw.filebase, 0, 0)) { @@ -359,7 +359,7 @@ return -1; } - if ((*gd_ef_[E->e->u.raw.file[0].subenc].unlink)( + if ((*_GD_ef[E->e->u.raw.file[0].subenc].unlink)( D->fragment[E->fragment_index].dirfd, E->e->u.raw.file)) { if (errno != ENOENT) { Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/encoding.c 2014-05-05 23:50:42 UTC (rev 897) @@ -47,7 +47,7 @@ #define GD_EXT_ENCODING_NULL GD_EXT_ENCODING #define GD_EXT_ENCODING_GEN GD_EXT_ENCODING #endif -struct encoding_t gd_ef_[GD_N_SUBENCODINGS] = { +struct encoding_t _GD_ef[GD_N_SUBENCODINGS] = { { GD_UNENCODED, "", GD_EF_ECOR, NULL, "none", 0, &_GD_GenericName, &_GD_RawOpen, &_GD_RawClose, &_GD_RawSeek, &_GD_RawRead, &_GD_RawSize, &_GD_RawWrite, &_GD_RawSync, &_GD_GenericMove, @@ -228,15 +228,15 @@ #endif /* set up the encoding library if required */ - if (gd_ef_[encoding].provides) { + if (_GD_ef[encoding].provides) { char *library; lt_dlhandle lib; /* make the library name */ library = (char *)malloc(sizeof(GETDATA_MODULEDIR) + - strlen(gd_ef_[encoding].affix) + sizeof(PACKAGE_VERSION) + 13); + strlen(_GD_ef[encoding].affix) + sizeof(PACKAGE_VERSION) + 13); if (!library) { - gd_ef_[encoding].provides = 0; + _GD_ef[encoding].provides = 0; #ifdef USE_PTHREAD pthread_mutex_unlock(&gd_mutex_); #endif @@ -245,7 +245,7 @@ } strcat(strcat(strcpy(library, GETDATA_MODULEDIR "/libgetdata"), - gd_ef_[encoding].affix), "-" PACKAGE_VERSION); + _GD_ef[encoding].affix), "-" PACKAGE_VERSION); library[sizeof(GETDATA_MODULEDIR) + 10] -= 'A' - 'a'; /* open */ @@ -254,7 +254,7 @@ if ((lib = lt_dlopenext(library + sizeof(GETDATA_MODULEDIR))) == NULL) { free(library); - gd_ef_[encoding].provides = 0; + _GD_ef[encoding].provides = 0; #ifdef USE_PTHREAD pthread_mutex_unlock(&gd_mutex_); #endif @@ -265,36 +265,36 @@ free(library); /* Try to resolve the symbols */ - if (gd_ef_[encoding].provides & GD_EF_NAME) - gd_ef_[encoding].name = (gd_ef_name_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Name"); - if (gd_ef_[encoding].provides & GD_EF_OPEN) - gd_ef_[encoding].open = (gd_ef_open_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Open"); - if (gd_ef_[encoding].provides & GD_EF_CLOSE) - gd_ef_[encoding].close = (gd_ef_close_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Close"); - if (gd_ef_[encoding].provides & GD_EF_SEEK) - gd_ef_[encoding].seek = (gd_ef_seek_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Seek"); - if (gd_ef_[encoding].provides & GD_EF_READ) - gd_ef_[encoding].read = (gd_ef_read_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Read"); - if (gd_ef_[encoding].provides & GD_EF_SIZE) - gd_ef_[encoding].size = (gd_ef_size_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Size"); - if (gd_ef_[encoding].provides & GD_EF_WRITE) - gd_ef_[encoding].write = (gd_ef_write_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Write"); - if (gd_ef_[encoding].provides & GD_EF_SYNC) - gd_ef_[encoding].sync = (gd_ef_sync_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Sync"); - if (gd_ef_[encoding].provides & GD_EF_UNLINK) - gd_ef_[encoding].unlink = (gd_ef_unlink_t)_GD_ResolveSymbol(lib, - gd_ef_ + encoding, "Unlink"); + if (_GD_ef[encoding].provides & GD_EF_NAME) + _GD_ef[encoding].name = (gd_ef_name_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Name"); + if (_GD_ef[encoding].provides & GD_EF_OPEN) + _GD_ef[encoding].open = (gd_ef_open_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Open"); + if (_GD_ef[encoding].provides & GD_EF_CLOSE) + _GD_ef[encoding].close = (gd_ef_close_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Close"); + if (_GD_ef[encoding].provides & GD_EF_SEEK) + _GD_ef[encoding].seek = (gd_ef_seek_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Seek"); + if (_GD_ef[encoding].provides & GD_EF_READ) + _GD_ef[encoding].read = (gd_ef_read_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Read"); + if (_GD_ef[encoding].provides & GD_EF_SIZE) + _GD_ef[encoding].size = (gd_ef_size_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Size"); + if (_GD_ef[encoding].provides & GD_EF_WRITE) + _GD_ef[encoding].write = (gd_ef_write_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Write"); + if (_GD_ef[encoding].provides & GD_EF_SYNC) + _GD_ef[encoding].sync = (gd_ef_sync_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Sync"); + if (_GD_ef[encoding].provides & GD_EF_UNLINK) + _GD_ef[encoding].unlink = (gd_ef_unlink_t)_GD_ResolveSymbol(lib, + _GD_ef + encoding, "Unlink"); /* we tried our best, don't bother trying again */ - gd_ef_[encoding].provides = 0; + _GD_ef[encoding].provides = 0; } #ifdef USE_PTHREAD pthread_mutex_unlock(&gd_mutex_); @@ -302,15 +302,15 @@ #endif ret = - (funcs & GD_EF_NAME && gd_ef_[encoding].name == NULL) || - (funcs & GD_EF_OPEN && gd_ef_[encoding].open == NULL) || - (funcs & GD_EF_CLOSE && gd_ef_[encoding].close == NULL) || - (funcs & GD_EF_SEEK && gd_ef_[encoding].seek == NULL) || - (funcs & GD_EF_READ && gd_ef_[encoding].read == NULL) || - (funcs & GD_EF_SIZE && gd_ef_[encoding].size == NULL) || - (funcs & GD_EF_WRITE && gd_ef_[encoding].write == NULL) || - (funcs & GD_EF_SYNC && gd_ef_[encoding].sync == NULL) || - (funcs & GD_EF_UNLINK && gd_ef_[encoding].unlink == NULL); + (funcs & GD_EF_NAME && _GD_ef[encoding].name == NULL) || + (funcs & GD_EF_OPEN && _GD_ef[encoding].open == NULL) || + (funcs & GD_EF_CLOSE && _GD_ef[encoding].close == NULL) || + (funcs & GD_EF_SEEK && _GD_ef[encoding].seek == NULL) || + (funcs & GD_EF_READ && _GD_ef[encoding].read == NULL) || + (funcs & GD_EF_SIZE && _GD_ef[encoding].size == NULL) || + (funcs & GD_EF_WRITE && _GD_ef[encoding].write == NULL) || + (funcs & GD_EF_SYNC && _GD_ef[encoding].sync == NULL) || + (funcs & GD_EF_UNLINK && _GD_ef[encoding].unlink == NULL); dreturn("%i", ret); return ret; @@ -364,7 +364,7 @@ { const int clotemp = (flags & GD_FINIRAW_CLOTEMP) ? 1 : 0; const int old_mode = E->e->u.raw.file[0].mode; - const int oop_write = ((gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) + const int oop_write = ((_GD_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) && (old_mode & GD_FILE_WRITE)) ? 1 : 0; dtrace("%p, %p, %i, 0x%X", D, E, fragment, flags); @@ -379,7 +379,7 @@ int n_read, n_wrote, n_to_write; do { - n_to_write = n_read = (*gd_ef_[E->e->u.raw.file[0].subenc].read)( + n_to_write = n_read = (*_GD_ef[E->e->u.raw.file[0].subenc].read)( E->e->u.raw.file, buffer, E->EN(raw,data_type), GD_BUFFER_SIZE); if (n_read < 0) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, @@ -387,7 +387,7 @@ dreturn("%i", -1); return -1; } else while (n_to_write > 0) { - n_wrote = (*gd_ef_[E->e->u.raw.file[0].subenc].write)( + n_wrote = (*_GD_ef[E->e->u.raw.file[0].subenc].write)( E->e->u.raw.file + 1, buffer, E->EN(raw,data_type), n_to_write); if (n_wrote < 0) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, @@ -400,7 +400,7 @@ } while (n_read == GD_BUFFER_SIZE); } - if ((*gd_ef_[E->e->u.raw.file[0].subenc].close)(E->e->u.raw.file + 1)) { + if ((*_GD_ef[E->e->u.raw.file[0].subenc].close)(E->e->u.raw.file + 1)) { dreturn("%i", -1); return -1; } @@ -408,7 +408,7 @@ /* close the file */ if ((E->e->u.raw.file[clotemp].idata >= 0) && - (*gd_ef_[E->e->u.raw.file[clotemp].subenc].close)(E->e->u.raw.file + + (*_GD_ef[E->e->u.raw.file[clotemp].subenc].close)(E->e->u.raw.file + clotemp)) { if (D->error == GD_E_OK) @@ -506,7 +506,7 @@ return 1; } - enc = gd_ef_ + E->e->u.raw.file[0].subenc; + enc = _GD_ef + E->e->u.raw.file[0].subenc; oop_write = ((enc->flags & GD_EF_OOP) && mode == GD_FILE_WRITE) ? 1 : 0; /* Do nothing, if possible */ @@ -606,19 +606,19 @@ dtrace("%p, \"%s\", \"%s\", 0x%08lx, %i, %p", D, name, enc_data, scheme, dirfd, file); - for (i = 0; gd_ef_[i].scheme != GD_ENC_UNSUPPORTED; i++) { - if (scheme == GD_AUTO_ENCODED || scheme == gd_ef_[i].scheme) { - if (gd_ef_[i].ext) { - candidate = (char *)malloc(len + strlen(gd_ef_[i].ext) + 1); + for (i = 0; _GD_ef[i].scheme != GD_ENC_UNSUPPORTED; i++) { + if (scheme == GD_AUTO_ENCODED || scheme == _GD_ef[i].scheme) { + if (_GD_ef[i].ext) { + candidate = (char *)malloc(len + strlen(_GD_ef[i].ext) + 1); if (!candidate) continue; - strcat(strcpy(candidate, name), gd_ef_[i].ext); + strcat(strcpy(candidate, name), _GD_ef[i].ext); } else { if (_GD_MissingFramework(i, GD_EF_NAME)) continue; - if ((*gd_ef_[i].name)(D, enc_data, file, name, 0, 1)) + if ((*_GD_ef[i].name)(D, enc_data, file, name, 0, 1)) continue; candidate = file->name; @@ -630,19 +630,19 @@ if (file != NULL) file->subenc = i; free(candidate); - dreturn("%08lx", gd_ef_[i].scheme); - return gd_ef_[i].scheme; + dreturn("%08lx", _GD_ef[i].scheme); + return _GD_ef[i].scheme; } free(candidate); } } if (scheme != 0 && file != NULL) { - for (i = 0; gd_ef_[i].scheme != GD_ENC_UNSUPPORTED; i++) - if (scheme == gd_ef_[i].scheme) { + for (i = 0; _GD_ef[i].scheme != GD_ENC_UNSUPPORTED; i++) + if (scheme == _GD_ef[i].scheme) { file->subenc = i; - dreturn("0x%08lx", gd_ef_[i].scheme); - return gd_ef_[i].scheme; + dreturn("0x%08lx", _GD_ef[i].scheme); + return _GD_ef[i].scheme; } } @@ -697,14 +697,14 @@ if (file->name == NULL) { file->D = D; file->name = (char *)_GD_Malloc(D, strlen(base) + (temp ? 8 : - strlen(gd_ef_[file->subenc].ext) + 1)); + strlen(_GD_ef[file->subenc].ext) + 1)); if (file->name == NULL) { dreturn("%i", -1); return -1; } strcat(strcpy(file->name, base), temp ? "_XXXXXX" : - gd_ef_[file->subenc].ext); + _GD_ef[file->subenc].ext); } dreturn("%i (%s)", 0, file->name); @@ -773,7 +773,7 @@ /* discard the old file */ _GD_FiniRawIO(D, raw_entry[i], fragment, GD_FINIRAW_DISCARD); - if ((*gd_ef_[temp.subenc].name)(D, + if ((*_GD_ef[temp.subenc].name)(D, (const char*)D->fragment[raw_entry[i]->fragment_index].enc_data, raw_entry[i]->e->u.raw.file, raw_entry[i]->e->u.raw.filebase, 0, 0)) @@ -785,7 +785,7 @@ { raw_entry[i]->e->u.raw.file[0].name = temp.name; raw_entry[i]->e->u.raw.file[0].subenc = temp.subenc; - } else if ((*gd_ef_[temp.subenc].unlink)(D->fragment[fragment].dirfd, + } else if ((*_GD_ef[temp.subenc].unlink)(D->fragment[fragment].dirfd, &temp)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, @@ -933,18 +933,18 @@ 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); return -1; } + /* spin up ltdl if needed */ + _GD_InitialiseFramework(); + /* 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) { + 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; @@ -952,8 +952,8 @@ } /* No write support; try read support */ - for (i = 0; gd_ef_[i].scheme != GD_ENC_UNSUPPORTED; i++) - if (gd_ef_[i].scheme == encoding) { + 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; Modified: trunk/getdata/src/endian.c =================================================================== --- trunk/getdata/src/endian.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/endian.c 2014-05-05 23:50:42 UTC (rev 897) @@ -65,7 +65,7 @@ /* if the field's data type is one byte long, and no in-framework * 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)) + !(_GD_ef[D->entry[i]->e->u.raw.file[0].subenc].flags & GD_EF_SWAP)) continue; /* add this raw field to the list */ Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/entry.c 2014-05-05 23:50:42 UTC (rev 897) @@ -377,7 +377,7 @@ _GD_SetError(D, GD_E_UNKNOWN_ENCODING, GD_E_UNENC_UNDET, NULL, 0, NULL); dreturn("%p", NULL); return NULL; - } else if ((*gd_ef_[E->e->u.raw.file[0].subenc].name)(D, + } else if ((*_GD_ef[E->e->u.raw.file[0].subenc].name)(D, (const char*)D->fragment[E->fragment_index].enc_data, E->e->u.raw.file, E->e->u.raw.filebase, 0, 0)) { Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/flimits.c 2014-05-05 23:50:42 UTC (rev 897) @@ -192,14 +192,14 @@ if (!_GD_Supports(D, E, GD_EF_NAME | GD_EF_SIZE)) break; - if ((*gd_ef_[E->e->u.raw.file[0].subenc].name)(D, + if ((*_GD_ef[E->e->u.raw.file[0].subenc].name)(D, (const char*)D->fragment[E->fragment_index].enc_data, E->e->u.raw.file, E->e->u.raw.filebase, 0, 0)) { break; } - ns = (*gd_ef_[E->e->u.raw.file[0].subenc].size)( + 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)); Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/flush.c 2014-05-05 23:50:42 UTC (rev 897) @@ -38,13 +38,13 @@ switch(E->field_type) { case GD_RAW_ENTRY: if (E->e->u.raw.file[0].idata >= 0 || - ((gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) && + ((_GD_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) && (E->e->u.raw.file[1].idata >= 0))) { if (syn && (D->flags & GD_ACCMODE) == GD_RDWR && (E->e->u.raw.file[0].mode & GD_FILE_WRITE) && - gd_ef_[E->e->u.raw.file[0].subenc].sync != NULL && - (*gd_ef_[E->e->u.raw.file[0].subenc].sync)(E->e->u.raw.file)) + _GD_ef[E->e->u.raw.file[0].subenc].sync != NULL && + (*_GD_ef[E->e->u.raw.file[0].subenc].sync)(E->e->u.raw.file)) { _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 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/fpos.c 2014-05-05 23:50:42 UTC (rev 897) @@ -276,7 +276,7 @@ break; } - if (_GD_WriteSeek(D, E, gd_ef_ + E->e->u.raw.file[0].subenc, offset - + if (_GD_WriteSeek(D, E, _GD_ef + E->e->u.raw.file[0].subenc, offset - E->EN(raw,spf) * D->fragment[E->fragment_index].frame_offset, mode) == -1) { Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/getdata.c 2014-05-05 23:50:42 UTC (rev 897) @@ -292,7 +292,7 @@ return 0; } - if ((*gd_ef_[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, s0, + if ((*_GD_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, s0, E->EN(raw,data_type), GD_FILE_READ) == -1) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -301,7 +301,7 @@ return 0; } - samples_read = (*gd_ef_[E->e->u.raw.file[0].subenc].read)(E->e->u.raw.file, + 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); @@ -312,7 +312,7 @@ return 0; } - if (gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_ECOR) + 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); Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/internal.h 2014-05-05 23:50:42 UTC (rev 897) @@ -918,10 +918,10 @@ #define GD_FINIRAW_DEFER 0x2 #define GD_FINIRAW_CLOTEMP 0x4 -/* number of subencodings (ie. the length of the gd_ef_ array */ +/* 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 */ +/* 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 */ @@ -995,7 +995,7 @@ gd_ef_sync_t sync; gd_ef_move_t move; gd_ef_unlink_t unlink; -} gd_ef_[GD_N_SUBENCODINGS]; +} _GD_ef[GD_N_SUBENCODINGS]; /* Format file fragment metadata */ struct gd_fragment_t { Modified: trunk/getdata/src/mod.c =================================================================== --- trunk/getdata/src/mod.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/mod.c 2014-05-05 23:50:42 UTC (rev 897) @@ -329,7 +329,7 @@ if (D->error) break; - enc = gd_ef_ + E->e->u.raw.file[0].subenc; + enc = _GD_ef + E->e->u.raw.file[0].subenc; /* open the old file */ if (_GD_InitRawIO(D, E, NULL, -1, NULL, 0, GD_FILE_READ, Modified: trunk/getdata/src/move.c =================================================================== --- trunk/getdata/src/move.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/move.c 2014-05-05 23:50:42 UTC (rev 897) @@ -55,8 +55,8 @@ { subencoding = E->e->u.raw.file[0].subenc; } else - for (i = 0; gd_ef_[i].scheme != GD_ENC_UNSUPPORTED; i++) { - if (gd_ef_[i].scheme == encoding) { + for (i = 0; _GD_ef[i].scheme != GD_ENC_UNSUPPORTED; i++) { + if (_GD_ef[i].scheme == encoding) { subencoding = i; break; } @@ -69,7 +69,7 @@ return -1; } - enc_out = gd_ef_ + subencoding; + enc_out = _GD_ef + subencoding; /* Check output encoding */ if (_GD_MissingFramework(subencoding, GD_EF_CLOSE | GD_EF_SEEK | GD_EF_WRITE | @@ -90,7 +90,7 @@ return -1; } - enc_in = gd_ef_ + E->e->u.raw.file[0].subenc; + enc_in = _GD_ef + E->e->u.raw.file[0].subenc; /* if neither encoding scheme does internal byte swapping, and the data * type can't be endianness swapped, sex differences can't matter */ @@ -246,7 +246,7 @@ E->e->u.raw.file[0].name = NULL; E->e->u.raw.file[0].subenc = subencoding; - if ((*gd_ef_[E->e->u.raw.file[0].subenc].name)(D, + if ((*_GD_ef[E->e->u.raw.file[0].subenc].name)(D, (const char*)D->fragment[E->fragment_index].enc_data, E->e->u.raw.file, new_filebase, 0, 0)) { Modified: trunk/getdata/src/name.c =================================================================== --- trunk/getdata/src/name.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/name.c 2014-05-05 23:50:42 UTC (rev 897) @@ -855,7 +855,7 @@ memcpy(&temp, E->e->u.raw.file, sizeof(struct gd_raw_file_)); temp.name = NULL; - if ((*gd_ef_[temp.subenc].name)(D, + if ((*_GD_ef[temp.subenc].name)(D, (const char*)D->fragment[E->fragment_index].enc_data, &temp, filebase, 0, 0)) { @@ -865,7 +865,7 @@ return -1; } - if ((*gd_ef_[temp.subenc].name)(D, + if ((*_GD_ef[temp.subenc].name)(D, (const char*)D->fragment[E->fragment_index].enc_data, E->e->u.raw.file, E->e->u.raw.filebase, 0, 0)) { @@ -875,7 +875,7 @@ return -1; } - if ((*gd_ef_[E->e->u.raw.file[0].subenc].move)( + if ((*_GD_ef[E->e->u.raw.file[0].subenc].move)( D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, D->fragment[E->fragment_index].dirfd, temp.name)) { Modified: trunk/getdata/src/nframes.c =================================================================== --- trunk/getdata/src/nframes.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/nframes.c 2014-05-05 23:50:42 UTC (rev 897) @@ -46,7 +46,7 @@ return 0; } - if ((*gd_ef_[D->reference_field->e->u.raw.file[0].subenc].name)(D, + if ((*_GD_ef[D->reference_field->e->u.raw.file[0].subenc].name)(D, (const char*)D->fragment[D->reference_field->fragment_index].enc_data, D->reference_field->e->u.raw.file, D->reference_field->e->u.raw.filebase, 0, 0)) @@ -55,7 +55,7 @@ return 0; } - nf = (*gd_ef_[D->reference_field->e->u.raw.file[0].subenc].size)( + 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)); Modified: trunk/getdata/src/parse.c =================================================================== --- trunk/getdata/src/parse.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/parse.c 2014-05-05 23:50:42 UTC (rev 897) @@ -2034,10 +2034,10 @@ if (!(*flags & GD_FORCE_ENCODING)) { D->fragment[me].encoding = GD_ENC_UNSUPPORTED; for (i = 0; i < GD_N_SUBENCODINGS - 1; ++i) - if (strcmp(in_cols[1], gd_ef_[i].ffname) == 0) { - D->fragment[me].encoding = gd_ef_[i].scheme; + if (strcmp(in_cols[1], _GD_ef[i].ffname) == 0) { + D->fragment[me].encoding = _GD_ef[i].scheme; free(D->fragment[me].enc_data); - if (n_cols > 2 && gd_ef_[i].flags & GD_EF_EDAT) + if (n_cols > 2 && _GD_ef[i].flags & GD_EF_EDAT) D->fragment[me].enc_data = _GD_Strdup(D, in_cols[2]); else D->fragment[me].enc_data = NULL; Modified: trunk/getdata/src/putdata.c =================================================================== --- trunk/getdata/src/putdata.c 2014-05-05 21:16:59 UTC (rev 896) +++ trunk/getdata/src/putdata.c 2014-05-05 23:50:42 UTC (rev 897) @@ -68,7 +68,7 @@ } /* fix endianness, if necessary */ - if (gd_ef_[E->e->u.raw.file[0].subenc].flags & GD_EF_ECOR) + 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); @@ -81,7 +81,7 @@ return 0; } - if (_GD_WriteSeek(D, E, gd_ef_ + E->e->u.raw.file[0].subenc, s0, + if (_GD_WriteSeek(D, E, _GD_ef + E->e->u.raw.file[0].subenc, s0, GD_FILE_WRITE) == -1) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -90,7 +90,7 @@ return 0; } - n_wrote = _GD_WriteOut(E, gd_ef_ + E->e->u.raw.file[0].subenc, databuffer, + n_wrote = _GD_WriteOut(E, _GD_ef + E->e->u.raw.file[0].subenc, databuffer, E->EN(raw,data_type), ns, 0); if (n_wrote < 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |