diff options
-rw-r--r-- | jim-aio.c | 214 | ||||
-rw-r--r-- | jim-array.c | 74 | ||||
-rw-r--r-- | jim-clock.c | 70 | ||||
-rw-r--r-- | jim-file.c | 302 | ||||
-rw-r--r-- | jim-package.c | 45 | ||||
-rw-r--r-- | jim-signal.c | 62 | ||||
-rw-r--r-- | jim-subcmd.c | 97 | ||||
-rw-r--r-- | jim-subcmd.h | 17 | ||||
-rw-r--r-- | jim.c | 212 |
9 files changed, 513 insertions, 580 deletions
@@ -821,129 +821,147 @@ static int aio_cmd_onexception(Jim_Interp *interp, int argc, Jim_Obj *const *arg #endif static const jim_subcmd_type aio_command_table[] = { - { .cmd = "read", - .args = "?-nonewline? ?len?", - .function = aio_cmd_read, - .minargs = 0, - .maxargs = 2, - .description = "Read and return bytes from the stream. To eof if no len." + { "read", + "?-nonewline? ?len?", + aio_cmd_read, + 0, + 2, + /* Description: Read and return bytes from the stream. To eof if no len. */ }, - { .cmd = "copyto", - .args = "handle ?size?", - .function = aio_cmd_copy, - .minargs = 1, - .maxargs = 2, - .description = "Copy up to 'size' bytes to the given filehandle, or to eof if no size." + { "copyto", + "handle ?size?", + aio_cmd_copy, + 1, + 2, + /* Description: Copy up to 'size' bytes to the given filehandle, or to eof if no size. */ }, - { .cmd = "gets", - .args = "?var?", - .function = aio_cmd_gets, - .minargs = 0, - .maxargs = 1, - .description = "Read one line and return it or store it in the var" + { "gets", + "?var?", + aio_cmd_gets, + 0, + 1, + /* Description: Read one line and return it or store it in the var */ }, - { .cmd = "puts", - .args = "?-nonewline? str", - .function = aio_cmd_puts, - .minargs = 1, - .maxargs = 2, - .description = "Write the string, with newline unless -nonewline" + { "puts", + "?-nonewline? str", + aio_cmd_puts, + 1, + 2, + /* Description: Write the string, with newline unless -nonewline */ }, #if !defined(JIM_ANSIC) && !defined(JIM_BOOTSTRAP) - { .cmd = "recvfrom", - .args = "len ?addrvar?", - .function = aio_cmd_recvfrom, - .minargs = 1, - .maxargs = 2, - .description = "Receive up to 'len' bytes on the socket. Sets 'addrvar' with receive address, if set" + { "recvfrom", + "len ?addrvar?", + aio_cmd_recvfrom, + 1, + 2, + /* Description: Receive up to 'len' bytes on the socket. Sets 'addrvar' with receive address, if set */ }, - { .cmd = "sendto", - .args = "str address", - .function = aio_cmd_sendto, - .minargs = 2, - .maxargs = 2, - .description = "Send 'str' to the given address (dgram only)" + { "sendto", + "str address", + aio_cmd_sendto, + 2, + 2, + /* Description: Send 'str' to the given address (dgram only) */ }, - { .cmd = "accept", - .function = aio_cmd_accept, - .description = "Server socket only: Accept a connection and return stream" + { "accept", + NULL, + aio_cmd_accept, + 0, + 0, + /* Description: Server socket only: Accept a connection and return stream */ }, - { .cmd = "listen", - .args = "backlog", - .function = aio_cmd_listen, - .minargs = 1, - .maxargs = 1, - .description = "Set the listen backlog for server socket" + { "listen", + "backlog", + aio_cmd_listen, + 1, + 1, + /* Description: Set the listen backlog for server socket */ }, #endif /* JIM_BOOTSTRAP */ - { .cmd = "flush", - .function = aio_cmd_flush, - .description = "Flush the stream" + { "flush", + NULL, + aio_cmd_flush, + 0, + 0, + /* Description: Flush the stream */ }, - { .cmd = "eof", - .function = aio_cmd_eof, - .description = "Returns 1 if stream is at eof" + { "eof", + NULL, + aio_cmd_eof, + 0, + 0, + /* Description: Returns 1 if stream is at eof */ }, - { .cmd = "close", - .flags = JIM_MODFLAG_FULLARGV, - .function = aio_cmd_close, - .description = "Closes the stream" + { "close", + NULL, + aio_cmd_close, + 0, + 0, + JIM_MODFLAG_FULLARGV, + /* Description: Closes the stream */ }, - { .cmd = "seek", - .args = "offset ?start|current|end", - .function = aio_cmd_seek, - .minargs = 1, - .maxargs = 2, - .description = "Seeks in the stream (default 'current')" + { "seek", + "offset ?start|current|end", + aio_cmd_seek, + 1, + 2, + /* Description: Seeks in the stream (default 'current') */ }, - { .cmd = "tell", - .function = aio_cmd_tell, - .description = "Returns the current seek position" + { "tell", + NULL, + aio_cmd_tell, + 0, + 0, + /* Description: Returns the current seek position */ }, - { .cmd = "filename", - .function = aio_cmd_filename, - .description = "Returns the original filename" + { "filename", + NULL, + aio_cmd_filename, + 0, + 0, + /* Description: Returns the original filename */ }, #ifdef O_NDELAY - { .cmd = "ndelay", - .args = "?0|1?", - .function = aio_cmd_ndelay, - .minargs = 0, - .maxargs = 1, - .description = "Set O_NDELAY (if arg). Returns current/new setting." + { "ndelay", + "?0|1?", + aio_cmd_ndelay, + 0, + 1, + /* Description: Set O_NDELAY (if arg). Returns current/new setting. */ }, #endif - { .cmd = "buffering", - .args = "none|line|full", - .function = aio_cmd_buffering, - .minargs = 1, - .maxargs = 1, - .description = "Sets buffering" + { "buffering", + "none|line|full", + aio_cmd_buffering, + 1, + 1, + /* Description: Sets buffering */ }, #ifdef jim_ext_eventloop - { .cmd = "readable", - .args = "?readable-script?", - .minargs = 0, - .maxargs = 1, - .function = aio_cmd_readable, - .description = "Returns script, or invoke readable-script when readable, {} to remove", + { "readable", + "?readable-script?", + aio_cmd_readable, + 0, + 1, + /* Description: Returns script, or invoke readable-script when readable, {} to remove */ }, - { .cmd = "writable", - .args = "?writable-script?", - .minargs = 0, - .maxargs = 1, - .function = aio_cmd_writable, - .description = "Returns script, or invoke writable-script when writable, {} to remove", + { "writable", + "?writable-script?", + aio_cmd_writable, + 0, + 1, + /* Description: Returns script, or invoke writable-script when writable, {} to remove */ }, - { .cmd = "onexception", - .args = "?exception-script?", - .minargs = 0, - .maxargs = 1, - .function = aio_cmd_onexception, - .description = "Returns script, or invoke exception-script when oob data, {} to remove", + { "onexception", + "?exception-script?", + aio_cmd_onexception, + 0, + 1, + /* Description: Returns script, or invoke exception-script when oob data, {} to remove */ }, #endif - { 0 } + { NULL } }; static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv) diff --git a/jim-array.c b/jim-array.c index 89a86f0..76c6bc6 100644 --- a/jim-array.c +++ b/jim-array.c @@ -218,49 +218,49 @@ static int array_cmd_set(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } static const jim_subcmd_type array_command_table[] = { - { .cmd = "exists", - .args = "arrayName", - .function = array_cmd_exists, - .minargs = 1, - .maxargs = 1, - .description = "Does array exist?" + { "exists", + "arrayName", + array_cmd_exists, + 1, + 1, + /* Description: Does array exist? */ }, - { .cmd = "get", - .args = "arrayName ?pattern?", - .function = array_cmd_get, - .minargs = 1, - .maxargs = 2, - .description = "Array contents as name value list" + { "get", + "arrayName ?pattern?", + array_cmd_get, + 1, + 2, + /* Description: Array contents as name value list */ }, - { .cmd = "names", - .args = "arrayName ?pattern?", - .function = array_cmd_names, - .minargs = 1, - .maxargs = 2, - .description = "Array keys as a list" + { "names", + "arrayName ?pattern?", + array_cmd_names, + 1, + 2, + /* Description: Array keys as a list */ }, - { .cmd = "set", - .args = "arrayName list", - .function = array_cmd_set, - .minargs = 2, - .maxargs = 2, - .description = "Set array from list" + { "set", + "arrayName list", + array_cmd_set, + 2, + 2, + /* Description: Set array from list */ }, - { .cmd = "size", - .args = "arrayName", - .function = array_cmd_size, - .minargs = 1, - .maxargs = 1, - .description = "Number of elements in array" + { "size", + "arrayName", + array_cmd_size, + 1, + 1, + /* Description: Number of elements in array */ }, - { .cmd = "unset", - .args = "arrayName ?pattern?", - .function = array_cmd_unset, - .minargs = 1, - .maxargs = 2, - .description = "Unset elements of an array" + { "unset", + "arrayName ?pattern?", + array_cmd_unset, + 1, + 2, + /* Description: Unset elements of an array */ }, - { .cmd = 0, + { NULL } }; diff --git a/jim-clock.c b/jim-clock.c index 51ffb51..3d95aa3 100644 --- a/jim-clock.c +++ b/jim-clock.c @@ -106,47 +106,51 @@ static int clock_cmd_millis(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } static const jim_subcmd_type clock_command_table[] = { - { .cmd = "seconds", - .function = clock_cmd_seconds, - .minargs = 0, - .maxargs = 0, - .description = "Returns the current time as seconds since the epoch" + { "seconds", + NULL, + clock_cmd_seconds, + 0, + 0, + /* Description: Returns the current time as seconds since the epoch */ }, - { .cmd = "clicks", - .function = clock_cmd_micros, - .minargs = 0, - .maxargs = 0, - .description = "Returns the current time in 'clicks'" + { "clicks", + NULL, + clock_cmd_micros, + 0, + 0, + /* Description: Returns the current time in 'clicks' */ }, - { .cmd = "microseconds", - .function = clock_cmd_micros, - .minargs = 0, - .maxargs = 0, - .description = "Returns the current time in microseconds" + { "microseconds", + NULL, + clock_cmd_micros, + 0, + 0, + /* Description: Returns the current time in microseconds */ }, - { .cmd = "milliseconds", - .function = clock_cmd_millis, - .minargs = 0, - .maxargs = 0, - .description = "Returns the current time in milliseconds" + { "milliseconds", + NULL, + clock_cmd_millis, + 0, + 0, + /* Description: Returns the current time in milliseconds */ }, - { .cmd = "format", - .args = "seconds ?-format format?", - .function = clock_cmd_format, - .minargs = 1, - .maxargs = 3, - .description = "Format the given time" + { "format", + "seconds ?-format format?", + clock_cmd_format, + 1, + 3, + /* Description: Format the given time */ }, #ifdef HAVE_STRPTIME - { .cmd = "scan", - .args = "str -format format", - .function = clock_cmd_scan, - .minargs = 3, - .maxargs = 3, - .description = "Determine the time according to the given format" + { "scan", + "str -format format", + clock_cmd_scan, + 3, + 3, + /* Description: Determine the time according to the given format */ }, #endif - { 0 } + { NULL } }; int Jim_clockInit(Jim_Interp *interp) @@ -687,189 +687,189 @@ static int file_cmd_stat(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } static const jim_subcmd_type file_command_table[] = { - { .cmd = "atime", - .args = "name", - .function = file_cmd_atime, - .minargs = 1, - .maxargs = 1, - .description = "Last access time" + { "atime", + "name", + file_cmd_atime, + 1, + 1, + /* Description: Last access time */ }, - { .cmd = "mtime", - .args = "name ?time?", - .function = file_cmd_mtime, - .minargs = 1, - .maxargs = 2, - .description = "Get or set last modification time" + { "mtime", + "name ?time?", + file_cmd_mtime, + 1, + 2, + /* Description: Get or set last modification time */ }, - { .cmd = "copy", - .args = "?-force? source dest", - .function = file_cmd_copy, - .minargs = 2, - .maxargs = 3, - .description = "Copy source file to destination file" + { "copy", + "?-force? source dest", + file_cmd_copy, + 2, + 3, + /* Description: Copy source file to destination file */ }, - { .cmd = "dirname", - .args = "name", - .function = file_cmd_dirname, - .minargs = 1, - .maxargs = 1, - .description = "Directory part of the name" + { "dirname", + "name", + file_cmd_dirname, + 1, + 1, + /* Description: Directory part of the name */ }, - { .cmd = "rootname", - .args = "name", - .function = file_cmd_rootname, - .minargs = 1, - .maxargs = 1, - .description = "Name without any extension" + { "rootname", + "name", + file_cmd_rootname, + 1, + 1, + /* Description: Name without any extension */ }, - { .cmd = "extension", - .args = "name", - .function = file_cmd_extension, - .minargs = 1, - .maxargs = 1, - .description = "Last extension including the dot" + { "extension", + "name", + file_cmd_extension, + 1, + 1, + /* Description: Last extension including the dot */ }, - { .cmd = "tail", - .args = "name", - .function = file_cmd_tail, - .minargs = 1, - .maxargs = 1, - .description = "Last component of the name" + { "tail", + "name", + file_cmd_tail, + 1, + 1, + /* Description: Last component of the name */ }, - { .cmd = "normalize", - .args = "name", - .function = file_cmd_normalize, - .minargs = 1, - .maxargs = 1, - .description = "Normalized path of name" + { "normalize", + "name", + file_cmd_normalize, + 1, + 1, + /* Description: Normalized path of name */ }, - { .cmd = "join", - .args = "name ?name ...?", - .function = file_cmd_join, - .minargs = 1, - .maxargs = -1, - .description = "Join multiple path components" + { "join", + "name ?name ...?", + file_cmd_join, + 1, + -1, + /* Description: Join multiple path components */ }, - { .cmd = "readable", - .args = "name", - .function = file_cmd_readable, - .minargs = 1, - .maxargs = 1, - .description = "Is file readable" + { "readable", + "name", + file_cmd_readable, + 1, + 1, + /* Description: Is file readable */ }, - { .cmd = "writable", - .args = "name", - .function = file_cmd_writable, - .minargs = 1, - .maxargs = 1, - .description = "Is file writable" + { "writable", + "name", + file_cmd_writable, + 1, + 1, + /* Description: Is file writable */ }, - { .cmd = "executable", - .args = "name", - .function = file_cmd_executable, - .minargs = 1, - .maxargs = 1, - .description = "Is file executable" + { "executable", + "name", + file_cmd_executable, + 1, + 1, + /* Description: Is file executable */ }, - { .cmd = "exists", - .args = "name", - .function = file_cmd_exists, - .minargs = 1, - .maxargs = 1, - .description = "Does file exist" + { "exists", + "name", + file_cmd_exists, + 1, + 1, + /* Description: Does file exist */ }, - { .cmd = "delete", - .args = "?-force|--? name ...", - .function = file_cmd_delete, - .minargs = 1, - .maxargs = -1, - .description = "Deletes the files or directories (must be empty unless -force)" + { "delete", + "?-force|--? name ...", + file_cmd_delete, + 1, + -1, + /* Description: Deletes the files or directories (must be empty unless -force) */ }, - { .cmd = "mkdir", - .args = "dir ...", - .function = file_cmd_mkdir, - .minargs = 1, - .maxargs = -1, - .description = "Creates the directories" + { "mkdir", + "dir ...", + file_cmd_mkdir, + 1, + -1, + /* Description: Creates the directories */ }, #ifdef HAVE_MKSTEMP - { .cmd = "tempfile", - .args = "?template?", - .function = file_cmd_tempfile, - .minargs = 0, - .maxargs = 1, - .description = "Creates a temporary filename" + { "tempfile", + "?template?", + file_cmd_tempfile, + 0, + 1, + /* Description: Creates a temporary filename */ }, #endif - { .cmd = "rename", - .args = "?-force? source dest", - .function = file_cmd_rename, - .minargs = 2, - .maxargs = 3, - .description = "Renames a file" + { "rename", + "?-force? source dest", + file_cmd_rename, + 2, + 3, + /* Description: Renames a file */ }, #if defined(HAVE_READLINK) - { .cmd = "readlink", - .args = "name", - .function = file_cmd_readlink, - .minargs = 1, - .maxargs = 1, - .description = "Value of the symbolic link" + { "readlink", + "name", + file_cmd_readlink, + 1, + 1, + /* Description: Value of the symbolic link */ }, #endif - { .cmd = "size", - .args = "name", - .function = file_cmd_size, - .minargs = 1, - .maxargs = 1, - .description = "Size of file" + { "size", + "name", + file_cmd_size, + 1, + 1, + /* Description: Size of file */ }, - { .cmd = "stat", - .args = "name var", - .function = file_cmd_stat, - .minargs = 2, - .maxargs = 2, - .description = "Stores results of stat in var array" + { "stat", + "name var", + file_cmd_stat, + 2, + 2, + /* Description: Stores results of stat in var array */ }, - { .cmd = "lstat", - .args = "name var", - .function = file_cmd_lstat, - .minargs = 2, - .maxargs = 2, - .description = "Stores results of lstat in var array" + { "lstat", + "name var", + file_cmd_lstat, + 2, + 2, + /* Description: Stores results of lstat in var array */ }, - { .cmd = "type", - .args = "name", - .function = file_cmd_type, - .minargs = 1, - .maxargs = 1, - .description = "Returns type of the file" + { "type", + "name", + file_cmd_type, + 1, + 1, + /* Description: Returns type of the file */ }, #ifdef HAVE_GETEUID - { .cmd = "owned", - .args = "name", - .function = file_cmd_owned, - .minargs = 1, - .maxargs = 1, - .description = "Returns 1 if owned by the current owner" + { "owned", + "name", + file_cmd_owned, + 1, + 1, + /* Description: Returns 1 if owned by the current owner */ }, #endif - { .cmd = "isdirectory", - .args = "name", - .function = file_cmd_isdirectory, - .minargs = 1, - .maxargs = 1, - .description = "Returns 1 if name is a directory" + { "isdirectory", + "name", + file_cmd_isdirectory, + 1, + 1, + /* Description: Returns 1 if name is a directory */ }, - { .cmd = "isfile", - .args = "name", - .function = file_cmd_isfile, - .minargs = 1, - .maxargs = 1, - .description = "Returns 1 if name is a file" + { "isfile", + "name", + file_cmd_isfile, + 1, + 1, + /* Description: Returns 1 if name is a file */ }, { - .cmd = 0 + NULL } }; diff --git a/jim-package.c b/jim-package.c index 9caec0d..83582ea 100644 --- a/jim-package.c +++ b/jim-package.c @@ -232,24 +232,33 @@ static int package_cmd_list(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } static const jim_subcmd_type package_command_table[] = { - {.cmd = "provide", - .args = "name ?version?", - .function = package_cmd_provide, - .minargs = 1, - .maxargs = 2, - .description = "Indicates that the current script provides the given package"}, - {.cmd = "require", - .args = "name ?version?", - .function = package_cmd_require, - .minargs = 1, - .maxargs = 2, - .description = "Loads the given package by looking in standard places"}, - {.cmd = "list", - .function = package_cmd_list, - .minargs = 0, - .maxargs = 0, - .description = "Lists all known packages"}, - {0} + { + "provide", + "name ?version?", + package_cmd_provide, + 1, + 2, + /* Description: Indicates that the current script provides the given package */ + }, + { + "require", + "name ?version?", + package_cmd_require, + 1, + 2, + /* Description: Loads the given package by looking in standard places */ + }, + { + "list", + NULL, + package_cmd_list, + 0, + 0, + /* Description: Lists all known packages */ + }, + { + NULL + } }; int Jim_packageInit(Jim_Interp *interp) diff --git a/jim-signal.c b/jim-signal.c index 6a2a2be..b248698 100644 --- a/jim-signal.c +++ b/jim-signal.c @@ -351,42 +351,42 @@ static int signal_cmd_throw(Jim_Interp *interp, int argc, Jim_Obj *const *argv) *----------------------------------------------------------------------------- */ static const jim_subcmd_type signal_command_table[] = { - { .cmd = "handle", - .args = "?signals ...?", - .function = signal_cmd_handle, - .minargs = 0, - .maxargs = -1, - .description = "Lists handled signals, or adds to handled signals" + { "handle", + "?signals ...?", + signal_cmd_handle, + 0, + -1, + /* Description: Lists handled signals, or adds to handled signals */ }, - { .cmd = "ignore", - .args = "?signals ...?", - .function = signal_cmd_ignore, - .minargs = 0, - .maxargs = -1, - .description = "Lists ignored signals, or adds to ignored signals" + { "ignore", + "?signals ...?", + signal_cmd_ignore, + 0, + -1, + /* Description: Lists ignored signals, or adds to ignored signals */ }, - { .cmd = "default", - .args = "?signals ...?", - .function = signal_cmd_default, - .minargs = 0, - .maxargs = -1, - .description = "Lists defaulted signals, or adds to defaulted signals" + { "default", + "?signals ...?", + signal_cmd_default, + 0, + -1, + /* Description: Lists defaulted signals, or adds to defaulted signals */ }, - { .cmd = "check", - .args = "?-clear? ?signals ...?", - .function = signal_cmd_check, - .minargs = 0, - .maxargs = -1, - .description = "Returns ignored signals which have occurred, and optionally clearing them" + { "check", + "?-clear? ?signals ...?", + signal_cmd_check, + 0, + -1, + /* Description: Returns ignored signals which have occurred, and optionally clearing them */ }, - { .cmd = "throw", - .args = "?signal?", - .function = signal_cmd_throw, - .minargs = 0, - .maxargs = 1, - .description = "Raises the given signal (default SIGINT)" + { "throw", + "?signal?", + signal_cmd_throw, + 0, + 1, + /* Description: Raises the given signal (default SIGINT) */ }, - { 0 } + { NULL } }; static int Jim_AlarmCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) diff --git a/jim-subcmd.c b/jim-subcmd.c index 2de560a..f417c1e 100644 --- a/jim-subcmd.c +++ b/jim-subcmd.c @@ -17,9 +17,7 @@ static int subcmd_null(Jim_Interp *interp, int argc, Jim_Obj *const *argv) * Do-nothing command to support -commands and -usage */ static const jim_subcmd_type dummy_subcmd = { - .cmd = "dummy", - .function = subcmd_null, - .flags = JIM_MODFLAG_HIDDEN, + "dummy", NULL, subcmd_null, 0, 0, JIM_MODFLAG_HIDDEN }; static void add_commands(Jim_Interp *interp, const jim_subcmd_type * ct, const char *sep) @@ -63,22 +61,6 @@ static void add_cmd_usage(Jim_Interp *interp, const jim_subcmd_type * ct, Jim_Ob } } -static void show_full_usage(Jim_Interp *interp, const jim_subcmd_type * ct, int argc, - Jim_Obj *const *argv) -{ - Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); - for (; ct->cmd; ct++) { - if (!(ct->flags & JIM_MODFLAG_HIDDEN)) { - /* subcmd */ - add_cmd_usage(interp, ct, argv[0]); - if (ct->description) { - Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n ", ct->description, NULL); - } - Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", NULL); - } - } -} - static void set_wrong_args(Jim_Interp *interp, const jim_subcmd_type * command_table, Jim_Obj *subcmd) { Jim_SetResultString(interp, "wrong # args: must be \"", -1); @@ -103,19 +85,12 @@ const jim_subcmd_type *Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); Jim_AppendStrings(interp, Jim_GetResult(interp), "wrong # args: should be \"", cmdname, " command ...\"\n", NULL); - Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help\" or \"", - cmdname, " -help command\" for help", NULL); + Jim_AppendStrings(interp, Jim_GetResult(interp), "Use \"", cmdname, " -help ?command?\" for help", NULL); return 0; } cmd = argv[1]; - if (argc == 2 && Jim_CompareStringImmediate(interp, cmd, "-usage")) { - /* Show full usage */ - show_full_usage(interp, command_table, argc, argv); - return &dummy_subcmd; - } - /* Check for the help command */ if (Jim_CompareStringImmediate(interp, cmd, "-help")) { if (argc == 2) { @@ -180,9 +155,6 @@ const jim_subcmd_type *Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type Jim_SetResultString(interp, "Usage: ", -1); /* subcmd */ add_cmd_usage(interp, ct, argv[0]); - if (ct->description) { - Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", ct->description, NULL); - } return &dummy_subcmd; } @@ -226,68 +198,3 @@ int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return Jim_CallSubCmd(interp, ct, argc, argv); } - -/* The following two functions are for normal commands */ -int -Jim_CheckCmdUsage(Jim_Interp *interp, const jim_subcmd_type * command_table, int argc, - Jim_Obj *const *argv) -{ - /* -usage or -help */ - if (argc == 2) { - if (Jim_CompareStringImmediate(interp, argv[1], "-usage") - || Jim_CompareStringImmediate(interp, argv[1], "-help")) { - Jim_SetResultString(interp, "Usage: ", -1); - add_cmd_usage(interp, command_table, NULL); - if (command_table->description) { - Jim_AppendStrings(interp, Jim_GetResult(interp), "\n\n", command_table->description, - NULL); - } - return JIM_OK; - } - } - if (argc >= 2 && command_table->function) { - /* This is actually a sub command table */ - - Jim_Obj *nargv[4]; - int nargc = 0; - const char *subcmd = NULL; - - if (Jim_CompareStringImmediate(interp, argv[1], "-subcommands")) { - Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); - add_commands(interp, (jim_subcmd_type *) command_table->function, " "); - return JIM_OK; - } - - if (Jim_CompareStringImmediate(interp, argv[1], "-subhelp") - || Jim_CompareStringImmediate(interp, argv[1], "-help")) { - subcmd = "-help"; - } - else if (Jim_CompareStringImmediate(interp, argv[1], "-subusage")) { - subcmd = "-usage"; - } - - if (subcmd) { - nargv[nargc++] = Jim_NewStringObj(interp, "$handle", -1); - nargv[nargc++] = Jim_NewStringObj(interp, subcmd, -1); - if (argc >= 3) { - nargv[nargc++] = argv[2]; - } - Jim_ParseSubCmd(interp, (jim_subcmd_type *) command_table->function, nargc, nargv); - Jim_FreeNewObj(interp, nargv[0]); - Jim_FreeNewObj(interp, nargv[1]); - return 0; - } - } - - /* Check the number of args */ - if (argc - 1 < command_table->minargs || (command_table->maxargs >= 0 - && argc - 1 > command_table->maxargs)) { - set_wrong_args(interp, command_table, NULL); - Jim_AppendStrings(interp, Jim_GetResult(interp), "\nUse \"", Jim_String(argv[0]), - " -help\" for help", NULL); - return JIM_ERR; - } - - /* Not usage, but passed arg checking */ - return -1; -} diff --git a/jim-subcmd.h b/jim-subcmd.h index 3a672eb..f10f5f6 100644 --- a/jim-subcmd.h +++ b/jim-subcmd.h @@ -28,8 +28,7 @@ typedef struct { tclmod_cmd_function *function; /* Function implementing the subcommand */ short minargs; /* Minimum required arguments */ short maxargs; /* Maximum allowed arguments or -1 if no limit */ - unsigned flags; /* JIM_MODFLAG_... plus custom flags */ - const char *description; /* Description of the subcommand */ + unsigned short flags; /* JIM_MODFLAG_... plus custom flags */ } jim_subcmd_type; /** @@ -71,20 +70,6 @@ int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv); */ int Jim_CallSubCmd(Jim_Interp *interp, const jim_subcmd_type *ct, int argc, Jim_Obj *const *argv); -/** - * Standard processing for a command. - * - * This does the '-help' and '-usage' check and the number of args checks. - * for a top level command against a single 'jim_subcmd_type' structure. - * - * Additionally, if command_table->function is set, it should point to a sub command table - * and '-subhelp ?subcmd?', '-subusage' and '-subcommands' are then also recognised. - * - * Returns 0 if user requested usage, -1 on arg error, 1 if OK to process. - */ -int -Jim_CheckCmdUsage(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv); - #ifdef __cplusplus } #endif @@ -6827,14 +6827,14 @@ int Jim_GetIndex(Jim_Interp *interp, Jim_Obj *objPtr, int *indexPtr) /* NOTE: These must be kept in the same order as JIM_OK, JIM_ERR, ... */ static const char * const jimReturnCodes[] = { - [JIM_OK] = "ok", - [JIM_ERR] = "error", - [JIM_RETURN] = "return", - [JIM_BREAK] = "break", - [JIM_CONTINUE] = "continue", - [JIM_SIGNAL] = "signal", - [JIM_EXIT] = "exit", - [JIM_EVAL] = "eval", + "ok", + "error", + "return", + "break", + "continue", + "signal", + "exit", + "eval", NULL }; @@ -6904,7 +6904,7 @@ enum { /* Continues on from the JIM_TT_ space */ /* Operations */ - JIM_EXPROP_MUL = JIM_TT_EXPR_OP, /* 15 */ + JIM_EXPROP_MUL = JIM_TT_EXPR_OP, /* 20 */ JIM_EXPROP_DIV, JIM_EXPROP_MOD, JIM_EXPROP_SUB, @@ -6919,47 +6919,47 @@ enum JIM_EXPROP_GTE, JIM_EXPROP_NUMEQ, JIM_EXPROP_NUMNE, - JIM_EXPROP_BITAND, /* 30 */ + JIM_EXPROP_BITAND, /* 35 */ JIM_EXPROP_BITXOR, JIM_EXPROP_BITOR, /* Note must keep these together */ - JIM_EXPROP_LOGICAND, /* 33 */ + JIM_EXPROP_LOGICAND, /* 38 */ JIM_EXPROP_LOGICAND_LEFT, JIM_EXPROP_LOGICAND_RIGHT, /* and these */ - JIM_EXPROP_LOGICOR, /* 36 */ + JIM_EXPROP_LOGICOR, /* 41 */ JIM_EXPROP_LOGICOR_LEFT, JIM_EXPROP_LOGICOR_RIGHT, /* and these */ /* Ternary operators */ - JIM_EXPROP_TERNARY, /* 39 */ + JIM_EXPROP_TERNARY, /* 44 */ JIM_EXPROP_TERNARY_LEFT, JIM_EXPROP_TERNARY_RIGHT, /* and these */ - JIM_EXPROP_COLON, /* 42 */ + JIM_EXPROP_COLON, /* 47 */ JIM_EXPROP_COLON_LEFT, JIM_EXPROP_COLON_RIGHT, - JIM_EXPROP_POW, /* 45 */ + JIM_EXPROP_POW, /* 50 */ /* Binary operators (strings) */ - JIM_EXPROP_STREQ, + JIM_EXPROP_STREQ, /* 51 */ JIM_EXPROP_STRNE, JIM_EXPROP_STRIN, JIM_EXPROP_STRNI, /* Unary operators (numbers) */ - JIM_EXPROP_NOT, + JIM_EXPROP_NOT, /* 55 */ JIM_EXPROP_BITNOT, JIM_EXPROP_UNARYMINUS, JIM_EXPROP_UNARYPLUS, /* Functions */ - JIM_EXPROP_FUNC_FIRST, + JIM_EXPROP_FUNC_FIRST, /* 59 */ JIM_EXPROP_FUNC_INT = JIM_EXPROP_FUNC_FIRST, JIM_EXPROP_FUNC_ABS, JIM_EXPROP_FUNC_DOUBLE, @@ -6968,7 +6968,7 @@ enum JIM_EXPROP_FUNC_SRAND, /* math functions from libm */ - JIM_EXPROP_FUNC_SIN, + JIM_EXPROP_FUNC_SIN, /* 64 */ JIM_EXPROP_FUNC_COS, JIM_EXPROP_FUNC_TAN, JIM_EXPROP_FUNC_ASIN, @@ -7699,86 +7699,92 @@ enum LAZY_RIGHT }; -/* name - precedence - arity - opcode */ +/* name - precedence - arity - opcode + * + * This array *must* be kept in sync with the JIM_EXPROP enum + */ static const struct Jim_ExprOperator Jim_ExprOperators[] = { - [JIM_EXPROP_FUNC_INT] = {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_DOUBLE] = {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_ABS] = {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_ROUND] = {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_RAND] = {"rand", 400, 0, JimExprOpNone, LAZY_NONE}, - [JIM_EXPROP_FUNC_SRAND] = {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE}, + {"*", 200, 2, JimExprOpBin, LAZY_NONE}, + {"/", 200, 2, JimExprOpBin, LAZY_NONE}, + {"%", 200, 2, JimExprOpIntBin, LAZY_NONE}, -#ifdef JIM_MATH_FUNCTIONS - [JIM_EXPROP_FUNC_SIN] = {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_COS] = {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_TAN] = {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_ASIN] = {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_ACOS] = {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_ATAN] = {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_SINH] = {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_COSH] = {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_TANH] = {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_CEIL] = {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_FLOOR] = {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_EXP] = {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_LOG] = {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_LOG10] = {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_SQRT] = {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, - [JIM_EXPROP_FUNC_POW] = {"pow", 400, 2, JimExprOpBin, LAZY_NONE}, -#endif + {"-", 100, 2, JimExprOpBin, LAZY_NONE}, + {"+", 100, 2, JimExprOpBin, LAZY_NONE}, + + {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, + {">>", 90, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_NOT] = {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE}, - [JIM_EXPROP_BITNOT] = {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE}, - [JIM_EXPROP_UNARYMINUS] = {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, - [JIM_EXPROP_UNARYPLUS] = {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, + {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, + {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_POW] = {"**", 250, 2, JimExprOpBin, LAZY_NONE}, + {"<", 80, 2, JimExprOpBin, LAZY_NONE}, + {">", 80, 2, JimExprOpBin, LAZY_NONE}, + {"<=", 80, 2, JimExprOpBin, LAZY_NONE}, + {">=", 80, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_MUL] = {"*", 200, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_DIV] = {"/", 200, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_MOD] = {"%", 200, 2, JimExprOpIntBin, LAZY_NONE}, + {"==", 70, 2, JimExprOpBin, LAZY_NONE}, + {"!=", 70, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_SUB] = {"-", 100, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_ADD] = {"+", 100, 2, JimExprOpBin, LAZY_NONE}, + {"&", 50, 2, JimExprOpIntBin, LAZY_NONE}, + {"^", 49, 2, JimExprOpIntBin, LAZY_NONE}, + {"|", 48, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_ROTL] = {"<<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_ROTR] = {">>>", 90, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_LSHIFT] = {"<<", 90, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_RSHIFT] = {">>", 90, 2, JimExprOpIntBin, LAZY_NONE}, + {"&&", 10, 2, NULL, LAZY_OP}, + {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT}, + {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT}, - [JIM_EXPROP_LT] = {"<", 80, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_GT] = {">", 80, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_LTE] = {"<=", 80, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_GTE] = {">=", 80, 2, JimExprOpBin, LAZY_NONE}, + {"||", 9, 2, NULL, LAZY_OP}, + {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT}, + {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT}, - [JIM_EXPROP_NUMEQ] = {"==", 70, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_NUMNE] = {"!=", 70, 2, JimExprOpBin, LAZY_NONE}, + {"?", 5, 2, JimExprOpNull, LAZY_OP}, + {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT}, + {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, - [JIM_EXPROP_STREQ] = {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE}, - [JIM_EXPROP_STRNE] = {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE}, + {":", 5, 2, JimExprOpNull, LAZY_OP}, + {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT}, + {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, - [JIM_EXPROP_STRIN] = {"in", 55, 2, JimExprOpStrBin, LAZY_NONE}, - [JIM_EXPROP_STRNI] = {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE}, + {"**", 250, 2, JimExprOpBin, LAZY_NONE}, - [JIM_EXPROP_BITAND] = {"&", 50, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_BITXOR] = {"^", 49, 2, JimExprOpIntBin, LAZY_NONE}, - [JIM_EXPROP_BITOR] = {"|", 48, 2, JimExprOpIntBin, LAZY_NONE}, + {"eq", 60, 2, JimExprOpStrBin, LAZY_NONE}, + {"ne", 60, 2, JimExprOpStrBin, LAZY_NONE}, - [JIM_EXPROP_LOGICAND] = {"&&", 10, 2, NULL, LAZY_OP}, - [JIM_EXPROP_LOGICOR] = {"||", 9, 2, NULL, LAZY_OP}, + {"in", 55, 2, JimExprOpStrBin, LAZY_NONE}, + {"ni", 55, 2, JimExprOpStrBin, LAZY_NONE}, - [JIM_EXPROP_TERNARY] = {"?", 5, 2, JimExprOpNull, LAZY_OP}, - [JIM_EXPROP_COLON] = {":", 5, 2, JimExprOpNull, LAZY_OP}, + {"!", 300, 1, JimExprOpNumUnary, LAZY_NONE}, + {"~", 300, 1, JimExprOpIntUnary, LAZY_NONE}, + {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, + {NULL, 300, 1, JimExprOpNumUnary, LAZY_NONE}, - /* private operators */ - [JIM_EXPROP_TERNARY_LEFT] = {NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT}, - [JIM_EXPROP_TERNARY_RIGHT] = {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, - [JIM_EXPROP_COLON_LEFT] = {NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT}, - [JIM_EXPROP_COLON_RIGHT] = {NULL, 5, 2, JimExprOpNull, LAZY_RIGHT}, - [JIM_EXPROP_LOGICAND_LEFT] = {NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT}, - [JIM_EXPROP_LOGICAND_RIGHT] = {NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT}, - [JIM_EXPROP_LOGICOR_LEFT] = {NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT}, - [JIM_EXPROP_LOGICOR_RIGHT] = {NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT}, + + + {"int", 400, 1, JimExprOpNumUnary, LAZY_NONE}, + {"abs", 400, 1, JimExprOpNumUnary, LAZY_NONE}, + {"double", 400, 1, JimExprOpNumUnary, LAZY_NONE}, + {"round", 400, 1, JimExprOpNumUnary, LAZY_NONE}, + {"rand", 400, 0, JimExprOpNone, LAZY_NONE}, + {"srand", 400, 1, JimExprOpIntUnary, LAZY_NONE}, + +#ifdef JIM_MATH_FUNCTIONS + {"sin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"cos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"tan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"asin", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"acos", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"atan", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"sinh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"cosh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"tanh", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"ceil", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"floor", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"exp", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"log", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"log10", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"sqrt", 400, 1, JimExprOpDoubleUnary, LAZY_NONE}, + {"pow", 400, 2, JimExprOpBin, LAZY_NONE}, +#endif }; #define JIM_EXPR_OPERATORS_NUM \ @@ -7923,7 +7929,7 @@ static int JimParseExprOperator(struct JimParserCtx *pc) int bestIdx = -1, bestLen = 0; /* Try to get the longest match. */ - for (i = JIM_TT_EXPR_OP; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) { + for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) { const char *opname; int oplen; @@ -7934,7 +7940,7 @@ static int JimParseExprOperator(struct JimParserCtx *pc) oplen = strlen(opname); if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) { - bestIdx = i; + bestIdx = i + JIM_TT_EXPR_OP; bestLen = oplen; } } @@ -7967,7 +7973,11 @@ static int JimParseExprOperator(struct JimParserCtx *pc) static const struct Jim_ExprOperator *JimExprOperatorInfoByOpcode(int opcode) { - return &Jim_ExprOperators[opcode]; + static Jim_ExprOperator dummy_op; + if (opcode < JIM_TT_EXPR_OP) { + return &dummy_op; + } + return &Jim_ExprOperators[opcode - JIM_TT_EXPR_OP]; } const char *jim_tt_name(int type) @@ -7982,7 +7992,7 @@ const char *jim_tt_name(int type) const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(type); static char buf[20]; - if (op && op->name) { + if (op->name) { return op->name; } sprintf(buf, "(%d)", type); @@ -8060,17 +8070,15 @@ static int ExprCheckCorrectness(ExprByteCode * expr) ScriptToken *t = &expr->token[i]; const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type); - if (op) { - stacklen -= op->arity; - if (stacklen < 0) { - break; - } - if (t->type == JIM_EXPROP_TERNARY || t->type == JIM_EXPROP_TERNARY_LEFT) { - ternary++; - } - else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) { - ternary--; - } + stacklen -= op->arity; + if (stacklen < 0) { + break; + } + if (t->type == JIM_EXPROP_TERNARY || t->type == JIM_EXPROP_TERNARY_LEFT) { + ternary++; + } + else if (t->type == JIM_EXPROP_COLON || t->type == JIM_EXPROP_COLON_LEFT) { + ternary--; } /* All operations and operands add one to the stack */ @@ -8152,7 +8160,8 @@ static int ExprAddLazyOperator(Jim_Interp *interp, ExprByteCode * expr, ParseTok /* Do we need to adjust the skip count for any &L, |L, ?L or :L in the left operand? */ for (i = leftindex - 1; i > 0; i--) { - if (JimExprOperatorInfoByOpcode(expr->token[i].type)->lazy == LAZY_LEFT) { + const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(expr->token[i].type); + if (op->lazy == LAZY_LEFT) { if (JimWideValue(expr->token[i - 1].objPtr) + i - 1 >= leftindex) { JimWideValue(expr->token[i - 1].objPtr) += 2; } @@ -8361,8 +8370,9 @@ static ExprByteCode *ExprCreateByteCode(Jim_Interp *interp, const ParseTokenList */ for (i = 0; i < tokenlist->count; i++) { ParseToken *t = &tokenlist->list[i]; + const struct Jim_ExprOperator *op = JimExprOperatorInfoByOpcode(t->type); - if (JimExprOperatorInfoByOpcode(t->type)->lazy == LAZY_OP) { + if (op->lazy == LAZY_OP) { count += 2; /* Ternary is a lazy op but also needs reordering */ if (t->type == JIM_EXPROP_TERNARY) { |