projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use enums, it's way better :)
[apps/madmutt.git]
/
lib-lua
/
lua-token.sh
diff --git
a/lib-lua/lua-token.sh
b/lib-lua/lua-token.sh
index
0cac016
..
17001f1
100644
(file)
--- a/
lib-lua/lua-token.sh
+++ b/
lib-lua/lua-token.sh
@@
-37,19
+37,28
@@
do_h() {
#ifndef MUTT_LIB_LUA_LUA_TOKEN_H
#define MUTT_LIB_LUA_LUA_TOKEN_H
#ifndef MUTT_LIB_LUA_LUA_TOKEN_H
#define MUTT_LIB_LUA_LUA_TOKEN_H
-enum lua_token {
- LTK_UNKNOWN,
-`tr 'a-z-/' 'A-Z__' | sed -e 's/.*/ LTK_&,/'`
-};
+typedef enum mlua_token {
+ LTK_UNKNOWN = -1,
+`grep_self "$0" | tr 'a-z-/' 'A-Z__' | sed -e 's/.*/ LTK_&,/'`
+ LTK_count,
+} mlua_token;
+
+extern const char *__mlua_token[LTK_count];
__attribute__((pure))
__attribute__((pure))
-
enum lua_token
lua_which_token(const char *s, ssize_t len);
+
mlua_token m
lua_which_token(const char *s, ssize_t len);
#endif /* MUTT_LIB_LUA_LUA_TOKEN_H */
EOF
}
#endif /* MUTT_LIB_LUA_LUA_TOKEN_H */
EOF
}
+do_tokens() {
+ while read tok; do
+ echo "$tok, LTK_`echo $tok | tr 'a-z-' 'A-Z_'`"
+ done
+}
+
do_c() {
do_c() {
- cat <<EOF | gperf -m16 -l -t -C -F",0" -Nlua_which_token_aux
+ cat <<EOF | gperf -m16 -l -t -C -F",0" -N
m
lua_which_token_aux
%{
`do_hdr`
%{
`do_hdr`
@@
-57,21
+66,25
@@
do_c() {
#include "lua-token.h"
static const struct tok *
#include "lua-token.h"
static const struct tok *
-lua_which_token_aux(const char *str, unsigned int len);
+
m
lua_which_token_aux(const char *str, unsigned int len);
%}
struct tok { const char *name; int val; };
%%
%}
struct tok { const char *name; int val; };
%%
-`
awk '{print $0 ", " NR }'
`
+`
grep_self "$0" | do_tokens
`
%%
%%
-enum lua_token lua_which_token(const char *s, ssize_t len)
+const char *__mlua_token[LTK_count] = {
+`grep_self "$0" | sed -e 's/.*/ "&",/'`
+};
+
+mlua_token mlua_which_token(const char *s, ssize_t len)
{
if (len < 0)
len = m_strlen(s);
if (len) {
{
if (len < 0)
len = m_strlen(s);
if (len) {
- const struct tok *res = lua_which_token_aux(s, len);
+ const struct tok *res =
m
lua_which_token_aux(s, len);
return res ? res->val : LTK_UNKNOWN;
} else {
return LTK_UNKNOWN;
return res ? res->val : LTK_UNKNOWN;
} else {
return LTK_UNKNOWN;
@@
-88,8
+101,8
@@
trap "rm -f $1" 1 2 3 15
rm -f $1
case "$1" in
rm -f $1
case "$1" in
- *.h)
grep_self "$0" |
do_h > $1;;
- *.c)
grep_self "$0" |
do_c > $1;;
+ *.h) do_h > $1;;
+ *.c) do_c > $1;;
*) die "you must ask for the 'h' or 'c' generation";;
esac
chmod -w $1
*) die "you must ask for the 'h' or 'c' generation";;
esac
chmod -w $1
@@
-97,6
+110,46
@@
chmod -w $1
exit 0
############ Put tokens here ############
exit 0
############ Put tokens here ############
+## alias_file
+## alias_format
+## ask-no
+## ask-yes
+## assumed_charset
+## beep
+## beep_new
+## bindir
+## charset
+## docdir
## dotlock
## dotlock
+## dsn_notify
+## dsn_return
+## editor
+## envelope_from_address
+## file_charset
+## from
+## gecos_mask
+## hcache_backend
+## homedir
+## hostname
+## mailcap_path
+## mailcap_sanitize
+## mail_check
+## no
+## operating_system
+## quit
+## record
+## send_charset
## sendmail
## sendmail
+## sendmail_wait
## shell
## shell
+## shorthost
+## signature
+## spam_separator
+## sysconfdir
+## tmpdir
+## use_8bitmime
+## use_domain
+## use_envelope_from
+## username
+## version
+## yes