From ef8d2a0e391fefd88541384d2478fdff0741875e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Mon, 14 Apr 2008 18:33:32 +0200
Subject: [PATCH] safe_apply() et al now return 1 on success and 0 (zero) if an
 error was caught.

Rev: src/interpret.c:1.395
Rev: src/interpret.h:1.173
---
 src/interpret.c | 18 +++++++++++-------
 src/interpret.h |  8 ++++----
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/interpret.c b/src/interpret.c
index e5178ed7e1..ab5a106260 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: interpret.c,v 1.394 2008/04/12 16:18:17 grubba Exp $
+|| $Id: interpret.c,v 1.395 2008/04/14 16:33:32 grubba Exp $
 */
 
 #include "global.h"
@@ -2407,10 +2407,11 @@ PMOD_EXPORT int apply_low_safe_and_stupid(struct object *o, INT32 offset)
   return ret;
 }
 
-PMOD_EXPORT void safe_apply_low2(struct object *o, int fun, int args,
-				 const char *fun_name)
+PMOD_EXPORT int safe_apply_low2(struct object *o, int fun, int args,
+				const char *fun_name)
 {
   JMP_BUF recovery;
+  int ret = 0;
 
   free_svalue(& throw_value);
   mark_free_svalue (&throw_value);
@@ -2418,6 +2419,7 @@ PMOD_EXPORT void safe_apply_low2(struct object *o, int fun, int args,
   {
     if(fun_name) call_handle_error();
     push_int(0);
+    ret = 0;
   }else{
     if (fun >= 0) {
       apply_low(o,fun,args);
@@ -2427,23 +2429,25 @@ PMOD_EXPORT void safe_apply_low2(struct object *o, int fun, int args,
       pop_n_elems(args);
       push_int(0);
     }
+    ret = 1;
   }
   UNSETJMP(recovery);
+  return ret;
 }
 
-PMOD_EXPORT void safe_apply_low(struct object *o, int fun, int args)
+PMOD_EXPORT int safe_apply_low(struct object *o, int fun, int args)
 {
-  safe_apply_low2(o, fun, args, "Unknown function.");
+  return safe_apply_low2(o, fun, args, "Unknown function.");
 }
 
-PMOD_EXPORT void safe_apply(struct object *o, const char *fun, INT32 args)
+PMOD_EXPORT int safe_apply(struct object *o, const char *fun, INT32 args)
 {
   int id;
 #ifdef PIKE_DEBUG
   if(!o->prog) Pike_fatal("Apply safe on destructed object.\n");
 #endif
   id = find_identifier(fun, o->prog);
-  safe_apply_low2(o, id, args, fun);
+  return safe_apply_low2(o, id, args, fun);
 }
 
 /* Returns nonzero if the function was called in some handler. */
diff --git a/src/interpret.h b/src/interpret.h
index 49151c4796..47a76e057a 100644
--- a/src/interpret.h
+++ b/src/interpret.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: interpret.h,v 1.172 2008/04/14 12:17:17 grubba Exp $
+|| $Id: interpret.h,v 1.173 2008/04/14 16:33:32 grubba Exp $
 */
 
 #ifndef INTERPRET_H
@@ -741,10 +741,10 @@ PMOD_EXPORT void mega_apply(enum apply_type type, INT32 args, void *arg1, void *
 PMOD_EXPORT void f_call_function(INT32 args);
 PMOD_EXPORT void call_handle_error(void);
 PMOD_EXPORT int apply_low_safe_and_stupid(struct object *o, INT32 offset);
-PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args);
-PMOD_EXPORT void safe_apply_low2(struct object *o,int fun,int args,
+PMOD_EXPORT int safe_apply_low(struct object *o,int fun,int args);
+PMOD_EXPORT int safe_apply_low2(struct object *o,int fun,int args,
 				 const char *fun_name);
-PMOD_EXPORT void safe_apply(struct object *o, const char *fun ,INT32 args);
+PMOD_EXPORT int safe_apply(struct object *o, const char *fun ,INT32 args);
 PMOD_EXPORT int low_unsafe_apply_handler(const char *fun,
 					 struct object *handler,
 					 struct object *compat,
-- 
GitLab