Page MenuHomeFreeBSD

libsysdecode: Teach mktables to handle enums
ClosedPublic

Authored by des on Wed, Jul 1, 11:12 AM.
Tags
None
Referenced Files
F162728557: D57993.id.diff
Thu, Jul 16, 5:25 AM
F162726310: D57993.id181175.diff
Thu, Jul 16, 4:55 AM
F162722933: D57993.id181176.diff
Thu, Jul 16, 4:13 AM
F162717565: D57993.id181179.diff
Thu, Jul 16, 2:57 AM
F162712920: D57993.id.diff
Thu, Jul 16, 1:51 AM
Unknown Object (File)
Wed, Jul 15, 7:28 AM
Unknown Object (File)
Wed, Jul 15, 7:28 AM
Unknown Object (File)
Tue, Jul 14, 10:56 PM
Subscribers

Details

Summary

While here, clean up and simplify the existing code.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Wed, Jul 1, 11:12 AM

hmm, given awk's limited regex syntax I think it would be better to process the exclusion using sed and use awk only to pick out enums.

jhb added inline comments.
lib/libsysdecode/mktables
57

Having filter be local so it doesn't get created in the global namespace is still nice.

108

s/TABLE_NAME/TABLE_START/? (Old bug I think)

125

I think the only thing here is that this doesn't permit named enums, only enum {\n... }. That's fine for now I guess, but at some point the regex might have to be relaxed to allow a valid C identifier between enum and the {.

des marked 2 inline comments as done.Wed, Jul 1, 12:59 PM
des added inline comments.
lib/libsysdecode/mktables
125

yes it does, the ([[:space:]].*)? bit takes care of that, and I added support for a leading typedef after you commented. I don't want to make it more specific than that because technically there could be attributes (e.g. enum_extensibility) between the enum keyword and the identifier.

des marked 2 inline comments as done.Wed, Jul 1, 1:00 PM

further simplify the original code

Thanks a lot! Didn't review the awk/sed code, since not an expert in it.

This revision is now accepted and ready to land.Wed, Jul 1, 2:43 PM
jhb added inline comments.
lib/libsysdecode/mktables
125

I had misread the regex as only matching whitespace. It is pretty generic as you note, but I agree that it's probably not tenable to be more specific than just requiring at least one space before any other non-space characters.

This revision was automatically updated to reflect the committed changes.

I've merged this to stable/15 but not stable/14 since it does not have the changes to <sys/socket.h> or <sys/netpfil/pf/pf_nl.h> which necessitated the change.