summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2002-02-06 08:58:56 +0000
committerThomas Roessler <roessler@does-not-exist.org>2002-02-06 08:58:56 +0000
commit866759060c591a194de82d5b6061da7a1f7e4d0f (patch)
tree67b0555478a14a42177fe90461d546ef8e76eea5 /lib.h
parent0ccf694bc52463e68a077ce7bac78487a43932a1 (diff)
Make some scanf formats safe.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index c6d5c271..d8d21bc2 100644
--- a/lib.h
+++ b/lib.h
@@ -64,6 +64,17 @@
# define STRING 256
# define SHORT_STRING 128
+/*
+ * Create a format string to be used with scanf.
+ * To use it, write, for instance, MUTT_FORMAT(HUGE_STRING).
+ *
+ * See K&R 2nd ed, p. 231 for an explanation.
+ */
+# define _MUTT_FORMAT_2(a,b) "%" ## a ## b
+# define _MUTT_FORMAT_1(a, b) _MUTT_FORMAT_2(#a, b)
+# define MUTT_FORMAT(a) _MUTT_FORMAT_1(a, "s")
+# define MUTT_FORMAT2(a,b) _MUTT_FORMAT_1(a, b)
+
# define FREE(x) safe_free((void **)x)
# define NONULL(x) x?x:""
# define ISSPACE(c) isspace((unsigned char)c)