From: Victor Wagner Date: Wed, 27 Apr 2016 12:22:20 +0000 (+0300) Subject: Merge branch 'master' of http://wagner.pp.ru/git/oss/catdoc X-Git-Tag: REL_0_95~1^2~2 X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=oss%2Fcatdoc.git;a=commitdiff_plain;h=26ea699acb7f01e0b3431fd6173feb1f09094d8e;hp=-c Merge branch 'master' of http://wagner.pp.ru/git/oss/catdoc Conflicts: src/fileutil.c --- 26ea699acb7f01e0b3431fd6173feb1f09094d8e diff --combined src/charsets.c index 0511876,5c58c76..e64e24c --- a/src/charsets.c +++ b/src/charsets.c @@@ -22,7 -22,7 +22,7 @@@ CHARSET target_charset /* Converts char in input charset into unicode representation */ /* Should be converted to macro */ /************************************************************************/ - int to_unicode (short int *charset, int c) { + int to_unicode (uint16_t *charset, int c) { return charset[c]; } /************************************************************************/ @@@ -70,10 -70,10 +70,10 @@@ CHARSET make_reverse_map(short int *cha /* Reads charset file (as got from ftp.unicode.org) and returns array of*/ /* 256 short ints (malloced) mapping from charset t unicode */ /************************************************************************/ - short int * read_charset(const char *filename) { + uint16_t * read_charset(const char *filename) { char *path; FILE *f; - short int *new; + uint16_t *new; int c; long int uc; path= find_file(stradd(filename,CHARSET_EXT),charset_path); @@@ -99,7 -99,6 +99,7 @@@ if (c<0||c>255||uc<0||(uc>0xFEFE&& uc!=0xFFFE)) { fprintf(stderr,"Invalid charset file %s\n",path); fclose(f); + free(new); return NULL; } new[c]=uc; @@@ -181,7 -180,7 +181,7 @@@ int get_utf8 (FILE *f,long *offset,lon return 0xfeff; /*skip corrupted sequebces*/ if (c <0xE0) { if (catdoc_read(buf+1, 1, 1, f)<=0) return EOF; - return ((c & 0x1F)<<6 | ((char)buf[1] & 0x3F)); + return (((c & 0x1F)<<6) | ((char)buf[1] & 0x3F)); } if (c <0xF0) { if (catdoc_read(buf+1, 1, 2, f)<=2) return (int)EOF; @@@ -252,7 -251,7 +252,7 @@@ char *to_utf8(unsigned int uc) } struct cp_map { - int codepage; + uint16_t codepage; char *charset_name; }; diff --combined src/fileutil.c index 5ae039f,ce0bdb7..fc8e7f7 --- a/src/fileutil.c +++ b/src/fileutil.c @@@ -99,22 -99,19 +99,19 @@@ char *find_file(char *name, const char /************************************************************************/ int check_charset(char **filename,const char *charset) { char *tmppath; + if (charset == NULL ) { + return 0; + } if (!strncmp(charset,"utf-8",6)) { *filename=strdup("utf-8"); return 1; } tmppath=find_file(stradd(charset,CHARSET_EXT),charset_path); - /* Some compilers evalate both arguments of && before - applying, so let's not use && as in the shell */ - if (tmppath) { - if (*tmppath) { + if (tmppath && *tmppath) { *filename=strdup(charset); free(tmppath); return 1; - } else { - free(tmppath); - } -- } ++ } return 0; }