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