This commit is contained in:
Alon Zakai 2013-03-12 19:01:48 -07:00
Родитель eb92e14f76
Коммит 7e2e2380a7
2 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -4350,14 +4350,18 @@ LibraryManager.library = {
return pdest + i - 1; return pdest + i - 1;
}, },
strncpy__asm: 'true',
strncpy__sig: 'iiii',
strncpy: function(pdest, psrc, num) { strncpy: function(pdest, psrc, num) {
var padding = false, curr; pdest = pdest|0; psrc = psrc|0; num = num|0;
for (var i = 0; i < num; i++) { var padding = 0, curr = 0, i = 0;
curr = padding ? 0 : {{{ makeGetValue('psrc', 'i', 'i8') }}}; while ((i|0) < (num|0)) {
curr = padding ? 0 : {{{ makeGetValueAsm('psrc', 'i', 'i8') }}};
{{{ makeSetValue('pdest', 'i', 'curr', 'i8') }}} {{{ makeSetValue('pdest', 'i', 'curr', 'i8') }}}
padding = padding || {{{ makeGetValue('psrc', 'i', 'i8') }}} == 0; padding = padding | ({{{ makeGetValueAsm('psrc', 'i', 'i8') }}} == 0);
i = (i+1)|0;
} }
return pdest; return pdest|0;
}, },
strlwr__deps:['tolower'], strlwr__deps:['tolower'],

Просмотреть файл

@ -1890,13 +1890,24 @@ Succeeded!
printf("%s\\n", strdup_val); printf("%s\\n", strdup_val);
free(strdup_val); free(strdup_val);
{
char *one = "one 1 ONE !";
char *two = "two 2 TWO ?";
char three[1024];
memset(three, '.', 1024);
three[50] = 0;
strncpy(three + argc, one + (argc/2), argc+1);
strncpy(three + argc*3, two + (argc/3), argc+2);
printf("waka %s\\n", three);
}
return 0; return 0;
} }
''' '''
for named in (0, 1): for named in (0, 1):
print named print named
Settings.NAMED_GLOBALS = named Settings.NAMED_GLOBALS = named
self.do_run(src, '4:10,177,543,def\n4\nwowie\ntoo\n76\n5\n(null)\n/* a comment */\n// another\ntest\n', ['wowie', 'too', '74']) self.do_run(src, '4:10,177,543,def\n4\nwowie\ntoo\n76\n5\n(null)\n/* a comment */\n// another\ntest\nwaka ....e 1 O...wo 2 T................................\n', ['wowie', 'too', '74'])
if self.emcc_args == []: if self.emcc_args == []:
gen = open(self.in_dir('src.cpp.o.js')).read() gen = open(self.in_dir('src.cpp.o.js')).read()
assert ('var __str1;' in gen) == named assert ('var __str1;' in gen) == named