Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Release "2.8.26". Interactive mode: change prompt to $ and an Interp option for changing it. Add history command for non-error cmds. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 00607b6d2b09c4d6a322e3d2bdccee77 |
User & Date: | pmacdona 2019-05-07 16:53:37 |
Original Comment: | Release "2.8.26". Interactive mode: change prompt to $. Add history command for non-error cmds. |
Context
2019-05-07
| ||
21:19 | Fix build without readline. check-in: 3ddfb7d113 user: pmacdona tags: trunk | |
16:53 | Release "2.8.26". Interactive mode: change prompt to $ and an Interp option for changing it. Add history command for non-error cmds. check-in: 00607b6d2b user: pmacdona tags: trunk | |
16:09 | Release "2.8.25". Fix function toString. check-in: c4e699bfd5 user: pmacdona tags: trunk | |
Changes
Changes to md/Reference.md.
690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
<tr><td>logAllowDups</td><td><i>BOOL</i></td><td>Log should not filter out duplicate messages.</td><td><i></i></td></tr> <tr><td>mutexUnlock</td><td><i>BOOL</i></td><td>Unlock own mutex when evaling in other interps (true).</td><td><i>initOnly</i></td></tr> <tr><td>noproto</td><td><i>BOOL</i></td><td>Disable support of the OOP symbols: __proto__, prototype, constructor, etc.</td><td><i></i></td></tr> <tr><td>noFuncString</td><td><i>BOOL</i></td><td>Disable viewing code body for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noRegex</td><td><i>BOOL</i></td><td>Disable viewing code for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noReadline</td><td><i>BOOL</i></td><td>In interactive mode disable use of readline.</td><td><i></i></td></tr> <tr><td>outUndef</td><td><i>BOOL</i></td><td>In interactive mode output result values that are undefined.</td><td><i></i></td></tr> </table> <a name="Interpend"></a> <p><a href="#TOC">Return to top</a> <a name="JSON"></a> <hr> |
> > |
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 |
<tr><td>logAllowDups</td><td><i>BOOL</i></td><td>Log should not filter out duplicate messages.</td><td><i></i></td></tr> <tr><td>mutexUnlock</td><td><i>BOOL</i></td><td>Unlock own mutex when evaling in other interps (true).</td><td><i>initOnly</i></td></tr> <tr><td>noproto</td><td><i>BOOL</i></td><td>Disable support of the OOP symbols: __proto__, prototype, constructor, etc.</td><td><i></i></td></tr> <tr><td>noFuncString</td><td><i>BOOL</i></td><td>Disable viewing code body for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noRegex</td><td><i>BOOL</i></td><td>Disable viewing code for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noReadline</td><td><i>BOOL</i></td><td>In interactive mode disable use of readline.</td><td><i></i></td></tr> <tr><td>outUndef</td><td><i>BOOL</i></td><td>In interactive mode output result values that are undefined.</td><td><i></i></td></tr> <tr><td>prompt</td><td><i>STRKEY</i></td><td>Prompt for interactive mode ('$ ').</td><td><i></i></td></tr> <tr><td>prompt2</td><td><i>STRKEY</i></td><td>Prompt for interactive mode line continue ('> ').</td><td><i></i></td></tr> </table> <a name="Interpend"></a> <p><a href="#TOC">Return to top</a> <a name="JSON"></a> <hr> |
Changes to src/jsi.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 .... 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 ..... 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 ..... 20966 20967 20968 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 ..... 23801 23802 23803 23804 23805 23806 23807 23808 23809 23810 23811 23812 23813 23814 23815 ..... 23822 23823 23824 23825 23826 23827 23828 23829 23830 23831 23832 23833 23834 23835 23836 ..... 23840 23841 23842 23843 23844 23845 23846 23847 23848 23849 23850 23851 23852 23853 23854 23855 23856 23857 23858 23859 23860 23861 23862 23863 23864 ..... 23865 23866 23867 23868 23869 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 23888 23889 23890 23891 ..... 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 23902 23903 23904 23905 ..... 23931 23932 23933 23934 23935 23936 23937 23938 23939 23940 23941 23942 23943 23944 |
/* jsi.h : External API header file for Jsi. */ #ifndef __JSI_H__ #define __JSI_H__ #define JSI_VERSION_MAJOR 2 #define JSI_VERSION_MINOR 8 #define JSI_VERSION_RELEASE 25 #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 ................................................................................ bool logColNums; bool privKeys; bool compat; bool mutexUnlock; bool noFuncString; int dblPrec; const char *blacklist; } jsi_SubOptions; extern Jsi_OptionSpec jsi_InterpLogOptions[]; typedef enum { jsi_TL_TRY, jsi_TL_WITH, ................................................................................ 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, noFuncString,.help="Disable viewing code body for functions", jsi_IIOF), JSI_OPT(BOOL, jsi_SubOptions, noRegex, .help="Disable viewing code for functions", jsi_IIOF), 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"), JSI_OPT_END(jsi_SubOptions, .help="Lesser sub-feature options") }; static const char *jsi_SafeModeStrs[] = { "none", "read", "write", "write2", NULL }; static const char *jsi_TypeChkStrs[] = { "parse", "run", "all", "error", "strict", "noundef", "nowith", "funcsig", NULL }; const char *jsi_callTraceStrs[] = { "funcs", "cmds", "new", "return", "args", "notrunc", "noparent", "full", "before", NULL}; const char *jsi_AssertModeStrs[] = { "throw", "log", "puts", NULL}; ................................................................................ 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; ................................................................................ #endif /* Collect and execute code from stdin. The first byte of flags are passed to Jsi_ValueGetDString(). */ Jsi_RC Jsi_Interactive(Jsi_Interp* interp, int flags) { Jsi_RC rc = JSI_OK; int done = 0, len, quote = (flags & 0xff), istty = 1, chkHelp=0, hasHelp=0; const char *prompt = "# "; char *buf; if (jsi_interactiveInterp) return Jsi_LogError("multiple interactive not supported"); #if JSI__SIGNAL signal(SIGINT, jsi_InteractiveSignal); #endif interp->typeCheck.parse = interp->typeCheck.run = interp->typeCheck.all = 1; ................................................................................ Jsi_DSInit(&dStr); #ifndef __WIN32 istty = isatty(fileno(stdin)); #else istty = _isatty(_fileno(stdin)); #endif #ifdef JSI_HAS_READLINE Jsi_DString dHist = {}; char *hist = NULL; #ifdef USE_GNU_READLINE rl_attempted_completion_function = jsiRlGetMatches; #else linenoiseSetCompletionCallback(jsiLNGetMatches); linenoiseSetHintsCallback(jsiLNhints); #endif ................................................................................ hist = Jsi_NormalPath(interp, hfile, &dHist); if (hist) jsi_sh_read_history(hist); } #endif interp->level++; if (!interp->iskips) puts("Jsish interactive: see 'help [cmd]'. \\ cancels > input." #if JSI__SIGNAL " ctrl-c aborts running script." #endif ); while (done==0 && interp->exited==0) { buf = get_inputline(interp, istty, prompt); if (buf) { if (buf[0] == '\\' && !buf[1]) { Jsi_DSSetLength(&dStr, 0); prompt = "# "; fprintf(stderr, "abandoned input"); } else Jsi_DSAppend(&dStr, buf, NULL); free(buf); } else { done = 1; } ................................................................................ len = Jsi_DSLength(&dStr); if (done && len == 0) break; if (!len) continue; Jsi_DSAppendLen(&dStr, " ", 1); // Allow for added space. buf = Jsi_DSValue(&dStr); if (done == 0 && (!jsi_StrIsBalanced(buf))) { prompt = "> "; continue; } prompt = "# "; while ((len = Jsi_Strlen(buf))>0 && (isspace(buf[len-1]))) buf[len-1] = 0; if (buf[0] == 0) { Jsi_DSSetLength(&dStr, 0); continue; } bool wantHelp = 0; if (interp->onEval == NULL) { /* Convenience: add semicolon to "var" statements (required by parser). */ if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) { if (!chkHelp++) hasHelp = (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0); if (hasHelp) { wantHelp = 1; char tbuf[BUFSIZ]; snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", buf+4); ................................................................................ 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); } } else { Jsi_Value *func = interp->onEval; if (func && Jsi_ValueIsFunction(interp, func)) { Jsi_Value *items[1] = {}; ................................................................................ interp->level--; #ifdef JSI_HAS_READLINE if (hist) { jsi_sh_stifle_history(100); jsi_sh_write_history(hist); } Jsi_DSFree(&dHist); #endif Jsi_DSFree(&dStr); if (interp->retValue) { Jsi_DecrRefCount(interp, interp->retValue); interp->retValue = NULL; } if (interp->exited && interp->level <= 0) |
| > > > > > | | | | | | > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 .... 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 ..... 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 ..... 20969 20970 20971 20972 20973 20974 20975 20976 20977 20978 20979 20980 20981 20982 20983 20984 ..... 23806 23807 23808 23809 23810 23811 23812 23813 23814 23815 23816 23817 23818 23819 23820 ..... 23827 23828 23829 23830 23831 23832 23833 23834 23835 23836 23837 23838 23839 23840 23841 ..... 23845 23846 23847 23848 23849 23850 23851 23852 23853 23854 23855 23856 23857 23858 23859 23860 23861 23862 23863 23864 23865 23866 23867 23868 23869 ..... 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 23888 23889 23890 23891 23892 23893 23894 23895 23896 23897 23898 23899 23900 23901 ..... 23902 23903 23904 23905 23906 23907 23908 23909 23910 23911 23912 23913 23914 23915 23916 23917 ..... 23943 23944 23945 23946 23947 23948 23949 23950 23951 23952 23953 23954 23955 23956 23957 |
/* jsi.h : External API header file for Jsi. */ #ifndef __JSI_H__ #define __JSI_H__ #define JSI_VERSION_MAJOR 2 #define JSI_VERSION_MINOR 8 #define JSI_VERSION_RELEASE 26 #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 ................................................................................ bool logColNums; bool privKeys; bool compat; bool mutexUnlock; bool noFuncString; int dblPrec; const char *blacklist; const char *prompt, *prompt2; } jsi_SubOptions; extern Jsi_OptionSpec jsi_InterpLogOptions[]; typedef enum { jsi_TL_TRY, jsi_TL_WITH, ................................................................................ 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, noFuncString,.help="Disable viewing code body for functions", jsi_IIOF), JSI_OPT(BOOL, jsi_SubOptions, noRegex, .help="Disable viewing code for functions", jsi_IIOF), 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"), JSI_OPT(STRKEY,jsi_SubOptions, prompt, .help="Prompt for interactive mode ('$ ')" ), JSI_OPT(STRKEY,jsi_SubOptions, prompt2, .help="Prompt for interactive mode line continue ('> ')" ), JSI_OPT_END(jsi_SubOptions, .help="Lesser sub-feature options") }; static const char *jsi_SafeModeStrs[] = { "none", "read", "write", "write2", NULL }; static const char *jsi_TypeChkStrs[] = { "parse", "run", "all", "error", "strict", "noundef", "nowith", "funcsig", NULL }; const char *jsi_callTraceStrs[] = { "funcs", "cmds", "new", "return", "args", "notrunc", "noparent", "full", "before", NULL}; const char *jsi_AssertModeStrs[] = { "throw", "log", "puts", NULL}; ................................................................................ return NULL; } } interp->maxDepth = JSI_MAX_EVAL_DEPTH; interp->maxIncDepth = JSI_MAX_INCLUDE_DEPTH; interp->typeWarnMax = 50; interp->subOpts.dblPrec = __DBL_DECIMAL_DIG__-1; interp->subOpts.prompt = "$ "; interp->subOpts.prompt2 = "> "; int iocnt; if (iopts) { iopts->interp = interp; interp->opts = *iopts; } interp->logOpts.file = 1; ................................................................................ #endif /* Collect and execute code from stdin. The first byte of flags are passed to Jsi_ValueGetDString(). */ Jsi_RC Jsi_Interactive(Jsi_Interp* interp, int flags) { Jsi_RC rc = JSI_OK; int done = 0, len, quote = (flags & 0xff), istty = 1, chkHelp=0, hasHelp=0; const char *prompt = interp->subOpts.prompt; char *buf; if (jsi_interactiveInterp) return Jsi_LogError("multiple interactive not supported"); #if JSI__SIGNAL signal(SIGINT, jsi_InteractiveSignal); #endif interp->typeCheck.parse = interp->typeCheck.run = interp->typeCheck.all = 1; ................................................................................ Jsi_DSInit(&dStr); #ifndef __WIN32 istty = isatty(fileno(stdin)); #else istty = _isatty(_fileno(stdin)); #endif #ifdef JSI_HAS_READLINE Jsi_DString dHist = {}, sHist = {}; char *hist = NULL; #ifdef USE_GNU_READLINE rl_attempted_completion_function = jsiRlGetMatches; #else linenoiseSetCompletionCallback(jsiLNGetMatches); linenoiseSetHintsCallback(jsiLNhints); #endif ................................................................................ hist = Jsi_NormalPath(interp, hfile, &dHist); if (hist) jsi_sh_read_history(hist); } #endif interp->level++; if (!interp->iskips) puts("Jsish interactive: see 'help [cmd]' or 'history'. \\ cancels > input." #if JSI__SIGNAL " ctrl-c aborts running script." #endif ); while (done==0 && interp->exited==0) { buf = get_inputline(interp, istty, prompt); if (buf) { if (buf[0] == '\\' && !buf[1]) { Jsi_DSSetLength(&dStr, 0); prompt = interp->subOpts.prompt; fprintf(stderr, "abandoned input"); } else Jsi_DSAppend(&dStr, buf, NULL); free(buf); } else { done = 1; } ................................................................................ len = Jsi_DSLength(&dStr); if (done && len == 0) break; if (!len) continue; Jsi_DSAppendLen(&dStr, " ", 1); // Allow for added space. buf = Jsi_DSValue(&dStr); if (done == 0 && (!jsi_StrIsBalanced(buf))) { prompt = interp->subOpts.prompt2; continue; } prompt = interp->subOpts.prompt; while ((len = Jsi_Strlen(buf))>0 && (isspace(buf[len-1]))) buf[len-1] = 0; if (buf[0] == 0) { Jsi_DSSetLength(&dStr, 0); continue; } bool wantHelp = 0; if (interp->onEval == NULL) { /* Convenience: add semicolon to "var" statements (required by parser). */ if (!Jsi_Strncmp(buf, "history", 7) && buf[7] == 0) { fputs(Jsi_DSValue(&sHist), stdout); Jsi_DSSetLength(&dStr, 0); continue; } if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) { if (!chkHelp++) hasHelp = (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0); if (hasHelp) { wantHelp = 1; char tbuf[BUFSIZ]; snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", buf+4); ................................................................................ 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); if (rc == JSI_OK) Jsi_DSAppend(&sHist, buf, "\n", NULL); } } else { Jsi_Value *func = interp->onEval; if (func && Jsi_ValueIsFunction(interp, func)) { Jsi_Value *items[1] = {}; ................................................................................ interp->level--; #ifdef JSI_HAS_READLINE if (hist) { jsi_sh_stifle_history(100); jsi_sh_write_history(hist); } Jsi_DSFree(&dHist); Jsi_DSFree(&sHist); #endif Jsi_DSFree(&dStr); if (interp->retValue) { Jsi_DecrRefCount(interp, interp->retValue); interp->retValue = NULL; } if (interp->exited && interp->level <= 0) |
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 8
#define JSI_VERSION_RELEASE 25
#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 8
#define JSI_VERSION_RELEASE 26
#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/jsiInt.h.
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 |
bool logColNums; bool privKeys; bool compat; bool mutexUnlock; bool noFuncString; int dblPrec; const char *blacklist; } jsi_SubOptions; extern Jsi_OptionSpec jsi_InterpLogOptions[]; typedef enum { jsi_TL_TRY, jsi_TL_WITH, |
> |
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
bool logColNums;
bool privKeys;
bool compat;
bool mutexUnlock;
bool noFuncString;
int dblPrec;
const char *blacklist;
const char *prompt, *prompt2;
} jsi_SubOptions;
extern Jsi_OptionSpec jsi_InterpLogOptions[];
typedef enum {
jsi_TL_TRY,
jsi_TL_WITH,
|
Changes to src/jsiInterp.c.
67
68
69
70
71
72
73
74
75
76
77
78
79
80
....
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
|
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, noFuncString,.help="Disable viewing code body for functions", jsi_IIOF),
JSI_OPT(BOOL, jsi_SubOptions, noRegex, .help="Disable viewing code for functions", jsi_IIOF),
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"),
JSI_OPT_END(jsi_SubOptions, .help="Lesser sub-feature options")
};
static const char *jsi_SafeModeStrs[] = { "none", "read", "write", "write2", NULL };
static const char *jsi_TypeChkStrs[] = { "parse", "run", "all", "error", "strict", "noundef", "nowith", "funcsig", NULL };
const char *jsi_callTraceStrs[] = { "funcs", "cmds", "new", "return", "args", "notrunc", "noparent", "full", "before", NULL};
const char *jsi_AssertModeStrs[] = { "throw", "log", "puts", NULL};
................................................................................
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;
|
>
>
>
>
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
....
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
|
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, noFuncString,.help="Disable viewing code body for functions", jsi_IIOF), JSI_OPT(BOOL, jsi_SubOptions, noRegex, .help="Disable viewing code for functions", jsi_IIOF), 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"), JSI_OPT(STRKEY,jsi_SubOptions, prompt, .help="Prompt for interactive mode ('$ ')" ), JSI_OPT(STRKEY,jsi_SubOptions, prompt2, .help="Prompt for interactive mode line continue ('> ')" ), JSI_OPT_END(jsi_SubOptions, .help="Lesser sub-feature options") }; static const char *jsi_SafeModeStrs[] = { "none", "read", "write", "write2", NULL }; static const char *jsi_TypeChkStrs[] = { "parse", "run", "all", "error", "strict", "noundef", "nowith", "funcsig", NULL }; const char *jsi_callTraceStrs[] = { "funcs", "cmds", "new", "return", "args", "notrunc", "noparent", "full", "before", NULL}; const char *jsi_AssertModeStrs[] = { "throw", "log", "puts", NULL}; ................................................................................ return NULL; } } interp->maxDepth = JSI_MAX_EVAL_DEPTH; interp->maxIncDepth = JSI_MAX_INCLUDE_DEPTH; interp->typeWarnMax = 50; interp->subOpts.dblPrec = __DBL_DECIMAL_DIG__-1; interp->subOpts.prompt = "$ "; interp->subOpts.prompt2 = "> "; int iocnt; if (iopts) { iopts->interp = interp; interp->opts = *iopts; } interp->logOpts.file = 1; |
Changes to src/jsiUtils.c.
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 ... 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 ... 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 .... 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 .... 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 .... 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
#endif /* Collect and execute code from stdin. The first byte of flags are passed to Jsi_ValueGetDString(). */ Jsi_RC Jsi_Interactive(Jsi_Interp* interp, int flags) { Jsi_RC rc = JSI_OK; int done = 0, len, quote = (flags & 0xff), istty = 1, chkHelp=0, hasHelp=0; const char *prompt = "# "; char *buf; if (jsi_interactiveInterp) return Jsi_LogError("multiple interactive not supported"); #if JSI__SIGNAL signal(SIGINT, jsi_InteractiveSignal); #endif interp->typeCheck.parse = interp->typeCheck.run = interp->typeCheck.all = 1; ................................................................................ Jsi_DSInit(&dStr); #ifndef __WIN32 istty = isatty(fileno(stdin)); #else istty = _isatty(_fileno(stdin)); #endif #ifdef JSI_HAS_READLINE Jsi_DString dHist = {}; char *hist = NULL; #ifdef USE_GNU_READLINE rl_attempted_completion_function = jsiRlGetMatches; #else linenoiseSetCompletionCallback(jsiLNGetMatches); linenoiseSetHintsCallback(jsiLNhints); #endif ................................................................................ hist = Jsi_NormalPath(interp, hfile, &dHist); if (hist) jsi_sh_read_history(hist); } #endif interp->level++; if (!interp->iskips) puts("Jsish interactive: see 'help [cmd]'. \\ cancels > input." #if JSI__SIGNAL " ctrl-c aborts running script." #endif ); while (done==0 && interp->exited==0) { buf = get_inputline(interp, istty, prompt); if (buf) { if (buf[0] == '\\' && !buf[1]) { Jsi_DSSetLength(&dStr, 0); prompt = "# "; fprintf(stderr, "abandoned input"); } else Jsi_DSAppend(&dStr, buf, NULL); free(buf); } else { done = 1; } ................................................................................ len = Jsi_DSLength(&dStr); if (done && len == 0) break; if (!len) continue; Jsi_DSAppendLen(&dStr, " ", 1); // Allow for added space. buf = Jsi_DSValue(&dStr); if (done == 0 && (!jsi_StrIsBalanced(buf))) { prompt = "> "; continue; } prompt = "# "; while ((len = Jsi_Strlen(buf))>0 && (isspace(buf[len-1]))) buf[len-1] = 0; if (buf[0] == 0) { Jsi_DSSetLength(&dStr, 0); continue; } bool wantHelp = 0; if (interp->onEval == NULL) { /* Convenience: add semicolon to "var" statements (required by parser). */ if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) { if (!chkHelp++) hasHelp = (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0); if (hasHelp) { wantHelp = 1; char tbuf[BUFSIZ]; snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", buf+4); ................................................................................ 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); } } else { Jsi_Value *func = interp->onEval; if (func && Jsi_ValueIsFunction(interp, func)) { Jsi_Value *items[1] = {}; ................................................................................ interp->level--; #ifdef JSI_HAS_READLINE if (hist) { jsi_sh_stifle_history(100); jsi_sh_write_history(hist); } Jsi_DSFree(&dHist); #endif Jsi_DSFree(&dStr); if (interp->retValue) { Jsi_DecrRefCount(interp, interp->retValue); interp->retValue = NULL; } if (interp->exited && interp->level <= 0) |
| | | | | | > > > > > > > > |
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 ... 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 ... 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 .... 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 .... 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 .... 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
#endif /* Collect and execute code from stdin. The first byte of flags are passed to Jsi_ValueGetDString(). */ Jsi_RC Jsi_Interactive(Jsi_Interp* interp, int flags) { Jsi_RC rc = JSI_OK; int done = 0, len, quote = (flags & 0xff), istty = 1, chkHelp=0, hasHelp=0; const char *prompt = interp->subOpts.prompt; char *buf; if (jsi_interactiveInterp) return Jsi_LogError("multiple interactive not supported"); #if JSI__SIGNAL signal(SIGINT, jsi_InteractiveSignal); #endif interp->typeCheck.parse = interp->typeCheck.run = interp->typeCheck.all = 1; ................................................................................ Jsi_DSInit(&dStr); #ifndef __WIN32 istty = isatty(fileno(stdin)); #else istty = _isatty(_fileno(stdin)); #endif #ifdef JSI_HAS_READLINE Jsi_DString dHist = {}, sHist = {}; char *hist = NULL; #ifdef USE_GNU_READLINE rl_attempted_completion_function = jsiRlGetMatches; #else linenoiseSetCompletionCallback(jsiLNGetMatches); linenoiseSetHintsCallback(jsiLNhints); #endif ................................................................................ hist = Jsi_NormalPath(interp, hfile, &dHist); if (hist) jsi_sh_read_history(hist); } #endif interp->level++; if (!interp->iskips) puts("Jsish interactive: see 'help [cmd]' or 'history'. \\ cancels > input." #if JSI__SIGNAL " ctrl-c aborts running script." #endif ); while (done==0 && interp->exited==0) { buf = get_inputline(interp, istty, prompt); if (buf) { if (buf[0] == '\\' && !buf[1]) { Jsi_DSSetLength(&dStr, 0); prompt = interp->subOpts.prompt; fprintf(stderr, "abandoned input"); } else Jsi_DSAppend(&dStr, buf, NULL); free(buf); } else { done = 1; } ................................................................................ len = Jsi_DSLength(&dStr); if (done && len == 0) break; if (!len) continue; Jsi_DSAppendLen(&dStr, " ", 1); // Allow for added space. buf = Jsi_DSValue(&dStr); if (done == 0 && (!jsi_StrIsBalanced(buf))) { prompt = interp->subOpts.prompt2; continue; } prompt = interp->subOpts.prompt; while ((len = Jsi_Strlen(buf))>0 && (isspace(buf[len-1]))) buf[len-1] = 0; if (buf[0] == 0) { Jsi_DSSetLength(&dStr, 0); continue; } bool wantHelp = 0; if (interp->onEval == NULL) { /* Convenience: add semicolon to "var" statements (required by parser). */ if (!Jsi_Strncmp(buf, "history", 7) && buf[7] == 0) { fputs(Jsi_DSValue(&sHist), stdout); Jsi_DSSetLength(&dStr, 0); continue; } if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) { if (!chkHelp++) hasHelp = (Jsi_PkgRequire(interp, "Jsi_Help", 0)>=0); if (hasHelp) { wantHelp = 1; char tbuf[BUFSIZ]; snprintf(tbuf, sizeof(tbuf), "return runModule('Jsi_Help', '%s'.trim().split(null));", buf+4); ................................................................................ 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); if (rc == JSI_OK) Jsi_DSAppend(&sHist, buf, "\n", NULL); } } else { Jsi_Value *func = interp->onEval; if (func && Jsi_ValueIsFunction(interp, func)) { Jsi_Value *items[1] = {}; ................................................................................ interp->level--; #ifdef JSI_HAS_READLINE if (hist) { jsi_sh_stifle_history(100); jsi_sh_write_history(hist); } Jsi_DSFree(&dHist); Jsi_DSFree(&sHist); #endif Jsi_DSFree(&dStr); if (interp->retValue) { Jsi_DecrRefCount(interp, interp->retValue); interp->retValue = NULL; } if (interp->exited && interp->level <= 0) |
Changes to tools/protos.jsi.
1 2 3 4 5 6 7 8 |
//JSI Command Prototypes: version 2.8.25
throw("NOT EXECUTABLE: USE FILE IN GEANY EDITOR FOR CMD LINE COMPLETION + GOTO TAG");
var Array = function(cmd,args) {};
Array.prototype.concat = function(...):array {};
Array.prototype.every = function(callback:function):any {};
Array.prototype.fill = function(value:any, start:number=0, end:number=-1):array {};
Array.prototype.filter = function(callback:function, this:object=void):array {};
|
| |
1 2 3 4 5 6 7 8 |
//JSI Command Prototypes: version 2.8.26
throw("NOT EXECUTABLE: USE FILE IN GEANY EDITOR FOR CMD LINE COMPLETION + GOTO TAG");
var Array = function(cmd,args) {};
Array.prototype.concat = function(...):array {};
Array.prototype.every = function(callback:function):any {};
Array.prototype.fill = function(value:any, start:number=0, end:number=-1):array {};
Array.prototype.filter = function(callback:function, this:object=void):array {};
|
Changes to www/reference.wiki.
723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
<tr><td>logAllowDups</td><td><i>BOOL</i></td><td>Log should not filter out duplicate messages.</td><td><i></i></td></tr> <tr><td>mutexUnlock</td><td><i>BOOL</i></td><td>Unlock own mutex when evaling in other interps (true).</td><td><i>initOnly</i></td></tr> <tr><td>noproto</td><td><i>BOOL</i></td><td>Disable support of the OOP symbols: __proto__, prototype, constructor, etc.</td><td><i></i></td></tr> <tr><td>noFuncString</td><td><i>BOOL</i></td><td>Disable viewing code body for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noRegex</td><td><i>BOOL</i></td><td>Disable viewing code for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noReadline</td><td><i>BOOL</i></td><td>In interactive mode disable use of readline.</td><td><i></i></td></tr> <tr><td>outUndef</td><td><i>BOOL</i></td><td>In interactive mode output result values that are undefined.</td><td><i></i></td></tr> </table> <a name="Interpend"></a> <p><a href="#TOC">Return to top</a> <a name="JSON"></a> <hr> |
> > |
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
<tr><td>logAllowDups</td><td><i>BOOL</i></td><td>Log should not filter out duplicate messages.</td><td><i></i></td></tr> <tr><td>mutexUnlock</td><td><i>BOOL</i></td><td>Unlock own mutex when evaling in other interps (true).</td><td><i>initOnly</i></td></tr> <tr><td>noproto</td><td><i>BOOL</i></td><td>Disable support of the OOP symbols: __proto__, prototype, constructor, etc.</td><td><i></i></td></tr> <tr><td>noFuncString</td><td><i>BOOL</i></td><td>Disable viewing code body for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noRegex</td><td><i>BOOL</i></td><td>Disable viewing code for functions.</td><td><i>initOnly</i></td></tr> <tr><td>noReadline</td><td><i>BOOL</i></td><td>In interactive mode disable use of readline.</td><td><i></i></td></tr> <tr><td>outUndef</td><td><i>BOOL</i></td><td>In interactive mode output result values that are undefined.</td><td><i></i></td></tr> <tr><td>prompt</td><td><i>STRKEY</i></td><td>Prompt for interactive mode ('$ ').</td><td><i></i></td></tr> <tr><td>prompt2</td><td><i>STRKEY</i></td><td>Prompt for interactive mode line continue ('> ').</td><td><i></i></td></tr> </table> <a name="Interpend"></a> <p><a href="#TOC">Return to top</a> <a name="JSON"></a> <hr> |