Fixed character set conversion functions (STR #2268)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@6922 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2009-10-29 20:00:12 +00:00
parent 03cf49e895
commit 91fa51ce85
3 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,6 @@
CHANGES IN FLTK 1.1.10 CHANGES IN FLTK 1.1.10
- Fixed character set conversion functions (STR #2268)
- Fixed image lib configure and fltk-config issues by backporting - Fixed image lib configure and fltk-config issues by backporting
the image lib and zlib configure code from FLTK 1.3 (STR #2203) the image lib and zlib configure code from FLTK 1.3 (STR #2203)
- Updated the bundled libpng to v1.2.40 (released Sep. 10, 2009) - Updated the bundled libpng to v1.2.40 (released Sep. 10, 2009)

View File

@ -78,8 +78,8 @@ static int n_buf = 0;
const char *fl_latin1_to_local(const char *t, int n) const char *fl_latin1_to_local(const char *t, int n)
{ {
if (n==-1) n = strlen(t); if (n==-1) n = strlen(t)+1;
if (n<=n_buf) { if (n>=n_buf) {
n_buf = (n + 257) & 0x7fffff00; n_buf = (n + 257) & 0x7fffff00;
if (buf) free(buf); if (buf) free(buf);
buf = (char*)malloc(n_buf); buf = (char*)malloc(n_buf);
@ -89,9 +89,9 @@ const char *fl_latin1_to_local(const char *t, int n)
for ( ; n>0; n--) { for ( ; n>0; n--) {
uchar c = *src++; uchar c = *src++;
if (c>127) if (c>127)
*dst = latin2roman[c-128]; *dst++ = latin2roman[c-128];
else else
*dst = c; *dst++ = c;
} }
//*dst = 0; // this would be wrong! //*dst = 0; // this would be wrong!
return buf; return buf;
@ -99,8 +99,8 @@ const char *fl_latin1_to_local(const char *t, int n)
const char *fl_local_to_latin1(const char *t, int n) const char *fl_local_to_latin1(const char *t, int n)
{ {
if (n==-1) n = strlen(t); if (n==-1) n = strlen(t)+1;
if (n<=n_buf) { if (n>=n_buf) {
n_buf = (n + 257) & 0x7fffff00; n_buf = (n + 257) & 0x7fffff00;
if (buf) free(buf); if (buf) free(buf);
buf = (char*)malloc(n_buf); buf = (char*)malloc(n_buf);

View File

@ -87,8 +87,8 @@ static int n_buf = 0;
const char *fl_local_to_mac_roman(const char *t, int n) const char *fl_local_to_mac_roman(const char *t, int n)
{ {
if (n==-1) n = strlen(t); if (n==-1) n = strlen(t)+1;
if (n<=n_buf) { if (n>=n_buf) {
n_buf = (n + 257) & 0x7fffff00; n_buf = (n + 257) & 0x7fffff00;
if (buf) free(buf); if (buf) free(buf);
buf = (char*)malloc(n_buf); buf = (char*)malloc(n_buf);
@ -98,9 +98,9 @@ const char *fl_local_to_mac_roman(const char *t, int n)
for ( ; n>0; n--) { for ( ; n>0; n--) {
uchar c = *src; uchar c = *src;
if (c>127) if (c>127)
*dst = latin2roman[c-128]; *dst++ = latin2roman[c-128];
else else
*dst = c; *dst++ = c;
} }
//*dst = 0; // this would be wrong! //*dst = 0; // this would be wrong!
return buf; return buf;
@ -108,8 +108,8 @@ const char *fl_local_to_mac_roman(const char *t, int n)
const char *fl_mac_roman_to_local(const char *t, int n) const char *fl_mac_roman_to_local(const char *t, int n)
{ {
if (n==-1) n = strlen(t); if (n==-1) n = strlen(t)+1;
if (n<=n_buf) { if (n>=n_buf) {
n_buf = (n + 257) & 0x7fffff00; n_buf = (n + 257) & 0x7fffff00;
if (buf) free(buf); if (buf) free(buf);
buf = (char*)malloc(n_buf); buf = (char*)malloc(n_buf);