Ticket #18: ansi-c-patch

File ansi-c-patch, 7.0 KB (added by ctl, 17 years ago)

patch

Line 
1Index: commands.c
2===================================================================
3--- commands.c  (revision 751)
4+++ commands.c  (working copy)
5@@ -2467,6 +2467,7 @@
6 {
7   owl_message *m;
8   owl_view *v;
9+  char *cmd;
10 
11   v = owl_global_get_current_view(&g);
12 
13@@ -2485,7 +2486,7 @@
14     owl_function_error("You already answered that question.");
15     return;
16   }
17-  char * cmd = owl_message_get_attribute_value(m, "yescommand");
18+  cmd = owl_message_get_attribute_value(m, "yescommand");
19   if(!cmd) {
20     owl_function_error("No yes command!");
21     return;
22@@ -2500,6 +2501,7 @@
23 {
24   owl_message *m;
25   owl_view *v;
26+  char *cmd;
27 
28   v = owl_global_get_current_view(&g);
29 
30@@ -2518,7 +2520,7 @@
31     owl_function_error("You already answered that question.");
32     return;
33   }
34-  char * cmd = owl_message_get_attribute_value(m, "nocommand");
35+  cmd = owl_message_get_attribute_value(m, "nocommand");
36   if(!cmd) {
37     owl_function_error("No no command!");
38     return;
39Index: functions.c
40===================================================================
41--- functions.c (revision 751)
42+++ functions.c (working copy)
43@@ -2800,6 +2800,7 @@
44   owl_view *v;
45   owl_message *m;
46   char *zperson, *filtname=NULL;
47+  char *argv[1];
48   
49   v=owl_global_get_current_view(&g);
50   m=owl_view_get_element(v, owl_global_get_curmsg(&g));
51@@ -2858,7 +2859,6 @@
52   }
53 
54   /* pass it off to perl */
55-  char *argv[1];
56   if(type) {
57     argv[0] = "-i";
58   };
59Index: message.c
60===================================================================
61--- message.c   (revision 751)
62+++ message.c   (working copy)
63@@ -26,10 +26,10 @@
64 
65 owl_fmtext_cache * owl_message_next_fmtext() /*noproto*/
66 {
67+    owl_fmtext_cache * f = fmtext_cache_next;
68     if(fmtext_cache_next->message != NULL) {
69         owl_message_invalidate_format(fmtext_cache_next->message);
70     }
71-    owl_fmtext_cache * f = fmtext_cache_next;
72     fmtext_cache_next++;
73     if(fmtext_cache_next - fmtext_cache == OWL_FMTEXT_CACHE_SIZE)
74         fmtext_cache_next = fmtext_cache;
75@@ -566,8 +566,9 @@
76 }
77 
78 int owl_message_is_answered(owl_message *m) {
79+  char *q;
80   if(!owl_message_is_question(m)) return 0;
81-  char * q = owl_message_get_attribute_value(m, "question");
82+  q = owl_message_get_attribute_value(m, "question");
83   if(!q) return 0;
84   return !strcmp(q, "answered");
85 }
86Index: global.c
87===================================================================
88--- global.c    (revision 751)
89+++ global.c    (working copy)
90@@ -17,6 +17,7 @@
91 void owl_global_init(owl_global *g) {
92   struct hostent *hent;
93   char hostname[MAXHOSTNAMELEN];
94+  char *cd;
95 
96   g->malloced=0;
97   g->freed=0;
98@@ -87,7 +88,7 @@
99 
100   g->confdir = NULL;
101   g->startupfile = NULL;
102-  char * cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR);
103+  cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR);
104   owl_global_set_confdir(g, cd);
105   owl_free(cd);
106 
107Index: filter.c
108===================================================================
109--- filter.c    (revision 751)
110+++ filter.c    (working copy)
111@@ -62,13 +62,13 @@
112 
113 static owl_filterelement * owl_filter_parse_primitive_expression(int argc, char **argv, int *next)
114 {
115+  owl_filterelement *fe, *op;
116+  int i = 0, skip;
117+
118   if(!argc) return NULL;
119 
120-  owl_filterelement * fe = owl_malloc(sizeof(owl_filterelement));
121-  owl_filterelement *op;
122-
123+  fe = owl_malloc(sizeof(owl_filterelement));
124   owl_filterelement_create(fe);
125-  int i = 0, skip;
126 
127   if(!strcasecmp(argv[i], "(")) {
128     i++;
129@@ -117,7 +117,7 @@
130 owl_filterelement * owl_filter_parse_expression(int argc, char **argv, int *next)
131 {
132   int i = 0, skip;
133-  owl_filterelement * op1 = NULL, * op2 = NULL;
134+  owl_filterelement * op1 = NULL, * op2 = NULL, *tmp;
135 
136   op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip);
137   i += skip;
138@@ -128,7 +128,7 @@
139        strcasecmp(argv[i], "or")) break;
140     op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip);
141     if(!op2) goto err;
142-    owl_filterelement * tmp = owl_malloc(sizeof(owl_filterelement));
143+    tmp = owl_malloc(sizeof(owl_filterelement));
144     if(!strcasecmp(argv[i], "and")) {
145       owl_filterelement_create_and(tmp, op1, op2);
146     } else {
147@@ -203,8 +203,9 @@
148  */
149 int owl_filter_message_match(owl_filter *f, owl_message *m)
150 {
151+  int ret;
152   if(!f->root) return 0;
153-  int ret = owl_filterelement_match(f->root, m);
154+  ret = owl_filterelement_match(f->root, m);
155   if(f->polarity) ret = !ret;
156   return ret;
157 }
158@@ -304,9 +305,11 @@
159 
160 
161 int owl_filter_regtest(void) {
162-  owl_list_create(&(g.filterlist));
163   int numfailed=0;
164   owl_message m;
165+  owl_filter f1, f2, f3, f4;
166+
167+  owl_list_create(&(g.filterlist));
168   owl_message_init(&m);
169   owl_message_set_type_zephyr(&m);
170   owl_message_set_direction_in(&m);
171@@ -344,8 +347,6 @@
172   TEST_FILTER("false and false or true", 1);
173   TEST_FILTER("true and false or false", 0);
174 
175-  owl_filter f1, f2, f3, f4;
176-
177   owl_filter_init_fromstring(&f1, "f1", "class owl");
178   owl_global_add_filter(&g, &f1);
179   TEST_FILTER("filter f1", 1);
180Index: variable.c
181===================================================================
182--- variable.c  (revision 751)
183+++ variable.c  (working copy)
184@@ -973,6 +973,7 @@
185   owl_vardict vd;
186   int numfailed=0;
187   char buf[1024];
188+  owl_variable * v;
189 
190   in_regtest = 1;
191 
192@@ -1026,8 +1027,6 @@
193   FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0,0));
194   FAIL_UNLESS("get enum 10", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser"));
195 
196-  owl_variable * v;
197
198   owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");
199   FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar", OWL_VARIABLE_STRING)));
200   FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(&vd, "stringvar")));
201Index: perlconfig.c
202===================================================================
203--- perlconfig.c        (revision 751)
204+++ perlconfig.c        (working copy)
205@@ -136,6 +136,7 @@
206   I32 count, len;
207   char *key,*val;
208   HV * hash;
209+  struct tm tm;
210 
211   hash = (HV*)SvRV(msg);
212 
213@@ -161,7 +162,6 @@
214       owl_message_set_zwriteline(m, val);
215     } else if (!strcmp(key, "time")) {
216       m->timestr = owl_strdup(val);
217-      struct tm tm;
218       strptime(val, "%a %b %d %T %Y", &tm);
219       m->time = mktime(&tm);
220     } else {
221@@ -444,6 +444,7 @@
222 {
223   int i, count;
224   char * ret = NULL;
225+  SV *rv;
226   STRLEN n_a;
227   dSP;
228 
229@@ -466,7 +467,7 @@
230   } else {
231     if(count != 1)
232       croak("Perl command %s returned more than one value!", cmd->name);
233-    SV * rv = POPs;
234+    rv = POPs;
235     if(SvTRUE(rv)) {
236       ret = owl_strdup(SvPV(rv, n_a));
237     }
238@@ -487,12 +488,12 @@
239 {
240   SV *cb = (SV*)(e->cbdata);
241   unsigned int n_a;
242+  dSP;
243+
244   if(cb == NULL) {
245     owl_function_error("Perl callback is NULL!");
246   }
247 
248-  dSP;
249-
250   ENTER;
251   SAVETMPS;
252 
253@@ -515,9 +516,9 @@
254 
255 void owl_perlconfig_mainloop()
256 {
257+  dSP;
258   if (!owl_perlconfig_is_function("BarnOwl::Hooks::_mainloop_hook"))
259     return;
260-  dSP ;
261   PUSHMARK(SP) ;
262   call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL);
263   if(SvTRUE(ERRSV)) {