Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.6.0
-
None
-
None
-
Operating System: MacOS 9
Platform: Macintosh
-
14402
Description
The function XMLParsePathToFSRef_Classic in the file MacOSPlatformUtils.cpp
doesn't recognize scandinavian letters in volume names. This is a bug fix:
void QuickAndDirtySetASCII_C_CharsFromUnicodeText(char **text, UniCharArrayPtr
ucap, UniCharCount ucc);
void QuickAndDirtySetASCII_C_CharsFromUnicodeText(char **text, UniCharArrayPtr
ucap, UniCharCount ucc)
{
ByteCount ail, aol, bigLength = 2 * ucc;
Ptr buffer = NewPtr(bigLength);
TECObjectRef ec;
OSStatus status = TECCreateConverter(&ec, kTextEncodingUnicodeDefault,
kTextEncodingMacRoman);
if (status != noErr) DebugStr("\p TECCreateConverter failed");
status = TECConvertText(ec, (ConstTextPtr)ucap, bigLength, &ail,
(TextPtr)buffer, bigLength, &aol);
if (status != noErr) DebugStr("\p TECConvertText failed");
status = TECDisposeConverter(ec);
if (status != noErr) DebugStr("\p TECDisposeConverter failed");
*text = (char *)NewPtr(aol);
BlockMove(buffer, (*text), aol);
DisposePtr(buffer);
}
bool
XMLParsePathToFSRef_Classic(const XMLCh* const pathName, FSRef& ref)
{
// Parse Path to FSRef by stepping manually through path components.
// Path's parsed in this way must always begin with a volume name.
// This assumption would fail for standard unix paths under Mac OS X,
// so for those cases we use the routine XMLParsePathToFSRef_Carbon
// above.
const XMLCh* p = pathName;
const XMLCh* pEnd;
std::size_t segLen;
const std::size_t kXMLBufCount = 256;
XMLCh xmlBuf[kXMLBufCount];
OSErr err = noErr;
if (*p == L'/')
{
// Absolute name: grab the first component as volume name
// Find the end of the path segment
for (pEnd = ++p; *pEnd && *pEnd != L'/'; ++pEnd) ;
segLen = pEnd - p;
// Try to find a volume that matches this name
for (ItemCount volIndex = 1; err == noErr; ++volIndex)
{
HFSUniStr255 hfsStr;
hfsStr.length = 0;
// Get the volume name
err = FSGetVolumeInfo(
0,
volIndex,
static_cast<FSVolumeRefNum*>(NULL),
0,
static_cast<FSVolumeInfo*>(NULL),
&hfsStr,
&ref
);
if (err == noErr) {
// Compare against our path segment
if (segLen == hfsStr.length)
// Bug fix for scandinavian letters in volume name *******
Str255 volname;
ParamBlockRec pb;
char **ctext = NULL;
QuickAndDirtySetASCII_C_CharsFromUnicodeText(ctext,
(UniCharArrayPtr)p, segLen);
pb.volumeParam.ioVolIndex = (short)volIndex;
pb.volumeParam.ioNamePtr = volname;
OSErr reply = PBGetVInfo(&pb, false);
if (reply == noErr)
{
if (IUMagString(volname+1, *ctext, volname[0], segLen) ==
0)
}
// End bug fix *******
}
}
p = pEnd;
}