public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pph] Fix token dumping within a window (issue4991046)
@ 2011-09-08 19:51 Diego Novillo
  0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2011-09-08 19:51 UTC (permalink / raw)
  To: reply, crowl, gcc-patches


When dumping a range of tokens, I was not properly counting the tokens
to be dumped, which resulted in empty output when dumping a range
of tokens in the middle of a large array.

I also reduced the size of the window to print.  It was too large to
be useful.

Tested on x86_64.  Committed to branch.


Diego.


	* parser.c (cp_lexer_dump_tokens): Properly count number of printed
	tokens to know when to stop.
	(cp_debug_parser): Reduce token window size to 20.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 700ca64..a46edba 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -259,7 +259,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
 		      cp_token *start_token, unsigned num,
 		      cp_token *curr_token)
 {
-  unsigned i;
+  unsigned i, nprinted;
   cp_token *token;
   bool do_print;
 
@@ -281,7 +281,8 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
     }
 
   do_print = false;
-  for (i = 0; VEC_iterate (cp_token, buffer, i, token) && i < num; i++)
+  nprinted = 0;
+  for (i = 0; VEC_iterate (cp_token, buffer, i, token) && nprinted < num; i++)
     {
       if (token == start_token)
 	do_print = true;
@@ -289,6 +290,7 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
       if (!do_print)
 	continue;
 
+      nprinted++;
       if (token == curr_token)
 	fprintf (file, "[[");
 
@@ -462,7 +464,7 @@ cp_debug_parser_tokens (FILE *file, cp_parser *parser, int window_size)
 void
 cp_debug_parser (FILE *file, cp_parser *parser)
 {
-  const size_t window_size = 200;
+  const size_t window_size = 20;
 
   if (file == NULL)
     file = stderr;

--
This patch is available for review at http://codereview.appspot.com/4991046

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-09-08 18:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 19:51 [pph] Fix token dumping within a window (issue4991046) Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).