[GRASS-dev] [GRASS GIS] #173: v.in.ogr: truncate cnames to first word

#173: v.in.ogr: truncate cnames to first word
----------------------+-----------------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: minor | Milestone: 6.4.0
Component: default | Version: unspecified
Keywords: v.in.ogr |
----------------------+-----------------------------------------------------
If you (ahem) don't read the instructions properly and with v.in.ogr's
cnames= option provide column types with the new names it gets added into
the vector's dbln file as an extra word, corrupting it. (it writes "cat
integer" as the key column, but then after reads DB filename as the third
word in the dbln file, which is "integer" not $GISDBASE/...)

then you can't do much (even remove the vector) without fixing the dbln
file.

to protect against that...

v.in.ogr line 270:
{{{
     ncnames = 0;
     if ( cnames_opt->answers ) {
         i = 0;
         while ( cnames_opt->answers[i++] ) {
             ncnames++;
         }
     }
}}}

in that loop add some sort of
   strchrnul(cnames_opt->answers[i-1], ' ') = '\0';

to cut away all but the first word?
how to write that correctly?

Hamish

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/173&gt;
GRASS GIS <http://grass.osgeo.org>

#173: v.in.ogr: truncate cnames to first word
-------------------------+--------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: minor | Milestone: 6.4.0
Component: Default | Version: unspecified
Keywords: v.in.ogr | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Changes (by mmetz):

  * platform: => Unspecified
  * cpu: => Unspecified

Comment:

Replying to [ticket:173 hamish]:
> If you (ahem) don't read the instructions properly and with v.in.ogr's
cnames= option provide column types with the new names it gets added into
the vector's dbln file as an extra word, corrupting it. (it writes "cat
integer" as the key column, but then after reads DB filename as the third
word in the dbln file, which is "integer" not $GISDBASE/...)
>
> then you can't do much (even remove the vector) without fixing the dbln
file.
>
>
> to protect against that...
>
> v.in.ogr line 270:
{{{
      ncnames = 0;
      if ( cnames_opt->answers ) {
         i = 0;
         while ( cnames_opt->answers[i++] ) {
             ncnames++;
         }
      }
}}}
>
>
> in that loop add some sort of
> strchrnul(cnames_opt->answers[i-1], ' ') = '\0';
>
Fixed in trunk r52812 by adding G_strip() followed by G_strchg(). Works
for me now. To be backported.

Markus M

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/173#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#173: v.in.ogr: truncate cnames to first word
----------------------+-----------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: minor | Milestone: 6.4.4
Component: Vector | Version: unspecified
Keywords: v.in.ogr | Platform: All
      Cpu: All |
----------------------+-----------------------------------------------------
Changes (by hamish):

  * platform: Unspecified => All
  * component: Default => Vector
  * cpu: Unspecified => All
  * milestone: 6.4.0 => 6.4.4

Comment:

Replying to [comment:1 mmetz]:
> Fixed in trunk r52812 by adding G_strip() followed by G_strchg().
> Works for me now. To be backported.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/173#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#173: v.in.ogr: truncate cnames to first word
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: minor | Milestone: 6.4.3
Component: Vector | Version: unspecified
Resolution: fixed | Keywords: v.in.ogr
  Platform: All | Cpu: All
---------------------+------------------------------------------------------
Changes (by neteler):

  * status: new => closed
  * resolution: => fixed
  * milestone: 6.4.4 => 6.4.3

Comment:

Replying to [comment:2 hamish]:
> Replying to [comment:1 mmetz]:
> > Fixed in trunk r52812 by adding G_strip() followed by G_strchg().
> > Works for me now. To be backported.

Backported in r56069 and r56070. Closing.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/173#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>