3 # Copyright © 2008 Pierre Habouzit <madcoder@debian.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 /* This file is autogenerated by $(basename $0) */
37 test $# -gt 2 ||
break
39 -o) shift; out
="$1"; shift;;
40 -t) shift; type_t
="$1"; shift;;
48 #ifndef AWESOME_TOKENIZE_H
49 #define AWESOME_TOKENIZE_H
51 typedef enum awesome_token_t {
53 `tr '[:lower:]' '[:upper:]' | sed -e "s/^[^/].*/ A_TK_&,/"`
56 __attribute__((pure)) enum awesome_token_t a_tokenize(const char *s, int len);
66 echo "$tok, A_TK_`echo $tok | tr '[:lower:]' '[:upper:]'`"
73 which gperf
> /dev
/null
75 echo "gperf not found. You need to install gperf." > /dev
/stderr
;
79 gperf
-l -t -C -F",0" \
80 --language=ANSI-C
-Na_tokenize_aux <<EOF \
81 | sed -e '/__gnu_inline__/d;s/\<\(__\|\)inline\>//g'
86 #include "common/tokenize.h"
88 static const struct tok *a_tokenize_aux(const char *str, unsigned int len);
91 struct tok { const char *name; int val; };
96 awesome_token_t a_tokenize(const char *s, int len)
102 const struct tok *res = a_tokenize_aux(s, len);
103 return res ? res->val : A_TK_UNKNOWN;
112 grep '^### ' "$1" | cut
-d ' ' -f 2
119 trap "rm -f ${TARGET}" 0
123 *.h
) do_h
> "${TARGET}" < "${TOKENS_FILE}" ;;
124 *.c
) do_c
> "${TARGET}" < "${TOKENS_FILE}" ;;
125 *) die
"you must ask for the 'h' or 'c' generation";;