aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Romanko <me@blankhex.com>2025-11-09 19:36:06 +0300
committerMikhail Romanko <me@blankhex.com>2025-11-09 19:36:06 +0300
commit176079e7e90ba42152f3b39c3fb5a32e6a2a7e21 (patch)
treef9ac710dac058aa9ba8cba566f4e52ff16c63820
parentaa402de368a65c4e325ed7c1c334212f2873daf9 (diff)
downloadbhlib-176079e7e90ba42152f3b39c3fb5a32e6a2a7e21.tar.gz
Rename & reorder readed bytes arg in string funcsHEADtrunk
-rw-r--r--doc/Manual/en/BH_String.pod84
-rw-r--r--doc/Manual/ru/BH_String.pod66
-rw-r--r--include/BH/Ini.h76
-rw-r--r--include/BH/String.h34
-rw-r--r--src/String/Float.c16
-rw-r--r--src/String/Inline/Int.h18
-rw-r--r--src/String/Int.c32
-rw-r--r--test/tests/TestInt.c68
8 files changed, 235 insertions, 159 deletions
diff --git a/doc/Manual/en/BH_String.pod b/doc/Manual/en/BH_String.pod
index a88d796..9e5e365 100644
--- a/doc/Manual/en/BH_String.pod
+++ b/doc/Manual/en/BH_String.pod
@@ -239,11 +239,11 @@ If successful, it returns 0 or an error code.
=head2 BH_StringToDouble
double BH_StringToDouble(const char *string,
- size_t *size);
+ size_t *actual);
Converts the string I<string> to a real number.
-The optional parameter I<size> returns the number of characters read from the
+The optional parameter I<actual> returns the number of characters read from the
string.
If successful, it returns the converted number or 0.
@@ -252,128 +252,128 @@ If successful, it returns the converted number or 0.
=head2 BH_StringToInt8s
int8_t BH_StringToInt8s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to an 8-bit signed integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
=head2 BH_StringToInt16s
int16_t BH_StringToInt16s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to a signed 16-bit integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
=head2 BH_StringToInt32s
int32_t BH_StringToInt32s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to a signed 32-bit integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
=head2 BH_StringToInt64s
int64_t BH_StringToInt64s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to a signed 64-bit integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
=head2 BH_StringToInt8u
uint8_t BH_StringToInt8u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to an unsigned 8-bit integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
=head2 BH_StringToInt16u
uint16_t BH_StringToInt16u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to an unsigned 16-bit integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
=head2 BH_StringToInt32u
uint32_t BH_StringToInt32u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to an unsigned 32-bit integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
=head2 BH_StringToInt64u
uint64_t BH_StringToInt64u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Converts the string I<string> to an unsigned 64-bit integer.
-The optional parameter I<size> returns the number of characters read from the
-string.
-
The optional parameter I<base> specifies the base of the number.
+The optional parameter I<actual> returns the number of characters read from the
+string.
+
If successful, it returns the converted number or 0.
diff --git a/doc/Manual/ru/BH_String.pod b/doc/Manual/ru/BH_String.pod
index 2c78942..931a937 100644
--- a/doc/Manual/ru/BH_String.pod
+++ b/doc/Manual/ru/BH_String.pod
@@ -243,7 +243,7 @@ I<string> (с ограничением по длинне I<size>).
Преобразовывает строку I<string> в вещественное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
В случае успеха, возвращает преобразованное число или 0.
@@ -251,120 +251,120 @@ I<string> (с ограничением по длинне I<size>).
=head2 BH_StringToInt8s
int8_t BH_StringToInt8s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое знаковое 8-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
=head2 BH_StringToInt16s
int16_t BH_StringToInt16s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое знаковое 16-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
=head2 BH_StringToInt32s
int32_t BH_StringToInt32s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое знаковое 32-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
=head2 BH_StringToInt64s
int64_t BH_StringToInt64s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое знаковое 64-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
=head2 BH_StringToInt8u
uint8_t BH_StringToInt8u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое беззнаковое 8-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
=head2 BH_StringToInt16u
uint16_t BH_StringToInt16u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое беззнаковое 16-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
=head2 BH_StringToInt32u
uint32_t BH_StringToInt32u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое беззнаковое 32-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
=head2 BH_StringToInt64u
uint64_t BH_StringToInt64u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
Преобразовывает строку I<string> в целое беззнаковое 64-битное число.
-Опциональный параметр I<size> возвращает число прочитанных символов из строки.
-
Опциональный параметр I<base> задает основание числа.
+Опциональный параметр I<actual> возвращает число прочитанных символов из строки.
+
В случае успеха, возвращает преобразованное число или 0.
diff --git a/include/BH/Ini.h b/include/BH/Ini.h
new file mode 100644
index 0000000..cd544ea
--- /dev/null
+++ b/include/BH/Ini.h
@@ -0,0 +1,76 @@
+#ifndef BH_INI_H
+#define BH_INI_H
+
+#include "IO.h"
+
+
+typedef struct BH_Ini BH_Ini;
+
+BH_Ini *BH_IniNew(void);
+
+
+void BH_IniFree(BH_Ini *ini);
+
+
+int BH_IniLoad(BH_Ini *ini,
+ BH_IO *io);
+
+
+int BH_IniSave(BH_Ini *ini,
+ BH_IO *io);
+
+
+int BH_IniSetString(BH_Ini *ini,
+ const char *section,
+ const char *key,
+ const char *value);
+
+
+const char *BH_IniString(BH_Ini *ini,
+ const char *section,
+ const char *key);
+
+
+void BH_IniRemoveSection(BH_Ini *ini,
+ const char *section);
+
+
+void BH_IniRemoveKey(BH_Ini *ini,
+ const char *section,
+ const char *key);
+
+
+void *BH_IniSectionIterNext(BH_Ini *ini,
+ void *iter);
+
+
+void *BH_IniSectionIterAt(BH_Ini *ini,
+ const char *section);
+
+
+const char *BH_IniSectionIterName(void *iter);
+
+
+void BH_IniSectionIterRemove(BH_Ini *ini,
+ void *iter);
+
+
+void *BH_IniKVIterNext(void *section,
+ void *iter);
+
+
+void *BH_IniKVIterAt(void *section,
+ const char *key);
+
+
+const char *BH_IniKVIterKey(void *iter);
+
+
+const char *BH_IniKVIterValue(void *iter);
+
+
+void BH_IniKVIterRemove(void *section,
+ void *iter);
+
+
+#endif /* BH_INI_H */
diff --git a/include/BH/String.h b/include/BH/String.h
index f9ef2bc..a1b7527 100644
--- a/include/BH/String.h
+++ b/include/BH/String.h
@@ -70,47 +70,47 @@ int BH_StringFromInt64u(char *string,
double BH_StringToDouble(const char *string,
- size_t *size);
+ size_t *actual);
int8_t BH_StringToInt8s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
int16_t BH_StringToInt16s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
int32_t BH_StringToInt32s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
int64_t BH_StringToInt64s(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
uint8_t BH_StringToInt8u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
uint16_t BH_StringToInt16u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
uint32_t BH_StringToInt32u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
uint64_t BH_StringToInt64u(const char *string,
- size_t *size,
- int base);
+ int base,
+ size_t *actual);
char *BH_StringDup(const char *string);
diff --git a/src/String/Float.c b/src/String/Float.c
index 4acf012..624b393 100644
--- a/src/String/Float.c
+++ b/src/String/Float.c
@@ -515,11 +515,11 @@ static int caselessCompare(const char *src,
static int parseFormat(const char *string,
- size_t *size,
char *buffer,
int *sign,
int *e,
- int *type)
+ int *type,
+ size_t *actual)
{
const char *current;
int esign, dot, count;
@@ -607,15 +607,15 @@ static int parseFormat(const char *string,
*e -= dot;
done:
- if (size)
- *size = current - string;
+ if (actual)
+ *actual = current - string;
return count;
}
double BH_StringToDouble(const char *string,
- size_t *size)
+ size_t *actual)
{
int type, e, sign, i, count, shift;
Mpi r, s, tmp[5];
@@ -627,7 +627,7 @@ double BH_StringToDouble(const char *string,
assert(string != NULL);
/* Parse from string format */
- count = parseFormat(string, size, buffer, &sign, &e, &type);
+ count = parseFormat(string, buffer, &sign, &e, &type, actual);
/* Handle special values */
if (type == BH_FP_INFINITE)
@@ -641,8 +641,8 @@ double BH_StringToDouble(const char *string,
else if (type == BH_FP_ZERO)
{
/* Hacky solution to indicate we haven't seen any digit */
- if (size)
- *size = 0;
+ if (actual)
+ *actual = 0;
return 0.0;
}
diff --git a/src/String/Inline/Int.h b/src/String/Inline/Int.h
index 57eaee0..d77a8cd 100644
--- a/src/String/Inline/Int.h
+++ b/src/String/Inline/Int.h
@@ -3,15 +3,15 @@ signed char sym;
/* Check for valid base and zero out read size */
result = 0;
-if (size)
- *size = 0;
+if (actual)
+ *actual = 0;
if (base != 0 && (base < 2 || base > 36))
return 0;
/* Handle space, sign and base */
-skipSpace(&string, size);
-handleSign(&string, size, &sign);
-guessBase(&string, size, &base);
+skipSpace(&string, actual);
+handleSign(&string, actual, &sign);
+guessBase(&string, actual, &base);
/* Read digits */
while(*string)
@@ -21,14 +21,14 @@ while(*string)
if (sym >= base || sym == -1)
break;
- if (size)
- (*size)++;
+ if (actual)
+ (*actual)++;
result = result * base + sym;
flag = 1;
}
/* Zero out size on error */
-if (!result && !flag && size)
- *size = 0;
+if (!result && !flag && actual)
+ *actual = 0;
return result * sign;
diff --git a/src/String/Int.c b/src/String/Int.c
index 9915607..a2f7456 100644
--- a/src/String/Int.c
+++ b/src/String/Int.c
@@ -160,8 +160,8 @@ int BH_StringFromInt64u(char *string,
int8_t BH_StringToInt8s(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
int8_t result;
#include "Inline/Int.h"
@@ -169,8 +169,8 @@ int8_t BH_StringToInt8s(const char *string,
int16_t BH_StringToInt16s(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
int16_t result;
#include "Inline/Int.h"
@@ -178,8 +178,8 @@ int16_t BH_StringToInt16s(const char *string,
int32_t BH_StringToInt32s(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
int32_t result;
#include "Inline/Int.h"
@@ -187,8 +187,8 @@ int32_t BH_StringToInt32s(const char *string,
int64_t BH_StringToInt64s(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
int64_t result;
#include "Inline/Int.h"
@@ -196,8 +196,8 @@ int64_t BH_StringToInt64s(const char *string,
uint8_t BH_StringToInt8u(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
uint8_t result;
#include "Inline/Int.h"
@@ -205,8 +205,8 @@ uint8_t BH_StringToInt8u(const char *string,
uint16_t BH_StringToInt16u(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
uint16_t result;
#include "Inline/Int.h"
@@ -214,8 +214,8 @@ uint16_t BH_StringToInt16u(const char *string,
uint32_t BH_StringToInt32u(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
uint32_t result;
#include "Inline/Int.h"
@@ -223,8 +223,8 @@ uint32_t BH_StringToInt32u(const char *string,
uint64_t BH_StringToInt64u(const char *string,
- size_t *size,
- int base)
+ int base,
+ size_t *actual)
{
uint64_t result;
#include "Inline/Int.h"
diff --git a/test/tests/TestInt.c b/test/tests/TestInt.c
index f372d4e..f287f89 100644
--- a/test/tests/TestInt.c
+++ b/test/tests/TestInt.c
@@ -8,35 +8,35 @@ BH_UNIT_TEST(Int8)
size_t size;
BH_VERIFY(BH_StringFromInt8s(str, 9, -13, 16, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8s(str, &size, 16) == -13);
+ BH_VERIFY(BH_StringToInt8s(str, 16, &size) == -13);
BH_VERIFY(size == 2);
BH_VERIFY(BH_StringFromInt8s(str, 9, -13, 10, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8s(str, &size, 10) == -13);
+ BH_VERIFY(BH_StringToInt8s(str, 10, &size) == -13);
BH_VERIFY(size == 3);
BH_VERIFY(BH_StringFromInt8s(str, 9, -13, 8, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8s(str, &size, 8) == -13);
+ BH_VERIFY(BH_StringToInt8s(str, 8, &size) == -13);
BH_VERIFY(size == 3);
BH_VERIFY(BH_StringFromInt8s(str, 9, -13, 2, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8s(str, &size, 2) == -13);
+ BH_VERIFY(BH_StringToInt8s(str, 2, &size) == -13);
BH_VERIFY(size == 5);
BH_VERIFY(BH_StringFromInt8u(str, 9, 200, 16, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8u(str, &size, 16) == 200);
+ BH_VERIFY(BH_StringToInt8u(str, 16, &size) == 200);
BH_VERIFY(size == 2);
BH_VERIFY(BH_StringFromInt8u(str, 9, 200, 10, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8u(str, &size, 10) == 200);
+ BH_VERIFY(BH_StringToInt8u(str, 10, &size) == 200);
BH_VERIFY(size == 3);
BH_VERIFY(BH_StringFromInt8u(str, 9, 200, 8, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8u(str, &size, 8) == 200);
+ BH_VERIFY(BH_StringToInt8u(str, 8, &size) == 200);
BH_VERIFY(size == 3);
BH_VERIFY(BH_StringFromInt8u(str, 9, 200, 2, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt8u(str, &size, 2) == 200);
+ BH_VERIFY(BH_StringToInt8u(str, 2, &size) == 200);
BH_VERIFY(size == 8);
return 0;
@@ -49,35 +49,35 @@ BH_UNIT_TEST(Int16)
size_t size;
BH_VERIFY(BH_StringFromInt16s(str, 17, -1234, 16, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16s(str, &size, 16) == -1234);
+ BH_VERIFY(BH_StringToInt16s(str, 16, &size) == -1234);
BH_VERIFY(size == 4);
BH_VERIFY(BH_StringFromInt16s(str, 17, -1234, 10, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16s(str, &size, 10) == -1234);
+ BH_VERIFY(BH_StringToInt16s(str, 10, &size) == -1234);
BH_VERIFY(size == 5);
BH_VERIFY(BH_StringFromInt16s(str, 17, -1234, 8, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16s(str, &size, 8) == -1234);
+ BH_VERIFY(BH_StringToInt16s(str, 8, &size) == -1234);
BH_VERIFY(size == 5);
BH_VERIFY(BH_StringFromInt16s(str, 17, -1234, 2, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16s(str, &size, 2) == -1234);
+ BH_VERIFY(BH_StringToInt16s(str, 2, &size) == -1234);
BH_VERIFY(size == 12);
BH_VERIFY(BH_StringFromInt16u(str, 17, 43210, 16, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16u(str, &size, 16) == 43210);
+ BH_VERIFY(BH_StringToInt16u(str, 16, &size) == 43210);
BH_VERIFY(size == 4);
BH_VERIFY(BH_StringFromInt16u(str, 17, 43210, 10, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16u(str, &size, 10) == 43210);
+ BH_VERIFY(BH_StringToInt16u(str, 10, &size) == 43210);
BH_VERIFY(size == 5);
BH_VERIFY(BH_StringFromInt16u(str, 17, 43210, 8, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16u(str, &size, 8) == 43210);
+ BH_VERIFY(BH_StringToInt16u(str, 8, &size) == 43210);
BH_VERIFY(size == 6);
BH_VERIFY(BH_StringFromInt16u(str, 17, 43210, 2, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt16u(str, &size, 2) == 43210);
+ BH_VERIFY(BH_StringToInt16u(str, 2, &size) == 43210);
BH_VERIFY(size == 16);
return 0;
@@ -90,35 +90,35 @@ BH_UNIT_TEST(Int32)
size_t size;
BH_VERIFY(BH_StringFromInt32s(str, 33, -1234567890l, 16, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32s(str, &size, 16) == -1234567890l);
+ BH_VERIFY(BH_StringToInt32s(str, 16, &size) == -1234567890l);
BH_VERIFY(size == 9);
BH_VERIFY(BH_StringFromInt32s(str, 33, -1234567890l, 10, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32s(str, &size, 10) == -1234567890l);
+ BH_VERIFY(BH_StringToInt32s(str, 10, &size) == -1234567890l);
BH_VERIFY(size == 11);
BH_VERIFY(BH_StringFromInt32s(str, 33, -1234567890l, 8, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32s(str, &size, 8) == -1234567890l);
+ BH_VERIFY(BH_StringToInt32s(str, 8, &size) == -1234567890l);
BH_VERIFY(size == 12);
BH_VERIFY(BH_StringFromInt32s(str, 33, -1234567890l, 2, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32s(str, &size, 2) == -1234567890l);
+ BH_VERIFY(BH_StringToInt32s(str, 2, &size) == -1234567890l);
BH_VERIFY(size == 32);
BH_VERIFY(BH_StringFromInt32u(str, 33, 3456789012ul, 16, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32u(str, &size, 16) == 3456789012ul);
+ BH_VERIFY(BH_StringToInt32u(str, 16, &size) == 3456789012ul);
BH_VERIFY(size == 8);
BH_VERIFY(BH_StringFromInt32u(str, 33, 3456789012ul, 10, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32u(str, &size, 10) == 3456789012ul);
+ BH_VERIFY(BH_StringToInt32u(str, 10, &size) == 3456789012ul);
BH_VERIFY(size == 10);
BH_VERIFY(BH_StringFromInt32u(str, 33, 3456789012ul, 8, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32u(str, &size, 8) == 3456789012ul);
+ BH_VERIFY(BH_StringToInt32u(str, 8, &size) == 3456789012ul);
BH_VERIFY(size == 11);
BH_VERIFY(BH_StringFromInt32u(str, 33, 3456789012ul, 2, NULL) == BH_OK);
- BH_VERIFY(BH_StringToInt32u(str, &size, 2) == 3456789012ul);
+ BH_VERIFY(BH_StringToInt32u(str, 2, &size) == 3456789012ul);
BH_VERIFY(size == 32);
return 0;
@@ -129,34 +129,34 @@ BH_UNIT_TEST(Parsing)
{
size_t size;
- BH_VERIFY(BH_StringToInt32s(" 0x1234", &size, 16) == 0x1234);
+ BH_VERIFY(BH_StringToInt32s(" 0x1234", 16, &size) == 0x1234);
BH_VERIFY(size == 9);
- BH_VERIFY(BH_StringToInt32s(" 12345", &size, 10) == 12345);
+ BH_VERIFY(BH_StringToInt32s(" 12345", 10, &size) == 12345);
BH_VERIFY(size == 8);
- BH_VERIFY(BH_StringToInt32s(" 0123", &size, 8) == 0123);
+ BH_VERIFY(BH_StringToInt32s(" 0123", 8, &size) == 0123);
BH_VERIFY(size == 7);
- BH_VERIFY(BH_StringToInt32s(" 0b1111Hello", &size, 2) == 15);
+ BH_VERIFY(BH_StringToInt32s(" 0b1111Hello", 2, &size) == 15);
BH_VERIFY(size == 9);
- BH_VERIFY(BH_StringToInt32s(" 0x1234", &size, 0) == 0x1234);
+ BH_VERIFY(BH_StringToInt32s(" 0x1234", 0, &size) == 0x1234);
BH_VERIFY(size == 9);
- BH_VERIFY(BH_StringToInt32s(" 0123", &size, 0) == 0123);
+ BH_VERIFY(BH_StringToInt32s(" 0123", 0, &size) == 0123);
BH_VERIFY(size == 7);
- BH_VERIFY(BH_StringToInt32s(" 123", &size, 0) == 123);
+ BH_VERIFY(BH_StringToInt32s(" 123", 0, &size) == 123);
BH_VERIFY(size == 6);
- BH_VERIFY(BH_StringToInt32s(" 0b1111", &size, 0) == 15);
+ BH_VERIFY(BH_StringToInt32s(" 0b1111", 0, &size) == 15);
BH_VERIFY(size == 9);
- BH_VERIFY(BH_StringToInt32s(" 12345Hello", &size, 10) == 12345);
+ BH_VERIFY(BH_StringToInt32s(" 12345Hello", 10, &size) == 12345);
BH_VERIFY(size == 8);
- BH_VERIFY(BH_StringToInt32s(" Hello", &size, 10) == 0);
+ BH_VERIFY(BH_StringToInt32s(" Hello", 10, &size) == 0);
BH_VERIFY(size == 0);
return 0;