X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fasmstmt.c;h=0644e802980e5dde69f9c4f72e1b9e54755de81d;hb=98da4b581175232d89630f5c19f22e37a7588c7b;hp=b34f78591dc26b9cb1e160561237993c4a5605ee;hpb=23fbf3ff2a8956483bffaf1943967e04074cf443;p=cc65 diff --git a/src/cc65/asmstmt.c b/src/cc65/asmstmt.c index b34f78591..0644e8029 100644 --- a/src/cc65/asmstmt.c +++ b/src/cc65/asmstmt.c @@ -190,7 +190,7 @@ static void ParseWordArg (StrBuf* T, unsigned Arg) -static void ParseLongArg (StrBuf* T, unsigned Arg) +static void ParseLongArg (StrBuf* T, unsigned Arg attribute ((unused))) /* Parse the %l format specifier */ { ExprDesc Expr; @@ -254,7 +254,7 @@ static void ParseLVarArg (StrBuf* T, unsigned Arg) * don't have a fixed stack offset, so check it and bail out with an error * if this is the case. */ - if ((Sym->Flags & SC_PARAM) == SC_PARAM && IsVariadic (CurrentFunc)) { + if ((Sym->Flags & SC_PARAM) == SC_PARAM && F_IsVariadic (CurrentFunc)) { Error ("Argument %u has no fixed stack offset", Arg); AsmErrorSkip (); return; @@ -273,8 +273,8 @@ static void ParseLVarArg (StrBuf* T, unsigned Arg) static void ParseAsm (void) /* Parse the contents of the ASM statement */ { - unsigned I; unsigned Arg; + char C; /* Create a target string buffer */ StrBuf T = AUTO_STRBUF_INITIALIZER; @@ -302,12 +302,8 @@ static void ParseAsm (void) * %o - Stack offset of a (local) variable * %% - The % sign */ - I = 0; Arg = 0; - while (I < SB_GetLen (&S)) { - - /* Get the next character */ - char C = SB_AtUnchecked (&S, I++); + while ((C = SB_Get (&S)) != '\0') { /* If it is a newline, the current line is ready to go */ if (C == '\n') { @@ -320,27 +316,19 @@ static void ParseAsm (void) /* Format specifier */ ++Arg; - - /* Check if we have characters left */ - if (I >= SB_GetLen (&S)) { - Error ("Error in __asm__ format specifier %u", Arg); - AsmErrorSkip (); - goto Done; - } else { - C = SB_AtUnchecked (&S, I++); - switch (C) { - case 'b': ParseByteArg (&T, Arg); break; - case 'w': ParseWordArg (&T, Arg); break; - case 'l': ParseLongArg (&T, Arg); break; - case 'v': ParseGVarArg (&T, Arg); break; - case 'o': ParseLVarArg (&T, Arg); break; - case '%': SB_AppendChar (&T, '%'); break; - default: - Error ("Error in __asm__ format specifier %u", Arg); - AsmErrorSkip (); - goto Done; - } - } + C = SB_Get (&S); + switch (C) { + case 'b': ParseByteArg (&T, Arg); break; + case 'w': ParseWordArg (&T, Arg); break; + case 'l': ParseLongArg (&T, Arg); break; + case 'v': ParseGVarArg (&T, Arg); break; + case 'o': ParseLVarArg (&T, Arg); break; + case '%': SB_AppendChar (&T, '%'); break; + default: + Error ("Error in __asm__ format specifier %u", Arg); + AsmErrorSkip (); + goto Done; + } } else { @@ -373,7 +361,9 @@ void AsmStatement (void) NextToken (); /* Need left parenthesis */ - ConsumeLParen (); + if (!ConsumeLParen ()) { + return; + } /* String literal */ if (CurTok.Tok != TOK_SCONST) {