0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-07-24 10:25:42 -04:00

preproc.c: Fix tab\space mess

It's really hard to read the code which is
terribly messed in tabs\spaces. Fix it all
at once. It's dirty work but has to be done
once.

No change on binary level.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2010-02-16 10:27:56 +03:00
parent 3012d5d430
commit accda195a3

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2009 The NASM Authors - All Rights Reserved
* Copyright 1996-2010 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@ -467,7 +467,8 @@ static Token *delete_Token(Token * t);
#define tok_is_(x,v) (tok_type_((x), TOK_OTHER) && !strcmp((x)->text,(v)))
#define tok_isnt_(x,v) ((x) && ((x)->type!=TOK_OTHER || strcmp((x)->text,(v))))
/* Handle TASM specific directives, which do not contain a % in
/*
* Handle TASM specific directives, which do not contain a % in
* front of them. We do it here because I could not find any other
* place to do it for the moment, and it is a hack (ideally it would
* be nice to be able to use the NASM pre-processor to do it).
@ -770,15 +771,19 @@ static char *read_line(void)
break;
p += strlen(p);
if (p > buffer && p[-1] == '\n') {
/* Convert backslash-CRLF line continuation sequences into
nothing at all (for DOS and Windows) */
/*
* Convert backslash-CRLF line continuation sequences into
* nothing at all (for DOS and Windows)
*/
if (((p - 2) > buffer) && (p[-3] == '\\') && (p[-2] == '\r')) {
p -= 3;
*p = 0;
continued_count++;
}
/* Also convert backslash-LF line continuation sequences into
nothing at all (for Unix) */
/*
* Also convert backslash-LF line continuation sequences into
* nothing at all (for Unix)
*/
else if (((p - 1) > buffer) && (p[-2] == '\\')) {
p -= 2;
*p = 0;
@ -948,8 +953,10 @@ static Token *tokenize(char *line)
if (!is_hex && (c == 'e' || c == 'E')) {
has_e = true;
if (*p == '+' || *p == '-') {
/* e can only be followed by +/- if it is either a
prefixed hex number or a floating-point number */
/*
* e can only be followed by +/- if it is either a
* prefixed hex number or a floating-point number
*/
p++;
is_float = true;
}
@ -962,14 +969,16 @@ static Token *tokenize(char *line)
} else if (isnumchar(c) || c == '_')
; /* just advance */
else if (c == '.') {
/* we need to deal with consequences of the legacy
parser, like "1.nolist" being two tokens
(TOK_NUMBER, TOK_ID) here; at least give it
a shot for now. In the future, we probably need
a flex-based scanner with proper pattern matching
to do it as well as it can be done. Nothing in
the world is going to help the person who wants
0x123.p16 interpreted as two tokens, though. */
/*
* we need to deal with consequences of the legacy
* parser, like "1.nolist" being two tokens
* (TOK_NUMBER, TOK_ID) here; at least give it
* a shot for now. In the future, we probably need
* a flex-based scanner with proper pattern matching
* to do it as well as it can be done. Nothing in
* the world is going to help the person who wants
* 0x123.p16 interpreted as two tokens, though.
*/
r = p;
while (*r == '_')
r++;
@ -1462,7 +1471,7 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail,
}
error(ERR_FATAL, "unable to open include file `%s'", file);
return NULL; /* never reached - placate compilers */
return NULL;
}
/*
@ -1768,7 +1777,7 @@ static bool if_condition(Token * tline, enum preproc_token ct)
needtype = TOK_STRING;
goto iftype;
iftype:
iftype:
t = tline = expand_smacro(tline);
while (tok_type_(t, TOK_WHITESPACE) ||
@ -1851,9 +1860,10 @@ static bool define_smacro(Context *ctx, const char *mname, bool casesense,
error(ERR_WARNING|ERR_PASS1,
"single-line macro `%s' defined both with and"
" without parameters", mname);
/* Some instances of the old code considered this a failure,
some others didn't. What is the right thing to do here? */
/*
* Some instances of the old code considered this a failure,
* some others didn't. What is the right thing to do here?
*/
free_tlist(expansion);
return false; /* Failure */
} else {
@ -2489,7 +2499,7 @@ static int do_directive(Token * tline)
severity = ERR_WARNING|ERR_WARN_USER;
goto issue_error;
issue_error:
issue_error:
{
/* Only error out if this is the final pass */
if (pass != 2 && i != PP_FATAL)
@ -3513,8 +3523,10 @@ static bool paste_tokens(Token **head, bool handle_paste_tokens)
tt = tt->next;
}
/* Now tt points to the first token after the potential
paste area... */
/*
* Now tt points to the first token after
* the potential paste area...
*/
if (tt != t->next) {
/* We have at least two tokens... */
len += strlen(t->text);