This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: Ping: [Patch]: Fix fixincludes/fixincl.c for SEPARATE_FIX_PROC


Danny Smith wrote:
> 
> Hello,
> 
> This is ping of a patch sent last week.

Sorry.  I just saw it today.

> 2004-11-17  Danny Smith  <dannysmith@users.sourceforge.net>
> 
>         * fixincl.c (fix_with_system): Access z_applyfix_prog[]
>          correctly.
> 
> Index: fixincl.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/fixincludes/fixincl.c,v
> retrieving revision 1.4
> diff -c -3 -p -r1.4 fixincl.c
> *** fixincl.c   27 Oct 2004 14:42:56 -0000      1.4
> --- fixincl.c   12 Nov 2004 05:15:21 -0000
> *************** fix_with_system (tFixDesc* p_fixd,
> *** 863,869 ****
> 
>           argsize = 32
>                   + strlen( pz_orig_dir )
> !                 + sizeof( z_applyfix_prog )
>                   + strlen( pz_fix_file )
>                   + strlen( pz_file_source )
>                   + strlen( pz_temp_file );
> --- 863,869 ----
> 
>           argsize = 32
>                   + strlen( pz_orig_dir )
> !                 + sizeof( z_applyfix_prog[i] )

This is not correct:

1.  A "z_" prefix implies an array of chars terminated with a NUL.
    This variable is now an array of pointers to characters.  The
    name must change.  I will do it now:  "apz_" Array of Ptrs to z-chars

2.  The sizeof expression will yield the size of a pointer, not the
    size of either constant string.  The older code yielded the size
    of two pointers.  :)

3.  A magic number, "2" is used in two places:  once for the array dimension
    and again for a "for (;;)" loop index limit.
      
>                   + strlen( pz_fix_file )
>                   + strlen( pz_file_source )
>                   + strlen( pz_temp_file );
> *************** fix_with_system (tFixDesc* p_fixd,
> *** 872,879 ****
> 
>           strcpy( pz_cmd, pz_orig_dir );
>           pz_scan = pz_cmd + strlen( pz_orig_dir );
> !         strcpy( pz_scan, z_applyfix_prog );
> !         pz_scan += sizeof( z_applyfix_prog ) - 1;
> 
>         if (stat (pz_scan, &buf) != -1)
>           {
> --- 872,879 ----
> 
>           strcpy( pz_cmd, pz_orig_dir );
>           pz_scan = pz_cmd + strlen( pz_orig_dir );
> !         strcpy( pz_scan, z_applyfix_prog[i] );
> !         pz_scan += sizeof( z_applyfix_prog[i] ) - 1;

Again, "sizeof()" won't work.

I will clean this all up and commit tonight.
Thank you.  Regards, Bruce


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