From: dirk Date: Wed, 23 Apr 2014 16:03:29 +0000 (+0000) Subject: Corrected newlines. X-Git-Tag: 7.0.1-0~2422 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9dbde130208643c1c27df9cf273a9d87870efe7;p=imagemagick Corrected newlines. --- diff --git a/MagickCore/profile.c b/MagickCore/profile.c index a7b8408f3..8dd0c9acc 100644 --- a/MagickCore/profile.c +++ b/MagickCore/profile.c @@ -99,16 +99,16 @@ source_type,target_profile,target_type,intent,flags); #define cmsOpenProfileFromMemTHR(context,profile,length) \ cmsOpenProfileFromMem(profile,length) -#endif - -/* - Forward declarations -*/ -static MagickBooleanType - SetImageProfileInternal(Image *,const char *,const StringInfo *, - const MagickBooleanType,ExceptionInfo *); - -static void +#endif + +/* + Forward declarations +*/ +static MagickBooleanType + SetImageProfileInternal(Image *,const char *,const StringInfo *, + const MagickBooleanType,ExceptionInfo *); + +static void WriteTo8BimProfile(Image *,const char*,const StringInfo *); /* @@ -1146,120 +1146,120 @@ static inline const unsigned char *ReadResourceShort(const unsigned char *p, *quantum=(unsigned short) (*p++ << 8); *quantum|=(unsigned short) (*p++ << 0); return(p); -}static inline void WriteResourceLong(unsigned char *p, - const unsigned int quantum) -{ - unsigned char - buffer[4]; - - buffer[0]=(unsigned char) (quantum >> 24); - buffer[1]=(unsigned char) (quantum >> 16); - buffer[2]=(unsigned char) (quantum >> 8); - buffer[3]=(unsigned char) quantum; - (void) CopyMagickMemory(p,buffer,4); -} - -static void WriteTo8BimProfile(Image *image,const char *name, - const StringInfo *iptc_profile) -{ - - const unsigned char - *datum, - *s; - - register const unsigned char - *p; - - size_t - length; - - StringInfo - *profile; - - ssize_t - count; - - unsigned char - length_byte; - - unsigned int - value; - - unsigned short - id; - - if (LocaleCompare(name,"iptc") != 0) - return; - profile=(StringInfo *)GetValueFromSplayTree((SplayTreeInfo *)image->profiles, - "8bim"); - if (profile == (StringInfo *) NULL) - return; - datum=GetStringInfoDatum(profile); - length=GetStringInfoLength(profile); - for (p=datum; p < (datum+length-16); ) - { - s=p; - if (LocaleNCompare((char *) p,"8BIM",4) != 0) - break; - p+=4; - p=ReadResourceShort(p,&id); - p=ReadResourceByte(p,&length_byte); - p+=length_byte; - if (((length_byte+1) & 0x01) != 0) - p++; - if (p > (datum+length-4)) - break; - p=ReadResourceLong(p,&value); - count=(ssize_t) value; - if ((p > (datum+length-count)) || (count > length)) - break; - if ((count & 0x01) != 0) - count++; - if (id == 0x0404) - { - size_t - offset, - rest; - - ssize_t - new_count; - - StringInfo - *new_profile; - - new_count=0; - rest=(datum+length)-(p+count); - if (iptc_profile == (StringInfo *) NULL) - { - offset=(s-datum); - new_profile=AcquireStringInfo(offset+rest); - (void) CopyMagickMemory(new_profile->datum,datum,offset); - } - else - { - offset=(p-datum); - new_count=iptc_profile->length; - if ((new_count & 0x01) != 0) - new_count++; - new_profile=AcquireStringInfo(offset+new_count+rest); - (void) CopyMagickMemory(new_profile->datum,datum,offset-4); - WriteResourceLong(new_profile->datum+offset-4, - iptc_profile->length); - (void) CopyMagickMemory(new_profile->datum+offset, - iptc_profile->datum,iptc_profile->length); - } - (void) CopyMagickMemory(new_profile->datum+offset+new_count,p+count, - rest); - (void) AddValueToSplayTree((SplayTreeInfo *) image->profiles, - ConstantString("8bim"),CloneStringInfo(new_profile)); - new_profile=DestroyStringInfo(new_profile); - break; - } - else - p+=count; - } -} - +}static inline void WriteResourceLong(unsigned char *p, + const unsigned int quantum) +{ + unsigned char + buffer[4]; + + buffer[0]=(unsigned char) (quantum >> 24); + buffer[1]=(unsigned char) (quantum >> 16); + buffer[2]=(unsigned char) (quantum >> 8); + buffer[3]=(unsigned char) quantum; + (void) CopyMagickMemory(p,buffer,4); +} + +static void WriteTo8BimProfile(Image *image,const char *name, + const StringInfo *iptc_profile) +{ + + const unsigned char + *datum, + *s; + + register const unsigned char + *p; + + size_t + length; + + StringInfo + *profile; + + ssize_t + count; + + unsigned char + length_byte; + + unsigned int + value; + + unsigned short + id; + + if (LocaleCompare(name,"iptc") != 0) + return; + profile=(StringInfo *)GetValueFromSplayTree((SplayTreeInfo *)image->profiles, + "8bim"); + if (profile == (StringInfo *) NULL) + return; + datum=GetStringInfoDatum(profile); + length=GetStringInfoLength(profile); + for (p=datum; p < (datum+length-16); ) + { + s=p; + if (LocaleNCompare((char *) p,"8BIM",4) != 0) + break; + p+=4; + p=ReadResourceShort(p,&id); + p=ReadResourceByte(p,&length_byte); + p+=length_byte; + if (((length_byte+1) & 0x01) != 0) + p++; + if (p > (datum+length-4)) + break; + p=ReadResourceLong(p,&value); + count=(ssize_t) value; + if ((p > (datum+length-count)) || (count > length)) + break; + if ((count & 0x01) != 0) + count++; + if (id == 0x0404) + { + size_t + offset, + rest; + + ssize_t + new_count; + + StringInfo + *new_profile; + + new_count=0; + rest=(datum+length)-(p+count); + if (iptc_profile == (StringInfo *) NULL) + { + offset=(s-datum); + new_profile=AcquireStringInfo(offset+rest); + (void) CopyMagickMemory(new_profile->datum,datum,offset); + } + else + { + offset=(p-datum); + new_count=iptc_profile->length; + if ((new_count & 0x01) != 0) + new_count++; + new_profile=AcquireStringInfo(offset+new_count+rest); + (void) CopyMagickMemory(new_profile->datum,datum,offset-4); + WriteResourceLong(new_profile->datum+offset-4, + iptc_profile->length); + (void) CopyMagickMemory(new_profile->datum+offset, + iptc_profile->datum,iptc_profile->length); + } + (void) CopyMagickMemory(new_profile->datum+offset+new_count,p+count, + rest); + (void) AddValueToSplayTree((SplayTreeInfo *) image->profiles, + ConstantString("8bim"),CloneStringInfo(new_profile)); + new_profile=DestroyStringInfo(new_profile); + break; + } + else + p+=count; + } +} + static void GetProfilesFromResourceBlock(Image *image, const StringInfo *resource_block,ExceptionInfo *exception) { @@ -1433,7 +1433,7 @@ static MagickBooleanType SetImageProfileInternal(Image *image,const char *name, { if (LocaleCompare(name,"8bim") == 0) GetProfilesFromResourceBlock(image,profile,exception); - else if (recursive == MagickFalse) + else if (recursive == MagickFalse) WriteTo8BimProfile(image,name,profile); } /*