Mercurial > hg > xemacs-beta
comparison src/dired.c @ 14:9ee227acff29 r19-15b90
Import from CVS: tag r19-15b90
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:48:42 +0200 |
parents | ac2d302a0011 |
children | 0293115a14e9 |
comparison
equal
deleted
inserted
replaced
13:13c6d0aaafe5 | 14:9ee227acff29 |
---|---|
91 | 91 |
92 { | 92 { |
93 /* XEmacs: this should come before the opendir() because it might error. */ | 93 /* XEmacs: this should come before the opendir() because it might error. */ |
94 Lisp_Object name_as_dir = Ffile_name_as_directory (dirname); | 94 Lisp_Object name_as_dir = Ffile_name_as_directory (dirname); |
95 CHECK_STRING (name_as_dir); | 95 CHECK_STRING (name_as_dir); |
96 memcpy (statbuf, ((char *) string_data (XSTRING (name_as_dir))), | 96 memcpy (statbuf, ((char *) XSTRING_DATA (name_as_dir)), |
97 string_length (XSTRING (name_as_dir))); | 97 XSTRING_LENGTH (name_as_dir)); |
98 statbuf_tail = statbuf + string_length (XSTRING (name_as_dir)); | 98 statbuf_tail = statbuf + XSTRING_LENGTH (name_as_dir); |
99 } | 99 } |
100 | 100 |
101 /* XEmacs: this should come after Ffile_name_as_directory() to avoid | 101 /* XEmacs: this should come after Ffile_name_as_directory() to avoid |
102 potential regexp cache smashage. This should come before the | 102 potential regexp cache smashage. This should come before the |
103 opendir() because it might signal an error. | 103 opendir() because it might signal an error. |
124 | 124 |
125 /* Do this opendir after anything which might signal an error; if | 125 /* Do this opendir after anything which might signal an error; if |
126 an error is signalled while the directory stream is open, we | 126 an error is signalled while the directory stream is open, we |
127 have to make sure it gets closed, and setting up an | 127 have to make sure it gets closed, and setting up an |
128 unwind_protect to do so would be a pain. */ | 128 unwind_protect to do so would be a pain. */ |
129 d = opendir ((char *) string_data (XSTRING (dirfilename))); | 129 d = opendir ((char *) XSTRING_DATA (dirfilename)); |
130 if (! d) | 130 if (! d) |
131 report_file_error ("Opening directory", list1 (dirname)); | 131 report_file_error ("Opening directory", list1 (dirname)); |
132 | 132 |
133 list = Qnil; | 133 list = Qnil; |
134 tail_cons = Qnil; | 134 tail_cons = Qnil; |
135 dirname_length = string_length (XSTRING (dirname)); | 135 dirname_length = XSTRING_LENGTH (dirname); |
136 #ifndef VMS | 136 #ifndef VMS |
137 if (dirname_length == 0 | 137 if (dirname_length == 0 |
138 || !IS_ANY_SEP (string_byte (XSTRING (dirname), dirname_length - 1))) | 138 || !IS_ANY_SEP (XSTRING_BYTE (dirname, dirname_length - 1))) |
139 { | 139 { |
140 *filename++ = DIRECTORY_SEP; | 140 *filename++ = DIRECTORY_SEP; |
141 dirname_length++; | 141 dirname_length++; |
142 } | 142 } |
143 #endif /* VMS */ | 143 #endif /* VMS */ |
275 static int | 275 static int |
276 file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, | 276 file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, |
277 struct stat *st_addr) | 277 struct stat *st_addr) |
278 { | 278 { |
279 Bytecount len = NAMLEN (dp); | 279 Bytecount len = NAMLEN (dp); |
280 Bytecount pos = string_length (XSTRING (dirname)); | 280 Bytecount pos = XSTRING_LENGTH (dirname); |
281 int value; | 281 int value; |
282 char *fullname = (char *) alloca (len + pos + 2); | 282 char *fullname = (char *) alloca (len + pos + 2); |
283 | 283 |
284 memcpy (fullname, string_data (XSTRING (dirname)), pos); | 284 memcpy (fullname, XSTRING_DATA (dirname), pos); |
285 #ifndef VMS | 285 #ifndef VMS |
286 if (!IS_DIRECTORY_SEP (fullname[pos - 1])) | 286 if (!IS_DIRECTORY_SEP (fullname[pos - 1])) |
287 fullname[pos++] = DIRECTORY_SEP; | 287 fullname[pos++] = DIRECTORY_SEP; |
288 #endif | 288 #endif |
289 | 289 |
346 completions when making a list of them.** */ | 346 completions when making a list of them.** */ |
347 | 347 |
348 for (passcount = !!all_flag; NILP (bestmatch) && passcount < 2; passcount++) | 348 for (passcount = !!all_flag; NILP (bestmatch) && passcount < 2; passcount++) |
349 { | 349 { |
350 d = opendir ((char *) | 350 d = opendir ((char *) |
351 string_data (XSTRING (Fdirectory_file_name (dirname)))); | 351 XSTRING_DATA (Fdirectory_file_name (dirname))); |
352 if (!d) | 352 if (!d) |
353 report_file_error ("Opening directory", list1 (dirname)); | 353 report_file_error ("Opening directory", list1 (dirname)); |
354 | 354 |
355 /* Loop reading blocks */ | 355 /* Loop reading blocks */ |
356 while (1) | 356 while (1) |
379 signal_quit (); | 379 signal_quit (); |
380 } | 380 } |
381 | 381 |
382 if (! DIRENTRY_NONEMPTY (dp) | 382 if (! DIRENTRY_NONEMPTY (dp) |
383 || cclen < file_name_length | 383 || cclen < file_name_length |
384 || 0 <= scmp (d_name, | 384 || 0 <= scmp (d_name, XSTRING_DATA (file), file_name_length)) |
385 string_data (XSTRING (file)), | |
386 file_name_length)) | |
387 continue; | 385 continue; |
388 | 386 |
389 if (file_name_completion_stat (dirname, dp, &st) < 0) | 387 if (file_name_completion_stat (dirname, dp, &st) < 0) |
390 continue; | 388 continue; |
391 | 389 |
418 if (!STRINGP (elt)) continue; | 416 if (!STRINGP (elt)) continue; |
419 skip = cclen - string_char_length (XSTRING (elt)); | 417 skip = cclen - string_char_length (XSTRING (elt)); |
420 if (skip < 0) continue; | 418 if (skip < 0) continue; |
421 | 419 |
422 if (0 > scmp (charptr_n_addr (d_name, skip), | 420 if (0 > scmp (charptr_n_addr (d_name, skip), |
423 string_data (XSTRING (elt)), | 421 XSTRING_DATA (elt), |
424 string_char_length (XSTRING (elt)))) | 422 string_char_length (XSTRING (elt)))) |
425 { | 423 { |
426 ignored_extension_p = 1; | 424 ignored_extension_p = 1; |
427 break; | 425 break; |
428 } | 426 } |
462 NUNGCPRO; | 460 NUNGCPRO; |
463 } | 461 } |
464 else | 462 else |
465 { | 463 { |
466 Charcount compare = min (bestmatchsize, cclen); | 464 Charcount compare = min (bestmatchsize, cclen); |
467 Bufbyte *p1 = string_data (XSTRING (bestmatch)); | 465 Bufbyte *p1 = XSTRING_DATA (bestmatch); |
468 Bufbyte *p2 = d_name; | 466 Bufbyte *p2 = d_name; |
469 Charcount matchsize = scmp (p1, p2, compare); | 467 Charcount matchsize = scmp (p1, p2, compare); |
470 | 468 |
471 if (matchsize < 0) | 469 if (matchsize < 0) |
472 matchsize = compare; | 470 matchsize = compare; |
488 (matchsize + !!directoryp | 486 (matchsize + !!directoryp |
489 == string_char_length (XSTRING (bestmatch)))) | 487 == string_char_length (XSTRING (bestmatch)))) |
490 /* If there is more than one exact match aside from | 488 /* If there is more than one exact match aside from |
491 case, and one of them is exact including case, | 489 case, and one of them is exact including case, |
492 prefer that one. */ | 490 prefer that one. */ |
493 && 0 > scmp_1 (p2, string_data (XSTRING (file)), | 491 && 0 > scmp_1 (p2, XSTRING_DATA (file), |
494 file_name_length, 0) | 492 file_name_length, 0) |
495 && 0 <= scmp_1 (p1, string_data (XSTRING (file)), | 493 && 0 <= scmp_1 (p1, XSTRING_DATA (file), |
496 file_name_length, 0))) | 494 file_name_length, 0))) |
497 { | 495 { |
498 bestmatch = make_string (d_name, len); | 496 bestmatch = make_string (d_name, len); |
499 if (directoryp) | 497 if (directoryp) |
500 bestmatch = Ffile_name_as_directory (bestmatch); | 498 bestmatch = Ffile_name_as_directory (bestmatch); |
576 | 574 |
577 filename = Fexpand_file_name (filename, Qnil); | 575 filename = Fexpand_file_name (filename, Qnil); |
578 CHECK_STRING (filename); | 576 CHECK_STRING (filename); |
579 fab = cc$rms_fab; | 577 fab = cc$rms_fab; |
580 xabfhc = cc$rms_xabfhc; | 578 xabfhc = cc$rms_xabfhc; |
581 fab.fab$l_fna = string_data (XSTRING (filename)); | 579 fab.fab$l_fna = XSTRING_DATA (filename); |
582 fab.fab$b_fns = strlen (fab.fab$l_fna); | 580 fab.fab$b_fns = strlen (fab.fab$l_fna); |
583 fab.fab$l_xab = (char *) &xabfhc; | 581 fab.fab$l_xab = (char *) &xabfhc; |
584 status = sys$open (&fab, 0, 0); | 582 status = sys$open (&fab, 0, 0); |
585 if (status != RMS$_NORMAL) /* Probably non-existent file */ | 583 if (status != RMS$_NORMAL) /* Probably non-existent file */ |
586 return Qnil; | 584 return Qnil; |
643 handler = Ffind_file_name_handler (filename, Qfile_attributes); | 641 handler = Ffind_file_name_handler (filename, Qfile_attributes); |
644 UNGCPRO; | 642 UNGCPRO; |
645 if (!NILP (handler)) | 643 if (!NILP (handler)) |
646 return call2 (handler, Qfile_attributes, filename); | 644 return call2 (handler, Qfile_attributes, filename); |
647 | 645 |
648 if (lstat ((char *) string_data (XSTRING (filename)), &s) < 0) | 646 if (lstat ((char *) XSTRING_DATA (filename), &s) < 0) |
649 return Qnil; | 647 return Qnil; |
650 | 648 |
651 GCPRO2 (filename, dirname); | 649 GCPRO2 (filename, dirname); |
652 | 650 |
653 #ifdef BSD4_2 | 651 #ifdef BSD4_2 |
654 dirname = Ffile_name_directory (filename); | 652 dirname = Ffile_name_directory (filename); |
655 #endif | 653 #endif |
656 | 654 |
657 #ifdef MSDOS | 655 #ifdef MSDOS |
658 { | 656 { |
659 char *tmpnam = | 657 char *tmpnam = (char *) XSTRING_DATA (Ffile_name_nondirectory (filename)); |
660 (char *) string_data (XSTRING (Ffile_name_nondirectory (filename))); | |
661 int l = strlen (tmpnam); | 658 int l = strlen (tmpnam); |
662 | 659 |
663 if (l >= 5 | 660 if (l >= 5 |
664 && S_ISREG (s.st_mode) | 661 && S_ISREG (s.st_mode) |
665 && (stricmp (&tmpnam[l - 4], ".com") == 0 | 662 && (stricmp (&tmpnam[l - 4], ".com") == 0 || |
666 || stricmp (&tmpnam[l - 4], ".exe") == 0 | 663 stricmp (&tmpnam[l - 4], ".exe") == 0 || |
667 || stricmp (&tmpnam[l - 4], ".bat") == 0)) | 664 stricmp (&tmpnam[l - 4], ".bat") == 0)) |
668 { | 665 { |
669 s.st_mode |= S_IEXEC; | 666 s.st_mode |= S_IEXEC; |
670 } | 667 } |
671 } | 668 } |
672 #endif /* MSDOS */ | 669 #endif /* MSDOS */ |
700 values[8] = make_string ((Bufbyte *) modes, 10); | 697 values[8] = make_string ((Bufbyte *) modes, 10); |
701 #if defined (BSD4_2) || defined (BSD4_3) /* file gid will be dir gid */ | 698 #if defined (BSD4_2) || defined (BSD4_3) /* file gid will be dir gid */ |
702 { | 699 { |
703 struct stat sdir; | 700 struct stat sdir; |
704 | 701 |
705 if (!NILP (dirname) && stat ((char *) string_data (XSTRING (dirname)), &sdir) == 0) | 702 if (!NILP (dirname) && stat ((char *) XSTRING_DATA (dirname), &sdir) == 0) |
706 values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil; | 703 values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil; |
707 else /* if we can't tell, assume worst */ | 704 else /* if we can't tell, assume worst */ |
708 values[9] = Qt; | 705 values[9] = Qt; |
709 } | 706 } |
710 #else /* file gid will be egid */ | 707 #else /* file gid will be egid */ |