Mercurial > hg > xemacs-beta
comparison src/dired.c @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | 9ee227acff29 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
61 Lisp_Object handler; | 61 Lisp_Object handler; |
62 struct re_pattern_buffer *bufp; | 62 struct re_pattern_buffer *bufp; |
63 | 63 |
64 char statbuf [MAXNAMLEN+2]; | 64 char statbuf [MAXNAMLEN+2]; |
65 char *statbuf_tail; | 65 char *statbuf_tail; |
66 Lisp_Object tail_cons; | 66 Lisp_Object tail_cons = Qnil; |
67 char slashfilename[MAXNAMLEN+2]; | 67 char slashfilename[MAXNAMLEN+2]; |
68 char *filename = slashfilename; | 68 char *filename = slashfilename; |
69 | 69 |
70 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 70 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
71 | 71 |
333 | 333 |
334 #ifdef FILE_SYSTEM_CASE | 334 #ifdef FILE_SYSTEM_CASE |
335 file = FILE_SYSTEM_CASE (file); | 335 file = FILE_SYSTEM_CASE (file); |
336 #endif | 336 #endif |
337 dirname = Fexpand_file_name (dirname, Qnil); | 337 dirname = Fexpand_file_name (dirname, Qnil); |
338 bestmatch = Qnil; | |
339 file_name_length = string_char_length (XSTRING (file)); | 338 file_name_length = string_char_length (XSTRING (file)); |
340 | 339 |
341 /* With passcount = 0, ignore files that end in an ignored extension. | 340 /* With passcount = 0, ignore files that end in an ignored extension. |
342 If nothing found then try again with passcount = 1, don't ignore them. | 341 If nothing found then try again with passcount = 1, don't ignore them. |
343 If looking for all completions, start with passcount = 1, | 342 If looking for all completions, start with passcount = 1, |
352 string_data (XSTRING (Fdirectory_file_name (dirname)))); | 351 string_data (XSTRING (Fdirectory_file_name (dirname)))); |
353 if (!d) | 352 if (!d) |
354 report_file_error ("Opening directory", list1 (dirname)); | 353 report_file_error ("Opening directory", list1 (dirname)); |
355 | 354 |
356 /* Loop reading blocks */ | 355 /* Loop reading blocks */ |
357 /* (att3b compiler bug requires do a null comparison this way) */ | |
358 while (1) | 356 while (1) |
359 { | 357 { |
360 DIRENTRY *dp; | 358 DIRENTRY *dp; |
361 Bytecount len; | 359 Bytecount len; |
362 /* scmp() works in characters, not bytes, so we have to compute | 360 /* scmp() works in characters, not bytes, so we have to compute |
369 dp = (*readfunc) (d); | 367 dp = (*readfunc) (d); |
370 if (!dp) break; | 368 if (!dp) break; |
371 | 369 |
372 d_name = (Bufbyte *) dp->d_name; | 370 d_name = (Bufbyte *) dp->d_name; |
373 len = NAMLEN (dp); | 371 len = NAMLEN (dp); |
374 /* mrb: #### FIX: The Name must be converted using | 372 cclen = bytecount_to_charcount (d_name, len); |
375 file-name-coding system or some such. At least this | |
376 change allows the saving of files in directories with | |
377 Japanese file names */ | |
378 /*cclen = bytecount_to_charcount (d_name, len);*/ | |
379 cclen = len; | |
380 | 373 |
381 /* Can't just use QUIT because we have to make sure the file | 374 /* Can't just use QUIT because we have to make sure the file |
382 descriptor gets closed. */ | 375 descriptor gets closed. */ |
383 if (QUITP) | 376 if (QUITP) |
384 { | 377 { |
401 { | 394 { |
402 #ifndef TRIVIAL_DIRECTORY_ENTRY | 395 #ifndef TRIVIAL_DIRECTORY_ENTRY |
403 #define TRIVIAL_DIRECTORY_ENTRY(n) (!strcmp (n, ".") || !strcmp (n, "..")) | 396 #define TRIVIAL_DIRECTORY_ENTRY(n) (!strcmp (n, ".") || !strcmp (n, "..")) |
404 #endif | 397 #endif |
405 /* "." and ".." are never interesting as completions, but are | 398 /* "." and ".." are never interesting as completions, but are |
406 actually in the way in a directory contains only one file. */ | 399 actually in the way in a directory containing only one file. */ |
407 if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name)) | 400 if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name)) |
408 continue; | 401 continue; |
409 } | 402 } |
410 else | 403 else |
411 { | 404 { |
412 /* Compare extensions-to-be-ignored against end of this file name */ | 405 /* Compare extensions-to-be-ignored against end of this file name */ |
413 /* if name is not an exact match against specified string */ | 406 /* if name is not an exact match against specified string. */ |
414 if (!passcount && cclen > file_name_length) | 407 if (!passcount && cclen > file_name_length) |
415 { | 408 { |
416 Lisp_Object tem; | 409 Lisp_Object tem; |
417 /* and exit this for loop if a match is found */ | 410 /* and exit this for loop if a match is found */ |
418 for (tem = Vcompletion_ignored_extensions; | 411 for (tem = Vcompletion_ignored_extensions; |
440 /* If an ignored-extensions match was found, | 433 /* If an ignored-extensions match was found, |
441 don't process this name as a completion. */ | 434 don't process this name as a completion. */ |
442 if (!passcount && ignored_extension_p) | 435 if (!passcount && ignored_extension_p) |
443 continue; | 436 continue; |
444 | 437 |
445 if (!passcount && regexp_ignore_completion_p (d_name, Qnil, 0, len)) | 438 if (!passcount && regexp_ignore_completion_p (d_name, Qnil, 0, cclen)) |
446 continue; | 439 continue; |
447 | 440 |
448 /* Update computation of how much all possible completions match */ | 441 /* Update computation of how much all possible completions match */ |
449 matchcount++; | 442 matchcount++; |
450 | 443 |
452 { | 445 { |
453 Lisp_Object name = Qnil; | 446 Lisp_Object name = Qnil; |
454 struct gcpro ngcpro1; | 447 struct gcpro ngcpro1; |
455 NGCPRO1 (name); | 448 NGCPRO1 (name); |
456 /* This is a possible completion */ | 449 /* This is a possible completion */ |
457 if (directoryp) | 450 name = make_string (d_name, len); |
458 { | 451 if (directoryp) /* Completion is a directory; end it with '/' */ |
459 /* This completion is a directory; make it end with '/' */ | 452 name = Ffile_name_as_directory (name); |
460 name = Ffile_name_as_directory | |
461 /* make_string (d_name, len); */ | |
462 (make_ext_string (d_name, len, FORMAT_BINARY)); | |
463 } | |
464 else | |
465 /* name = make_string (d_name, len) */ | |
466 name = make_ext_string (d_name, len, FORMAT_BINARY); | |
467 if (all_flag) | 453 if (all_flag) |
468 { | 454 { |
469 bestmatch = Fcons (name, bestmatch); | 455 bestmatch = Fcons (name, bestmatch); |
470 } | 456 } |
471 else | 457 else |
488 { | 474 { |
489 /* If this is an exact match except for case, | 475 /* If this is an exact match except for case, |
490 use it as the best match rather than one that is not | 476 use it as the best match rather than one that is not |
491 an exact match. This way, we get the case pattern | 477 an exact match. This way, we get the case pattern |
492 of the actual match. */ | 478 of the actual match. */ |
493 if ((matchsize == len | 479 if ((matchsize == cclen |
494 && matchsize + !!directoryp | 480 && matchsize + !!directoryp |
495 < string_char_length (XSTRING (bestmatch))) | 481 < string_char_length (XSTRING (bestmatch))) |
496 || | 482 || |
497 /* If there is no exact match ignoring case, | 483 /* If there is no exact match ignoring case, |
498 prefer a match that does not change the case | 484 prefer a match that does not change the case |
499 of the input. */ | 485 of the input. */ |
500 (((matchsize == len) | 486 (((matchsize == cclen) |
501 == | 487 == |
502 (matchsize + !!directoryp | 488 (matchsize + !!directoryp |
503 == string_char_length (XSTRING (bestmatch)))) | 489 == string_char_length (XSTRING (bestmatch)))) |
504 /* If there is more than one exact match aside from | 490 /* If there is more than one exact match aside from |
505 case, and one of them is exact including case, | 491 case, and one of them is exact including case, |
507 && 0 > scmp_1 (p2, string_data (XSTRING (file)), | 493 && 0 > scmp_1 (p2, string_data (XSTRING (file)), |
508 file_name_length, 0) | 494 file_name_length, 0) |
509 && 0 <= scmp_1 (p1, string_data (XSTRING (file)), | 495 && 0 <= scmp_1 (p1, string_data (XSTRING (file)), |
510 file_name_length, 0))) | 496 file_name_length, 0))) |
511 { | 497 { |
512 /* bestmatch = make_string (d_name, len); */ /* mrb */ | 498 bestmatch = make_string (d_name, len); |
513 bestmatch = make_ext_string (d_name, len, FORMAT_BINARY); | |
514 if (directoryp) | 499 if (directoryp) |
515 bestmatch = | 500 bestmatch = Ffile_name_as_directory (bestmatch); |
516 Ffile_name_as_directory (bestmatch); | |
517 } | 501 } |
518 } | 502 } |
519 | 503 |
520 /* If this dirname all matches, | 504 /* If this dirname all matches, |
521 see if implicit following slash does too. */ | 505 see if implicit following slash does too. */ |