diff options
| author | Stefan Monnier | 2012-05-25 11:01:30 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-05-25 11:01:30 -0400 |
| commit | e8d32c7e803ad2b790627876bf7afc9381f252c9 (patch) | |
| tree | 7a762ce52b59d80c76f3cbe12321c057d2d69bcc /src | |
| parent | 245101e5da68860cf5c9d366f1858c374ba8c46f (diff) | |
| download | emacs-e8d32c7e803ad2b790627876bf7afc9381f252c9.tar.gz emacs-e8d32c7e803ad2b790627876bf7afc9381f252c9.zip | |
* src/fileio.c, src/character.h: Minor style tweaks.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/character.h | 2 | ||||
| -rw-r--r-- | src/fileio.c | 66 |
3 files changed, 38 insertions, 34 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8697e70d51d..911354b7a61 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-05-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * fileio.c, character.h: Minor style tweaks. | ||
| 4 | |||
| 1 | 2012-05-24 Dmitry Antipov <dmantipov@yandex.ru> | 5 | 2012-05-24 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 6 | ||
| 3 | * window.h (clip_changed): Remove useless declaration. | 7 | * window.h (clip_changed): Remove useless declaration. |
diff --git a/src/character.h b/src/character.h index 88de343b228..9b3790713ee 100644 --- a/src/character.h +++ b/src/character.h | |||
| @@ -434,7 +434,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 434 | unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \ | 434 | unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \ |
| 435 | int chlen; \ | 435 | int chlen; \ |
| 436 | \ | 436 | \ |
| 437 | OUTPUT= STRING_CHAR_AND_LENGTH (chp, chlen); \ | 437 | OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \ |
| 438 | BYTEIDX += chlen; \ | 438 | BYTEIDX += chlen; \ |
| 439 | } \ | 439 | } \ |
| 440 | else \ | 440 | else \ |
diff --git a/src/fileio.c b/src/fileio.c index f09ba2c394c..eac7554b17f 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -877,7 +877,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 877 | } | 877 | } |
| 878 | } | 878 | } |
| 879 | 879 | ||
| 880 | /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ | 880 | /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below. */ |
| 881 | nm = (char *) alloca (SBYTES (name) + 1); | 881 | nm = (char *) alloca (SBYTES (name) + 1); |
| 882 | memcpy (nm, SSDATA (name), SBYTES (name) + 1); | 882 | memcpy (nm, SSDATA (name), SBYTES (name) + 1); |
| 883 | 883 | ||
| @@ -905,7 +905,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 905 | if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) | 905 | if (drive && IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) |
| 906 | nm++; | 906 | nm++; |
| 907 | 907 | ||
| 908 | /* Discard any previous drive specifier if nm is now in UNC format. */ | 908 | /* Discard any previous drive specifier if nm is now in UNC format. */ |
| 909 | if (IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) | 909 | if (IS_DIRECTORY_SEP (nm[0]) && IS_DIRECTORY_SEP (nm[1])) |
| 910 | { | 910 | { |
| 911 | drive = 0; | 911 | drive = 0; |
| @@ -970,7 +970,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 970 | } | 970 | } |
| 971 | else | 971 | else |
| 972 | #endif | 972 | #endif |
| 973 | /* drive must be set, so this is okay */ | 973 | /* Drive must be set, so this is okay. */ |
| 974 | if (strcmp (nm - 2, SSDATA (name)) != 0) | 974 | if (strcmp (nm - 2, SSDATA (name)) != 0) |
| 975 | { | 975 | { |
| 976 | char temp[] = " :"; | 976 | char temp[] = " :"; |
| @@ -1016,7 +1016,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1016 | if (!(newdir = egetenv ("HOME"))) | 1016 | if (!(newdir = egetenv ("HOME"))) |
| 1017 | newdir = ""; | 1017 | newdir = ""; |
| 1018 | nm++; | 1018 | nm++; |
| 1019 | /* egetenv may return a unibyte string, which will bite us since | 1019 | /* `egetenv' may return a unibyte string, which will bite us since |
| 1020 | we expect the directory to be multibyte. */ | 1020 | we expect the directory to be multibyte. */ |
| 1021 | tem = build_string (newdir); | 1021 | tem = build_string (newdir); |
| 1022 | if (!STRING_MULTIBYTE (tem)) | 1022 | if (!STRING_MULTIBYTE (tem)) |
| @@ -1058,7 +1058,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1058 | use the drive's current directory as the prefix if needed. */ | 1058 | use the drive's current directory as the prefix if needed. */ |
| 1059 | if (!newdir && drive) | 1059 | if (!newdir && drive) |
| 1060 | { | 1060 | { |
| 1061 | /* Get default directory if needed to make nm absolute. */ | 1061 | /* Get default directory if needed to make nm absolute. */ |
| 1062 | char *adir = NULL; | 1062 | char *adir = NULL; |
| 1063 | if (!IS_DIRECTORY_SEP (nm[0])) | 1063 | if (!IS_DIRECTORY_SEP (nm[0])) |
| 1064 | { | 1064 | { |
| @@ -1068,7 +1068,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1068 | } | 1068 | } |
| 1069 | if (!adir) | 1069 | if (!adir) |
| 1070 | { | 1070 | { |
| 1071 | /* Either nm starts with /, or drive isn't mounted. */ | 1071 | /* Either nm starts with /, or drive isn't mounted. */ |
| 1072 | adir = alloca (4); | 1072 | adir = alloca (4); |
| 1073 | adir[0] = DRIVE_LETTER (drive); | 1073 | adir[0] = DRIVE_LETTER (drive); |
| 1074 | adir[1] = ':'; | 1074 | adir[1] = ':'; |
| @@ -1080,11 +1080,11 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1080 | #endif /* DOS_NT */ | 1080 | #endif /* DOS_NT */ |
| 1081 | 1081 | ||
| 1082 | /* Finally, if no prefix has been specified and nm is not absolute, | 1082 | /* Finally, if no prefix has been specified and nm is not absolute, |
| 1083 | then it must be expanded relative to default_directory. */ | 1083 | then it must be expanded relative to default_directory. */ |
| 1084 | 1084 | ||
| 1085 | if (1 | 1085 | if (1 |
| 1086 | #ifndef DOS_NT | 1086 | #ifndef DOS_NT |
| 1087 | /* /... alone is not absolute on DOS and Windows. */ | 1087 | /* /... alone is not absolute on DOS and Windows. */ |
| 1088 | && !IS_DIRECTORY_SEP (nm[0]) | 1088 | && !IS_DIRECTORY_SEP (nm[0]) |
| 1089 | #endif | 1089 | #endif |
| 1090 | #ifdef WINDOWSNT | 1090 | #ifdef WINDOWSNT |
| @@ -1106,7 +1106,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1106 | #ifdef DOS_NT | 1106 | #ifdef DOS_NT |
| 1107 | if (newdir) | 1107 | if (newdir) |
| 1108 | { | 1108 | { |
| 1109 | /* First ensure newdir is an absolute name. */ | 1109 | /* First ensure newdir is an absolute name. */ |
| 1110 | if ( | 1110 | if ( |
| 1111 | /* Detect MSDOS file names with drive specifiers. */ | 1111 | /* Detect MSDOS file names with drive specifiers. */ |
| 1112 | ! (IS_DRIVE (newdir[0]) | 1112 | ! (IS_DRIVE (newdir[0]) |
| @@ -1121,7 +1121,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1121 | Because of the admonition against calling expand-file-name | 1121 | Because of the admonition against calling expand-file-name |
| 1122 | when we have pointers into lisp strings, we accomplish this | 1122 | when we have pointers into lisp strings, we accomplish this |
| 1123 | indirectly by prepending newdir to nm if necessary, and using | 1123 | indirectly by prepending newdir to nm if necessary, and using |
| 1124 | cwd (or the wd of newdir's drive) as the new newdir. */ | 1124 | cwd (or the wd of newdir's drive) as the new newdir. */ |
| 1125 | char *adir; | 1125 | char *adir; |
| 1126 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) | 1126 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) |
| 1127 | { | 1127 | { |
| @@ -1146,7 +1146,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1146 | newdir = adir; | 1146 | newdir = adir; |
| 1147 | } | 1147 | } |
| 1148 | 1148 | ||
| 1149 | /* Strip off drive name from prefix, if present. */ | 1149 | /* Strip off drive name from prefix, if present. */ |
| 1150 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) | 1150 | if (IS_DRIVE (newdir[0]) && IS_DEVICE_SEP (newdir[1])) |
| 1151 | { | 1151 | { |
| 1152 | drive = newdir[0]; | 1152 | drive = newdir[0]; |
| @@ -1196,7 +1196,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1196 | else | 1196 | else |
| 1197 | tlen = 0; | 1197 | tlen = 0; |
| 1198 | 1198 | ||
| 1199 | /* Now concatenate the directory and name to new space in the stack frame */ | 1199 | /* Now concatenate the directory and name to new space in the stack frame. */ |
| 1200 | tlen += strlen (nm) + 1; | 1200 | tlen += strlen (nm) + 1; |
| 1201 | #ifdef DOS_NT | 1201 | #ifdef DOS_NT |
| 1202 | /* Reserve space for drive specifier and escape prefix, since either | 1202 | /* Reserve space for drive specifier and escape prefix, since either |
| @@ -1292,7 +1292,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1292 | } | 1292 | } |
| 1293 | 1293 | ||
| 1294 | #ifdef DOS_NT | 1294 | #ifdef DOS_NT |
| 1295 | /* At last, set drive name. */ | 1295 | /* At last, set drive name. */ |
| 1296 | #ifdef WINDOWSNT | 1296 | #ifdef WINDOWSNT |
| 1297 | /* Except for network file name. */ | 1297 | /* Except for network file name. */ |
| 1298 | if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) | 1298 | if (!(IS_DIRECTORY_SEP (target[0]) && IS_DIRECTORY_SEP (target[1]))) |
| @@ -1320,7 +1320,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1320 | and perhaps call the corresponding file handler. This is needed | 1320 | and perhaps call the corresponding file handler. This is needed |
| 1321 | for filenames such as "/foo/../user@host:/bar/../baz". Expanding | 1321 | for filenames such as "/foo/../user@host:/bar/../baz". Expanding |
| 1322 | the ".." component gives us "/user@host:/bar/../baz" which needs | 1322 | the ".." component gives us "/user@host:/bar/../baz" which needs |
| 1323 | to be expanded again. */ | 1323 | to be expanded again. */ |
| 1324 | handler = Ffind_file_name_handler (result, Qexpand_file_name); | 1324 | handler = Ffind_file_name_handler (result, Qexpand_file_name); |
| 1325 | if (!NILP (handler)) | 1325 | if (!NILP (handler)) |
| 1326 | { | 1326 | { |
| @@ -1396,7 +1396,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1396 | } | 1396 | } |
| 1397 | } | 1397 | } |
| 1398 | 1398 | ||
| 1399 | /* Now determine directory to start with and put it in NEWDIR */ | 1399 | /* Now determine directory to start with and put it in NEWDIR. */ |
| 1400 | 1400 | ||
| 1401 | newdir = 0; | 1401 | newdir = 0; |
| 1402 | 1402 | ||
| @@ -1409,17 +1409,17 @@ See also the function `substitute-in-file-name'.") | |||
| 1409 | } | 1409 | } |
| 1410 | else /* ~user/filename */ | 1410 | else /* ~user/filename */ |
| 1411 | { | 1411 | { |
| 1412 | /* Get past ~ to user */ | 1412 | /* Get past ~ to user. */ |
| 1413 | unsigned char *user = nm + 1; | 1413 | unsigned char *user = nm + 1; |
| 1414 | /* Find end of name. */ | 1414 | /* Find end of name. */ |
| 1415 | unsigned char *ptr = (unsigned char *) strchr (user, '/'); | 1415 | unsigned char *ptr = (unsigned char *) strchr (user, '/'); |
| 1416 | ptrdiff_t len = ptr ? ptr - user : strlen (user); | 1416 | ptrdiff_t len = ptr ? ptr - user : strlen (user); |
| 1417 | /* Copy the user name into temp storage. */ | 1417 | /* Copy the user name into temp storage. */ |
| 1418 | o = (unsigned char *) alloca (len + 1); | 1418 | o = (unsigned char *) alloca (len + 1); |
| 1419 | memcpy (o, user, len); | 1419 | memcpy (o, user, len); |
| 1420 | o[len] = 0; | 1420 | o[len] = 0; |
| 1421 | 1421 | ||
| 1422 | /* Look up the user name. */ | 1422 | /* Look up the user name. */ |
| 1423 | BLOCK_INPUT; | 1423 | BLOCK_INPUT; |
| 1424 | pw = (struct passwd *) getpwnam (o + 1); | 1424 | pw = (struct passwd *) getpwnam (o + 1); |
| 1425 | UNBLOCK_INPUT; | 1425 | UNBLOCK_INPUT; |
| @@ -1440,7 +1440,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1440 | newdir = SDATA (defalt); | 1440 | newdir = SDATA (defalt); |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | /* Now concatenate the directory and name to new space in the stack frame */ | 1443 | /* Now concatenate the directory and name to new space in the stack frame. */ |
| 1444 | 1444 | ||
| 1445 | tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1; | 1445 | tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1; |
| 1446 | target = (unsigned char *) alloca (tlen); | 1446 | target = (unsigned char *) alloca (tlen); |
| @@ -1456,7 +1456,7 @@ See also the function `substitute-in-file-name'.") | |||
| 1456 | 1456 | ||
| 1457 | strcat (target, nm); | 1457 | strcat (target, nm); |
| 1458 | 1458 | ||
| 1459 | /* Now canonicalize by removing /. and /foo/.. if they appear */ | 1459 | /* Now canonicalize by removing /. and /foo/.. if they appear. */ |
| 1460 | 1460 | ||
| 1461 | p = target; | 1461 | p = target; |
| 1462 | o = target; | 1462 | o = target; |
| @@ -1528,7 +1528,7 @@ search_embedded_absfilename (char *nm, char *endp) | |||
| 1528 | ) | 1528 | ) |
| 1529 | { | 1529 | { |
| 1530 | for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++); | 1530 | for (s = p; *s && (!IS_DIRECTORY_SEP (*s)); s++); |
| 1531 | if (p[0] == '~' && s > p + 1) /* we've got "/~something/" */ | 1531 | if (p[0] == '~' && s > p + 1) /* We've got "/~something/". */ |
| 1532 | { | 1532 | { |
| 1533 | char *o = alloca (s - p + 1); | 1533 | char *o = alloca (s - p + 1); |
| 1534 | struct passwd *pw; | 1534 | struct passwd *pw; |
| @@ -1612,7 +1612,7 @@ those `/' is discarded. */) | |||
| 1612 | (make_specified_string (p, -1, endp - p, multibyte)); | 1612 | (make_specified_string (p, -1, endp - p, multibyte)); |
| 1613 | 1613 | ||
| 1614 | /* See if any variables are substituted into the string | 1614 | /* See if any variables are substituted into the string |
| 1615 | and find the total length of their values in `total' */ | 1615 | and find the total length of their values in `total'. */ |
| 1616 | 1616 | ||
| 1617 | for (p = nm; p != endp;) | 1617 | for (p = nm; p != endp;) |
| 1618 | if (*p != '$') | 1618 | if (*p != '$') |
| @@ -1624,7 +1624,7 @@ those `/' is discarded. */) | |||
| 1624 | goto badsubst; | 1624 | goto badsubst; |
| 1625 | else if (*p == '$') | 1625 | else if (*p == '$') |
| 1626 | { | 1626 | { |
| 1627 | /* "$$" means a single "$" */ | 1627 | /* "$$" means a single "$". */ |
| 1628 | p++; | 1628 | p++; |
| 1629 | total -= 1; | 1629 | total -= 1; |
| 1630 | substituted = 1; | 1630 | substituted = 1; |
| @@ -1644,7 +1644,7 @@ those `/' is discarded. */) | |||
| 1644 | s = p; | 1644 | s = p; |
| 1645 | } | 1645 | } |
| 1646 | 1646 | ||
| 1647 | /* Copy out the variable name */ | 1647 | /* Copy out the variable name. */ |
| 1648 | target = (char *) alloca (s - o + 1); | 1648 | target = (char *) alloca (s - o + 1); |
| 1649 | strncpy (target, o, s - o); | 1649 | strncpy (target, o, s - o); |
| 1650 | target[s - o] = 0; | 1650 | target[s - o] = 0; |
| @@ -1652,7 +1652,7 @@ those `/' is discarded. */) | |||
| 1652 | strupr (target); /* $home == $HOME etc. */ | 1652 | strupr (target); /* $home == $HOME etc. */ |
| 1653 | #endif /* DOS_NT */ | 1653 | #endif /* DOS_NT */ |
| 1654 | 1654 | ||
| 1655 | /* Get variable value */ | 1655 | /* Get variable value. */ |
| 1656 | o = egetenv (target); | 1656 | o = egetenv (target); |
| 1657 | if (o) | 1657 | if (o) |
| 1658 | { | 1658 | { |
| @@ -1674,12 +1674,12 @@ those `/' is discarded. */) | |||
| 1674 | if (!substituted) | 1674 | if (!substituted) |
| 1675 | return filename; | 1675 | return filename; |
| 1676 | 1676 | ||
| 1677 | /* If substitution required, recopy the string and do it */ | 1677 | /* If substitution required, recopy the string and do it. */ |
| 1678 | /* Make space in stack frame for the new copy */ | 1678 | /* Make space in stack frame for the new copy. */ |
| 1679 | xnm = (char *) alloca (SBYTES (filename) + total + 1); | 1679 | xnm = (char *) alloca (SBYTES (filename) + total + 1); |
| 1680 | x = xnm; | 1680 | x = xnm; |
| 1681 | 1681 | ||
| 1682 | /* Copy the rest of the name through, replacing $ constructs with values */ | 1682 | /* Copy the rest of the name through, replacing $ constructs with values. */ |
| 1683 | for (p = nm; *p;) | 1683 | for (p = nm; *p;) |
| 1684 | if (*p != '$') | 1684 | if (*p != '$') |
| 1685 | *x++ = *p++; | 1685 | *x++ = *p++; |
| @@ -1707,7 +1707,7 @@ those `/' is discarded. */) | |||
| 1707 | s = p; | 1707 | s = p; |
| 1708 | } | 1708 | } |
| 1709 | 1709 | ||
| 1710 | /* Copy out the variable name */ | 1710 | /* Copy out the variable name. */ |
| 1711 | target = (char *) alloca (s - o + 1); | 1711 | target = (char *) alloca (s - o + 1); |
| 1712 | strncpy (target, o, s - o); | 1712 | strncpy (target, o, s - o); |
| 1713 | target[s - o] = 0; | 1713 | target[s - o] = 0; |
| @@ -1715,7 +1715,7 @@ those `/' is discarded. */) | |||
| 1715 | strupr (target); /* $home == $HOME etc. */ | 1715 | strupr (target); /* $home == $HOME etc. */ |
| 1716 | #endif /* DOS_NT */ | 1716 | #endif /* DOS_NT */ |
| 1717 | 1717 | ||
| 1718 | /* Get variable value */ | 1718 | /* Get variable value. */ |
| 1719 | o = egetenv (target); | 1719 | o = egetenv (target); |
| 1720 | if (!o) | 1720 | if (!o) |
| 1721 | { | 1721 | { |
| @@ -1777,7 +1777,7 @@ expand_and_dir_to_file (Lisp_Object filename, Lisp_Object defdir) | |||
| 1777 | stat behaves differently depending! */ | 1777 | stat behaves differently depending! */ |
| 1778 | if (SCHARS (absname) > 1 | 1778 | if (SCHARS (absname) > 1 |
| 1779 | && IS_DIRECTORY_SEP (SREF (absname, SBYTES (absname) - 1)) | 1779 | && IS_DIRECTORY_SEP (SREF (absname, SBYTES (absname) - 1)) |
| 1780 | && !IS_DEVICE_SEP (SREF (absname, SBYTES (absname)-2))) | 1780 | && !IS_DEVICE_SEP (SREF (absname, SBYTES (absname) - 2))) |
| 1781 | /* We cannot take shortcuts; they might be wrong for magic file names. */ | 1781 | /* We cannot take shortcuts; they might be wrong for magic file names. */ |
| 1782 | absname = Fdirectory_file_name (absname); | 1782 | absname = Fdirectory_file_name (absname); |
| 1783 | return absname; | 1783 | return absname; |
| @@ -1805,7 +1805,7 @@ barf_or_query_if_file_exists (Lisp_Object absname, const char *querystring, | |||
| 1805 | 1805 | ||
| 1806 | encoded_filename = ENCODE_FILE (absname); | 1806 | encoded_filename = ENCODE_FILE (absname); |
| 1807 | 1807 | ||
| 1808 | /* stat is a good way to tell whether the file exists, | 1808 | /* `stat' is a good way to tell whether the file exists, |
| 1809 | regardless of what access permissions it has. */ | 1809 | regardless of what access permissions it has. */ |
| 1810 | if (lstat (SSDATA (encoded_filename), &statbuf) >= 0) | 1810 | if (lstat (SSDATA (encoded_filename), &statbuf) >= 0) |
| 1811 | { | 1811 | { |