diff --git a/Compiler/runtime/systemimpl.c b/Compiler/runtime/systemimpl.c index 32e73e38f33..d5f792b4c7d 100644 --- a/Compiler/runtime/systemimpl.c +++ b/Compiler/runtime/systemimpl.c @@ -1834,26 +1834,17 @@ extern int SystemImpl__reopenStandardStream(int id,const char *filename) return 1; } -static char* SystemImpl__iconv__ascii(const char * str) +char* SystemImpl__iconv__ascii(const char * str) { - static char *buf = 0; - static int buflen = 0; + char *buf = 0; char *in_str,*res; size_t sz,out_sz; iconv_t ic; int i; sz = strlen(str); - if (buflen < sz) { - if (buf) free(buf); - buf = (char*)malloc(sz); - if (!buf) { - buflen = 0; - return (char*) ""; - } - buflen = sz; - } + buf = malloc(sz+1); *buf = 0; - for (i=0; ichars,ModelicaParser_encoding,"UTF-8",0); if (!*res) { const char *strs[2]; - signed char *buf = (signed char*) strdup((char*)text->chars); + signed char buf[76]; int len = strlen((const char*)buf), i; + res = SystemImpl__iconv__ascii((const char*)text->chars); /* Avoid printing huge strings */ if (len > 75) { - len = 75; - buf[len] = 0; - buf[len-1] = '.'; - buf[len-2] = '.'; - buf[len-3] = '.'; + len = 72; + buf[len+0] = '.'; + buf[len+1] = '.'; + buf[len+2] = '.'; + buf[len+3] = '0'; } - for (i=0;iset8(text,res); + free(res); + /* ModelicaParser_lexerError = ANTLR3_TRUE; */ + } else if (strcmp(ModelicaParser_encoding,"UTF-8")!=0) { text->set8(text,res); } }