mirror of
https://github.com/cc65/cc65.git
synced 2024-09-06 18:54:30 +00:00
Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@2479 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
e6f9464ea9
commit
b3496bb343
@ -377,11 +377,14 @@ static int MacroCall (Macro* M)
|
|||||||
const char* ArgStart;
|
const char* ArgStart;
|
||||||
char* B;
|
char* B;
|
||||||
|
|
||||||
/* Expect an argument list */
|
/* Check for an argument list. If we don't have a list, we won't expand
|
||||||
|
* the macro.
|
||||||
|
*/
|
||||||
SkipBlank ();
|
SkipBlank ();
|
||||||
if (CurC != '(') {
|
if (CurC != '(') {
|
||||||
PPError ("Illegal macro call");
|
KeepStr (M->Name);
|
||||||
return 0;
|
KeepChar (' ');
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Eat the left paren */
|
/* Eat the left paren */
|
||||||
@ -404,29 +407,29 @@ static int MacroCall (Macro* M)
|
|||||||
B = CopyQuotedString (B);
|
B = CopyQuotedString (B);
|
||||||
} else if (CurC == ',' || CurC == ')') {
|
} else if (CurC == ',' || CurC == ')') {
|
||||||
if (ParCount == 0) {
|
if (ParCount == 0) {
|
||||||
/* End of actual argument */
|
/* End of actual argument */
|
||||||
*B++ = '\0';
|
*B++ = '\0';
|
||||||
while (IsBlank(*ArgStart)) {
|
while (IsBlank(*ArgStart)) {
|
||||||
++ArgStart;
|
++ArgStart;
|
||||||
}
|
}
|
||||||
if (ArgCount < M->ArgCount) {
|
if (ArgCount < M->ArgCount) {
|
||||||
M->ActualArgs[ArgCount++] = ArgStart;
|
M->ActualArgs[ArgCount++] = ArgStart;
|
||||||
} else if (CurC != ')' || *ArgStart != '\0' || M->ArgCount > 0) {
|
} else if (CurC != ')' || *ArgStart != '\0' || M->ArgCount > 0) {
|
||||||
/* Be sure not to count the single empty argument for a
|
/* Be sure not to count the single empty argument for a
|
||||||
* macro that does not have arguments.
|
* macro that does not have arguments.
|
||||||
*/
|
*/
|
||||||
++ArgCount;
|
++ArgCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for end of macro param list */
|
/* Check for end of macro param list */
|
||||||
if (CurC == ')') {
|
if (CurC == ')') {
|
||||||
NextChar ();
|
NextChar ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start the next param */
|
/* Start the next param */
|
||||||
ArgStart = B;
|
ArgStart = B;
|
||||||
NextChar ();
|
NextChar ();
|
||||||
} else {
|
} else {
|
||||||
/* Comma or right paren inside nested parenthesis */
|
/* Comma or right paren inside nested parenthesis */
|
||||||
if (CurC == ')') {
|
if (CurC == ')') {
|
||||||
@ -436,15 +439,15 @@ static int MacroCall (Macro* M)
|
|||||||
NextChar ();
|
NextChar ();
|
||||||
}
|
}
|
||||||
} else if (IsBlank (CurC)) {
|
} else if (IsBlank (CurC)) {
|
||||||
/* Squeeze runs of blanks */
|
/* Squeeze runs of blanks */
|
||||||
*B++ = ' ';
|
*B++ = ' ';
|
||||||
SkipBlank ();
|
SkipBlank ();
|
||||||
} else if (CurC == '/' && NextC == '*') {
|
} else if (CurC == '/' && NextC == '*') {
|
||||||
*B++ = ' ';
|
*B++ = ' ';
|
||||||
OldStyleComment ();
|
OldStyleComment ();
|
||||||
} else if (ANSI == 0 && CurC == '/' && NextC == '/') {
|
} else if (ANSI == 0 && CurC == '/' && NextC == '/') {
|
||||||
*B++ = ' ';
|
*B++ = ' ';
|
||||||
NewStyleComment ();
|
NewStyleComment ();
|
||||||
} else if (CurC == '\0') {
|
} else if (CurC == '\0') {
|
||||||
/* End of line inside macro argument list - read next line */
|
/* End of line inside macro argument list - read next line */
|
||||||
if (NextLine () == 0) {
|
if (NextLine () == 0) {
|
||||||
@ -480,12 +483,12 @@ static void ExpandMacro (Macro* M)
|
|||||||
{
|
{
|
||||||
/* Check if this is a function like macro */
|
/* Check if this is a function like macro */
|
||||||
if (M->ArgCount >= 0) {
|
if (M->ArgCount >= 0) {
|
||||||
/* Function like macro */
|
/* Function like macro */
|
||||||
if (MacroCall (M) == 0) {
|
if (MacroCall (M) == 0) {
|
||||||
ClearLine ();
|
ClearLine ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Just copy the replacement text */
|
/* Just copy the replacement text */
|
||||||
KeepStr (M->Replacement);
|
KeepStr (M->Replacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -499,7 +502,7 @@ static void DefineMacro (void)
|
|||||||
ident Ident;
|
ident Ident;
|
||||||
char Buf[LINESIZE];
|
char Buf[LINESIZE];
|
||||||
Macro* M;
|
Macro* M;
|
||||||
Macro* Existing;
|
Macro* Existing;
|
||||||
|
|
||||||
/* Read the macro name */
|
/* Read the macro name */
|
||||||
SkipBlank ();
|
SkipBlank ();
|
||||||
@ -625,7 +628,7 @@ static int Pass1 (const char* From, char* To)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (MaybeMacro (Ident[0])) {
|
if (MaybeMacro (Ident[0])) {
|
||||||
done = 0;
|
done = 0;
|
||||||
}
|
}
|
||||||
KeepStr (Ident);
|
KeepStr (Ident);
|
||||||
}
|
}
|
||||||
@ -668,17 +671,17 @@ static int Pass2 (const char* From, char* To)
|
|||||||
if (IsIdent (CurC)) {
|
if (IsIdent (CurC)) {
|
||||||
SymName (Ident);
|
SymName (Ident);
|
||||||
M = FindMacro (Ident);
|
M = FindMacro (Ident);
|
||||||
if (M) {
|
if (M) {
|
||||||
ExpandMacro (M);
|
ExpandMacro (M);
|
||||||
no_chg = 0;
|
no_chg = 0;
|
||||||
} else {
|
} else {
|
||||||
KeepStr (Ident);
|
KeepStr (Ident);
|
||||||
}
|
}
|
||||||
} else if (IsQuote (CurC)) {
|
} else if (IsQuote (CurC)) {
|
||||||
mptr = CopyQuotedString (mptr);
|
mptr = CopyQuotedString (mptr);
|
||||||
} else {
|
} else {
|
||||||
KeepChar (CurC);
|
KeepChar (CurC);
|
||||||
NextChar ();
|
NextChar ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return no_chg;
|
return no_chg;
|
||||||
|
Loading…
Reference in New Issue
Block a user