]> git.sur5r.net Git - cc65/commitdiff
Fixed a pointer test again -- but, it's better than in pull request #391. 400/head
authorGreg King <gregdk@users.sf.net>
Sat, 11 Mar 2017 20:11:15 +0000 (15:11 -0500)
committerGreg King <gregdk@users.sf.net>
Sat, 11 Mar 2017 20:11:15 +0000 (15:11 -0500)
This time, the expression compares the pointer directly, instead of comparing the pointer's target.  The new expression avoids an array underrun.

test/ref/yacc.c

index d0b9190e4f54213c980018ae45c16e09494a65a7..ab72e24c0881e48868e4d35c6160464b6ae7e3d0 100644 (file)
@@ -562,13 +562,13 @@ yylook()
                }
 
 # ifdef LEXDEBUG
-               if (*(lsp-1) < yysvec + 1)
+               if (lsp == yylstate)
                {
                        fprintf(yyout,"yylook:  stopped (end)\n");
                }
                else
                {
-                       fprintf(yyout,"yylook:  stopped at %d with\n",*(lsp-1)-yysvec-1);
+                       fprintf(yyout,"yylook:  stopped at %d with:\n",*(lsp-1)-(yysvec+1));
                }
 # endif
                while (lsp-- > yylstate)
@@ -594,7 +594,7 @@ yylook()
                                yyleng = yylastch-yytext+1;
                                yytext[yyleng] = 0;
 # ifdef LEXDEBUG
-                               fprintf(yyout,"\nyylook:  match action %d\n",*yyfnd);
+                               fprintf(yyout,"yylook:  match action %d\n",*yyfnd);
                                fprintf(yyout,"yylook:  done loops: %d\n",testbreak);
 # endif
                                return(*yyfnd++);