summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2010-10-04 18:46:37 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2010-10-04 18:46:37 (GMT)
commit4b5ae88422348a6c99750dd2a8d0178f78743b25 (patch)
tree1d75352b49f0f69ba0817fe9d7acfb8d4317b1f0 /src
parent82c6eab1814e1e06ef9472f6f4bbc8522064e0bc (diff)
downloadhdf5-4b5ae88422348a6c99750dd2a8d0178f78743b25.zip
hdf5-4b5ae88422348a6c99750dd2a8d0178f78743b25.tar.gz
hdf5-4b5ae88422348a6c99750dd2a8d0178f78743b25.tar.bz2
[svn-r19507] Fix for bug 1707 - I changed the design from the previous fix as Quincey suggested. I added a
flag IS_DEDAULT in the H5E_auto_t structure. Both H5Eprint1/2 are the default now. If the user sets his/her own printing function. Then a call to H5Eget_auto1/2 will have to match H5Eset_auto1/2. Tested on jam, heiwa, and amani.
Diffstat (limited to 'src')
-rw-r--r--src/H5E.c27
-rw-r--r--src/H5Edeprec.c21
-rw-r--r--src/H5Epkg.h7
3 files changed, 46 insertions, 9 deletions
diff --git a/src/H5E.c b/src/H5E.c
index 704253f..4b581f6 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -178,10 +178,10 @@ H5E_set_default_auto(H5E_t *stk)
#ifdef H5_NO_DEPRECATED_SYMBOLS
stk->auto_op.vers = 2;
#else
- stk->auto_op.func1 = (H5E_auto1_t)H5Eprint1;
+ stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1;
#endif
- stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2;
- stk->auto_op.user_set = FALSE;
+ stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2;
+ stk->auto_op.is_default = TRUE;
stk->auto_data = NULL;
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -1560,6 +1560,11 @@ done:
* Programmer: Robb Matzke
* Saturday, February 28, 1998
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the printing function isn't the default H5Eprint1 or 2,
+ * and H5Eset_auto1 has been called to set the old style
+ * printing function, a call to H5Eget_auto2 should fail.
*-------------------------------------------------------------------------
*/
herr_t
@@ -1584,7 +1589,8 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data)
if(H5E_get_auto(estack, &op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
- if(op.user_set && op.vers == 1)
+ /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto1 */
+ if(!op.is_default && op.vers == 1)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto1 has been called")
if(func)
@@ -1615,6 +1621,9 @@ done:
* Programmer: Robb Matzke
* Friday, February 27, 1998
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on.
*-------------------------------------------------------------------------
*/
herr_t
@@ -1636,10 +1645,18 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data)
if(NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+ /* Get the automatic error reporting information */
+ if(H5E_get_auto(estack, &op, NULL) < 0)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
+
/* Set the automatic error reporting information */
op.vers = 2;
- op.user_set = TRUE;
+ if(func != op.func2_default)
+ op.is_default = FALSE;
+ else
+ op.is_default = TRUE;
op.func2 = func;
+
if(H5E_set_auto(estack, &op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info")
diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c
index 9f6d869..0a028d9 100644
--- a/src/H5Edeprec.c
+++ b/src/H5Edeprec.c
@@ -370,6 +370,11 @@ done:
* Programmer: Raymond Lu
* Sep 16, 2003
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the printing function isn't the default H5Eprint1 or 2,
+ * and H5Eset_auto2 has been called to set the new style
+ * printing function, a call to H5Eget_auto1 should fail.
*-------------------------------------------------------------------------
*/
herr_t
@@ -390,7 +395,8 @@ H5Eget_auto1(H5E_auto1_t *func, void **client_data)
if(H5E_get_auto(estack, &auto_op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
- if(auto_op.user_set && auto_op.vers == 2)
+ /* Fail if the printing function isn't the default(user-set) and set through H5Eset_auto2 */
+ if(!auto_op.is_default && auto_op.vers == 2)
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "wrong API function, H5Eset_auto2 has been called")
if(func)
@@ -422,6 +428,9 @@ done:
* Programmer: Raymond Lu
* Sep 16, 2003
*
+ * Modification:Raymond Lu
+ * 4 October 2010
+ * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on.
*-------------------------------------------------------------------------
*/
herr_t
@@ -438,10 +447,18 @@ H5Eset_auto1(H5E_auto1_t func, void *client_data)
if(NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
+ /* Get the automatic error reporting information */
+ if(H5E_get_auto(estack, &auto_op, NULL) < 0)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get automatic error info")
+
/* Set the automatic error reporting information */
auto_op.vers = 1;
- auto_op.user_set = TRUE;
+ if(func != auto_op.func1_default)
+ auto_op.is_default = FALSE;
+ else
+ auto_op.is_default = TRUE;
auto_op.func1 = func;
+
if(H5E_set_auto(estack, &auto_op, client_data) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't set automatic error info")
diff --git a/src/H5Epkg.h b/src/H5Epkg.h
index b9688d2..93e0d82 100644
--- a/src/H5Epkg.h
+++ b/src/H5Epkg.h
@@ -71,15 +71,18 @@
#ifndef H5_NO_DEPRECATED_SYMBOLS
typedef struct {
unsigned vers; /* Which version callback to use */
- hbool_t user_set; /* If the printing function has been set. */
+ hbool_t is_default; /* If the printing function is the library's own. */
H5E_auto1_t func1; /* Old-style callback, NO error stack param. */
H5E_auto2_t func2; /* New-style callback, with error stack param. */
+ H5E_auto1_t func1_default; /* The saved library's default function - old style. */
+ H5E_auto2_t func2_default; /* The saved library's default function - new style. */
} H5E_auto_op_t;
#else
typedef struct {
unsigned vers; /* Which version callback to use */
- hbool_t user_set; /* If the printing function has been set. */
+ hbool_t is_default; /* If the printing function is the library's own. */
H5E_auto_t func2; /* Only the new style callback function is available. */
+ H5E_auto2_t func2_default; /* The saved library's default function - new style. */
} H5E_auto_op_t;
#endif