% MagickCore String Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% August 2003 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the license. You may %
*/
#if !defined(MAGICKCORE_HAVE_STRCASECMP) || !defined(MAGICKCORE_HAVE_STRNCASECMP)
static const unsigned char
- asciimap[] =
+ AsciiMap[] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
size_t
length;
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(destination != (char **) NULL);
if (source == (const char *) NULL)
{
StringInfo
*clone_info;
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
clone_info=AcquireStringInfo(string_info->length);
int
status;
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(target != (StringInfo *) NULL);
assert(target->signature == MagickSignature);
assert(source != (StringInfo *) NULL);
size_t
length;
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
assert(source != (const StringInfo *) NULL);
*/
MagickExport StringInfo *DestroyStringInfo(StringInfo *string_info)
{
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
if (string_info->datum != (unsigned char *) NULL)
size_t
length;
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(source != (const char *) NULL);
length=strlen(source);
for (p=source; *p != '\0'; p++)
#endif
for (i=0; (length >= bytes) && (units[i+1] != (const char *) NULL); i++)
length/=bytes;
+ count=0;
for (j=2; j < 12; j++)
{
count=FormatLocaleString(format,MaxTextExtent,"%.*g%sB",(int) (i+j),length,
j;
assert(id != (const char *) NULL);
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",id);
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
p=(char *) string_info->datum;
break;
p++;
}
+ (void) FormatLocaleFile(file,"%s(%.20g): ",id,(double) string_info->length);
if (i == string_info->length)
{
- (void) fputs((char *) string_info->datum,file);
+ for (i=0; i < string_info->length; i++)
+ (void) fputc(string_info->datum[i],file);
(void) fputc('\n',file);
return;
}
*/
MagickExport void ResetStringInfo(StringInfo *string_info)
{
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
(void) ResetMagickMemory(string_info->datum,0,string_info->length);
MagickExport void SetStringInfo(StringInfo *string_info,
const StringInfo *source)
{
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
assert(source != (StringInfo *) NULL);
MagickExport void SetStringInfoDatum(StringInfo *string_info,
const unsigned char *source)
{
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
if (string_info->length != 0)
MagickExport void SetStringInfoLength(StringInfo *string_info,
const size_t length)
{
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
if (~length < MaxTextExtent)
*/
MagickExport void SetStringInfoPath(StringInfo *string_info,const char *path)
{
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
assert(path != (const char *) NULL);
StringInfo
*split_info;
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string_info != (StringInfo *) NULL);
assert(string_info->signature == MagickSignature);
if (offset > string_info->length)
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% StringToArrayOfDoubles() converts a string of space or comma seperated
+% StringToArrayOfDoubles() converts a string of space or comma separated
% numbers into array of floating point numbers (doubles). Any number that
% failes to parse properly will produce a syntax error. As will two commas
% without a number between them. However a final comma at the end will
%
% The format of the StringToArrayOfDoubles method is:
%
-% double *StringToArrayOfDoubles(const char *string,
-% size_t *count, ExceptionInfo *exception)
+% double *StringToArrayOfDoubles(const char *string,size_t *count)
%
% A description of each parameter follows:
%
-% o string: the string containing the comma/space seperated values.
+% o string: the string containing the comma/space separated values.
%
% o count: returns number of arguments in returned array
%
-% o exception: return 'memory failure' exceptions
+% o exception: return any errors or warnings in this structure.
%
*/
-MagickExport double *StringToArrayOfDoubles(const char *string,
- ssize_t *count, ExceptionInfo *exception)
+MagickExport double *StringToArrayOfDoubles(const char *string,ssize_t *count,
+ ExceptionInfo *exception)
{
- const char
- *p;
-
char
*q;
+ const char
+ *p;
+
double
*array;
register ssize_t
i;
- /* Determine count of values, and check syntax */
+ /*
+ Determine count of values, and check syntax.
+ */
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
*count=0;
- p=string;
i=0;
- while( *p != '\0' )
+ p=string;
+ while (*p != '\0')
{
- (void) StringToDouble(p, &q); /* get value - ignores leading space */
- if (p == q) return((double *)NULL); /* no value found */
- p=q; i++; /* inc value count */
- while ( isspace((int)*p) ) p++; /* skip spaces */
- if ( *p == ',' ) p++; /* skip comma */
- while ( isspace((int)*p) ) p++; /* and more spaces */
+ (void) StringToDouble(p,&q); /* get value - ignores leading space */
+ if (p == q)
+ return((double *) NULL); /* no value found */
+ p=q;
+ i++; /* increment value count */
+ while (isspace((int) ((unsigned char) *p)) != 0)
+ p++; /* skip spaces */
+ if (*p == ',')
+ p++; /* skip comma */
+ while (isspace((int) ((unsigned char) *p)) != 0)
+ p++; /* and more spaces */
}
-
- /* Allocate floating point argument list */
+ /*
+ Allocate floating point argument list.
+ */
*count=i;
- array=(double *) AcquireQuantumMemory(i,sizeof(*array));
- if (array == (double *) NULL) {
- ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
- (void) ThrowMagickException(exception,GetMagickModule(),
- ResourceLimitFatalError,"MemoryAllocationFailed"," ");
- return((double *)NULL);
- }
-
- /* Fill in the floating point values */
- p=string;
+ array=(double *) AcquireQuantumMemory((size_t) i,sizeof(*array));
+ if (array == (double *) NULL)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ ResourceLimitError,"MemoryAllocationFailed","`%s'","");
+ return((double *) NULL);
+ }
+ /*
+ Fill in the floating point values.
+ */
i=0;
- while( *p != '\0' && i < *count ) {
+ p=string;
+ while ((*p != '\0') && (i < *count))
+ {
array[i++]=StringToDouble(p,&q);
p=q;
- while ( isspace((int)*p) || *p == ',' ) p++;
+ while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
+ p++;
}
-
return(array);
}
\f
StringInfo
*string_info;
- (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(string != (const char *) NULL);
string_info=AcquireStringInfo(strlen(string));
SetStringInfoDatum(string_info,(const unsigned char *) string);