Follow-up Comment #17, bug #64018 (project groff): [comment #15 comment #15:] > I regret that the implementation language makes _groff_ so stinky for people. Having seen the problems it was solving, I can understand why Clark selected it over the just-born ANSI C. It's much closer to applications programming than systems programming, and C++ had much promise there. Of course Stroustrup promoted as the best language for everything. :-/ > > From today's perspective, in _groff_ there are huge amounts of data-structure walking code that could be replaced by C++98 "algorithms" (they _are_, but God the name assaults the nose like a bottle of brogrammer patchouli oil), or cleanly replaced by C++11 idioms. > > I get the feeling that Clark ended up not doing as much input validation as he might simply because it was so incredibly tedious to walk data structures. > > Here's a recent example of some validation I added, with annotations of future possibilities. >
> bool is_family_valid(const char *fam) > { > // std::vector<const char *> styles{"R", "I", "B", "BI"}; // C++11 > const size_t nstyles = 4; > const char *st[nstyles] = { "R", "I", "B", "BI" }; > std::vector<const char *> styles(st, (st + nstyles)); > // for (auto style : styles) // C++11 > std::vector<const char *>::iterator style; > for (style = styles.begin(); style != styles.end(); style++) > if (!check_font(fam, *style)) > return false; > return true; > } > > C++11 would cut this function about in half. Of course, the whole thing is pure bloat from an Annotated Reference Manual C++ perspective, where'd you skip all this ridiculous validation entirely because what could go wrong? The ARPAnet is such a friendly place... > Wow! You can cut that in half in C. #define lengthof(a) (sizeof(a) / sizeof((a)[0])) bool is_family_valid(const char *fam) { static const char st[][3] = { "R", "I", "B", "BI" }; for (size_t i = 0; i < lengthof(st); i++) { if (!check_font(fam, st[i])) return false; } return true; } _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?64018> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/