Skip to content

Commit c1c1cbb

Browse files
committed
Merge pull request #27 from max99x/master
Python fixes: demo polish and module loading
2 parents 5aec040 + 9d0ea81 commit c1c1cbb

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ under the licensing terms detailed in LICENSE.
33

44
* Alon Zakai <[email protected]> (copyright owned by Mozilla Foundation)
55
* Tim Dawborn <[email protected]>
6-
6+
* Max Shawabkeh <[email protected]>

demos/python.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
if (force) {
5151
var element = document.getElementById('output');
52-
element.innerHTML = text;
52+
element.value = text;
5353
}
5454
}
5555

@@ -67,14 +67,14 @@
6767
if (e === 'halting, since this is the first run') {
6868
return;
6969
}
70-
element.innerHTML = 'JS crash: |<b>' + e + '</b>|. Please let us know about this problem!<hr>' + element.innerHTML;
70+
element.value = 'JS crash:\n\n' + e + '\n\nPlease let us know about this problem!\n' + element.value;
7171
return;
7272
}
7373

7474
if (printed) {
75-
element.innerHTML = lines.map(function(line) { return line.replace('<', '&lt;', 'g') }).join('<br>') + '<hr>' + element.innerHTML;
75+
element.value = lines.join('\n') + element.value;
7676
} else {
77-
element.innerHTML = '<small><i>(no output)</i></small><hr>' + element.innerHTML;
77+
element.value = '\n(no output)\n-------------\n' + element.value;
7878
}
7979
}
8080

@@ -127,7 +127,6 @@ <h1>Python on the Web</h1>
127127
</div>
128128
</form>
129129
<hr>
130-
<div id="output" style="font-family: Courier New,Courier,monospace;"></div>
130+
<textarea id="output" style="font-family: monospace; width: 80%" rows="10" readonly></textarea>
131131
</body>
132132
</html>
133-

src/library.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ var Library = {
368368
},
369369
__01fopen64_: 'fopen',
370370

371+
fdopen: function(descriptor, mode) {
372+
// TODO: Check whether mode is acceptable for the current stream.
373+
return descriptor;
374+
},
375+
371376
rewind__deps: ['$STDIO'],
372377
rewind: function(stream) {
373378
var info = STDIO.streams[stream];
@@ -388,6 +393,7 @@ var Library = {
388393
return 0;
389394
},
390395
__01fseeko64_: 'fseek',
396+
__01lseek64_: 'fseek',
391397

392398
ftell__deps: ['$STDIO'],
393399
ftell: function(stream) {
@@ -511,6 +517,13 @@ var Library = {
511517
}
512518
},
513519

520+
__01open64___deps: ['open'],
521+
__01open64_: function(filename, mode, flags) {
522+
// open(), but with flags and mode switched.
523+
// TODO: Verify why this happens at all.
524+
return _open(filename, flags, mode);
525+
},
526+
514527
close: function(stream) {
515528
return 0;
516529
},
@@ -1211,6 +1224,11 @@ var Library = {
12111224
return 0; // NULL
12121225
},
12131226

1227+
unlink: function(filename) {
1228+
// TODO: Actually implement.
1229+
return 0;
1230+
},
1231+
12141232
// time.h
12151233

12161234
time: function(ptr) {
@@ -1259,7 +1277,7 @@ var Library = {
12591277
// stat.h
12601278

12611279
__01stat64_: function() { return -1 },
1262-
__01fstat64_: function() { return -1 },
1280+
__01fstat64_: 'fstat',
12631281

12641282
// locale.h
12651283

0 commit comments

Comments
 (0)