* remove old lib-lua cruft.
* make luapkg2c support bool type.
* make luapkg2c support C bit-fields.
* import beep{,_new}, and hcache_backend.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
** unset, you must first use the ``tag-prefix'' function (default: "\fT;\fP") to
** make the next function apply to all tagged messages.
*/
- {"beep", DT_BOOL, R_NONE, OPTBEEP, "yes" },
- /*
- ** .pp
- ** When this variable is \fIset\fP, Madmutt will beep when an error occurs.
- */
- {"beep_new", DT_BOOL, R_NONE, OPTBEEPNEW, "no" },
- /*
- ** .pp
- ** When this variable is \fIset\fP, Madmutt will beep whenever it prints a message
- ** notifying you of new mail. This is independent of the setting of the
- ** ``$$beep'' variable.
- */
{"bounce", DT_QUAD, R_NONE, OPT_BOUNCE, "ask-yes" },
/*
** .pp
liblua_a_DEPENDENCIES = madmutt.h
liblua_a_SOURCES = madmutt.cpkg \
- lib-lua.h lib-lua_priv.h \
+ lib-lua.h \
runtime.c \
$(BUILT_SOURCES)
-noinst_HEADERS = lib-lua.h lib-lua_priv.h
+noinst_HEADERS = lib-lua.h
lua-token.c lua-token.h: lua-token.sh
sh $< $@ || (rm -f $@; exit 1)
+++ /dev/null
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * Copyright © 2007 Pierre Habouzit
- */
-
-#ifndef MUTT_LIB_LUA_LIB_LUA_PRIV_H
-#define MUTT_LIB_LUA_LIB_LUA_PRIV_H
-
-#include "lib-lua.h"
-
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-
-typedef struct reg_entry {
- int type;
- union {
- int i;
- char *s;
- };
-} reg_entry;
-
-
-#endif
exit 0
############ Put tokens here ############
+## beep
+## beep_new
## bindir
## docdir
## dotlock
## editor
+## hcache_backend
## quit
## sendmail
## shell
if (/^\s*\.(push|kind|ctype|check)\s*=\s*(.*?)\s*;\s*$/) {
$t{$1} = $2;
if ($1 eq "kind") {
- if ($2 =~ /^'([si])'$/) {
+ if ($2 =~ /^'([bis])'$/) {
$t{kind} = $1;
} else {
- fatal($src, "error: .kind should be 'i' or 's' got $2)");
+ fatal($src, "error: .kind should be [ibs] got $2)");
}
}
} elsif (!/^\s*$/) {
fatal($src, "incomplete type $type: missing .$i") unless defined $t{$i};
}
unless (defined $t{check}) {
- if ($t{kind} eq 's') {
- $t{check} = 'luaL_checkstring($L, $$)';
+ if ($t{kind} eq 'b') {
+ $t{check} = '(luaL_checkint($L, $$) == 0)';
}
if ($t{kind} eq 'i') {
- $t{check} = 'luaL_checkint($l, $$)';
+ $t{check} = 'luaL_checkint($L, $$)';
+ }
+
+ if ($t{kind} eq 's') {
+ $t{check} = 'luaL_checkstring($L, $$)';
}
}
+ $t{ctypefmt} .= ' %s' unless (($t{ctypefmt} = $t{ctype}) =~ s/:/ \%s :/);
+ $t{ctype} =~ s/:.*//;
+
return $types{$type} = \%t;
}
$call =~ s/\$\$/$t{type}->{push}/;
}
+ if ($t{type}->{kind} eq 'b') {
+ put_line($f, 0);
+ print " lua_pushboolean(L, $call);\n";
+ }
+
+ if ($t{type}->{kind} eq 'i') {
+ put_line($f, 0);
+ print " lua_pushint(L, $call);\n";
+ }
+
if ($t{type}->{kind} eq 's') {
if ($t{const}) {
put_line($f, 0);
}
}
- if ($t{type}->{kind} eq 'i') {
- put_line($f, 0);
- print " lua_pushint(L, $call);\n";
- }
-
printf " return %d;\n", ($f->{type} ne "void");
print "}\n";
}
put_line($p, 0);
print " $p->{init},\n";
} else {
+ print " 0,\n" if ($t{type}->{kind} eq 'b');
print " 0,\n" if ($t{type}->{kind} eq 'i');
print " NULL,\n" if ($t{type}->{kind} eq 's');
}
next if $t{const};
put_line($p, 0);
- print " m_strreplace(&$var, $p->{init});\n" if ($t{type}->{kind} eq 's');
+ print " $var = $p->{init};\n" if ($t{type}->{kind} eq 'b');
print " $var = $p->{init};\n" if ($t{type}->{kind} eq 'i');
+ print " m_strreplace(&$var, $p->{init});\n" if ($t{type}->{kind} eq 's');
}
print "};\n";
};
foreach (@{$pkg->{props}}) {
my $p = $pkg->{members}{$_};
my %t = find_type($p, $p->{type});
- print " $t{type}->{ctype} $p->{name};\n";
+ printf " $t{type}->{ctypefmt};\n", $p->{name};
}
put_line($pkg, 0);
print <<EOF;
my $tok = $p->{name};
$tok =~ tr/a-z/A-Z/;
- if ($t{type}->{kind} eq 's') {
- $call = "lua_pushstring(L, $call)";
+ if ($t{type}->{kind} eq 'b') {
+ $call = "lua_pushboolean(L, $call)";
}
if ($t{type}->{kind} eq 'i') {
$call = "lua_pushinteger(L, $call)";
}
+ if ($t{type}->{kind} eq 's') {
+ $call = "lua_pushstring(L, $call)";
+ }
+
if (defined $t{type}->{push}) {
$call =~ s/\$\$/$t{type}->{push}/;
}
put_line($p, 0);
print " case LTK_$tok: \n";
- print " m_strreplace(&$var, $check)" if ($t{type}->{kind} eq 's');
+ print " $var = $check" if ($t{type}->{kind} eq 'b');
print " $var = $check" if ($t{type}->{kind} eq 'i');
+ print " m_strreplace(&$var, $check)" if ($t{type}->{kind} eq 's');
print ";\n return 1;\n";
}
print;
}
}
- print "/* vi"."m:set ft=c: */\n";
stream_close(\%src);
}
return path;
}
+@type bool = {
+ .kind = 'b';
+ .ctype = unsigned : 1;
+};
+
@type string_t = {
.kind = 's';
.ctype = const char *;
@type quadopt_t = {
.kind = 'i';
.check = luaM_checkquadopt($L, $$);
- .ctype = quadopt_t;
+ .ctype = unsigned : 2;
};
+#if defined(HAVE_QDBM)
+# define HCACHE_BACKEND "qdbm"
+#elif defined(HAVE_GDBM)
+# define HCACHE_BACKEND "gdbm"
+#elif defined(HAVE_DB4)
+# define HCACHE_BACKEND "db4"
+#else
+# define HCACHE_BACKEND "unknown"
+#endif
+
@package madmutt {
const string_t version = VERSION;
const string_t sysconfdir = SYSCONFDIR;
const string_t bindir = BINDIR;
const string_t docdir = PKGDOCDIR;
+ const string_t hcache_backend = HCACHE_BACKEND;
path_t dotlock = BINDIR "/mutt_dotlock";
path_t editor = getenv("VISUAL") ?: getenv("EDITOR") ?: "vi";
path_t sendmail = SENDMAIL " -eom -oi";
path_t shell = madmutt_init_shell();
- quadopt_t quit = M_YES;
+ quadopt_t quit = M_YES;
+ bool beep = 1;
+ bool beep_new = 0;
const string_t pwd(void) = madmutt_pwd();
} ml_core;
+/* vim:set ft=c: */
*/
#include <lib-lib/lib-lib.h>
-#include "lib-lua_priv.h"
+#include <lib-lua/lib-lua.h>
static lua_State *L;
-
void luaM_initialize(void)
{
static const luaL_Reg lualibs[] = {
sidebar_draw ();
mutt_message (_("New mail in this mailbox."));
- if (option (OPTBEEPNEW))
+ if (ml_core.beep_new)
beep ();
}
else if (check == M_FLAGS)
menu->redraw |= REDRAW_SIDEBAR;
}
if (do_buffy_notify) {
- if (buffy_notify () && option (OPTBEEPNEW))
+ if (buffy_notify () && ml_core.beep_new)
beep ();
}
else
#define CLEARLINE_WIN(x) move(x,(option(OPTMBOXPANE)?SidebarWidth:0)), clrtoeol()
#define CLEARLINE(x) move(x,0), clrtoeol()
#define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
-#define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
+#define BEEP() do { if (ml_core.beep) beep(); } while (0)
#if ! (defined(USE_SLANG_CURSES) || defined(HAVE_CURS_SET))
#define curs_set(x)
OPTATTACHSPLIT,
OPTAUTOEDIT,
OPTAUTOTAG,
- OPTBEEP,
- OPTBEEPNEW,
OPTBOUNCEDELIVERED,
OPTBRAILLEFRIENDLY,
OPTCHECKNEW,