[GRASS5] [bug #1023] (grass) v.extract again

this bug's URL: http://intevation.de/rt/webrt?serial_num=1023
-------------------------------------------------------------------------

Neteler:

I'm need v.extract again and it doesn't work.

I think that the problems are:

int cat_array[5000]; declare array of 5000 cat

but all the loop's like

for (i = 0; listopt->answers[i]; i++)
{
scan_names (&cats, listopt->answers[i], &x);
cat_array[cat_index] = x;
cat_index++;
}

or

while (1)
{
  if (!fgets (buffr, 39, in)) break;
  sscanf (buffr, "%[a-zA-Z., -_/$%@!#0-9]", text);
  /*sscanf (buffr, "%s", text); */
  /*scan %s stops at whitespace?*/
  scan_names (&cats, text, &x);
  cat_array[cat_index] = x;
  cat_index++;
}

or

while (x <= y)
{
cat_array[cat_index] = x++;
cat_index++;
}

and others don't check the max of the cat_array array (5000). I'm working with a small area of my country (I'm live at Uruguay a small country in South America). I have more than 5000 lines to extract then I recieve segmentation fault message. I think put categories to extract in a array It's a bad idea.

To set the number of categories the program use
recd = pcats->num;
I think this is the numbrer of the max. categorie, but not number of categories. The code must be:
recd = pcats->ncats;
I debug another errors but I don't now what happend yet.
I don't have to much time to fix this errors (I'm a Civil Environment-Hydraulic Engineer not a programmer) but I'll try.
Thank you for your time. Fernando Pacheco.
P.D. -> Since 01/May/2002 where are mirror site of grass at http://www.dinama.gub.uy/grass/.

--- Headers Follow ---

From neteler@itc.it Fri Apr 19 17:03:29 2002

Return-Path: <neteler@itc.it>
Delivered-To: grass-bugs@lists.intevation.de
Received: from mail.intevation.de (aktaia [212.95.126.10])
  by lists.intevation.de (Postfix) with ESMTP id 0585C13965
  for <grass-bugs@lists.intevation.de>; Fri, 19 Apr 2002 17:03:28 +0200 (CEST)
Received: from camelot.itc.it (camelot.itc.it [195.223.171.5])
  by mail.intevation.de (Postfix) with ESMTP id D45E71B6D6
  for <grass-bugs@intevation.de>; Fri, 19 Apr 2002 17:03:27 +0200 (CEST)
Received: from orchestra.itc.it (orchestra [10.0.10.11])
  by camelot.itc.it (8.11.3/8.11.3) with ESMTP id g3JF3Rn29840
  for <grass-bugs@intevation.de>; Fri, 19 Apr 2002 17:03:27 +0200 (MET DST)
Received: from thuille.itc.it. (thuille [10.40.0.110])
  by orchestra.itc.it (8.11.6/8.11.6) with ESMTP id g3JF3KK16999
  for <grass-bugs@intevation.de>; Fri, 19 Apr 2002 17:03:20 +0200
Received: (from neteler@localhost)
  by thuille.itc.it. (8.11.6/8.11.2) id g3JF3KV07869
  for grass-bugs@intevation.de; Fri, 19 Apr 2002 17:03:20 +0200
Resent-Message-Id: <200204191503.g3JF3KV07869@thuille.itc.it.>
Received: from camelot.itc.it (camelot [195.223.171.5])
  by orchestra.itc.it (8.11.6/8.11.6) with ESMTP id g38CrWK06239
  for <neteler@itc.it>; Mon, 8 Apr 2002 14:53:32 +0200
Received: from rigel.dinama.gub.uy ([200.40.77.185])
  by camelot.itc.it (8.11.3/8.11.3) with ESMTP id g38CrOn10173
  for <neteler@itc.it>; Mon, 8 Apr 2002 14:53:30 +0200 (MET DST)
Received: from [200.40.77.186] (helo=mafalda)
  by rigel.dinama.gub.uy with smtp (Exim 3.34 #1 (Debian))
  id 16uVtx-00046o-00
  for <neteler@itc.it>; Mon, 08 Apr 2002 06:57:29 -0300
Date: Mon, 8 Apr 2002 10:28:50 -0300
From: "Ing. Civil H/A Fernando Pacheco" <fpacheco@dinama.gub.uy>
To: neteler@itc.it
Subject: v.extract again
Message-Id: <20020408102850.2facf838.fpacheco@dinama.gub.uy>
Organization: Direcci
X-Mailer: Sylpheed version 0.7.4 (GTK+ 1.2.10; i386-debian-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Resent-From: neteler@itc.it
Resent-Date: Fri, 19 Apr 2002 17:03:20 +0200
Resent-To: grass-bugs@intevation.de
X-Spam-Status: No, hits=0 required=5 tests=SUPERLONG_LINE

-------------------------------------------- Managed by Request Tracker

Request Tracker wrote:

I'm need v.extract again and it doesn't work.

I think that the problems are:

int cat_array[5000]; declare array of 5000 cat

I've committed a fix which re-allocates the array as necessary.

To set the number of categories the program use
recd = pcats->num;

I think this is the numbrer of the max. categorie, but not number of
categories. The code must be:

recd = pcats->ncats;

I'm not sufficiently familiar with category handling to be sure; can
anyone else comment on this?

--
Glynn Clements <glynn.clements@virgin.net>

On Fri, Apr 19, 2002 at 08:16:53PM +0100, Glynn Clements wrote:

Request Tracker wrote:

> I'm need v.extract again and it doesn't work.
>
> I think that the problems are:
>
> int cat_array[5000]; declare array of 5000 cat

I've committed a fix which re-allocates the array as necessary.

> To set the number of categories the program use
> recd = pcats->num;
>
> I think this is the numbrer of the max. categorie, but not number of
> categories. The code must be:
>
> recd = pcats->ncats;

I'm not sufficiently familiar with category handling to be sure; can
anyone else comment on this?

"num" is highest category number, "ncats" is total number of entries.
Sounds like it should be "ncats". Category numbers certainly don't
have to be continuous.

--
Eric G. Miller <egm2@jps.net>

Eric G. Miller wrote:

> > To set the number of categories the program use
> > recd = pcats->num;
> >
> > I think this is the numbrer of the max. categorie, but not number of
> > categories. The code must be:
> >
> > recd = pcats->ncats;
>
> I'm not sufficiently familiar with category handling to be sure; can
> anyone else comment on this?

"num" is highest category number, "ncats" is total number of entries.
Sounds like it should be "ncats". Category numbers certainly don't
have to be continuous.

OK, fixed.

--
Glynn Clements <glynn.clements@virgin.net>