[#7708] Bug in libsnmp-ruby1.8 — Hadmut Danisch <hadmut@...>

Hi,

8 messages 2006/04/11
[#7709] Re: Bug in libsnmp-ruby1.8 — Eric Hodel <drbrain@...7.net> 2006/04/11

On Apr 11, 2006, at 6:23 AM, Hadmut Danisch wrote:

[#7770] Re: possible defect in array.c — "Brown, Warren" <warrenbrown@...>

> rb_range_beg_len (in range.c) does set beg and len.

13 messages 2006/04/26
[#7771] Re: possible defect in array.c — "Pat Eyler" <rubypate@...> 2006/04/26

On 4/26/06, Brown, Warren <warrenbrown@aquire.com> wrote:

Re: possible defect in array.c

From: "Pat Eyler" <rubypate@...>
Date: 2006-04-26 16:15:24 UTC
List: ruby-core #7773
On 4/26/06, Jacob Fugal <lukfugl@gmail.com> wrote:
> On 4/26/06, Pat Eyler <rubypate@gmail.com> wrote:
> > 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.

More proof that I'm not a C hacker.  I did compile after making the
change and didn't see any errors from gcc:

$ make
gcc -g -O2  -DRUBY_EXPORT  -I. -I.  -c array.c
ar rcu libruby-static.a array.o ascii.o bignum.o class.o compar.o
dir.o dln.o enum.o enumerator.o error.o euc_jp.o eval.o file.o gc.o
hash.o inits.o io.o marshal.o math.o numeric.o object.o pack.o parse.o
process.o prec.o random.o range.o re.o regcomp.o regenc.o regerror.o
regexec.o regparse.o ruby.o signal.o sjis.o sprintf.o st.o string.o
struct.o time.o utf8.o util.o variable.o version.o  dmyext.o

and the tests looked good:
$ make test
test succeeded
$


So I didn't realize there was a problem.

> 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
>
>


In This Thread