summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-25 06:50:30 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-25 06:50:30 +0000
commite9926c60bcbbe7135f163674c17e7601e3295dbc (patch)
tree5743e41d919a00bbde3111682bbcf17b75401378 /src/helper
parent5506f716256374b24a4c0137a4fe57038fdffb10 (diff)
downloadopenocd+libswd-e9926c60bcbbe7135f163674c17e7601e3295dbc.tar.gz
openocd+libswd-e9926c60bcbbe7135f163674c17e7601e3295dbc.tar.bz2
openocd+libswd-e9926c60bcbbe7135f163674c17e7601e3295dbc.tar.xz
openocd+libswd-e9926c60bcbbe7135f163674c17e7601e3295dbc.zip
sync with Jim Tcl repository.
git-svn-id: svn://svn.berlios.de/openocd/trunk@964 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/jim.c22
-rw-r--r--src/helper/jim.h2
2 files changed, 17 insertions, 7 deletions
diff --git a/src/helper/jim.c b/src/helper/jim.c
index ce7b8f62..a9838ab0 100644
--- a/src/helper/jim.c
+++ b/src/helper/jim.c
@@ -2173,8 +2173,9 @@ static Jim_Obj *JimStringToUpper(Jim_Interp *interp, Jim_Obj *strObjPtr)
* 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;
@@ -2190,8 +2191,6 @@ Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
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;
@@ -2456,6 +2455,15 @@ Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr,
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
* ---------------------------------------------------------------------------*/
@@ -8777,15 +8785,17 @@ int Jim_EvalFile(Jim_Interp *interp, const char *filename)
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;
diff --git a/src/helper/jim.h b/src/helper/jim.h
index 342c19e3..a89500fb 100644
--- a/src/helper/jim.h
+++ b/src/helper/jim.h
@@ -3,7 +3,7 @@
* 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>