summaryrefslogtreecommitdiffstats
path: root/src/H5Tbit.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-08-21 20:30:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-08-21 20:30:19 (GMT)
commitf8a796ebfc24c8f5f2c2c4f592234deb2b225c09 (patch)
treeb68f1de29b43ba1d654d9b8c7c05e23db9a1b15d /src/H5Tbit.c
parent5f7de916882208cd9f3b3490c59e0f3ab92cdc40 (diff)
downloadhdf5-f8a796ebfc24c8f5f2c2c4f592234deb2b225c09.zip
hdf5-f8a796ebfc24c8f5f2c2c4f592234deb2b225c09.tar.gz
hdf5-f8a796ebfc24c8f5f2c2c4f592234deb2b225c09.tar.bz2
[svn-r15510] Description:
Clean up warnings & formatting Tested on: Mac OS X/32 10.5.4 (amazon) More tests forthcoming
Diffstat (limited to 'src/H5Tbit.c')
-rw-r--r--src/H5Tbit.c145
1 files changed, 74 insertions, 71 deletions
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
index 948a6eb..a5340a6 100644
--- a/src/H5Tbit.c
+++ b/src/H5Tbit.c
@@ -395,10 +395,10 @@ H5T_bit_set (uint8_t *buf, size_t offset, size_t size, hbool_t value)
*-------------------------------------------------------------------------
*/
ssize_t
-H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
+H5T_bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
hbool_t value)
{
- ssize_t base=(ssize_t)offset;
+ ssize_t base = (ssize_t)offset;
ssize_t idx, i;
size_t iu;
ssize_t ret_value=(-1); /* Return value */
@@ -407,78 +407,81 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_find);
/* Some functions call this with value=TRUE */
- assert (TRUE==1);
-
- switch (direction) {
- case H5T_BIT_LSB:
- /* Calculate index */
- idx = (ssize_t)(offset / 8);
- offset %= 8;
-
- /* Beginning */
- if (offset) {
- for (iu=offset; iu<8 && size>0; iu++, size--) {
- if (value==(hbool_t)((buf[idx]>>iu) & 0x01))
- HGOTO_DONE(8*idx+(ssize_t)iu - base);
- }
- offset = 0;
- idx++;
- }
- /* Middle */
- while (size>=8) {
- if ((value?0x00:0xff)!=buf[idx]) {
- for (i=0; i<8; i++) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01))
- HGOTO_DONE(8*idx+i - base);
- }
- }
- size -= 8;
- idx++;
- }
- /* End */
- for (i=0; i<(ssize_t)size; i++) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01))
- HGOTO_DONE(8*idx+i - base);
- }
- break;
-
- case H5T_BIT_MSB:
- /* Calculate index */
- idx = (ssize_t)((offset+size-1) / 8);
- offset %= 8;
-
- /* Beginning */
- if (size>8-offset && (offset+size)%8) {
- for (iu=(offset+size)%8; iu>0; --iu, --size) {
- if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
- HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
- }
- --idx;
- }
- /* Middle */
- while (size>=8) {
- if ((value?0x00:0xff)!=buf[idx]) {
- for (i=7; i>=0; --i) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01))
- HGOTO_DONE(8*idx+i - base);
- }
- }
- size -= 8;
- --idx;
- }
- /* End */
- if (size>0) {
- for (iu=offset+size; iu>offset; --iu) {
- if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
- HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
- }
- }
- break;
- }
+ HDassert(TRUE == 1);
+
+ switch(direction) {
+ case H5T_BIT_LSB:
+ /* Calculate index */
+ idx = (ssize_t)(offset / 8);
+ offset %= 8;
+
+ /* Beginning */
+ if (offset) {
+ for (iu=offset; iu<8 && size>0; iu++, size--) {
+ if (value==(hbool_t)((buf[idx]>>iu) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)iu - base);
+ }
+ offset = 0;
+ idx++;
+ }
+ /* Middle */
+ while (size>=8) {
+ if ((value?0x00:0xff)!=buf[idx]) {
+ for (i=0; i<8; i++) {
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
+ }
+ }
+ size -= 8;
+ idx++;
+ }
+ /* End */
+ for (i=0; i<(ssize_t)size; i++) {
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
+ }
+ break;
+
+ case H5T_BIT_MSB:
+ /* Calculate index */
+ idx = (ssize_t)((offset+size-1) / 8);
+ offset %= 8;
+
+ /* Beginning */
+ if (size>8-offset && (offset+size)%8) {
+ for (iu=(offset+size)%8; iu>0; --iu, --size) {
+ if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
+ }
+ --idx;
+ }
+ /* Middle */
+ while (size>=8) {
+ if ((value?0x00:0xff)!=buf[idx]) {
+ for (i=7; i>=0; --i) {
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
+ }
+ }
+ size -= 8;
+ --idx;
+ }
+ /* End */
+ if (size>0) {
+ for (iu=offset+size; iu>offset; --iu) {
+ if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
+ }
+ }
+ break;
+
+ default:
+ HDassert(0 && "Unknown bit search direction");
+ } /* end switch */
done:
FUNC_LEAVE_NOAPI(ret_value);
-}
+} /* end H5T_bit_find() */
/*-------------------------------------------------------------------------