summaryrefslogtreecommitdiffstats
path: root/src/H5Tbit.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-08-21 21:15:00 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-08-21 21:15:00 (GMT)
commit7a2756e7ae8164ac6601957f3a9617a00456f918 (patch)
tree07de6d5fe4151080e2da9375156ee5a62c2c627b /src/H5Tbit.c
parent428715468b9ddbe7077a191939fde535588afe3a (diff)
downloadhdf5-7a2756e7ae8164ac6601957f3a9617a00456f918.zip
hdf5-7a2756e7ae8164ac6601957f3a9617a00456f918.tar.gz
hdf5-7a2756e7ae8164ac6601957f3a9617a00456f918.tar.bz2
[svn-r15513] Description:
Bring back r15510 & r15512 from trunk: Fix compiler warnings and formatting. Tested on: Mac OS X/32 10.5.4 (amazon) More tests upcoming
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() */
/*-------------------------------------------------------------------------