Avoid rm switching to interactive mode for any locale other than POSIX:
* reset errno to 0 if it has been set during execution of any ICU method (which doesn't set errno itself, but may invoke system functions that do) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37736 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -23,6 +24,27 @@ CreateInstance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper class resetting errno to 0 if it has been set during the execution
|
||||||
|
* of ICU methods. Any changes of errno shall only be done by our callers.
|
||||||
|
*/
|
||||||
|
class ErrnoMaintainer {
|
||||||
|
public:
|
||||||
|
ErrnoMaintainer()
|
||||||
|
: fErrnoUponEntry(errno)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~ErrnoMaintainer()
|
||||||
|
{
|
||||||
|
if (errno != 0 && fErrnoUponEntry == 0)
|
||||||
|
errno = 0;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
int fErrnoUponEntry;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
ICULocaleBackend::ICULocaleBackend()
|
ICULocaleBackend::ICULocaleBackend()
|
||||||
:
|
:
|
||||||
fMonetaryData(fLocaleConv),
|
fMonetaryData(fLocaleConv),
|
||||||
@@ -40,6 +62,8 @@ ICULocaleBackend::~ICULocaleBackend()
|
|||||||
void
|
void
|
||||||
ICULocaleBackend::Initialize(LocaleDataBridge* dataBridge)
|
ICULocaleBackend::Initialize(LocaleDataBridge* dataBridge)
|
||||||
{
|
{
|
||||||
|
ErrnoMaintainer errnoMaintainer;
|
||||||
|
|
||||||
fCtypeData.Initialize(&dataBridge->ctypeDataBridge);
|
fCtypeData.Initialize(&dataBridge->ctypeDataBridge);
|
||||||
fMessagesData.Initialize(&dataBridge->messagesDataBridge);
|
fMessagesData.Initialize(&dataBridge->messagesDataBridge);
|
||||||
fMonetaryData.Initialize(&dataBridge->monetaryDataBridge);
|
fMonetaryData.Initialize(&dataBridge->monetaryDataBridge);
|
||||||
@@ -55,6 +79,8 @@ ICULocaleBackend::Initialize(LocaleDataBridge* dataBridge)
|
|||||||
const char*
|
const char*
|
||||||
ICULocaleBackend::SetLocale(int category, const char* posixLocaleName)
|
ICULocaleBackend::SetLocale(int category, const char* posixLocaleName)
|
||||||
{
|
{
|
||||||
|
ErrnoMaintainer errnoMaintainer;
|
||||||
|
|
||||||
if (posixLocaleName == NULL)
|
if (posixLocaleName == NULL)
|
||||||
return _QueryLocale(category);
|
return _QueryLocale(category);
|
||||||
|
|
||||||
@@ -123,6 +149,8 @@ ICULocaleBackend::LCTimeInfo()
|
|||||||
int
|
int
|
||||||
ICULocaleBackend::IsWCType(wint_t wc, wctype_t charClass)
|
ICULocaleBackend::IsWCType(wint_t wc, wctype_t charClass)
|
||||||
{
|
{
|
||||||
|
ErrnoMaintainer errnoMaintainer;
|
||||||
|
|
||||||
return fCtypeData.IsWCType(wc, charClass);
|
return fCtypeData.IsWCType(wc, charClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +158,8 @@ ICULocaleBackend::IsWCType(wint_t wc, wctype_t charClass)
|
|||||||
status_t
|
status_t
|
||||||
ICULocaleBackend::ToWCTrans(wint_t wc, wctrans_t transition, wint_t& result)
|
ICULocaleBackend::ToWCTrans(wint_t wc, wctrans_t transition, wint_t& result)
|
||||||
{
|
{
|
||||||
|
ErrnoMaintainer errnoMaintainer;
|
||||||
|
|
||||||
return fCtypeData.ToWCTrans(wc, transition, result);
|
return fCtypeData.ToWCTrans(wc, transition, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +167,8 @@ ICULocaleBackend::ToWCTrans(wint_t wc, wctrans_t transition, wint_t& result)
|
|||||||
const char*
|
const char*
|
||||||
ICULocaleBackend::GetLanginfo(int index)
|
ICULocaleBackend::GetLanginfo(int index)
|
||||||
{
|
{
|
||||||
|
ErrnoMaintainer errnoMaintainer;
|
||||||
|
|
||||||
switch(index) {
|
switch(index) {
|
||||||
case CODESET:
|
case CODESET:
|
||||||
return fCtypeData.GetLanginfo(index);
|
return fCtypeData.GetLanginfo(index);
|
||||||
@@ -214,6 +246,8 @@ ICULocaleBackend::GetLanginfo(int index)
|
|||||||
status_t
|
status_t
|
||||||
ICULocaleBackend::Strcoll(const char* a, const char* b, int& result)
|
ICULocaleBackend::Strcoll(const char* a, const char* b, int& result)
|
||||||
{
|
{
|
||||||
|
ErrnoMaintainer errnoMaintainer;
|
||||||
|
|
||||||
return fCollateData.Strcoll(a, b, result);
|
return fCollateData.Strcoll(a, b, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +256,8 @@ status_t
|
|||||||
ICULocaleBackend::Strxfrm(char* out, const char* in, size_t size,
|
ICULocaleBackend::Strxfrm(char* out, const char* in, size_t size,
|
||||||
size_t& outSize)
|
size_t& outSize)
|
||||||
{
|
{
|
||||||
|
ErrnoMaintainer errnoMaintainer;
|
||||||
|
|
||||||
return fCollateData.Strxfrm(out, in, size, outSize);
|
return fCollateData.Strxfrm(out, in, size, outSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user