188 |
unwind_protect to do so would be a pain. */ |
unwind_protect to do so would be a pain. */ |
189 |
retry: |
retry: |
190 |
|
|
191 |
d = opendir (XSTRING (dirfilename)->data); |
d = opendir (SDATA (dirfilename)); |
192 |
if (d == NULL) |
if (d == NULL) |
193 |
report_file_error ("Opening directory", Fcons (directory, Qnil)); |
report_file_error ("Opening directory", Fcons (directory, Qnil)); |
194 |
|
|
199 |
Fcons (make_number (((unsigned long) d) >> 16), |
Fcons (make_number (((unsigned long) d) >> 16), |
200 |
make_number (((unsigned long) d) & 0xffff))); |
make_number (((unsigned long) d) & 0xffff))); |
201 |
|
|
202 |
directory_nbytes = STRING_BYTES (XSTRING (directory)); |
directory_nbytes = SBYTES (directory); |
203 |
re_match_object = Qt; |
re_match_object = Qt; |
204 |
|
|
205 |
/* Decide whether we need to add a directory separator. */ |
/* Decide whether we need to add a directory separator. */ |
206 |
#ifndef VMS |
#ifndef VMS |
207 |
if (directory_nbytes == 0 |
if (directory_nbytes == 0 |
208 |
|| !IS_ANY_SEP (XSTRING (directory)->data[directory_nbytes - 1])) |
|| !IS_ANY_SEP (SREF (directory, directory_nbytes - 1))) |
209 |
needsep = 1; |
needsep = 1; |
210 |
#endif /* not VMS */ |
#endif /* not VMS */ |
211 |
|
|
237 |
/* Note: ENCODE_FILE can GC; it should protect its argument, |
/* Note: ENCODE_FILE can GC; it should protect its argument, |
238 |
though. */ |
though. */ |
239 |
name = DECODE_FILE (name); |
name = DECODE_FILE (name); |
240 |
len = STRING_BYTES (XSTRING (name)); |
len = SBYTES (name); |
241 |
|
|
242 |
/* Now that we have unwind_protect in place, we might as well |
/* Now that we have unwind_protect in place, we might as well |
243 |
allow matching to be interrupted. */ |
allow matching to be interrupted. */ |
245 |
QUIT; |
QUIT; |
246 |
|
|
247 |
if (NILP (match) |
if (NILP (match) |
248 |
|| (0 <= re_search (bufp, XSTRING (name)->data, len, 0, len, 0))) |
|| (0 <= re_search (bufp, SDATA (name), len, 0, len, 0))) |
249 |
wanted = 1; |
wanted = 1; |
250 |
|
|
251 |
immediate_quit = 0; |
immediate_quit = 0; |
259 |
int nchars; |
int nchars; |
260 |
|
|
261 |
fullname = make_uninit_multibyte_string (nbytes, nbytes); |
fullname = make_uninit_multibyte_string (nbytes, nbytes); |
262 |
bcopy (XSTRING (directory)->data, XSTRING (fullname)->data, |
bcopy (SDATA (directory), SDATA (fullname), |
263 |
directory_nbytes); |
directory_nbytes); |
264 |
|
|
265 |
if (needsep) |
if (needsep) |
266 |
XSTRING (fullname)->data[directory_nbytes] = DIRECTORY_SEP; |
SREF (fullname, directory_nbytes) = DIRECTORY_SEP; |
267 |
|
|
268 |
bcopy (XSTRING (name)->data, |
bcopy (SDATA (name), |
269 |
XSTRING (fullname)->data + directory_nbytes + needsep, |
SDATA (fullname) + directory_nbytes + needsep, |
270 |
len); |
len); |
271 |
|
|
272 |
nchars = chars_in_text (XSTRING (fullname)->data, nbytes); |
nchars = chars_in_text (SDATA (fullname), nbytes); |
273 |
|
|
274 |
/* Some bug somewhere. */ |
/* Some bug somewhere. */ |
275 |
if (nchars > nbytes) |
if (nchars > nbytes) |
276 |
abort (); |
abort (); |
277 |
|
|
278 |
XSTRING (fullname)->size = nchars; |
SCHARS (fullname) = nchars; |
279 |
if (nchars == nbytes) |
if (nchars == nbytes) |
280 |
SET_STRING_BYTES (XSTRING (fullname), -1); |
STRING_SET_UNIBYTE (fullname); |
281 |
|
|
282 |
finalname = fullname; |
finalname = fullname; |
283 |
} |
} |
519 |
|
|
520 |
for (passcount = !!all_flag; NILP (bestmatch) && passcount < 2; passcount++) |
for (passcount = !!all_flag; NILP (bestmatch) && passcount < 2; passcount++) |
521 |
{ |
{ |
522 |
d = opendir (XSTRING (Fdirectory_file_name (encoded_dir))->data); |
d = opendir (SDATA (Fdirectory_file_name (encoded_dir))); |
523 |
if (!d) |
if (!d) |
524 |
report_file_error ("Opening directory", Fcons (dirname, Qnil)); |
report_file_error ("Opening directory", Fcons (dirname, Qnil)); |
525 |
|
|
542 |
if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) |
if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) |
543 |
goto quit; |
goto quit; |
544 |
if (! DIRENTRY_NONEMPTY (dp) |
if (! DIRENTRY_NONEMPTY (dp) |
545 |
|| len < XSTRING (encoded_file)->size |
|| len < SCHARS (encoded_file) |
546 |
|| 0 <= scmp (dp->d_name, XSTRING (encoded_file)->data, |
|| 0 <= scmp (dp->d_name, SDATA (encoded_file), |
547 |
XSTRING (encoded_file)->size)) |
SCHARS (encoded_file))) |
548 |
continue; |
continue; |
549 |
|
|
550 |
if (file_name_completion_stat (encoded_dir, dp, &st) < 0) |
if (file_name_completion_stat (encoded_dir, dp, &st) < 0) |
561 |
actually in the way in a directory contains only one file. */ |
actually in the way in a directory contains only one file. */ |
562 |
if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name)) |
if (!passcount && TRIVIAL_DIRECTORY_ENTRY (dp->d_name)) |
563 |
continue; |
continue; |
564 |
if (!passcount && len > XSTRING (encoded_file)->size) |
if (!passcount && len > SCHARS (encoded_file)) |
565 |
/* Ignore directories if they match an element of |
/* Ignore directories if they match an element of |
566 |
completion-ignored-extensions which ends in a slash. */ |
completion-ignored-extensions which ends in a slash. */ |
567 |
for (tem = Vcompletion_ignored_extensions; |
for (tem = Vcompletion_ignored_extensions; |
575 |
/* Need to encode ELT, since scmp compares unibyte |
/* Need to encode ELT, since scmp compares unibyte |
576 |
strings only. */ |
strings only. */ |
577 |
elt = ENCODE_FILE (elt); |
elt = ENCODE_FILE (elt); |
578 |
elt_len = XSTRING (elt)->size - 1; /* -1 for trailing / */ |
elt_len = SCHARS (elt) - 1; /* -1 for trailing / */ |
579 |
if (elt_len <= 0) |
if (elt_len <= 0) |
580 |
continue; |
continue; |
581 |
p1 = XSTRING (elt)->data; |
p1 = SDATA (elt); |
582 |
if (p1[elt_len] != '/') |
if (p1[elt_len] != '/') |
583 |
continue; |
continue; |
584 |
skip = len - elt_len; |
skip = len - elt_len; |
594 |
{ |
{ |
595 |
/* Compare extensions-to-be-ignored against end of this file name */ |
/* Compare extensions-to-be-ignored against end of this file name */ |
596 |
/* if name is not an exact match against specified string */ |
/* if name is not an exact match against specified string */ |
597 |
if (!passcount && len > XSTRING (encoded_file)->size) |
if (!passcount && len > SCHARS (encoded_file)) |
598 |
/* and exit this for loop if a match is found */ |
/* and exit this for loop if a match is found */ |
599 |
for (tem = Vcompletion_ignored_extensions; |
for (tem = Vcompletion_ignored_extensions; |
600 |
CONSP (tem); tem = XCDR (tem)) |
CONSP (tem); tem = XCDR (tem)) |
604 |
/* Need to encode ELT, since scmp compares unibyte |
/* Need to encode ELT, since scmp compares unibyte |
605 |
strings only. */ |
strings only. */ |
606 |
elt = ENCODE_FILE (elt); |
elt = ENCODE_FILE (elt); |
607 |
skip = len - XSTRING (elt)->size; |
skip = len - SCHARS (elt); |
608 |
if (skip < 0) continue; |
if (skip < 0) continue; |
609 |
|
|
610 |
if (0 <= scmp (dp->d_name + skip, |
if (0 <= scmp (dp->d_name + skip, |
611 |
XSTRING (elt)->data, |
SDATA (elt), |
612 |
XSTRING (elt)->size)) |
SCHARS (elt))) |
613 |
continue; |
continue; |
614 |
break; |
break; |
615 |
} |
} |
661 |
else |
else |
662 |
{ |
{ |
663 |
bestmatch = name; |
bestmatch = name; |
664 |
bestmatchsize = XSTRING (name)->size; |
bestmatchsize = SCHARS (name); |
665 |
} |
} |
666 |
} |
} |
667 |
else |
else |
668 |
{ |
{ |
669 |
compare = min (bestmatchsize, len); |
compare = min (bestmatchsize, len); |
670 |
p1 = XSTRING (bestmatch)->data; |
p1 = SDATA (bestmatch); |
671 |
p2 = (unsigned char *) dp->d_name; |
p2 = (unsigned char *) dp->d_name; |
672 |
matchsize = scmp(p1, p2, compare); |
matchsize = scmp(p1, p2, compare); |
673 |
if (matchsize < 0) |
if (matchsize < 0) |
682 |
but BESTMATCH is not (it is too long). */ |
but BESTMATCH is not (it is too long). */ |
683 |
if ((matchsize == len |
if ((matchsize == len |
684 |
&& matchsize + !!directoryp |
&& matchsize + !!directoryp |
685 |
< XSTRING (bestmatch)->size) |
< SCHARS (bestmatch)) |
686 |
|| |
|| |
687 |
/* If there is no exact match ignoring case, |
/* If there is no exact match ignoring case, |
688 |
prefer a match that does not change the case |
prefer a match that does not change the case |
695 |
(((matchsize == len) |
(((matchsize == len) |
696 |
== |
== |
697 |
(matchsize + !!directoryp |
(matchsize + !!directoryp |
698 |
== XSTRING (bestmatch)->size)) |
== SCHARS (bestmatch))) |
699 |
&& !bcmp (p2, XSTRING (encoded_file)->data, XSTRING (encoded_file)->size) |
&& !bcmp (p2, SDATA (encoded_file), SCHARS (encoded_file)) |
700 |
&& bcmp (p1, XSTRING (encoded_file)->data, XSTRING (encoded_file)->size))) |
&& bcmp (p1, SDATA (encoded_file), SCHARS (encoded_file)))) |
701 |
{ |
{ |
702 |
bestmatch = make_string (dp->d_name, len); |
bestmatch = make_string (dp->d_name, len); |
703 |
if (directoryp) |
if (directoryp) |
727 |
bestmatch = DECODE_FILE (bestmatch); |
bestmatch = DECODE_FILE (bestmatch); |
728 |
return bestmatch; |
return bestmatch; |
729 |
} |
} |
730 |
if (matchcount == 1 && bestmatchsize == XSTRING (file)->size) |
if (matchcount == 1 && bestmatchsize == SCHARS (file)) |
731 |
return Qt; |
return Qt; |
732 |
bestmatch = Fsubstring (bestmatch, make_number (0), |
bestmatch = Fsubstring (bestmatch, make_number (0), |
733 |
make_number (bestmatchsize)); |
make_number (bestmatchsize)); |
777 |
struct stat *st_addr; |
struct stat *st_addr; |
778 |
{ |
{ |
779 |
int len = NAMLEN (dp); |
int len = NAMLEN (dp); |
780 |
int pos = XSTRING (dirname)->size; |
int pos = SCHARS (dirname); |
781 |
int value; |
int value; |
782 |
char *fullname = (char *) alloca (len + pos + 2); |
char *fullname = (char *) alloca (len + pos + 2); |
783 |
|
|
794 |
#endif /* __DJGPP__ > 1 */ |
#endif /* __DJGPP__ > 1 */ |
795 |
#endif /* MSDOS */ |
#endif /* MSDOS */ |
796 |
|
|
797 |
bcopy (XSTRING (dirname)->data, fullname, pos); |
bcopy (SDATA (dirname), fullname, pos); |
798 |
#ifndef VMS |
#ifndef VMS |
799 |
if (!IS_DIRECTORY_SEP (fullname[pos - 1])) |
if (!IS_DIRECTORY_SEP (fullname[pos - 1])) |
800 |
fullname[pos++] = DIRECTORY_SEP; |
fullname[pos++] = DIRECTORY_SEP; |
847 |
filename = Fexpand_file_name (filename, Qnil); |
filename = Fexpand_file_name (filename, Qnil); |
848 |
fab = cc$rms_fab; |
fab = cc$rms_fab; |
849 |
xabfhc = cc$rms_xabfhc; |
xabfhc = cc$rms_xabfhc; |
850 |
fab.fab$l_fna = XSTRING (filename)->data; |
fab.fab$l_fna = SDATA (filename); |
851 |
fab.fab$b_fns = strlen (fab.fab$l_fna); |
fab.fab$b_fns = strlen (fab.fab$l_fna); |
852 |
fab.fab$l_xab = (char *) &xabfhc; |
fab.fab$l_xab = (char *) &xabfhc; |
853 |
status = sys$open (&fab, 0, 0); |
status = sys$open (&fab, 0, 0); |
916 |
|
|
917 |
encoded = ENCODE_FILE (filename); |
encoded = ENCODE_FILE (filename); |
918 |
|
|
919 |
if (lstat (XSTRING (encoded)->data, &s) < 0) |
if (lstat (SDATA (encoded), &s) < 0) |
920 |
return Qnil; |
return Qnil; |
921 |
|
|
922 |
switch (s.st_mode & S_IFMT) |
switch (s.st_mode & S_IFMT) |
946 |
dirname = Ffile_name_directory (filename); |
dirname = Ffile_name_directory (filename); |
947 |
if (! NILP (dirname)) |
if (! NILP (dirname)) |
948 |
encoded = ENCODE_FILE (dirname); |
encoded = ENCODE_FILE (dirname); |
949 |
if (! NILP (dirname) && stat (XSTRING (encoded)->data, &sdir) == 0) |
if (! NILP (dirname) && stat (SDATA (encoded), &sdir) == 0) |
950 |
values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil; |
values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil; |
951 |
else /* if we can't tell, assume worst */ |
else /* if we can't tell, assume worst */ |
952 |
values[9] = Qt; |
values[9] = Qt; |