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) 96 static volatile locale_t
97 c_locale = (locale_t) NULL;
108 #if defined(MAGICKCORE_LOCALE_SUPPORT) 128 static 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");
176 if (p->
path != (
char *) NULL)
178 if (p->
tag != (
char *) NULL)
180 if (p->
message != (
char *) NULL)
197 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT 236 #if defined(MAGICKCORE_LOCALE_SUPPORT) 256 static void DestroyCLocale(
void)
258 if (c_locale != (locale_t) NULL)
259 freelocale(c_locale);
260 c_locale=(locale_t) NULL;
333 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VFPRINTF_L) 338 locale=AcquireCLocale();
339 if (locale == (locale_t) NULL)
340 n=(ssize_t) vfprintf(file,format,operands);
342 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 343 n=(ssize_t) vfprintf_l(file,format,locale,operands);
345 n=(ssize_t) vfprintf_l(file,locale,format,operands);
349 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE) 355 locale=AcquireCLocale();
356 if (locale == (locale_t) NULL)
357 n=(ssize_t) vfprintf(file,format,operands);
360 previous_locale=uselocale(locale);
361 n=(ssize_t) vfprintf(file,format,operands);
362 uselocale(previous_locale);
366 n=(ssize_t) vfprintf(file,format,operands);
381 va_start(operands,format);
419 const size_t length,
const char *
magick_restrict format,va_list operands)
424 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VSNPRINTF_L) 429 locale=AcquireCLocale();
430 if (locale == (locale_t) NULL)
431 n=(ssize_t) vsnprintf(
string,length,format,operands);
433 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 434 n=(ssize_t) vsnprintf_l(
string,length,format,locale,operands);
436 n=(ssize_t) vsnprintf_l(
string,length,locale,format,operands);
439 #elif defined(MAGICKCORE_HAVE_VSNPRINTF) 440 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE) 446 locale=AcquireCLocale();
447 if (locale == (locale_t) NULL)
448 n=(ssize_t) vsnprintf(
string,length,format,operands);
451 previous_locale=uselocale(locale);
452 n=(ssize_t) vsnprintf(
string,length,format,operands);
453 uselocale(previous_locale);
457 n=(ssize_t) vsnprintf(
string,length,format,operands);
460 n=(ssize_t) vsprintf(
string,format,operands);
463 string[length-1]=
'\0';
476 va_start(operands,format);
518 if ((tag == (
const char *) NULL) || (
LocaleCompare(tag,
"*") == 0))
560 #if defined(__cplusplus) || defined(c_plusplus) 577 #if defined(__cplusplus) || defined(c_plusplus) 596 assert(pattern != (
char *) NULL);
598 assert(number_messages != (
size_t *) NULL);
623 *number_messages=(size_t) i;
657 #if defined(__cplusplus) || defined(c_plusplus) 672 #if defined(__cplusplus) || defined(c_plusplus) 691 assert(pattern != (
char *) NULL);
693 assert(number_messages != (
size_t *) NULL);
697 return((
char **) NULL);
700 if (messages == (
char **) NULL)
701 return((
char **) NULL);
713 messages[i]=(
char *) NULL;
714 *number_messages=(size_t) i;
752 if ((tag == (
const char *) NULL) || (*tag ==
'\0'))
805 assert(filename != (
const char *) NULL);
818 while (element != (
const char *) NULL)
823 "Searching for locale file: \"%s\"",path);
831 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 836 blob=(
char *) NTResourceToBlob(filename);
837 if (blob != (
char *) NULL)
920 locale=(
char *) NULL;
921 p=setlocale(LC_CTYPE,(
const char *) NULL);
922 if (p != (
const char *) NULL)
924 if (locale == (
char *) NULL)
926 if (locale == (
char *) NULL)
928 if (locale == (
char *) NULL)
930 if (locale == (
char *) NULL)
932 if (locale == (
char *) NULL)
980 if ((*
string ==
'0') && ((
string[1] | 0x20)==
'x'))
981 value=(double) strtoul(
string,&q,16);
984 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_STRTOD_L) 988 locale=AcquireCLocale();
989 if (locale == (locale_t) NULL)
990 value=strtod(
string,&q);
992 value=strtod_l(
string,&q,locale);
994 value=strtod(
string,&q);
997 if (sentinal != (
char **) NULL)
1041 if (file == (
const FILE *) NULL)
1045 if (locale_info == (
const LocaleInfo **) NULL)
1047 path=(
const char *) NULL;
1048 for (i=0; i < (ssize_t) number_messages; i++)
1052 if ((path == (
const char *) NULL) ||
1055 if (locale_info[i]->path != (
char *) NULL)
1059 "-------------------------------------------------" 1060 "------------------------------\n");
1062 path=locale_info[i]->
path;
1064 if (locale_info[i]->message != (
char *) NULL)
1068 (void) fflush(file);
1115 p=path+strlen(path)-1;
1118 for (count=0; (count < (ssize_t) components) && (p > path); p--)
1124 if (count < (ssize_t) components)
1130 const char *reason,
const char *description)
1134 if (reason == (
char *) NULL)
1137 if (description != (
char *) NULL)
1140 (void) fflush(stderr);
1145 const char *filename,
const char *locale,
const size_t depth,
ExceptionInfo *exception)
1175 "Loading locale configure file \"%s\" ...",filename);
1176 if (xml == (
const char *) NULL)
1186 for (q=(
char *) xml; *q !=
'\0'; )
1203 while (isspace((
int) ((
unsigned char) *q)) != 0)
1216 while (isspace((
int) ((
unsigned char) *q)) != 0)
1226 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
1260 if (file_xml != (
char *) NULL)
1276 while ((*token !=
'>') && (*q !=
'\0'))
1301 while ((*token !=
'>') && (*q !=
'\0'))
1314 for (p=(
char *) q; (*q !=
'<') && (*q !=
'\0'); q++) ;
1315 while (isspace((
int) ((
unsigned char) *p)) != 0)
1318 while ((isspace((
int) ((
unsigned char) *q)) != 0) && (q > p))
1323 (void) memset(locale_info,0,
sizeof(*locale_info));
1344 if (*keyword ==
'<')
1349 if (*(keyword+1) ==
'?')
1351 if (*(keyword+1) ==
'/')
1358 token[strlen(token)-1]=
'\0';
1364 (void)
GetNextToken(q,(
const char **) NULL,extent,token);
1405 if (p == (
char *) NULL)
1407 if (q == (
char *) NULL)
1411 if (q == (
char *) NULL)
1415 *r = (
const unsigned char *) p,
1416 *s = (
const unsigned char *) q;
1418 for ( ; (*r !=
'\0') && (*s !=
'\0') && ((*r == *s) ||
1452 assert(
string != (
char *) NULL);
1453 for (q=
string; *q !=
'\0'; q++)
1481 if ((c == EOF) || (c != (
unsigned char) c))
1483 #if defined(MAGICKCORE_LOCALE_SUPPORT) 1484 if (c_locale != (locale_t) NULL)
1485 return(tolower_l((
int) ((
unsigned char) c),c_locale));
1487 return(tolower((
int) ((
unsigned char) c)));
1529 if (p == (
char *) NULL)
1531 if (q == (
char *) NULL)
1535 if (q == (
char *) NULL)
1541 *s = (
const unsigned char *) p,
1542 *t = (
const unsigned char *) q;
1547 for (n--; (*s !=
'\0') && (*t !=
'\0') && (n != 0) && ((*s == *t) ||
1581 assert(
string != (
char *) NULL);
1582 for (q=
string; *q !=
'\0'; q++)
1612 #if defined(MAGICKCORE_LOCALE_SUPPORT) 1613 if (c_locale != (locale_t) NULL)
1614 return(toupper_l((
int) ((
unsigned char) c),c_locale));
1616 return(toupper((
int) ((
unsigned char) c)));
1641 #if defined(MAGICKCORE_LOCALE_SUPPORT) 1642 (void) AcquireCLocale();
1672 #if defined(MAGICKCORE_LOCALE_SUPPORT)
static void * DestroyLocaleNode(void *locale_info)
#define MagickMaxRecursionDepth
MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, const void *key, const void *value)
static void ChopLocaleComponents(char *path, const size_t components)
MagickExport size_t ConcatenateMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
MagickPrivate ssize_t FormatLocaleStringList(char *magick_restrict string, const size_t length, const char *magick_restrict format, va_list operands)
MagickExport void SetStringInfoPath(StringInfo *string_info, const char *path)
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
MagickExport void ResetLinkedListIterator(LinkedListInfo *list_info)
MagickPrivate void LocaleComponentTerminus(void)
MagickExport int LocaleLowercase(const int c)
MagickExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
static const char * LocaleMap
static void * DestroyOptions(void *message)
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
static SplayTreeInfo * AcquireLocaleSplayTree(const char *filename, const char *locale, ExceptionInfo *exception)
MagickExport MagickBooleanType AppendValueToLinkedList(LinkedListInfo *list_info, const void *value)
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
MagickExport LinkedListInfo * GetLocaleOptions(const char *filename, ExceptionInfo *exception)
static int LocaleTagCompare(const void *x, const void *y)
MagickExport size_t CopyMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
MagickExport void * GetNextValueInLinkedList(LinkedListInfo *list_info)
MagickExport const void * GetNextValueInSplayTree(SplayTreeInfo *splay_tree)
#define MagickCoreSignature
void(* FatalErrorHandler)(const ExceptionType, const char *, const char *)
MagickExport int LocaleUppercase(const int c)
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
MagickPrivate ssize_t FormatLocaleFileList(FILE *file, const char *magick_restrict format, va_list operands)
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
#define DirectorySeparator
unsigned int MagickStatusType
MagickExport char * AcquireString(const char *source)
MagickExport void LocaleLower(char *string)
MagickExport MagickBooleanType GlobExpression(const char *magick_restrict expression, const char *magick_restrict pattern, const MagickBooleanType case_insensitive)
MagickExport void * AcquireCriticalMemory(const size_t size)
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
MagickExport magick_hot_spot size_t GetNextToken(const char *magick_restrict start, const char **magick_restrict end, const size_t extent, char *magick_restrict token)
static MagickBooleanType LoadLocaleCache(SplayTreeInfo *, const char *, const char *, const char *, const size_t, ExceptionInfo *)
MagickExport SplayTreeInfo * DestroySplayTree(SplayTreeInfo *splay_tree)
MagickExport SplayTreeInfo * NewSplayTree(int(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
MagickExport MagickBooleanType ListLocaleInfo(FILE *file, ExceptionInfo *exception)
MagickExport char ** GetLocaleList(const char *pattern, size_t *number_messages, ExceptionInfo *exception)
#define MagickLocaleExtent
MagickExport FatalErrorHandler SetFatalErrorHandler(FatalErrorHandler handler)
static SemaphoreInfo * locale_semaphore
static int LocaleInfoCompare(const void *x, const void *y)
MagickExport char * GetEnvironmentValue(const char *name)
MagickExport StringInfo * ConfigureFileToStringInfo(const char *filename)
MagickExport LinkedListInfo * NewLinkedList(const size_t capacity)
static void LocaleFatalErrorHandler(const ExceptionType magick_unused(severity), const char *reason, const char *description)
static SplayTreeInfo * locale_cache
MagickExport const void * GetValueFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
MagickExport const char * GetClientName(void)
MagickExport StringInfo * AcquireStringInfo(const size_t length)
MagickExport int LocaleCompare(const char *p, const char *q)
MagickExport LinkedListInfo * DestroyLocaleOptions(LinkedListInfo *messages)
#define GetMagickModule()
MagickExport int CompareSplayTreeString(const void *target, const void *source)
MagickExport const char * GetStringInfoPath(const StringInfo *string_info)
MagickExport const char * GetLocaleMessage(const char *tag)
MagickPrivate MagickBooleanType LocaleComponentGenesis(void)
MagickExport void SetStringInfoLength(StringInfo *string_info, const size_t length)
MagickExport char * DestroyString(char *string)
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
MagickExport const LocaleInfo * GetLocaleInfo_(const char *tag, ExceptionInfo *exception)
MagickExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree)
MagickExport void * RelinquishMagickMemory(void *memory)
#define magick_unreferenced(x)
MagickExport size_t GetNumberOfNodesInSplayTree(const SplayTreeInfo *splay_tree)
static MagickBooleanType IsLocaleTreeInstantiated(ExceptionInfo *)
MagickExport const char * GetLocaleValue(const LocaleInfo *locale_info)
MagickPrivate char * FileToXML(const char *, const size_t)
MagickBooleanType stealth
MagickExport const LocaleInfo ** GetLocaleInfoList(const char *pattern, size_t *number_messages, ExceptionInfo *exception)
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
MagickExport void LocaleUpper(char *string)
MagickExport char * ConstantString(const char *source)
MagickExport void SetStringInfoDatum(StringInfo *string_info, const unsigned char *source)
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
MagickExport double InterpretLocaleValue(const char *magick_restrict string, char **magick_restrict sentinal)