42#include "MagickCore/studio.h"
43#include "MagickCore/blob.h"
44#include "MagickCore/client.h"
45#include "MagickCore/configure.h"
46#include "MagickCore/exception.h"
47#include "MagickCore/exception-private.h"
48#include "MagickCore/image-private.h"
49#include "MagickCore/linked-list.h"
50#include "MagickCore/locale_.h"
51#include "MagickCore/locale-private.h"
52#include "MagickCore/log.h"
53#include "MagickCore/memory_.h"
54#include "MagickCore/memory-private.h"
55#include "MagickCore/nt-base-private.h"
56#include "MagickCore/semaphore.h"
57#include "MagickCore/splay-tree.h"
58#include "MagickCore/string_.h"
59#include "MagickCore/string-private.h"
60#include "MagickCore/token.h"
61#include "MagickCore/utility.h"
62#include "MagickCore/utility-private.h"
63#include "MagickCore/xml-tree.h"
64#include "MagickCore/xml-tree-private.h"
69#if (defined(MAGICKCORE_HAVE_NEWLOCALE) || defined(MAGICKCORE_WINDOWS_SUPPORT)) && !defined(__MINGW32__)
70# define MAGICKCORE_LOCALE_SUPPORT
72#define LocaleFilename "locale.xml"
79 "<?xml version=\"1.0\"?>"
81 " <locale name=\"C\">"
83 " <Message name=\"\">"
95#if defined(MAGICKCORE_LOCALE_SUPPORT)
96static volatile locale_t
97 c_locale = (locale_t) NULL;
103static MagickBooleanType
105 LoadLocaleCache(
SplayTreeInfo *,
const char *,
const char *,
const char *,
108#if defined(MAGICKCORE_LOCALE_SUPPORT)
128static locale_t AcquireCLocale(
void)
130#if defined(MAGICKCORE_HAVE_NEWLOCALE)
131 if (c_locale == (locale_t) NULL)
132 c_locale=newlocale(LC_ALL_MASK,
"C",(locale_t) 0);
133#elif defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__)
134 if (c_locale == (locale_t) NULL)
135 c_locale=_create_locale(LC_ALL,
"C");
170static void *DestroyLocaleNode(
void *locale_info)
176 if (p->path != (
char *) NULL)
177 p->path=DestroyString(p->path);
178 if (p->tag != (
char *) NULL)
179 p->tag=DestroyString(p->tag);
180 if (p->message != (
char *) NULL)
181 p->message=DestroyString(p->message);
182 return(RelinquishMagickMemory(p));
185static SplayTreeInfo *AcquireLocaleSplayTree(
const char *filename,
191 cache=NewSplayTree(CompareSplayTreeString,(
void *(*)(
void *)) NULL,
193#if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
201 options=GetLocaleOptions(filename,exception);
202 option=(
const StringInfo *) GetNextValueInLinkedList(options);
205 (void) LoadLocaleCache(cache,(
const char *)
206 GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
208 option=(
const StringInfo *) GetNextValueInLinkedList(options);
210 options=DestroyLocaleOptions(options);
211 if (GetNumberOfNodesInSplayTree(cache) == 0)
213 options=GetLocaleOptions(
"english.xml",exception);
214 option=(
const StringInfo *) GetNextValueInLinkedList(options);
217 (void) LoadLocaleCache(cache,(
const char *)
218 GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
220 option=(
const StringInfo *) GetNextValueInLinkedList(options);
222 options=DestroyLocaleOptions(options);
226 magick_unreferenced(filename);
228 if (GetNumberOfNodesInSplayTree(cache) == 0)
229 (void) LoadLocaleCache(cache,LocaleMap,
"built-in",locale,0,
234#if defined(MAGICKCORE_LOCALE_SUPPORT)
254static void DestroyCLocale(
void)
256 if (c_locale != (locale_t) NULL)
257 freelocale(c_locale);
258 c_locale=(locale_t) NULL;
286static void *DestroyOptions(
void *message)
288 return(DestroyStringInfo((
StringInfo *) message));
294 if (IsEventLogging() != MagickFalse)
295 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
296 return(DestroyLinkedList(messages,DestroyOptions));
326MagickPrivate ssize_t FormatLocaleFileList(FILE *file,
327 const char *magick_restrict format,va_list operands)
332#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VFPRINTF_L)
337 locale=AcquireCLocale();
338 if (locale == (locale_t) NULL)
339 n=(ssize_t) vfprintf(file,format,operands);
341#if defined(MAGICKCORE_WINDOWS_SUPPORT)
342 n=(ssize_t) vfprintf_l(file,format,locale,operands);
344 n=(ssize_t) vfprintf_l(file,locale,format,operands);
348#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE)
354 locale=AcquireCLocale();
355 if (locale == (locale_t) NULL)
356 n=(ssize_t) vfprintf(file,format,operands);
359 previous_locale=uselocale(locale);
360 n=(ssize_t) vfprintf(file,format,operands);
361 uselocale(previous_locale);
365 n=(ssize_t) vfprintf(file,format,operands);
371MagickExport ssize_t FormatLocaleFile(FILE *file,
372 const char *magick_restrict format,...)
380 va_start(operands,format);
381 n=FormatLocaleFileList(file,format,operands);
417MagickPrivate ssize_t FormatLocaleStringList(
char *magick_restrict
string,
418 const size_t length,
const char *magick_restrict format,va_list operands)
423#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VSNPRINTF_L)
428 locale=AcquireCLocale();
429 if (locale == (locale_t) NULL)
430 n=(ssize_t) vsnprintf(
string,length,format,operands);
432#if defined(MAGICKCORE_WINDOWS_SUPPORT)
433 n=(ssize_t) vsnprintf_l(
string,length,format,locale,operands);
435 n=(ssize_t) vsnprintf_l(
string,length,locale,format,operands);
438#elif defined(MAGICKCORE_HAVE_VSNPRINTF)
439#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE)
445 locale=AcquireCLocale();
446 if (locale == (locale_t) NULL)
447 n=(ssize_t) vsnprintf(
string,length,format,operands);
450 previous_locale=uselocale(locale);
451 n=(ssize_t) vsnprintf(
string,length,format,operands);
452 uselocale(previous_locale);
456 n=(ssize_t) vsnprintf(
string,length,format,operands);
459 n=(ssize_t) vsprintf(
string,format,operands);
462 string[length-1]=
'\0';
466MagickExport ssize_t FormatLocaleString(
char *magick_restrict
string,
467 const size_t length,
const char *magick_restrict format,...)
475 va_start(operands,format);
476 n=FormatLocaleStringList(
string,length,format,operands);
507MagickExport
const LocaleInfo *GetLocaleInfo_(
const char *tag,
514 if (IsLocaleTreeInstantiated(exception) == MagickFalse)
516 LockSemaphoreInfo(locale_semaphore);
517 if ((tag == (
const char *) NULL) || (LocaleCompare(tag,
"*") == 0))
519 ResetSplayTreeIterator(locale_cache);
520 locale_info=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
521 UnlockSemaphoreInfo(locale_semaphore);
524 locale_info=(
const LocaleInfo *) GetValueFromSplayTree(locale_cache,tag);
525 UnlockSemaphoreInfo(locale_semaphore);
559#if defined(__cplusplus) || defined(c_plusplus)
563static int LocaleInfoCompare(
const void *x,
const void *y)
571 if (LocaleCompare((*p)->path,(*q)->path) == 0)
572 return(LocaleCompare((*p)->tag,(*q)->tag));
573 return(LocaleCompare((*p)->path,(*q)->path));
576#if defined(__cplusplus) || defined(c_plusplus)
580MagickExport
const LocaleInfo **GetLocaleInfoList(
const char *pattern,
595 assert(pattern != (
char *) NULL);
596 assert(number_messages != (
size_t *) NULL);
597 if (IsEventLogging() != MagickFalse)
598 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
600 p=GetLocaleInfo_(
"*",exception);
603 messages=(
const LocaleInfo **) AcquireQuantumMemory((
size_t)
604 GetNumberOfNodesInSplayTree(locale_cache)+1UL,
sizeof(*messages));
610 LockSemaphoreInfo(locale_semaphore);
611 ResetSplayTreeIterator(locale_cache);
612 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
615 if ((p->stealth == MagickFalse) &&
616 (GlobExpression(p->tag,pattern,MagickTrue) != MagickFalse))
618 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
620 UnlockSemaphoreInfo(locale_semaphore);
621 qsort((
void *) messages,(
size_t) i,
sizeof(*messages),LocaleInfoCompare);
623 *number_messages=(size_t) i;
657#if defined(__cplusplus) || defined(c_plusplus)
661static int LocaleTagCompare(
const void *x,
const void *y)
669 return(LocaleCompare(*p,*q));
672#if defined(__cplusplus) || defined(c_plusplus)
676MagickExport
char **GetLocaleList(
const char *pattern,
size_t *number_messages,
691 assert(pattern != (
char *) NULL);
692 assert(number_messages != (
size_t *) NULL);
693 if (IsEventLogging() != MagickFalse)
694 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
696 p=GetLocaleInfo_(
"*",exception);
698 return((
char **) NULL);
699 messages=(
char **) AcquireQuantumMemory((
size_t)
700 GetNumberOfNodesInSplayTree(locale_cache)+1UL,
sizeof(*messages));
701 if (messages == (
char **) NULL)
702 return((
char **) NULL);
703 LockSemaphoreInfo(locale_semaphore);
704 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
707 if ((p->stealth == MagickFalse) &&
708 (GlobExpression(p->tag,pattern,MagickTrue) != MagickFalse))
709 messages[i++]=ConstantString(p->tag);
710 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
712 UnlockSemaphoreInfo(locale_semaphore);
713 qsort((
void *) messages,(
size_t) i,
sizeof(*messages),LocaleTagCompare);
714 messages[i]=(
char *) NULL;
715 *number_messages=(size_t) i;
742MagickExport
const char *GetLocaleMessage(
const char *tag)
745 name[MagickLocaleExtent];
753 if ((tag == (
const char *) NULL) || (*tag ==
'\0'))
755 exception=AcquireExceptionInfo();
756 (void) FormatLocaleString(name,MagickLocaleExtent,
"%s/",tag);
757 locale_info=GetLocaleInfo_(name,exception);
758 exception=DestroyExceptionInfo(exception);
760 return(locale_info->message);
790MagickExport
LinkedListInfo *GetLocaleOptions(
const char *filename,
794 path[MagickPathExtent];
806 assert(filename != (
const char *) NULL);
808 if (IsEventLogging() != MagickFalse)
809 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",filename);
810 (void) CopyMagickString(path,filename,MagickPathExtent);
814 messages=NewLinkedList(0);
815 paths=GetConfigurePaths(filename,exception);
818 ResetLinkedListIterator(paths);
819 element=(
const char *) GetNextValueInLinkedList(paths);
820 while (element != (
const char *) NULL)
822 (void) FormatLocaleString(path,MagickPathExtent,
"%s%s",element,
824 (void) LogMagickEvent(LocaleEvent,GetMagickModule(),
825 "Searching for locale file: \"%s\"",path);
826 xml=ConfigureFileToStringInfo(path);
828 (void) AppendValueToLinkedList(messages,xml);
829 element=(
const char *) GetNextValueInLinkedList(paths);
831 paths=DestroyLinkedList(paths,RelinquishMagickMemory);
833#if defined(MAGICKCORE_WINDOWS_SUPPORT)
838 blob=(
char *) NTResourceToBlob(filename);
839 if (blob != (
char *) NULL)
841 xml=AcquireStringInfo(0);
842 SetStringInfoLength(xml,strlen(blob)+1);
843 SetStringInfoDatum(xml,(
const unsigned char *) blob);
844 blob=(
char *) RelinquishMagickMemory(blob);
845 SetStringInfoPath(xml,filename);
846 (void) AppendValueToLinkedList(messages,xml);
850 ResetLinkedListIterator(messages);
876MagickExport
const char *GetLocaleValue(
const LocaleInfo *locale_info)
878 if (IsEventLogging() != MagickFalse)
879 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
881 assert(locale_info->signature == MagickCoreSignature);
882 return(locale_info->message);
908static MagickBooleanType IsLocaleTreeInstantiated(
ExceptionInfo *exception)
913 ActivateSemaphoreInfo(&locale_semaphore);
914 LockSemaphoreInfo(locale_semaphore);
923 locale=(
char *) NULL;
924 p=setlocale(LC_CTYPE,(
const char *) NULL);
925 if (p != (
const char *) NULL)
926 locale=ConstantString(p);
927 if (locale == (
char *) NULL)
928 locale=GetEnvironmentValue(
"LC_ALL");
929 if (locale == (
char *) NULL)
930 locale=GetEnvironmentValue(
"LC_MESSAGES");
931 if (locale == (
char *) NULL)
932 locale=GetEnvironmentValue(
"LC_CTYPE");
933 if (locale == (
char *) NULL)
934 locale=GetEnvironmentValue(
"LANG");
935 if (locale == (
char *) NULL)
936 locale=ConstantString(
"C");
937 locale_cache=AcquireLocaleSplayTree(LocaleFilename,locale,exception);
938 locale=DestroyString(locale);
940 UnlockSemaphoreInfo(locale_semaphore);
942 return(locale_cache != (
SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
974MagickExport
double InterpretLocaleValue(
const char *magick_restrict
string,
975 char *magick_restrict *sentinel)
983 if ((*
string ==
'0') && ((
string[1] | 0x20)==
'x'))
984 value=(double) strtoul(
string,&q,16);
987#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_STRTOD_L)
991 locale=AcquireCLocale();
992 if (locale == (locale_t) NULL)
993 value=strtod(
string,&q);
995 value=strtod_l(
string,&q,locale);
997 value=strtod(
string,&q);
1000 if (sentinel != (
char **) NULL)
1029MagickExport MagickBooleanType ListLocaleInfo(FILE *file,
1044 if (file == (
const FILE *) NULL)
1047 locale_info=GetLocaleInfoList(
"*",&number_messages,exception);
1048 if (locale_info == (
const LocaleInfo **) NULL)
1049 return(MagickFalse);
1050 path=(
const char *) NULL;
1051 for (i=0; i < (ssize_t) number_messages; i++)
1053 if (locale_info[i]->stealth != MagickFalse)
1055 if ((path == (
const char *) NULL) ||
1056 (LocaleCompare(path,locale_info[i]->path) != 0))
1058 if (locale_info[i]->path != (
char *) NULL)
1059 (
void) FormatLocaleFile(file,
"\nPath: %s\n\n",locale_info[i]->path);
1060 (void) FormatLocaleFile(file,
"Tag/Message\n");
1061 (void) FormatLocaleFile(file,
1062 "-------------------------------------------------"
1063 "------------------------------\n");
1065 path=locale_info[i]->path;
1066 (void) FormatLocaleFile(file,
"%s\n",locale_info[i]->tag);
1067 if (locale_info[i]->message != (
char *) NULL)
1068 (
void) FormatLocaleFile(file,
" %s",locale_info[i]->message);
1069 (void) FormatLocaleFile(file,
"\n");
1071 (void) fflush(file);
1073 RelinquishMagickMemory((
void *) locale_info);
1108static void ChopLocaleComponents(
char *path,
const size_t components)
1118 p=path+strlen(path)-1;
1121 for (count=0; (count < (ssize_t) components) && (p > path); p--)
1127 if (count < (ssize_t) components)
1132static void LocaleFatalErrorHandler(
const ExceptionType severity,
1133 const char *reason,
const char *description) magick_attribute((__noreturn__));
1135static void LocaleFatalErrorHandler(
1136 const ExceptionType magick_unused(severity),
1137 const char *reason,
const char *description)
1139 magick_unreferenced(severity);
1141 (void) FormatLocaleFile(stderr,
"%s: ",GetClientName());
1142 if (reason != (
char *) NULL)
1143 (
void) FormatLocaleFile(stderr,
" %s",reason);
1144 if (description != (
char *) NULL)
1145 (void) FormatLocaleFile(stderr,
" (%s)",description);
1146 (void) FormatLocaleFile(stderr,
".\n");
1147 (void) fflush(stderr);
1151static MagickBooleanType LoadLocaleCache(
SplayTreeInfo *cache,
const char *xml,
1152 const char *filename,
const char *locale,
const size_t depth,
ExceptionInfo *exception)
1155 keyword[MagickLocaleExtent],
1156 message[MagickLocaleExtent],
1157 tag[MagickLocaleExtent],
1181 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
1182 "Loading locale configure file \"%s\" ...",filename);
1183 if (xml == (
const char *) NULL)
1184 return(MagickFalse);
1190 fatal_handler=SetFatalErrorHandler(LocaleFatalErrorHandler);
1191 token=AcquireString(xml);
1192 extent=strlen(token)+MagickPathExtent;
1193 for (q=(
char *) xml; *q !=
'\0'; )
1198 (void) GetNextToken(q,&q,extent,token);
1201 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1202 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
1207 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
1209 (void) GetNextToken(q,&q,extent,token);
1210 while (isspace((
int) ((
unsigned char) *q)) != 0)
1215 if (LocaleNCompare(keyword,
"<!--",4) == 0)
1220 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
1222 (void) GetNextToken(q,&q,extent,token);
1223 while (isspace((
int) ((
unsigned char) *q)) != 0)
1228 if (LocaleCompare(keyword,
"<include") == 0)
1233 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
1235 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1236 (void) GetNextToken(q,&q,extent,token);
1239 (void) GetNextToken(q,&q,extent,token);
1240 if (LocaleCompare(keyword,
"locale") == 0)
1242 if (LocaleCompare(locale,token) != 0)
1246 if (LocaleCompare(keyword,
"file") == 0)
1248 if (depth > MagickMaxRecursionDepth)
1249 (void) ThrowMagickException(exception,GetMagickModule(),
1250 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
1254 path[MagickPathExtent],
1258 GetPathComponent(filename,HeadPath,path);
1260 (void) ConcatenateMagickString(path,DirectorySeparator,
1262 if (*token == *DirectorySeparator)
1263 (void) CopyMagickString(path,token,MagickPathExtent);
1265 (
void) ConcatenateMagickString(path,token,MagickPathExtent);
1266 file_xml=FileToXML(path,~0UL);
1267 if (file_xml != (
char *) NULL)
1269 status&=LoadLocaleCache(cache,file_xml,path,locale,
1271 file_xml=DestroyString(file_xml);
1278 if (LocaleCompare(keyword,
"<locale") == 0)
1283 while ((*token !=
'>') && (*q !=
'\0'))
1285 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1286 (void) GetNextToken(q,&q,extent,token);
1289 (void) GetNextToken(q,&q,extent,token);
1293 if (LocaleCompare(keyword,
"</locale>") == 0)
1295 ChopLocaleComponents(tag,1);
1296 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1299 if (LocaleCompare(keyword,
"<localemap>") == 0)
1301 if (LocaleCompare(keyword,
"</localemap>") == 0)
1303 if (LocaleCompare(keyword,
"<message") == 0)
1308 while ((*token !=
'>') && (*q !=
'\0'))
1310 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1311 (void) GetNextToken(q,&q,extent,token);
1314 (void) GetNextToken(q,&q,extent,token);
1315 if (LocaleCompare(keyword,
"name") == 0)
1317 (void) ConcatenateMagickString(tag,token,MagickLocaleExtent);
1318 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1321 for (p=(
char *) q; (*q !=
'<') && (*q !=
'\0'); q++) ;
1322 while (isspace((
int) ((
unsigned char) *p)) != 0)
1325 while ((isspace((
int) ((
unsigned char) *q)) != 0) && (q > p))
1327 (void) CopyMagickString(message,p,MagickMin((
size_t) (q-p+2),
1328 MagickLocaleExtent));
1329 locale_info=(
LocaleInfo *) AcquireCriticalMemory(
sizeof(*locale_info));
1330 (void) memset(locale_info,0,
sizeof(*locale_info));
1331 locale_info->path=ConstantString(filename);
1332 locale_info->tag=ConstantString(tag);
1333 locale_info->message=ConstantString(message);
1334 locale_info->signature=MagickCoreSignature;
1335 status=AddValueToSplayTree(cache,locale_info->tag,locale_info);
1336 if (status == MagickFalse)
1337 (void) ThrowMagickException(exception,GetMagickModule(),
1338 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
1340 (void) ConcatenateMagickString(tag,message,MagickLocaleExtent);
1341 (void) ConcatenateMagickString(tag,
"\n",MagickLocaleExtent);
1345 if (LocaleCompare(keyword,
"</message>") == 0)
1347 ChopLocaleComponents(tag,2);
1348 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1351 if (*keyword ==
'<')
1356 if (*(keyword+1) ==
'?')
1358 if (*(keyword+1) ==
'/')
1360 ChopLocaleComponents(tag,1);
1362 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1365 token[strlen(token)-1]=
'\0';
1366 (void) CopyMagickString(token,token+1,MagickLocaleExtent);
1367 (void) ConcatenateMagickString(tag,token,MagickLocaleExtent);
1368 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1371 (void) GetNextToken(q,(
const char **) NULL,extent,token);
1375 token=(
char *) RelinquishMagickMemory(token);
1376 (void) SetFatalErrorHandler(fatal_handler);
1377 return(status != 0 ? MagickTrue : MagickFalse);
1410MagickExport
int LocaleCompare(
const char *p,
const char *q)
1412 if (p == (
char *) NULL)
1414 if (q == (
char *) NULL)
1418 if (q == (
char *) NULL)
1422 *r = (
const unsigned char *) p,
1423 *s = (
const unsigned char *) q;
1425 for ( ; (*r !=
'\0') && (*s !=
'\0') && ((*r == *s) ||
1426 (LocaleToLowercase((
int) *r) == LocaleToLowercase((
int) *s))); r++, s++);
1427 return(LocaleToLowercase((
int) *r)-LocaleToLowercase((
int) *s));
1454MagickExport
void LocaleLower(
char *
string)
1459 assert(
string != (
char *) NULL);
1460 for (q=
string; *q !=
'\0'; q++)
1461 *q=(
char) LocaleToLowercase((
int) *q);
1486MagickExport
int LocaleLowercase(
const int c)
1488 return(LocaleToLowercase(c));
1528MagickExport
int LocaleNCompare(
const char *p,
const char *q,
const size_t length)
1530 if (p == (
char *) NULL)
1532 if (q == (
char *) NULL)
1536 if (q == (
char *) NULL)
1542 *s = (
const unsigned char *) p,
1543 *t = (
const unsigned char *) q;
1548 for (n--; (*s !=
'\0') && (*t !=
'\0') && (n != 0) && ((*s == *t) ||
1549 (LocaleToLowercase((
int) *s) == LocaleToLowercase((
int) *t))); s++, t++, n--);
1550 return(LocaleToLowercase((
int) *s)-LocaleToLowercase((
int) *t));
1577MagickExport
void LocaleUpper(
char *
string)
1582 assert(
string != (
char *) NULL);
1583 for (q=
string; *q !=
'\0'; q++)
1584 *q=(
char) LocaleToUppercase((
int) *q);
1609MagickExport
int LocaleUppercase(
const int c)
1611 return(LocaleToUppercase(c));
1632MagickPrivate MagickBooleanType LocaleComponentGenesis(
void)
1635 locale_semaphore=AcquireSemaphoreInfo();
1636#if defined(MAGICKCORE_LOCALE_SUPPORT)
1637 (void) AcquireCLocale();
1660MagickPrivate
void LocaleComponentTerminus(
void)
1663 ActivateSemaphoreInfo(&locale_semaphore);
1664 LockSemaphoreInfo(locale_semaphore);
1666 locale_cache=DestroySplayTree(locale_cache);
1667#if defined(MAGICKCORE_LOCALE_SUPPORT)
1670 UnlockSemaphoreInfo(locale_semaphore);
1671 RelinquishSemaphoreInfo(&locale_semaphore);