X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=oss%2Fcatdoc.git;a=blobdiff_plain;f=src%2Ffileutil.c;h=fc8e7f7bae850c9a28b328d1dd1c1f598b9fd616;hp=ce616c2ea112d170894a7d95dbf7679d00437e1c;hb=26ea699acb7f01e0b3431fd6173feb1f09094d8e;hpb=b89ceec5c7a586c1ad3e4758c4d2fdd160117d27 diff --git a/src/fileutil.c b/src/fileutil.c index ce616c2..fc8e7f7 100644 --- a/src/fileutil.c +++ b/src/fileutil.c @@ -99,20 +99,19 @@ char *find_file(char *name, const char *path) /************************************************************************/ 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; - } - } + } return 0; } @@ -180,14 +179,16 @@ void list_charsets(void) { char *q; char path_buf[PATH_BUF_SIZE]; char dir_sep[2]={DIR_SEP,0}; + char **ptr; #ifdef __MSDOS__ struct ffblk ffblock; int res,col; #else glob_t glob_buf; int count,glob_flags=GLOB_ERR; + + memset(&glob_buf,0,sizeof(glob_t)); #endif - char **ptr; for (p=charset_path;p;p=(q?(q+1):NULL)) { q=strchr(p,LIST_SEP); if (q) {