mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
nasmlib: add bsii() case-insensitive version of bsi()
This commit is contained in:
16
nasmlib.c
16
nasmlib.c
@@ -1088,6 +1088,22 @@ int bsi(char *string, const char **array, int size)
|
|||||||
return -1; /* we haven't got it :( */
|
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 char *file_name = NULL;
|
||||||
static int32_t line_number = 0;
|
static int32_t line_number = 0;
|
||||||
|
|
||||||
|
@@ -257,8 +257,11 @@ int32_t reloc_wrt(expr *);
|
|||||||
* Binary search routine. Returns index into `array' of an entry
|
* Binary search routine. Returns index into `array' of an entry
|
||||||
* matching `string', or <0 if no match. `array' is taken to
|
* matching `string', or <0 if no match. `array' is taken to
|
||||||
* contain `size' elements.
|
* contain `size' elements.
|
||||||
|
*
|
||||||
|
* bsi() is case sensitive, bsii() is case insensitive.
|
||||||
*/
|
*/
|
||||||
int bsi(char *string, const char **array, int size);
|
int bsi(char *string, const char **array, int size);
|
||||||
|
int bsii(char *string, const char **array, int size);
|
||||||
|
|
||||||
char *src_set_fname(char *newname);
|
char *src_set_fname(char *newname);
|
||||||
int32_t src_set_linnum(int32_t newline);
|
int32_t src_set_linnum(int32_t newline);
|
||||||
|
Reference in New Issue
Block a user