diff --git a/headers/os/support/Architecture.h b/headers/os/support/Architecture.h index 5ed8bc7197..a14d4373c0 100644 --- a/headers/os/support/Architecture.h +++ b/headers/os/support/Architecture.h @@ -1,9 +1,9 @@ /* - * Copyright 2013, Haiku, Inc. All Rights Reserved. + * Copyright 2013-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ -#ifndef _SUPPORT_ARCHITECTURE_H -#define _SUPPORT_ARCHITECTURE_H +#ifndef _ARCHITECTURE_H +#define _ARCHITECTURE_H #include @@ -13,7 +13,6 @@ __BEGIN_DECLS - const char* get_architecture(); const char* get_primary_architecture(); size_t get_secondary_architectures(const char** architectures, @@ -21,22 +20,17 @@ size_t get_secondary_architectures(const char** architectures, size_t get_architectures(const char** architectures, size_t count); const char* guess_architecture_for_path(const char* path); - __END_DECLS /* C++ API */ #ifdef __cplusplus - #include - status_t get_secondary_architectures(BStringList& _architectures); status_t get_architectures(BStringList& _architectures); +#endif /* __cplusplus */ -#endif - - -#endif /* _SUPPORT_ARCHITECTURE_H */ +#endif /* _ARCHITECTURE_H */ diff --git a/headers/os/support/Archivable.h b/headers/os/support/Archivable.h index 88fe3b8e62..3f022c387e 100644 --- a/headers/os/support/Archivable.h +++ b/headers/os/support/Archivable.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCHIVABLE_H diff --git a/headers/os/support/Autolock.h b/headers/os/support/Autolock.h index fb7db6b159..fbe793ba16 100644 --- a/headers/os/support/Autolock.h +++ b/headers/os/support/Autolock.h @@ -2,8 +2,8 @@ * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ -#ifndef _SUPPORT_AUTOLOCK_H -#define _SUPPORT_AUTOLOCK_H +#ifndef _AUTOLOCK_H +#define _AUTOLOCK_H #include @@ -101,4 +101,5 @@ BAutolock::Unlock() fLocker->Unlock(); } -#endif // _SUPPORT_AUTOLOCK_H + +#endif // _AUTOLOCK_H diff --git a/headers/os/support/Beep.h b/headers/os/support/Beep.h index 0c49e549b3..b8adb712d0 100644 --- a/headers/os/support/Beep.h +++ b/headers/os/support/Beep.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Copyright 2007-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _BEEP_H @@ -17,6 +17,6 @@ status_t beep(); status_t system_beep(const char* eventName); status_t add_system_beep_event(const char* eventName, uint32 flags = 0); -#endif +#endif // __cplusplus #endif // _BEEP_H diff --git a/headers/os/support/BlockCache.h b/headers/os/support/BlockCache.h index 873c8d72b0..c9c6a79f01 100644 --- a/headers/os/support/BlockCache.h +++ b/headers/os/support/BlockCache.h @@ -61,4 +61,5 @@ class BBlockCache { uint32 _reserved[2]; }; + #endif // _BLOCK_CACHE_H diff --git a/headers/os/support/BufferIO.h b/headers/os/support/BufferIO.h index 00ace8eead..f5eccc8cd2 100644 --- a/headers/os/support/BufferIO.h +++ b/headers/os/support/BufferIO.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2007-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _BUFFER_IO_H diff --git a/headers/os/support/BufferedDataIO.h b/headers/os/support/BufferedDataIO.h index 4e24790542..0d100d198d 100644 --- a/headers/os/support/BufferedDataIO.h +++ b/headers/os/support/BufferedDataIO.h @@ -1,5 +1,5 @@ /* - * Copyright 2011, Haiku, Inc. All Rights Reserved. + * Copyright 2011 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _BUFFERED_DATA_IO_H diff --git a/headers/os/support/ByteOrder.h b/headers/os/support/ByteOrder.h index de6e959a15..39819d4c64 100644 --- a/headers/os/support/ByteOrder.h +++ b/headers/os/support/ByteOrder.h @@ -1,9 +1,9 @@ /* - * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Copyright 2007 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ -#ifndef _BYTEORDER_H -#define _BYTEORDER_H +#ifndef _BYTE_ORDER_H +#define _BYTE_ORDER_H #include @@ -111,7 +111,7 @@ typedef enum { #ifdef __cplusplus extern "C" { -#endif +#endif /* __cplusplus */ extern status_t swap_data(type_code type, void *data, size_t length, swap_action action); @@ -132,6 +132,6 @@ extern uint16 __swap_int16(uint16 arg); #ifdef __cplusplus } -#endif +#endif /* __cplusplus */ -#endif /* _BYTEORDER_H */ +#endif /* _BYTE_ORDER_H */ diff --git a/headers/os/support/ClassInfo.h b/headers/os/support/ClassInfo.h index 0df2c19c0f..d689c41b7d 100644 --- a/headers/os/support/ClassInfo.h +++ b/headers/os/support/ClassInfo.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Copyright 2007 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _CLASS_INFO_H @@ -20,5 +20,5 @@ (dynamic_cast(object) != NULL) #define is_instance_of(object, class) \ (typeid(*(object)) == typeid(class)) - + #endif // _CLASS_INFO_H diff --git a/headers/os/support/DataIO.h b/headers/os/support/DataIO.h index 1e5dc6a520..e39bdcfd66 100644 --- a/headers/os/support/DataIO.h +++ b/headers/os/support/DataIO.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2014, Haiku, Inc. All rights reserved. + * Copyright 2005-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _DATA_IO_H diff --git a/headers/os/support/DateTime.h b/headers/os/support/DateTime.h index 17e1c65052..3d06bb47d3 100644 --- a/headers/os/support/DateTime.h +++ b/headers/os/support/DateTime.h @@ -1,9 +1,9 @@ /* - * Copyright 2007-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2007-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ -#ifndef _DATE_TIME_H_ -#define _DATE_TIME_H_ +#ifndef _DATE_TIME_H +#define _DATE_TIME_H #include @@ -14,7 +14,6 @@ class BMessage; namespace BPrivate { - enum time_type { B_GMT_TIME, B_LOCAL_TIME @@ -206,10 +205,8 @@ private: BTime fTime; }; - } // namespace BPrivate - using BPrivate::time_type; using BPrivate::B_GMT_TIME; using BPrivate::B_LOCAL_TIME; @@ -224,4 +221,4 @@ using BPrivate::BDate; using BPrivate::BDateTime; -#endif // _DATE_TIME_H_ +#endif // _DATE_TIME_H diff --git a/headers/os/support/Debug.h b/headers/os/support/Debug.h index 1f88b2716b..9cc39fd8c9 100644 --- a/headers/os/support/Debug.h +++ b/headers/os/support/Debug.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Copyright 2007 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _DEBUG_H diff --git a/headers/os/support/Errors.h b/headers/os/support/Errors.h index 62343b482d..285b56d6a9 100644 --- a/headers/os/support/Errors.h +++ b/headers/os/support/Errors.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2014, Haiku, Inc. All Rights Reserved. + * Copyright 2007-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _ERRORS_H diff --git a/headers/os/support/Flattenable.h b/headers/os/support/Flattenable.h index 40a4deb10b..1eee881c51 100644 --- a/headers/os/support/Flattenable.h +++ b/headers/os/support/Flattenable.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2007-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _FLATTENABLE_H diff --git a/headers/os/support/List.h b/headers/os/support/List.h index 6aa67d0e3b..dd38992b1f 100644 --- a/headers/os/support/List.h +++ b/headers/os/support/List.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2009 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _BE_LIST_H @@ -12,14 +12,14 @@ class BList { public: BList(int32 count = 20); - BList(const BList& anotherList); + BList(const BList& other); virtual ~BList(); BList& operator=(const BList& other); bool operator==(const BList& other) const; bool operator!=(const BList& other) const; - // Adding and removing items. + // Adding and removing items bool AddItem(void* item, int32 index); bool AddItem(void* item); bool AddList(const BList* list, int32 index); @@ -28,7 +28,7 @@ public: bool RemoveItem(void* item); void* RemoveItem(int32 index); bool RemoveItems(int32 index, int32 count); - bool ReplaceItem(int32 index, void* newItem); + bool ReplaceItem(int32 index, void* item); void MakeEmpty(); @@ -36,7 +36,7 @@ public: void SortItems(int (*compareFunc)(const void*, const void*)); bool SwapItems(int32 indexA, int32 indexB); - bool MoveItem(int32 fromIndex, int32 toIndex); + bool MoveItem(int32 from, int32 to); // Retrieve items void* ItemAt(int32 index) const; @@ -76,4 +76,5 @@ private: uint32 _reserved[1]; }; + #endif // _BE_LIST_H diff --git a/headers/os/support/Locker.h b/headers/os/support/Locker.h index 5816baefb7..7c115bd05d 100644 --- a/headers/os/support/Locker.h +++ b/headers/os/support/Locker.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _LOCKER_H diff --git a/headers/os/support/ObjectList.h b/headers/os/support/ObjectList.h index f0e1927efa..af30f89196 100644 --- a/headers/os/support/ObjectList.h +++ b/headers/os/support/ObjectList.h @@ -51,11 +51,12 @@ template class BObjectList; template struct UnaryPredicate { - virtual int operator()(const T *) const // virtual could be avoided here if FindBinaryInsertionIndex, // etc. were member template functions - { return 0; } + { + return 0; + } private: static int _unary_predicate_glue(const void *item, void *context); @@ -112,7 +113,6 @@ protected: template class BObjectList : private _PointerList_ { public: - // iteration and sorting typedef T* (*EachFunction)(T*, void*); typedef const T* (*ConstEachFunction)(const T*, void*); @@ -424,7 +424,7 @@ BObjectList::BObjectList(int32 itemsPerBlock, bool owning) template -BObjectList::BObjectList(const BObjectList &list) +BObjectList::BObjectList(const BObjectList& list) : _PointerList_(list) { @@ -483,25 +483,25 @@ BObjectList::AddItem(T* item) template bool -BObjectList::AddItem(T* item, int32 atIndex) +BObjectList::AddItem(T* item, int32 index) { - return _PointerList_::AddItem((void*)item, atIndex); + return _PointerList_::AddItem((void*)item, index); } template bool -BObjectList::AddList(BObjectList* newItems) +BObjectList::AddList(BObjectList* list) { - return _PointerList_::AddList(newItems); + return _PointerList_::AddList(list); } template bool -BObjectList::AddList(BObjectList* newItems, int32 atIndex) +BObjectList::AddList(BObjectList* list, int32 index) { - return _PointerList_::AddList(newItems, atIndex); + return _PointerList_::AddList(list, index); } @@ -540,16 +540,18 @@ BObjectList::ReplaceItem(int32 index, T* item) { if (owning) delete ItemAt(index); + return _PointerList_::ReplaceItem(index, (void*)item); } template T* -BObjectList::SwapWithItem(int32 index, T* newItem) +BObjectList::SwapWithItem(int32 index, T* item) { T* result = ItemAt(index); - _PointerList_::ReplaceItem(index, (void*)newItem); + _PointerList_::ReplaceItem(index, (void*)item); + return result; } @@ -712,6 +714,7 @@ BObjectList::BinarySearch(const T& key, CompareFunction func) const return (T*)_PointerList_::BinarySearch(&key, (GenericCompareFunction)func); } + template T* BObjectList::BinarySearch(const T& key, CompareFunctionWithState func, @@ -942,4 +945,4 @@ BObjectList::BinaryInsertUnique(T* item, const UnaryPredicate& pred) } -#endif /* _OBJECT_LIST_H */ +#endif // _OBJECT_LIST_H diff --git a/headers/os/support/String.h b/headers/os/support/String.h index 7ca3b64442..9dcc88c9ff 100644 --- a/headers/os/support/String.h +++ b/headers/os/support/String.h @@ -1,9 +1,9 @@ /* - * Copyright 2001-2010, Haiku Inc. All Rights Reserved. + * Copyright 2001-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ -#ifndef __BSTRING__ -#define __BSTRING__ +#ifndef _B_STRING_H +#define _B_STRING_H #include @@ -383,7 +383,7 @@ private: // Escape BString& _DoCharacterEscape(const char* string, - const char *setOfCharsToEscape, char escapeChar); + const char* setOfCharsToEscape, char escapeChar); BString& _DoCharacterDeescape(const char* string, char escapeChar); @@ -426,7 +426,7 @@ BString::Length() const { // the most significant bit is reserved; accessing // it in any way will cause the computer to explode - return fPrivateData ? (*(((int32 *)fPrivateData) - 1) & 0x7fffffff) : 0; + return fPrivateData ? (*(((int32*)fPrivateData) - 1) & 0x7fffffff) : 0; } @@ -453,7 +453,7 @@ BString::HashValue() const } -inline BString & +inline BString& BString::SetTo(const char* string) { return operator=(string); @@ -476,23 +476,23 @@ BString::ByteAt(int32 index) const } -inline BString & -BString::operator+=(const BString &string) +inline BString& +BString::operator+=(const BString& string) { _DoAppend(string.String(), string.Length()); return *this; } -inline BString & -BString::Append(const BString &string) +inline BString& +BString::Append(const BString& string) { _DoAppend(string.String(), string.Length()); return *this; } -inline BString & +inline BString& BString::Append(const char* string) { return operator+=(string); @@ -500,42 +500,42 @@ BString::Append(const char* string) inline bool -BString::operator==(const BString &string) const +BString::operator==(const BString& string) const { return strcmp(String(), string.String()) == 0; } inline bool -BString::operator<(const BString &string) const +BString::operator<(const BString& string) const { return strcmp(String(), string.String()) < 0; } inline bool -BString::operator<=(const BString &string) const +BString::operator<=(const BString& string) const { return strcmp(String(), string.String()) <= 0; } inline bool -BString::operator>=(const BString &string) const +BString::operator>=(const BString& string) const { return strcmp(String(), string.String()) >= 0; } inline bool -BString::operator>(const BString &string) const +BString::operator>(const BString& string) const { return strcmp(String(), string.String()) > 0; } inline bool -BString::operator!=(const BString &string) const +BString::operator!=(const BString& string) const { return strcmp(String(), string.String()) != 0; } @@ -556,42 +556,42 @@ BString::operator const char*() const inline bool -operator<(const char *str, const BString &string) +operator<(const char* str, const BString& string) { return string > str; } inline bool -operator<=(const char *str, const BString &string) +operator<=(const char* str, const BString& string) { return string >= str; } inline bool -operator==(const char *str, const BString &string) +operator==(const char* str, const BString& string) { return string == str; } inline bool -operator>(const char *str, const BString &string) +operator>(const char* str, const BString& string) { return string < str; } inline bool -operator>=(const char *str, const BString &string) +operator>=(const char* str, const BString& string) { return string <= str; } inline bool -operator!=(const char *str, const BString &string) +operator!=(const char* str, const BString& string) { return string != str; } @@ -618,4 +618,5 @@ private: int32 fPosition; }; -#endif // __BSTRING__ + +#endif // _B_STRING_H diff --git a/headers/os/support/StringList.h b/headers/os/support/StringList.h index c1938121f2..559e8d6b3e 100644 --- a/headers/os/support/StringList.h +++ b/headers/os/support/StringList.h @@ -1,9 +1,9 @@ /* - * Copyright 2011, Haiku, Inc. All Rights Reserved. + * Copyright 2011 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ -#ifndef _SUPPORT_BSTRING_LIST_H_ -#define _SUPPORT_BSTRING_LIST_H_ +#ifndef _STRING_LIST_H +#define _STRING_LIST_H #include @@ -100,4 +100,4 @@ BStringList::operator!=(const BStringList& other) const } -#endif // _SUPPORT_BSTRING_LIST_H_ +#endif // _STRING_LIST_H diff --git a/headers/os/support/SupportDefs.h b/headers/os/support/SupportDefs.h index aae8002000..1f413d378b 100644 --- a/headers/os/support/SupportDefs.h +++ b/headers/os/support/SupportDefs.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2004-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Author: diff --git a/headers/os/support/TLS.h b/headers/os/support/TLS.h index 9f2d494959..344e58d72e 100644 --- a/headers/os/support/TLS.h +++ b/headers/os/support/TLS.h @@ -1,9 +1,9 @@ /* - * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2007 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _TLS_H -#define _TLS_H +#define _TLS_H #include @@ -19,7 +19,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /* __cplusplus */ extern int32 tls_allocate(void); @@ -54,16 +54,16 @@ tls_set(int32 index, void *value) : : "r" (index), "r" (value)); } -#else +#else /* !_NO_INLINE_ASM && __INTEL__ && __GNUC__ */ extern void *tls_get(int32 index); extern void **tls_address(int32 index); extern void tls_set(int32 index, void *value); -#endif +#endif /* !_NO_INLINE_ASM && __INTEL__ && __GNUC__ */ #ifdef __cplusplus } -#endif +#endif /* __cplusplus */ #endif /* _TLS_H */ diff --git a/headers/os/support/TypeConstants.h b/headers/os/support/TypeConstants.h index 9272b04cdf..33f8d202c6 100644 --- a/headers/os/support/TypeConstants.h +++ b/headers/os/support/TypeConstants.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2005-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Author: @@ -63,23 +63,37 @@ enum { B_NETWORK_ADDRESS_TYPE = 'NWAD', B_MIME_STRING_TYPE = 'MIMS', - // deprecated, do not use - B_ASCII_TYPE = 'TEXT' // use B_STRING_TYPE instead + /* deprecated, do not use */ + B_ASCII_TYPE = 'TEXT' + /* use B_STRING_TYPE instead */ }; -// System-wide MIME types for handling URL's +/* System-wide MIME types for handling URL's */ -extern const char *B_URL_HTTP; // application/x-vnd.Be.URL.http -extern const char *B_URL_HTTPS; // application/x-vnd.Be.URL.https -extern const char *B_URL_FTP; // application/x-vnd.Be.URL.ftp -extern const char *B_URL_GOPHER; // application/x-vnd.Be.URL.gopher -extern const char *B_URL_MAILTO; // application/x-vnd.Be.URL.mailto -extern const char *B_URL_NEWS; // application/x-vnd.Be.URL.news -extern const char *B_URL_NNTP; // application/x-vnd.Be.URL.nntp -extern const char *B_URL_TELNET; // application/x-vnd.Be.URL.telnet -extern const char *B_URL_RLOGIN; // application/x-vnd.Be.URL.rlogin -extern const char *B_URL_TN3270; // application/x-vnd.Be.URL.tn3270 -extern const char *B_URL_WAIS; // application/x-vnd.Be.URL.wais -extern const char *B_URL_FILE; // application/x-vnd.Be.URL.file +extern const char* B_URL_HTTP; + /* application/x-vnd.Be.URL.http */ +extern const char* B_URL_HTTPS; + /* application/x-vnd.Be.URL.https */ +extern const char* B_URL_FTP; + /* application/x-vnd.Be.URL.ftp */ +extern const char* B_URL_GOPHER; + /* application/x-vnd.Be.URL.gopher */ +extern const char* B_URL_MAILTO; + /* application/x-vnd.Be.URL.mailto */ +extern const char* B_URL_NEWS; + /* application/x-vnd.Be.URL.news */ +extern const char* B_URL_NNTP; + /* application/x-vnd.Be.URL.nntp */ +extern const char* B_URL_TELNET; + /* application/x-vnd.Be.URL.telnet */ +extern const char* B_URL_RLOGIN; + /* application/x-vnd.Be.URL.rlogin */ +extern const char* B_URL_TN3270; + /* application/x-vnd.Be.URL.tn3270 */ +extern const char* B_URL_WAIS; + /* application/x-vnd.Be.URL.wais */ +extern const char* B_URL_FILE; + /* application/x-vnd.Be.URL.file */ -#endif // _TYPE_CONSTANTS_H + +#endif /* _TYPE_CONSTANTS_H */ diff --git a/headers/os/support/UTF8.h b/headers/os/support/UTF8.h index ab5416a696..e7e10a55ee 100644 --- a/headers/os/support/UTF8.h +++ b/headers/os/support/UTF8.h @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Copyright 2007 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _UTF8_H @@ -11,9 +11,9 @@ #include -// Conversion Flavors +/* Conversion Flavors */ enum { - B_ISO1_CONVERSION, // ISO 8859-x + B_ISO1_CONVERSION, /* ISO 8859-x */ B_ISO2_CONVERSION, B_ISO3_CONVERSION, B_ISO4_CONVERSION, @@ -23,28 +23,28 @@ enum { B_ISO8_CONVERSION, B_ISO9_CONVERSION, B_ISO10_CONVERSION, - B_MAC_ROMAN_CONVERSION, // Macintosh Roman - B_SJIS_CONVERSION, // Shift-JIS - B_EUC_CONVERSION, // EUC Packed Japanese - B_JIS_CONVERSION, // JIS X 0208-1990 - B_MS_WINDOWS_CONVERSION, // Windows Latin-1 Codepage 1252 - B_UNICODE_CONVERSION, // Unicode 2.0, UCS-2 - B_KOI8R_CONVERSION, // KOI8-R - B_MS_WINDOWS_1251_CONVERSION, // Windows Cyrillic Codepage 1251 - B_MS_DOS_866_CONVERSION, // MS-DOS Codepage 866 - B_MS_DOS_CONVERSION, // MS-DOS Codepage 437 - B_EUC_KR_CONVERSION, // EUC Korean + B_MAC_ROMAN_CONVERSION, /* Macintosh Roman */ + B_SJIS_CONVERSION, /* Shift-JIS */ + B_EUC_CONVERSION, /* EUC Packed Japanese */ + B_JIS_CONVERSION, /* JIS X 0208-1990 */ + B_MS_WINDOWS_CONVERSION, /* Windows Latin-1 Codepage 1252 */ + B_UNICODE_CONVERSION, /* Unicode 2.0, UCS-2 */ + B_KOI8R_CONVERSION, /* KOI8-R */ + B_MS_WINDOWS_1251_CONVERSION, /* Windows Cyrillic Codepage 1251 */ + B_MS_DOS_866_CONVERSION, /* MS-DOS Codepage 866 */ + B_MS_DOS_CONVERSION, /* MS-DOS Codepage 437 */ + B_EUC_KR_CONVERSION, /* EUC Korean */ B_ISO13_CONVERSION, B_ISO14_CONVERSION, B_ISO15_CONVERSION, - B_BIG5_CONVERSION, // Chinese Big5 - B_GBK_CONVERSION, // Chinese GB18030 - B_UTF16_CONVERSION, // Unicode UTF-16 - B_MS_WINDOWS_1250_CONVERSION // Windows Central European Codepage + B_BIG5_CONVERSION, /* Chinese Big5 */ + B_GBK_CONVERSION, /* Chinese GB18030 */ + B_UTF16_CONVERSION, /* Unicode UTF-16 */ + B_MS_WINDOWS_1250_CONVERSION /* Windows Central European Codepage */ }; -// Conversion Functions +/* Conversion Functions */ #ifdef __cplusplus @@ -56,6 +56,6 @@ status_t convert_from_utf8(uint32 destEncoding, const char* source, int32* sourceLength, char* dest, int32* destLength, int32* state, char substitute = B_SUBSTITUTE); -#endif +#endif /* __cplusplus */ #endif /* _UTF8_H */ diff --git a/headers/os/support/parsedate.h b/headers/os/support/parsedate.h index 6f483a5077..5c3e8434dc 100644 --- a/headers/os/support/parsedate.h +++ b/headers/os/support/parsedate.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2007 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _PARSEDATE_H @@ -19,7 +19,7 @@ #ifdef __cplusplus extern "C" { -#endif +#endif /* __cplusplus */ extern time_t parsedate(const char *dateString, time_t now); extern time_t parsedate_etc(const char *dateString, time_t now, int *_storedFlags); @@ -29,6 +29,6 @@ extern const char **get_dateformats(void); #ifdef __cplusplus } -#endif +#endif /* __cplusplus */ #endif /* _PARSEDATE_H */ diff --git a/src/kits/support/Archivable.cpp b/src/kits/support/Archivable.cpp index 3761040208..8c092d984a 100644 --- a/src/kits/support/Archivable.cpp +++ b/src/kits/support/Archivable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2012, Haiku, Inc. + * Copyright 2001-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -237,9 +237,7 @@ check_signature(const char* signature, image_info& info) } -namespace BPrivate -{ - +namespace BPrivate { instantiation_func find_instantiation_func(const char* className, const char* signature, @@ -294,11 +292,10 @@ find_instantiation_func(const char* className, const char* signature, return instantiationFunc; } - -} +} // namespace BPrivate -// #pragma mark - +// #pragma mark - BArchivable BArchivable::BArchivable() @@ -374,6 +371,7 @@ BArchivable::Perform(perform_code d, void* arg) return B_OK; } } + return B_NAME_NOT_FOUND; } @@ -392,7 +390,7 @@ BArchivable::AllArchived(BMessage* archive) const } -// #pragma mark - +// #pragma mark - BArchiver BArchiver::BArchiver(BMessage* archive) @@ -401,7 +399,7 @@ BArchiver::BArchiver(BMessage* archive) fArchive(archive), fFinished(false) { - if (!fManager) + if (fManager == NULL) fManager = new BArchiveManager(this); } @@ -467,7 +465,7 @@ BArchiver::RegisterArchivable(const BArchivable* archivable) } -// #pragma mark - +// #pragma mark - BUnarchiver BUnarchiver::BUnarchiver(const BMessage* archive) @@ -525,6 +523,7 @@ BUnarchiver::IsInstantiated(const char* field, int32 index) int32 token; if (fArchive->FindInt32(field, index, &token) == B_OK) return IsInstantiated(token); + return false; } @@ -573,7 +572,7 @@ BUnarchiver::IsArchiveManaged(const BMessage* archive) if (BManagerBase::ManagerPointer(archive)) return true; - if (!archive) + if (archive == NULL) return false; // managed top level archives return here @@ -588,7 +587,7 @@ BUnarchiver::IsArchiveManaged(const BMessage* archive) template<> status_t BUnarchiver::InstantiateObject(BMessage* from, - BArchivable*& object) + BArchivable* &object) { BUnarchiver unarchiver(BUnarchiver::PrepareArchive(from)); object = instantiate_object(from); @@ -597,7 +596,7 @@ BUnarchiver::InstantiateObject(BMessage* from, BMessage* -BUnarchiver::PrepareArchive(BMessage*& archive) +BUnarchiver::PrepareArchive(BMessage* &archive) { // this check allows PrepareArchive to be // called on new or old-style archives @@ -605,8 +604,10 @@ BUnarchiver::PrepareArchive(BMessage*& archive) BUnarchiveManager* manager = BManagerBase::UnarchiveManager(archive); if (!manager) manager = new BUnarchiveManager(archive); + manager->Acquire(); } + return archive; } @@ -744,6 +745,9 @@ instantiate_object(BMessage* from) } +// #pragma mark - support_globals + + bool validate_instantiation(BMessage* from, const char* className) { @@ -807,10 +811,11 @@ find_instantiation_func(BMessage* archive) } -// BArchivable binary compatibility -#if __GNUC__ == 2 +// #pragma mark - BArchivable binary compatibility +#if __GNUC__ == 2 + extern "C" status_t _ReservedArchivable1__11BArchivable(BArchivable* archivable, const BMessage* archive) @@ -839,7 +844,6 @@ _ReservedArchivable2__11BArchivable(BArchivable* archivable, #elif __GNUC__ > 2 - extern "C" status_t _ZN11BArchivable20_ReservedArchivable1Ev(BArchivable* archivable, const BMessage* archive) @@ -865,10 +869,7 @@ _ZN11BArchivable20_ReservedArchivable2Ev(BArchivable* archivable, return performData.return_value; } - #endif // _GNUC__ > 2 void BArchivable::_ReservedArchivable3() {} - - diff --git a/src/kits/support/ArchivingManagers.cpp b/src/kits/support/ArchivingManagers.cpp index 069b3392be..82838e8d64 100644 --- a/src/kits/support/ArchivingManagers.cpp +++ b/src/kits/support/ArchivingManagers.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2010, Haiku, Inc. + * Copyright 2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Alex Wilson (yourpalal2@gmail.com) + * Alex Wilson, yourpalal2@gmail.com */ + #include "ArchivingManagers.h" #include diff --git a/src/kits/support/ArchivingManagers.h b/src/kits/support/ArchivingManagers.h index 76423521b5..b4e55f5924 100644 --- a/src/kits/support/ArchivingManagers.h +++ b/src/kits/support/ArchivingManagers.h @@ -1,5 +1,5 @@ /* - * Copyright 2010, Haiku, Inc. All Rights Reserved. + * Copyright 2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _ARCHIVING_MANAGERS_H @@ -165,4 +165,5 @@ private: } // namespace Archiving } // namespace BPrivate -#endif + +#endif // _ARCHIVING_MANAGERS_H diff --git a/src/kits/support/Base64.cpp b/src/kits/support/Base64.cpp index 3f1246c503..94ad054e43 100644 --- a/src/kits/support/Base64.cpp +++ b/src/kits/support/Base64.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013, Haiku, Inc. All rights reserved. + * Copyright 2011-2013 Haiku, Inc. All rights reserved. * Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved. */ @@ -12,14 +12,14 @@ static const char kBase64Alphabet[64] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '+', - '/' - }; + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '+', + '/' +}; ssize_t @@ -141,5 +141,4 @@ decode_base64(char *out, const char *in, off_t length) { return decode_base64(out, in, length); } - -#endif +#endif // __GNUC__ <= 2 diff --git a/src/kits/support/Beep.cpp b/src/kits/support/Beep.cpp index 673d2f4b7b..b4519b7006 100644 --- a/src/kits/support/Beep.cpp +++ b/src/kits/support/Beep.cpp @@ -57,4 +57,3 @@ add_system_beep_event(const char* name, uint32 flags) return status; } - diff --git a/src/kits/support/BufferIO.cpp b/src/kits/support/BufferIO.cpp index a64d611c4e..744f0e31ca 100644 --- a/src/kits/support/BufferIO.cpp +++ b/src/kits/support/BufferIO.cpp @@ -1,9 +1,9 @@ /* - * Copyright (c) 2001-2008, Haiku + * Copyright 2001-2008 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license * * Authors: - * Stefano Ceccherini (burton666@libero.it) + * Stefano Ceccherini, burton666@libero.it */ @@ -253,7 +253,7 @@ BBufferIO::PrintToStream() const } -// #pragma mark - +// #pragma mark - FBC padding // These functions are here to maintain future binary diff --git a/src/kits/support/DataIO.cpp b/src/kits/support/DataIO.cpp index 657d195c3f..90c4b8c676 100644 --- a/src/kits/support/DataIO.cpp +++ b/src/kits/support/DataIO.cpp @@ -1,9 +1,9 @@ /* - * Copyright 2005-2014, Haiku, Inc. + * Copyright 2005-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Stefano Ceccherini (burton666@libero.it) + * Stefano Ceccherini, burton666@libero.it */ @@ -145,7 +145,7 @@ BPositionIO::~BPositionIO() ssize_t -BPositionIO::Read(void *buffer, size_t size) +BPositionIO::Read(void* buffer, size_t size) { off_t curPos = Position(); ssize_t result = ReadAt(curPos, buffer, size); @@ -157,7 +157,7 @@ BPositionIO::Read(void *buffer, size_t size) ssize_t -BPositionIO::Write(const void *buffer, size_t size) +BPositionIO::Write(const void* buffer, size_t size) { off_t curPos = Position(); ssize_t result = WriteAt(curPos, buffer, size); @@ -216,7 +216,7 @@ void BPositionIO::_ReservedPositionIO12(){} // #pragma mark - -BMemoryIO::BMemoryIO(void *buffer, size_t length) +BMemoryIO::BMemoryIO(void* buffer, size_t length) : fReadOnly(false), fBuffer(static_cast(buffer)), @@ -227,7 +227,7 @@ BMemoryIO::BMemoryIO(void *buffer, size_t length) } -BMemoryIO::BMemoryIO(const void *buffer, size_t length) +BMemoryIO::BMemoryIO(const void* buffer, size_t length) : fReadOnly(true), fBuffer(const_cast(static_cast(buffer))), @@ -244,7 +244,7 @@ BMemoryIO::~BMemoryIO() ssize_t -BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size) +BMemoryIO::ReadAt(off_t pos, void* buffer, size_t size) { if (buffer == NULL || pos < 0) return B_BAD_VALUE; @@ -254,12 +254,13 @@ BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size) sizeRead = min_c((off_t)size, (off_t)fLength - pos); memcpy(buffer, fBuffer + pos, sizeRead); } + return sizeRead; } ssize_t -BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size) +BMemoryIO::WriteAt(off_t pos, const void* buffer, size_t size) { if (fReadOnly) return B_NOT_ALLOWED; @@ -296,6 +297,7 @@ BMemoryIO::Seek(off_t position, uint32 seek_mode) default: break; } + return fPosition; } @@ -317,6 +319,7 @@ BMemoryIO::SetSize(off_t size) return B_ERROR; fLength = size; + return B_OK; } @@ -363,7 +366,7 @@ BMallocIO::~BMallocIO() ssize_t -BMallocIO::ReadAt(off_t pos, void *buffer, size_t size) +BMallocIO::ReadAt(off_t pos, void* buffer, size_t size) { if (buffer == NULL) return B_BAD_VALUE; @@ -373,12 +376,13 @@ BMallocIO::ReadAt(off_t pos, void *buffer, size_t size) sizeRead = min_c((off_t)size, (off_t)fLength - pos); memcpy(buffer, fData + pos, sizeRead); } + return sizeRead; } ssize_t -BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size) +BMallocIO::WriteAt(off_t pos, const void* buffer, size_t size) { if (buffer == NULL) return B_BAD_VALUE; @@ -394,6 +398,7 @@ BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size) if (pos + size > fLength) fLength = pos + size; } + return error != B_OK ? error : size; } @@ -439,7 +444,7 @@ BMallocIO::SetSize(off_t size) size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize; if (size != (off_t)fMallocSize) { // we need to resize - if (char *newData = static_cast(realloc(fData, newSize))) { + if (char* newData = static_cast(realloc(fData, newSize))) { // set the new area to 0 if (newSize > fMallocSize) memset(newData + fMallocSize, 0, newSize - fMallocSize); @@ -462,12 +467,13 @@ BMallocIO::SetBlockSize(size_t blockSize) { if (blockSize == 0) blockSize = 1; + if (blockSize != fBlockSize) fBlockSize = blockSize; } -const void * +const void* BMallocIO::Buffer() const { return fData; diff --git a/src/kits/support/DateTime.cpp b/src/kits/support/DateTime.cpp index aa4aaf6dd2..3d4a051751 100644 --- a/src/kits/support/DateTime.cpp +++ b/src/kits/support/DateTime.cpp @@ -1,10 +1,10 @@ /* - * Copyright 2007-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2007-2010 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Julun - * Stephan Aßmus + * Stephan Aßmus, superstippi@gmx.de + * Julun, host.haiku@gmx.de */ #include "DateTime.h" @@ -18,7 +18,6 @@ namespace BPrivate { - const int32 kSecondsPerMinute = 60; const int32 kHoursPerDay = 24; @@ -1496,5 +1495,4 @@ BDateTime::operator>=(const BDateTime& dateTime) const return false; } - -} //namespace BPrivate +} /* namespace BPrivate */ diff --git a/src/kits/support/List.cpp b/src/kits/support/List.cpp index 641fcfcd69..a9788d1c69 100644 --- a/src/kits/support/List.cpp +++ b/src/kits/support/List.cpp @@ -1,12 +1,13 @@ /* - * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * The Storage kit Team - * Isaac Yonemoto - * Rene Gollent + * The Storage Kit Team * Stephan Aßmus + * Rene Gollent + * John Scipione, jscipione@gmail.com + * Isaac Yonemoto */ //! BList class provides storage for pointers. Not thread safe. @@ -42,14 +43,14 @@ BList::BList(int32 count) } -BList::BList(const BList& anotherList) +BList::BList(const BList& other) : fObjectList(NULL), fPhysicalSize(0), fItemCount(0), - fBlockSize(anotherList.fBlockSize) + fBlockSize(other.fBlockSize) { - *this = anotherList; + *this = other; } @@ -60,13 +61,13 @@ BList::~BList() BList& -BList::operator=(const BList& list) +BList::operator=(const BList& other) { - if (&list != this) { - fBlockSize = list.fBlockSize; - if (_ResizeArray(list.fItemCount)) { - fItemCount = list.fItemCount; - memcpy(fObjectList, list.fObjectList, fItemCount * sizeof(void*)); + if (&other != this) { + fBlockSize = other.fBlockSize; + if (_ResizeArray(other.fItemCount)) { + fItemCount = other.fItemCount; + memcpy(fObjectList, other.fObjectList, fItemCount * sizeof(void*)); } } @@ -75,16 +76,16 @@ BList::operator=(const BList& list) bool -BList::operator==(const BList& list) const +BList::operator==(const BList& other) const { - if (&list == this) + if (&other == this) return true; - if (list.fItemCount != fItemCount) + if (other.fItemCount != fItemCount) return false; if (fItemCount > 0) { - return memcmp(fObjectList, list.fObjectList, + return memcmp(fObjectList, other.fObjectList, fItemCount * sizeof(void*)) == 0; } @@ -93,9 +94,9 @@ BList::operator==(const BList& list) const bool -BList::operator!=(const BList& list) const +BList::operator!=(const BList& other) const { - return !(*this == list); + return !(*this == other); } @@ -143,6 +144,7 @@ BList::AddList(const BList* list, int32 index) int32 count = list->fItemCount; if (fItemCount + count > fPhysicalSize) result = _ResizeArray(fItemCount + count); + if (result) { fItemCount += count; move_items(fObjectList + index, count, fItemCount - index - count); @@ -150,6 +152,7 @@ BList::AddList(const BList* list, int32 index) list->fItemCount * sizeof(void*)); } } + return result; } @@ -163,12 +166,14 @@ BList::AddList(const BList* list) int32 count = list->fItemCount; if (fItemCount + count > fPhysicalSize) result = _ResizeArray(fItemCount + count); + if (result) { fItemCount += count; memcpy(fObjectList + index, list->fObjectList, list->fItemCount * sizeof(void*)); } } + return result; } @@ -220,12 +225,12 @@ BList::RemoveItems(int32 index, int32 count) bool -BList::ReplaceItem(int32 index, void* newItem) +BList::ReplaceItem(int32 index, void* item) { bool result = false; if (index >= 0 && index < fItemCount) { - fObjectList[index] = newItem; + fObjectList[index] = item; result = true; } return result; @@ -278,22 +283,20 @@ BList::SwapItems(int32 indexA, int32 indexB) A C D E F G B H I J */ bool -BList::MoveItem(int32 fromIndex, int32 toIndex) +BList::MoveItem(int32 from, int32 to) { - if ((fromIndex >= fItemCount) || (toIndex >= fItemCount) || (fromIndex < 0) - || (toIndex < 0)) { + if ((from >= fItemCount) || (to >= fItemCount) || (from < 0) || (to < 0)) return false; - } - void* tmpMover = fObjectList[fromIndex]; - if (fromIndex < toIndex) { - memmove(fObjectList + fromIndex, fObjectList + fromIndex + 1, - (toIndex - fromIndex) * sizeof(void*)); - } else if (fromIndex > toIndex) { - memmove(fObjectList + toIndex + 1, fObjectList + toIndex, - (fromIndex - toIndex) * sizeof(void*)); - }; - fObjectList[toIndex] = tmpMover; + void* tmpMover = fObjectList[from]; + if (from < to) { + memmove(fObjectList + from, fObjectList + from + 1, + (to - from) * sizeof(void*)); + } else if (from > to) { + memmove(fObjectList + to + 1, fObjectList + to, + (from - to) * sizeof(void*)); + } + fObjectList[to] = tmpMover; return true; } @@ -305,7 +308,7 @@ BList::MoveItem(int32 fromIndex, int32 toIndex) void* BList::ItemAt(int32 index) const { - void *item = NULL; + void* item = NULL; if (index >= 0 && index < fItemCount) item = fObjectList[index]; return item; @@ -315,7 +318,7 @@ BList::ItemAt(int32 index) const void* BList::FirstItem() const { - void *item = NULL; + void* item = NULL; if (fItemCount > 0) item = fObjectList[0]; return item; @@ -467,8 +470,7 @@ void BList::_ReservedList1() {} void BList::_ReservedList2() {} -/*! Resizes fObjectList to be large enough to contain count items. -*/ +//! Resizes fObjectList to be large enough to contain count items. bool BList::_ResizeArray(int32 count) { @@ -480,12 +482,12 @@ BList::_ResizeArray(int32 count) int32 targetSize = count; if (targetSize <= 0) targetSize = fBlockSize; + if (targetSize > fPhysicalSize) { while (newSize < targetSize) newSize <<= 1; - } else if (targetSize <= fResizeThreshold) { + } else if (targetSize <= fResizeThreshold) newSize = fResizeThreshold; - } // resize if necessary if (newSize != fPhysicalSize) { @@ -501,6 +503,6 @@ BList::_ResizeArray(int32 count) } else result = false; } + return result; } - diff --git a/src/kits/support/Locker.cpp b/src/kits/support/Locker.cpp index 13c3bc3ad8..630c22ed21 100644 --- a/src/kits/support/Locker.cpp +++ b/src/kits/support/Locker.cpp @@ -1,9 +1,9 @@ /* - * Copyright 2001-2009, Haiku, Inc. + * Copyright 2001-2009 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: - * Erik Jaesler + * Erik Jaesler, erik@cgsoftware.com */ diff --git a/src/kits/support/String.cpp b/src/kits/support/String.cpp index 6e06c225f0..38a5747248 100644 --- a/src/kits/support/String.cpp +++ b/src/kits/support/String.cpp @@ -1,14 +1,14 @@ /* - * Copyright 2001-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Marc Flerackers (mflerackers@androme.be) - * Stefano Ceccherini (burton666@libero.it) - * Oliver Tappe (openbeos@hirschkaefer.de) + * Stefano Ceccherini, burton666@libero.it * Axel Dörfler, axeld@pinc-software.de - * Julun - * Michael Lotz + * Marc Flerackers, mflerackers@androme.be + * Julun, host.haiku@gmx.de + * Michael Lotz, mmlr@mlotz.ch + * Oliver Tappe, openbeos@hirschkaefer.de */ @@ -54,10 +54,10 @@ min_clamp0(int32 num1, int32 num2) //! Returns length of given string (but clamps to given maximum). static inline int32 -strlen_clamp(const char* str, int32 max) +strlen_clamp(const char* string, int32 max) { // this should yield 0 for max<0: - return max <= 0 ? 0 : strnlen(str, max); + return max <= 0 ? 0 : strnlen(string, max); } @@ -71,9 +71,9 @@ string_length(const char* string) //! helper function, massages given pointer into a legal c-string: static inline const char* -safestr(const char* str) +safestr(const char* string) { - return str ? str : ""; + return string != NULL ? string : ""; } @@ -110,6 +110,7 @@ public: } fBuffer[fSize++] = pos; + return true; } @@ -134,7 +135,8 @@ private: BStringRef::BStringRef(BString& string, int32 position) - : fString(string), fPosition(position) + : + fString(string), fPosition(position) { } diff --git a/src/kits/support/Url.cpp b/src/kits/support/Url.cpp index dd59207b99..bfe9965f5a 100644 --- a/src/kits/support/Url.cpp +++ b/src/kits/support/Url.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007-2009 Haiku Inc. All rights reserved. + * Copyright 2007-2009 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -275,7 +275,5 @@ BUrl::Path() const return fPath; } - } // namespace Support } // namespace BPrivate - diff --git a/src/kits/support/Uuid.cpp b/src/kits/support/Uuid.cpp index 23fd3c70b6..bc08a00e52 100644 --- a/src/kits/support/Uuid.cpp +++ b/src/kits/support/Uuid.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013, Haiku, Inc. + * Copyright 2013 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -32,13 +32,13 @@ init_random_seed() seed ^= (uint32)(addr_t)&time; srandom(seed); + return true; } namespace BPrivate { - BUuid::BUuid() { memset(fValue, 0, sizeof(fValue)); @@ -93,6 +93,7 @@ BUuid::ToString() const buffer[2 * i] = kHexChars[fValue[i] >> 4]; buffer[2 * i + 1] = kHexChars[fValue[i] & 0xf]; } + return BString().SetToFormat("%.8s-%.4s-%.4s-%.4s-%.12s", buffer, buffer + 8, buffer + 12, buffer + 16, buffer + 20); } @@ -109,6 +110,7 @@ BUuid& BUuid::operator=(const BUuid& other) { memcpy(fValue, other.fValue, sizeof(fValue)); + return *this; } @@ -153,7 +155,6 @@ BUuid::_SetToRandomFallback() fValue[4 * i] |= (bitsToMove << i) & 0x80; } - } // namespace BPrivate