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