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 * See the file AUTHORS included with the NASM distribution for
* the specific copyright holders. * 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_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)))) #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 * 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 * 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). * be nice to be able to use the NASM pre-processor to do it).
@ -770,15 +771,19 @@ static char *read_line(void)
break; break;
p += strlen(p); p += strlen(p);
if (p > buffer && p[-1] == '\n') { 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')) { if (((p - 2) > buffer) && (p[-3] == '\\') && (p[-2] == '\r')) {
p -= 3; p -= 3;
*p = 0; *p = 0;
continued_count++; 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] == '\\')) { else if (((p - 1) > buffer) && (p[-2] == '\\')) {
p -= 2; p -= 2;
*p = 0; *p = 0;
@ -948,8 +953,10 @@ static Token *tokenize(char *line)
if (!is_hex && (c == 'e' || c == 'E')) { if (!is_hex && (c == 'e' || c == 'E')) {
has_e = true; has_e = true;
if (*p == '+' || *p == '-') { 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++; p++;
is_float = true; is_float = true;
} }
@ -962,14 +969,16 @@ static Token *tokenize(char *line)
} else if (isnumchar(c) || c == '_') } else if (isnumchar(c) || c == '_')
; /* just advance */ ; /* just advance */
else if (c == '.') { else if (c == '.') {
/* we need to deal with consequences of the legacy /*
parser, like "1.nolist" being two tokens * we need to deal with consequences of the legacy
(TOK_NUMBER, TOK_ID) here; at least give it * parser, like "1.nolist" being two tokens
a shot for now. In the future, we probably need * (TOK_NUMBER, TOK_ID) here; at least give it
a flex-based scanner with proper pattern matching * a shot for now. In the future, we probably need
to do it as well as it can be done. Nothing in * a flex-based scanner with proper pattern matching
the world is going to help the person who wants * to do it as well as it can be done. Nothing in
0x123.p16 interpreted as two tokens, though. */ * the world is going to help the person who wants
* 0x123.p16 interpreted as two tokens, though.
*/
r = p; r = p;
while (*r == '_') while (*r == '_')
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); error(ERR_FATAL, "unable to open include file `%s'", file);
return NULL; /* never reached - placate compilers */ return NULL;
} }
/* /*
@ -1851,9 +1860,10 @@ static bool define_smacro(Context *ctx, const char *mname, bool casesense,
error(ERR_WARNING|ERR_PASS1, error(ERR_WARNING|ERR_PASS1,
"single-line macro `%s' defined both with and" "single-line macro `%s' defined both with and"
" without parameters", mname); " without parameters", mname);
/*
/* Some instances of the old code considered this a failure, * Some instances of the old code considered this a failure,
some others didn't. What is the right thing to do here? */ * some others didn't. What is the right thing to do here?
*/
free_tlist(expansion); free_tlist(expansion);
return false; /* Failure */ return false; /* Failure */
} else { } else {
@ -3513,8 +3523,10 @@ static bool paste_tokens(Token **head, bool handle_paste_tokens)
tt = tt->next; 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) { if (tt != t->next) {
/* We have at least two tokens... */ /* We have at least two tokens... */
len += strlen(t->text); len += strlen(t->text);