diff options
author | Alain Frisch <alain@frisch.fr> | 2012-12-19 16:22:30 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2012-12-19 16:22:30 +0000 |
commit | ff4e0a81f893a2d387d72005c5bbf28c2fc34897 (patch) | |
tree | 8231e2938ca26949affe233ca87dd967ec81b692 /byterun | |
parent | a19a4642e5a81b51dda14dd759cc2ae74e0c51ee (diff) |
#5774: fix MSVC port.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13141 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun')
-rw-r--r-- | byterun/str.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/byterun/str.c b/byterun/str.c index 147d13c74..9a96147ee 100644 --- a/byterun/str.c +++ b/byterun/str.c @@ -65,11 +65,12 @@ CAMLprim value caml_string_set(value str, value index, value newval) CAMLprim value caml_string_get16(value str, value index) { + intnat res; + unsigned char b1, b2; intnat idx = Long_val(index); if (idx < 0 || idx >= caml_string_length(str) - 1) caml_array_bound_error(); - intnat res; - unsigned char b1 = Byte_u(str, idx); - unsigned char b2 = Byte_u(str, idx + 1); + b1 = Byte_u(str, idx); + b2 = Byte_u(str, idx + 1); #ifdef ARCH_BIG_ENDIAN res = b1 << 8 | b2; #else @@ -80,13 +81,14 @@ CAMLprim value caml_string_get16(value str, value index) CAMLprim value caml_string_get32(value str, value index) { + intnat res; + unsigned char b1, b2, b3, b4; intnat idx = Long_val(index); if (idx < 0 || idx >= caml_string_length(str) - 3) caml_array_bound_error(); - intnat res; - unsigned char b1 = Byte_u(str, idx); - unsigned char b2 = Byte_u(str, idx + 1); - unsigned char b3 = Byte_u(str, idx + 2); - unsigned char b4 = Byte_u(str, idx + 3); + b1 = Byte_u(str, idx); + b2 = Byte_u(str, idx + 1); + b3 = Byte_u(str, idx + 2); + b4 = Byte_u(str, idx + 3); #ifdef ARCH_BIG_ENDIAN res = b1 << 24 | b2 << 16 | b3 << 8 | b4; #else @@ -103,18 +105,19 @@ CAMLprim value caml_string_get32(value str, value index) CAMLprim value caml_string_get64(value str, value index) { - intnat idx = Long_val(index); - if (idx < 0 || idx >= caml_string_length(str) - 7) caml_array_bound_error(); uint32 reshi; uint32 reslo; - unsigned char b1 = Byte_u(str, idx); - unsigned char b2 = Byte_u(str, idx + 1); - unsigned char b3 = Byte_u(str, idx + 2); - unsigned char b4 = Byte_u(str, idx + 3); - unsigned char b5 = Byte_u(str, idx + 4); - unsigned char b6 = Byte_u(str, idx + 5); - unsigned char b7 = Byte_u(str, idx + 6); - unsigned char b8 = Byte_u(str, idx + 7); + unsigned char b1, b2, b3, b4, b5, b6, b7, b8; + intnat idx = Long_val(index); + if (idx < 0 || idx >= caml_string_length(str) - 7) caml_array_bound_error(); + b1 = Byte_u(str, idx); + b2 = Byte_u(str, idx + 1); + b3 = Byte_u(str, idx + 2); + b4 = Byte_u(str, idx + 3); + b5 = Byte_u(str, idx + 4); + b6 = Byte_u(str, idx + 5); + b7 = Byte_u(str, idx + 6); + b8 = Byte_u(str, idx + 7); #ifdef ARCH_BIG_ENDIAN reshi = b1 << 24 | b2 << 16 | b3 << 8 | b4; reslo = b5 << 24 | b6 << 16 | b7 << 8 | b8; @@ -127,10 +130,11 @@ CAMLprim value caml_string_get64(value str, value index) CAMLprim value caml_string_set16(value str, value index, value newval) { + unsigned char b1, b2; + intnat val; intnat idx = Long_val(index); if (idx < 0 || idx >= caml_string_length(str) - 1) caml_array_bound_error(); - unsigned char b1, b2; - intnat val = Long_val(newval); + val = Long_val(newval); #ifdef ARCH_BIG_ENDIAN b1 = 0xFF & val >> 8; b2 = 0xFF & val; @@ -145,10 +149,11 @@ CAMLprim value caml_string_set16(value str, value index, value newval) CAMLprim value caml_string_set32(value str, value index, value newval) { + unsigned char b1, b2, b3, b4; + intnat val; intnat idx = Long_val(index); if (idx < 0 || idx >= caml_string_length(str) - 3) caml_array_bound_error(); - unsigned char b1, b2, b3, b4; - intnat val = Int32_val(newval); + val = Int32_val(newval); #ifdef ARCH_BIG_ENDIAN b1 = 0xFF & val >> 24; b2 = 0xFF & val >> 16; @@ -169,11 +174,12 @@ CAMLprim value caml_string_set32(value str, value index, value newval) CAMLprim value caml_string_set64(value str, value index, value newval) { - intnat idx = Long_val(index); - if (idx < 0 || idx >= caml_string_length(str) - 7) caml_array_bound_error(); unsigned char b1, b2, b3, b4, b5, b6, b7, b8; - int64 val = Int64_val(newval); uint32 lo,hi; + int64 val; + intnat idx = Long_val(index); + if (idx < 0 || idx >= caml_string_length(str) - 7) caml_array_bound_error(); + val = Int64_val(newval); I64_split(val,hi,lo); #ifdef ARCH_BIG_ENDIAN b1 = 0xFF & hi >> 24; |