Bruce Dubbs bruce.dubbs at
Mon Mar 15 21:36:58 PDT 2010

Mike McCarty wrote:

> The routine we tracked the problem down to
> had a McCabe cyclomatic complexity 'way over 1000. The upper limit
> for a routine which is maintainable is considered to be about 24
> or so. It had deeply nested switch() statements, with gotos which
> went between diffferent levels of separately nested switch()
> statements. It was unbelievable spaghetti. T

GOTO considered harmful - Dijkstra (Title by Wirth)

That is terrible.  I've seen worse, both very old code and relatively 
new code.  For instance, I recently (about 2008) had one function that 
was over 1000 lines long.  Some lines were over 200 characters in 
length.  Indentation levels went to at least 8, probably more.  Totally 
unmaintainable.  The author supposedly has a MSCS.  He doesn't work for 
us any more.

> Since that time, the FSF grep has supposedly been rewritten, so I
> can't specifically address it. However, if it is anything at all
> like it's predecessor, it is not, and cannot be, maintained.

I haven't looked at grep specifically, but I've found that free software 
has a great variance in code quality.  Some, like the kernel, are quite 
good.  Others try but don't quite 'get it'.  Still others are quite 
variable.  For instance, the Qt libraries are very well done.  The Qt 
utilities such as qmake, are not so good.  mysql is one of those that is 
OK, but not great.

A quick look at grep with wc shows:

   7899 ./lib/regex.c
   3634 ./src/dfa.c
   2284 ./src/grep.c
   1158 ./src/search.c
28876 total

That does not exude confidence to me.

   -- Bruce

More information about the lfs-support mailing list