* TODO: Lots of things work - via a hack
* However, no format item can be >= JIM_MAX_FMT
*/
-Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
- int objc, Jim_Obj *const *objv)
+#define JIM_MAX_FMT 2048
+static Jim_Obj *Jim_FormatString_Inner(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
+ int objc, Jim_Obj *const *objv, char *sprintf_buf)
{
const char *fmt, *_fmt;
int fmtLen;
jim_wide wideValue;
double doubleValue;
/* we cheat and use Sprintf()! */
-#define JIM_MAX_FMT 2048
- char sprintf_buf[JIM_MAX_FMT];
char fmt_str[100];
char *cp;
int width;
return resObjPtr;
}
+Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
+ int objc, Jim_Obj *const *objv)
+{
+ char *sprintf_buf=malloc(JIM_MAX_FMT);
+ Jim_Obj *t=Jim_FormatString_Inner(interp, fmtObjPtr, objc, objv, sprintf_buf);
+ free(sprintf_buf);
+ return t;
+}
+
/* -----------------------------------------------------------------------------
* Compared String Object
* ---------------------------------------------------------------------------*/
int nread, totread, maxlen, buflen;
int retval;
Jim_Obj *scriptObjPtr;
- char cwd[ 2048 ];
if ((fp = fopen(filename, "r")) == NULL) {
+ const int cwd_len=2048;
+ char *cwd=malloc(cwd_len);
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
- getcwd( cwd, sizeof(cwd) );
+ getcwd( cwd, cwd_len );
Jim_AppendStrings(interp, Jim_GetResult(interp),
"Error loading script \"", filename, "\"",
" cwd: ", cwd,
" err: ", strerror(errno), NULL);
+ free(cwd);
return JIM_ERR;
}
buflen = 1024;
* Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
* Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
* Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
- * Copyright 2008 oharboe - Øyvind Harboe - soyvind.harboe@zylin.com
+ * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
* Copyright 2008 Andrew Lunn <andrew@lunn.ch>
* Copyright 2008 Duane Ellis <openocd@duaneellis.com>
* Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>