From fe1d16ba54e519c5d71b5e25eb2c07f4ba39de7a Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 25 Mar 2005 09:34:51 +0000 Subject: SetReturnCodeFromAny() modified to accept numerical codes. --- jim.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'jim.c') diff --git a/jim.c b/jim.c index 3bcd2ef..bc2b273 100644 --- a/jim.c +++ b/jim.c @@ -2,7 +2,7 @@ * Copyright 2005 Salvatore Sanfilippo * Copyright 2005 Clemens Hintze * - * $Id: jim.c,v 1.128 2005/03/24 13:58:05 antirez Exp $ + * $Id: jim.c,v 1.129 2005/03/25 09:34:51 antirez Exp $ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -5596,11 +5596,14 @@ int SetReturnCodeFromAny(Jim_Interp *interp, Jim_Obj *objPtr) { const char *str; int strLen, returnCode; + jim_wide wideValue; /* Get the string representation */ str = Jim_GetString(objPtr, &strLen); - /* Try to convert into a jim_wide */ - if (!JimStringCompare(str, strLen, "ok", 2, JIM_NOCASE)) + /* Try to convert into an integer */ + if (JimGetWideNoErr(interp, objPtr, &wideValue) != JIM_ERR) + returnCode = (int) wideValue; + else if (!JimStringCompare(str, strLen, "ok", 2, JIM_NOCASE)) returnCode = JIM_OK; else if (!JimStringCompare(str, strLen, "error", 5, JIM_NOCASE)) returnCode = JIM_ERR; @@ -10931,7 +10934,7 @@ int Jim_InteractivePrompt(Jim_Interp *interp) printf("Welcome to Jim version %d.%d, " "Copyright (c) 2005 Salvatore Sanfilippo\n", JIM_VERSION / 100, JIM_VERSION % 100); - printf("CVS ID: $Id: jim.c,v 1.128 2005/03/24 13:58:05 antirez Exp $\n"); + printf("CVS ID: $Id: jim.c,v 1.129 2005/03/25 09:34:51 antirez Exp $\n"); Jim_SetVariableStrWithStr(interp, "jim_interactive", "1"); while (1) { char buf[1024]; -- cgit v1.1