On 4/26/06, Pat Eyler <rubypate / gmail.com> wrote:
> On 4/26/06, Brown, Warren <warrenbrown / aquire.com> wrote:
> > > rb_range_beg_len (in range.c) does set beg and len.
> > > I'm hoping the other edge cases (argc <1 or >3) are
> > > covered too.
> >
> >     Instead of marking this as a false positive due to assumptions about
> > what is happening outside of this function, why not just initialize
> > "beg" to 0 and not make *any* assumptions?  Seems like a much better
> > solution to me.
>
> good idea:
>
> *** array.c     12 Dec 2005 16:46:59 -0000      1.186
> --- array.c     26 Apr 2006 15:27:05 -0000
> ***************
> *** 2100,2105 ****
> --- 2100,2106 ----
>   {
>       VALUE item, arg1, arg2;
>       long beg, end, len;
> +     beg = 0;
>       VALUE *p, *pend;
>       int block_p = Qfalse;

Actually, that'd be a syntax error in C. All variable declarations in
C must precede all other statements. So your added line would need to
be after the variable declaration block. Alternatively, you could also
just add an " = 0" to the declaration of beg, since variables can be
intialized during declaration:

 *** array.c
 --- array.c
 ***************
 *** 2100,2105 ****
 --- 2100,2105 ----
   {
       VALUE item, arg1, arg2;
 -     long beg, end, len;
 +     long beg = 0, end, len;
       VALUE *p, *pend;
       int block_p = Qfalse;

Jacob Fugal