Permalink
Browse files

make fgetc return the char value as unsigned (in a signed int)

  • Loading branch information...
1 parent 7b9855c commit 9662b116ce446adc36d70453976989a16b8f2997 @kripken committed May 24, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/library.js
  2. +14 −0 tests/runner.py
View
@@ -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',
View
@@ -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):

0 comments on commit 9662b11

Please sign in to comment.