1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Improved handling/reporting of conditions which trigger an exit() from native code, e.g. calling the '.read' command. Added a Help button which simply submits the '.help' command. Added commented-out variants of various -Ox flags to simplify experimenting with them.

FossilOrigin-Name: bf06ddf4125d2726019fa16d312726c8551094be991509499b5688f6a68a7747
This commit is contained in:
stephan
2022-05-18 21:18:21 +00:00
parent 0076e49700
commit b0dae2b3c3
4 changed files with 60 additions and 33 deletions

View File

@ -1526,10 +1526,16 @@ fiddle_generated = $(fiddle_html) \
clean-fiddle: clean-fiddle:
rm -f $(fiddle_generated) rm -f $(fiddle_generated)
clean: clean-fiddle clean: clean-fiddle
emcc_flags = -sEXPORTED_RUNTIME_METHODS=ccall,cwrap \ emcc_opt = -O0
#emcc_opt = -O1
#emcc_opt = -O2
#emcc_opt = -O3
#emcc_opt = -Oz
emcc_flags = $(emcc_opt) \
-sEXPORTED_RUNTIME_METHODS=ccall,cwrap \
-sEXPORTED_FUNCTIONS=_fiddle_exec \ -sEXPORTED_FUNCTIONS=_fiddle_exec \
-sEXIT_RUNTIME=1 \
--shell-file $(fiddle_tmpl) --shell-file $(fiddle_tmpl)
$(fiddle_html): Makefile sqlite3.c shell.c $(fiddle_tmpl) $(fiddle_html): Makefile sqlite3.c shell.c $(fiddle_tmpl)
emcc -o $@ $(emcc_flags) sqlite3.c shell.c emcc -o $@ $(emcc_flags) sqlite3.c shell.c
fiddle: $(fiddle_html) fiddle: $(fiddle_html)

View File

@ -56,6 +56,10 @@
label { label {
cursor: pointer; cursor: pointer;
} }
.error {
color: red;
background-color: yellow;
}
</style> </style>
</head> </head>
<body> <body>
@ -81,6 +85,7 @@ select * from t;</textarea>
<div class='ta-wrapper'> <div class='ta-wrapper'>
<textarea id="output" readonly rows="18" placeholder="Shell output"></textarea> <textarea id="output" readonly rows="18" placeholder="Shell output"></textarea>
<div class='button-bar'> <div class='button-bar'>
<button data-cmd='.help' disabled>Help</button>
<button id='btn-clear-output' disabled>Clear</button> <button id='btn-clear-output' disabled>Clear</button>
</div> </div>
</div> </div>
@ -92,7 +97,6 @@ select * from t;</textarea>
<label for='opt-cb-sbs'>Side-by-side</label> <label for='opt-cb-sbs'>Side-by-side</label>
</div> </div>
</fieldset> </fieldset>
<hr>
<script type='text/javascript'> <script type='text/javascript'>
(function(){ (function(){
/** /**
@ -130,23 +134,30 @@ select * from t;</textarea>
doExec(sql); doExec(sql);
} }
},false); },false);
doExec()/*sets up the db and outputs the header*/; doExec(null)/*sets up the db and outputs the header*/;
let e = document.querySelector('#opt-cb-sbs'); let e = document.querySelector('#opt-cb-sbs');
const mainWrapper = document.querySelector('#main-wrapper'); const mainWrapper = document.querySelector('#main-wrapper');
e.addEventListener('change', function(){ e.addEventListener('change', function(){
mainWrapper.classList[this.checked ? 'add' : 'remove']('side-by-side'); mainWrapper.classList[this.checked ? 'add' : 'remove']('side-by-side');
}, false); }, false);
/* For all buttons with data-cmd=X, map a click handler which
calls doExec(X). */
const cmdClick = function(){doExec(this.dataset.cmd);};
document.querySelectorAll('button[data-cmd]').forEach(
e => e.addEventListener('click', cmdClick, false)
);
}; };
/** /**
What follow is part of the emscripten core setup. Do not modify without What follows is part of the emscripten core setup. Do not
understanding what it's doing... modify without understanding what it's doing...
*/ */
var statusElement = document.getElementById('status'); const statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress'); const progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner'); const spinnerElement = document.getElementById('spinner');
window.Module = { const Module = window.Module = {
preRun: [], preRun: [],
postRun: [], postRun: [],
onRuntimeInitialized: function(){ onRuntimeInitialized: function(){
@ -158,7 +169,7 @@ select * from t;</textarea>
} }
f._.value = ''; // clear browser cache f._.value = ''; // clear browser cache
return function(text) { return function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); if(arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML // These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;"); //text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;"); //text = text.replace(/</g, "&lt;");
@ -170,15 +181,15 @@ select * from t;</textarea>
f._.scrollTop = f._.scrollHeight; // focus on bottom f._.scrollTop = f._.scrollHeight; // focus on bottom
}; };
})(), })(),
setStatus: function(text) { setStatus: function f(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; if(!f.last) f.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.last.text) return; if(text === f.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); const m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now(); const now = Date.now();
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon if(m && now - f.last.time < 30) return; // if this is a progress update, skip it if too soon
Module.setStatus.last.time = now; f.last.time = now;
Module.setStatus.last.text = text; f.last.text = text;
if (m) { if(m) {
text = m[1]; text = m[1];
progressElement.value = parseInt(m[2])*100; progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100; progressElement.max = parseInt(m[4])*100;
@ -188,23 +199,33 @@ select * from t;</textarea>
progressElement.value = null; progressElement.value = null;
progressElement.max = null; progressElement.max = null;
progressElement.hidden = true; progressElement.hidden = true;
if (!text) spinnerElement.hidden = true; if(!text) spinnerElement.hidden = true;
} }
statusElement.innerHTML = text; statusElement.innerHTML = text;
}, },
totalDependencies: 0, totalDependencies: 0,
monitorRunDependencies: function(left) { monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left); this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); this.setStatus(left
? ('Preparing... (' + (this.totalDependencies-left)
+ '/' + this.totalDependencies + ')')
: 'All downloads complete.');
} }
}; };
Module.printErr = Module.print/*redirect stderr*/; Module.printErr = Module.print/*capture stderr output*/;
Module.setStatus('Downloading...'); Module.setStatus('Downloading...');
window.onerror = function() { window.onerror = function(/*message, source, lineno, colno, error*/) {
const err = arguments[4];
if(err && 'ExitStatus'==err.name){
Module.printErr("FATAL ERROR:", err.message);
Module.printErr("Restarting the app requires reloading the page.");
const taOutput = document.querySelector('#output');
if(taOutput) taOutput.classList.add('error');
}
Module.setStatus('Exception thrown, see JavaScript console'); Module.setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none'; spinnerElement.style.display = 'none';
Module.setStatus = function(text) { Module.setStatus = function(text) {
if (text) console.error('[post-exception status] ' + text); if(text) console.error('[post-exception status] ' + text);
}; };
}; };
})(); })();

