From: cristy Date: Tue, 14 Apr 2015 23:54:43 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~1103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4618c0bfed02b00a0b112dfc619da885355e189;p=imagemagick --- diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 805a0186e..29dd17dca 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -3232,7 +3232,7 @@ static MagickBooleanType SetPixelCacheExtent(Image *image,MagickSizeType length) format[MaxTextExtent], message[MaxTextExtent]; - (void) FormatMagickSize(length,MagickFalse,"B",format); + (void) FormatMagickSize(length,MagickFalse,"B",MaxTextExtent,format); (void) FormatLocaleString(message,MaxTextExtent, "extend %s (%s[%d], disk, %s)",cache_info->filename, cache_info->cache_filename,cache_info->file,format); @@ -3364,7 +3364,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, if (image->debug != MagickFalse) { (void) FormatMagickSize(cache_info->length,MagickTrue,"B", - format); + MaxTextExtent,format); type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t) cache_info->type); (void) FormatLocaleString(message,MaxTextExtent, @@ -3424,7 +3424,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, if (image->debug != MagickFalse) { (void) FormatMagickSize(cache_info->length,MagickFalse,"B", - format); + MaxTextExtent,format); type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t) cache_info->type); (void) FormatLocaleString(message,MaxTextExtent, @@ -3507,7 +3507,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, if (image->debug != MagickFalse) { (void) FormatMagickSize(cache_info->length,MagickTrue,"B", - format); + MaxTextExtent,format); type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t) cache_info->type); (void) FormatLocaleString(message,MaxTextExtent, @@ -3532,7 +3532,8 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode, } if (image->debug != MagickFalse) { - (void) FormatMagickSize(cache_info->length,MagickFalse,"B",format); + (void) FormatMagickSize(cache_info->length,MagickFalse,"B",MaxTextExtent, + format); type=CommandOptionToMnemonic(MagickCacheOptions,(ssize_t) cache_info->type); (void) FormatLocaleString(message,MaxTextExtent, diff --git a/MagickCore/identify.c b/MagickCore/identify.c index 8b1142084..4cb815cc4 100644 --- a/MagickCore/identify.c +++ b/MagickCore/identify.c @@ -600,7 +600,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file, if (image->total_colors != 0) { (void) FormatMagickSize(image->total_colors,MagickFalse,"B", - format); + MaxTextExtent,format); (void) FormatLocaleFile(file,"%s ",format); } } @@ -619,7 +619,7 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file, if (GetBlobSize(image) != 0) { (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B", - format); + MaxTextExtent,format); (void) FormatLocaleFile(file,"%s ",format); } (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time, @@ -1383,15 +1383,16 @@ MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file, } (void) FormatLocaleFile(file," Tainted: %s\n",CommandOptionToMnemonic( MagickBooleanOptions,(ssize_t) image->taint)); - (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",format); + (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",MaxTextExtent, + format); (void) FormatLocaleFile(file," Filesize: %s\n",format); (void) FormatMagickSize((MagickSizeType) image->columns*image->rows, - MagickFalse,"B",format); + MagickFalse,"B",MaxTextExtent,format); if (strlen(format) > 1) format[strlen(format)-1]='\0'; (void) FormatLocaleFile(file," Number pixels: %s\n",format); (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/ - elapsed_time+0.5),MagickFalse,"B",format); + elapsed_time+0.5),MagickFalse,"B",MaxTextExtent,format); (void) FormatLocaleFile(file," Pixels per second: %s\n",format); (void) FormatLocaleFile(file," User time: %0.3fu\n",user_time); (void) FormatLocaleFile(file," Elapsed time: %lu:%02lu.%03lu\n", diff --git a/MagickCore/property.c b/MagickCore/property.c index eb8ebc14b..728b13a4e 100644 --- a/MagickCore/property.c +++ b/MagickCore/property.c @@ -2289,7 +2289,8 @@ static const char *GetMagickPropertyLetter(ImageInfo *image_info, case 'b': /* image size read in - in bytes */ { WarnNoImageReturn("\"%%%c\"",letter); - (void) FormatMagickSize(image->extent,MagickFalse,"B",value); + (void) FormatMagickSize(image->extent,MagickFalse,"B",MaxTextExtent, + value); break; } case 'c': /* image comment property - empty string by default */ @@ -2967,7 +2968,8 @@ MagickExport const char *GetMagickProperty(ImageInfo *image_info, if (LocaleCompare("size",property) == 0) { WarnNoImageReturn("\"%%[%s]\"",property); - (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",value); + (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B", + MaxTextExtent,value); break; } if (LocaleCompare("skewness",property) == 0) diff --git a/MagickCore/resize.c b/MagickCore/resize.c index b0a9c6677..00ccc13ba 100644 --- a/MagickCore/resize.c +++ b/MagickCore/resize.c @@ -3704,7 +3704,8 @@ MagickExport Image *ThumbnailImage(const Image *image,const size_t columns, } (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double) attributes.st_mtime); - (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",value); + (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",MaxTextExtent, + value); (void) SetImageProperty(thumbnail_image,"Thumb::Size",value,exception); (void) FormatLocaleString(value,MaxTextExtent,"image/%s",image->magick); LocaleLower(value); diff --git a/MagickCore/resource.c b/MagickCore/resource.c index 16c197991..d4eea9f8b 100644 --- a/MagickCore/resource.c +++ b/MagickCore/resource.c @@ -175,7 +175,7 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, limit; status=MagickFalse; - (void) FormatMagickSize(size,MagickFalse,"B",resource_request); + (void) FormatMagickSize(size,MagickFalse,"B",MaxTextExtent,resource_request); if (resource_semaphore == (SemaphoreInfo *) NULL) ActivateSemaphoreInfo(&resource_semaphore); LockSemaphoreInfo(resource_semaphore); @@ -188,9 +188,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, status=(resource_info.area_limit == MagickResourceInfinity) || (size < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.area,MagickFalse, - "B",resource_current); - (void) FormatMagickSize(resource_info.area_limit,MagickFalse, - "B",resource_limit); + "B",MaxTextExtent,resource_current); + (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B", + MaxTextExtent,resource_limit); break; } case MemoryResource: @@ -201,9 +201,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, ((MagickSizeType) resource_info.memory < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.memory,MagickTrue, - "B",resource_current); - (void) FormatMagickSize(resource_info.memory_limit,MagickTrue, - "B",resource_limit); + "B",MaxTextExtent,resource_current); + (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,"B", + MaxTextExtent,resource_limit); break; } case MapResource: @@ -213,9 +213,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, status=(resource_info.map_limit == MagickResourceInfinity) || ((MagickSizeType) resource_info.map < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.map,MagickTrue, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.map_limit,MagickTrue, - "B",resource_limit); + "B",MaxTextExtent,resource_limit); break; } case DiskResource: @@ -226,9 +226,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, ((MagickSizeType) resource_info.disk < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.disk,MagickTrue, - "B",resource_current); - (void) FormatMagickSize(resource_info.disk_limit,MagickTrue, - "B",resource_limit); + "B",MaxTextExtent,resource_current); + (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,"B", + MaxTextExtent,resource_limit); break; } case FileResource: @@ -239,9 +239,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, ((MagickSizeType) resource_info.file < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.file,MagickFalse, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.file_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } case HeightResource: @@ -251,9 +251,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, status=(resource_info.area_limit == MagickResourceInfinity) || (size < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.height,MagickFalse, - "P",resource_current); + "P",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.height_limit,MagickFalse, - "P",resource_limit); + "P",MaxTextExtent,resource_limit); break; } case ThreadResource: @@ -263,9 +263,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, ((MagickSizeType) resource_info.thread < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.thread,MagickFalse, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.thread_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } case ThrottleResource: @@ -275,9 +275,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, ((MagickSizeType) resource_info.throttle < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.throttle, - MagickFalse,"B",resource_current); + MagickFalse,"B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.throttle_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } case TimeResource: @@ -288,9 +288,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, ((MagickSizeType) resource_info.time < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.time,MagickFalse, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.time_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } case WidthResource: @@ -300,9 +300,9 @@ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, status=(resource_info.area_limit == MagickResourceInfinity) || (size < limit) ? MagickTrue : MagickFalse; (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse, - "P",resource_current); - (void) FormatMagickSize(resource_info.width_limit,MagickFalse, - "P",resource_limit); + "P",MaxTextExtent,resource_current); + (void) FormatMagickSize(resource_info.width_limit,MagickFalse,"P", + MaxTextExtent,resource_limit); break; } default: @@ -783,16 +783,19 @@ MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file, ActivateSemaphoreInfo(&resource_semaphore); LockSemaphoreInfo(resource_semaphore); (void) FormatMagickSize(resource_info.width_limit,MagickFalse,"P", - width_limit); + MaxTextExtent,width_limit); (void) FormatMagickSize(resource_info.height_limit,MagickFalse,"P", - height_limit); - (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B",area_limit); + MaxTextExtent,height_limit); + (void) FormatMagickSize(resource_info.area_limit,MagickFalse,"B", + MaxTextExtent,area_limit); (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,"B", - memory_limit); - (void) FormatMagickSize(resource_info.map_limit,MagickTrue,"B",map_limit); + MaxTextExtent,memory_limit); + (void) FormatMagickSize(resource_info.map_limit,MagickTrue,"B", + MaxTextExtent,map_limit); (void) CopyMagickString(disk_limit,"unlimited",MaxTextExtent); if (resource_info.disk_limit != MagickResourceInfinity) - (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,"B",disk_limit); + (void) FormatMagickSize(resource_info.disk_limit,MagickTrue,"B", + MaxTextExtent,disk_limit); (void) CopyMagickString(time_limit,"unlimited",MaxTextExtent); if (resource_info.time_limit != MagickResourceInfinity) (void) FormatLocaleString(time_limit,MaxTextExtent,"%.20g",(double) @@ -849,7 +852,7 @@ MagickExport void RelinquishMagickResource(const ResourceType type, resource_limit[MaxTextExtent], resource_request[MaxTextExtent]; - (void) FormatMagickSize(size,MagickFalse,"B",resource_request); + (void) FormatMagickSize(size,MagickFalse,"B",MaxTextExtent,resource_request); if (resource_semaphore == (SemaphoreInfo *) NULL) ActivateSemaphoreInfo(&resource_semaphore); LockSemaphoreInfo(resource_semaphore); @@ -859,88 +862,88 @@ MagickExport void RelinquishMagickResource(const ResourceType type, { resource_info.width=(MagickOffsetType) size; (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse, - "P",resource_current); + "P",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.width_limit,MagickFalse, - "P",resource_limit); + "P",MaxTextExtent,resource_limit); break; } case HeightResource: { resource_info.width=(MagickOffsetType) size; (void) FormatMagickSize((MagickSizeType) resource_info.width,MagickFalse, - "P",resource_current); + "P",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.width_limit,MagickFalse, - "P",resource_limit); + "P",MaxTextExtent,resource_limit); break; } case AreaResource: { resource_info.area=(MagickOffsetType) size; (void) FormatMagickSize((MagickSizeType) resource_info.area,MagickFalse, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.area_limit,MagickFalse, - "B",resource_limit); + "B",MaxTextExtent,resource_limit); break; } case MemoryResource: { resource_info.memory-=size; (void) FormatMagickSize((MagickSizeType) resource_info.memory, - MagickTrue,"B",resource_current); + MagickTrue,"B",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.memory_limit,MagickTrue, - "B",resource_limit); + "B",MaxTextExtent,resource_limit); break; } case MapResource: { resource_info.map-=size; (void) FormatMagickSize((MagickSizeType) resource_info.map,MagickTrue, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.map_limit,MagickTrue, - "B",resource_limit); + "B",MaxTextExtent,resource_limit); break; } case DiskResource: { resource_info.disk-=size; (void) FormatMagickSize((MagickSizeType) resource_info.disk,MagickTrue, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize(resource_info.disk_limit,MagickTrue, - "B",resource_limit); + "B",MaxTextExtent,resource_limit); break; } case FileResource: { resource_info.file-=size; (void) FormatMagickSize((MagickSizeType) resource_info.file,MagickFalse, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.file_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } case ThreadResource: { (void) FormatMagickSize((MagickSizeType) resource_info.thread,MagickFalse, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.thread_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } case ThrottleResource: { (void) FormatMagickSize((MagickSizeType) resource_info.throttle, - MagickFalse,"B",resource_current); + MagickFalse,"B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.throttle_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } case TimeResource: { resource_info.time-=size; (void) FormatMagickSize((MagickSizeType) resource_info.time,MagickFalse, - "B",resource_current); + "B",MaxTextExtent,resource_current); (void) FormatMagickSize((MagickSizeType) resource_info.time_limit, - MagickFalse,"B",resource_limit); + MagickFalse,"B",MaxTextExtent,resource_limit); break; } default: diff --git a/MagickCore/string.c b/MagickCore/string.c index 070555206..349c6bbd8 100644 --- a/MagickCore/string.c +++ b/MagickCore/string.c @@ -1059,7 +1059,7 @@ MagickExport StringInfo *FileToStringInfo(const char *filename, % The format of the FormatMagickSize method is: % % ssize_t FormatMagickSize(const MagickSizeType size,const char *suffix, -^ char *format) +% const size_t length,char *format) % % A description of each parameter follows: % @@ -1069,18 +1069,21 @@ MagickExport StringInfo *FileToStringInfo(const char *filename, % % o suffix: append suffix, typically B or P. % +% o length: the maximum length of the string. +% % o format: human readable format. % */ MagickExport ssize_t FormatMagickSize(const MagickSizeType size, - const MagickBooleanType bi,const char *suffix,char *format) + const MagickBooleanType bi,const char *suffix,const size_t length, + char *format) { const char **units; double bytes, - length; + extent; register ssize_t i, @@ -1107,21 +1110,21 @@ MagickExport ssize_t FormatMagickSize(const MagickSizeType size, units=bi_units; } #if defined(_MSC_VER) && (_MSC_VER == 1200) - length=(double) ((MagickOffsetType) size); + extent=(double) ((MagickOffsetType) size); #else - length=(double) size; + extent=(double) size; #endif - for (i=0; (length >= bytes) && (units[i+1] != (const char *) NULL); i++) - length/=bytes; + for (i=0; (extent >= bytes) && (units[i+1] != (const char *) NULL); i++) + extent/=bytes; count=0; for (j=2; j < 12; j++) { if (suffix == (const char *) NULL) - count=FormatLocaleString(format,MaxTextExtent,"%.*g%s",(int) (i+j), - length,units[i]); + count=FormatLocaleString(format,length,"%.*g%s",(int) (i+j),extent, + units[i]); else - count=FormatLocaleString(format,MaxTextExtent,"%.*g%s%s",(int) (i+j), - length,units[i],suffix); + count=FormatLocaleString(format,length,"%.*g%s%s",(int) (i+j),extent, + units[i],suffix); if (strchr(format,'+') == (char *) NULL) break; } @@ -1149,12 +1152,12 @@ MagickExport ssize_t FormatMagickSize(const MagickSizeType size, % % A description of each parameter follows. % -% o time: the time since the Epoch (00:00:00 UTC, January 1, 1970), -% measured in seconds. +% o time: the time since the Epoch (00:00:00 UTC, January 1, 1970), +% measured in seconds. % -% o length: the maximum length of the string. +% o length: the maximum length of the string. % -% o timestamp: Return the Internet date/time here. +% o timestamp: Return the Internet date/time here. % */ MagickExport ssize_t FormatMagickTime(const time_t time,const size_t length, diff --git a/MagickCore/string_.h b/MagickCore/string_.h index efb8eef16..921718797 100644 --- a/MagickCore/string_.h +++ b/MagickCore/string_.h @@ -79,7 +79,7 @@ extern MagickExport size_t extern MagickExport ssize_t FormatMagickSize(const MagickSizeType,const MagickBooleanType,const char *, - char *), + const size_t,char *), FormatMagickTime(const time_t,const size_t,char *); extern MagickExport StringInfo diff --git a/coders/json.c b/coders/json.c index 0b8db165a..ce1bb5ed0 100644 --- a/coders/json.c +++ b/coders/json.c @@ -1336,15 +1336,16 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file, } (void) FormatLocaleFile(file," Tainted: %s\n",CommandOptionToMnemonic( MagickBooleanOptions,(ssize_t) image->taint)); - (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",format); + (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",MaxTextExtent, + format); (void) FormatLocaleFile(file," Filesize: %s\n",format); (void) FormatMagickSize((MagickSizeType) image->columns*image->rows, - MagickFalse,"B",format); + MagickFalse,"B",MaxTextExtent,format); if (strlen(format) > 1) format[strlen(format)-1]='\0'; (void) FormatLocaleFile(file," Number pixels: %s\n",format); (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/ - elapsed_time+0.5),MagickFalse,"B",format); + elapsed_time+0.5),MagickFalse,"B",MaxTextExtent,format); (void) FormatLocaleFile(file," Pixels per second: %s\n",format); (void) FormatLocaleFile(file," User time: %0.3fu\n",user_time); (void) FormatLocaleFile(file," Elapsed time: %lu:%02lu.%03lu\n",