diff options
| author | Miles Bader | 2006-03-28 23:08:20 +0000 |
|---|---|---|
| committer | Miles Bader | 2006-03-28 23:08:20 +0000 |
| commit | 1ef7e5599f5aa981399221e657ff34e80cc2c1a3 (patch) | |
| tree | 539ff4cf9ea84af29a4e8628d049f3a4253a51f4 /src/editfns.c | |
| parent | 33bd75ec5fb277e58731c8cbbb942cba4d9a9f19 (diff) | |
| parent | 29314e0fd78063d663bd272787d0ea81cc61e38e (diff) | |
| download | emacs-1ef7e5599f5aa981399221e657ff34e80cc2c1a3.tar.gz emacs-1ef7e5599f5aa981399221e657ff34e80cc2c1a3.zip | |
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-49
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 164-184)
- Update from CVS
- Merge from gnus--rel--5.10
- Update from CVS: man/mh-e.texi (Folders): Various edits.
- Update from erc--emacs--0
* gnus--rel--5.10 (patch 62-70)
- Merge from emacs--devo--0
- Update from CVS
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/editfns.c b/src/editfns.c index 7c2c2a8edd0..59401fdfecd 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -72,6 +72,8 @@ Boston, MA 02110-1301, USA. */ | |||
| 72 | extern char **environ; | 72 | extern char **environ; |
| 73 | #endif | 73 | #endif |
| 74 | 74 | ||
| 75 | #define TM_YEAR_BASE 1900 | ||
| 76 | |||
| 75 | extern size_t emacs_strftimeu P_ ((char *, size_t, const char *, | 77 | extern size_t emacs_strftimeu P_ ((char *, size_t, const char *, |
| 76 | const struct tm *, int)); | 78 | const struct tm *, int)); |
| 77 | static int tm_diff P_ ((struct tm *, struct tm *)); | 79 | static int tm_diff P_ ((struct tm *, struct tm *)); |
| @@ -719,7 +721,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) | |||
| 719 | int orig_point = 0; | 721 | int orig_point = 0; |
| 720 | int fwd; | 722 | int fwd; |
| 721 | Lisp_Object prev_old, prev_new; | 723 | Lisp_Object prev_old, prev_new; |
| 722 | 724 | ||
| 723 | if (NILP (new_pos)) | 725 | if (NILP (new_pos)) |
| 724 | /* Use the current point, and afterwards, set it. */ | 726 | /* Use the current point, and afterwards, set it. */ |
| 725 | { | 727 | { |
| @@ -734,7 +736,7 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */) | |||
| 734 | 736 | ||
| 735 | prev_old = make_number (XFASTINT (old_pos) - 1); | 737 | prev_old = make_number (XFASTINT (old_pos) - 1); |
| 736 | prev_new = make_number (XFASTINT (new_pos) - 1); | 738 | prev_new = make_number (XFASTINT (new_pos) - 1); |
| 737 | 739 | ||
| 738 | if (NILP (Vinhibit_field_text_motion) | 740 | if (NILP (Vinhibit_field_text_motion) |
| 739 | && !EQ (new_pos, old_pos) | 741 | && !EQ (new_pos, old_pos) |
| 740 | && (!NILP (Fget_char_property (new_pos, Qfield, Qnil)) | 742 | && (!NILP (Fget_char_property (new_pos, Qfield, Qnil)) |
| @@ -1720,7 +1722,9 @@ DOW and ZONE.) */) | |||
| 1720 | XSETFASTINT (list_args[2], decoded_time->tm_hour); | 1722 | XSETFASTINT (list_args[2], decoded_time->tm_hour); |
| 1721 | XSETFASTINT (list_args[3], decoded_time->tm_mday); | 1723 | XSETFASTINT (list_args[3], decoded_time->tm_mday); |
| 1722 | XSETFASTINT (list_args[4], decoded_time->tm_mon + 1); | 1724 | XSETFASTINT (list_args[4], decoded_time->tm_mon + 1); |
| 1723 | XSETINT (list_args[5], decoded_time->tm_year + 1900); | 1725 | /* On 64-bit machines an int is narrower than EMACS_INT, thus the |
| 1726 | cast below avoids overflow in int arithmetics. */ | ||
| 1727 | XSETINT (list_args[5], TM_YEAR_BASE + (EMACS_INT) decoded_time->tm_year); | ||
| 1724 | XSETFASTINT (list_args[6], decoded_time->tm_wday); | 1728 | XSETFASTINT (list_args[6], decoded_time->tm_wday); |
| 1725 | list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; | 1729 | list_args[7] = (decoded_time->tm_isdst)? Qt : Qnil; |
| 1726 | 1730 | ||
| @@ -1776,7 +1780,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) | |||
| 1776 | tm.tm_hour = XINT (args[2]); | 1780 | tm.tm_hour = XINT (args[2]); |
| 1777 | tm.tm_mday = XINT (args[3]); | 1781 | tm.tm_mday = XINT (args[3]); |
| 1778 | tm.tm_mon = XINT (args[4]) - 1; | 1782 | tm.tm_mon = XINT (args[4]) - 1; |
| 1779 | tm.tm_year = XINT (args[5]) - 1900; | 1783 | tm.tm_year = XINT (args[5]) - TM_YEAR_BASE; |
| 1780 | tm.tm_isdst = -1; | 1784 | tm.tm_isdst = -1; |
| 1781 | 1785 | ||
| 1782 | if (CONSP (zone)) | 1786 | if (CONSP (zone)) |
| @@ -1842,11 +1846,25 @@ but this is considered obsolete. */) | |||
| 1842 | { | 1846 | { |
| 1843 | time_t value; | 1847 | time_t value; |
| 1844 | char buf[30]; | 1848 | char buf[30]; |
| 1849 | struct tm *tm; | ||
| 1845 | register char *tem; | 1850 | register char *tem; |
| 1846 | 1851 | ||
| 1847 | if (! lisp_time_argument (specified_time, &value, NULL)) | 1852 | if (! lisp_time_argument (specified_time, &value, NULL)) |
| 1848 | value = -1; | 1853 | error ("Invalid time specification"); |
| 1849 | tem = (char *) ctime (&value); | 1854 | /* Do not use ctime, since it has undefined behavior with |
| 1855 | out-of-range time stamps. This avoids a core dump triggered by | ||
| 1856 | (current-time-string '(2814749767106 0)) on 64-bit Solaris 8. See | ||
| 1857 | <http://www.opengroup.org/austin/mailarchives/ag/msg09294.html> | ||
| 1858 | for more details about this portability problem. */ | ||
| 1859 | tm = localtime (&value); | ||
| 1860 | /* Checking for out-of-range time stamps avoids buffer overruns that | ||
| 1861 | cause core dump on some systems (e.g., 64-bit Solaris), and also | ||
| 1862 | preserves the historic behavior of always returning a fixed-size | ||
| 1863 | 24-character string. */ | ||
| 1864 | if (! (tm && -999 - TM_YEAR_BASE <= tm->tm_year | ||
| 1865 | && tm->tm_year <= 9999 - TM_YEAR_BASE)) | ||
| 1866 | error ("Specified time is not representable"); | ||
| 1867 | tem = asctime (tm); | ||
| 1850 | 1868 | ||
| 1851 | strncpy (buf, tem, 24); | 1869 | strncpy (buf, tem, 24); |
| 1852 | buf[24] = 0; | 1870 | buf[24] = 0; |
| @@ -1854,8 +1872,6 @@ but this is considered obsolete. */) | |||
| 1854 | return build_string (buf); | 1872 | return build_string (buf); |
| 1855 | } | 1873 | } |
| 1856 | 1874 | ||
| 1857 | #define TM_YEAR_BASE 1900 | ||
| 1858 | |||
| 1859 | /* Yield A - B, measured in seconds. | 1875 | /* Yield A - B, measured in seconds. |
| 1860 | This function is copied from the GNU C Library. */ | 1876 | This function is copied from the GNU C Library. */ |
| 1861 | static int | 1877 | static int |