[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes to m4/m4/utility.c,v
From: |
Eric Blake |
Subject: |
Changes to m4/m4/utility.c,v |
Date: |
Tue, 14 Nov 2006 05:58:03 +0000 |
CVSROOT: /sources/m4
Module name: m4
Changes by: Eric Blake <ericb> 06/11/14 05:58:01
Index: m4/utility.c
===================================================================
RCS file: /sources/m4/m4/m4/utility.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- m4/utility.c 11 Nov 2006 14:00:28 -0000 1.55
+++ m4/utility.c 14 Nov 2006 05:58:01 -0000 1.56
@@ -115,6 +115,31 @@
}
}
+
+/* Parse ARG as a truth value. If unrecognized, issue a warning on
+ behalf of ME and return PREVIOUS; otherwise return the parsed
+ value. */
+bool
+m4_parse_truth_arg (m4 *context, const char *arg, const char *me,
+ bool previous)
+{
+ /* 0, no, off, blank... */
+ if (!arg || arg[0] == '\0'
+ || arg[0] == '0'
+ || arg[0] == 'n' || arg[0] == 'N'
+ || ((arg[0] == 'o' || arg[0] == 'O')
+ && (arg[1] == 'f' || arg[1] == 'F')))
+ return false;
+ /* 1, yes, on... */
+ if (arg[0] == '1'
+ || arg[0] == 'y' || arg[0] == 'Y'
+ || ((arg[0] == 'o' || arg[0] == 'O')
+ && (arg[1] == 'n' || arg[1] == 'N')))
+ return true;
+ m4_warn (context, 0, _("%s: unknown directive `%s'"), me, arg);
+ return previous;
+}
+
/* Issue an error. The message is printf-style, based on FORMAT and
any other arguments, and the program name and location (if we are
currently parsing an input file) are automatically prepended. If