[667] in BarnOwl Developers
[D-O-H] r752 - trunk/owl
daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:08:29 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 8 Aug 2007 18:01:51 -0400 (EDT)
Author: nelhage
Date: 2007-08-08 18:01:51 -0400 (Wed, 08 Aug 2007)
New Revision: 752
Modified:
trunk/owl/commands.c
trunk/owl/filter.c
trunk/owl/functions.c
trunk/owl/global.c
trunk/owl/message.c
trunk/owl/perlconfig.c
trunk/owl/variable.c
Log:
Applying ctl's variable shuffling patch for better ANSI C-ness. closes #18
Modified: trunk/owl/commands.c
===================================================================
--- trunk/owl/commands.c 2007-08-02 02:58:31 UTC (rev 751)
+++ trunk/owl/commands.c 2007-08-08 22:01:51 UTC (rev 752)
@@ -2467,6 +2467,7 @@
{
owl_message *m;
owl_view *v;
+ char *cmd;
v = owl_global_get_current_view(&g);
@@ -2485,7 +2486,7 @@
owl_function_error("You already answered that question.");
return;
}
- char * cmd = owl_message_get_attribute_value(m, "yescommand");
+ cmd = owl_message_get_attribute_value(m, "yescommand");
if(!cmd) {
owl_function_error("No yes command!");
return;
@@ -2500,6 +2501,7 @@
{
owl_message *m;
owl_view *v;
+ char *cmd;
v = owl_global_get_current_view(&g);
@@ -2518,7 +2520,7 @@
owl_function_error("You already answered that question.");
return;
}
- char * cmd = owl_message_get_attribute_value(m, "nocommand");
+ cmd = owl_message_get_attribute_value(m, "nocommand");
if(!cmd) {
owl_function_error("No no command!");
return;
Modified: trunk/owl/filter.c
===================================================================
--- trunk/owl/filter.c 2007-08-02 02:58:31 UTC (rev 751)
+++ trunk/owl/filter.c 2007-08-08 22:01:51 UTC (rev 752)
@@ -62,13 +62,13 @@
static owl_filterelement * owl_filter_parse_primitive_expression(int argc, char **argv, int *next)
{
+ owl_filterelement *fe, *op;
+ int i = 0, skip;
+
if(!argc) return NULL;
- owl_filterelement * fe = owl_malloc(sizeof(owl_filterelement));
- owl_filterelement *op;
-
+ fe = owl_malloc(sizeof(owl_filterelement));
owl_filterelement_create(fe);
- int i = 0, skip;
if(!strcasecmp(argv[i], "(")) {
i++;
@@ -117,7 +117,7 @@
owl_filterelement * owl_filter_parse_expression(int argc, char **argv, int *next)
{
int i = 0, skip;
- owl_filterelement * op1 = NULL, * op2 = NULL;
+ owl_filterelement * op1 = NULL, * op2 = NULL, *tmp;
op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip);
i += skip;
@@ -128,7 +128,7 @@
strcasecmp(argv[i], "or")) break;
op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip);
if(!op2) goto err;
- owl_filterelement * tmp = owl_malloc(sizeof(owl_filterelement));
+ tmp = owl_malloc(sizeof(owl_filterelement));
if(!strcasecmp(argv[i], "and")) {
owl_filterelement_create_and(tmp, op1, op2);
} else {
@@ -203,8 +203,9 @@
*/
int owl_filter_message_match(owl_filter *f, owl_message *m)
{
+ int ret;
if(!f->root) return 0;
- int ret = owl_filterelement_match(f->root, m);
+ ret = owl_filterelement_match(f->root, m);
if(f->polarity) ret = !ret;
return ret;
}
@@ -304,9 +305,11 @@
int owl_filter_regtest(void) {
- owl_list_create(&(g.filterlist));
int numfailed=0;
owl_message m;
+ owl_filter f1, f2, f3, f4;
+
+ owl_list_create(&(g.filterlist));
owl_message_init(&m);
owl_message_set_type_zephyr(&m);
owl_message_set_direction_in(&m);
@@ -344,8 +347,6 @@
TEST_FILTER("false and false or true", 1);
TEST_FILTER("true and false or false", 0);
- owl_filter f1, f2, f3, f4;
-
owl_filter_init_fromstring(&f1, "f1", "class owl");
owl_global_add_filter(&g, &f1);
TEST_FILTER("filter f1", 1);
Modified: trunk/owl/functions.c
===================================================================
--- trunk/owl/functions.c 2007-08-02 02:58:31 UTC (rev 751)
+++ trunk/owl/functions.c 2007-08-08 22:01:51 UTC (rev 752)
@@ -2800,6 +2800,7 @@
owl_view *v;
owl_message *m;
char *zperson, *filtname=NULL;
+ char *argv[1];
v=owl_global_get_current_view(&g);
m=owl_view_get_element(v, owl_global_get_curmsg(&g));
@@ -2858,7 +2859,6 @@
}
/* pass it off to perl */
- char *argv[1];
if(type) {
argv[0] = "-i";
};
Modified: trunk/owl/global.c
===================================================================
--- trunk/owl/global.c 2007-08-02 02:58:31 UTC (rev 751)
+++ trunk/owl/global.c 2007-08-08 22:01:51 UTC (rev 752)
@@ -17,6 +17,7 @@
void owl_global_init(owl_global *g) {
struct hostent *hent;
char hostname[MAXHOSTNAMELEN];
+ char *cd;
g->malloced=0;
g->freed=0;
@@ -87,7 +88,7 @@
g->confdir = NULL;
g->startupfile = NULL;
- char * cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR);
+ cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR);
owl_global_set_confdir(g, cd);
owl_free(cd);
Modified: trunk/owl/message.c
===================================================================
--- trunk/owl/message.c 2007-08-02 02:58:31 UTC (rev 751)
+++ trunk/owl/message.c 2007-08-08 22:01:51 UTC (rev 752)
@@ -26,10 +26,10 @@
owl_fmtext_cache * owl_message_next_fmtext() /*noproto*/
{
+ owl_fmtext_cache * f = fmtext_cache_next;
if(fmtext_cache_next->message != NULL) {
owl_message_invalidate_format(fmtext_cache_next->message);
}
- owl_fmtext_cache * f = fmtext_cache_next;
fmtext_cache_next++;
if(fmtext_cache_next - fmtext_cache == OWL_FMTEXT_CACHE_SIZE)
fmtext_cache_next = fmtext_cache;
@@ -566,8 +566,9 @@
}
int owl_message_is_answered(owl_message *m) {
+ char *q;
if(!owl_message_is_question(m)) return 0;
- char * q = owl_message_get_attribute_value(m, "question");
+ q = owl_message_get_attribute_value(m, "question");
if(!q) return 0;
return !strcmp(q, "answered");
}
Modified: trunk/owl/perlconfig.c
===================================================================
--- trunk/owl/perlconfig.c 2007-08-02 02:58:31 UTC (rev 751)
+++ trunk/owl/perlconfig.c 2007-08-08 22:01:51 UTC (rev 752)
@@ -136,6 +136,7 @@
I32 count, len;
char *key,*val;
HV * hash;
+ struct tm tm;
hash = (HV*)SvRV(msg);
@@ -161,7 +162,6 @@
owl_message_set_zwriteline(m, val);
} else if (!strcmp(key, "time")) {
m->timestr = owl_strdup(val);
- struct tm tm;
strptime(val, "%a %b %d %T %Y", &tm);
m->time = mktime(&tm);
} else {
@@ -444,6 +444,7 @@
{
int i, count;
char * ret = NULL;
+ SV *rv;
STRLEN n_a;
dSP;
@@ -466,7 +467,7 @@
} else {
if(count != 1)
croak("Perl command %s returned more than one value!", cmd->name);
- SV * rv = POPs;
+ rv = POPs;
if(SvTRUE(rv)) {
ret = owl_strdup(SvPV(rv, n_a));
}
@@ -487,12 +488,12 @@
{
SV *cb = (SV*)(e->cbdata);
unsigned int n_a;
+ dSP;
+
if(cb == NULL) {
owl_function_error("Perl callback is NULL!");
}
- dSP;
-
ENTER;
SAVETMPS;
@@ -515,9 +516,9 @@
void owl_perlconfig_mainloop()
{
+ dSP;
if (!owl_perlconfig_is_function("BarnOwl::Hooks::_mainloop_hook"))
return;
- dSP ;
PUSHMARK(SP) ;
call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL);
if(SvTRUE(ERRSV)) {
Modified: trunk/owl/variable.c
===================================================================
--- trunk/owl/variable.c 2007-08-02 02:58:31 UTC (rev 751)
+++ trunk/owl/variable.c 2007-08-08 22:01:51 UTC (rev 752)
@@ -973,6 +973,7 @@
owl_vardict vd;
int numfailed=0;
char buf[1024];
+ owl_variable * v;
in_regtest = 1;
@@ -1026,8 +1027,6 @@
FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0,0));
FAIL_UNLESS("get enum 10", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser"));
- owl_variable * v;
-
owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");
FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar", OWL_VARIABLE_STRING)));
FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(&vd, "stringvar")));