LGTM.  I can't come up with any credible case where that would fail
badly.  I suppose if someone wanted SHMOOZHz that would be okay albeit
weird.  One would normally expect a limited number of things before the
H, but I don't think we need be concerned about that.
I first considered making the code more complicated, rather than
simpler, by specifically checking for Hz to be preceded by:
* Numeric
* Underscore
* K, M, G

But I think we're looking for accidental violations, not someone
trying to be a wise guy.

And there could be legitimate reasons why the character preceding the H is something unanticipated but completely reasonable, FREQHz for example.  I think you cut the problem done to the bone and there is no need to make it more complex.

On the other hand, I don't worry about efficiency in nxstyle.  It will never be a performance bottleneck.  So it is better to keep things simple and straightforward vs. obtuse and optimized.

Were you seeing complaints on MHz in the past?  That one should not have generated a complaint.

You should feel free to just modify nxstyle at any time you like.  It is really brain-dead code.  It is mostly one big function (called main()) and just works with lots of flags.  And that one big function is just one big loop that examines each line.  Most things are very simple, but can become complex only because they are in a long sequence of inline logic.

The only tricky thing I have run into is with all of the flags (and line numbers which are treated like flags).  Since the logic to pass through one line from the source file is long, logic later in the pass might expect a flag to be set, but is not set until later in the pass.  So there is some complexity in ordering. There is a little bit of state information that causes it to behave differently depending on the current state.  Bad state-dependent handling is a frequent source of problems too.

Otherwise, it truly is brain dead code.  It knows nothing about overall C grammar.

I started out life a a tiny, ad hoc program to help me review code and then became indispensable.  It was never designed; it just evolved.

Greg



Reply via email to