* Replaced some more PRINT with TRACE
* applying our coding guidelines here and there but not everywhere :-) * no functional changes git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27150 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -81,7 +81,7 @@ AllocationDescriptorList<Accessor>::AllocationDescriptorList(Icb *icb,
|
||||
fReadFromIcb(true),
|
||||
fVolume(icb->GetVolume())
|
||||
{
|
||||
DEBUG_INIT("AllocationDescriptorList<>");
|
||||
TRACE(("AllocationDescriptorList<>\n"));
|
||||
_WalkContinuationChain(_CurrentDescriptor());
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ AllocationDescriptorList<Accessor>::FindExtent(off_t start,
|
||||
long_address *extent, bool *isEmpty)
|
||||
{
|
||||
TRACE(("UDF: AllocationDescriptorList<>::FindExtent: start: %Ld, "
|
||||
"extent: %p, isEmpty: %p", start, extent, isEmpty));
|
||||
"extent: %p, isEmpty: %p\n", start, extent, isEmpty));
|
||||
|
||||
off_t startBlock = start >> fVolume->BlockShift();
|
||||
|
||||
@@ -147,16 +147,19 @@ template<class Accessor>
|
||||
AllocationDescriptorList<Accessor>::Descriptor*
|
||||
AllocationDescriptorList<Accessor>::_CurrentDescriptor() const
|
||||
{
|
||||
DEBUG_INIT("AllocationDescriptorList<>");
|
||||
PRINT(("(_DescriptorIndex()+1)*sizeof(Descriptor) = %ld\n", (_DescriptorIndex()+1)*sizeof(Descriptor)));
|
||||
PRINT(("_DescriptorArraySize() = %ld\n", _DescriptorArraySize()));
|
||||
PRINT(("_DescriptorArray() = %p\n", _DescriptorArray()));
|
||||
TRACE(("AllocationDescriptorList<>::_CurrentDescriptor: "
|
||||
"_DescriptorIndex() + 1) * sizeof(Descriptor) = %ld\n",
|
||||
"\t_DescriptorArraySize() = %ld\n\t_DescriptorArray() = %p\n",
|
||||
(_DescriptorIndex() + 1) * sizeof(Descriptor), _DescriptorArraySize(),
|
||||
_DescriptorArray()));
|
||||
|
||||
return ((_DescriptorIndex() + 1) * sizeof(Descriptor)
|
||||
<= _DescriptorArraySize())
|
||||
? &(_DescriptorArray()[_DescriptorIndex()])
|
||||
: NULL;
|
||||
}
|
||||
|
||||
|
||||
template<class Accessor>
|
||||
status_t
|
||||
AllocationDescriptorList<Accessor>::_MoveToNextDescriptor()
|
||||
|
||||
@@ -143,7 +143,7 @@ template <class DescriptorList>
|
||||
status_t
|
||||
Icb::_Read(DescriptorList &list, off_t pos, void *_buffer, size_t *length, uint32 *block)
|
||||
{
|
||||
TRACE(("Icb::_Read(): list: %p, pos: %Ld, buffer: %p, length: (%p)->%ld",
|
||||
TRACE(("Icb::_Read(): list: %p, pos: %Ld, buffer: %p, length: (%p)->%ld\n",
|
||||
&list, pos, _buffer, length, (length ? *length : 0)));
|
||||
|
||||
uint64 bytesLeftInFile = uint64(pos) > Length() ? 0 : Length() - pos;
|
||||
|
||||
@@ -92,84 +92,92 @@ utf8_to_unicode(const char **in)
|
||||
}
|
||||
|
||||
|
||||
/*! \brief Creates an empty string object.
|
||||
*/
|
||||
/*! \brief Creates an empty string object. */
|
||||
UdfString::UdfString()
|
||||
: fCs0String(NULL)
|
||||
, fUtf8String(NULL)
|
||||
:
|
||||
fCs0String(NULL),
|
||||
fUtf8String(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Creates a new UdfString object from the given Utf8 string.
|
||||
*/
|
||||
|
||||
/*! \brief Creates a new UdfString object from the given Utf8 string. */
|
||||
UdfString::UdfString(const char *utf8)
|
||||
: fCs0String(NULL)
|
||||
, fUtf8String(NULL)
|
||||
:
|
||||
fCs0String(NULL),
|
||||
fUtf8String(NULL)
|
||||
{
|
||||
SetTo(utf8);
|
||||
}
|
||||
|
||||
/*! \brief Creates a new UdfString object from the given Cs0 string.
|
||||
*/
|
||||
|
||||
/*! \brief Creates a new UdfString object from the given Cs0 string. */
|
||||
UdfString::UdfString(const char *cs0, uint32 length)
|
||||
: fCs0String(NULL)
|
||||
, fUtf8String(NULL)
|
||||
:
|
||||
fCs0String(NULL),
|
||||
fUtf8String(NULL)
|
||||
{
|
||||
SetTo(cs0, length);
|
||||
}
|
||||
|
||||
|
||||
UdfString::~UdfString()
|
||||
{
|
||||
DEBUG_INIT("String");
|
||||
|
||||
_Clear();
|
||||
}
|
||||
|
||||
/*! \brief Assignment from a Utf8 string.
|
||||
*/
|
||||
|
||||
/*! \brief Assignment from a Utf8 string. */
|
||||
void
|
||||
UdfString::SetTo(const char *utf8)
|
||||
{
|
||||
DEBUG_INIT_ETC("UdfString", ("utf8: `%s', strlen(utf8): %ld", utf8,
|
||||
utf8 ? strlen(utf8) : 0));
|
||||
TRACE(("UdfString::SetTo: utf8 = `%s', strlen(utf8) = %ld\n",
|
||||
utf8, utf8 ? strlen(utf8) : 0));
|
||||
_Clear();
|
||||
if (!utf8) {
|
||||
PRINT(("passed NULL utf8 string\n"));
|
||||
return;
|
||||
}
|
||||
uint32 length = strlen(utf8);
|
||||
// First copy the utf8 string
|
||||
fUtf8String = new(nothrow) char[length+1];
|
||||
if (!fUtf8String){
|
||||
PRINT(("new fUtf8String[%ld] allocation failed\n", length+1));
|
||||
|
||||
if (utf8 == NULL) {
|
||||
TRACE_ERROR(("UdfString::SetTo: passed NULL utf8 string\n"));
|
||||
return;
|
||||
}
|
||||
memcpy(fUtf8String, utf8, length+1);
|
||||
|
||||
uint32 length = strlen(utf8);
|
||||
// First copy the utf8 string
|
||||
fUtf8String = new(nothrow) char[length + 1];
|
||||
if (fUtf8String == NULL) {
|
||||
TRACE_ERROR(("UdfString::SetTo: fUtf8String[%ld] allocation failed\n",
|
||||
length + 1));
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(fUtf8String, utf8, length + 1);
|
||||
// Next convert to raw 4-byte unicode. Then we'll do some
|
||||
// analysis to figure out if we have any invalid characters,
|
||||
// and whether we can get away with compressed 8-bit unicode,
|
||||
// or have to use burly 16-bit unicode.
|
||||
uint32 *raw = new(nothrow) uint32[length];
|
||||
if (!raw) {
|
||||
PRINT(("new uint32 raw[%ld] temporary string allocation failed\n", length));
|
||||
if (raw == NULL) {
|
||||
TRACE_ERROR(("UdfString::SetTo: uint32 raw[%ld] temporary string "
|
||||
"allocation failed\n", length));
|
||||
_Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
const char *in = utf8;
|
||||
uint32 rawLength = 0;
|
||||
for (uint32 i = 0; i < length && uint32(in-utf8) < length; i++, rawLength++)
|
||||
raw[i] = utf8_to_unicode(&in);
|
||||
for (uint32 i = 0; i < length && uint32(in - utf8) < length; i++, rawLength++)
|
||||
raw[i] = utf8_to_unicode(&in);
|
||||
|
||||
// Check for invalids.
|
||||
uint32 mask = 0xffff0000;
|
||||
for (uint32 i = 0; i < rawLength; i++) {
|
||||
if (raw[i] & mask) {
|
||||
PRINT(("WARNING: utf8 string contained a multi-byte sequence which "
|
||||
TRACE(("WARNING: utf8 string contained a multi-byte sequence which "
|
||||
"was converted into a unicode character larger than 16-bits; "
|
||||
"character will be converted to an underscore character for "
|
||||
"safety.\n"));
|
||||
raw[i] = '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
// See if we can get away with 8-bit compressed unicode
|
||||
mask = 0xffffff00;
|
||||
bool canUse8bit = true;
|
||||
@@ -178,22 +186,23 @@ UdfString::SetTo(const char *utf8)
|
||||
canUse8bit = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Build our cs0 string
|
||||
if (canUse8bit) {
|
||||
fCs0Length = rawLength+1;
|
||||
fCs0Length = rawLength + 1;
|
||||
fCs0String = new(nothrow) char[fCs0Length];
|
||||
if (fCs0String) {
|
||||
fCs0String[0] = '\x08'; // 8-bit compressed unicode
|
||||
for (uint32 i = 0; i < rawLength; i++)
|
||||
fCs0String[i+1] = raw[i] % 256;
|
||||
fCs0String[i + 1] = raw[i] % 256;
|
||||
} else {
|
||||
PRINT(("new fCs0String[%ld] allocation failed\n", fCs0Length));
|
||||
TRACE_ERROR(("UdfString::SetTo: fCs0String[%ld] allocation failed\n",
|
||||
fCs0Length));
|
||||
_Clear();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
fCs0Length = rawLength*2+1;
|
||||
fCs0Length = rawLength * 2 + 1;
|
||||
fCs0String = new(nothrow) char[fCs0Length];
|
||||
if (fCs0String) {
|
||||
uint32 pos = 0;
|
||||
@@ -207,8 +216,9 @@ UdfString::SetTo(const char *utf8)
|
||||
fCs0String[pos++] = low;
|
||||
}
|
||||
} else {
|
||||
PRINT(("new fCs0String[%ld] allocation failed\n", fCs0Length));
|
||||
_Clear();
|
||||
TRACE_ERROR(("UdfString::SetTo: fCs0String[%ld] allocation failed\n",
|
||||
fCs0Length));
|
||||
_Clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -217,8 +227,8 @@ UdfString::SetTo(const char *utf8)
|
||||
raw = NULL;
|
||||
}
|
||||
|
||||
/*! \brief Assignment from a Cs0 string.
|
||||
*/
|
||||
|
||||
/*! \brief Assignment from a Cs0 string. */
|
||||
void
|
||||
UdfString::SetTo(const char *cs0, uint32 length)
|
||||
{
|
||||
@@ -231,7 +241,7 @@ UdfString::SetTo(const char *cs0, uint32 length)
|
||||
PRINT(("passed NULL cs0 string\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// First copy the Cs0 string and length
|
||||
fCs0String = new(nothrow) char[length];
|
||||
if (fCs0String) {
|
||||
|
||||
@@ -61,8 +61,7 @@ UdfString::UdfString(const array<char, length> &dString)
|
||||
: fCs0String(NULL)
|
||||
, fUtf8String(NULL)
|
||||
{
|
||||
DEBUG_INIT_ETC("UdfString", ("dString.length(): %ld", dString.length()));
|
||||
|
||||
TRACE(("UdfString::UdfString: dString.length(): %ld", dString.length()));
|
||||
SetTo(dString);
|
||||
}
|
||||
|
||||
@@ -76,16 +75,14 @@ void
|
||||
UdfString::SetTo(const array<char, length> &dString)
|
||||
{
|
||||
uint8 dataLength = dString.length() == 0
|
||||
? 0
|
||||
: reinterpret_cast<const uint8*>(dString.data)[dString.length()-1];
|
||||
if (dataLength == 0
|
||||
|| dataLength == 1 /* technically illegal, but... */)
|
||||
{
|
||||
? 0 : reinterpret_cast<const uint8 *>(dString.data)[dString.length() - 1];
|
||||
if (dataLength == 0
|
||||
|| dataLength == 1 /* technically illegal, but... */) {
|
||||
SetTo(NULL);
|
||||
} else {
|
||||
if (dataLength > dString.length()-1)
|
||||
dataLength = dString.length()-1;
|
||||
SetTo(reinterpret_cast<const char*>(dString.data), dataLength);
|
||||
if (dataLength > dString.length() - 1)
|
||||
dataLength = dString.length() - 1;
|
||||
SetTo(reinterpret_cast<const char *>(dString.data), dataLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user