/ Check-in [ad72e1facf]
DEMO | DOWNLOAD | DEPLOY | SEARCH
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Interactive mode fixes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ad72e1facf7644ebf4c0bcf5666f1878f5e2308b
User & Date: pmacdona 2019-05-08 02:23:20
Context
2019-05-08
02:25
Interactive integrity check. check-in: 1540c573a7 user: pmacdona tags: trunk
02:23
Interactive mode fixes. check-in: ad72e1facf user: pmacdona tags: trunk
2019-05-07
21:19
Fix build without readline. check-in: 3ddfb7d113 user: pmacdona tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/jsiCmds.c.

4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
....
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
    const char *anam;
    bool isMain = jsi_isMain(interp);
    if (interp->isMain)
        interp->isMain = 0;
    
    if (v2 && !Jsi_ValueIsObjType(interp, v2, JSI_OT_ARRAY))
        return Jsi_LogError("arg 2: expected array|undefined");
    if (!v1) {
        mod = interp->framePtr->fileName;
        if (mod) mod = Jsi_Strrchr(mod, '/');
        if (!mod) return JSI_ERROR;
        mod++;
        cp = Jsi_Strrchr(mod, '.');
        int len = (cp?(cp-mod):(int)Jsi_Strlen(mod));
        mod = Jsi_DSAppendLen(&dStr, mod, len);
................................................................................
    { "parseFloat", parseFloatCmd,   1,  1, "val", .help="Convert string to a double", .retType=(uint)JSI_TT_NUMBER },
    { "parseOpts",  SysParseOptsCmd, 2,  3, "self:object|userobj, options:object, conf:object|null|undefined", .help="Parse options", .retType=(uint)JSI_TT_ANY, .flags=0},
    { "printf",     SysPrintfCmd,    1, -1, "format:string, ...", .help="Formatted output to stdout", .retType=(uint)JSI_TT_VOID, .flags=0 },
    { "provide",    SysProvideCmd,   0,  3, "name:string|function=void, version:number|string=1.0, opts:object|function=void", .help="Provide a package for use with require. Default is the file tail-rootname", .retType=(uint)JSI_TT_VOID },
    { "puts",       SysPutsCmd,      1, -1, "val, ...", .help="Output one or more values to stdout", .retType=(uint)JSI_TT_VOID, .flags=0, .info=FN_puts },
    { "quote",      SysQuoteCmd,     1,  1, "val:string", .help="Return quoted string", .retType=(uint)JSI_TT_STRING },
    { "require",    SysRequireCmd,   0,  3, "name:string=void, version:number|string=1, options:object=void", .help="Load/query packages", .retType=(uint)JSI_TT_NUMBER|JSI_TT_OBJECT|JSI_TT_ARRAY, .flags=0, .info=FN_require, .opts=jsiModuleOptions },
    { "runModule",  SysRunModuleCmd, 0,  2, "cmd:string|function=void, conf:array=undefined", .help="Invoke named module. If name is empty, uses file basename. If isMain and no args givine parses console.args", .retType=(uint)JSI_TT_ANY, .flags=0},
    { "sleep",      SysSleepCmd,     0,  1, "secs:number=1.0",  .help="sleep for N milliseconds, minimum .001", .retType=(uint)JSI_TT_VOID },
#ifndef JSI_OMIT_EVENT
    { "setInterval",setIntervalCmd,  2,  2, "callback:function, ms:number", .help="Setup recurring function to run every given millisecs", .retType=(uint)JSI_TT_NUMBER },
    { "setTimeout", setTimeoutCmd,   2,  2, "callback:function, ms:number", .help="Setup function to run after given millisecs", .retType=(uint)JSI_TT_NUMBER },
#endif
    { "source",     SysSourceCmd,    1,  2, "val:string|array, options:object=void",  .help="Load and evaluate source files", .retType=(uint)JSI_TT_VOID, .flags=0, .info=0, .opts=SourceOptions},
    { "strftime",   DateStrftimeCmd, 0,  2, "num:number=null, options:string|object=void",  .help="Format numeric time (in ms) to a string", .retType=(uint)JSI_TT_STRING, .flags=0, .info=FN_strftime, .opts=DateOptions },







|







 







|







4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
....
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
    const char *anam;
    bool isMain = jsi_isMain(interp);
    if (interp->isMain)
        interp->isMain = 0;
    
    if (v2 && !Jsi_ValueIsObjType(interp, v2, JSI_OT_ARRAY))
        return Jsi_LogError("arg 2: expected array|undefined");
    if (!v1 || Jsi_ValueIsNull(interp, v1)) {
        mod = interp->framePtr->fileName;
        if (mod) mod = Jsi_Strrchr(mod, '/');
        if (!mod) return JSI_ERROR;
        mod++;
        cp = Jsi_Strrchr(mod, '.');
        int len = (cp?(cp-mod):(int)Jsi_Strlen(mod));
        mod = Jsi_DSAppendLen(&dStr, mod, len);
................................................................................
    { "parseFloat", parseFloatCmd,   1,  1, "val", .help="Convert string to a double", .retType=(uint)JSI_TT_NUMBER },
    { "parseOpts",  SysParseOptsCmd, 2,  3, "self:object|userobj, options:object, conf:object|null|undefined", .help="Parse options", .retType=(uint)JSI_TT_ANY, .flags=0},
    { "printf",     SysPrintfCmd,    1, -1, "format:string, ...", .help="Formatted output to stdout", .retType=(uint)JSI_TT_VOID, .flags=0 },
    { "provide",    SysProvideCmd,   0,  3, "name:string|function=void, version:number|string=1.0, opts:object|function=void", .help="Provide a package for use with require. Default is the file tail-rootname", .retType=(uint)JSI_TT_VOID },
    { "puts",       SysPutsCmd,      1, -1, "val, ...", .help="Output one or more values to stdout", .retType=(uint)JSI_TT_VOID, .flags=0, .info=FN_puts },
    { "quote",      SysQuoteCmd,     1,  1, "val:string", .help="Return quoted string", .retType=(uint)JSI_TT_STRING },
    { "require",    SysRequireCmd,   0,  3, "name:string=void, version:number|string=1, options:object=void", .help="Load/query packages", .retType=(uint)JSI_TT_NUMBER|JSI_TT_OBJECT|JSI_TT_ARRAY, .flags=0, .info=FN_require, .opts=jsiModuleOptions },
    { "runModule",  SysRunModuleCmd, 0,  2, "cmd:string|null|function=void, conf:array=undefined", .help="Invoke named module. If name is empty, uses file basename. If isMain and no args givine parses console.args", .retType=(uint)JSI_TT_ANY, .flags=0},
    { "sleep",      SysSleepCmd,     0,  1, "secs:number=1.0",  .help="sleep for N milliseconds, minimum .001", .retType=(uint)JSI_TT_VOID },
#ifndef JSI_OMIT_EVENT
    { "setInterval",setIntervalCmd,  2,  2, "callback:function, ms:number", .help="Setup recurring function to run every given millisecs", .retType=(uint)JSI_TT_NUMBER },
    { "setTimeout", setTimeoutCmd,   2,  2, "callback:function, ms:number", .help="Setup function to run after given millisecs", .retType=(uint)JSI_TT_NUMBER },
#endif
    { "source",     SysSourceCmd,    1,  2, "val:string|array, options:object=void",  .help="Load and evaluate source files", .retType=(uint)JSI_TT_VOID, .flags=0, .info=0, .opts=SourceOptions},
    { "strftime",   DateStrftimeCmd, 0,  2, "num:number=null, options:string|object=void",  .help="Format numeric time (in ms) to a string", .retType=(uint)JSI_TT_STRING, .flags=0, .info=FN_strftime, .opts=DateOptions },

Changes to src/jsiUtils.c.

1037
1038
1039
1040
1041
1042
1043

1044
1045
1046
1047
1048
1049
1050
                    rc = Jsi_EvalString(interp, tbuf, JSI_RETURN);
                }
            }
            if (!wantHelp) {
                if (!Jsi_Strncmp(buf,"var ", 4) && Jsi_Strchr(buf, '\n')==NULL && Jsi_Strchr(buf, ';')==NULL)
                    Jsi_Strcpy(buf+Jsi_Strlen(buf), ";"); // Added space above so strcat ok.
                rc = Jsi_EvalString(interp, buf, JSI_EVAL_RETURN);

#ifdef JSI_HAS_READLINE
                if (rc == JSI_OK)
                    Jsi_DSAppend(&sHist, buf, "\n", NULL);
#endif
            }
        }
        else







>







1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
                    rc = Jsi_EvalString(interp, tbuf, JSI_RETURN);
                }
            }
            if (!wantHelp) {
                if (!Jsi_Strncmp(buf,"var ", 4) && Jsi_Strchr(buf, '\n')==NULL && Jsi_Strchr(buf, ';')==NULL)
                    Jsi_Strcpy(buf+Jsi_Strlen(buf), ";"); // Added space above so strcat ok.
                rc = Jsi_EvalString(interp, buf, JSI_EVAL_RETURN);
                prompt = interp->subOpts.prompt;
#ifdef JSI_HAS_READLINE
                if (rc == JSI_OK)
                    Jsi_DSAppend(&sHist, buf, "\n", NULL);
#endif
            }
        }
        else