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

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

Overview
Comment:Release "2.5.21". Fix Sqlite select "insert" mode for query. Swap -m and -M. Make --module source file then invoke runModule().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e82becfd14065f905d1a07b1ff3cafd3d4373aa0
User & Date: pmacdona 2018-10-15 22:48:15
Context
2018-10-17
01:36
Release "2.5.22". To exec add "chdir" option. check-in: 1cd1d600a3 user: pmacdona tags: trunk
2018-10-15
22:48
Release "2.5.21". Fix Sqlite select "insert" mode for query. Swap -m and -M. Make --module source file then invoke runModule(). check-in: e82becfd14 user: pmacdona tags: trunk
2018-10-11
17:31
Release "2.5.20". Fix issue [a86dc1c04b]: Heap use after free in Jsi_ObjFree. Increase floating point precision to max-1 (default) and make it changable. check-in: 973645aa81 user: pmacdona tags: trunk
Changes

Changes to lib/Jsi_SqliteUI/Jsi_SqliteUI.jsi.

47
48
49
50
51
52
53




















54
55
56
57
58
59
60
...
124
125
126
127
128
129
130

131
132
133
134
135
136
137
138



139
140
141
142
143
144
145
            "CREATE TABLE IF NOT EXISTS dbfiles (file);" +
            "CREATE TABLE IF NOT EXISTS saved_queries (query NOT NULL, dbID NOT NULL);" +
            "CREATE UNIQUE INDEX IF NOT EXISTS savedq_idx ON saved_queries(query, dbID);"
    };
    
    parseOpts(self, options, conf);





















    function tvalsDelete(id:number, d:object)  //Handle submit of tvals action delete.
    {
        var q = 'DELETE FROM "'+d.table+'" WHERE rowid = '+d.rowid+';';
        self.db.query(q);
        WsSend(id,"tvalsDeleteAck",{result:true, tag:d.tag, table:d.table, from:'tvalsDelete'});
    }
    
................................................................................
    function loadTList(id:number)
    {
        var rc = {}, db = self.db;
        var lst = db.query('SELECT * FROM sqlite_master ORDER BY name;');
        self.dbinfo = {};
        for (var t in lst) {
            var l = lst[t];

            if (l.type === 'index') {
                lst[t].info = db.query('PRAGMA index_info("'+l.name+'")');
            }
            if (l.type !== 'table' && l.type !== 'view') continue;
            lst[t].index_list = db.query('PRAGMA index_list("'+l.name+'")');
            lst[t].size = ((self.sizeViews || l.type === 'table')?db.onecolumn('SELECT count(*) FROM "'+l.name+'"'):'');
            lst[t].info = db.query('PRAGMA table_info("'+l.name+'")');
            self.dbinfo[l.name] = l;



        }
        rc.db_list= db.query('PRAGMA database_list');
        if (self.optdb)        
            rc.savedq = self.optdb.eval("SELECT query FROM saved_queries WHERE dbID == $self(dbID)");
        rc.dbfile = self.dbfile;
        rc.dbtail = File.tail(self.dbfile);
        rc.dbdirname = File.dirname(self.dbfile);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
|
|
|
|
|
|
|
|
>
>
>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
            "CREATE TABLE IF NOT EXISTS dbfiles (file);" +
            "CREATE TABLE IF NOT EXISTS saved_queries (query NOT NULL, dbID NOT NULL);" +
            "CREATE UNIQUE INDEX IF NOT EXISTS savedq_idx ON saved_queries(query, dbID);"
    };
    
    parseOpts(self, options, conf);

    function DumpSql(files) {
        var rv = 'PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\n';
        for (var fn of files) {
            var re = '', db = new Sqlite(fn);
            for (var i of db.query("SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL")) {
                if (i.name.match(/^sqlite_/)) continue;
                switch (i.type) {
                    case 'table':
                        rv += i.sql + ';\n' + db.query('SELECT * FROM '+i.name, {mode:'insert', table:i.name});
                        break;
                    case 'index': case 'trigger': case 'view':
                        re += i.sql+';\n';
                }
            }
            rv += re;
        }
        rv += 'COMMIT;\n';
        return rv;
    }
    
    function tvalsDelete(id:number, d:object)  //Handle submit of tvals action delete.
    {
        var q = 'DELETE FROM "'+d.table+'" WHERE rowid = '+d.rowid+';';
        self.db.query(q);
        WsSend(id,"tvalsDeleteAck",{result:true, tag:d.tag, table:d.table, from:'tvalsDelete'});
    }
    
