On 24/09/10 22:38, Pádraig Brady wrote:
> On 24/09/10 21:15, Suhan Andrei wrote:
>> Hi
>>
>> Just wanted to let you know there are some errors when using old compiler 
>> (
>> gcc -v
>> Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
>> gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
>> )
>>
>>
>> Tere are 2 variables defined inside blocks of code that triggers old c 
>> compiler 
>> to spill errors.
>> I used code from coreutils-8.5.tar.gz 
>> I moved declaration at the start of code and all compiled ok.
> 
> Eep, I'll fix that up, as we want to keep stuff under gl/
> C89 conformant, as it may be moved to gnulib at some stage.

I'll push the attached soon.

cheers,
Pádraig.
commit 013ed013129cf3197686ab83ed4761f82302c916
Author: Pádraig Brady <p...@draigbrady.com>
Date:   Fri Oct 1 14:28:18 2010 +0100

    maint: tweak the mbsalign module to be C89 compatible
    
    This module may be moved to gnulib at some stage.
    
    * gl/lib/mbsalign.c (mbsalign): Declare variables at start of scope
    (ambsalign): Likewise
    * gl/lib/mbsalign.h: Remove trailing comma from enum

diff --git a/gl/lib/mbsalign.c b/gl/lib/mbsalign.c
index b92fe8f..117e4bf 100644
--- a/gl/lib/mbsalign.c
+++ b/gl/lib/mbsalign.c
@@ -217,7 +217,7 @@ mbsalign_unibyte:
   /* Write as much NUL terminated output to DEST as possible.  */
   if (dest_size != 0)
     {
-      size_t start_spaces, end_spaces;
+      size_t start_spaces, end_spaces, space_left;
       char *dest_end = dest + dest_size - 1;
 
       switch (align)
@@ -238,7 +238,7 @@ mbsalign_unibyte:
         }
 
       dest = mbs_align_pad (dest, dest_end, start_spaces);
-      size_t space_left = dest_end - dest;
+      space_left = dest_end - dest;
       dest = mempcpy (dest, str_to_print, MIN (n_used_bytes, space_left));
       mbs_align_pad (dest, dest_end, end_spaces);
     }
@@ -265,8 +265,9 @@ ambsalign (const char *src, size_t *width, mbs_align_t align, int flags)
 
   while (req >= size)
     {
+      char *nbuf;
       size = req + 1;           /* Space for NUL.  */
-      char *nbuf = realloc (buf, size);
+      nbuf = realloc (buf, size);
       if (nbuf == NULL)
         {
           free (buf);
diff --git a/gl/lib/mbsalign.h b/gl/lib/mbsalign.h
index 41bd490..96e81e7 100644
--- a/gl/lib/mbsalign.h
+++ b/gl/lib/mbsalign.h
@@ -21,7 +21,7 @@ typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
 enum {
   /* Use unibyte mode for invalid multibyte strings or
      or when heap memory is exhausted.  */
-  MBA_UNIBYTE_FALLBACK = 0x0001,
+  MBA_UNIBYTE_FALLBACK = 0x0001
 
 #if 0 /* Other possible options.  */
   /* Skip invalid multibyte chars rather than failing  */

Reply via email to