Store matches in a linked list, to avoid reading definition file twice.

Also avoids a possible race condition if the file is updated while
being read.
Reorder functions to avoid declarations and make private functions static.
cw.c: remove obsolete code dealing with borders.