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
73#if defined(MAGICKCORE_WINDOWS_SUPPORT)
74# if !defined(freelocale)
75# define freelocale _free_locale
77# if !defined(locale_t)
78# define locale_t _locale_t
80# if !defined(strtod_l)
81# define strtod_l _strtod_l
83# if !defined(vfprintf_l)
84# define vfprintf_l _vfprintf_l
86# if !defined(vsnprintf_l)
87# define vsnprintf_l _vsnprintf_l
91#define LocaleFilename "locale.xml"
98 "<?xml version=\"1.0\"?>"
100 " <locale name=\"C\">"
102 " <Message name=\"\">"
114#if defined(MAGICKCORE_LOCALE_SUPPORT)
115static volatile locale_t
116 c_locale = (locale_t) NULL;
122static MagickBooleanType
124 LoadLocaleCache(
SplayTreeInfo *,
const char *,
const char *,
const char *,
127#if defined(MAGICKCORE_LOCALE_SUPPORT)
147static locale_t AcquireCLocale(
void)
149#if defined(MAGICKCORE_HAVE_NEWLOCALE)
150 if (c_locale == (locale_t) NULL)
151 c_locale=newlocale(LC_ALL_MASK,
"C",(locale_t) 0);
152#elif defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__)
153 if (c_locale == (locale_t) NULL)
154 c_locale=_create_locale(LC_ALL,
"C");
189static void *DestroyLocaleNode(
void *locale_info)
195 if (p->path != (
char *) NULL)
196 p->path=DestroyString(p->path);
197 if (p->tag != (
char *) NULL)
198 p->tag=DestroyString(p->tag);
199 if (p->message != (
char *) NULL)
200 p->message=DestroyString(p->message);
201 return(RelinquishMagickMemory(p));
204static SplayTreeInfo *AcquireLocaleSplayTree(
const char *filename,
210 cache=NewSplayTree(CompareSplayTreeString,(
void *(*)(
void *)) NULL,
212#if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
220 options=GetLocaleOptions(filename,exception);
221 option=(
const StringInfo *) GetNextValueInLinkedList(options);
224 (void) LoadLocaleCache(cache,(
const char *)
225 GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
227 option=(
const StringInfo *) GetNextValueInLinkedList(options);
229 options=DestroyLocaleOptions(options);
230 if (GetNumberOfNodesInSplayTree(cache) == 0)
232 options=GetLocaleOptions(
"english.xml",exception);
233 option=(
const StringInfo *) GetNextValueInLinkedList(options);
236 (void) LoadLocaleCache(cache,(
const char *)
237 GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
239 option=(
const StringInfo *) GetNextValueInLinkedList(options);
241 options=DestroyLocaleOptions(options);
245 magick_unreferenced(filename);
247 if (GetNumberOfNodesInSplayTree(cache) == 0)
248 (void) LoadLocaleCache(cache,LocaleMap,
"built-in",locale,0,
253#if defined(MAGICKCORE_LOCALE_SUPPORT)
273static void DestroyCLocale(
void)
275 if (c_locale != (locale_t) NULL)
276 freelocale(c_locale);
277 c_locale=(locale_t) NULL;
305static void *DestroyOptions(
void *message)
307 return(DestroyStringInfo((
StringInfo *) message));
313 if (IsEventLogging() != MagickFalse)
314 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
315 return(DestroyLinkedList(messages,DestroyOptions));
345MagickPrivate ssize_t FormatLocaleFileList(FILE *file,
346 const char *magick_restrict format,va_list operands)
351#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VFPRINTF_L)
356 locale=AcquireCLocale();
357 if (locale == (locale_t) NULL)
358 n=(ssize_t) vfprintf(file,format,operands);
360#if defined(MAGICKCORE_WINDOWS_SUPPORT)
361 n=(ssize_t) vfprintf_l(file,format,locale,operands);
363 n=(ssize_t) vfprintf_l(file,locale,format,operands);
367#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE)
373 locale=AcquireCLocale();
374 if (locale == (locale_t) NULL)
375 n=(ssize_t) vfprintf(file,format,operands);
378 previous_locale=uselocale(locale);
379 n=(ssize_t) vfprintf(file,format,operands);
380 uselocale(previous_locale);
384 n=(ssize_t) vfprintf(file,format,operands);
390MagickExport ssize_t FormatLocaleFile(FILE *file,
391 const char *magick_restrict format,...)
399 va_start(operands,format);
400 n=FormatLocaleFileList(file,format,operands);
436MagickPrivate ssize_t FormatLocaleStringList(
char *magick_restrict
string,
437 const size_t length,
const char *magick_restrict format,va_list operands)
442#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VSNPRINTF_L)
447 locale=AcquireCLocale();
448 if (locale == (locale_t) NULL)
449 n=(ssize_t) vsnprintf(
string,length,format,operands);
451#if defined(MAGICKCORE_WINDOWS_SUPPORT)
452 n=(ssize_t) vsnprintf_l(
string,length,format,locale,operands);
454 n=(ssize_t) vsnprintf_l(
string,length,locale,format,operands);
457#elif defined(MAGICKCORE_HAVE_VSNPRINTF)
458#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE)
464 locale=AcquireCLocale();
465 if (locale == (locale_t) NULL)
466 n=(ssize_t) vsnprintf(
string,length,format,operands);
469 previous_locale=uselocale(locale);
470 n=(ssize_t) vsnprintf(
string,length,format,operands);
471 uselocale(previous_locale);
475 n=(ssize_t) vsnprintf(
string,length,format,operands);
478 n=(ssize_t) vsprintf(
string,format,operands);
481 string[length-1]=
'\0';
485MagickExport ssize_t FormatLocaleString(
char *magick_restrict
string,
486 const size_t length,
const char *magick_restrict format,...)
494 va_start(operands,format);
495 n=FormatLocaleStringList(
string,length,format,operands);
526MagickExport
const LocaleInfo *GetLocaleInfo_(
const char *tag,
533 if (IsLocaleTreeInstantiated(exception) == MagickFalse)
535 LockSemaphoreInfo(locale_semaphore);
536 if ((tag == (
const char *) NULL) || (LocaleCompare(tag,
"*") == 0))
538 ResetSplayTreeIterator(locale_cache);
539 locale_info=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
540 UnlockSemaphoreInfo(locale_semaphore);
543 locale_info=(
const LocaleInfo *) GetValueFromSplayTree(locale_cache,tag);
544 UnlockSemaphoreInfo(locale_semaphore);
578#if defined(__cplusplus) || defined(c_plusplus)
582static int LocaleInfoCompare(
const void *x,
const void *y)
590 if (LocaleCompare((*p)->path,(*q)->path) == 0)
591 return(LocaleCompare((*p)->tag,(*q)->tag));
592 return(LocaleCompare((*p)->path,(*q)->path));
595#if defined(__cplusplus) || defined(c_plusplus)
599MagickExport
const LocaleInfo **GetLocaleInfoList(
const char *pattern,
614 assert(pattern != (
char *) NULL);
615 assert(number_messages != (
size_t *) NULL);
616 if (IsEventLogging() != MagickFalse)
617 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
619 p=GetLocaleInfo_(
"*",exception);
622 messages=(
const LocaleInfo **) AcquireQuantumMemory((
size_t)
623 GetNumberOfNodesInSplayTree(locale_cache)+1UL,
sizeof(*messages));
629 LockSemaphoreInfo(locale_semaphore);
630 ResetSplayTreeIterator(locale_cache);
631 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
634 if ((p->stealth == MagickFalse) &&
635 (GlobExpression(p->tag,pattern,MagickTrue) != MagickFalse))
637 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
639 UnlockSemaphoreInfo(locale_semaphore);
640 qsort((
void *) messages,(
size_t) i,
sizeof(*messages),LocaleInfoCompare);
642 *number_messages=(size_t) i;
676#if defined(__cplusplus) || defined(c_plusplus)
680static int LocaleTagCompare(
const void *x,
const void *y)
688 return(LocaleCompare(*p,*q));
691#if defined(__cplusplus) || defined(c_plusplus)
695MagickExport
char **GetLocaleList(
const char *pattern,
size_t *number_messages,
710 assert(pattern != (
char *) NULL);
711 assert(number_messages != (
size_t *) NULL);
712 if (IsEventLogging() != MagickFalse)
713 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
715 p=GetLocaleInfo_(
"*",exception);
717 return((
char **) NULL);
718 messages=(
char **) AcquireQuantumMemory((
size_t)
719 GetNumberOfNodesInSplayTree(locale_cache)+1UL,
sizeof(*messages));
720 if (messages == (
char **) NULL)
721 return((
char **) NULL);
722 LockSemaphoreInfo(locale_semaphore);
723 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
726 if ((p->stealth == MagickFalse) &&
727 (GlobExpression(p->tag,pattern,MagickTrue) != MagickFalse))
728 messages[i++]=ConstantString(p->tag);
729 p=(
const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
731 UnlockSemaphoreInfo(locale_semaphore);
732 qsort((
void *) messages,(
size_t) i,
sizeof(*messages),LocaleTagCompare);
733 messages[i]=(
char *) NULL;
734 *number_messages=(size_t) i;
761MagickExport
const char *GetLocaleMessage(
const char *tag)
764 name[MagickLocaleExtent];
772 if ((tag == (
const char *) NULL) || (*tag ==
'\0'))
774 exception=AcquireExceptionInfo();
775 (void) FormatLocaleString(name,MagickLocaleExtent,
"%s/",tag);
776 locale_info=GetLocaleInfo_(name,exception);
777 exception=DestroyExceptionInfo(exception);
779 return(locale_info->message);
809MagickExport
LinkedListInfo *GetLocaleOptions(
const char *filename,
813 path[MagickPathExtent];
825 assert(filename != (
const char *) NULL);
827 if (IsEventLogging() != MagickFalse)
828 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",filename);
829 (void) CopyMagickString(path,filename,MagickPathExtent);
833 messages=NewLinkedList(0);
834 paths=GetConfigurePaths(filename,exception);
837 ResetLinkedListIterator(paths);
838 element=(
const char *) GetNextValueInLinkedList(paths);
839 while (element != (
const char *) NULL)
841 (void) FormatLocaleString(path,MagickPathExtent,
"%s%s",element,
843 (void) LogMagickEvent(LocaleEvent,GetMagickModule(),
844 "Searching for locale file: \"%s\"",path);
845 xml=ConfigureFileToStringInfo(path);
847 (void) AppendValueToLinkedList(messages,xml);
848 element=(
const char *) GetNextValueInLinkedList(paths);
850 paths=DestroyLinkedList(paths,RelinquishMagickMemory);
852#if defined(MAGICKCORE_WINDOWS_SUPPORT)
857 blob=(
char *) NTResourceToBlob(filename);
858 if (blob != (
char *) NULL)
860 xml=AcquireStringInfo(0);
861 SetStringInfoLength(xml,strlen(blob)+1);
862 SetStringInfoDatum(xml,(
const unsigned char *) blob);
863 blob=(
char *) RelinquishMagickMemory(blob);
864 SetStringInfoPath(xml,filename);
865 (void) AppendValueToLinkedList(messages,xml);
869 ResetLinkedListIterator(messages);
895MagickExport
const char *GetLocaleValue(
const LocaleInfo *locale_info)
897 if (IsEventLogging() != MagickFalse)
898 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
900 assert(locale_info->signature == MagickCoreSignature);
901 return(locale_info->message);
927static MagickBooleanType IsLocaleTreeInstantiated(
ExceptionInfo *exception)
932 ActivateSemaphoreInfo(&locale_semaphore);
933 LockSemaphoreInfo(locale_semaphore);
942 locale=(
char *) NULL;
943 p=setlocale(LC_CTYPE,(
const char *) NULL);
944 if (p != (
const char *) NULL)
945 locale=ConstantString(p);
946 if (locale == (
char *) NULL)
947 locale=GetEnvironmentValue(
"LC_ALL");
948 if (locale == (
char *) NULL)
949 locale=GetEnvironmentValue(
"LC_MESSAGES");
950 if (locale == (
char *) NULL)
951 locale=GetEnvironmentValue(
"LC_CTYPE");
952 if (locale == (
char *) NULL)
953 locale=GetEnvironmentValue(
"LANG");
954 if (locale == (
char *) NULL)
955 locale=ConstantString(
"C");
956 locale_cache=AcquireLocaleSplayTree(LocaleFilename,locale,exception);
957 locale=DestroyString(locale);
959 UnlockSemaphoreInfo(locale_semaphore);
961 return(locale_cache != (
SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
993MagickExport
double InterpretLocaleValue(
const char *magick_restrict
string,
994 char *magick_restrict *sentinel)
1002 if ((*
string ==
'0') && ((
string[1] | 0x20)==
'x'))
1003 value=(double) strtoul(
string,&q,16);
1006#if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_STRTOD_L)
1010 locale=AcquireCLocale();
1011 if (locale == (locale_t) NULL)
1012 value=strtod(
string,&q);
1014 value=strtod_l(
string,&q,locale);
1016 value=strtod(
string,&q);
1019 if (sentinel != (
char **) NULL)
1048MagickExport MagickBooleanType ListLocaleInfo(FILE *file,
1063 if (file == (
const FILE *) NULL)
1066 locale_info=GetLocaleInfoList(
"*",&number_messages,exception);
1067 if (locale_info == (
const LocaleInfo **) NULL)
1068 return(MagickFalse);
1069 path=(
const char *) NULL;
1070 for (i=0; i < (ssize_t) number_messages; i++)
1072 if (locale_info[i]->stealth != MagickFalse)
1074 if ((path == (
const char *) NULL) ||
1075 (LocaleCompare(path,locale_info[i]->path) != 0))
1077 if (locale_info[i]->path != (
char *) NULL)
1078 (void) FormatLocaleFile(file,
"\nPath: %s\n\n",locale_info[i]->path);
1079 (void) FormatLocaleFile(file,
"Tag/Message\n");
1080 (void) FormatLocaleFile(file,
1081 "-------------------------------------------------"
1082 "------------------------------\n");
1084 path=locale_info[i]->path;
1085 (void) FormatLocaleFile(file,
"%s\n",locale_info[i]->tag);
1086 if (locale_info[i]->message != (
char *) NULL)
1087 (void) FormatLocaleFile(file,
" %s",locale_info[i]->message);
1088 (void) FormatLocaleFile(file,
"\n");
1090 (void) fflush(file);
1092 RelinquishMagickMemory((
void *) locale_info);
1127static void ChopLocaleComponents(
char *path,
const size_t components)
1137 p=path+strlen(path)-1;
1140 for (count=0; (count < (ssize_t) components) && (p > path); p--)
1146 if (count < (ssize_t) components)
1151static void LocaleFatalErrorHandler(
const ExceptionType severity,
1152 const char *reason,
const char *description) magick_attribute((__noreturn__));
1154static void LocaleFatalErrorHandler(
1155 const ExceptionType magick_unused(severity),
1156 const char *reason,
const char *description)
1158 magick_unreferenced(severity);
1160 (void) FormatLocaleFile(stderr,
"%s: ",GetClientName());
1161 if (reason != (
char *) NULL)
1162 (void) FormatLocaleFile(stderr,
" %s",reason);
1163 if (description != (
char *) NULL)
1164 (void) FormatLocaleFile(stderr,
" (%s)",description);
1165 (void) FormatLocaleFile(stderr,
".\n");
1166 (void) fflush(stderr);
1170static MagickBooleanType LoadLocaleCache(
SplayTreeInfo *cache,
const char *xml,
1171 const char *filename,
const char *locale,
const size_t depth,
ExceptionInfo *exception)
1174 keyword[MagickLocaleExtent],
1175 message[MagickLocaleExtent],
1176 tag[MagickLocaleExtent],
1200 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
1201 "Loading locale configure file \"%s\" ...",filename);
1202 if (xml == (
const char *) NULL)
1203 return(MagickFalse);
1209 fatal_handler=SetFatalErrorHandler(LocaleFatalErrorHandler);
1210 token=AcquireString(xml);
1211 extent=strlen(token)+MagickPathExtent;
1212 for (q=(
char *) xml; *q !=
'\0'; )
1217 (void) GetNextToken(q,&q,extent,token);
1220 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1221 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
1226 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
1228 (void) GetNextToken(q,&q,extent,token);
1229 while (isspace((
int) ((
unsigned char) *q)) != 0)
1234 if (LocaleNCompare(keyword,
"<!--",4) == 0)
1239 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
1241 (void) GetNextToken(q,&q,extent,token);
1242 while (isspace((
int) ((
unsigned char) *q)) != 0)
1247 if (LocaleCompare(keyword,
"<include") == 0)
1252 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
1254 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1255 (void) GetNextToken(q,&q,extent,token);
1258 (void) GetNextToken(q,&q,extent,token);
1259 if (LocaleCompare(keyword,
"locale") == 0)
1261 if (LocaleCompare(locale,token) != 0)
1265 if (LocaleCompare(keyword,
"file") == 0)
1267 if (depth > MagickMaxRecursionDepth)
1268 (void) ThrowMagickException(exception,GetMagickModule(),
1269 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
1273 path[MagickPathExtent],
1277 GetPathComponent(filename,HeadPath,path);
1279 (void) ConcatenateMagickString(path,DirectorySeparator,
1281 if (*token == *DirectorySeparator)
1282 (void) CopyMagickString(path,token,MagickPathExtent);
1284 (
void) ConcatenateMagickString(path,token,MagickPathExtent);
1285 file_xml=FileToXML(path,~0UL);
1286 if (file_xml != (
char *) NULL)
1288 status&=(MagickStatusType) LoadLocaleCache(cache,file_xml,
1289 path,locale,depth+1,exception);
1290 file_xml=DestroyString(file_xml);
1297 if (LocaleCompare(keyword,
"<locale") == 0)
1302 while ((*token !=
'>') && (*q !=
'\0'))
1304 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1305 (void) GetNextToken(q,&q,extent,token);
1308 (void) GetNextToken(q,&q,extent,token);
1312 if (LocaleCompare(keyword,
"</locale>") == 0)
1314 ChopLocaleComponents(tag,1);
1315 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1318 if (LocaleCompare(keyword,
"<localemap>") == 0)
1320 if (LocaleCompare(keyword,
"</localemap>") == 0)
1322 if (LocaleCompare(keyword,
"<message") == 0)
1327 while ((*token !=
'>') && (*q !=
'\0'))
1329 (void) CopyMagickString(keyword,token,MagickLocaleExtent);
1330 (void) GetNextToken(q,&q,extent,token);
1333 (void) GetNextToken(q,&q,extent,token);
1334 if (LocaleCompare(keyword,
"name") == 0)
1336 (void) ConcatenateMagickString(tag,token,MagickLocaleExtent);
1337 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1340 for (p=(
char *) q; (*q !=
'<') && (*q !=
'\0'); q++) ;
1341 while (isspace((
int) ((
unsigned char) *p)) != 0)
1344 while ((isspace((
int) ((
unsigned char) *q)) != 0) && (q > p))
1346 (void) CopyMagickString(message,p,MagickMin((
size_t) (q-p+2),
1347 MagickLocaleExtent));
1348 locale_info=(
LocaleInfo *) AcquireCriticalMemory(
sizeof(*locale_info));
1349 (void) memset(locale_info,0,
sizeof(*locale_info));
1350 locale_info->path=ConstantString(filename);
1351 locale_info->tag=ConstantString(tag);
1352 locale_info->message=ConstantString(message);
1353 locale_info->signature=MagickCoreSignature;
1354 status=AddValueToSplayTree(cache,locale_info->tag,locale_info);
1355 if (status == MagickFalse)
1356 (void) ThrowMagickException(exception,GetMagickModule(),
1357 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
1359 (void) ConcatenateMagickString(tag,message,MagickLocaleExtent);
1360 (void) ConcatenateMagickString(tag,
"\n",MagickLocaleExtent);
1364 if (LocaleCompare(keyword,
"</message>") == 0)
1366 ChopLocaleComponents(tag,2);
1367 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1370 if (*keyword ==
'<')
1375 if (*(keyword+1) ==
'?')
1377 if (*(keyword+1) ==
'/')
1379 ChopLocaleComponents(tag,1);
1381 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1384 token[strlen(token)-1]=
'\0';
1385 (void) CopyMagickString(token,token+1,MagickLocaleExtent);
1386 (void) ConcatenateMagickString(tag,token,MagickLocaleExtent);
1387 (void) ConcatenateMagickString(tag,
"/",MagickLocaleExtent);
1390 (void) GetNextToken(q,(
const char **) NULL,extent,token);
1394 token=(
char *) RelinquishMagickMemory(token);
1395 (void) SetFatalErrorHandler(fatal_handler);
1396 return(status != 0 ? MagickTrue : MagickFalse);
1429MagickExport
int LocaleCompare(
const char *p,
const char *q)
1431 if (p == (
char *) NULL)
1433 if (q == (
char *) NULL)
1437 if (q == (
char *) NULL)
1441 *r = (
const unsigned char *) p,
1442 *s = (
const unsigned char *) q;
1444 for ( ; (*r !=
'\0') && (*s !=
'\0') && ((*r == *s) ||
1445 (LocaleToLowercase((
int) *r) == LocaleToLowercase((
int) *s))); r++, s++);
1446 return(LocaleToLowercase((
int) *r)-LocaleToLowercase((
int) *s));
1473MagickExport
void LocaleLower(
char *
string)
1478 assert(
string != (
char *) NULL);
1479 for (q=
string; *q !=
'\0'; q++)
1480 *q=(
char) LocaleToLowercase((
int) *q);
1505MagickExport
int LocaleLowercase(
const int c)
1507 return(LocaleToLowercase(c));
1547MagickExport
int LocaleNCompare(
const char *p,
const char *q,
const size_t length)
1549 if (p == (
char *) NULL)
1551 if (q == (
char *) NULL)
1555 if (q == (
char *) NULL)
1561 *s = (
const unsigned char *) p,
1562 *t = (
const unsigned char *) q;
1567 for (n--; (*s !=
'\0') && (*t !=
'\0') && (n != 0) && ((*s == *t) ||
1568 (LocaleToLowercase((
int) *s) == LocaleToLowercase((
int) *t))); s++, t++, n--);
1569 return(LocaleToLowercase((
int) *s)-LocaleToLowercase((
int) *t));
1596MagickExport
void LocaleUpper(
char *
string)
1601 assert(
string != (
char *) NULL);
1602 for (q=
string; *q !=
'\0'; q++)
1603 *q=(
char) LocaleToUppercase((
int) *q);
1628MagickExport
int LocaleUppercase(
const int c)
1630 return(LocaleToUppercase(c));
1651MagickPrivate MagickBooleanType LocaleComponentGenesis(
void)
1654 locale_semaphore=AcquireSemaphoreInfo();
1655#if defined(MAGICKCORE_LOCALE_SUPPORT)
1656 (void) AcquireCLocale();
1679MagickPrivate
void LocaleComponentTerminus(
void)
1682 ActivateSemaphoreInfo(&locale_semaphore);
1683 LockSemaphoreInfo(locale_semaphore);
1685 locale_cache=DestroySplayTree(locale_cache);
1686#if defined(MAGICKCORE_LOCALE_SUPPORT)
1689 UnlockSemaphoreInfo(locale_semaphore);
1690 RelinquishSemaphoreInfo(&locale_semaphore);