[GRASS5] Some news: KerGIS
tlaronde at polynum.com
Sat Jan 24 09:08:14 EST 2004
Some may wonder, after the discussions held in the late november, if I
have made some vaporware announces and if actually something is done.
Short answer: YES.
Long answer follows...
In the end of November 2003 I have decided that it was more easy to
start from scratch from the last CERL public release of the public
domain GRASS than to start to reorganize and fix the code in the current
The reasons are the following:
- CERL GRASS was developped by a very small core team, focusing on
general programs and functions, and having explicit goals. That is:
this code was consistent. So it is far more easy to evolve a
consistent, "small" code, than to try to fix code gathered from
distinct sources, not having the same goals nor skills, and
developping for customed applications with no overview in mind.
- to make the code evolve, one needs an overview. The same premises
lead to the same conclusion: more easy to gain this overview with
the smallest set of consistent code.
1. State after 2 months (calendar) -- 1 month (real coding time)
My premises were correct. Indeed the code is consistent. "Old" i.e. pre
C standardization, yes ---and this is a pain by itself. But the project
conducted by Michael Shapiro and Dave Gerdes _was_ conducted, and they
have anticipated a great deal about things that were not obvious to
many by the time.
The fact that GRASS (and indeed, until very recently _this_ GRASS) is
still here is due to this far-sighted leading. It's normal that after
more than ten years, the same code is no more far-sighted... but this
can be in no way attributed to its creators, but to _us_ who have made
nothing of this stuff.
There are places ---mainly with the vector code--- where some
disorganization is found. But this is because all was under construction
or under reorganization. There are a lot of TODO, and some duplication
of code that have conducted Dave Gerdes to plan to strenghten the code
(creation of the digitizer library, reorganization of the digitizing
stuff with incorporation of LTPlus and so on).
=> I have fixed these while fixing the code and put the libraries
where they belong and created, for example, the digitizer library.
So after this time, and after fixing the things explained in details
after (in short, standard C and POSIX, fix the code ---so there
is no more warnings from the compiler--- first reorganization), _all_
the libraries of the not X code, all the programs from general, display,
fonts, vector are UP and RUNNING, fixed and compile with:
COMPILE_FLAGS = -O -fno-builtin -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror
except one (newly created file) defining the new function G_read_line
which replaces the limited and unsafe G_gets, with dynamic allocation of
memory to absorb a not limited line and handling signals, since I use a
non local goto and gcc issues a non pertinent warning [gcc is a great
tool, it's just unfortunate that one can not specify to not stop on
Here is the list:
2. Fixing: Goals and Method
I want the code to compile smoothly on any standard C and POSIX
platform. This is a portability goal, but a consistency one too: the
standard C prototypes are the correct way to ensure that the functions
are used the way they are designed to be [and I have actually found
programs where this was not the case!]
The implication are simple: support of TERMIOS and that's all, no
support for the deprecated and not portable setruid(3) and setrgid(3).
The method was the following.
First, since the amount of work is huge, I have started by discarding
all the code that was obsolete or useless. By principe, I have kept all
the CERL code, and review first the contrib sources. The result is that
I have discarded everything in the contrib sources ---limited use,
licence problems, poor coding--- but general programs found in
I have only kept devices that I plan to use: i.e. PostScript for
hardcopy, X for display.
This was the first simplification.
While fixing the code I have made further ones, deleting junks
(including a SPARC core dump file!), backup, saved,
duplicates, unused (and useless) files and kept only 1 version, the
latest one (if there are problems in the latest ones, this needs to be
fixed but it is useless to keep all the others).
If I found a program whose utility was doubtful AND poorly coded I have
saved it in my unlimited storage device: /dev/null.
Further more, I have kept only the "cmd" version, since the huge
majority of the programs already used the parser. So the files of the
program live now directly under its subdirectory and not in the
<program>/cmd. If the "interactive" version was totally different from
the "cli" one, i have created a new program: example (sole one at the
moment) g.region, where the "interactive" version is a menu driven one
=> creation of g.menu.region.
THERE IS NO MORE MAKELINKS DANCE.
If I found _inside a file_, unused portions of code I have deleted them
if they were useless, or resurrected portions that were usefull ones.
-> There were functions handy to identify (debug) one particular
element (and I was planning to modify the code to support this)
-> There was one SCS extension usefull to everybody (Snap to line)
Note: the original version do the Zoom is more handy and powerful
than the present ones (can widen the window i.e. see the whole map
with the portion presently displayed and can define a new zone)
=> this "original" version of v.digit is more handy than the
In mode details
At the present no changes are attempted in this area so no bugs are
introduced while trying to suppress the old ones.
To ease the maintainance, there must be some style and some naming
conventions: I have modified the names so that a library is identified
clearly by a conventional prefix (gis had G_, I have created DZ_ for the
digitizer libray, B_ for the build one and so on).
General functions put in userland programs have been extracted from the
programs and put back in their libraries.
A first attempt has been made to avoid circular dependices between
libraries, and for example certain functions in GISLIB using VASKLIB
have been extracted and renammed and put back in VASKLIB, the goal
being, too, to avoid the ABAB dance when linking libraries with
Headers have been created and standardized too with a common naming
scheme and so on.
Libraries and headers have been gathered in the correct places i.e. in
A common style is defined (beginning) for the name of files, headers,
the use of general functions (DEBUGF) and so on.
"Early optimizations are the root of all evil".
Since I wanted to start by fixing the old code, I have, initially,
refrained from doing optimizations.
But I have finally decided to do the obvious ones (so obvious that these
should not imply new bugs).
The main optimizations are macros replacing functions simply calling
another function (without sharing static variables not accessible from
extern), and the suppression of GIS functions simply mimicking (with
limitations...) standard C ones (G_*alloc, string manipulations
functions). [not to mention in the case of the memory allocation that
some day one will want to "improve" them by doing a custom management,
and that programs were happily mixing G_*alloc with *alloc and free...]
AFTER THE FIRST TESTS, THESE SIMPLE OPTIMIZATIONS HAVE ALREADY
LED TO SPEED IMPROVMENTS
G_gets has been replaced with the secure (newly created) G_read_line
But the code remains unsafe, since there are a lot of sprintf spread all
around that don't limit nor check the amount of data they put in the
3. Future directions
I will continue to fix the code in this order:
and finally xgrass.
In the mean time (since the work is mainly boring, I need to have some
more exciting coding stuff) I will start developping new applications
in the DB field (where I keep strictly nothing).
Things to be fixed:
XDRIVER: only handle 8 bits depth -> improved, with GLX support
The combination is standard C, POSIX, X, GLX and Motif for the X
The goals are always:
0. Consistency, primitives not policies
4. The name of the game
At the moment, BSD style one. The first public release will be done when
the code is fixed and the source tree reorganized.
To be continued...
Thierry Laronde (Alceste) <tlaronde at polynum.org>
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
More information about the grass-dev