Re: [PATCH, libcpp] Fix thinko in _cpp_remaining_tokens_num_in_context (PR bootstrap/50801)

2011-10-20 Thread Ulrich Weigand
Dodji Seketeli wrote:

 I have lightly tested it on SPU in a cross compiled environment (so I
 couldn't bootstrap it there) and I have bootstrapped it on
 x86_64-unknown-linux-gnu.  One person confirmed in the audit trail of
 the PR that it fixes the issue for him on PPC, so I am proposing the
 patch even if I don't know if it bootstraps on SPU or PPC in general.

Well, SPU doesn't bootstrap as such (it's a target-only architecture),
but I can confirm that the patch does fix the newlib build failure I
was seeing on SPU.

Thanks for the quick fix!

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


Re: [PATCH, libcpp] Fix thinko in _cpp_remaining_tokens_num_in_context (PR bootstrap/50801)

2011-10-20 Thread Ulrich Weigand
Dodji Seketeli wrote:

cpp_context *context = pfile-context;
if (context-tokens_kind == TOKENS_KIND_DIRECT)
 -return ((LAST (context).token - FIRST (context).token)
 - / sizeof (cpp_token));
 +return (LAST (context).token - FIRST (context).token);
else if (context-tokens_kind == TOKENS_KIND_INDIRECT
  || context-tokens_kind == TOKENS_KIND_EXTENDED)
  return ((LAST (context).ptoken - FIRST (context).ptoken)

B.t.w. isn't the same thinko also present in the else if path:

  else if (context-tokens_kind == TOKENS_KIND_INDIRECT
   || context-tokens_kind == TOKENS_KIND_EXTENDED)
return ((LAST (context).ptoken - FIRST (context).ptoken)
/ sizeof (cpp_token *));

ptoken seems to be of type const cpp_token **, so the pointer
subtraction already divides by sizeof (cpp_token *).

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


Re: [PATCH, libcpp] Fix thinko in _cpp_remaining_tokens_num_in_context (PR bootstrap/50801)

2011-10-20 Thread Dodji Seketeli
Ulrich Weigand uweig...@de.ibm.com writes:

 I can confirm that the patch does fix the newlib build failure I was
 seeing on SPU.

Pheew, thank you.

Below is a better patch that I am bootstrapping at the moment.

From: Dodji Seketeli do...@redhat.com
Date: Thu, 20 Oct 2011 09:43:49 +0200
Subject: [PATCH] Fix thinko in _cpp_remaining_tokens_num_in_context

libcpp/

* lex.c (_cpp_remaining_tokens_num_in_context): Fix computation of
number of tokens.
---
 libcpp/ChangeLog |6 ++
 libcpp/lex.c |6 ++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index bbb4085..128d3e1 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-20  Dodji Seketeli  do...@redhat.com
+
+   PR bootstrap/50801
+   * lex.c (_cpp_remaining_tokens_num_in_context): Fix computation of
+   number of tokens.
+
 2011-10-18  Dodji Seketeli  do...@redhat.com
 
PR bootstrap/50760
diff --git a/libcpp/lex.c b/libcpp/lex.c
index cd6ae9f..527368b 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -1710,12 +1710,10 @@ _cpp_remaining_tokens_num_in_context (cpp_reader *pfile)
 {
   cpp_context *context = pfile-context;
   if (context-tokens_kind == TOKENS_KIND_DIRECT)
-return ((LAST (context).token - FIRST (context).token)
-   / sizeof (cpp_token));
+return (LAST (context).token - FIRST (context).token);
   else if (context-tokens_kind == TOKENS_KIND_INDIRECT
   || context-tokens_kind == TOKENS_KIND_EXTENDED)
-return ((LAST (context).ptoken - FIRST (context).ptoken)
-   / sizeof (cpp_token *));
+return (LAST (context).ptoken - FIRST (context).ptoken);
   else
   abort ();
 }
-- 
1.7.6.4



-- 
Dodji


Re: [PATCH, libcpp] Fix thinko in _cpp_remaining_tokens_num_in_context (PR bootstrap/50801)

2011-10-20 Thread Dodji Seketeli
Ulrich Weigand uweig...@de.ibm.com writes:

 B.t.w. isn't the same thinko also present in the else if path:

Right.  Jakub spotted it as well.  Hence the followup patch in the other
subthread.

Thanks for watching.

-- 
Dodji


Re: [PATCH, libcpp] Fix thinko in _cpp_remaining_tokens_num_in_context (PR bootstrap/50801)

2011-10-20 Thread Dodji Seketeli
Dodji Seketeli do...@redhat.com writes:

 libcpp/

   * lex.c (_cpp_remaining_tokens_num_in_context): Fix computation of
   number of tokens.

Jakub OKed the patch on IRC, so I went ahead and committed to trunk

Thanks.

-- 
Dodji