mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-19 18:00:23 +08:00
add nasm_strsep to nasmlib, for output/outmacho.c - strtok doesn't work
This commit is contained in:
parent
2ad45a56b4
commit
7fcda399cd
21
nasmlib.c
21
nasmlib.c
@ -156,6 +156,25 @@ int nasm_strnicmp(const char *s1, const char *s2, int n)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(strsep)
|
||||
char *nasm_strsep(char **stringp, const char *delim)
|
||||
{
|
||||
char *s = *stringp;
|
||||
char *e;
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
e = strpbrk(s, delim);
|
||||
if (e)
|
||||
*e++ = '\0';
|
||||
|
||||
*stringp = e;
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define lib_isnumchar(c) ( isalnum(c) || (c) == '$')
|
||||
#define numvalue(c) ((c)>='a' ? (c)-'a'+10 : (c)>='A' ? (c)-'A'+10 : (c)-'0')
|
||||
|
||||
@ -755,7 +774,7 @@ int stdscan(void *private_data, struct tokenval *tv)
|
||||
if (isidstart(*stdscan_bufptr) ||
|
||||
(*stdscan_bufptr == '$' && isidstart(stdscan_bufptr[1]))) {
|
||||
/* now we've got an identifier */
|
||||
int i;
|
||||
uint32_t i;
|
||||
int is_sym = FALSE;
|
||||
|
||||
if (*stdscan_bufptr == '$') {
|
||||
|
@ -71,6 +71,13 @@ int nasm_stricmp(const char *, const char *);
|
||||
int nasm_strnicmp(const char *, const char *, int);
|
||||
#endif
|
||||
|
||||
#if defined(strsep)
|
||||
#define nasm_strsep strsep
|
||||
#else
|
||||
char *nasm_strsep(char **stringp, const char *delim);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Convert a string into a number, using NASM number rules. Sets
|
||||
* `*error' to TRUE if an error occurs, and FALSE otherwise.
|
||||
|
@ -537,7 +537,7 @@ static int32_t macho_section(char *name, int pass, int *bits)
|
||||
sectionAttributes = NULL;
|
||||
} else {
|
||||
sectionAttributes = name;
|
||||
name = strtok((char*)§ionAttributes, " \t");
|
||||
name = nasm_strsep(§ionAttributes, " \t");
|
||||
}
|
||||
|
||||
for (sm = sectmap; sm->nasmsect != NULL; ++sm) {
|
||||
@ -572,7 +572,7 @@ static int32_t macho_section(char *name, int pass, int *bits)
|
||||
}
|
||||
|
||||
while ((NULL != sectionAttributes)
|
||||
&& (currentAttribute = strtok((char*)§ionAttributes, " \t"))) {
|
||||
&& (currentAttribute = nasm_strsep(§ionAttributes, " \t"))) {
|
||||
if (0 != *currentAttribute) {
|
||||
if (!nasm_strnicmp("align=", currentAttribute, 6)) {
|
||||
char *end;
|
||||
@ -1037,7 +1037,7 @@ static void macho_write_symtab (void)
|
||||
struct symbol *sym;
|
||||
struct section *s;
|
||||
int32_t fi;
|
||||
int32_t i;
|
||||
uint32_t i;
|
||||
|
||||
/* we don't need to pad here since MACHO_RELINFO_SIZE == 8 */
|
||||
|
||||
@ -1102,7 +1102,7 @@ static void macho_write_symtab (void)
|
||||
static void macho_fixup_relocs (struct reloc *r)
|
||||
{
|
||||
struct symbol *sym;
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
while (r != NULL) {
|
||||
if (r->ext) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user