dnl This file is part of GNU Rush. dnl Copyright (C) 2007, 2008, 2009, 2010 Sergey Poznyakoff. dnl dnl GNU Rush is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 3, or (at your option) dnl any later version. dnl dnl GNU Rush is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with GNU Rush. If not, see . divert(-1) changequote([<,>]) changecom(/*,*/) dnl upcase(ARGS...) dnl Concatenate and convert ARGS to upper case. dnl define([], [], [], [])>]) dnl concat(ARGS...) dnl Concatenate arguments, inserting ", " between each of pair of them. dnl define([],[],1,[<$1>],[<$1, concat(shift($@))>])>]) dnl flushleft(ARGS...) dnl Concatenate ARGS and remove any leading whitespace dnl define([], [], [<^[ ]+>])>]) dnl chop(ARGS...) dnl Concatenate ARGS and remove any trailing whitespace dnl define([], [], [<[ ]+$>])>]) dnl escape(ARGS...) dnl Concatenate ARGS and escape any occurrences of double-quotes with dnl backslashes. dnl define([], [],[<[\"]>],[<\\\&>])>]) dnl prep(ARG) dnl Prepare ARG for including in C strings: replace newlines with any amount dnl of preceding and following whitespace by a single space character, remove dnl leading whitespace, and escape double-quotes. dnl define([], [],[<[ ]* +[ ]*>],[< >])))>]) dnl SHORT_OPTS dnl Accumulator for the 3rd argument of getopt_long dnl define([],[<>]) dnl GROUP(STRING) dnl Begin a named group of options dnl define([],[])") }, divert(-1)>]) define([<__GATHER_OPTIONS>],[< define([],ifelse([<$2>],,[]upcase(patsubst($1,-,_)),'$2')) ifelse([<$2>],,[< divert(1) KEY, divert(-1) >]) define([],ifdef([],SELECTOR) case KEY:) ifelse([<$1>],,,[< divert(2) { "$1", ARGTYPE, 0, KEY }, divert(-1)>]) dnl define([],SHORT_OPTS[<>]dnl ifelse([<$2>],,,$2[<>]ifelse(ARGTYPE,[],,ARGTYPE,[],:,ARGTYPE,[],::))) dnl ifelse([<$1>],,,dnl [],ifelse(LONG_TAG,,[<--$1>],[]))>]) ifelse([<$2>],,,dnl [],ifelse(SHORT_TAG,,[<-$2>],[]))>]) >]) dnl OPTION(long-opt, short-opt, [arg], [descr]) dnl Introduce a command line option. Arguments: dnl long-opt Long option. dnl short-opt Short option (a single char) dnl (At least one of long-opt or short-opt must be present) dnl dnl Optional arguments: dnl arg Option argument. dnl descr Option description dnl dnl If arg is absent, the option does not take any arguments. If arg is dnl enclosed in square brackets, the option takes an optional argument. dnl Otherwise, the argument is required. dnl dnl If descr is not given the option will not appear in the --help and dnl --usage outputs. dnl define([