add nasm_strsep to nasmlib, for output/outmacho.c - strtok doesn't work

This commit is contained in:
Frank Kotler 2007-08-26 05:48:54 +00:00
parent 2ad45a56b4
commit 7fcda399cd
3 changed files with 31 additions and 5 deletions

View File

@ -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 == '$') {

View File

@ -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.

View File

@ -537,7 +537,7 @@ static int32_t macho_section(char *name, int pass, int *bits)
sectionAttributes = NULL;
} else {
sectionAttributes = name;
name = strtok((char*)&sectionAttributes, " \t");
name = nasm_strsep(&sectionAttributes, " \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*)&sectionAttributes, " \t"))) {
&& (currentAttribute = nasm_strsep(&sectionAttributes, " \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) {