[377] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r518 - trunk/owl

daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:05:31 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Thu, 11 Jan 2007 11:02:24 -0500 (EST)

Author: asedeno
Date: 2007-01-11 11:02:24 -0500 (Thu, 11 Jan 2007)
New Revision: 518

Modified:
   trunk/owl/commands.c
Log:
* Make yes/no not segfault when there is no current messge.
* Make yes/no return types consistant with the rest of commands.c.



Modified: trunk/owl/commands.c
===================================================================
--- trunk/owl/commands.c	2007-01-10 21:01:48 UTC (rev 517)
+++ trunk/owl/commands.c	2007-01-11 16:02:24 UTC (rev 518)
@@ -2439,10 +2439,20 @@
     return NULL;
 }
 
-void owl_command_yes(void)
+char *owl_command_yes(void)
 {
-  owl_message *m = owl_view_get_element(owl_global_get_current_view(&g),
-                                        owl_global_get_curmsg(&g));
+  owl_message *m;
+  owl_view *v;
+
+  v = owl_global_get_current_view(&g);
+
+  /* bail if there's no current message */
+  if (owl_view_get_size(v) < 1) {
+    owl_function_error("No current message.");
+    return NULL;
+  }
+
+  m = owl_view_get_element(v, owl_global_get_curmsg(&g));
   if(!owl_message_is_question(m)) {
     owl_function_error("That message isn't a question.");
     return NULL;
@@ -2459,12 +2469,23 @@
 
   owl_function_command_norv(cmd);
   owl_message_set_isanswered(m);
+  return NULL;
 }
 
 char *owl_command_no(void)
 {
-  owl_message *m = owl_view_get_element(owl_global_get_current_view(&g),
-                                        owl_global_get_curmsg(&g));
+  owl_message *m;
+  owl_view *v;
+
+  v = owl_global_get_current_view(&g);
+
+  /* bail if there's no current message */
+  if (owl_view_get_size(v) < 1) {
+    owl_function_error("No current message.");
+    return NULL;
+  }
+
+  m = owl_view_get_element(v, owl_global_get_curmsg(&g));
   if(!owl_message_is_question(m)) {
     owl_function_error("That message isn't a question.");
     return NULL;
@@ -2481,6 +2502,7 @@
 
   owl_function_command_norv(cmd);
   owl_message_set_isanswered(m);
+  return NULL;
 }
 
 /*********************************************************************/


home help back first fref pref prev next nref lref last post