View File

@ -1,9 +1,9 @@
C Code\sstyle\sfixes:\ss/char\sconst/const\schar/. C Improved\shandling/reporting\sof\sconditions\swhich\strigger\san\sexit()\sfrom\snative\scode,\se.g.\scalling\sthe\s'.read'\scommand.\sAdded\sa\sHelp\sbutton\swhich\ssimply\ssubmits\sthe\s'.help'\scommand.\sAdded\scommented-out\svariants\sof\svarious\s-Ox\sflags\sto\ssimplify\sexperimenting\swith\sthem.
D 2022-05-18T18:10:17.699 D 2022-05-18T21:18:21.599
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F Makefile.in ff32504cde350caaf4d52abfdca5dd1fa88b21e53071a0f9cc3539b6789c3606 F Makefile.in 92890acbab78c76f32ebb1ad50b961c3fc413f7b05052663c8b17d1b7f74a697
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241 F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
F Makefile.msc b28a8a7a977e7312f6859f560348e1eb110c21bd6cf9fab0d16537c0a514eef3 F Makefile.msc b28a8a7a977e7312f6859f560348e1eb110c21bd6cf9fab0d16537c0a514eef3
F README.md 8b8df9ca852aeac4864eb1e400002633ee6db84065bd01b78c33817f97d31f5e F README.md 8b8df9ca852aeac4864eb1e400002633ee6db84065bd01b78c33817f97d31f5e
@ -56,7 +56,7 @@ F ext/expert/sqlite3expert.c 6ca30d73b9ed75bd56d6e0d7f2c962d2affaa72c505458619d0
F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b
F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72 F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72
F ext/fiddle/Makefile ea647919e6ac4b50edde1490f60ee87e8ccd75141e4aa650718c6f28eb323bbc F ext/fiddle/Makefile ea647919e6ac4b50edde1490f60ee87e8ccd75141e4aa650718c6f28eb323bbc
F ext/fiddle/fiddle.in.html aef414dcdede5842ae8328bd17aa0d97ee5f592098c1936ce26f9d4d26ab40fa F ext/fiddle/fiddle.in.html be6f4402b5b3e6287004b1b4d76c049d1fc0a5ae3b642578241e77e853fda30e
F ext/fiddle/index.md 08d25ec6fe2a56923e8ea6e5d6c80907bf3a60f9c40a6841a8f402e402dd5f22 F ext/fiddle/index.md 08d25ec6fe2a56923e8ea6e5d6c80907bf3a60f9c40a6841a8f402e402dd5f22
F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e
F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b
@ -1957,8 +1957,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 4eec05457fabe8248b8fd48d6187e772b69429ed64e99f02d0ad6b1230b5835e P 9bf042b2eb2137239a59e421e89eb463e719b264eac3db2adae44e321b9a4ad3
R 827e31b4bc83d11855fefe2a58e8b6d3 R 7e80413f51d07b2a693b13b3778bbe1a
U stephan U stephan
Z d569a8b85b6a19a19ff04cd6f21c4eda Z 307b97d13682722e9b5c5bfc0074797a
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
9bf042b2eb2137239a59e421e89eb463e719b264eac3db2adae44e321b9a4ad3 bf06ddf4125d2726019fa16d312726c8551094be991509499b5688f6a68a7747