X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fpreproc.c;h=1b13018bc3a623e5cf4fde505edb38df5f4f8f53;hb=9b7c16ec4cbb5282642c377272224e3fc825f860;hp=f45bcdedd93e89005fd5d2e4b44d87e3cf3be5ed;hpb=e8b90752d9c4d88311dbcd8e74bc4f46028ef852;p=cc65 diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index f45bcdedd..1b13018bc 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2007, Ullrich von Bassewitz */ +/* (C) 1998-2009, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -189,7 +189,7 @@ static MacroExp* InitMacroExp (MacroExp* E, Macro* M) /* Initialize a MacroExp structure */ { InitCollection (&E->ActualArgs); - InitStrBuf (&E->Replacement); + SB_Init (&E->Replacement); E->M = M; return E; } @@ -206,7 +206,7 @@ static void DoneMacroExp (MacroExp* E) FreeStrBuf (CollAtUnchecked (&E->ActualArgs, I)); } DoneCollection (&E->ActualArgs); - DoneStrBuf (&E->Replacement); + SB_Done (&E->Replacement); } @@ -446,7 +446,7 @@ static void ReadMacroArgs (MacroExp* E) } /* Check for end of macro param list */ - if (CurC == ')') { + if (CurC == ')') { NextChar (); break; } @@ -488,7 +488,7 @@ static void ReadMacroArgs (MacroExp* E) } /* Deallocate string buf resources */ - DoneStrBuf (&Arg); + SB_Done (&Arg); } @@ -504,6 +504,7 @@ static void MacroArgSubst (MacroExp* E) /* Remember the current input and switch to the macro replacement. */ + int OldIndex = SB_GetIndex (&E->M->Replacement); SB_Reset (&E->M->Replacement); OldSource = InitLine (&E->M->Replacement); @@ -623,6 +624,7 @@ static void MacroArgSubst (MacroExp* E) /* Switch back the input */ InitLine (OldSource); + SB_SetIndex (&E->M->Replacement, OldIndex); } @@ -674,7 +676,10 @@ static void MacroCall (StrBuf* Target, Macro* M) static void ExpandMacro (StrBuf* Target, Macro* M) /* Expand a macro into Target */ { - /* ### printf ("Expanding %s(%u)\n", M->Name, ++V); */ +#if 0 + static unsigned V = 0; + printf ("Expanding %s(%u)\n", M->Name, ++V); +#endif /* Check if this is a function like macro */ if (M->ArgCount >= 0) { @@ -713,7 +718,9 @@ static void ExpandMacro (StrBuf* Target, Macro* M) DoneMacroExp (&E); } - /* ### printf ("Done with %s(%u)\n", M->Name, V--); */ +#if 0 + printf ("Done with %s(%u)\n", M->Name, V--); +#endif } @@ -829,8 +836,9 @@ static void DefineMacro (void) while (IsSpace (SB_LookAtLast (&M->Replacement))) { SB_Drop (&M->Replacement, 1); } - - /* ### printf ("%s: <%.*s>\n", M->Name, SB_GetLen (&M->Replacement), SB_GetConstBuf (&M->Replacement)); */ +#if 0 + printf ("%s: <%.*s>\n", M->Name, SB_GetLen (&M->Replacement), SB_GetConstBuf (&M->Replacement)); +#endif /* If we have an existing macro, check if the redefinition is identical. * Print a diagnostic if not. @@ -1145,7 +1153,7 @@ static void DoInclude (void) Done: /* Free the allocated filename data */ - DoneStrBuf (&Filename); + SB_Done (&Filename); /* Clear the remaining line so the next input will come from the new * file (if open) @@ -1379,7 +1387,7 @@ void Preprocess (void) Done: if (Verbosity > 1 && SB_NotEmpty (Line)) { printf ("%s(%u): %.*s\n", GetCurrentFile (), GetCurrentLine (), - SB_GetLen (Line), SB_GetConstBuf (Line)); + (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } }