]> www.wagner.pp.ru Git - oss/catdoc.git/blobdiff - src/fileutil.c
Merge branch 'master' of http://wagner.pp.ru/git/oss/catdoc
[oss/catdoc.git] / src / fileutil.c
index 5ae039f5cd603eb9f57b5338266af4c051b227d8..fc8e7f7bae850c9a28b328d1dd1c1f598b9fd616 100644 (file)
@@ -99,22 +99,19 @@ char *find_file(char *name, const char *path)
 /************************************************************************/
 int check_charset(char **filename,const char *charset) {
        char *tmppath;
 /************************************************************************/
 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);
        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;
                        *filename=strdup(charset);
                        free(tmppath);
                        return 1;
-               } else {
-                       free(tmppath);
-               }
-       }
+       } 
        return 0;
 }
 
        return 0;
 }