................................................................................
    function loadTList(id:number)
    {
        var rc = {}, db = self.db;
        var lst = db.query('SELECT * FROM sqlite_master ORDER BY name;');
        self.dbinfo = {};
        for (var t in lst) {
            var l = lst[t];
            try {
                if (l.type === 'index') {
                    lst[t].info = db.query('PRAGMA index_info("'+l.name+'")');
                }
                if (l.type !== 'table' && l.type !== 'view') continue;
                lst[t].index_list = db.query('PRAGMA index_list("'+l.name+'")');
                lst[t].size = ((self.sizeViews || l.type === 'table')?db.onecolumn('SELECT count(*) FROM "'+l.name+'"'):'');
                lst[t].info = db.query('PRAGMA table_info("'+l.name+'")');
                self.dbinfo[l.name] = l;
            } catch(e) {
                puts('DB error',e);
            }
        }
        rc.db_list= db.query('PRAGMA database_list');
        if (self.optdb)        
            rc.savedq = self.optdb.eval("SELECT query FROM saved_queries WHERE dbID == $self(dbID)");
        rc.dbfile = self.dbfile;
        rc.dbtail = File.tail(self.dbfile);
        rc.dbdirname = File.dirname(self.dbfile);

Changes to lib/Jsi_SqliteUI/html/main.htmli.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        <table>
        <tr><td class=right title="Table value newlines suppressed">No-Newlines:</td>
            <td> <input type=checkbox onclick='ToggleOpt("wrap")'></td>
        </tr>
        </table>
    </div>
    <div id=uihelp style="display:none">
    <? include('sqliteui_doc.md'); ?>
For more information, see the <a href=/html/sqliteui_doc.md target=_blank>SqliteUI Manual</a>.
    </div>
</div>
<input style="width:90%" id=parm_query title='Enter a free-form SQL query here'>

<div id=tvals_parm style="display:block" class=tblconf>
    <button onclick='TNavAddRow()' id=tnav_row_add title='Add a new row to the current table'>+</button>







|







34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        <table>
        <tr><td class=right title="Table value newlines suppressed">No-Newlines:</td>
            <td> <input type=checkbox onclick='ToggleOpt("wrap")'></td>
        </tr>
        </table>
    </div>
    <div id=uihelp style="display:none">
    <? include('sqliteui_doc.html'); ?>
For more information, see the <a href=/html/sqliteui_doc.md target=_blank>SqliteUI Manual</a>.
    </div>
</div>
<input style="width:90%" id=parm_query title='Enter a free-form SQL query here'>

<div id=tvals_parm style="display:block" class=tblconf>
    <button onclick='TNavAddRow()' id=tnav_row_add title='Add a new row to the current table'>+</button>

Name change from lib/Jsi_SqliteUI/html/sqliteui_doc.md to lib/Jsi_SqliteUI/html/sqliteui_doc.html.

1
2
3
4
5

6
7

8
9
10
11
12
13

14
# Sqlite User-Interface

SqliteUI is a Web user-interface for Sqlite databases
implemented using [Jsi](http://jsish.org) as backend.


Here is an overview of the UI features:


* To view a table, click on it in the Table list.
* To change/limit the view, set values in *WHERE*, *COLUMNS*, *OFFSET*, ...
* Double-click a row to edit it.
* Control-click on a table to view it's schema.
* Toggle open/close a section by clicking on header.
* Type a query at top, and save it as a Saved Query


|



<
>

<
>
|
|
|
|
|
|
>

1
2
3
4

5
6

7
8
9
10
11
12
13
14
15
<h2>Sqlite User-Interface</h2>

SqliteUI is a Web user-interface for Sqlite databases
implemented using [Jsi](http://jsish.org) as backend.

<p>
Here is an overview of the UI features:

<ul>
<li> To view a table, click on it in the Table list.
<li> To change/limit the view, set values in WHERE, COLUMNS, OFFSET, ...
<li> Double-click a row to edit it.
<li> Control-click on a table to view it's schema.
<li> Toggle open/close a section by clicking on header.
<li> Type a query at top, and save it as a Saved Query
</ul>

Changes to src/jsi.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   5
#define JSI_VERSION_RELEASE 20

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* jsi.h : External API header file for Jsi. */
#ifndef __JSI_H__
#define __JSI_H__

#define JSI_VERSION_MAJOR   2
#define JSI_VERSION_MINOR   5
#define JSI_VERSION_RELEASE 21

#define JSI_VERSION (JSI_VERSION_MAJOR + ((Jsi_Number)JSI_VERSION_MINOR/100.0) + ((Jsi_Number)JSI_VERSION_RELEASE/10000.0))

#ifndef JSI_EXTERN
#define JSI_EXTERN extern
#endif

Changes to src/jsiInterp.c.

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
...
690
691
692
693
694
695
696

697
698
699
700
701
702
703
704
705
...
719
720
721
722
723
724
725
726
727
728


729
730
731
732
733
734
735
...
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
....
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
    JSI_OPT(STRKEY, jsi_LogOptions, timeFmt, .help="A format string to use with strftime" ),
    JSI_OPT(USEROBJ,jsi_LogOptions, chan,    .help="Channel to send output to", .flags=0, .custom=0, .data=(void*)"Channel" ),
    JSI_OPT_END(jsi_LogOptions, .help="Interp options for logging")
};
static Jsi_OptionSpec InterpSubOptions[] = {
    JSI_OPT(STRKEY,jsi_SubOptions, blacklist,   .help="Comma separated modules to disable loading for", jsi_IIOF ),
    JSI_OPT(BOOL,  jsi_SubOptions, compat,      .help="Ignore unknown options via JSI_OPTS_IGNORE_EXTRA in option parser" ),
    JSI_OPT(INT,   jsi_SubOptions, dblPrec,     .help="Format precision of double (-1): 0=max, -1=max-1, ..", jsi_IIOF),
    JSI_OPT(BOOL,  jsi_SubOptions, istty,       .help="Indicates interp is in interactive mode", jsi_IIRO),
    JSI_OPT(BOOL,  jsi_SubOptions, logColNums,  .help="Display column numbers in error messages"),
    JSI_OPT(BOOL,  jsi_SubOptions, logAllowDups,.help="Log should not filter out duplicate messages"),
    JSI_OPT(BOOL,  jsi_SubOptions, mutexUnlock, .help="Unlock own mutex when evaling in other interps (true)", jsi_IIOF),
    JSI_OPT(BOOL,  jsi_SubOptions, noproto,     .help="Disable support of the OOP symbols:  __proto__, prototype, constructor, etc"),
    JSI_OPT(BOOL,  jsi_SubOptions, noReadline,  .help="In interactive mode disable use of readline" ),
    JSI_OPT(BOOL,  jsi_SubOptions, outUndef,     .help="In interactive mode output result values that are undefined"),
................................................................................
        if (interp->opts.no_interactive)
            return interp;
        rc = Jsi_Interactive(interp, JSI_OUTPUT_QUOTE|JSI_OUTPUT_NEWLINES);
    } else {
        if (argc == 2 && !Jsi_Strcmp(argv[1], "-h" )) {
            puts("usage: jsish -h/--help | -v/--version | -d/--debug | -D/--debugui | -u/--unittest | -U/-UU\n\t"
            "| -s/--safe | -Z/--zip | -S/--sqliteui | -w/--wget | -W/--websrv | -H/--htmli | -J/--jsi\n\t"
            "| -C/--cssi | -c/--cdata | -M/--module | -m/--make | -e/--eval | -t/--tracecall\n\t"
            "| -a/--archive | -T/--typecheck OPT | -IOPT VAL | FILE arg arg ...\nUse --help for long help.");
            return jsi_DoExit(interp, 1);
        }
        if (argc == 2 && !Jsi_Strcmp(argv[1], "--help")) {
            puts("jsish arguments:\n"
              "  -a/--archive FILE\tMount an archive (zip, sqlar or fossil repo) and run module.\n"
              "  -c/--cdata FILE\tGenerate .c or JSON output from a .jsc description.\n"
................................................................................
              "  -C/--cssi FILE\tPreprocess embedded CSS in .css file.\n"
              "  -d/--debug FILE\tRun console debugger on script.\n"
              "  -D/--debugui FILE\tRun web-gui debugger on script.\n"
              "  -e/--eval STRING\tEvaluate a javascript string and exit.\n"
              "  -h/--help\t\tPrint help in short or long form.\n"
              "  -H/--htmli FILE\tPreprocess embedded jsi in .htmli file.\n"
              "  -J/--jsi FILE\t\tPreprocess a .jsi file to typecheck in standard javascript.\n"

              "  -m/--make FILE\tPreprocess script as a Jsi Makefile.\n"
              "  -M/--module NAME\tInvoke module using runModule(NAME) (eg. from the /zvfs directory).\n"
              "  -s/--safe FILE\tRun script in safe sub-interp.\n"
              "  -S/--sqliteui DBFILE\tRun Sqlite web-gui.\n"
              "  -t/--tracecall\tTrace all function calls.\n"
              "  -T/--typecheck OPT\tEnable typechecking.\n"
              "  -u/--unittest FILE\tRun unit-tests on a script file, or a dir containing .js/.jsi files.\n"
              "  -U/-UU SCRIPT\t\tShow output from unit-test mode, omitting pass/fail compare.\n"
              "  -v/--version\t\tPrint short/long version info and exit.\n"
................................................................................
            printf("%u.%u.%u %.4" JSI_NUMGFMT " %s", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE, Jsi_Version(), str);
            return jsi_DoExit(interp, 1);
        }
        if (argc == 2 && !Jsi_Strcmp(argv[1], "-v" )) {
            printf("%u.%u.%u\n", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE);
            return jsi_DoExit(interp, 1);
        }
        if (argc > 2 && (Jsi_Strcmp(argv[1], "--module")==0 || Jsi_Strcmp(argv[1], "-M" )==0)) {
            Jsi_DString dStr = {};
            Jsi_DSAppend(&dStr, "runModule(\"", argv[2], "\",console.args.slice(1));", NULL);


            rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
            Jsi_DSFree(&dStr);
        }
        else if (argc == 3 && (Jsi_Strcmp(argv[1], "--eval")==0 || Jsi_Strcmp(argv[1], "-e" )==0))
            rc = Jsi_EvalString(interp, argv[2], JSI_EVAL_NOSKIPBANG);

        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--debug")==0 || Jsi_Strcmp(argv[1], "-d" )==0)) {
................................................................................
            rc = Jsi_EvalString(interp, "runModule('Jsi_Csspp');", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--jsi")==0 || Jsi_Strcmp(argv[1], "-J" )==0))
            rc = Jsi_EvalString(interp, "runModule('Jsi_Jspp');", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--htmli")==0 || Jsi_Strcmp(argv[1], "-H" )==0))
            rc = Jsi_EvalString(interp, "runModule('Jsi_Htmlpp');", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--unittest")==0 || Jsi_Strcmp(argv[1], "-u" )==0))
            rc = Jsi_EvalString(interp, "exit(runModule('Jsi_UnitTest'));", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--make")==0 || Jsi_Strcmp(argv[1], "-m" )==0))
            rc = Jsi_EvalString(interp, "exit(runModule('Jsi_Make'));", JSI_EVAL_ISMAIN);
        else {
            int iocnt;
            for (iocnt = 1; (iocnt+1)<argc; iocnt+=2) {
                if (Jsi_Strcmp(argv[iocnt], "-t") == 0 || Jsi_Strcmp(argv[iocnt], "--tracecall") == 0) {iocnt--; continue; }
                if (Jsi_Strcmp(argv[iocnt], "-T") == 0 || Jsi_Strcmp(argv[iocnt], "--typecheck") == 0) {continue; }
                if (Jsi_Strcmp(argv[iocnt], "-U") == 0) {iocnt--; continue; }
................................................................................
            Jsi_LogError("exceeded max subinterp depth");
            return NULL;
        }
    }
    interp->maxDepth = JSI_MAX_EVAL_DEPTH;
    interp->maxIncDepth = JSI_MAX_INCLUDE_DEPTH;
    interp->typeWarnMax = 50;
    interp->subOpts.dblPrec = -1;

    int iocnt;
    if (iopts) {
        iopts->interp = interp;
        interp->opts = *iopts;
    }
    interp->logOpts.file = 1;







|







 







|







 







>
|
<







 







|

|
>
>







 







|







 







|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
...
690
691
692
693
694
695
696
697
698

699
700
701
702
703
704
705
...
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
...
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
....
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
    JSI_OPT(STRKEY, jsi_LogOptions, timeFmt, .help="A format string to use with strftime" ),
    JSI_OPT(USEROBJ,jsi_LogOptions, chan,    .help="Channel to send output to", .flags=0, .custom=0, .data=(void*)"Channel" ),
    JSI_OPT_END(jsi_LogOptions, .help="Interp options for logging")
};
static Jsi_OptionSpec InterpSubOptions[] = {
    JSI_OPT(STRKEY,jsi_SubOptions, blacklist,   .help="Comma separated modules to disable loading for", jsi_IIOF ),
    JSI_OPT(BOOL,  jsi_SubOptions, compat,      .help="Ignore unknown options via JSI_OPTS_IGNORE_EXTRA in option parser" ),
    JSI_OPT(INT,   jsi_SubOptions, dblPrec,     .help="Format precision of double where 0=max, -1=max-1, ... (max-1)", jsi_IIOF),
    JSI_OPT(BOOL,  jsi_SubOptions, istty,       .help="Indicates interp is in interactive mode", jsi_IIRO),
    JSI_OPT(BOOL,  jsi_SubOptions, logColNums,  .help="Display column numbers in error messages"),
    JSI_OPT(BOOL,  jsi_SubOptions, logAllowDups,.help="Log should not filter out duplicate messages"),
    JSI_OPT(BOOL,  jsi_SubOptions, mutexUnlock, .help="Unlock own mutex when evaling in other interps (true)", jsi_IIOF),
    JSI_OPT(BOOL,  jsi_SubOptions, noproto,     .help="Disable support of the OOP symbols:  __proto__, prototype, constructor, etc"),
    JSI_OPT(BOOL,  jsi_SubOptions, noReadline,  .help="In interactive mode disable use of readline" ),
    JSI_OPT(BOOL,  jsi_SubOptions, outUndef,     .help="In interactive mode output result values that are undefined"),
................................................................................
        if (interp->opts.no_interactive)
            return interp;
        rc = Jsi_Interactive(interp, JSI_OUTPUT_QUOTE|JSI_OUTPUT_NEWLINES);
    } else {
        if (argc == 2 && !Jsi_Strcmp(argv[1], "-h" )) {
            puts("usage: jsish -h/--help | -v/--version | -d/--debug | -D/--debugui | -u/--unittest | -U/-UU\n\t"
            "| -s/--safe | -Z/--zip | -S/--sqliteui | -w/--wget | -W/--websrv | -H/--htmli | -J/--jsi\n\t"
            "| -C/--cssi | -c/--cdata | -m/--module | -M/--make | -e/--eval | -t/--tracecall\n\t"
            "| -a/--archive | -T/--typecheck OPT | -IOPT VAL | FILE arg arg ...\nUse --help for long help.");
            return jsi_DoExit(interp, 1);
        }
        if (argc == 2 && !Jsi_Strcmp(argv[1], "--help")) {
            puts("jsish arguments:\n"
              "  -a/--archive FILE\tMount an archive (zip, sqlar or fossil repo) and run module.\n"
              "  -c/--cdata FILE\tGenerate .c or JSON output from a .jsc description.\n"
................................................................................
              "  -C/--cssi FILE\tPreprocess embedded CSS in .css file.\n"
              "  -d/--debug FILE\tRun console debugger on script.\n"
              "  -D/--debugui FILE\tRun web-gui debugger on script.\n"
              "  -e/--eval STRING\tEvaluate a javascript string and exit.\n"
              "  -h/--help\t\tPrint help in short or long form.\n"
              "  -H/--htmli FILE\tPreprocess embedded jsi in .htmli file.\n"
              "  -J/--jsi FILE\t\tPreprocess a .jsi file to typecheck in standard javascript.\n"
              "  -m/--module FILE\tSource file and invoke runModule.\n"
              "  -M/--make FILE\tPreprocess script as a Jsi Makefile.\n"

              "  -s/--safe FILE\tRun script in safe sub-interp.\n"
              "  -S/--sqliteui DBFILE\tRun Sqlite web-gui.\n"
              "  -t/--tracecall\tTrace all function calls.\n"
              "  -T/--typecheck OPT\tEnable typechecking.\n"
              "  -u/--unittest FILE\tRun unit-tests on a script file, or a dir containing .js/.jsi files.\n"
              "  -U/-UU SCRIPT\t\tShow output from unit-test mode, omitting pass/fail compare.\n"
              "  -v/--version\t\tPrint short/long version info and exit.\n"
................................................................................
            printf("%u.%u.%u %.4" JSI_NUMGFMT " %s", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE, Jsi_Version(), str);
            return jsi_DoExit(interp, 1);
        }
        if (argc == 2 && !Jsi_Strcmp(argv[1], "-v" )) {
            printf("%u.%u.%u\n", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE);
            return jsi_DoExit(interp, 1);
        }
        if (argc > 2 && (Jsi_Strcmp(argv[1], "--module")==0 || Jsi_Strcmp(argv[1], "-m" )==0)) {
            Jsi_DString dStr = {};
            const char* cpe = Jsi_Strrchr(argv[2], '.');
            int len = (cpe?cpe-argv[2]:Jsi_Strlen(argv[2]));
            Jsi_DSPrintf(&dStr, "source(\"%s\"); puts(runModule(\"%.*s\",console.args.slice(1)));", argv[2], len, argv[2]);
            rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
            Jsi_DSFree(&dStr);
        }
        else if (argc == 3 && (Jsi_Strcmp(argv[1], "--eval")==0 || Jsi_Strcmp(argv[1], "-e" )==0))
            rc = Jsi_EvalString(interp, argv[2], JSI_EVAL_NOSKIPBANG);

        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--debug")==0 || Jsi_Strcmp(argv[1], "-d" )==0)) {
................................................................................
            rc = Jsi_EvalString(interp, "runModule('Jsi_Csspp');", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--jsi")==0 || Jsi_Strcmp(argv[1], "-J" )==0))
            rc = Jsi_EvalString(interp, "runModule('Jsi_Jspp');", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--htmli")==0 || Jsi_Strcmp(argv[1], "-H" )==0))
            rc = Jsi_EvalString(interp, "runModule('Jsi_Htmlpp');", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--unittest")==0 || Jsi_Strcmp(argv[1], "-u" )==0))
            rc = Jsi_EvalString(interp, "exit(runModule('Jsi_UnitTest'));", JSI_EVAL_ISMAIN);
        else if (interp->selfZvfs && argc > 1 && (Jsi_Strcmp(argv[1], "--make")==0 || Jsi_Strcmp(argv[1], "-M" )==0))
            rc = Jsi_EvalString(interp, "exit(runModule('Jsi_Make'));", JSI_EVAL_ISMAIN);
        else {
            int iocnt;
            for (iocnt = 1; (iocnt+1)<argc; iocnt+=2) {
                if (Jsi_Strcmp(argv[iocnt], "-t") == 0 || Jsi_Strcmp(argv[iocnt], "--tracecall") == 0) {iocnt--; continue; }
                if (Jsi_Strcmp(argv[iocnt], "-T") == 0 || Jsi_Strcmp(argv[iocnt], "--typecheck") == 0) {continue; }
                if (Jsi_Strcmp(argv[iocnt], "-U") == 0) {iocnt--; continue; }
................................................................................
            Jsi_LogError("exceeded max subinterp depth");
            return NULL;
        }
    }
    interp->maxDepth = JSI_MAX_EVAL_DEPTH;
    interp->maxIncDepth = JSI_MAX_INCLUDE_DEPTH;
    interp->typeWarnMax = 50;
    interp->subOpts.dblPrec = DBL_DECIMAL_DIG-1;

    int iocnt;
    if (iopts) {
        iopts->interp = interp;
        interp->opts = *iopts;
    }
    interp->logOpts.file = 1;

Changes to src/jsiOptions.c.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    {_JSI_OPNM(TIME_W),  .cName="time_w",   .size=sizeof(time_w),     .fmt=PRId64, .xfmt="#" PRIx64,   .sfmt=SCNd64, .help="A time value in milliseconds stored as a 64 bit integer" },
    {_JSI_OPNM(TIME_D),  .cName="time_d",   .size=sizeof(time_d),     .fmt="g",    .xfmt="#" "g",      .sfmt="g", .help="A time value in milliseconds stored as a double" },
    {_JSI_OPNM(TIME_T),  .cName="time_t",   .size=sizeof(time_t),     .fmt="ld",   .xfmt="#lx",  .sfmt="ld", .help="A time value stored in a unix time_t" },
    {_JSI_OPNM(SIZE_T),  .cName="size_t",   .size=sizeof(size_t),     .fmt="zd",   .xfmt="#zx",  .sfmt="z", .help="Size unsigned" },
    {_JSI_OPNM(SSIZE_T), .cName="ssize_t",  .size=sizeof(ssize_t),    .fmt="zu",   .xfmt="#zx",  .sfmt="zu", .help="Size integer" },
    {_JSI_OPNM(INTPTR_T),.cName="intptr_t", .size=sizeof(intptr_t),   .fmt="d",    .xfmt="#x",   .sfmt="d", .help="Integer large enough to store pointer" },
    {_JSI_OPNM(UINTPTR_T),.cName="uintptr_t",.size=sizeof(uintptr_t), .fmt="u",    .xfmt="#x",   .sfmt="u", .help="Unsigned large enough to store pointer" },
    {_JSI_OPNM(NUMBER),   .cName="Jsi_Number",.size=sizeof(Jsi_Number),.fmt=JSI_NUMGFMT, .xfmt="#" JSI_NUMGFMT,   .sfmt=JSI_NUMGFMT, .help="Double or long double" },
    {_JSI_OPNM(INT),     .cName="int",      .size=sizeof(int),        .fmt="d",    .xfmt="#x",   .sfmt="d", .help="Integer" },
    {_JSI_OPNM(UINT),    .cName="uint",     .size=sizeof(uint),       .fmt="u",    .xfmt="#x",   .sfmt="u", .help="Unsigned" },
    {_JSI_OPNM(LONG),    .cName="long",     .size=sizeof(long),       .fmt="ld",   .xfmt="#lx",  .sfmt="ld", .help="Long" },
    {_JSI_OPNM(ULONG),   .cName="ulong",    .size=sizeof(ulong),      .fmt="lu",   .xfmt="#lx",  .sfmt="lu", .help="Unsigned long" },
    {_JSI_OPNM(SHORT),   .cName="short",    .size=sizeof(short),      .fmt="hd",   .xfmt="#hx",  .sfmt="hd", .help="Short" },
    {_JSI_OPNM(USHORT),  .cName="ushort",   .size=sizeof(ushort),     .fmt="hu",   .xfmt="#hx",  .sfmt="hu", .help="Unsigned short" },
    {_JSI_OPNM(STRING),  .cName="Jsi_Value*",.size=sizeof(Jsi_Value*),.fmt="s",    .xfmt="s", .sfmt=0, .help="A string Value"},







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    {_JSI_OPNM(TIME_W),  .cName="time_w",   .size=sizeof(time_w),     .fmt=PRId64, .xfmt="#" PRIx64,   .sfmt=SCNd64, .help="A time value in milliseconds stored as a 64 bit integer" },
    {_JSI_OPNM(TIME_D),  .cName="time_d",   .size=sizeof(time_d),     .fmt="g",    .xfmt="#" "g",      .sfmt="g", .help="A time value in milliseconds stored as a double" },
    {_JSI_OPNM(TIME_T),  .cName="time_t",   .size=sizeof(time_t),     .fmt="ld",   .xfmt="#lx",  .sfmt="ld", .help="A time value stored in a unix time_t" },
    {_JSI_OPNM(SIZE_T),  .cName="size_t",   .size=sizeof(size_t),     .fmt="zd",   .xfmt="#zx",  .sfmt="z", .help="Size unsigned" },
    {_JSI_OPNM(SSIZE_T), .cName="ssize_t",  .size=sizeof(ssize_t),    .fmt="zu",   .xfmt="#zx",  .sfmt="zu", .help="Size integer" },
    {_JSI_OPNM(INTPTR_T),.cName="intptr_t", .size=sizeof(intptr_t),   .fmt="d",    .xfmt="#x",   .sfmt="d", .help="Integer large enough to store pointer" },
    {_JSI_OPNM(UINTPTR_T),.cName="uintptr_t",.size=sizeof(uintptr_t), .fmt="u",    .xfmt="#x",   .sfmt="u", .help="Unsigned large enough to store pointer" },
    {_JSI_OPNM(NUMBER),  .cName="Jsi_Number",.size=sizeof(Jsi_Number),.fmt=JSI_NUMGFMT,.xfmt="#" JSI_NUMGFMT,.sfmt=JSI_NUMGFMT, .help="Double or long double" },
    {_JSI_OPNM(INT),     .cName="int",      .size=sizeof(int),        .fmt="d",    .xfmt="#x",   .sfmt="d", .help="Integer" },
    {_JSI_OPNM(UINT),    .cName="uint",     .size=sizeof(uint),       .fmt="u",    .xfmt="#x",   .sfmt="u", .help="Unsigned" },
    {_JSI_OPNM(LONG),    .cName="long",     .size=sizeof(long),       .fmt="ld",   .xfmt="#lx",  .sfmt="ld", .help="Long" },
    {_JSI_OPNM(ULONG),   .cName="ulong",    .size=sizeof(ulong),      .fmt="lu",   .xfmt="#lx",  .sfmt="lu", .help="Unsigned long" },
    {_JSI_OPNM(SHORT),   .cName="short",    .size=sizeof(short),      .fmt="hd",   .xfmt="#hx",  .sfmt="hd", .help="Short" },
    {_JSI_OPNM(USHORT),  .cName="ushort",   .size=sizeof(ushort),     .fmt="hu",   .xfmt="#hx",  .sfmt="hu", .help="Unsigned short" },
    {_JSI_OPNM(STRING),  .cName="Jsi_Value*",.size=sizeof(Jsi_Value*),.fmt="s",    .xfmt="s", .sfmt=0, .help="A string Value"},

Changes to src/jsiSqlite.c.

2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
....
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
    
    case _JSI_EF_INSERT: {
        Jsi_DString vStr = {};    
        while( JSI_OK==(rc = dbEvalStep(&sEval)) ) {
            int i;
            int nCol;
            const char *tbl = (opts.table ? opts.table : "table");
            if (cnt)
                Jsi_DSAppend(dStr, "\n", NULL);
            Jsi_DSAppend(dStr, "INSERT INTO ", tbl, " VALUES(", NULL);
            dbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
            for(i=0; i<nCol; i++) {
                Jsi_Number dv;
                const char *azArg;
                Jsi_DSSetLength(&vStr, 0);
                dbEvalSetColumn(&sEval, i, &vStr);
                sqlite3_stmt *pStmt = sEval.pPreStmt->pStmt;
                int ptype = sqlite3_column_type(pStmt, i);
                
                azArg = Jsi_DSValue(&vStr);
                const char *zSep = i>0 ? ",": "";
                if( (azArg[i]==0) || (apColType && apColType[i]==SQLITE_NULL) ) {
                  Jsi_DSAppend(dStr, zSep, "NULL", NULL);
                }else if( ptype ==SQLITE_TEXT ) {
                  if( zSep[0] ) Jsi_DSAppend(dStr,zSep, NULL);
                  dbOutputQuotedString(dStr, azArg);
                }else if (ptype==SQLITE_INTEGER || ptype ==SQLITE_FLOAT) {
                  Jsi_DSAppend(dStr, zSep, azArg, NULL);
                }else if (ptype ==SQLITE_BLOB) {
................................................................................
                }else if( Jsi_GetDouble(interp, azArg, &dv) == JSI_OK ){
                  Jsi_DSAppend(dStr, zSep, azArg, NULL);
                }else{
                  if( zSep[0] ) Jsi_DSAppend(dStr,zSep, NULL);
                  dbOutputQuotedString(dStr, azArg);
                }
            }
            Jsi_DSAppend(dStr, ");", NULL);
            cnt++;
            if (opts.limit && cnt>=opts.limit) break;
        }
        Jsi_DSFree(&vStr);
    }

    case _JSI_EF_TABS:







<
<
|











|







 







|







2767
2768
2769
2770
2771
2772
2773


2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
....
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
    
    case _JSI_EF_INSERT: {
        Jsi_DString vStr = {};    
        while( JSI_OK==(rc = dbEvalStep(&sEval)) ) {
            int i;
            int nCol;
            const char *tbl = (opts.table ? opts.table : "table");


            Jsi_DSAppend(dStr, "INSERT INTO \"", tbl, "\" VALUES(", NULL);
            dbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
            for(i=0; i<nCol; i++) {
                Jsi_Number dv;
                const char *azArg;
                Jsi_DSSetLength(&vStr, 0);
                dbEvalSetColumn(&sEval, i, &vStr);
                sqlite3_stmt *pStmt = sEval.pPreStmt->pStmt;
                int ptype = sqlite3_column_type(pStmt, i);
                
                azArg = Jsi_DSValue(&vStr);
                const char *zSep = i>0 ? ",": "";
                if(apColType && apColType[i]==SQLITE_NULL) {
                  Jsi_DSAppend(dStr, zSep, "NULL", NULL);
                }else if( ptype ==SQLITE_TEXT ) {
                  if( zSep[0] ) Jsi_DSAppend(dStr,zSep, NULL);
                  dbOutputQuotedString(dStr, azArg);
                }else if (ptype==SQLITE_INTEGER || ptype ==SQLITE_FLOAT) {
                  Jsi_DSAppend(dStr, zSep, azArg, NULL);
                }else if (ptype ==SQLITE_BLOB) {
................................................................................
                }else if( Jsi_GetDouble(interp, azArg, &dv) == JSI_OK ){
                  Jsi_DSAppend(dStr, zSep, azArg, NULL);
                }else{
                  if( zSep[0] ) Jsi_DSAppend(dStr,zSep, NULL);
                  dbOutputQuotedString(dStr, azArg);
                }
            }
            Jsi_DSAppend(dStr, ");\n", NULL);
            cnt++;
            if (opts.limit && cnt>=opts.limit) break;
        }
        Jsi_DSFree(&vStr);
    }

    case _JSI_EF_TABS: