[GRASS-dev] Some questions about standardization

Wolf Bergenheim wolf+grass at bergenheim.net
Tue Jul 3 01:27:34 EDT 2007


On 02.07.2007 20:04, Carlos Dávila wrote:
> 
> I need some help to continue with further changes. As I'm not programmer
> I don't know well what can be changed in code and what can't, so I ask
> you some cases:
> a) %s: can't open tempfile -> Unable to open temporary file <%s> (does
> it affect where is the %s?)

No, except as long as it doesn't pass another %-expression (which it
doesn't in this case). %s is replaced with the next string given in the
parameter list (the variable names after the ','). Actually it is
replaced with the value of the next argument treated as a char pointer.
So if the next value is an integer with the value of 5 then the 5 is
treated as a pointer and tries to read memory at location 5 which will
result in a crash.

> b) can't open raster map <%s> in mapset %s -> Unable to open raster map
> <%s> (Can I drop last %s without problems?)

No you can't. You also need to drop the third argument which is the mapset.

> c) How can I pass from "Unable to open the temporary file." to "Unable
> to open temporary file <%s>"? E.g. from /display/d.text.freetype/main.c:
> 
> tmpfile = G_tempfile();
>        if(!(fp = fopen(tmpfile, "w")))
>            error(_("Unable to write the temporary file"));
> 

Do this:
	tmpfile = G_tempfile();
	if(!(fp = fopen(tmpfile, "w")))
	    error(_("Unable to write temporary file <%s>"), tempfile);

--Wolf

-- 

<:3 )---- Wolf Bergenheim ----( 8:>




More information about the grass-dev mailing list