diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-05-24 13:59:46 +0200 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-05-24 13:59:46 +0200 |
commit | 9662b116ce446adc36d70453976989a16b8f2997 (patch) | |
tree | 4c9bddff98fb1da5e653271fbcb28228b5178330 | |
parent | 7b9855c0625fbc8469b70dd5e3ee3d6772977766 (diff) |
make fgetc return the char value as unsigned (in a signed int)
-rw-r--r-- | src/library.js | 2 | ||||
-rwxr-xr-x | tests/runner.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js index 2472e701..4b7b755b 100644 --- a/src/library.js +++ b/src/library.js @@ -2852,7 +2852,7 @@ LibraryManager.library = { streamObj.error = true; return -1; } else { - return {{{ makeGetValue('_fgetc.ret', '0', 'i8') }}}; + return {{{ makeGetValue('_fgetc.ret', '0', 'i8', null, 1) }}}; } }, getc: 'fgetc', diff --git a/tests/runner.py b/tests/runner.py index ed9bcdd5..e9c9018b 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -3954,6 +3954,20 @@ def process(filename): ''' self.do_run(src, 'isatty? 0,0,1\ngot: 35\ngot: 45\ngot: 25\ngot: 15\n', post_build=post) + def test_fgetc_unsigned(self): + if self.emcc_args is None: return self.skip('requires emcc') + src = r''' + #include <stdio.h> + int main() { + FILE *file = fopen("file_with_byte_234.txt", "rb"); + int c = fgetc(file); + printf("*%d\n", c); + } + ''' + open('file_with_byte_234.txt', 'wb').write('\xea') + self.emcc_args += ['--embed-file', 'file_with_byte_234.txt'] + self.do_run(src, '*234\n') + def test_folders(self): add_pre_run = ''' def process(filename): |