summaryrefslogtreecommitdiff
path: root/nasmlib.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-08-29 16:25:46 +0000
committerH. Peter Anvin <hpa@zytor.com>2007-08-29 16:25:46 +0000
commit14f8bf2edf69be882e149bf9dde65bccb367c975 (patch)
treef6907a44219ebd051b13125c0c674cce0b2a75f8 /nasmlib.c
parent12fc7bc4b2c4864aedc5af595d8185e080a5bb4a (diff)
downloadnasm-14f8bf2edf69be882e149bf9dde65bccb367c975.tar.gz
nasm-14f8bf2edf69be882e149bf9dde65bccb367c975.tar.bz2
nasm-14f8bf2edf69be882e149bf9dde65bccb367c975.zip
nasmlib: add bsii() case-insensitive version of bsi()
Diffstat (limited to 'nasmlib.c')
-rw-r--r--nasmlib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/nasmlib.c b/nasmlib.c
index e380542..64d85b9 100644
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -1088,6 +1088,22 @@ int bsi(char *string, const char **array, int size)
return -1; /* we haven't got it :( */
}
+int bsii(char *string, const char **array, int size)
+{
+ int i = -1, j = size; /* always, i < index < j */
+ while (j - i >= 2) {
+ int k = (i + j) / 2;
+ int l = nasm_stricmp(string, array[k]);
+ if (l < 0) /* it's in the first half */
+ j = k;
+ else if (l > 0) /* it's in the second half */
+ i = k;
+ else /* we've got it :) */
+ return k;
+ }
+ return -1; /* we haven't got it :( */
+}
+
static char *file_name = NULL;
static int32_t line_number = 0;