mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-10-10 00:25:06 -04:00
SPDX is an international standard for documenting software license requirements. Remove the existing headers and replace with a brief SPDX preamble. See: https://spdx.dev/use/specifications/ The script used to convert the files is added to "tools", and the file header templates in headers/ are updated. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
47 lines
1.3 KiB
C
47 lines
1.3 KiB
C
/* SPDX-License-Identifier: BSD-2-Clause */
|
|
/* Copyright 1996-2016 The NASM Authors - All Rights Reserved */
|
|
|
|
/*
|
|
* nasmlib.c library routines for the Netwide Assembler
|
|
*/
|
|
|
|
#include "compiler.h"
|
|
|
|
|
|
#include "nasmlib.h"
|
|
|
|
/*
|
|
* Binary search.
|
|
*/
|
|
int bsi(const 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 = strcmp(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 :( */
|
|
}
|
|
|
|
int bsii(const 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 :( */
|
|
}
|