Opened 16 years ago

Closed 11 years ago

#173 closed defect (fixed)

v.in.ogr: truncate cnames to first word

Reported by: hamish Owned by: grass-dev@…
Priority: minor Milestone: 6.4.3
Component: Vector Version: unspecified
Keywords: v.in.ogr Cc:
CPU: All Platform: All

Description

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

Change History (3)

in reply to:  description ; comment:1 by mmetz, 12 years ago

CPU: Unspecified
Platform: Unspecified

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

in reply to:  1 ; comment:2 by hamish, 11 years ago

Component: DefaultVector
CPU: UnspecifiedAll
Milestone: 6.4.06.4.4
Platform: UnspecifiedAll

Replying to mmetz:

Fixed in trunk r52812 by adding G_strip() followed by G_strchg(). Works for me now. To be backported.

in reply to:  2 comment:3 by neteler, 11 years ago

Milestone: 6.4.46.4.3
Resolution: fixed
Status: newclosed

Replying to hamish:

Replying to 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.

Note: See TracTickets for help on using tickets.