utils/macros.h: Add <ctype.h> and `foocmp' helper macros.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 1 Oct 2019 17:41:17 +0000 (18:41 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 8 May 2020 12:44:29 +0000 (13:44 +0100)
commit3618811496a6d131fd4bffa19e262c521d39e819
tree640c04f64f3bd46a25ff81910351b9b0fb9245ae
parent776d2da28318443431563b68c2807eb0c29c49fa
utils/macros.h: Add <ctype.h> and `foocmp' helper macros.

Both of these have been a nuisance for years.  Do something about it.

The command

git grep -En '\<(is|to)[a-z]+\(|\<(str|mem)[a-z]*cmp\(' -- '*.[ch]'

finds code which it might be good to change.

The hairy Emacs command

(query-replace-regexp
 "\\<\\(\\(str\\|mem\\)\\sw*cmp\\)(\\([^,]*\\), \\([^)]*\\)) \\(==\\|!=\\|<\\|<=\\|>\\|>=\\) 0"
 '(replace-eval-replacement
   . (concat (replace-quote (upcase (match-string 1)))
     "(\\3, \\5, \\4)"))
 nil
 (if (and transient-mark-mode mark-active) (region-beginning))
 (if (and transient-mark-mode mark-active) (region-end))
 nil)

will convert easy cases of `foocmp' calls, but hard ones have to be done
by hand.
22 files changed:
codec/baseconv.c
codec/bincode.c
codec/url.c
hash/crc-mktab.c
hash/unihash-mkstatic.c
sel/bres-adns.c
sel/ident.c
struct/dstr-putf.c
struct/sym.c
struct/t/assoc-test.c
struct/t/da-test.c
struct/t/dstr-putf-test.c
struct/t/sym-test.c
sys/t/fdpass-test.c
sys/t/mdup-test.c
test/testrig.c
trace/trace.c
trace/traceopt.c
utils/macros.3
utils/macros.h
utils/str.c
utils/versioncmp.c