mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-13 17:57:12 +08:00
preproc: Convert tabs to spaces
No func cnages Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
6ebe3bcd2e
commit
4d8dbd98b2
122
preproc.c
122
preproc.c
@ -1,6 +1,6 @@
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 1996-2012 The NASM Authors - All Rights Reserved
|
||||
* Copyright 1996-2014 The NASM Authors - All Rights Reserved
|
||||
* See the file AUTHORS included with the NASM distribution for
|
||||
* the specific copyright holders.
|
||||
*
|
||||
@ -503,10 +503,10 @@ static Token *reverse_tokens(Token *t)
|
||||
Token *next;
|
||||
|
||||
while (t) {
|
||||
next = t->next;
|
||||
t->next = prev;
|
||||
prev = t;
|
||||
t = next;
|
||||
next = t->next;
|
||||
t->next = prev;
|
||||
prev = t;
|
||||
t = next;
|
||||
}
|
||||
|
||||
return prev;
|
||||
@ -960,24 +960,24 @@ static Token *tokenize(char *line)
|
||||
type = TOK_PREPROC_QQ; /* %?? */
|
||||
p++;
|
||||
}
|
||||
} else if (*p == '!') {
|
||||
type = TOK_PREPROC_ID;
|
||||
p++;
|
||||
if (isidchar(*p)) {
|
||||
do {
|
||||
p++;
|
||||
}
|
||||
while (isidchar(*p));
|
||||
} else if (*p == '\'' || *p == '\"' || *p == '`') {
|
||||
p = nasm_skip_string(p);
|
||||
if (*p)
|
||||
p++;
|
||||
else
|
||||
error(ERR_NONFATAL|ERR_PASS1, "unterminated %! string");
|
||||
} else {
|
||||
/* %! without string or identifier */
|
||||
type = TOK_OTHER; /* Legacy behavior... */
|
||||
}
|
||||
} else if (*p == '!') {
|
||||
type = TOK_PREPROC_ID;
|
||||
p++;
|
||||
if (isidchar(*p)) {
|
||||
do {
|
||||
p++;
|
||||
}
|
||||
while (isidchar(*p));
|
||||
} else if (*p == '\'' || *p == '\"' || *p == '`') {
|
||||
p = nasm_skip_string(p);
|
||||
if (*p)
|
||||
p++;
|
||||
else
|
||||
error(ERR_NONFATAL|ERR_PASS1, "unterminated %! string");
|
||||
} else {
|
||||
/* %! without string or identifier */
|
||||
type = TOK_OTHER; /* Legacy behavior... */
|
||||
}
|
||||
} else if (isidchar(*p) ||
|
||||
((*p == '!' || *p == '%' || *p == '$') &&
|
||||
isidchar(p[1]))) {
|
||||
@ -1246,31 +1246,31 @@ static char *detoken(Token * tlist, bool expand_locals)
|
||||
|
||||
list_for_each(t, tlist) {
|
||||
if (t->type == TOK_PREPROC_ID && t->text[1] == '!') {
|
||||
char *v;
|
||||
char *q = t->text;
|
||||
char *v;
|
||||
char *q = t->text;
|
||||
|
||||
v = t->text + 2;
|
||||
if (*v == '\'' || *v == '\"' || *v == '`') {
|
||||
size_t len = nasm_unquote(v, NULL);
|
||||
size_t clen = strlen(v);
|
||||
v = t->text + 2;
|
||||
if (*v == '\'' || *v == '\"' || *v == '`') {
|
||||
size_t len = nasm_unquote(v, NULL);
|
||||
size_t clen = strlen(v);
|
||||
|
||||
if (len != clen) {
|
||||
error(ERR_NONFATAL | ERR_PASS1,
|
||||
"NUL character in %! string");
|
||||
v = NULL;
|
||||
}
|
||||
}
|
||||
if (len != clen) {
|
||||
error(ERR_NONFATAL | ERR_PASS1,
|
||||
"NUL character in %! string");
|
||||
v = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (v) {
|
||||
char *p = getenv(v);
|
||||
if (!p) {
|
||||
error(ERR_NONFATAL | ERR_PASS1,
|
||||
"nonexistent environment variable `%s'", v);
|
||||
p = "";
|
||||
}
|
||||
t->text = nasm_strdup(p);
|
||||
}
|
||||
nasm_free(q);
|
||||
if (v) {
|
||||
char *p = getenv(v);
|
||||
if (!p) {
|
||||
error(ERR_NONFATAL | ERR_PASS1,
|
||||
"nonexistent environment variable `%s'", v);
|
||||
p = "";
|
||||
}
|
||||
t->text = nasm_strdup(p);
|
||||
}
|
||||
nasm_free(q);
|
||||
}
|
||||
|
||||
/* Expand local macros here and not during preprocessing */
|
||||
@ -1723,26 +1723,26 @@ static bool if_condition(Token * tline, enum preproc_token ct)
|
||||
break;
|
||||
|
||||
case PPC_IFENV:
|
||||
tline = expand_smacro(tline);
|
||||
tline = expand_smacro(tline);
|
||||
j = false; /* have we matched yet? */
|
||||
while (tline) {
|
||||
skip_white_(tline);
|
||||
if (!tline || (tline->type != TOK_ID &&
|
||||
tline->type != TOK_STRING &&
|
||||
tline->type != TOK_STRING &&
|
||||
(tline->type != TOK_PREPROC_ID ||
|
||||
tline->text[1] != '!'))) {
|
||||
tline->text[1] != '!'))) {
|
||||
error(ERR_NONFATAL,
|
||||
"`%s' expects environment variable names",
|
||||
pp_directives[ct]);
|
||||
pp_directives[ct]);
|
||||
goto fail;
|
||||
}
|
||||
p = tline->text;
|
||||
if (tline->type == TOK_PREPROC_ID)
|
||||
p += 2; /* Skip leading %! */
|
||||
if (*p == '\'' || *p == '\"' || *p == '`')
|
||||
nasm_unquote_cstr(p, ct);
|
||||
if (getenv(p))
|
||||
j = true;
|
||||
p = tline->text;
|
||||
if (tline->type == TOK_PREPROC_ID)
|
||||
p += 2; /* Skip leading %! */
|
||||
if (*p == '\'' || *p == '\"' || *p == '`')
|
||||
nasm_unquote_cstr(p, ct);
|
||||
if (getenv(p))
|
||||
j = true;
|
||||
tline = tline->next;
|
||||
}
|
||||
break;
|
||||
@ -3177,11 +3177,11 @@ issue_error:
|
||||
return DIRECTIVE_FOUND;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the string to a token stream. Note that smacros
|
||||
* are stored with the token stream reversed, so we have to
|
||||
* reverse the output of tokenize().
|
||||
*/
|
||||
/*
|
||||
* Convert the string to a token stream. Note that smacros
|
||||
* are stored with the token stream reversed, so we have to
|
||||
* reverse the output of tokenize().
|
||||
*/
|
||||
nasm_unquote_cstr(t->text, i);
|
||||
macro_start = reverse_tokens(tokenize(t->text));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user