Thread: [Getdata-commits] SF.net SVN: getdata:[905] trunk/getdata (Page 9)
Scientific Database Format
Brought to you by:
ketiltrout
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-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-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-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-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-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-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-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-10-16 23:26:46
|
Revision: 928 http://sourceforge.net/p/getdata/code/928 Author: ketiltrout Date: 2014-10-16 23:26:40 +0000 (Thu, 16 Oct 2014) Log Message: ----------- Merge all the I/O error codes into GD_E_IO. Also GD_E_LUT. Add deprecated error codes to Python. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/cxx/test/big_test.cpp trunk/getdata/bindings/f77/test/big_test.f trunk/getdata/bindings/f77/test/big_test95.f90 trunk/getdata/bindings/idl/test/big_test.pro trunk/getdata/bindings/make_parameters.c trunk/getdata/bindings/matlab/matlab.c trunk/getdata/bindings/matlab/test/big_test.m trunk/getdata/bindings/perl/t/big_test.t trunk/getdata/bindings/php/test/big_test.php trunk/getdata/bindings/python/pygetdata.c trunk/getdata/bindings/python/test/big_test.py trunk/getdata/man/dirfile-encoding.5 trunk/getdata/man/gd_add.3 trunk/getdata/man/gd_add_bit.3 trunk/getdata/man/gd_add_spec.3 trunk/getdata/man/gd_alter_bit.3 trunk/getdata/man/gd_alter_encoding.3.in trunk/getdata/man/gd_alter_endianness.3.in trunk/getdata/man/gd_alter_entry.3 trunk/getdata/man/gd_alter_frameoffset.3.in trunk/getdata/man/gd_alter_spec.3 trunk/getdata/man/gd_cbopen.3 trunk/getdata/man/gd_close.3 trunk/getdata/man/gd_delete.3 trunk/getdata/man/gd_desync.3 trunk/getdata/man/gd_eof.3 trunk/getdata/man/gd_error_string.3 trunk/getdata/man/gd_flush.3 trunk/getdata/man/gd_framenum_subset.3 trunk/getdata/man/gd_getdata.3 trunk/getdata/man/gd_include_affix.3 trunk/getdata/man/gd_metaflush.3 trunk/getdata/man/gd_move.3 trunk/getdata/man/gd_native_type.3 trunk/getdata/man/gd_nframes.3 trunk/getdata/man/gd_putdata.3 trunk/getdata/man/gd_rename.3 trunk/getdata/man/gd_rewrite_fragment.3 trunk/getdata/man/gd_seek.3 trunk/getdata/man/gd_tell.3 trunk/getdata/man/gd_uninclude.3 trunk/getdata/src/common.c trunk/getdata/src/del.c trunk/getdata/src/encoding.c trunk/getdata/src/errors.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/fpos.c trunk/getdata/src/fragment.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/include.c trunk/getdata/src/internal.h trunk/getdata/src/legacy.c trunk/getdata/src/mod.c trunk/getdata/src/move.c trunk/getdata/src/name.c trunk/getdata/src/nframes.c trunk/getdata/src/open.c trunk/getdata/src/putdata.c trunk/getdata/test/alter_entry_scalar_amb.c trunk/getdata/test/error_error.c trunk/getdata/test/error_verbose.c trunk/getdata/test/get_linterp1.c trunk/getdata/test/get_linterp_empty.c trunk/getdata/test/get_linterp_notab.c trunk/getdata/test/include_nonexistent.c trunk/getdata/test/legacy_error.c trunk/getdata/test/legacy_nonexistent.c trunk/getdata/test/open_eaccess.c trunk/getdata/test/open_nonexistent.c trunk/getdata/test/open_notdirfile.c trunk/getdata/test/open_sym_d.c trunk/getdata/test/open_sym_l.c trunk/getdata/test/parse_include_dir.c trunk/getdata/test/parse_include_nonexistent.c trunk/getdata/test/put_linterp_notab.c trunk/getdata/test/test.h Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/ChangeLog 2014-10-16 23:26:40 UTC (rev 928) @@ -1,3 +1,22 @@ +2014-10-16 D. V. Wiebe <g et...@ke...> svn:928 + * bindings/make_parameters.c: Replace numeric type literals with CPP macros + for legibility. + + * man/gd_getdata.3: Explain I/O pointers more. + + * src/getdata.h.in: Merge GD_E_OPEN, GD_E_TRUNC, GD_E_RAW_IO, + GD_E_OPEN_FRAGMENT, most of GD_E_FLUSH and half of GD_E_OPEN_LINFILE into + the new GD_E_IO and deprecate. The remainder of GD_E_OPEN_LINFILE (syntax + errors) is now the new GD_E_LUT. + * src/common.c (_GD_ReadLinterpFile): Consolidate error handling code. + Handle syntax errors better. + * src/flush.c (_GD_FieldSpec): Raise GD_E_LINE_TOO_LONG for line overflows. + * src/errors.c (_GD_SetError2 _GD_SetError gd_error_string): Track stdlib + errno separately and implicitly. + + * bindings/python/pygetdata.c: Define deprecated Exceptions as aliases for + current ones. + 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. Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/NEWS 2014-10-16 23:26:40 UTC (rev 928) @@ -189,9 +189,24 @@ * 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. + itself when given the field code to an alias, rather than the field the + alias points to. + * A number of different error codes which indicated the same problem (an + I/O error returned by the filesystem) have been merged into one. The error + codes GD_E_OPEN, GD_E_TRUNC, GD_E_RAW_IO, GD_E_OPEN_FRAGMENT, GD_E_FLUSH + are replaced by the new error GD_E_IO. The old symbols remain as aliases + but are deprecated. There is one exception to this merge: attempts to + flush metadata lines which are too long are now reported using + GD_E_LINE_TOO_LONG. Previously, these errors used GD_E_FLUSH. + + * The error code GD_E_OPEN_LINFILE has also been removed. It has been split + into two parts: + - I/O errors resulting from reading the LINTERP table file are now reported + using GD_E_IO; + - Syntax errors in the table are reported using the new GD_E_LUT error code. + GD_E_OPEN_LINFILE remains as a deprecated alias for GD_E_LUT. + * gd_encoding_support() has been added to permit run-time determination of supported encodings. @@ -236,6 +251,10 @@ * PERL: alter_entry() now only updates defined elements in the passed entry hash. + * PYTHON: for backwards compatiblity, exceptions now exist for deprecated + error codes (such as OpenError). These deprecated exceptions are simply + aliases for the current ones and are never returned by the bindings. + * C++ BUG FIX: Fixed segfault in RawEntry destructor. Reported by S. J. Benton. Modified: trunk/getdata/bindings/cxx/test/big_test.cpp =================================================================== --- trunk/getdata/bindings/cxx/test/big_test.cpp 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/cxx/test/big_test.cpp 2014-10-16 23:26:40 UTC (rev 928) @@ -240,7 +240,7 @@ // 1: Dirfile::Error check d = new Dirfile("x"); - CHECK_ERROR(1, GD_E_OPEN); + CHECK_ERROR(1, GD_E_IO); delete d; // 2: Dirfile::Dirfile check Modified: trunk/getdata/bindings/f77/test/big_test.f =================================================================== --- trunk/getdata/bindings/f77/test/big_test.f 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/f77/test/big_test.f 2014-10-16 23:26:40 UTC (rev 928) @@ -280,7 +280,7 @@ ne = 0 C 1: GDEROR check CALL GDOPEN(d, "x", 1, GD_RO) - CALL CHKERR(ne, 1, d, GD_EOP) + CALL CHKERR(ne, 1, d, GD_EIO) C 2: GDOPEN check CALL GDOPEN(d, fildir, 12, GD_RW) Modified: trunk/getdata/bindings/f77/test/big_test95.f90 =================================================================== --- trunk/getdata/bindings/f77/test/big_test95.f90 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/f77/test/big_test95.f90 2014-10-16 23:26:40 UTC (rev 928) @@ -249,7 +249,7 @@ ! 1: fgd_error check d = fgd_open('x', GD_RDONLY) - call check_err(ne, 1, d, GD_E_OPEN) + call check_err(ne, 1, d, GD_E_IO) call fgd_discard(d) ! 2: fgd_open check Modified: trunk/getdata/bindings/idl/test/big_test.pro =================================================================== --- trunk/getdata/bindings/idl/test/big_test.pro 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/idl/test/big_test.pro 2014-10-16 23:26:40 UTC (rev 928) @@ -85,12 +85,12 @@ ; 0: getdata_constants check defsysv, "!GD", getdata_constants() -nume += check_simple(0, !GD.E_OPEN, 1) +nume += check_simple(0, !GD.E_OK, 0) ; 1: gd_error check d = gd_open("x",error=error) -nume += check_error(1, d, !GD.E_OPEN) -nume += check_simple(1, error, !GD.E_OPEN) +nume += check_error(1, d, !GD.E_IO) +nume += check_simple(1, error, !GD.E_IO) gd_close, d, /DISCARD ; 2: gd_open check Modified: trunk/getdata/bindings/make_parameters.c =================================================================== --- trunk/getdata/bindings/make_parameters.c 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/make_parameters.c 2014-10-16 23:26:40 UTC (rev 928) @@ -29,224 +29,227 @@ #define GD_NO_LEGACY_API #include "getdata.h" -/* The type parameter: - * 0: error codes - * 1: open flags not in IDL - * 2: open flags represented as LONG in IDL - * 3: entry types - * 4: data types - * 5: delete/rename flags (not in IDL) - * 6: protection levels - * 7: callback actions (not in IDL) - * 8: GD_E_FORMAT suberrors (not in IDL) - * 9: special version codes - * 10: gd_seek whence values - * 11: gd_seek flags (not in IDL) - * 12: window operations - * 13: desynced flags (not in IDL) - * 14: entry_list constants (not in IDL) - * 15: entry flags - * 98: miscellaneous constants not in IDL - * 99: miscellaneous constants - */ +/* parameter types (used by Fortran, IDL, and PHP) */ +#define GDMP_ERR 0x00000001 /* error code */ +#define GDMP_DEPERR 0x00000002 /* deprecated error codes not in PHP */ +#define GDMP_OFLAG 0x00000004 /* open flags not in IDL */ +#define GDMP_OFLAG_L 0x00000008 /* open flags represented as LONG in IDL */ +#define GDMP_ENTYPE 0x00000010 /* entry types */ +#define GDMP_DTYPE 0x00000020 /* data types */ +#define GDMP_RFLAG 0x00000040 /* delete and rename flags (not in IDL) */ +#define GDMP_PROT 0x00000080 /* protection levels */ +#define GDMP_CALLBAK 0x00000100 /* callback actions (not in IDL) */ +#define GDMP_FORMAT 0x00000200 /* GD_E_FORMAT suberrors (not in IDL) */ +#define GDMP_VERS 0x00000400 /* special version codes */ +#define GDMP_WHENCE 0x00000800 /* gd_seek whence values */ +#define GDMP_SEEK 0x00001000 /* gd_seek flags (not in IDL) */ +#define GDMP_WINDOP 0x00002000 /* window operations */ +#define GDMP_DESYNC 0x00004000 /* desync flags (not in IDL) */ +#define GDMP_ENLIST 0x00008000 /* entry_list constants (not in IDL) */ +#define GDMP_EFLAG 0x00010000 /* entry flags */ +#define GDMP_MISC_I 0x00020000 /* miscellaneous constants not in IDL */ +#define GDMP_MISC 0x00040000 /* miscellaneous constants */ + #define CONSTANT(s,f,t) { "GD_" #s, #s, f, GD_ ## s, t } static struct { const char* lname; /* Long name */ const char* sname; /* Short name */ const char* fname; /* F77 name */ long int value; - int type; + unsigned type; } constant_list[] = { - CONSTANT(E_OK, "GD_EOK", 0), - CONSTANT(E_OPEN, "GD_EOP", 0), - CONSTANT(E_FORMAT, "GD_EFO", 0), - CONSTANT(E_TRUNC, "GD_ETR", 0), - CONSTANT(E_CREAT, "GD_ECR", 0), - CONSTANT(E_BAD_CODE, "GD_EBC", 0), - CONSTANT(E_BAD_TYPE, "GD_EBT", 0), - CONSTANT(E_RAW_IO, "GD_ERW", 0), - CONSTANT(E_OPEN_FRAGMENT, "GD_EOF", 0), - CONSTANT(E_INTERNAL_ERROR, "GD_EIE", 0), - CONSTANT(E_ALLOC, "GD_EAL", 0), - CONSTANT(E_RANGE, "GD_ERA", 0), - CONSTANT(E_OPEN_LINFILE, "GD_EOL", 0), - CONSTANT(E_RECURSE_LEVEL, "GD_ERL", 0), - CONSTANT(E_BAD_DIRFILE, "GD_EBD", 0), - CONSTANT(E_BAD_FIELD_TYPE, "GD_EBF", 0), - CONSTANT(E_ACCMODE, "GD_EAC", 0), - CONSTANT(E_UNSUPPORTED, "GD_UNS", 0), - CONSTANT(E_UNKNOWN_ENCODING,"GD_EUE",0), - CONSTANT(E_BAD_ENTRY, "GD_EBE", 0), - CONSTANT(E_DUPLICATE, "GD_EDU", 0), - CONSTANT(E_DIMENSION, "GD_EDM", 0), - CONSTANT(E_BAD_INDEX, "GD_EBI", 0), - CONSTANT(E_BAD_SCALAR, "GD_EBS", 0), - CONSTANT(E_BAD_REFERENCE, "GD_EBR", 0), - CONSTANT(E_PROTECTED, "GD_EPT", 0), - CONSTANT(E_DELETE, "GD_EDL", 0), - CONSTANT(E_ARGUMENT, "GD_EAR", 0), - CONSTANT(E_CALLBACK, "GD_ECB", 0), - CONSTANT(E_EXISTS, "GD_EEX", 0), - CONSTANT(E_UNCLEAN_DB, "GD_UCL", 0), - CONSTANT(E_DOMAIN, "GD_EDO", 0), - CONSTANT(E_BAD_REPR, "GD_ERP", 0), - CONSTANT(E_FLUSH, "GD_EFL", 0), - CONSTANT(E_BOUNDS, "GD_EBO", 0), - CONSTANT(E_LINE_TOO_LONG, "GD_ETL", 0), + CONSTANT(E_OK, "GD_EOK", GDMP_ERR), + CONSTANT(E_FORMAT, "GD_EFO", GDMP_ERR), + CONSTANT(E_CREAT, "GD_ECR", GDMP_ERR), + CONSTANT(E_BAD_CODE, "GD_EBC", GDMP_ERR), + CONSTANT(E_BAD_TYPE, "GD_EBT", GDMP_ERR), + CONSTANT(E_IO, "GD_EIO", GDMP_ERR), + CONSTANT(E_INTERNAL_ERROR, "GD_EIE", GDMP_ERR), + CONSTANT(E_ALLOC, "GD_EAL", GDMP_ERR), + CONSTANT(E_RANGE, "GD_ERA", GDMP_ERR), + CONSTANT(E_LUT, "GD_ELT", GDMP_ERR), + CONSTANT(E_RECURSE_LEVEL, "GD_ERL", GDMP_ERR), + CONSTANT(E_BAD_DIRFILE, "GD_EBD", GDMP_ERR), + CONSTANT(E_BAD_FIELD_TYPE, "GD_EBF", GDMP_ERR), + CONSTANT(E_ACCMODE, "GD_EAC", GDMP_ERR), + CONSTANT(E_UNSUPPORTED, "GD_UNS", GDMP_ERR), + CONSTANT(E_UNKNOWN_ENCODING,"GD_EUE",GDMP_ERR), + CONSTANT(E_BAD_ENTRY, "GD_EBE", GDMP_ERR), + CONSTANT(E_DUPLICATE, "GD_EDU", GDMP_ERR), + CONSTANT(E_DIMENSION, "GD_EDM", GDMP_ERR), + CONSTANT(E_BAD_INDEX, "GD_EBI", GDMP_ERR), + CONSTANT(E_BAD_SCALAR, "GD_EBS", GDMP_ERR), + CONSTANT(E_BAD_REFERENCE, "GD_EBR", GDMP_ERR), + CONSTANT(E_PROTECTED, "GD_EPT", GDMP_ERR), + CONSTANT(E_DELETE, "GD_EDL", GDMP_ERR), + CONSTANT(E_ARGUMENT, "GD_EAR", GDMP_ERR), + CONSTANT(E_CALLBACK, "GD_ECB", GDMP_ERR), + CONSTANT(E_EXISTS, "GD_EEX", GDMP_ERR), + CONSTANT(E_UNCLEAN_DB, "GD_UCL", GDMP_ERR), + CONSTANT(E_DOMAIN, "GD_EDO", GDMP_ERR), + CONSTANT(E_BAD_REPR, "GD_ERP", GDMP_ERR), + CONSTANT(E_BOUNDS, "GD_EBO", GDMP_ERR), + CONSTANT(E_LINE_TOO_LONG, "GD_ETL", GDMP_ERR), - CONSTANT(E_OPEN_INCLUDE, "GD_EOI", 0), /* deprecated */ - CONSTANT(E_BAD_ENDIANNESS, "GD_EEN", 0), /* deprecated */ - CONSTANT(E_BAD_PROTECTION, "GD_EBP", 0), /* deprecated */ - CONSTANT(E_BAD_VERSION, "GD_EVR", 0), /* deprecated */ + CONSTANT(E_BAD_ENDIANNESS, "GD_EEN", GDMP_DEPERR), + CONSTANT(E_BAD_PROTECTION, "GD_EBP", GDMP_DEPERR), + CONSTANT(E_BAD_VERSION, "GD_EVR", GDMP_DEPERR), + CONSTANT(E_OPEN_LINFILE, "GD_EOL", GDMP_DEPERR), + CONSTANT(E_FLUSH, "GD_EFL", GDMP_DEPERR), + CONSTANT(E_OPEN, "GD_EOP", GDMP_DEPERR), + CONSTANT(E_OPEN_FRAGMENT, "GD_EOF", GDMP_DEPERR), + CONSTANT(E_OPEN_INCLUDE, "GD_EOI", GDMP_DEPERR), + CONSTANT(E_RAW_IO, "GD_ERW", GDMP_DEPERR), + CONSTANT(E_TRUNC, "GD_ETR", GDMP_DEPERR), - CONSTANT(RDONLY, "GD_RO", 2), - CONSTANT(RDWR, "GD_RW", 2), - CONSTANT(FORCE_ENDIAN, "GD_FE", 1), - CONSTANT(BIG_ENDIAN, "GD_BE", 2), - CONSTANT(LITTLE_ENDIAN, "GD_LE", 2), - CONSTANT(CREAT, "GD_CR", 1), - CONSTANT(EXCL, "GD_EX", 1), - CONSTANT(TRUNC, "GD_TR", 1), - CONSTANT(PEDANTIC, "GD_PE", 1), - CONSTANT(FORCE_ENCODING, "GD_FC", 1), - CONSTANT(VERBOSE, "GD_VB", 2), - CONSTANT(IGNORE_DUPS, "GD_ID", 1), - CONSTANT(IGNORE_REFS, "GD_IR", 1), - CONSTANT(PRETTY_PRINT, "GD_PP", 2), - CONSTANT(ARM_ENDIAN, "GD_AE", 2), - CONSTANT(NOT_ARM_ENDIAN, "GD_NA", 2), - CONSTANT(PERMISSIVE, "GD_PM", 1), - CONSTANT(TRUNCSUB, "GD_TS", 1), + CONSTANT(RDONLY, "GD_RO", GDMP_OFLAG_L), + CONSTANT(RDWR, "GD_RW", GDMP_OFLAG_L), + CONSTANT(FORCE_ENDIAN, "GD_FE", GDMP_OFLAG), + CONSTANT(BIG_ENDIAN, "GD_BE", GDMP_OFLAG_L), + CONSTANT(LITTLE_ENDIAN, "GD_LE", GDMP_OFLAG_L), + CONSTANT(CREAT, "GD_CR", GDMP_OFLAG), + CONSTANT(EXCL, "GD_EX", GDMP_OFLAG), + CONSTANT(TRUNC, "GD_TR", GDMP_OFLAG), + CONSTANT(PEDANTIC, "GD_PE", GDMP_OFLAG), + CONSTANT(FORCE_ENCODING, "GD_FC", GDMP_OFLAG), + CONSTANT(VERBOSE, "GD_VB", GDMP_OFLAG_L), + CONSTANT(IGNORE_DUPS, "GD_ID", GDMP_OFLAG), + CONSTANT(IGNORE_REFS, "GD_IR", GDMP_OFLAG), + CONSTANT(PRETTY_PRINT, "GD_PP", GDMP_OFLAG_L), + CONSTANT(ARM_ENDIAN, "GD_AE", GDMP_OFLAG_L), + CONSTANT(NOT_ARM_ENDIAN, "GD_NA", GDMP_OFLAG_L), + CONSTANT(PERMISSIVE, "GD_PM", GDMP_OFLAG), + CONSTANT(TRUNCSUB, "GD_TS", GDMP_OFLAG), - CONSTANT(AUTO_ENCODED, "GDE_AU", 1), - CONSTANT(BZIP2_ENCODED, "GDE_BZ", 2), - CONSTANT(GZIP_ENCODED, "GDE_GZ", 2), - CONSTANT(LZMA_ENCODED, "GDE_LZ", 2), - CONSTANT(SIE_ENCODED, "GDE_SI", 2), - CONSTANT(SLIM_ENCODED, "GDE_SL", 2), - CONSTANT(TEXT_ENCODED, "GDE_TX", 2), - CONSTANT(UNENCODED, "GDE_UN", 2), - CONSTANT(ZZSLIM_ENCODED, "GDE_ZS", 2), - CONSTANT(ZZIP_ENCODED, "GDE_ZZ", 2), + CONSTANT(AUTO_ENCODED, "GDE_AU", GDMP_OFLAG), + CONSTANT(BZIP2_ENCODED, "GDE_BZ", GDMP_OFLAG_L), + CONSTANT(GZIP_ENCODED, "GDE_GZ", GDMP_OFLAG_L), + CONSTANT(LZMA_ENCODED, "GDE_LZ", GDMP_OFLAG_L), + CONSTANT(SIE_ENCODED, "GDE_SI", GDMP_OFLAG_L), + CONSTANT(SLIM_ENCODED, "GDE_SL", GDMP_OFLAG_L), + CONSTANT(TEXT_ENCODED, "GDE_TX", GDMP_OFLAG_L), + CONSTANT(UNENCODED, "GDE_UN", GDMP_OFLAG_L), + CONSTANT(ZZSLIM_ENCODED, "GDE_ZS", GDMP_OFLAG_L), + CONSTANT(ZZIP_ENCODED, "GDE_ZZ", GDMP_OFLAG_L), - CONSTANT(NO_ENTRY, "GD_NOE", 3), - CONSTANT(RAW_ENTRY, "GD_RWE", 3), - CONSTANT(LINCOM_ENTRY, "GD_LCE", 3), - CONSTANT(LINTERP_ENTRY, "GD_LTE", 3), - CONSTANT(BIT_ENTRY, "GD_BTE", 3), - CONSTANT(MULTIPLY_ENTRY, "GD_MTE", 3), - CONSTANT(PHASE_ENTRY, "GD_PHE", 3), - CONSTANT(INDEX_ENTRY, "GD_IXE", 3), - CONSTANT(POLYNOM_ENTRY, "GD_PNE", 3), - CONSTANT(SBIT_ENTRY, "GD_SBE", 3), - CONSTANT(DIVIDE_ENTRY, "GD_DVE", 3), - CONSTANT(RECIP_ENTRY, "GD_RCE", 3), - CONSTANT(WINDOW_ENTRY, "GD_WDE", 3), - CONSTANT(MPLEX_ENTRY, "GD_MXE", 3), - CONSTANT(INDIR_ENTRY, "GD_IDE", 3), - CONSTANT(SINDIR_ENTRY, "GD_SDE", 3), - CONSTANT(CONST_ENTRY, "GD_COE", 3), - CONSTANT(CARRAY_ENTRY, "GD_CAE", 3), - CONSTANT(STRING_ENTRY, "GD_STE", 3), - CONSTANT(SARRAY_ENTRY, "GD_SAE", 3), + CONSTANT(NO_ENTRY, "GD_NOE", GDMP_ENTYPE), + CONSTANT(RAW_ENTRY, "GD_RWE", GDMP_ENTYPE), + CONSTANT(LINCOM_ENTRY, "GD_LCE", GDMP_ENTYPE), + CONSTANT(LINTERP_ENTRY, "GD_LTE", GDMP_ENTYPE), + CONSTANT(BIT_ENTRY, "GD_BTE", GDMP_ENTYPE), + CONSTANT(MULTIPLY_ENTRY, "GD_MTE", GDMP_ENTYPE), + CONSTANT(PHASE_ENTRY, "GD_PHE", GDMP_ENTYPE), + CONSTANT(INDEX_ENTRY, "GD_IXE", GDMP_ENTYPE), + CONSTANT(POLYNOM_ENTRY, "GD_PNE", GDMP_ENTYPE), + CONSTANT(SBIT_ENTRY, "GD_SBE", GDMP_ENTYPE), + CONSTANT(DIVIDE_ENTRY, "GD_DVE", GDMP_ENTYPE), + CONSTANT(RECIP_ENTRY, "GD_RCE", GDMP_ENTYPE), + CONSTANT(WINDOW_ENTRY, "GD_WDE", GDMP_ENTYPE), + CONSTANT(MPLEX_ENTRY, "GD_MXE", GDMP_ENTYPE), + CONSTANT(INDIR_ENTRY, "GD_IDE", GDMP_ENTYPE), + CONSTANT(SINDIR_ENTRY, "GD_SDE", GDMP_ENTYPE), + CONSTANT(CONST_ENTRY, "GD_COE", GDMP_ENTYPE), + CONSTANT(CARRAY_ENTRY, "GD_CAE", GDMP_ENTYPE), + CONSTANT(STRING_ENTRY, "GD_STE", GDMP_ENTYPE), + CONSTANT(SARRAY_ENTRY, "GD_SAE", GDMP_ENTYPE), - CONSTANT(NULL, "GD_NUL", 4), - CONSTANT(UINT8, "GD_U8", 4), - CONSTANT(INT8, "GD_I8", 4), - CONSTANT(UINT16, "GD_U16", 4), - CONSTANT(INT16, "GD_I16", 4), - CONSTANT(UINT32, "GD_U32", 4), - CONSTANT(INT32, "GD_I32", 4), - CONSTANT(UINT64, "GD_U64", 4), - CONSTANT(INT64, "GD_I64", 4), - CONSTANT(FLOAT32, "GD_F32", 4), - CONSTANT(FLOAT64, "GD_F64", 4), - CONSTANT(COMPLEX64, "GD_C64", 4), - CONSTANT(COMPLEX128, "GDC128", 4), - CONSTANT(STRING, "GD_STR", 4), + CONSTANT(NULL, "GD_NUL", GDMP_DTYPE), + CONSTANT(UINT8, "GD_U8", GDMP_DTYPE), + CONSTANT(INT8, "GD_I8", GDMP_DTYPE), + CONSTANT(UINT16, "GD_U16", GDMP_DTYPE), + CONSTANT(INT16, "GD_I16", GDMP_DTYPE), + CONSTANT(UINT32, "GD_U32", GDMP_DTYPE), + CONSTANT(INT32, "GD_I32", GDMP_DTYPE), + CONSTANT(UINT64, "GD_U64", GDMP_DTYPE), + CONSTANT(INT64, "GD_I64", GDMP_DTYPE), + CONSTANT(FLOAT32, "GD_F32", GDMP_DTYPE), + CONSTANT(FLOAT64, "GD_F64", GDMP_DTYPE), + CONSTANT(COMPLEX64, "GD_C64", GDMP_DTYPE), + CONSTANT(COMPLEX128, "GDC128", GDMP_DTYPE), + CONSTANT(STRING, "GD_STR", GDMP_DTYPE), - CONSTANT(DEL_META, "GDD_MT", 5), - CONSTANT(DEL_DATA, "GDD_DT", 5), - CONSTANT(DEL_DEREF, "GDD_DR", 5), - CONSTANT(DEL_FORCE, "GDD_FO", 5), - CONSTANT(REN_DATA, "GDR_DT", 5), - CONSTANT(REN_UPDB, "GDR_UP", 5), - CONSTANT(REN_DANGLE, "GDR_DL", 5), - CONSTANT(REN_FORCE, "GDR_FO", 5), + CONSTANT(DEL_META, "GDD_MT", GDMP_RFLAG), + CONSTANT(DEL_DATA, "GDD_DT", GDMP_RFLAG), + CONSTANT(DEL_DEREF, "GDD_DR", GDMP_RFLAG), + CONSTANT(DEL_FORCE, "GDD_FO", GDMP_RFLAG), + CONSTANT(REN_DATA, "GDR_DT", GDMP_RFLAG), + CONSTANT(REN_UPDB, "GDR_UP", GDMP_RFLAG), + CONSTANT(REN_DANGLE, "GDR_DL", GDMP_RFLAG), + CONSTANT(REN_FORCE, "GDR_FO", GDMP_RFLAG), - CONSTANT(PROTECT_NONE, "GDPR_N", 6), - CONSTANT(PROTECT_FORMAT, "GDPR_F", 6), - CONSTANT(PROTECT_DATA, "GDPR_D", 6), - CONSTANT(PROTECT_ALL, "GDPR_A", 6), + CONSTANT(PROTECT_NONE, "GDPR_N", GDMP_PROT), + CONSTANT(PROTECT_FORMAT, "GDPR_F", GDMP_PROT), + CONSTANT(PROTECT_DATA, "GDPR_D", GDMP_PROT), + CONSTANT(PROTECT_ALL, "GDPR_A", GDMP_PROT), - CONSTANT(SYNTAX_ABORT, "GDSX_A", 7), - CONSTANT(SYNTAX_RESCAN, "GDSX_S", 7), - CONSTANT(SYNTAX_IGNORE, "GDSX_I", 7), - CONSTANT(SYNTAX_CONTINUE, "GDSX_C", 7), + CONSTANT(SYNTAX_ABORT, "GDSX_A", GDMP_CALLBAK), + CONSTANT(SYNTAX_RESCAN, "GDSX_S", GDMP_CALLBAK), + CONSTANT(SYNTAX_IGNORE, "GDSX_I", GDMP_CALLBAK), + CONSTANT(SYNTAX_CONTINUE, "GDSX_C", GDMP_CALLBAK), - CONSTANT(E_FORMAT_BAD_SPF, "GDF_SF", 8), - CONSTANT(E_FORMAT_N_FIELDS,"GDF_NF", 8), - CONSTANT(E_FORMAT_N_TOK, "GDF_NT", 8), - CONSTANT(E_FORMAT_NUMBITS, "GDF_NB", 8), - CONSTANT(E_FORMAT_BITNUM, "GDF_BN", 8), - CONSTANT(E_FORMAT_BITSIZE, "GDF_SZ", 8), - CONSTANT(E_FORMAT_CHARACTER,"GDF_CH", 8), - CONSTANT(E_FORMAT_BAD_LINE,"GDF_LI", 8), - CONSTANT(E_FORMAT_RES_NAME,"GDF_RN", 8), - CONSTANT(E_FORMAT_ENDIAN, "GDF_EN", 8), - CONSTANT(E_FORMAT_BAD_TYPE,"GDF_TY", 8), - CONSTANT(E_FORMAT_BAD_NAME,"GDF_NA", 8), - CONSTANT(E_FORMAT_UNTERM, "GDF_UM", 8), - CONSTANT(E_FORMAT_METARAW, "GDF_MR", 8), - CONSTANT(E_FORMAT_NO_PARENT,"GDF_PA", 8), - CONSTANT(E_FORMAT_DUPLICATE,"GDF_DU", 8), - CONSTANT(E_FORMAT_LOCATION,"GDF_LO", 8), - CONSTANT(E_FORMAT_PROTECT, "GDF_PR", 8), - CONSTANT(E_FORMAT_LITERAL, "GDF_LT", 8), - CONSTANT(E_FORMAT_WINDOP, "GDF_WO", 8), - CONSTANT(E_FORMAT_META_META,"GDF_MM", 8), - CONSTANT(E_FORMAT_ALIAS, "GDF_AL", 8), - CONSTANT(E_FORMAT_MPLEXVAL,"GDF_MV", 8), + CONSTANT(E_FORMAT_BAD_SPF, "GDF_SF", GDMP_FORMAT), + CONSTANT(E_FORMAT_N_FIELDS, "GDF_NF", GDMP_FORMAT), + CONSTANT(E_FORMAT_N_TOK, "GDF_NT", GDMP_FORMAT), + CONSTANT(E_FORMAT_NUMBITS, "GDF_NB", GDMP_FORMAT), + CONSTANT(E_FORMAT_BITNUM, "GDF_BN", GDMP_FORMAT), + CONSTANT(E_FORMAT_BITSIZE, "GDF_SZ", GDMP_FORMAT), + CONSTANT(E_FORMAT_CHARACTER,"GDF_CH", GDMP_FORMAT), + CONSTANT(E_FORMAT_BAD_LINE, "GDF_LI", GDMP_FORMAT), + CONSTANT(E_FORMAT_RES_NAME, "GDF_RN", GDMP_FORMAT), + CONSTANT(E_FORMAT_ENDIAN, "GDF_EN", GDMP_FORMAT), + CONSTANT(E_FORMAT_BAD_TYPE, "GDF_TY", GDMP_FORMAT), + CONSTANT(E_FORMAT_BAD_NAME, "GDF_NA", GDMP_FORMAT), + CONSTANT(E_FORMAT_UNTERM, "GDF_UM", GDMP_FORMAT), + CONSTANT(E_FORMAT_METARAW, "GDF_MR", GDMP_FORMAT), + CONSTANT(E_FORMAT_NO_PARENT,"GDF_PA", GDMP_FORMAT), + CONSTANT(E_FORMAT_DUPLICATE,"GDF_DU", GDMP_FORMAT), + CONSTANT(E_FORMAT_LOCATION, "GDF_LO", GDMP_FORMAT), + CONSTANT(E_FORMAT_PROTECT, "GDF_PR", GDMP_FORMAT), + CONSTANT(E_FORMAT_LITERAL, "GDF_LT", GDMP_FORMAT), + CONSTANT(E_FORMAT_WINDOP, "GDF_WO", GDMP_FORMAT), + CONSTANT(E_FORMAT_META_META,"GDF_MM", GDMP_FORMAT), + CONSTANT(E_FORMAT_ALIAS, "GDF_AL", GDMP_FORMAT), + CONSTANT(E_FORMAT_MPLEXVAL, "GDF_MV", GDMP_FORMAT), - CONSTANT(VERSION_CURRENT, "GDSV_C", 9), - CONSTANT(VERSION_LATEST, "GDSV_L", 9), - CONSTANT(VERSION_EARLIEST, "GDSV_E", 9), + CONSTANT(VERSION_CURRENT, "GDSV_C", GDMP_VERS), + CONSTANT(VERSION_LATEST, "GDSV_L", GDMP_VERS), + CONSTANT(VERSION_EARLIEST, "GDSV_E", GDMP_VERS), - CONSTANT(SEEK_SET, "GDSK_S", 10), - CONSTANT(SEEK_CUR, "GDSK_C", 10), - CONSTANT(SEEK_END, "GDSK_E", 10), - CONSTANT(SEEK_WRITE, "GDSK_W", 11), + CONSTANT(SEEK_SET, "GDSK_S", GDMP_WHENCE), + CONSTANT(SEEK_CUR, "GDSK_C", GDMP_WHENCE), + CONSTANT(SEEK_END, "GDSK_E", GDMP_WHENCE), + CONSTANT(SEEK_WRITE, "GDSK_W", GDMP_SEEK), - CONSTANT(WINDOP_UNK, "GDW_UN", 12), - CONSTANT(WINDOP_EQ, "GDW_EQ", 12), - CONSTANT(WINDOP_GE, "GDW_GE", 12), - CONSTANT(WINDOP_GT, "GDW_GT", 12), - CONSTANT(WINDOP_LE, "GDW_LE", 12), - CONSTANT(WINDOP_LT, "GDW_LT", 12), - CONSTANT(WINDOP_NE, "GDW_NE", 12), - CONSTANT(WINDOP_SET, "GDW_ST", 12), - CONSTANT(WINDOP_CLR, "GDW_CL", 12), + CONSTANT(WINDOP_UNK, "GDW_UN", GDMP_WINDOP), + CONSTANT(WINDOP_EQ, "GDW_EQ", GDMP_WINDOP), + CONSTANT(WINDOP_GE, "GDW_GE", GDMP_WINDOP), + CONSTANT(WINDOP_GT, "GDW_GT", GDMP_WINDOP), + CONSTANT(WINDOP_LE, "GDW_LE", GDMP_WINDOP), + CONSTANT(WINDOP_LT, "GDW_LT", GDMP_WINDOP), + CONSTANT(WINDOP_NE, "GDW_NE", GDMP_WINDOP), + CONSTANT(WINDOP_SET, "GDW_ST", GDMP_WINDOP), + CONSTANT(WINDOP_CLR, "GDW_CL", GDMP_WINDOP), - CONSTANT(DESYNC_PATHCHECK, "GDDS_P", 13), - CONSTANT(DESYNC_REOPEN, "GDDS_O", 13), + CONSTANT(DESYNC_PATHCHECK, "GDDS_P", GDMP_DESYNC), + CONSTANT(DESYNC_REOPEN, "GDDS_O", GDMP_DESYNC), - CONSTANT(ALL_ENTRIES, "GDEN_X", 14), - CONSTANT(VECTOR_ENTRIES, "GDEN_V", 14), - CONSTANT(SCALAR_ENTRIES, "GDEN_S", 14), - CONSTANT(ALIAS_ENTRIES, "GDEN_A", 14), - CONSTANT(ENTRIES_HIDDEN, "GDEN_H", 14), - CONSTANT(ENTRIES_NOALIAS, "GDEN_N", 14), + CONSTANT(ALL_ENTRIES, "GDEN_X", GDMP_ENLIST), + CONSTANT(VECTOR_ENTRIES, "GDEN_V", GDMP_ENLIST), + CONSTANT(SCALAR_ENTRIES, "GDEN_S", GDMP_ENLIST), + CONSTANT(ALIAS_ENTRIES, "GDEN_A", GDMP_ENLIST), + CONSTANT(ENTRIES_HIDDEN, "GDEN_H", GDMP_ENLIST), + CONSTANT(ENTRIES_NOALIAS, "GDEN_N", GDMP_ENLIST), - CONSTANT(EN_CALC, "GDE_CA", 15), - CONSTANT(EN_HIDDEN, "GDE_HI", 15), - CONSTANT(EN_COMPSCAL, "GDE_CS", 15), + CONSTANT(EN_CALC, "GDE_CA", GDMP_EFLAG), + CONSTANT(EN_HIDDEN, "GDE_HI", GDMP_EFLAG), + CONSTANT(EN_COMPSCAL, "GDE_CS", GDMP_EFLAG), - CONSTANT(ALL_FRAGMENTS, "GD_ALL", 99), - CONSTANT(DEFAULT_LOOKBACK, "GDLB_D", 99), - CONSTANT(DIRFILE_STANDARDS_VERSION, "GD_DSV", 99), - CONSTANT(HERE, "GD_HER", 98), - CONSTANT(LOOKBACK_ALL, "GDLB_A", 98), - CONSTANT(MAX_LINE_LENGTH, "GD_MLL", 99), + CONSTANT(ALL_FRAGMENTS, "GD_ALL", GDMP_MISC), + CONSTANT(DEFAULT_LOOKBACK, "GDLB_D", GDMP_MISC), + CONSTANT(DIRFILE_STANDARDS_VERSION, "GD_DSV", GDMP_MISC), + CONSTANT(HERE, "GD_HER", GDMP_MISC_I), + CONSTANT(LOOKBACK_ALL, "GDLB_A", GDMP_MISC_I), + CONSTANT(MAX_LINE_LENGTH, "GD_MLL", GDMP_MISC), { NULL } }; @@ -275,109 +278,117 @@ printf("s/@PARAMETERS95@/\\\n! Error codes\\\n"); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 0) + if (constant_list[j].type == GDMP_ERR) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); + printf("\\\n%c Deprecated error codes\\\n", c); + + for (j = 0; constant_list[j].lname != NULL; ++j) + if (constant_list[j].type == GDMP_DEPERR) + parameter(constant_list[j].lname, constant_list[j].fname, + constant_list[j].value, i); + printf("\\\n%c Open flags\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 1 || constant_list[j].type == 2) + if (constant_list[j].type & (GDMP_OFLAG | GDMP_OFLAG_L)) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); - printf("\\\n%c Field types\\\n", c); + printf("\\\n%c Entry types\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 3) + if (constant_list[j].type == GDMP_ENTYPE) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf( "\\\n%c Data types -- the unsigned types won't work when passed as\\\n" - "%c a return type, but we keep them anyways, since\\\n" - "%c they might appear as a result of calling %s\\\n", - c, c, c, (i == 0) ? "GDGERW" : "fget_entry"); + "%c a return type; they are defined because they\\\n" + "%c may be returned by %s or %s\\\n", c, c, c, + (i == 0) ? "GDGERW" : "fget_entry", + (i == 0) ? "GDNTYP" : "fget_native_type"); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 4) + if (constant_list[j].type == GDMP_DTYPE) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); - printf("\\\n%c Delete flags\\\n", c); + printf("\\\n%c Delete and Rename flags\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 5) + if (constant_list[j].type == GDMP_RFLAG) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Protection levels\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 6) + if (constant_list[j].type == GDMP_PROT) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Callback actions\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 7) + if (constant_list[j].type == GDMP_CALLBAK) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Syntax suberrors\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 8) + if (constant_list[j].type == GDMP_FORMAT) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Special version codes\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 9) + if (constant_list[j].type == GDMP_VERS) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Seek flags\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 10 || constant_list[j].type == 11) + if (constant_list[j].type & (GDMP_WHENCE | GDMP_SEEK)) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Window operations\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 12) + if (constant_list[j].type == GDMP_WINDOP) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Desync flags\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 13) + if (constant_list[j].type == GDMP_DESYNC) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Entry List codes and flags\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 14) + if (constant_list[j].type == GDMP_ENLIST) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Entry object flags\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 15) + if (constant_list[j].type == GDMP_EFLAG) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); printf("\\\n%c Miscellaneous parameters\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 98 || constant_list[j].type == 99) + if (constant_list[j].type & (GDMP_MISC | GDMP_MISC_I)) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); @@ -424,13 +435,12 @@ ); for (i = 0; constant_list[i].lname != NULL; ++i) - if ((constant_list[i].type != 1) && (constant_list[i].type != 5) && - (constant_list[i].type != 7) && (constant_list[i].type != 8) && - (constant_list[i].type != 11) && (constant_list[i].type != 13) && - (constant_list[i].type != 14) && (constant_list[i].type != 98)) + if (constant_list[i].type & (GDMP_ERR | GDMP_DEPERR | GDMP_OFLAG_L | + GDMP_ENTYPE | GDMP_DTYPE | GDMP_PROT | GDMP_VERS | GDMP_WHENCE | + GDMP_WINDOP | GDMP_EFLAG | GDMP_MISC)) { printf("{ \"%s\", 0, (void*)IDL_TYP_%s }, ", constant_list[i].sname, - (constant_list[i].type == 2) ? "LONG" : "INT"); + (constant_list[i].type == GDMP_OFLAG_L) ? "LONG" : "INT"); } printf("{ NULL }};\n"); @@ -446,14 +456,14 @@ "\n"); for (n = i = 0; constant_list[i].lname != NULL; ++i) - if ((constant_list[i].type != 1) && (constant_list[i].type != 5) && - (constant_list[i].type != 7) && (constant_list[i].type != 8) && - (constant_list[i].type != 11) && (constant_list[i].type != 13) && - (constant_list[i].type != 14) && (constant_list[i].type != 98)) + if (constant_list[i].type & (GDMP_ERR | GDMP_DEPERR | GDMP_OFLAG_L | + GDMP_ENTYPE | GDMP_DTYPE | GDMP_PROT | GDMP_VERS | GDMP_WHENCE | + GDMP_WINDOP | GDMP_EFLAG | GDMP_MISC)) { printf("*(IDL_%s*)(data + IDL_StructTagInfoByIndex(gdidl_const_def, %i, " - "IDL_MSG_LONGJMP, NULL)) = %li;\n", (constant_list[i].type == 2) ? - "LONG" : "INT", n++, constant_list[i].value); + "IDL_MSG_LONGJMP, NULL)) = %li;\n", + (constant_list[i].type == GDMP_OFLAG_L) ? "LONG" : "INT", + n++, constant_list[i].value); } printf("return r; }\n"); @@ -569,9 +579,10 @@ ); for (i = 0; constant_list[i].lname != NULL; ++i) - printf("zend_register_long_constant(ZEND_STRS(\"%s\"), %li, CONST_CS, " - "module_number TSRMLS_CC);", constant_list[i].lname, - constant_list[i].value); + if (constant_list[i].type != GDMP_DEPERR) + printf("zend_register_long_constant(ZEND_STRS(\"%s\"), %li, CONST_CS, " + "module_number TSRMLS_CC);", constant_list[i].lname, + constant_list[i].value); puts("dreturnvoid();}"); } Modified: trunk/getdata/bindings/matlab/matlab.c =================================================================== --- trunk/getdata/bindings/matlab/matlab.c 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/matlab/matlab.c 2014-10-16 23:26:40 UTC (rev 928) @@ -55,18 +55,18 @@ static const char *gdmx_msgid[GD_N_ERROR_CODES] = { NULL, /* GD_E_OK */ - GD_LIBCOMP "Open", + GD_LIBCOMP "Error01", /* unused */ GD_LIBCOMP "Format", - GD_LIBCOMP "Trunc", + GD_LIBCOMP "Error03", /* unused */ GD_LIBCOMP "Creat", GD_LIBCOMP "BadCode", GD_LIBCOMP "BadType", - GD_LIBCOMP "RawIO", - GD_LIBCOMP "OpenFragment", + GD_LIBCOMP "IO", + GD_LIBCOMP "Error08", /* unused */ GD_LIBCOMP "InternalError", GD_LIBCOMP "Alloc", GD_LIBCOMP "Range", - GD_LIBCOMP "OpenLinfile", + GD_LIBCOMP "LUT", GD_LIBCOMP "RecurseLevel", GD_LIBCOMP "BadDirfile", GD_LIBCOMP "BadFieldType", @@ -88,7 +88,7 @@ GD_LIBCOMP "Domain", GD_LIBCOMP "BadRepr", GD_LIBCOMP "Error33", /* unused */ - GD_LIBCOMP "Flush", + GD_LIBCOMP "Error34", /* unused */ GD_LIBCOMP "Bounds", GD_LIBCOMP "LineTooLong" }; Modified: trunk/getdata/bindings/matlab/test/big_test.m =================================================================== --- trunk/getdata/bindings/matlab/test/big_test.m 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/matlab/test/big_test.m 2014-10-16 23:26:40 UTC (rev 928) @@ -85,7 +85,7 @@ try D = gd_open('x'); catch exc - ne = ne + check_exc(exc, 1, 'Open'); + ne = ne + check_exc(exc, 1, 'IO'); end % 2: gd_open check Modified: trunk/getdata/bindings/perl/t/big_test.t =================================================================== --- trunk/getdata/bindings/perl/t/big_test.t 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/perl/t/big_test.t 2014-10-16 23:26:40 UTC (rev 928) @@ -191,7 +191,7 @@ # 1: error check $_ = &GetData::open("x", $GetData::RDONLY); -CheckError(1, $GetData::E_OPEN); +CheckError(1, $GetData::E_IO); # 2: open check $_ = &GetData::open("dirfile", $GetData::RDWR); Modified: trunk/getdata/bindings/php/test/big_test.php =================================================================== --- trunk/getdata/bindings/php/test/big_test.php 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/php/test/big_test.php 2014-10-16 23:26:40 UTC (rev 928) @@ -174,7 +174,7 @@ # 1: gd_error $D = gd_open(''); -check_error(1, $D, GD_E_OPEN); +check_error(1, $D, GD_E_IO); # 2: gd_open $D = gd_open("dirfile\0extra", GD_RDWR); Modified: trunk/getdata/bindings/python/pygetdata.c =================================================================== --- trunk/getdata/bindings/python/pygetdata.c 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/python/pygetdata.c 2014-10-16 23:26:40 UTC (rev 928) @@ -23,18 +23,18 @@ static PyObject *GdPy_DirfileError; static const char *gdpy_exception_list[GD_N_ERROR_CODES] = { NULL, - "Open", + NULL, /* 1 */ "Format", - "Truncate", + NULL, /* 3 */ "Creation", "BadCode", "BadType", - "RawIO", - "OpenFragment", + "IO", + NULL, /* 8 */ "Internal", "Alloc", "Range", - "OpenLinfile", + "LUT", "RecurseLevel", "BadDirfile", "BadFieldType", @@ -55,13 +55,33 @@ "UncleanDatabase", "Domain", "BadRepr", - NULL, - "Flush", + NULL, /* 33 */ + NULL, /* 34 */ "Bounds", "LineTooLong" }; PyObject *gdpy_exceptions[GD_N_ERROR_CODES]; +/* These are unused but for backwards compatibility are defined as aliases of + * current exceptions */ +static struct { + const char *name; + int e; +} gdpy_dead_exceptions[] = { + { "BadEndianness", GD_E_ARGUMENT }, + { "BadProtection", GD_E_ARGUMENT }, + { "BadVersion", GD_E_ARGUMENT }, + { "OpenLinfile", GD_E_LUT }, + { "Flush", GD_E_IO }, + { "Open", GD_E_IO }, + { "OpenFragment", GD_E_IO }, + { "OpenFragment", GD_E_IO }, + { "OpenInclude", GD_E_IO }, + { "RawIO", GD_E_IO }, + { "Trunc", GD_E_IO }, + { NULL, 0} +}; + int gdpy_convert_from_pyobj(PyObject *value, union gdpy_quadruple_value *data, gd_type_t type) { @@ -548,6 +568,7 @@ { int i; PyObject *mod; + PyObject *mdict; dtracevoid(); @@ -664,5 +685,16 @@ gdpy_exceptions[i] = GdPy_DirfileError; } + /* add dead exceptions -- we do this through manual dictionary editing */ + mdict = PyModule_GetDict(mod); + if (mdict) + for (i = 0; gdpy_dead_exceptions[i].name; ++i) { + char name[40]; + sprintf(name, "%sError", gdpy_dead_exceptions[i].name); + Py_INCREF(gdpy_exceptions[gdpy_dead_exceptions[i].e]); + PyDict_SetItemString(mdict, name, + gdpy_exceptions[gdpy_dead_exceptions[i].e]); + } + dreturnvoid(); } Modified: trunk/getdata/bindings/python/test/big_test.py =================================================================== --- trunk/getdata/bindings/python/test/big_test.py 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/bindings/python/test/big_test.py 2014-10-16 23:26:40 UTC (rev 928) @@ -132,7 +132,7 @@ try: d = pygetdata.dirfile("x", pygetdata.RDONLY) except: - CheckException(1, pygetdata.OpenError) + CheckException(1, pygetdata.IOError) # 2: dirfile check try: Modified: trunk/getdata/man/dirfile-encoding.5 =================================================================== --- trunk/getdata/man/dirfile-encoding.5 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/dirfile-encoding.5 2014-10-16 23:26:40 UTC (rev 928) @@ -1,6 +1,6 @@ .\" dirfile-encoding.5. The dirfile-encoding man page. .\" -.\" Copyright (C) 2008, 2009, 2010, 2012, 2013 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2012, 2013, 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-encoding 5 "22 May 2014" "Standards Version 10" "DATA FORMATS" +.TH dirfile-encoding 5 "16 October 2014" "Standards Version 10" "DATA FORMATS" .SH NAME dirfile-encoding \(em dirfile database encoding schemes .SH DESCRIPTION @@ -59,10 +59,12 @@ .BR gd_add "(3), " gd_add_raw "(3), " gd_add_spec (3), .BR gd_alter_encoding "(3), " gd_alter_endianness (3), .BR gd_alter_frameoffset "(3), " gd_alter_entry (3), -.BR gd_alter_raw "(3), " gd_alter_spec "(3), " gd_getdata (3), -.BR gd_move "(3), " gd_nframes "(3), " gd_putdata (3), +.BR gd_alter_raw "(3), " gd_alter_spec "(3), " gd_flush (3), +.BR gd_getdata "(3), " gd_malter_spec "(3), " gd_move (3), +.BR gd_nframes "(3), " gd_putdata "(3), " gd_raw_close (3), +.BR gd_rename (3), and -.BR gd_rename (3). +.BR gd_sync (3). .P Most of the encodings supported by GetData are implemented through external libraries which handle the actual file I/O and data translation. All such Modified: trunk/getdata/man/gd_add.3 =================================================================== --- trunk/getdata/man/gd_add.3 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_add.3 2014-10-16 23:26:40 UTC (rev 928) @@ -1,6 +1,6 @@ .\" gd_add.3. The gd_add man page. .\" -.\" Copyright (C) 2008, 2009, 2010, 2012, 2013 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2012, 2013, 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 gd_add 3 "5 May 2014" "Version 0.9.0" "GETDATA" +.TH gd_add 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_add, gd_madd \(em add a field to a dirfile .SH SYNOPSIS @@ -163,17 +163,17 @@ This indicates a bug in the library. Please report the incident to the GetData developers. .TP +.B GD_E_IO +An I/O error occurred while creating an empty binary file to be associated with +a newly added +.B RAW +field. +.TP .B GD_E_PROTECTED The metadata of the fragment was protected from change. Or, the creation of a .B RAW field was attempted and the data of the fragment was protected. .TP -.B GD_E_RAW_IO -An I/O error occurred while creating an empty binary file to be associated with -a newly added -.B RAW -field. -.TP .B GD_E_UNKNOWN_ENCODING The encoding scheme of the indicated format specification fragment is not known to the library. As a result, the library was unable to create an empty binary Modified: trunk/getdata/man/gd_add_bit.3 =================================================================== --- trunk/getdata/man/gd_add_bit.3 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_add_bit.3 2014-10-16 23:26:40 UTC (rev 928) @@ -1,6 +1,6 @@ .\" gd_add_bit.3. The gd_add_bit man page. .\" -.\" Copyright (C) 2008, 2009, 2010, 2012, 2013 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2012, 2013, 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 gd_add_bit 3 "5 May 2014" "Version 0.9.0" "GETDATA" +.TH gd_add_bit 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_add_bit, gd_add_carray gd_add_clincom, gd_add_const, gd_add_cpolynom, gd_add_crecip, gd_add_divide, gd_add_lincom, gd_add_linterp, gd_add_multiply, @@ -264,27 +264,30 @@ This indicates a bug in the library. Please report the incident to the GetData developers. .TP +.B GD_E_IO +.RB ( gd_add_raw () +only) An I/O error occurred while creating an empty binary file to be +associated with a newly added +.B RAW +field. +.TP .B GD_E_PROTECTED The metadata of the fragment was protected from change. Or, the creation of a .B RAW field was attempted and the data of the fragment was protected. .TP -.B GD_E_RAW_IO -An I/O error occurred while creating an empty binary file to be associated with -a newly added -.B RAW -field. -.TP .B GD_E_UNKNOWN_ENCODING -The encoding scheme of the indicated format specification fragment is not known -to the library. As a result, the library was unable to create an empty binary -file to be associated with a newly added +.RB ( gd_add_raw () +only) The encoding scheme of the indicated format specification fragment is not +known to the library. As a result, the library was unable to create an empty +binary file to be associated with a newly added .B RAW field. .TP .B GD_E_UNSUPPORTED -The encoding scheme of the indicated format specification fragment does not -support creating an empty binary file to be associated with a newly added +.RB ( gd_add_raw () +only) The encoding scheme of the indicated format specification fragment does +not support creating an empty binary file to be associated with a newly added .B RAW field. .PP Modified: trunk/getdata/man/gd_add_spec.3 =================================================================== --- trunk/getdata/man/gd_add_spec.3 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_add_spec.3 2014-10-16 23:26:40 UTC (rev 928) @@ -1,6 +1,6 @@ .\" gd_add_spec.3. The gd_add_spec man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 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 gd_add_spec 3 "4 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_add_spec 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_add_spec, gd_madd_spec \(em add a field to a dirfile .SH SYNOPSIS @@ -94,6 +94,12 @@ A syntax error was encountered in .IR line . .TP +.B GD_E_IO +An I/O error occurred while creating an empty binary file to be associated with +a newly added +.B RAW +field. +.TP .B GD_E_LINE_TOO_LONG The supplied .I line @@ -109,12 +115,6 @@ .B RAW field was attempted and the data of the fragment was protected. .TP -.B GD_E_RAW_IO -An I/O error occurred while creating an empty binary file to be associated with -a newly added -.B RAW -field. -.TP .B GD_E_UNKNOWN_ENCODING The encoding scheme of the indicated format specification fragment is not known to the library. As a result, the library was unable to create an empty binary Modified: trunk/getdata/man/gd_alter_bit.3 =================================================================== --- trunk/getdata/man/gd_alter_bit.3 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_alter_bit.3 2014-10-16 23:26:40 UTC (rev 928) @@ -1,6 +1,6 @@ .\" gd_alter_bit.3. The gd_alter_bit man page. .\" -.\" Copyright (C) 2008, 2009, 2010, 2012, 2013 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2012, 2013, 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 gd_alter_bit 3 "1 October 2013" "Version 0.9.0" "GETDATA" +.TH gd_alter_bit 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_bit, gd_alter_carray, gd_alter_clincom, gd_alter_const, gd_alter_cpolynom, gd_alter_crecip, gd_alter_divide, gd_alter_lincom, @@ -197,7 +197,8 @@ .I recode is non-zero, the binary file associated with the .B RAW -field will be re-encoded to reflect the new field parameters. +field will be re-encoded to reflect the new field parameters. In this case, +the field's I/O pointer will be reset to the beginning-of-frame. If .BR gd_alter_carray () @@ -248,13 +249,7 @@ .IR data_type " or " const_type argument was invalid. .TP -.B GD_E_PROTECTED -The metadata of the fragment was protected from change. Or, a request to -translate the binary file associated with a -.B RAW -field was attempted, but the data of the fragment was protected. -.TP -.B GD_E_RAW_IO +.B GD_E_IO An I/O error occurred while translating the binary file associated with a modified .B RAW @@ -262,6 +257,12 @@ .B LINTERP table file. .TP +.B GD_E_PROTECTED +The metadata of the fragment was protected from change. Or, a request to +translate the binary file associated with a +.B RAW +field was attempted, but the data of the fragment was protected. +.TP .B GD_E_UNKNOWN_ENCODING The encoding scheme of the indicated format specification fragment is not known to the library. As a result, the library was unable to translate the binary Modified: trunk/getdata/man/gd_alter_encoding.3.in =================================================================== --- trunk/getdata/man/gd_alter_encoding.3.in 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_alter_encoding.3.in 2014-10-16 23:26:40 UTC (rev 928) @@ -2,7 +2,7 @@ .\" .\" @configure_input@ .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2014 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -15,7 +15,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_alter_encoding 3 "20 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_alter_encoding 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_encoding \(em modify the binary encoding of data in a dirfile .SH SYNOPSIS @@ -32,8 +32,8 @@ .BR gd_alter_encoding () function sets the binary encoding of the format specification fragment given by .I fragment_index -to -.I byte_sex +to the encoding specified by +.I encoding in the dirfile(5) database specified by .IR dirfile . The binary encoding of a fragment indicate the encoding of data stored in binary @@ -45,13 +45,14 @@ fields is ignored. The -.I byte_sex +.I encoding argument should be one of the following: .IP .nh .ad l .BR GD_UNENCODED ,\~ GD_BZIP2_ENCODED ,\~ GD_GZIP_ENCODED ,\~ -.BR GD_LZMA_ENCODED ,\~ GD_SLIM_ENCODED ,\~ GD_TEXT_ENCODED . +.BR GD_LZMA_ENCODED ,\~ GD_SLIM_ENCODED ,\~ GD_SIE_ENCODED ,\~ +.BR GD_TEXT_ENCODED . .ad n .hy .PP @@ -73,7 +74,11 @@ .B RAW fields to account for the change in binary encoding. If the encoding of the fragment is encoding insensitive, or if the data type is only one byte in -size, no change is made. If +size, no change is made. The I/O pointer of all affected +.B RAW +fields is reset to the beginning-of-frame. + +If .I recode is zero, affected binary files are left untouched. @@ -95,14 +100,14 @@ .B GD_E_BAD_INDEX The supplied index was out of range. .TP +.B GD_E_IO +An I/O error occurred while attempting to recode a binary file. +.TP .B GD_E_PROTECTED The metadata of the given format specification fragment was protected from change, or the binary data of the fragment was protected from change and binary file recoding was requested. .TP -.B GD_E_RAW_IO -An I/O error occurred while attempting to recode a binary file. -.TP .B GD_E_UNCLEAN_DB An error occurred while moving the recoded file into place. As a result, the database may be in an unclean state. See the Modified: trunk/getdata/man/gd_alter_endianness.3.in =================================================================== --- trunk/getdata/man/gd_alter_endianness.3.in 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_alter_endianness.3.in 2014-10-16 23:26:40 UTC (rev 928) @@ -2,7 +2,7 @@ .\" .\" @configure_input@ .\" -.\" Copyright (C) 2008, 2010, 2012 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2012, 2014 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -15,7 +15,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_alter_endianness 3 "1 January 2012" "Version 0.8.0" "GETDATA" +.TH gd_alter_endianness 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_endianness \(em modify the byte sex of fields in a dirfile .SH SYNOPSIS @@ -83,7 +83,11 @@ .B RAW fields to account for the change in byte sex. If the encoding of the fragment is endianness insensitive, or if the data type is only one byte in -size, no change is made. If +size, no change is made. The I/O pointer of all affected +.B RAW +fields is reset to the beginning-of-frame. + +If .I recode is zero, affected binary files are left untouched. @@ -110,14 +114,14 @@ .B GD_E_BAD_INDEX The supplied index was out of range. .TP +.B GD_E_IO +An I/O error occurred while attempting to byte swap a binary file. +.TP .B GD_E_PROTECTED The metadata of the indicated format specification fragment was protected from change, or the binary data of the fragment was protected from change and binary file byte swapping was requested. .TP -.B GD_E_RAW_IO -An I/O error occurred while attempting to byte swap a binary file. -.TP .B GD_E_UNCLEAN_DB An error occurred while moving the byte-swapped file into place. As a result, the database may be in an unclean state. See the Modified: trunk/getdata/man/gd_alter_entry.3 =================================================================== --- trunk/getdata/man/gd_alter_entry.3 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_alter_entry.3 2014-10-16 23:26:40 UTC (rev 928) @@ -1,6 +1,6 @@ .\" gd_alter_entry.3. The gd_alter_entry man page. .\" -.\" Copyright (C) 2008, 2009, 2010, 2012, 2013 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2012, 2013, 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 gd_alter_entry 3 "27 November 2013" "Version 0.9.0" "GETDATA" +.TH gd_alter_entry 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_entry \(em modify the metadata of a dirfile field .SH SYNOPSIS @@ -79,7 +79,8 @@ field and the .I recode argument is non-zero, the binary file associated with the field will be -converted for changes in data type and samples-per-frame. If +converted for changes in data type and samples-per-frame. In this case, +the field's I/O pointer will be reset to the beginning-of-frame. If .I recode is zero, no binary file conversion will take place. @@ -236,13 +237,7 @@ .BR CARRAY entry, was invalid. .TP -.B GD_E_PROTECTED -The metadata of the fragment was protected from change. Or, a request to -translate the binary file associated with a -.B RAW -field was attempted, but the data of the fragment was protected. -.TP -.B GD_E_RAW_IO +.B GD_E_IO An I/O error occurred while translating the binary file associated with a modified .B RAW @@ -250,6 +245,12 @@ .B LINTERP table file. .TP +.B GD_E_PROTECTED +The metadata of the fragment was protected from change. Or, a request to +translate the binary file associated with a +.B RAW +field was attempted, but the data of the fragment was protected. +.TP .B GD_E_UNKNOWN_ENCODING The encoding scheme of the indicated format specification fragment is not known to the library. As a result, the library was unable to translate the binary Modified: trunk/getdata/man/gd_alter_frameoffset.3.in =================================================================== --- trunk/getdata/man/gd_alter_frameoffset.3.in 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_alter_frameoffset.3.in 2014-10-16 23:26:40 UTC (rev 928) @@ -2,7 +2,7 @@ .\" .\" @configure_input@ .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2014 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -15,7 +15,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_alter_frameoffset 3 "20 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_alter_frameoffset 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_frameoffset \(em modify the starting frame of fields in a dirfile .SH SYNOPSIS @@ -63,7 +63,12 @@ fields to account for the change in frame offset. If the new frame offset is larger than the old frame offset, this will result in permanent deletion of data from the database. If the new frame offset is smaller than the old frame -offset, the binary file will be padded at the front with zeroes. If +offset, the binary file will be padded at the front with zeroes. The I/O +pointer of all affected +.B RAW +fields is reset to the beginning-of-frame. + +If .I recode is zero, affected binary files are left untouched. @@ -85,6 +90,9 @@ .B GD_E_BAD_INDEX The supplied index was out of range. .TP +.B GD_E_IO +An I/O error occurred while attempting to shift a binary file. +.TP .B GD_E_PROTECTED The metadata of the given format specification fragment was protected from change, or the binary data of the fragment was protected from change and binary @@ -93,9 +101,6 @@ .B GD_E_RANGE The supplied offset was less than zero. .TP -.B GD_E_RAW_IO -An I/O error occurred while attempting to shift a binary file. -.TP .B GD_E_UNCLEAN_DB An error occurred while moving the shifted file into place. As a result, the database may be in an unclean state. See the Modified: trunk/getdata/man/gd_alter_spec.3 =================================================================== --- trunk/getdata/man/gd_alter_spec.3 2014-10-11 04:38:47 UTC (rev 927) +++ trunk/getdata/man/gd_alter_spec.3 2014-10-16 23:26:40 UTC (rev 928) @@ -1,6 +1,6 @@ .\" gd_alter_spec.3. The gd_alter_spec man page. .\" -.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011, 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 gd_alter_spec 3 "5 May 2014" "Version 0.9.0" "GETDATA" +.TH gd_alter_spec 3 "16 October 2014" "Version 0.9.0" "GETDATA" .SH NAME gd_alter_spec, gd_malter_spec \(em modify a field in a dirfile .SH SYNOPSIS @@ -55,7 +55,8 @@ and the .I recode argument is non-zero, the binary file associated with the field will be -converted for changes in data type and samples-per-frame. If +converted for changes in data type and samples-per-frame. In this case, +the field's I/O pointer will be reset to ... [truncated message content] |
From: <ket...@us...> - 2014-10-17 01:13:49
|
Revision: 929 http://sourceforge.net/p/getdata/code/929 Author: ketiltrout Date: 2014-10-17 01:13:36 +0000 (Fri, 17 Oct 2014) Log Message: ----------- Ignore GD_RDONLY if creating a dirfile. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/man/gd_cbopen.3 trunk/getdata/src/open.c trunk/getdata/test/Makefile.am trunk/getdata/test/creat_rdonly.c Added Paths: ----------- trunk/getdata/test/creat_rdonly_exists.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2014-10-16 23:26:40 UTC (rev 928) +++ trunk/getdata/ChangeLog 2014-10-17 01:13:36 UTC (rev 929) @@ -1,3 +1,8 @@ +2014-10-16 D. V. Wiebe <g et...@ke...> svn:929 + * src/open.c (_GD_CreateDirfile): Force GD_RDWR when creating a dirfile. + * test/creat_rdonly.c: Updated. + * test/creat_rdonly_exists.c: Added. + 2014-10-16 D. V. Wiebe <g et...@ke...> svn:928 * bindings/make_parameters.c: Replace numeric type literals with CPP macros for legibility. Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2014-10-16 23:26:40 UTC (rev 928) +++ trunk/getdata/NEWS 2014-10-17 01:13:36 UTC (rev 929) @@ -30,6 +30,11 @@ gzip-encoded data works. See the gzip discussion in the 0.8.0 section below for important notes. + * A newly-created dirfile is now always opened in read-write mode, ignoring the + access mode specified in the call. Previously, specifying both GD_RDONLY and + GD_CREAT in open calls would result in an access mode (GD_E_ACCMODE) error if + the dirfile didn't already exist. + * 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. Modified: trunk/getdata/man/gd_cbopen.3 =================================================================== --- trunk/getdata/man/gd_cbopen.3 2014-10-16 23:26:40 UTC (rev 928) +++ trunk/getdata/man/gd_cbopen.3 2014-10-17 01:13:36 UTC (rev 929) @@ -118,6 +118,13 @@ An empty dirfile will be created, if one does not already exist. This will create both the dirfile directory and an empty format specification file called .IR format . +If the call creates a dirfile, then the specified access mode is ignored: a +newly-created DIRFILE is always opened with access mode +.BR GD_RDWR , +even if +.B GD_RDONLY +had been specified. + The directory will have have mode .BR S_IRWXU " | " S_IRWXG " | " S_IRWXO (0777), modified by the caller's umask value (see @@ -127,7 +134,6 @@ file will have mode .BR S_IRUSR " | " S_IWUSR " | " S_IRGRP " | " S_IWGRP " | " S_IROTH " | " S_IWOTH (0666), also modified by the caller's umask. - The owner of the dirfile directory and .I format file will be the effective user ID of the caller. Group ownership follows the @@ -629,9 +635,7 @@ be internally flagged as invalid. Possible error values are: .TP 8 .B GD_E_ACCMODE -The library was asked to create or truncate a dirfile opened read-only (i.e. -.B GD_CREAT -or +The library was asked to truncate a dirfile opened read-only (i.e. .B GD_TRUNC was specified in .I flags Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2014-10-16 23:26:40 UTC (rev 928) +++ trunk/getdata/src/open.c 2014-10-17 01:13:36 UTC (rev 929) @@ -301,13 +301,9 @@ if ((D->flags & GD_CREAT && (dirfd < 0 || format_error)) || (D->flags & GD_TRUNC)) { - /* can't create a read-only dirfile */ - if ((D->flags & GD_ACCMODE) == GD_RDONLY) { - _GD_SetError(D, GD_E_ACCMODE, 0, NULL, 0, NULL); - free(dirfile); - dreturn("%p", NULL); - return NULL; - } + /* a newly created dirfile ignores the specified access mode */ + if ((D->flags & GD_ACCMODE) == GD_RDONLY) + D->flags |= GD_RDWR; /* attempt to create the dirfile directory, if not present */ if (dirfd < 0) { Index: trunk/getdata/test =================================================================== --- trunk/getdata/test 2014-10-16 23:26:40 UTC (rev 928) +++ trunk/getdata/test 2014-10-17 01:13:36 UTC (rev 929) Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore ## -303,6 +303,7 ## creat creat_excl creat_rdonly +creat_rdonly_exists cvlist cvlist_array cvlist_array0 Modified: trunk/getdata/test/Makefile.am =================================================================== --- trunk/getdata/test/Makefile.am 2014-10-16 23:26:40 UTC (rev 928) +++ trunk/getdata/test/Makefile.am 2014-10-17 01:13:36 UTC (rev 929) @@ -131,7 +131,7 @@ convert_uint8_int64 convert_uint8_int8 convert_uint8_uint16 \ convert_uint8_uint32 convert_uint8_uint64 -CREAT_TESTS=creat creat_excl creat_rdonly +CREAT_TESTS=creat creat_excl creat_rdonly creat_rdonly_exists DEL_TESTS=del_alias del_carray del_carray_deref del_const del_const_deref \ del_const_force del_data del_data_enoent del_data_open del_derived \ Modified: trunk/getdata/test/creat_rdonly.c =================================================================== --- trunk/getdata/test/creat_rdonly.c 2014-10-16 23:26:40 UTC (rev 928) +++ trunk/getdata/test/creat_rdonly.c 2014-10-17 01:13:36 UTC (rev 929) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2011, 2013 D. V. Wiebe +/* Copyright (C) 2008-2011, 2013, 2014 D. V. Wiebe * *************************************************************************** * @@ -35,18 +35,20 @@ DIRFILE *D; rmdirfile(); - D = gd_open(filedir, GD_RDONLY | GD_CREAT); + D = gd_open(filedir, GD_RDONLY | GD_CREAT | GD_VERBOSE); e1 = gd_error(D); - CHECKI(e1, GD_E_ACCMODE); + CHECKI(e1, 0); - e2 = gd_close(D); + e2 = gd_add_spec(D, "test CONST UINT8 1", 0); CHECKI(e2, 0); + gd_discard(D); + unlink_ret = unlink(format); rmdir_ret = rmdir(filedir); - CHECKI(unlink_ret, -1); - CHECKI(rmdir_ret, -1); + CHECKI(unlink_ret, 0); + CHECKI(rmdir_ret, 0); return r; } Added: trunk/getdata/test/creat_rdonly_exists.c =================================================================== --- trunk/getdata/test/creat_rdonly_exists.c (rev 0) +++ trunk/getdata/test/creat_rdonly_exists.c 2014-10-17 01:13:36 UTC (rev 929) @@ -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"; + int e1, e2, r = 0; + DIRFILE *D; + + rmdirfile(); + mkdir(filedir, 0777); + close(open(format, O_CREAT | O_EXCL | O_WRONLY, 0666)); + + D = gd_open(filedir, GD_RDONLY | GD_CREAT); + e1 = gd_error(D); + CHECKI(e1, 0); + + gd_add_spec(D, "test CONST UINT8 1", 0); + e2 = gd_error(D); + CHECKI(e2, GD_E_ACCMODE); + + 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...> - 2015-01-12 10:10:05
|
Revision: 940 http://sourceforge.net/p/getdata/code/940 Author: ketiltrout Date: 2015-01-12 10:09:51 +0000 (Mon, 12 Jan 2015) Log Message: ----------- Namespaces. Includes some refactoring of field code handling in the parser. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/configure.ac trunk/getdata/man/gd_array_len.3 trunk/getdata/man/gd_bof.3 trunk/getdata/man/gd_entry.3 trunk/getdata/man/gd_entry_type.3 trunk/getdata/man/gd_eof.3 trunk/getdata/man/gd_flush.3 trunk/getdata/man/gd_framenum_subset.3 trunk/getdata/man/gd_get_carray_slice.3 trunk/getdata/man/gd_getdata.3 trunk/getdata/man/gd_linterp_tablename.3 trunk/getdata/man/gd_native_type.3 trunk/getdata/man/gd_put_carray_slice.3 trunk/getdata/man/gd_put_string.3 trunk/getdata/man/gd_putdata.3 trunk/getdata/man/gd_raw_filename.3 trunk/getdata/man/gd_seek.3 trunk/getdata/man/gd_spf.3 trunk/getdata/man/gd_tell.3 trunk/getdata/man/gd_validate.3 trunk/getdata/src/add.c trunk/getdata/src/common.c trunk/getdata/src/constant.c trunk/getdata/src/entry.c trunk/getdata/src/errors.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/fpos.c trunk/getdata/src/fragment.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/include.c trunk/getdata/src/internal.h trunk/getdata/src/mod.c trunk/getdata/src/move.c trunk/getdata/src/name.c trunk/getdata/src/open.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/src/spf.c trunk/getdata/test/Makefile.am trunk/getdata/test/del_alias.c trunk/getdata/test/get_polynom_cmpin.c trunk/getdata/test/put_repr.c trunk/getdata/test/repr_bad.c trunk/getdata/test/version_9_strict.c Added Paths: ----------- trunk/getdata/test/add_dot10.c trunk/getdata/test/add_dot5.c trunk/getdata/test/add_dot6.c trunk/getdata/test/add_ns.c trunk/getdata/test/add_ns_frag.c trunk/getdata/test/add_ns_frag2.c trunk/getdata/test/include_ns.c trunk/getdata/test/name_dot10.c trunk/getdata/test/name_dot5.c trunk/getdata/test/name_dot5r.c trunk/getdata/test/name_dot9.c trunk/getdata/test/name_ns.c trunk/getdata/test/name_ns2.c trunk/getdata/test/name_ns2r.c trunk/getdata/test/name_nsdot.c trunk/getdata/test/parse_include_ns.c trunk/getdata/test/parse_include_ns2.c trunk/getdata/test/parse_include_nsabs.c trunk/getdata/test/parse_include_nsinh.c trunk/getdata/test/parse_include_nspop.c trunk/getdata/test/parse_include_nsrabs.c trunk/getdata/test/parse_include_nsrainh.c trunk/getdata/test/parse_include_nsrinh.c trunk/getdata/test/parse_include_nsroot.c trunk/getdata/test/parse_ns.c trunk/getdata/test/parse_ns_abs.c trunk/getdata/test/parse_ns_dot.c trunk/getdata/test/parse_ns_dotdot.c trunk/getdata/test/parse_ns_dotdotns.c trunk/getdata/test/parse_ns_dotns.c trunk/getdata/test/parse_ns_ndotdots.c trunk/getdata/test/parse_ns_ndots.c trunk/getdata/test/parse_ns_nsdot.c trunk/getdata/test/parse_ns_nsdotdot.c trunk/getdata/test/parse_ns_par.c trunk/getdata/test/parse_ns_sub.c trunk/getdata/test/parse_nsf.c trunk/getdata/test/parse_nsf_abs.c trunk/getdata/test/parse_nsf_alias.c trunk/getdata/test/parse_nsf_dot.c trunk/getdata/test/parse_nsf_hide.c trunk/getdata/test/parse_nsf_index.c trunk/getdata/test/parse_nsf_meta.c trunk/getdata/test/parse_nsf_meta2.c trunk/getdata/test/parse_nsf_par.c trunk/getdata/test/parse_nsf_ref.c trunk/getdata/test/parse_nsf_refabs.c trunk/getdata/test/parse_nsf_refrel.c trunk/getdata/test/parse_nsf_root.c trunk/getdata/test/parse_nsf_rpar.c trunk/getdata/test/parse_nsf_sub.c Removed Paths: ------------- trunk/getdata/test/add_dot.c trunk/getdata/test/name_dot.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/ChangeLog 2015-01-12 10:09:51 UTC (rev 940) @@ -1,9 +1,64 @@ -2014-10-16 D. V. Wiebe <g et...@ke...> svn:929 +2014-12-31 D. V. Wiebe <ge...@ke...> svn:??? + * src/getdata.c (_GD_DoField) src/putdata.c (_GD_DoFieldOut): Fix recursion + counting on error. + + * src/getdata.h.in src/errors.c: Merge GD_E_BAD_REPR into GD_E_BAD_CODE. + + * src/common.c (_GD_FindEntry): Added. + * src/entry.c (gd_raw_filename gd_entry, gd_entry_type gd_linterp_tablename) + src/flush.c (_GD_SyncOrClose) src/spf.c (_GD_GetSPF) src/constant.c + (gd_put_carray_slice gd_put_carray) src/putdata.c (gd_putdata64) + src/flimits.c (gd_eof64 gd_bof64) src/fpos.c (gd_tell64 gd_seek64): + Use _GD_FindEntry instead of _GD_FindFieldAndRepr. + * src/constant.c (_GD_PutCarraySlice) src/putdata.c (_GD_DoFieldOut): + Remove repr parameter. + * src/putdata.c (_GD_DoLinterpOut _GD_DoLincomOut _GD_DoBitOut + _GD_DoPhaseOut _GD_DoRecipOut _GD_DoPolynomOut _GD_DoMplexOut + _GD_DoConstOut): Return error if input field has a repr. + + * src/parse.c: Use struct parser_state to pass around parser data rather + than passing bits and pieces individually. + * src/internal.h: Define struct parser_state. + * src/parse.c (_GD_SimpleParserInit): Added. + * src/open.c (_GD_Open): Initialise the parser proto-state; set or clear + GD_PEDANTIC in the dirfile flags after parsing completes. + + * src/mod.c (gd_alter_spec gd_malter_spec) src/parse.c (gd_strtok) src/add.c + (_GD_FixName gd_madd_spec gd_add_spec): Call _GD_SimpleParserInit(). + + * src/parse.c (_GD_ParseFieldSpec): Speed up strcmps. + + * src/common.c (_GD_GrabDir): Let callers (i.e. _GD_Include) skip + canonicalisation, if they've already done it. + + * src/internal.h: Add ns and nsl to gd_fragment_t. + * src/name.c (_GD_MungeCode): Remove subfield munging (the P parameter). + Replace err_ok with flags parameter. Don't malloc the buffer it the caller + doesn't want it. + * src/name.c (_GD_ValidateField): Replaced affix parameter with flags. + * src/parse.c (_GD_SubfieldCode _GD_CodeFromFrag _GD_InputCode _GD_SetField): + Added. + + * src/name.c (_GD_MungeCode _GD_CheckCodeAffixes _GD_ValidateField) + src/include.c (_GD_SetFieldAffixes _GD_Include): Handle + namespaces. + * src/parse.c (_GD_ParseNamespace): Added. + * src/parse.c (_GD_ParseDirective): Handle "/NAMESPACE" + + * src/name,c (_GD_MakeNewCode): Handle errors better. + + * src/getdata.h.in: Declare GD_EN_DOTTED. + * src/name.c (_GD_PerformRename) src/add.c (_GD_Add): Set or clear GD_EN_DOTTED. + + * src/fragment.c (_GD_SubFragmentList _GD_CheckChangeNamespace + gd_fragment_namespace): Added. + +2014-10-16 D. V. Wiebe <ge...@ke...> svn:929 * src/open.c (_GD_CreateDirfile): Force GD_RDWR when creating a dirfile. * test/creat_rdonly.c: Updated. * test/creat_rdonly_exists.c: Added. -2014-10-16 D. V. Wiebe <g et...@ke...> svn:928 +2014-10-16 D. V. Wiebe <ge...@ke...> svn:928 * bindings/make_parameters.c: Replace numeric type literals with CPP macros for legibility. @@ -22,7 +77,7 @@ * bindings/python/pygetdata.c: Define deprecated Exceptions as aliases for current ones. -2014-07-30 D. V. Wiebe <g et...@ke...> svn:921 +2014-07-30 D. V. Wiebe <ge...@ke...> svn:921 * src/del.c (gd_delete_alias): Deleted. * src/del.c (gd_delete): Don't dereference the field code. @@ -41,11 +96,11 @@ test 225. -2014-07-25 D. V. Wiebe <g et...@ke...> svn:915 +2014-07-25 D. V. Wiebe <ge...@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 +2014-07-25 D. V. Wiebe <ge...@ke...> svn:914 * src/parse.c (_GD_TokToNum): Added. * src/parse.c (_GD_SetScalar): Call _GD_TokToNum to parse numbers. @@ -69,14 +124,14 @@ * 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 +2014-07-17 D. V. Wiebe <ge...@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 +2014-07-17 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. @@ -374,7 +429,8 @@ * bindings/f77/fgetdata.c (GDASCA): Handle error in gd_entry call. - * bindings/php/getdata.c (gdphp_data_to_array): Add missing break. + * bindings/php/getdata.c (gdphp_data_to_array) src/types.c (_GD_ConvertType): + Add missing break. * bindings/php/getdata.c (gd_error_string): Handle error in gd_error_string call. @@ -384,7 +440,7 @@ * bindings/python/pydirfile.c (gdpy_dirfile_getentry gdpy_dirfile_getstring gdpy_dirfile_putcarray gdpy_dirfile_putdata) src/include.c (_GD_Include) src/name.c (_GD_PrepareRename) src/putdata.c (_GD_DoMplexOut) src/sie.c - (_GD_SampIndWrite) src/types.c (_GD_ConvertType): Deallocate buffers on error. + (_GD_SampIndWrite): Deallocate buffers on error. * bindings/python/pyentry.c (gdpy_entry_seta): Set a[i] if the pyobj is complex. @@ -437,7 +493,7 @@ 2013-12-12 D. V. Wiebe <ge...@ke...> svn:874 * src/endian.c (_GD_CheckByteSex): Added. * src/endian.c (_GD_FileSwapBytes): Added (replacing macro in internal.h). - * src/endian.c (_GD_FixEndianness): Call _GD_CheckByteSex() to check wether + * src/endian.c (_GD_FixEndianness): Call _GD_CheckByteSex() to check whether correction is needed. * src/getdata.c (_GD_DoRaw) src/move.c (_GD_MogrifyFile) src/putdata.c @@ -474,8 +530,8 @@ * test/cvlist_meta0.c: Check error. - * bindings/cxx/ getdata/entry.h (Entry::CompScal): Allow non-zero for - RECIP, too. + * bindings/cxx/getdata/entry.h (Entry::CompScal): Allow non-zero for + RECIP, too. 2013-12-06 D. V. Wiebe <ge...@ke...> svn:867 * test/add_dot.c test/alter_clincom.c test/alter_const_r2c.c test/sie_sync.c Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/NEWS 2015-01-12 10:09:51 UTC (rev 940) @@ -35,6 +35,13 @@ GD_RDONLY and GD_CREAT in open calls would result in an access mode (GD_E_ACCMODE) error if the dirfile didn't already exist. + * Many functions which used to silently ignore representation suffixes in + field codes passed to them no longer do that. Most of these will report + an error (GD_E_BAD_CODE) if passed a representation suffix. The affected + functions are: gd_bof, gd_entry, gd_entry_type, gd_eof, gd_flush, + gd_linterp_tablename, gd_put_carray, gd_put_carray_slice, gd_putdata, + gd_raw_close, gd_raw_filename, gd_seek, gd_spf, gd_sync, gd_tell. + * 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. Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/configure.ac 2015-01-12 10:09:51 UTC (rev 940) @@ -80,14 +80,14 @@ AC_CANONICAL_HOST dnl Legacy API -AC_ARG_ENABLE(legacy-api, AS_HELP_STRING([--disable-legacy-api], - [don't include the legacy API wrapper in the library]), dnl' +AC_ARG_ENABLE(legacy-api, AS_HELP_STRING([--enaable-legacy-api], + [include the legacy API wrapper in the library]), dnl' [ case "${enableval}" in no) include_legacy_api="no" ;; *) include_legacy_api="yes" ;; esac - ], [ include_legacy_api="yes" ]) + ], [ include_legacy_api="no" ]) AC_MSG_CHECKING([whether to include the legacy API]) AC_MSG_RESULT([$include_legacy_api]) Modified: trunk/getdata/man/gd_array_len.3 =================================================================== --- trunk/getdata/man/gd_array_len.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_array_len.3 2015-01-12 10:09:51 UTC (rev 940) @@ -69,11 +69,6 @@ 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). Modified: trunk/getdata/man/gd_bof.3 =================================================================== --- trunk/getdata/man/gd_bof.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_bof.3 2015-01-12 10:09:51 UTC (rev 940) @@ -78,11 +78,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of its inputs was not recognised. -.TP .B GD_E_DIMENSION A scalar field was found where a vector field was expected in the definition of Modified: trunk/getdata/man/gd_entry.3 =================================================================== --- trunk/getdata/man/gd_entry.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_entry.3 2015-01-12 10:09:51 UTC (rev 940) @@ -93,11 +93,6 @@ .TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. -.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). Modified: trunk/getdata/man/gd_entry_type.3 =================================================================== --- trunk/getdata/man/gd_entry_type.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_entry_type.3 2015-01-12 10:09:51 UTC (rev 940) @@ -80,11 +80,6 @@ The field specified by .I field_code was not found in the database. -.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). Modified: trunk/getdata/man/gd_eof.3 =================================================================== --- trunk/getdata/man/gd_eof.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_eof.3 2015-01-12 10:09:51 UTC (rev 940) @@ -89,11 +89,6 @@ .I INDEX as one of its inputs. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of its inputs was not recognised. -.TP .B GD_E_DIMENSION A scalar field was found where a vector field was expected in the definition of Modified: trunk/getdata/man/gd_flush.3 =================================================================== --- trunk/getdata/man/gd_flush.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_flush.3 2015-01-12 10:09:51 UTC (rev 940) @@ -85,11 +85,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised. -.TP .B GD_E_IO An I/O error occurred while trying to write modified data or metadata to disk. .TP Modified: trunk/getdata/man/gd_framenum_subset.3 =================================================================== --- trunk/getdata/man/gd_framenum_subset.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_framenum_subset.3 2015-01-12 10:09:51 UTC (rev 940) @@ -110,11 +110,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of its input fields, was not recognised. -.TP .B GD_E_BAD_SCALAR A scalar field used in the definition of the field was not found, or was not of scalar type. Modified: trunk/getdata/man/gd_get_carray_slice.3 =================================================================== --- trunk/getdata/man/gd_get_carray_slice.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_get_carray_slice.3 2015-01-12 10:09:51 UTC (rev 940) @@ -183,11 +183,6 @@ .BR gd_get_string (3) instead. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of the field codes it uses for input, was invalid. -.TP .B GD_E_BAD_TYPE An invalid .I return_type Modified: trunk/getdata/man/gd_getdata.3 =================================================================== --- trunk/getdata/man/gd_getdata.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_getdata.3 2015-01-12 10:09:51 UTC (rev 940) @@ -269,11 +269,6 @@ .I dirfile was supplied. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of the field codes it uses for input, was invalid. -.TP .B GD_E_BAD_SCALAR A scalar field used in the definition of the field was not found, or was not of scalar type. Modified: trunk/getdata/man/gd_linterp_tablename.3 =================================================================== --- trunk/getdata/man/gd_linterp_tablename.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_linterp_tablename.3 2015-01-12 10:09:51 UTC (rev 940) @@ -76,11 +76,6 @@ was not a .B LINTERP field. -.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). Modified: trunk/getdata/man/gd_native_type.3 =================================================================== --- trunk/getdata/man/gd_native_type.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_native_type.3 2015-01-12 10:09:51 UTC (rev 940) @@ -125,11 +125,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of its input fields, was not recognised. -.TP .B GD_E_DIMENSION A scalar field was found where a vector field was expected. .TP Modified: trunk/getdata/man/gd_put_carray_slice.3 =================================================================== --- trunk/getdata/man/gd_put_carray_slice.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_put_carray_slice.3 2015-01-12 10:09:51 UTC (rev 940) @@ -178,10 +178,6 @@ .BR gd_put_string (3) instead. .TP -.B GD_E_BAD_REPR -A representation suffix in the field definition was invalid, or an attempt was -made to write to a representation, instead of the underlying field. -.TP .B GD_E_BAD_TYPE An invalid .I data_type Modified: trunk/getdata/man/gd_put_string.3 =================================================================== --- trunk/getdata/man/gd_put_string.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_put_string.3 2015-01-12 10:09:51 UTC (rev 940) @@ -80,11 +80,6 @@ .BR gd_put_constant (3) instead. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised. -.TP .B GD_E_BAD_TYPE An invalid .I data_type Modified: trunk/getdata/man/gd_putdata.3 =================================================================== --- trunk/getdata/man/gd_putdata.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_putdata.3 2015-01-12 10:09:51 UTC (rev 940) @@ -182,12 +182,6 @@ how to partition the input data. Alternately, the caller may have attempted to write to the implicit INDEX field, which is not possible. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised, or an attempt was made to write to a field representation, -instead of the underlying field. -.TP .B GD_E_BAD_TYPE An invalid .I data_type Modified: trunk/getdata/man/gd_raw_filename.3 =================================================================== --- trunk/getdata/man/gd_raw_filename.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_raw_filename.3 2015-01-12 10:09:51 UTC (rev 940) @@ -67,11 +67,6 @@ .B RAW field. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised. -.TP .B GD_E_UNKNOWN_ENCODING The encoding scheme of the specified field could not be determined or was not understood by GetData. Modified: trunk/getdata/man/gd_seek.3 =================================================================== --- trunk/getdata/man/gd_seek.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_seek.3 2015-01-12 10:09:51 UTC (rev 940) @@ -159,11 +159,6 @@ .I INDEX field, which has no end-of-field marker. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of the field codes it uses for input, was invalid. -.TP .B GD_E_DIMENSION The specified field or one of its inputs wasn't of vector type. .TP Modified: trunk/getdata/man/gd_spf.3 =================================================================== --- trunk/getdata/man/gd_spf.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_spf.3 2015-01-12 10:09:51 UTC (rev 940) @@ -59,11 +59,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised. -.TP .B GD_E_DIMENSION A scalar field was found where a vector field was expected. .TP Modified: trunk/getdata/man/gd_tell.3 =================================================================== --- trunk/getdata/man/gd_tell.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_tell.3 2015-01-12 10:09:51 UTC (rev 940) @@ -60,11 +60,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.IR field_code , -or in one of the field codes it uses for input, was invalid. -.TP .B GD_E_DIMENSION The specified field or one of its inputs wasn't of vector type. .TP Modified: trunk/getdata/man/gd_validate.3 =================================================================== --- trunk/getdata/man/gd_validate.3 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/man/gd_validate.3 2015-01-12 10:09:51 UTC (rev 940) @@ -56,11 +56,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised. -.TP .B GD_E_BAD_SCALAR A non-literal scalar used in the definition of the field or one of its inputs was not found, or was not a Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/add.c 2015-01-12 10:09:51 UTC (rev 940) @@ -43,11 +43,12 @@ { gd_entry_t *P; char *ptr; + struct parser_state p; dtrace("%p, %p, \"%s\", %i, %p", D, buffer, name, frag, offset); /* Check prefix and suffix */ - if (_GD_CheckCodeAffixes(D, NULL, name, frag, 1)) { + if (_GD_CheckCodeAffixes(D, name, frag, 1)) { dreturn("%p", NULL); return NULL; } @@ -60,7 +61,8 @@ return NULL; } - P = _GD_CheckParent(D, &ptr, -1, 0); + _GD_SimpleParserInit(D, NULL, &p); + P = _GD_CheckParent(D, &p, &ptr, -1); if (D->error) { free(*buffer); @@ -109,11 +111,8 @@ E->scalar[i] = NULL; } else { /* check for correct affixes */ - if (_GD_CheckCodeAffixes(D, NULL, entry->scalar[i], entry->fragment_index, - 1)) - { + if (_GD_CheckCodeAffixes(D, 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) && @@ -267,7 +266,9 @@ added field this way */ /* Check */ - if (_GD_ValidateField(E->field + offset, D->standards, 1, 0, &is_dot)) { + if (_GD_ValidateField(E->field + offset, D->standards, 1, GD_VF_CODE, + &is_dot)) + { _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_INVALID, NULL, 0, entry->field); _GD_FreeE(D, E, 1); dreturn("%p", NULL); @@ -300,10 +301,10 @@ E->e->u.raw.file[0].idata = E->e->u.raw.file[1].idata = -1; E->e->u.raw.file[0].subenc = GD_ENC_UNKNOWN; - E->e->u.raw.filebase = _GD_MungeCode(D, NULL, + E->e->u.raw.filebase = _GD_MungeCode(D, NULL, 0, D->fragment[entry->fragment_index].prefix, D->fragment[entry->fragment_index].suffix, NULL, NULL, E->field, - &offset, 0); + NULL, NULL, GD_MC_RQ_PARTS); if (D->error) break; @@ -331,8 +332,7 @@ E->EN(lincom,n_fields), NULL); for (i = 0; i < E->EN(lincom,n_fields); ++i) - _GD_CheckCodeAffixes(D, NULL, entry->in_fields[i], - entry->fragment_index, 1); + _GD_CheckCodeAffixes(D, entry->in_fields[i], entry->fragment_index, 1); if (D->error) break; @@ -369,8 +369,8 @@ case GD_LINTERP_ENTRY: E->e->u.linterp.table_len = -1; - if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1)) + if (_GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, + 1)) { break; } @@ -382,9 +382,9 @@ case GD_DIVIDE_ENTRY: case GD_INDIR_ENTRY: case GD_SINDIR_ENTRY: - if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1) || _GD_CheckCodeAffixes(D, NULL, - entry->in_fields[1], entry->fragment_index, 1)) + if (_GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, + 1) || _GD_CheckCodeAffixes(D, entry->in_fields[1], + entry->fragment_index, 1)) { break; } @@ -393,8 +393,8 @@ E->in_fields[1] = _GD_Strdup(D, entry->in_fields[1]); break; case GD_RECIP_ENTRY: - if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1)) + if (_GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, + 1)) { break; } @@ -418,8 +418,8 @@ E->EN(bit,numbits) = entry->EN(bit,numbits); E->EN(bit,bitnum) = entry->EN(bit,bitnum); - if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1)) + if (_GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, + 1)) { break; } @@ -441,8 +441,8 @@ case GD_PHASE_ENTRY: E->EN(phase,shift) = entry->EN(phase,shift); - if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1)) + if (_GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, + 1)) { break; } @@ -455,9 +455,9 @@ E->EN(window,windop) = entry->EN(window,windop); E->EN(window,threshold) = entry->EN(window,threshold); - if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1) || _GD_CheckCodeAffixes(D, NULL, - entry->in_fields[1], entry->fragment_index, 1)) + if (_GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, + 1) || _GD_CheckCodeAffixes(D, entry->in_fields[1], + entry->fragment_index, 1)) { break; } @@ -474,9 +474,9 @@ E->EN(mplex,count_val) = entry->EN(mplex,count_val); E->EN(mplex,period) = entry->EN(mplex,period); - if (_GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1) || _GD_CheckCodeAffixes(D, NULL, - entry->in_fields[1], entry->fragment_index, 1)) + if (_GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, + 1) || _GD_CheckCodeAffixes(D, entry->in_fields[1], + entry->fragment_index, 1)) { break; } @@ -545,10 +545,8 @@ _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_ENTRY_POLYORD, NULL, E->EN(polynom,poly_ord), NULL); } else { - _GD_CheckCodeAffixes(D, NULL, entry->in_fields[0], - entry->fragment_index, 1); - _GD_CheckCodeAffixes(D, NULL, entry->in_fields[1], - entry->fragment_index, 1); + _GD_CheckCodeAffixes(D, entry->in_fields[0], entry->fragment_index, 1); + _GD_CheckCodeAffixes(D, entry->in_fields[1], entry->fragment_index, 1); } if (D->error) @@ -607,6 +605,7 @@ dreturn("%p", NULL); return NULL; } + E->flags |= GD_EN_DOTTED; D->dot_list = (gd_entry_t **)new_list; } @@ -680,6 +679,7 @@ int n_cols; int me; gd_entry_t* E = NULL; + struct parser_state p; dtrace("%p, \"%s\", \"%s\"", D, line, parent); @@ -718,13 +718,14 @@ } /* 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_NOSTANDARD); + _GD_SimpleParserInit(D, "gd_madd_spec()", &p); + n_cols = _GD_Tokenise(D, &p, line, &outstring, &tok_pos, MAX_IN_COLS, + in_cols); /* Directive parsing is skipped -- The Field Spec parser will add the field */ if (!D->error) - _GD_ParseFieldSpec(D, n_cols, in_cols, E, "dirfile_madd_spec()", 0, me, - D->standards, 1, GD_PEDANTIC, 1, &outstring, tok_pos); + _GD_ParseFieldSpec(D, &p, n_cols, in_cols, E, me, 1, 1, &outstring, + tok_pos); free(outstring); @@ -749,6 +750,7 @@ const char *tok_pos = NULL; char *in_cols[MAX_IN_COLS]; int n_cols; + struct parser_state p; dtrace("%p, \"%s\", %i", D, line, fragment_index); @@ -782,14 +784,23 @@ _GD_ClearError(D); + if (~D->flags & GD_HAVE_VERSION) + _GD_FindVersion(D); + + if (D->av) { + p.standards = D->standards; + p.pedantic = 1; + } + /* 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_NOSTANDARD); + _GD_SimpleParserInit(D, "gd_add_spec()", &p); + n_cols = _GD_Tokenise(D, &p, line, &outstring, &tok_pos, MAX_IN_COLS, + in_cols); /* Directive parsing is skipped -- The Field Spec parser will add the field */ if (!D->error) - _GD_ParseFieldSpec(D, n_cols, in_cols, NULL, "dirfile_add_spec()", 0, - fragment_index, D->standards, 1, GD_PEDANTIC, 1, &outstring, tok_pos); + _GD_ParseFieldSpec(D, &p, n_cols, in_cols, NULL, fragment_index, 1, 1, + &outstring, tok_pos); free(outstring); @@ -1425,7 +1436,7 @@ /* Actually store the constant, now */ if (entry) - _GD_DoFieldOut(D, entry, 0, 0, 1, data_type, value); + _GD_DoFieldOut(D, entry, 0, 1, data_type, value); dreturn("%i", D->error ? -1 : 0); return D->error ? -1 : 0; @@ -1458,7 +1469,7 @@ /* Actually store the carray, now */ if (entry) - _GD_DoFieldOut(D, entry, 0, 0, array_len, data_type, values); + _GD_DoFieldOut(D, entry, 0, array_len, data_type, values); dreturn("%i", D->error ? -1 : 0); return D->error ? -1 : 0; @@ -2120,7 +2131,7 @@ /* Actually store the constant, now */ if (entry) - _GD_DoFieldOut(D, entry, 0, 0, 1, data_type, value); + _GD_DoFieldOut(D, entry, 0, 1, data_type, value); dreturn("%i", D->error ? -1 : 0); return D->error ? -1 : 0; @@ -2153,7 +2164,7 @@ /* Actually store the carray, now */ if (entry) - _GD_DoFieldOut(D, entry, 0, 0, array_len, data_type, values); + _GD_DoFieldOut(D, entry, 0, array_len, data_type, values); dreturn("%i", D->error ? -1 : 0); return D->error ? -1 : 0; @@ -2282,12 +2293,14 @@ } /* check alias name */ - if (_GD_ValidateField(munged_code + offset, D->standards, 1, 0, NULL)) + if (_GD_ValidateField(munged_code + offset, D->standards, 1, GD_VF_CODE, + NULL)) + { _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_INVALID, NULL, 0, field_code); - else if (_GD_FindField(D, munged_code, D->entry, D->n_entries, 1, &u)) + } else if (_GD_FindField(D, munged_code, D->entry, D->n_entries, 1, &u)) _GD_SetError(D, GD_E_DUPLICATE, 0, NULL, 0, munged_code); else - _GD_CheckCodeAffixes(D, NULL, target, fragment_index, 1); /* check target */ + _GD_CheckCodeAffixes(D, target, fragment_index, 1); /* check target */ if (D->error) goto add_alias_error; Modified: trunk/getdata/src/common.c =================================================================== --- trunk/getdata/src/common.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/common.c 2015-01-12 10:09:51 UTC (rev 940) @@ -218,7 +218,7 @@ dtrace("%p, %p, %p", D, E, e); e->u.linterp.table_dirfd = _GD_GrabDir(D, - D->fragment[E->fragment_index].dirfd, E->EN(linterp,table)); + D->fragment[E->fragment_index].dirfd, E->EN(linterp,table), 0); temp_buffer = _GD_Strdup(D, E->EN(linterp,table)); if (temp_buffer == NULL) { @@ -840,8 +840,8 @@ break; default: if (err) - _GD_SetError(D, GD_E_BAD_REPR, GD_E_REPR_UNKNOWN, NULL, 0, - field_code_in + field_code_len - 1); + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_REPR, NULL, 0, + field_code_in); dreturn("%i", 0); return 0; } @@ -896,6 +896,28 @@ return 0; } +/* Find an entry without a representation */ +gd_entry_t *_GD_FindEntry(DIRFILE *restrict D, const char *restrict field_code, + unsigned int *restrict index, int set, int err) +{ + gd_entry_t *E = NULL; + + dtrace("%p, \"%s\", %p, %i, %i", D, field_code, index, set, err); + + if (D->n_dot > 0) + E = _GD_FindField(D, field_code, D->dot_list, D->n_dot, 1, NULL); + + if (E == NULL || index != NULL) + E = _GD_FindField(D, field_code, D->entry, D->n_entries, 1, index); + + if (E == NULL && set) + if (err) + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code); + + dreturn("%p", E); + return E; +} + /* Find the entry and the representation */ gd_entry_t *_GD_FindFieldAndRepr(DIRFILE *restrict D, const char *restrict field_code_in, char **restrict field_code, @@ -1306,15 +1328,18 @@ return filepath; } -int _GD_GrabDir(DIRFILE *D, int dirfd, const char *name) +int _GD_GrabDir(DIRFILE *D, int dirfd, const char *name, int canonical) { unsigned int i; char *path, *dir = NULL; void *ptr; - dtrace("%p, %i, \"%s\"", D, dirfd, name); + dtrace("%p, %i, \"%s\", %i", D, dirfd, name, canonical); - path = _GD_MakeFullPath(D, dirfd, name, 1); + if (canonical) + path = _GD_Strdup(D, name); + else + path = _GD_MakeFullPath(D, dirfd, name, 1); if (path == NULL) { dreturn("%i", -1); Modified: trunk/getdata/src/constant.c =================================================================== --- trunk/getdata/src/constant.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/constant.c 2015-01-12 10:09:51 UTC (rev 940) @@ -170,14 +170,13 @@ return gd_array_len(D, field_code); } -static int _GD_PutCarraySlice(DIRFILE* D, gd_entry_t *E, int repr, - unsigned long first, size_t n, gd_type_t data_type, const void *data_in) - gd_nothrow +static int _GD_PutCarraySlice(DIRFILE* D, gd_entry_t *E, unsigned long first, + size_t n, gd_type_t data_type, const void *data_in) gd_nothrow { int i; - dtrace("%p, %p, %i, %lu, %" PRNsize_t ", 0x%X, %p", D, E, repr, first, n, - data_type, data_in); + dtrace("%p, %p, %lu, %" PRNsize_t ", 0x%X, %p", D, E, first, n, data_type, + data_in); if ((D->flags & GD_ACCMODE) != GD_RDWR) { _GD_SetError(D, GD_E_ACCMODE, 0, NULL, 0, NULL); @@ -190,7 +189,7 @@ { _GD_SetError(D, GD_E_BOUNDS, 0, NULL, 0, NULL); } else - _GD_DoFieldOut(D, E, repr, first, n, data_type, data_in); + _GD_DoFieldOut(D, E, first, n, data_type, data_in); if (D->error) { dreturn("%i", -1); @@ -210,15 +209,13 @@ return 0; } -int gd_put_carray_slice(DIRFILE* D, const char *field_code_in, - unsigned long first, size_t n, gd_type_t data_type, const void *data_in) -gd_nothrow +int gd_put_carray_slice(DIRFILE* D, const char *field_code, unsigned long first, + size_t n, gd_type_t data_type, const void *data_in) gd_nothrow { gd_entry_t *entry; - int repr, r = -1; - char* field_code; + int r = -1; - dtrace("%p, \"%s\", %lu, %" PRNsize_t ", 0x%X, %p", D, field_code_in, first, + dtrace("%p, \"%s\", %lu, %" PRNsize_t ", 0x%X, %p", D, field_code, first, n, data_type, data_in); if (D->flags & GD_INVALID) { @@ -229,10 +226,10 @@ _GD_ClearError(D); - entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, - 1); + entry = _GD_FindField(D, field_code, D->entry, D->n_entries, 1, NULL); - if (D->error) { + if (entry == NULL) { + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code); dreturn("%i", -1); return -1; } @@ -242,23 +239,19 @@ { _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); } else - r = _GD_PutCarraySlice(D, entry, repr, first, n, data_type, data_in); + r = _GD_PutCarraySlice(D, entry, first, n, data_type, data_in); - if (field_code != field_code_in) - free(field_code); - dreturn("%i", r); return r; } -int gd_put_carray(DIRFILE* D, const char *field_code_in, gd_type_t data_type, +int gd_put_carray(DIRFILE* D, const char *field_code, gd_type_t data_type, const void *data_in) gd_nothrow { gd_entry_t *entry; - int repr, r = -1; - char* field_code; + int r = -1; - dtrace("%p, \"%s\", 0x%x, %p", D, field_code_in, data_type, data_in); + dtrace("%p, \"%s\", 0x%x, %p", D, field_code, data_type, data_in); if (D->flags & GD_INVALID) { _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -268,10 +261,10 @@ _GD_ClearError(D); - entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, - 1); + entry = _GD_FindField(D, field_code, D->entry, D->n_entries, 1, NULL); - if (D->error) { + if (entry == NULL) { + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code); dreturn("%i", -1); return -1; } @@ -281,21 +274,18 @@ { _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); } else - r = _GD_PutCarraySlice(D, entry, repr, 0, + r = _GD_PutCarraySlice(D, entry, 0, (entry->field_type == GD_CONST_ENTRY) ? 1 : entry->EN(scalar,array_len), data_type, data_in); - if (field_code != field_code_in) - free(field_code); - dreturn("%i", r); return r; } -int gd_put_constant(DIRFILE* D, const char *field_code_in, gd_type_t data_type, +int gd_put_constant(DIRFILE* D, const char *field_code, gd_type_t data_type, const void *data_in) gd_nothrow { - return gd_put_carray_slice(D, field_code_in, 0, 1, data_type, data_in); + return gd_put_carray_slice(D, field_code, 0, 1, data_type, data_in); } /* vim: ts=2 sw=2 et tw=80 Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/entry.c 2015-01-12 10:09:51 UTC (rev 940) @@ -342,13 +342,12 @@ return !e; } -char* gd_raw_filename(DIRFILE* D, const char* field_code_in) gd_nothrow +char* gd_raw_filename(DIRFILE* D, const char* field_code) gd_nothrow { - int repr; - char *field_code, *filename; + char *filename; gd_entry_t *E; - dtrace("%p, \"%s\"", D, field_code_in); + dtrace("%p, \"%s\"", D, field_code); _GD_ClearError(D); @@ -359,7 +358,7 @@ } /* Check field */ - E = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, 1); + E = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { dreturn("%p", NULL); @@ -372,9 +371,6 @@ return NULL; } - if (field_code != field_code_in) - free(field_code); - if (E->e->u.raw.file[0].name == NULL) { /* ensure encoding sybtype is known */ if (!_GD_Supports(D, E, GD_EF_NAME)) { @@ -402,14 +398,12 @@ return filename; } -int gd_entry(DIRFILE* D, const char* field_code_in, gd_entry_t* entry) - gd_nothrow +int gd_entry(DIRFILE* D, const char* field_code, gd_entry_t* entry) gd_nothrow { - int i, repr; + int i; gd_entry_t *E; - char* field_code; - dtrace("%p, \"%s\", %p", D, field_code_in, entry); + dtrace("%p, \"%s\", %p", D, field_code, entry); if (D->flags & GD_INVALID) { _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -419,17 +413,14 @@ _GD_ClearError(D); - /* get rid of the represenation, if any */ - E = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, 1); + E = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_MISSING, NULL, 0, field_code); dreturn("%i", -1); return -1; } - if (field_code != field_code_in) - free(field_code); - /* Calculate the entry, if necessary */ if (!(E->flags & GD_EN_CALC)) _GD_CalculateEntry(D, E, 0); @@ -630,13 +621,11 @@ return n; } -gd_entype_t gd_entry_type(DIRFILE* D, const char* field_code_in) gd_nothrow +gd_entype_t gd_entry_type(DIRFILE* D, const char* field_code) gd_nothrow { gd_entry_t* E; - char* field_code; - int repr; - dtrace("%p, \"%s\"", D, field_code_in); + dtrace("%p, \"%s\"", D, field_code); if (D->flags & GD_INVALID) { _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -646,17 +635,13 @@ _GD_ClearError(D); - /* get rid of the represenation, if any */ - E = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, 1); + E = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { dreturn("%i", GD_NO_ENTRY); return GD_NO_ENTRY; } - if (field_code != field_code_in) - free(field_code); - dreturn("%i", E->field_type); return E->field_type; } @@ -813,7 +798,6 @@ _GD_ClearError(D); - /* get rid of the representation, if any */ E = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, 1); if (D->error) { @@ -876,13 +860,12 @@ return 0; } -char *gd_linterp_tablename(DIRFILE *D, const char *field_code_in) gd_nothrow +char *gd_linterp_tablename(DIRFILE *D, const char *field_code) gd_nothrow { - int repr; gd_entry_t *E; - char *field_code, *table; + char *table; - dtrace("%p, \"%s\"", D, field_code_in); + dtrace("%p, \"%s\"", D, field_code); if (D->flags & GD_INVALID) { _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -892,19 +875,15 @@ _GD_ClearError(D); - E = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, 1); + E = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { dreturn("%p", NULL); return NULL; } - if (field_code != field_code_in) - free(field_code); - if (E->field_type != GD_LINTERP_ENTRY) { - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, - field_code_in); + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); dreturn("%p", NULL); return NULL; } Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/errors.c 2015-01-12 10:09:51 UTC (rev 940) @@ -49,8 +49,7 @@ "Field name is reserved on line {3} of {2}", 0 }, { GD_E_FORMAT, GD_E_FORMAT_ENDIAN, "Unrecognised endianness on line {3} of {2}", 0 }, - { GD_E_FORMAT, GD_E_FORMAT_BAD_NAME, - "Bad field name on line {3} of {2}: {4}", 0 }, + { GD_E_FORMAT, GD_E_FORMAT_BAD_NAME, "Bad name on line {3} of {2}: {4}", 0 }, { GD_E_FORMAT, GD_E_FORMAT_UNTERM, "Unterminated token on line {3} of {2}", 0 }, { GD_E_FORMAT, GD_E_FORMAT_METARAW, @@ -79,8 +78,10 @@ { GD_E_CREAT, GD_E_CREAT_FORMAT, "Unable to create format file {2}: ", 1 }, /* 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_INVALID, "Bad field code: {4}", 0 }, { GD_E_BAD_CODE, GD_E_CODE_AMBIGUOUS, "Ambiguous field code: {4}", 0 }, + { GD_E_BAD_CODE, GD_E_CODE_INVALID_NS, "Bad namespace: {4}", 0 }, + { GD_E_BAD_CODE, GD_E_CODE_REPR, "Invalid representation suffix in: {4}", 0 }, /* GD_E_BAD_TYPE: 1 = data type */ { GD_E_BAD_TYPE, 0, "Bad data type: {1}", 0 }, /* GD_E_IO: 2 = filename; 3 = line; 4 = included file */ @@ -196,10 +197,6 @@ { GD_E_DOMAIN, GD_E_DOMAIN_EMPTY, "Improper domain: empty set", 0 }, { GD_E_DOMAIN, GD_E_DOMAIN_ANTITONIC, "Improper domain: not monotonic", 0 }, { GD_E_DOMAIN, GD_E_DOMAIN_MULTIPOS, "I/O position mismatch in inputs", 0 }, - /* GD_E_UNCLEAN_DB: 4 = repr */ - { GD_E_BAD_REPR, GD_E_REPR_UNKNOWN, "Unknown field representation: .{4}", 0 }, - { GD_E_BAD_REPR, GD_E_REPR_PUT, "Unable to write to field reprentation: .{4}", - 0 }, /* GD_E_BOUNDS: (nothing) */ { GD_E_BOUNDS, 0, "Array length out of bounds", 0 }, /* GD_E_LINE_TOO_LONG */ Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/flimits.c 2015-01-12 10:09:51 UTC (rev 940) @@ -355,14 +355,13 @@ return ns; } -off64_t gd_eof64(DIRFILE* D, const char *field_code_in) +off64_t gd_eof64(DIRFILE* D, const char *field_code) { off64_t ns; gd_entry_t *entry; - int repr, is_index; - char* field_code; + int is_index; - dtrace("%p, \"%s\"", D, field_code_in); + dtrace("%p, \"%s\"", D, field_code); _GD_ClearError(D); @@ -372,8 +371,7 @@ return -1; } - entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, - 1); + entry = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { dreturn("%i", -1); @@ -385,9 +383,6 @@ if (is_index) _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); - dreturn("%lli", (unsigned long long)ns); return ns; } @@ -549,16 +544,14 @@ return bof; } -off64_t gd_bof64(DIRFILE* D, const char *field_code_in) gd_nothrow +off64_t gd_bof64(DIRFILE* D, const char *field_code) gd_nothrow { off64_t bof; gd_entry_t *entry; - int repr; - char *field_code; unsigned int spf; long long ds; - dtrace("%p, \"%s\"", D, field_code_in); + dtrace("%p, \"%s\"", D, field_code); _GD_ClearError(D); @@ -568,8 +561,7 @@ return -1; } - entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, - 1); + entry = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { dreturn("%i", -1); @@ -581,9 +573,6 @@ if (bof != -1) bof = bof * spf + ds; - if (field_code != field_code_in) - free(field_code); - dreturn("%lli", (unsigned long long)bof); return bof; } Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/flush.c 2015-01-12 10:09:51 UTC (rev 940) @@ -295,7 +295,6 @@ static ssize_t _GD_WriteFieldCode(DIRFILE *D, FILE *stream, int me, const char *code, int index, int permissive, int standards, unsigned flags) { - int dummy; ssize_t len; char *ptr; @@ -305,8 +304,8 @@ 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); + ptr = _GD_MungeCode(D, NULL, 0, D->fragment[me].prefix, + D->fragment[me].suffix, NULL, NULL, code, NULL, NULL, GD_MC_RQ_PARTS); len = _GD_StringEscapeise(stream, ptr, 0, permissive, standards); @@ -817,7 +816,7 @@ char temp_file[] = "format_XXXXXX"; char* ptr; struct tm now; - int fd, dummy; + int fd; int pretty = 0; ssize_t max_len = 0; unsigned int u; @@ -1017,10 +1016,10 @@ if (permissive || D->standards >= 3) for (j = 0; j < D->n_fragment; ++j) if (D->fragment[j].parent == i) { - char *prefix = _GD_MungeCode(D, NULL, D->fragment[i].prefix, NULL, NULL, - NULL, D->fragment[j].prefix, &dummy, 0); - char *suffix = _GD_MungeCode(D, NULL, NULL, D->fragment[i].suffix, NULL, - NULL, D->fragment[j].suffix, &dummy, 0); + char *prefix = _GD_MungeCode(D, NULL, 0, D->fragment[i].prefix, NULL, + NULL, NULL, D->fragment[j].prefix, NULL, NULL, GD_MC_RQ_PARTS); + char *suffix = _GD_MungeCode(D, NULL, 0, NULL, D->fragment[i].suffix, + NULL, NULL, D->fragment[j].suffix, NULL, NULL, GD_MC_RQ_PARTS); if (fprintf(stream, "%sINCLUDE ", (D->standards >= 5) ? "/" : "") < 0 || _GD_StringEscapeise(stream, D->fragment[j].ename, 0, permissive, @@ -1185,8 +1184,6 @@ static int _GD_SyncOrClose(DIRFILE* D, const char* field_code, int syn, int clo) { unsigned int i; - int repr; - char *simple_field_code; gd_entry_t *E; dtrace("%p, \"%s\", %i, %i", D, field_code, syn, clo); @@ -1202,15 +1199,10 @@ if (D->entry[i]->field_type == GD_RAW_ENTRY) _GD_Flush(D, D->entry[i], syn, clo); } else { - /* discard representation */ - E = _GD_FindFieldAndRepr(D, field_code, &simple_field_code, &repr, NULL, 1, - 1); + E = _GD_FindEntry(D, field_code, NULL, 1, 1); if (!D->error) _GD_Flush(D, E, syn, clo); - - if (field_code != simple_field_code) - free(simple_field_code); } dreturn("%i", (D->error == GD_E_OK) ? 0 : -1); @@ -1411,7 +1403,10 @@ D->av &= GD_VERS_GE_6; break; case '.': - D->av &= GD_VERS_LE_5; + if (D->entry[i]->flags & GD_EN_DOTTED) + D->av &= GD_VERS_LE_5; + else + D->av &= GD_VERS_GE_10; break; case '&': case ';': Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/fpos.c 2015-01-12 10:09:51 UTC (rev 940) @@ -123,14 +123,12 @@ /* Get the current I/O position of the given field */ -off64_t gd_tell64(DIRFILE *D, const char *field_code_in) gd_nothrow +off64_t gd_tell64(DIRFILE *D, const char *field_code) gd_nothrow { off64_t pos = -1; gd_entry_t* entry; - char* field_code; - int repr; - dtrace("%p, \"%s\"", D, field_code_in); + dtrace("%p, \"%s\"", D, field_code); if (D->flags & GD_INVALID) {/* don't crash */ _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -140,8 +138,7 @@ _GD_ClearError(D); - entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, - 1); + entry = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { dreturn("%u", 0); @@ -153,9 +150,6 @@ else pos = _GD_GetFilePos(D, entry, -1); - if (field_code != field_code_in) - free(field_code); - dreturn("%lli", (long long)pos); return pos; } @@ -335,17 +329,16 @@ /* 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 gd_seek64(DIRFILE *D, const char *field_code, off64_t frame_num, off64_t sample_num, int whence) { unsigned int spf = 0; off64_t pos = 0; gd_entry_t* entry; - char* field_code; - int repr, is_index = 0; + int is_index = 0; unsigned int mode = (whence & GD_SEEK_WRITE) ? GD_FILE_WRITE : GD_FILE_READ; - dtrace("%p, \"%s\", %lli, %lli, 0x%X", D, field_code_in, (long long)frame_num, + dtrace("%p, \"%s\", %lli, %lli, 0x%X", D, field_code, (long long)frame_num, (long long)sample_num, whence); if (D->flags & GD_INVALID) {/* don't crash */ @@ -356,8 +349,7 @@ _GD_ClearError(D); - entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1, - 1); + entry = _GD_FindEntry(D, field_code, NULL, 1, 1); if (D->error) { dreturn("%i", -1); @@ -366,8 +358,6 @@ if (entry->field_type & GD_SCALAR_ENTRY_BIT) { _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, field_code); - if (field_code != field_code_in) - free(field_code); dreturn("%i", -1); return -1; } @@ -376,8 +366,6 @@ spf = _GD_GetSPF(D, entry); if (D->error) { - if (field_code != field_code_in) - free(field_code); dreturn("%i", -1); return -1; } @@ -400,9 +388,6 @@ if (!D->error) _GD_Seek(D, entry, sample_num + pos, mode); - if (field_code != field_code_in) - free(field_code); - if (D->error) pos = -1; else Modified: trunk/getdata/src/fragment.c =================================================================== --- trunk/getdata/src/fragment.c 2015-01-12 07:35:20 UTC (rev 939) +++ trunk/getdata/src/fragment.c 2015-01-12 10:09:51 UTC (rev 940) @@ -83,7 +83,7 @@ static char **_GD_CheckAffixes(DIRFILE *D, int i, const char *prefix, const char *suffix, char **codes, unsigned *n) { - int j, dummy; + int j; unsigned u, nn = *n; char **new_codes = codes, **ptr; @@ -109,10 +109,12 @@ /* Propagate changes downward */ for (j = 0; j < D->n_fragment; ++j) if (D->fragment[j].parent == i) { - char *subprefix = _GD_MungeCode(D, NULL, D->fragment[i].prefix, NULL, - prefix, NULL, D->fragment[j].prefix, &dummy, 1); - char *subsuffix = _GD_MungeCode(D, NULL, NULL, D->fragment[i].suffix, - NULL, suffix, D->fragment[j].suffix, &dummy, 1); + char *subprefix = _GD_MungeCode(D, NULL, 0, D->fragment[i].prefix, + NULL, prefix, NULL, D->fragment[j].prefix, NULL, NULL, + GD_MC_RQ_PARTS | GD_MC_ERROR_OK); + char *subsuffix = _GD_MungeCode(D, NULL, 0, NULL, + D->fragment[i].suffix, NULL, suffix, D->fragment[j].suffix, NULL, + NULL, GD_MC_RQ_PARTS | GD_MC_ERROR_OK); if (D->error) { free(subprefix); dreturn("%p (%i)", new_codes, *n); @@ -135,20 +137,19 @@ if (D->entry[u]->fragment_index == i && D->entry[u]->e->n_meta != -1) { ptr = _GD_Realloc(D, new_codes, sizeof(*ptr) * ++nn); if (ptr) { + char *nso; new_codes = ptr; /* remunge the code */ - new_codes[nn - 1] = _GD_MungeCode(D, NULL, D->fragment[i].prefix, - D->fragment[i].suffix, prefix, suffix, D->entry[u]->field, &dummy, - 0); + new_codes[nn - 1] = _GD_MungeCode(D, NULL, 0, D->fragment[i].prefix, + D->fragment[i].suffix, prefix, suffix, D->entry[u]->field, &nso, + NULL, GD_MC_RQ_PARTS); /* look for a duplicate and validate */ if (new_codes[nn - 1] && _GD_FindField(D, new_codes[nn - 1], D->entry, D->n_entries, 1, NULL)) { _GD_SetError(D, GD_E_DUPLICATE, 0, NULL, 0, new_codes[nn - 1]); - } else if (_GD_ValidateField(new_codes[nn - 1], D->standards, 1, 0, - NULL)) - { + } else if (_GD_ValidateField(nso, D->standards, 1, GD_VF_NAME, NULL)) { _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_INVALID, NULL, 0, new_codes[nn - 1]); } @@ -409,3 +410,266 @@ dreturn("%i", changed); return changed; } + +/* create a list of indices to subfragments, including this one */ +static int _GD_SubFragmentList(DIRFILE *restrict D, int i, int **restrict ilist) +{ + int *list; + int j, n = 1; + + dtrace("%p, %i, %p", D, i, ilist); + + /* i is always in the list */ + list = _GD_Malloc(D, sizeof(*list)); + if (list == NULL) { + dreturn("%i", 0); + return 0; + } + list[0] = i; + + /* search for children */ + for (j = 0; j < D->n_fragment; ++j) + if (D->fragment[j].parent == i) { + int nsub, *sublist, *ptr; + + nsub = _GD_SubFragmentList(D, j, &sublist); + if (nsub == 0) { + free(list); + dreturn("%i", 0); + return 0; + } + + /* append to current list */ + ptr = _GD_Realloc(D, list, (nsub + n) * sizeof(*list)); + if (ptr == NULL) { + free(list); + dreturn("%i", 0); + return 0; + } + list = ptr; + memcpy(list + n, sublist, nsub * sizeof(*list)); + free(sublist); + + n += nsub; + } + + /* done */ + *ilist = list; + dreturn("%i", n); + return n; +} + +/* Check a fragment namespace change. Returns non-zero if the checks fail. */ +static int _GD_CheckChangeNamespace(DIRFILE *D, const char *newns, + size_t newnsl, size_t oldnsl, int i, char ***codes) +{ + int j, ni; + unsigned u; + int *ilist; + char **c = *codes; + const ssize_t dnsl = newnsl - oldnsl; + + dtrace("%p, \"%s\", %" PRNsize_t ", %" PRNsize_t ", %i, %p", D, newns, newnsl, + oldnsl, i, codes); + + if (newns == NULL) + newns = ""; + + /* find all affected fragments */ + ni = _GD_SubFragmentList(D, i, &ilist); + if (ni == 0) { /* malloc error */ + free(*codes); + dreturn("%i", 1); + return 1; + } + + /* find all affected entries and generate new field codes */ + for (u = 0; u < D->n_entries; ++u) { + /* check fragment list */ + int found = 0; + size_t l; + + for (j = 0; j < ni; ++j) + if (D->entry[u]->fragment_index == ilist[j]) { + found = 1; + break; + } + + if (!found) { + c[u] = NULL; + continue; + } + + /* compose the new name */ + l = strlen(D->entry[u]->field); + c[u] = _GD_Malloc(D, l + dnsl + 1); + if (c[u] == NULL) + goto CHECKS_FAILED; + + /* so much easier than dealing with affixes... */ + strncpy(c[u], newns, newnsl); + strcpy(c[u] + newnsl, D->entry[i]->field + oldnsl); + + /* Check whether it already exists */ + if (_GD_FindField(D, c[u], D->entry, D->n_entries, 1, NULL)) { + _GD_SetError(D, GD_E_DUPLICATE, 0, NULL, 0, c[u]); + goto CHECKS_FAILED; + } + } + + free(ilist); + dreturn("%i", 0); + return 0; + +CHECKS_FAILED: + do { + free(c[u]); + } while (u--); + free(c); + free(ilist); + dreturn("%i", 1); + return 1; +} + +const char *gd_fragment_namespace(DIRFILE *D, int index, const char *ns) +{ + dtrace("%p, %i, \"%s\"", D, index, ns); + + _GD_ClearError(D); + + if (D->flags & GD_INVALID) { + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%i", 0); + return 0; + } + + if (index < 0 || index >= D->n_fragment) { + _GD_SetError(D, GD_E_BAD_INDEX, 0, NULL, 0, NULL); + dreturn("%p", NULL); + return NULL; + } + + if (ns) { + unsigned u; + char **codes, *newns; + size_t newnsl; + + const char *oldns = D->fragment[index].ns; + size_t oldnsl = D->fragment[index].nsl; + + const char *pns = index > 0 ? D->fragment[D->fragment[index].parent].ns + : NULL; + size_t pnsl = index > 0 ? D->fragment[D->fragment[index].parent].nsl : 0; + + if (index == 0) { + _GD_SetError(D, GD_E_BAD_INDEX, 0, NULL, 0, NULL); + dreturn("%p", NULL); + return NULL; + } + + if ((D->flags & GD_ACCMODE) == GD_RDONLY) { + _GD_SetError(D, GD_E_ACCMODE, 0, NULL, 0, NULL); + dreturn("%p", NULL); + return NULL; + } + + if (D->fragment[D->fragment[index].parent].protection & GD_PROTECT_FORMAT) { + _GD_SetError(D, GD_E_PROTECTED, GD_E_PROTECTED_FORMAT, NULL, 0, + D->fragment[D->fragment[index].parent].cname); + dreturn("%p", NULL); + return NULL; + } + + if (_GD_ValidateField(ns, D->standards, 1, GD_VF_NS, NULL)) { + /* invalid namespace */ + _GD_SetError(D, GD_E_BAD_CODE, GD_E_CODE_INVALID, NULL, 0, ns); + dreturn("%p", NULL); + return NULL; + } + + /* remove spurious leading dot */ + if (ns[0] == '.') + ns++; + + newnsl = strlen(ns); + + if (ns[0] == '\0') { + /* Duplicate parent space */ + newnsl = pnsl; + if (pns == NULL) { + newns = NULL; + newnsl = 0; + } else { + newns = _GD_Strdup(D, pns); + if (newns == NULL) { + dreturn("%p", NULL); + return NULL; + } + } + } else if (pns) { + /* append */ + newnsl += pnsl + 1; + newns = _GD_Malloc(D, newnsl + 1); + + if (newns == NULL) { + dreturn("%p", NULL); + return NULL; + } + strcpy(new... [truncated message content] |