Tomotaka SUWA
t-suw****@users*****
2006年 12月 9日 (土) 09:58:29 JST
Index: AquaSKK/ChangeLog diff -u AquaSKK/ChangeLog:1.33.2.4 AquaSKK/ChangeLog:1.33.2.5 --- AquaSKK/ChangeLog:1.33.2.4 Fri Dec 8 23:38:57 2006 +++ AquaSKK/ChangeLog Sat Dec 9 09:58:29 2006 @@ -1,3 +1,9 @@ +2006-12-09 Tomotaka SUWA <t.suw****@mac*****> + + * CppCFString.cpp (CppCFString::toCString): len * ratio ÅèÄ + ½obt@ÌTCYðAlen * (ratio + 1) ƵÄÏ·ÖÉnµÄ¢½ + sïðC³B + 2006-12-08 Tomotaka SUWA <t.suw****@mac*****> * NumericConverter.*: UTF-8 »BCppCFString ð std::string Éu·B Index: AquaSKK/CppCFString.cpp diff -u AquaSKK/CppCFString.cpp:1.5 AquaSKK/CppCFString.cpp:1.5.2.1 --- AquaSKK/CppCFString.cpp:1.5 Fri May 5 00:27:02 2006 +++ AquaSKK/CppCFString.cpp Sat Dec 9 09:58:29 2006 @@ -1,5 +1,5 @@ /* - $Id: CppCFString.cpp,v 1.5 2006/05/04 15:27:02 t-suwa Exp $ + $Id: CppCFString.cpp,v 1.5.2.1 2006/12/09 00:58:29 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -344,17 +344,15 @@ // Ô³ê½char*ÍAgpãÉK¸delete[]·é±ÆB³àÈÎ[NB const int len = CFStringGetLength(cf_string); char* buf = NULL; - + if(len == 0) { buf = new char[1]; buf[0] = 0; } else { - int ratio = 3; - do { - if(buf) delete[] buf; - buf = new char[len * ratio]; - ++ ratio; - } while(!CFStringGetCString(cf_string, buf, len * ratio, encoding)); + int bufsize = CFStringGetMaximumSizeForEncoding(len, encoding); + bufsize += 1; // for NULL terminator + buf = new char[bufsize]; + CFStringGetCString(cf_string, buf, bufsize, encoding); } return buf; }