aboutsummaryrefslogtreecommitdiff
path: root/jim-pack.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-12-19 09:31:40 +1000
committerSteve Bennett <steveb@workware.net.au>2020-12-26 18:08:29 +1000
commitea1b12824f360ca2f3b4838e1d88605b9b1c1a6d (patch)
treeda9cc972a7fedcfe45eaa068636345013c785d12 /jim-pack.c
parenta905122e48ae2f5208b037d8bfc08631b753cb63 (diff)
downloadjimtcl-ea1b12824f360ca2f3b4838e1d88605b9b1c1a6d.zip
jimtcl-ea1b12824f360ca2f3b4838e1d88605b9b1c1a6d.tar.gz
jimtcl-ea1b12824f360ca2f3b4838e1d88605b9b1c1a6d.tar.bz2
core: support integer expressions in various commands
For convenience, many commands now accept integer expressions rather than only simple integers. These are: loop, range, incr, string repeat, lrepeat, pack, unpack, rand This simplifies many cases where previously expr {} or $() was required. e.g. foreach i [range 4+1 2*$b] { ... } string repeat 2**$n a Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-pack.c')
-rw-r--r--jim-pack.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/jim-pack.c b/jim-pack.c
index 6518192..0d1dd94 100644
--- a/jim-pack.c
+++ b/jim-pack.c
@@ -290,14 +290,14 @@ static int Jim_UnpackCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_ERR;
}
- if (Jim_GetWide(interp, argv[3], &pos) != JIM_OK) {
+ if (Jim_GetWideExpr(interp, argv[3], &pos) != JIM_OK) {
return JIM_ERR;
}
if (pos < 0 || (option == OPT_STR && pos % 8)) {
Jim_SetResultFormatted(interp, "bad bitoffset: %#s", argv[3]);
return JIM_ERR;
}
- if (Jim_GetWide(interp, argv[4], &width) != JIM_OK) {
+ if (Jim_GetWideExpr(interp, argv[4], &width) != JIM_OK) {
return JIM_ERR;
}
if (width < 0 || (option == OPT_STR && width % 8) || (option != OPT_STR && width > sizeof(jim_wide) * 8) ||
@@ -387,14 +387,14 @@ static int Jim_PackCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_ERR;
}
if ((option == OPT_LE || option == OPT_BE) &&
- Jim_GetWide(interp, argv[2], &value) != JIM_OK) {
+ Jim_GetWideExpr(interp, argv[2], &value) != JIM_OK) {
return JIM_ERR;
}
if ((option == OPT_FLOATLE || option == OPT_FLOATBE) &&
Jim_GetDouble(interp, argv[2], &fvalue) != JIM_OK) {
return JIM_ERR;
}
- if (Jim_GetWide(interp, argv[4], &width) != JIM_OK) {
+ if (Jim_GetWideExpr(interp, argv[4], &width) != JIM_OK) {
return JIM_ERR;
}
if (width <= 0 || (option == OPT_STR && width % 8) || (option != OPT_STR && width > sizeof(jim_wide) * 8) ||
@@ -403,7 +403,7 @@ static int Jim_PackCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_ERR;
}
if (argc == 6) {
- if (Jim_GetWide(interp, argv[5], &pos) != JIM_OK) {
+ if (Jim_GetWideExpr(interp, argv[5], &pos) != JIM_OK) {
return JIM_ERR;
}
if (pos < 0 || (option == OPT_STR && pos % 8)) {