From 9ada2de83a7a4038e4b3d0e500360eb38ee6ecaa Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Fri, 29 Aug 1997 11:58:58 -0500 Subject: [svn-r50] ./src/H5G.c Commented out H5G_basename(). Fixed a bug in H5G_namei() and H5G_insert(). ./src/H5O.c Fixed a bug in H5O_modify() --- src/H5G.c | 14 +++++++++----- src/H5O.c | 11 ++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/H5G.c b/src/H5G.c index cccd34e..b1441c6 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -99,6 +99,7 @@ H5G_component (const char *name, size_t *size_p) * *------------------------------------------------------------------------- */ +#if 0 static const char * H5G_basename (const char *name, size_t *size_p) { @@ -122,6 +123,7 @@ H5G_basename (const char *name, size_t *size_p) if (size_p) *size_p = strcspn (s, "/"); return s; } +#endif /*------------------------------------------------------------------------- @@ -251,11 +253,11 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, aside = TRUE; } H5O_reset (H5O_NAME, &mesg); + } else { + /* component not found */ + if (dir_ent) *dir_ent = *dir; + HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, -2); } - - /* component not found */ - if (dir_ent) *dir_ent = *dir; - HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, -2); } /* next component */ @@ -637,7 +639,9 @@ H5G_insert (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, if (f->root_sym->header<=0) { H5O_name_t name_mesg; name_mesg.s = rest; - if (H5O_modify (f, ent->header, ent, NULL, H5O_NAME, 0, &name_mesg)<0) { + if (H5O_modify (f, ent->header, ent, NULL, H5O_NAME, 0, &name_mesg)<0 && + H5O_modify (f, ent->header, ent, NULL, H5O_NAME, H5O_NEW_MESG, + &name_mesg)<0) { /* cannot add/change name message */ HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); } diff --git a/src/H5O.c b/src/H5O.c index 0eb04bc..9e58f27 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -728,15 +728,15 @@ H5O_modify (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, } /* Count similar messages */ - for (idx=sequence=0; idxnmesgs; idx++) { + for (idx=0,sequence=-1; idxnmesgs; idx++) { if (type->id != oh->mesg[idx].type->id) continue; - if (sequence==overwrite) break; - sequence++; + if (++sequence==overwrite) break; } /* Was the right message found? */ - if (overwrite>=0 && sequence!=overwrite) { - HRETURN_ERROR (H5E_OHDR, H5E_NOTFOUND, FAIL); + if (overwrite>=0 && + (idx>=oh->nmesgs || sequence!=overwrite)) { + HRETURN_ERROR (H5E_OHDR, H5E_NOTFOUND, FAIL); /*message not found*/ } /* Allocate space for the new message */ @@ -745,6 +745,7 @@ H5O_modify (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, H5O_ALIGN (size, oh->alignment); idx = H5O_alloc (f, oh, type, size); if (idx<0) HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL); + sequence++; } /* Copy the native value into the object header */ -- cgit v0.12