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 'a-z-./ ' 'A-Z____' | 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 'a-z-./ ' 'A-Z____'`"
73 if ! which gperf
> /dev
/null
; then
74 echo "gperf not found. You need to install gperf." > /dev
/stderr
;
78 cat <<EOF | gperf -l -t -C -F",0" \
79 --language=ANSI-C -Na_tokenize_aux \
80 | sed -e '/__gnu_inline__/d;s/\<\(__\|\)inline\>//g'
85 #include "common/tokenize.h"
87 static const struct tok *a_tokenize_aux(const char *str, unsigned int len);
90 struct tok { const char *name; int val; };
95 awesome_token_t a_tokenize(const char *s, int len)
101 const struct tok *res = a_tokenize_aux(s, len);
102 return res ? res->val : A_TK_UNKNOWN;
111 grep '^### ' "$1" | cut
-d ' ' -f 2
118 trap "rm -f ${TARGET}" 0
122 *.h
) cat "${TOKENS_FILE}" | do_h
> "${TARGET}";;
123 *.c
) cat "${TOKENS_FILE}" | do_c
> "${TARGET}";;
124 *) die
"you must ask for the 'h' or 'c' generation";;