[GRASS-dev] nvizlib compile error

Glynn Clements glynn at gclements.plus.com
Wed Jul 9 23:45:24 EDT 2008


Martin Landa wrote:

> > Now it compiles, but when I display the elevation map from the NC data set
> > and then chose the nviz tool in the map display, the entire wx gui
> > crashes...
> > Just found out why: it's a locale problem. LANG is set to fr_BE.UTF-8 on my
> > system. When I set it to C nviz runs (great job !!), but when I leave the
> > default setting, wxgrass crashes and I get the following error in the
> > terminal window where I launch g.gui:
> >
> > GRASS_INFO_ERROR(22238,1): région pour le jeu de données (mapset) courant
> > ligne 1: <n-s resol: 29.349241>
> >
> > GRASS_INFO_ERROR(22238,1): lancer "g.region"
> > GRASS_INFO_END(22238,1)
> 
> right, it crashes when LC_NUMERIC != "C",  calling G_scan_resolution()

LC_NUMERIC affects the format which scanf("%f") etc understands. If
it's set to a locale which uses a comma as the decimal separator, any
GRASS function which tries to read floating-point values which use a
period (i.e. many of GRASS' internal file formats) will fail.

This isn't a problem for normal GRASS modules, as GRASS modules (and
library functions) never call setlocale(LC_NUMERIC). It is a problem
if you're using GRASS library functions from within a program which
sets LC_NUMERIC from the environment (I suspect that this includes the
Python interpreter).

> http://trac.osgeo.org/grass/browser/grass/trunk/lib/gis/rd_cellhd.c#L258
> 
> quick fix
> 
> http://trac.osgeo.org/grass/changeset/32063

A more general fix would be to call setlocale(LC_NUMERIC,"C") from
e.g. gisinit() (in lib/gis/gisinit.c). Otherwise, we will probably end
up running into this issue repeatedly.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list