From ea1b12824f360ca2f3b4838e1d88605b9b1c1a6d Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sat, 19 Dec 2020 09:31:40 +1000 Subject: 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 --- jim-pack.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'jim-pack.c') 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)) { -- cgit v1.1