X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Fdired.c;h=c2309f1587888644506846ff5777ba9839c2bdd8;hp=076e339fea99054c2dddc1461d9f6ca823d7a205;hb=35adcaaeafb1fe93eaf00c39b48619e8f188ff3f;hpb=669565bfdc5d704dfb1d5ac1a0ec01fb3615a1ae diff --git a/src/dired.c b/src/dired.c index 076e339..c2309f1 100644 --- a/src/dired.c +++ b/src/dired.c @@ -116,7 +116,7 @@ If FILES-ONLY is the symbol t, then only the "files" in the directory which might compile a new regexp until we're done with the loop! */ /* Do this opendir after anything which might signal an error. - NOTE: the above comment is old; previosly, there was no + NOTE: the above comment is old; previously, there was no unwind-protection in case of error, but now there is. */ d = opendir ((char *) XSTRING_DATA (dirname)); if (!d) @@ -128,7 +128,6 @@ If FILES-ONLY is the symbol t, then only the "files" in the directory while (1) { DIRENTRY *dp = readdir (d); - Lisp_Object name; int len; if (!dp) @@ -179,22 +178,22 @@ If FILES-ONLY is the symbol t, then only the "files" in the directory continue; } - if (!NILP (full)) - name = concat2 (dirname, make_ext_string ((Bufbyte *)dp->d_name, - len, FORMAT_FILENAME)); - else - name = make_ext_string ((Bufbyte *)dp->d_name, - len, FORMAT_FILENAME); + { + Lisp_Object name = + make_ext_string ((Bufbyte *)dp->d_name, len, FORMAT_FILENAME); + if (!NILP (full)) + name = concat2 (dirname, name); - list = Fcons (name, list); + list = Fcons (name, list); + } } } unbind_to (speccount, Qnil); /* This will close the dir */ - if (!NILP (nosort)) - RETURN_UNGCPRO (list); - else - RETURN_UNGCPRO (Fsort (Fnreverse (list), Qstring_lessp)); + if (NILP (nosort)) + list = Fsort (Fnreverse (list), Qstring_lessp); + + RETURN_UNGCPRO (list); } static Lisp_Object file_name_completion (Lisp_Object file, @@ -376,9 +375,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, dp = readdir (d); if (!dp) break; - /* #### This is a bad idea, because d_name can contain - control characters, which can make XEmacs crash. This - should be handled properly with FORMAT_FILENAME. */ + /* Cast to Bufbyte* is OK, as readdir() Mule-encapsulates. */ d_name = (Bufbyte *) dp->d_name; len = NAMLEN (dp); cclen = bytecount_to_charcount (d_name, len); @@ -531,6 +528,10 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, } + +/* The *pwent() functions do not exist on NT */ +#ifndef WINDOWSNT + static Lisp_Object user_name_completion (Lisp_Object user, int all_flag, int *uniq); @@ -689,14 +690,10 @@ user_name_completion (Lisp_Object user, int all_flag, int *uniq) for (i = 0; i < user_cache_len; i++) { - Bytecount len; + Bufbyte *d_name = (Bufbyte *) user_cache[i]; + Bytecount len = strlen ((char *) d_name); /* scmp() works in chars, not bytes, so we have to compute this: */ - Charcount cclen; - Bufbyte *d_name; - - d_name = (Bufbyte *) user_cache[i]; - len = strlen (d_name); - cclen = bytecount_to_charcount (d_name, len); + Charcount cclen = bytecount_to_charcount (d_name, len); QUIT; @@ -775,14 +772,15 @@ user_name_completion (Lisp_Object user, int all_flag, int *uniq) return Qt; return Fsubstring (bestmatch, Qzero, make_int (bestmatchsize)); } +#endif /* ! defined WINDOWSNT */ Lisp_Object make_directory_hash_table (CONST char *path) { DIR *d; - Lisp_Object hash = make_lisp_hashtable (100, HASHTABLE_NONWEAK, - HASHTABLE_EQUAL); + Lisp_Object hash = + make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL); if ((d = opendir (path))) { DIRENTRY *dp; @@ -791,8 +789,8 @@ make_directory_hash_table (CONST char *path) { Bytecount len = NAMLEN (dp); if (DIRENTRY_NONEMPTY (dp)) - Fputhash (make_ext_string ((Bufbyte *) dp->d_name, len, - FORMAT_FILENAME), Qt, hash); + /* Cast to Bufbyte* is OK, as readdir() Mule-encapsulates. */ + Fputhash (make_string ((Bufbyte *) dp->d_name, len), Qt, hash); } closedir (d); } @@ -938,9 +936,11 @@ syms_of_dired (void) DEFSUBR (Fdirectory_files); DEFSUBR (Ffile_name_completion); DEFSUBR (Ffile_name_all_completions); +#ifndef WINDOWSNT DEFSUBR (Fuser_name_completion); DEFSUBR (Fuser_name_completion_1); DEFSUBR (Fuser_name_all_completions); +#endif DEFSUBR (Ffile_attributes); } @@ -956,7 +956,9 @@ It is used by the functions `file-name-completion' and */ ); Vcompletion_ignored_extensions = Qnil; +#ifndef WINDOWSNT user_cache = NULL; user_cache_len = 0; user_cache_max = 0; +#endif }