diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-08-29 16:25:46 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-08-29 16:25:46 +0000 |
commit | 14f8bf2edf69be882e149bf9dde65bccb367c975 (patch) | |
tree | f6907a44219ebd051b13125c0c674cce0b2a75f8 /nasmlib.c | |
parent | 12fc7bc4b2c4864aedc5af595d8185e080a5bb4a (diff) | |
download | nasm-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.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; |