ntpq quirk

Achim Gratz Stromeko at nexgo.de
Mon Nov 28 20:54:42 UTC 2016


Mark Atwood writes:
> I was on a project years ago that did that (minimal length matching of
> command strings).
>
> Someone on team dug up an amazing little utility that ingested a list of
> strings, and emitted a human-unreadable table-driven maximally efficient C
> function that implemented some computer science magic state machine
> character parser that took as a parameter char* and returned a integer or
> enum that designated one of the target strings that was minimal matched by
> the input.
>
> We then made running this code generator a Makefile production, and
> compiled the generator itself as another dependent Makefile production.
>
> I'm struggling now to remember it's name...

I wouldn't be too surprised if it was gperf or gengetopt, although at
one point in time several such implementations made their rounds.

https://www.gnu.org/software/gperf/
https://www.gnu.org/software/gengetopt/gengetopt.html

The general solution to this problem is to build a trie, but in this
case pre-computing a hash table from all possible unique input strings
is probably easier, all things considered.  I'm pretty sure Python has a
shortest unique prefix matcher already somewhere in the options parser,
just like about anybody else.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf rackAttack:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds



More information about the devel mailing list