comparison src/dired.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents d883f39b8495
children 064ab7fed2e0
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
114 114
115 /* Now *bufp is the compiled form of MATCH; don't call anything 115 /* Now *bufp is the compiled form of MATCH; don't call anything
116 which might compile a new regexp until we're done with the loop! */ 116 which might compile a new regexp until we're done with the loop! */
117 117
118 /* Do this opendir after anything which might signal an error. 118 /* Do this opendir after anything which might signal an error.
119 NOTE: the above comment is old; previosly, there was no 119 NOTE: the above comment is old; previously, there was no
120 unwind-protection in case of error, but now there is. */ 120 unwind-protection in case of error, but now there is. */
121 d = opendir ((char *) XSTRING_DATA (dirname)); 121 d = opendir ((char *) XSTRING_DATA (dirname));
122 if (!d) 122 if (!d)
123 report_file_error ("Opening directory", list1 (dirname)); 123 report_file_error ("Opening directory", list1 (dirname));
124 124
126 126
127 /* Loop reading blocks */ 127 /* Loop reading blocks */
128 while (1) 128 while (1)
129 { 129 {
130 DIRENTRY *dp = readdir (d); 130 DIRENTRY *dp = readdir (d);
131 Lisp_Object name;
132 int len; 131 int len;
133 132
134 if (!dp) 133 if (!dp)
135 break; 134 break;
136 len = NAMLEN (dp); 135 len = NAMLEN (dp);
177 continue; 176 continue;
178 else if (!EQ (files_only, Qt) && !dir_p) 177 else if (!EQ (files_only, Qt) && !dir_p)
179 continue; 178 continue;
180 } 179 }
181 180
182 if (!NILP (full)) 181 {
183 name = concat2 (dirname, make_ext_string ((Bufbyte *)dp->d_name, 182 Lisp_Object name =
184 len, FORMAT_FILENAME)); 183 make_ext_string ((Bufbyte *)dp->d_name, len, FORMAT_FILENAME);
185 else 184 if (!NILP (full))
186 name = make_ext_string ((Bufbyte *)dp->d_name, 185 name = concat2 (dirname, name);
187 len, FORMAT_FILENAME); 186
188 187 list = Fcons (name, list);
189 list = Fcons (name, list); 188 }
190 } 189 }
191 } 190 }
192 unbind_to (speccount, Qnil); /* This will close the dir */ 191 unbind_to (speccount, Qnil); /* This will close the dir */
193 192
194 if (!NILP (nosort)) 193 if (NILP (nosort))
195 RETURN_UNGCPRO (list); 194 list = Fsort (Fnreverse (list), Qstring_lessp);
196 else 195
197 RETURN_UNGCPRO (Fsort (Fnreverse (list), Qstring_lessp)); 196 RETURN_UNGCPRO (list);
198 } 197 }
199 198
200 static Lisp_Object file_name_completion (Lisp_Object file, 199 static Lisp_Object file_name_completion (Lisp_Object file,
201 Lisp_Object dirname, 200 Lisp_Object dirname,
202 int all_flag, int ver_flag); 201 int all_flag, int ver_flag);
689 user_cache_time = EMACS_SECS (t); 688 user_cache_time = EMACS_SECS (t);
690 } 689 }
691 690
692 for (i = 0; i < user_cache_len; i++) 691 for (i = 0; i < user_cache_len; i++)
693 { 692 {
694 Bytecount len; 693 Bufbyte *d_name = (Bufbyte *) user_cache[i];
694 Bytecount len = strlen ((char *) d_name);
695 /* scmp() works in chars, not bytes, so we have to compute this: */ 695 /* scmp() works in chars, not bytes, so we have to compute this: */
696 Charcount cclen; 696 Charcount cclen = bytecount_to_charcount (d_name, len);
697 Bufbyte *d_name;
698
699 d_name = (Bufbyte *) user_cache[i];
700 len = strlen (d_name);
701 cclen = bytecount_to_charcount (d_name, len);
702 697
703 QUIT; 698 QUIT;
704 699
705 if (cclen < user_name_length || 700 if (cclen < user_name_length ||
706 0 <= scmp (d_name, XSTRING_DATA (user), user_name_length)) 701 0 <= scmp (d_name, XSTRING_DATA (user), user_name_length))
782 777
783 Lisp_Object 778 Lisp_Object
784 make_directory_hash_table (CONST char *path) 779 make_directory_hash_table (CONST char *path)
785 { 780 {
786 DIR *d; 781 DIR *d;
787 Lisp_Object hash = make_lisp_hashtable (100, HASHTABLE_NONWEAK, 782 Lisp_Object hash =
788 HASHTABLE_EQUAL); 783 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
789 if ((d = opendir (path))) 784 if ((d = opendir (path)))
790 { 785 {
791 DIRENTRY *dp; 786 DIRENTRY *dp;
792 787
793 while ((dp = readdir (d))) 788 while ((dp = readdir (d)))