[GRASS-dev] GRASS 7 development started

Glynn Clements glynn at gclements.plus.com
Thu Jul 31 19:04:59 EDT 2008


Markus Neteler wrote:

> >> Can we trap this? Otherwise we can run it locally and fix all warnings
> >> manually in SVN before running the global automated indenting.
> >
> > You can verify that the indentation isn't changing the semantics of
> > the code by compiling everything[1] without -g and with -DNDEBUG,
> > before and after indenting, and comparing the .o files.
> 
> Mhh, sounds like quite some work.

Not really:

	CFLAGS=-DNDEBUG CXXFLAGS=-DNDEBUG ./configure ...
	make
	find . -type f -name '*.o' | xargs md5sum > objects1.md5
	make clean
	tools/grass_indent_ALL.sh
	make
	find . -type f -name '*.o' | xargs md5sum > objects2.md5
	diff -u objects1.md5 objects2.md5

> > When I tried it on Linux with everything except MySQL, SQLite and
> > OpenDWG, I didn't find any mismatches. That probably accounts for 99%
> > of the code, so the chances are slim that there are any problems in
> > the fraction of the code which didn't get compiled.
> 
> You mean that you indented and compiled all successfully?
> So we can go ahead?

I have just tried again, and everything seems okay.

However, I had to manually revert the vdigit and r.terraflow headers,
as they contain C++, which indent can't handle.

Specifically, it doesn't understand template syntax; it thinks that
< and > are less-than and greater-than operators. More significantly,
where you have a nested template such as:

	std::vector<std::vector<int> >

it removes the space between the two closing angle brackets, leaving:

	std::vector < std::vector < int >>

which is a syntax error.

This issue only affects r.terraflow and vdigit. The other C++ modules
(i.atcorr and gui/wxpython/nviz) don't use nested templates, so the
problem doesn't arise. OTOH, it still introduces undesirable spaces,
so it's probably best to restore those headers as well, just for
cosmetic reasons.

The only object files which differ between pre- and post- indenting
are:

1. Those in the gem directory, due to gem/Makefile forcing -g. 
Recompiling with CFLAGS=-DNDEBUG results in object files which are
identical before and after indentation.

2. ccforest.o from r.terraflow (which isn't actually being indented
because it's C++). This is because the compiler generates a symbol of
the form:

	_GLOBAL__I_ccforest.cc_9D2164D3_AB435F14

where the last 8 hex digits appear to be random (deleting the file and
re-compiling it cause the digits to change with each compilation).

Comparing hex dumps of the ccforest.o files indicates that there are
no other differences.

IOW, so long as you don't indent the gui/wxpython/vdigit or
r.terraflow headers, the indentation is safe.

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


More information about the grass-dev mailing list