This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RESEND] Error in exemple code in glibc manual on section 6.3.5


On 5/29/09, Ryan Arnold <ryan.arnold@gmail.com> wrote:
> On Fri, May 29, 2009 at 11:34 AM, André Goddard Rosa
> <andre.goddard@gmail.com> wrote:
>> Hi, glibc mailing list!
>>
>>      I found an error in the glibc manual. Do I need to file a bug
>> for fixing the manual?
>
>>  ERROR:
>>  The memmove() listed above has its parameters inverted, because it`s
>>  not putting the remaining characters
>>  in the beginning of the buffer.
>
> André,
>
> Yes I suggest opening a GLIBC bugzilla bug.
>
> Ryan S. Arnold
>

Dear Ryan,

    I' ve opened it at
http://sources.redhat.com/bugzilla/show_bug.cgi?id=10220 and included
a proposed patch on bugzilla and attached.

    Please consider it.

Thanks,
Andre
From 60a6ab9277412f8fc6554ce4a7eedc85ed5b3a2b Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A9=20Goddard=20Rosa?= <andre.goddard@gmail.com>
Date: Sat, 30 May 2009 03:11:55 -0300
Subject: [PATCH] manual: Fix inverted memmove parameters in manual example 'file_mbsrtowcs'
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

On section 6.3.5 - "A Complete Multibyte Conversion Example" the example
describe an algorithm to convert an NUL-terminated multibyte character
string at into an equivalent wide character string. It does:

1. read from input file to temp buffer
2. convert characters in temp buffer
3. write to output file the converted characters
4. go to step one, but first copy incomplete sequence to start of temp buffer

The pass four is implemented by a memmove(), taking an incomplete at the
end of the buffer and repositioning it at the start of the buffer, but its
parameters were wrongly inverted.

Signed-off-by: Andrà Goddard Rosa <andre.goddard@gmail.com>

diff --git a/manual/charset.texi b/manual/charset.texi
index 8b2c09c..79854e5 100644
--- a/manual/charset.texi
+++ b/manual/charset.texi
@@ -1234,7 +1234,7 @@ file_mbsrtowcs (int input, int output)
       /* @r{If any characters must be carried forward,}
          @r{put them at the beginning of @code{buffer}.} */
       if (filled > 0)
-        memmove (inp, buffer, filled);
+        memmove (buffer, inp, filled);
     @}
 
   return 1;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]