Mercurial > emacs
comparison src/fileio.c @ 68118:8b817a6ceff5
(Fexpand_file_name): Remove redundant tests. Fix elimination of // so that
it doesn't prevent elimination of an immediately following /. or /..
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 10 Jan 2006 17:46:41 +0000 |
parents | 5a3907cc23fc |
children | ebfcb70d92d2 8438f5473d99 7beb78bc1f8e |
comparison
equal
deleted
inserted
replaced
68117:340b01243a62 | 68118:8b817a6ceff5 |
---|---|
1 /* File IO for GNU Emacs. | 1 /* File IO for GNU Emacs. |
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, | 2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, |
3 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | 3 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
4 2005 Free Software Foundation, Inc. | 4 2005, 2006 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GNU Emacs. | 6 This file is part of GNU Emacs. |
7 | 7 |
8 GNU Emacs is free software; you can redistribute it and/or modify | 8 GNU Emacs is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
1642 #else /* not VMS */ | 1642 #else /* not VMS */ |
1643 if (!IS_DIRECTORY_SEP (*p)) | 1643 if (!IS_DIRECTORY_SEP (*p)) |
1644 { | 1644 { |
1645 *o++ = *p++; | 1645 *o++ = *p++; |
1646 } | 1646 } |
1647 else if (IS_DIRECTORY_SEP (p[0]) | 1647 else if (p[1] == '.' |
1648 && p[1] == '.' | |
1649 && (IS_DIRECTORY_SEP (p[2]) | 1648 && (IS_DIRECTORY_SEP (p[2]) |
1650 || p[2] == 0)) | 1649 || p[2] == 0)) |
1651 { | 1650 { |
1652 /* If "/." is the entire filename, keep the "/". Otherwise, | 1651 /* If "/." is the entire filename, keep the "/". Otherwise, |
1653 just delete the whole "/.". */ | 1652 just delete the whole "/.". */ |
1654 if (o == target && p[2] == '\0') | 1653 if (o == target && p[2] == '\0') |
1655 *o++ = *p; | 1654 *o++ = *p; |
1656 p += 2; | 1655 p += 2; |
1657 } | 1656 } |
1658 else if (IS_DIRECTORY_SEP (p[0]) && p[1] == '.' && p[2] == '.' | 1657 else if (p[1] == '.' && p[2] == '.' |
1659 /* `/../' is the "superroot" on certain file systems. | 1658 /* `/../' is the "superroot" on certain file systems. |
1660 Turned off on DOS_NT systems because they have no | 1659 Turned off on DOS_NT systems because they have no |
1661 "superroot" and because this causes us to produce | 1660 "superroot" and because this causes us to produce |
1662 file names like "d:/../foo" which fail file-related | 1661 file names like "d:/../foo" which fail file-related |
1663 functions of the underlying OS. (To reproduce, try a | 1662 functions of the underlying OS. (To reproduce, try a |
1673 /* Keep initial / only if this is the whole name. */ | 1672 /* Keep initial / only if this is the whole name. */ |
1674 if (o == target && IS_ANY_SEP (*o) && p[3] == 0) | 1673 if (o == target && IS_ANY_SEP (*o) && p[3] == 0) |
1675 ++o; | 1674 ++o; |
1676 p += 3; | 1675 p += 3; |
1677 } | 1676 } |
1678 else if (p > target | 1677 else if (p > target && IS_DIRECTORY_SEP (p[1])) |
1679 && IS_DIRECTORY_SEP (p[0]) && IS_DIRECTORY_SEP (p[1])) | 1678 /* Collapse multiple `/' in a row. */ |
1680 { | 1679 p++; |
1681 /* Collapse multiple `/' in a row. */ | |
1682 *o++ = *p++; | |
1683 while (IS_DIRECTORY_SEP (*p)) | |
1684 ++p; | |
1685 } | |
1686 else | 1680 else |
1687 { | 1681 { |
1688 *o++ = *p++; | 1682 *o++ = *p++; |
1689 } | 1683 } |
1690 #endif /* not VMS */ | 1684 #endif /* not VMS */ |