#include "MagickCore/utility.h"
#include "MagickCore/utility-private.h"
#include "MagickCore/xml-tree.h"
+#include "MagickCore/xml-tree-private.h"
\f
/*
Define declarations.
*/
static MagickBooleanType
IsLocaleTreeInstantiated(ExceptionInfo *),
- LoadLocaleCache(const char *,const char *,const char *,const size_t,
- ExceptionInfo *);
+ LoadLocaleCache(SplayTreeInfo *,const char *,const char *,const char *,
+ const size_t,ExceptionInfo *);
\f
#if defined(MAGICKCORE_HAVE_STRTOD_L)
/*
static SplayTreeInfo *AcquireLocaleSplayTree(const char *filename,
const char *locale,ExceptionInfo *exception)
{
- const StringInfo
- *option;
-
- LinkedListInfo
- *options;
-
MagickStatusType
status;
if (locale_cache == (SplayTreeInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
status=MagickTrue;
- options=GetLocaleOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
- while (option != (const StringInfo *) NULL)
{
- status&=LoadLocaleCache((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),locale,0,exception);
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options;
+
+ options=GetLocaleOptions(filename,exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
- }
-#endif
- options=DestroyLocaleOptions(options);
-#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
- if (GetNumberOfNodesInSplayTree(locale_cache) == 0)
+ while (option != (const StringInfo *) NULL)
{
- options=GetLocaleOptions("english.xml",exception);
+ status&=LoadLocaleCache(locale_cache,(const char *)
+ GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
+ exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
+ }
+ options=DestroyLocaleOptions(options);
+ if (GetNumberOfNodesInSplayTree(locale_cache) == 0)
{
- status&=LoadLocaleCache((const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),locale,0,exception);
+ options=GetLocaleOptions("english.xml",exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadLocaleCache(locale_cache,(const char *)
+ GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
+ exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyLocaleOptions(options);
}
- options=DestroyLocaleOptions(options);
- }
+ }
#endif
if (GetNumberOfNodesInSplayTree(locale_cache) == 0)
- status&=LoadLocaleCache(LocaleMap,"built-in",locale,0,exception);
+ status&=LoadLocaleCache(locale_cache,LocaleMap,"built-in",locale,0,
+ exception);
return(locale_cache);
}
\f
*/
static MagickBooleanType IsLocaleTreeInstantiated(ExceptionInfo *exception)
{
- if (locale_semaphore == (SemaphoreInfo *) NULL)
- ActivateSemaphoreInfo(&locale_semaphore);
- LockSemaphoreInfo(locale_semaphore);
if (locale_cache == (SplayTreeInfo *) NULL)
{
- char
- *locale;
-
- register const char
- *p;
-
- locale=(char *) NULL;
- p=setlocale(LC_CTYPE,(const char *) NULL);
- if (p != (const char *) NULL)
- locale=ConstantString(p);
- if (locale == (char *) NULL)
- locale=GetEnvironmentValue("LC_ALL");
- if (locale == (char *) NULL)
- locale=GetEnvironmentValue("LC_MESSAGES");
- if (locale == (char *) NULL)
- locale=GetEnvironmentValue("LC_CTYPE");
- if (locale == (char *) NULL)
- locale=GetEnvironmentValue("LANG");
- if (locale == (char *) NULL)
- locale=ConstantString("C");
- locale_cache=AcquireLocaleSplayTree(LocaleFilename,locale,exception);
- locale=DestroyString(locale);
+ if (locale_semaphore == (SemaphoreInfo *) NULL)
+ ActivateSemaphoreInfo(&locale_semaphore);
+ LockSemaphoreInfo(locale_semaphore);
+ if (locale_cache == (SplayTreeInfo *) NULL)
+ {
+ char
+ *locale;
+
+ register const char
+ *p;
+
+ locale=(char *) NULL;
+ p=setlocale(LC_CTYPE,(const char *) NULL);
+ if (p != (const char *) NULL)
+ locale=ConstantString(p);
+ if (locale == (char *) NULL)
+ locale=GetEnvironmentValue("LC_ALL");
+ if (locale == (char *) NULL)
+ locale=GetEnvironmentValue("LC_MESSAGES");
+ if (locale == (char *) NULL)
+ locale=GetEnvironmentValue("LC_CTYPE");
+ if (locale == (char *) NULL)
+ locale=GetEnvironmentValue("LANG");
+ if (locale == (char *) NULL)
+ locale=ConstantString("C");
+ locale_cache=AcquireLocaleSplayTree(LocaleFilename,locale,exception);
+ locale=DestroyString(locale);
+ }
+ UnlockSemaphoreInfo(locale_semaphore);
}
- UnlockSemaphoreInfo(locale_semaphore);
return(locale_cache != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
%
% The format of the LoadLocaleCache method is:
%
-% MagickBooleanType LoadLocaleCache(const char *xml,const char *filename,
-% const size_t depth,ExceptionInfo *exception)
+% MagickBooleanType LoadLocaleCache(SplayTreeInfo *locale_cache,
+% const char *xml,const char *filename,const size_t depth,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
return(y);
}
-static MagickBooleanType LoadLocaleCache(const char *xml,const char *filename,
- const char *locale,const size_t depth,ExceptionInfo *exception)
+static MagickBooleanType LoadLocaleCache(SplayTreeInfo *locale_cache,
+ const char *xml,const char *filename,const char *locale,const size_t depth,
+ ExceptionInfo *exception)
{
char
keyword[MaxTextExtent],
"Loading locale configure file \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
- if (locale_cache == (SplayTreeInfo *) NULL)
- {
- locale_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
- DestroyLocaleNode);
- if (locale_cache == (SplayTreeInfo *) NULL)
- return(MagickFalse);
- }
status=MagickTrue;
locale_info=(LocaleInfo *) NULL;
*tag='\0';
(void) CopyMagickString(path,token,MaxTextExtent);
else
(void) ConcatenateMagickString(path,token,MaxTextExtent);
- xml=FileToString(path,~0UL,exception);
+ xml=FileToXML(path,~0UL);
if (xml != (char *) NULL)
{
- status=LoadLocaleCache(xml,path,locale,depth+1,exception);
+ status&=LoadLocaleCache(locale_cache,xml,path,locale,
+ depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
*/
MagickPrivate MagickBooleanType LocaleComponentGenesis(void)
{
- locale_semaphore=AcquireSemaphoreInfo();
+ if (locale_semaphore == (SemaphoreInfo *) NULL)
+ locale_semaphore=AcquireSemaphoreInfo();
return(MagickTrue);
}
\f