From ee6dbe0a8d66f8f17a5da82e8dad810d88e33bf6 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sun, 24 Jan 2010 13:46:32 +1000 Subject: Allow catch to specify what is caught *: Default to the same as Tcl. Not signal, eval, exit. *: Use 'catch -exit' to also catch exit. *: Also map for standard return codes: [info returncodes] *: Also Jim_ReturnCode() *: Add Jim_FindByName() for searching in a char* array *: Fix 'info nameofexectutable' if $::jim_argv0 is not set --- jim-syslog.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'jim-syslog.c') diff --git a/jim-syslog.c b/jim-syslog.c index 29f4d9c..18e63a6 100644 --- a/jim-syslog.c +++ b/jim-syslog.c @@ -53,24 +53,6 @@ static const char *priorities[] = { }; /** - * Find a matching name in the array of the given length. - * - * NULL entries are ignored. - * - * Returns the matching index if found, or -1 if not. - */ -static int find_by_name(const char *name, const char *array[], size_t len) -{ - int i; - for (i = 0; i < len; i++) { - if (array[i] && strcmp(array[i], name) == 0) { - return i; - } - } - return -1; -} - -/** * Deletes the syslog command. */ static void Jim_SyslogCmdDelete(Jim_Interp *interp, void *privData) @@ -102,7 +84,7 @@ wrongargs: } while (i < argc-1) { if (Jim_CompareStringImmediate(interp, argv[i], "-facility")) { - int entry = find_by_name(Jim_GetString(argv[i + 1], NULL), facilities, sizeof(facilities) / sizeof(*facilities)); + int entry = Jim_FindByName(Jim_GetString(argv[i + 1], NULL), facilities, sizeof(facilities) / sizeof(*facilities)); if (entry < 0) { Jim_SetResultString(interp, "Unknown facility", -1); return JIM_ERR; @@ -147,7 +129,7 @@ wrongargs: } if (i