X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Feditfns.c;h=8ad18f53e0210628136c3f3fb8357a2538a4776b;hb=f2d21161ddfc8df9e30d7d1ba57c526833f9ae2d;hp=7a8df46362427d305988bf1d92ed9ea53c5b263a;hpb=98a6e4055a1fa624c592ac06f79287d55196ca37;p=chise%2Fxemacs-chise.git.1 diff --git a/src/editfns.c b/src/editfns.c index 7a8df46..8ad18f5 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -36,6 +36,7 @@ Boston, MA 02111-1307, USA. */ #include "frame.h" #include "insdel.h" #include "window.h" +#include "casetab.h" #include "chartab.h" #include "line-number.h" @@ -636,20 +637,24 @@ On Unix it is obtained from TMPDIR, with /tmp as the default. { mkdir(path, 0700); /* ignore retval -- checked next anyway. */ } - if (lstat(path, &st) == 0 && st.st_uid == myuid && S_ISDIR(st.st_mode)) + if (lstat(path, &st) == 0 && st.st_uid == (uid_t) myuid && + S_ISDIR(st.st_mode)) { tmpdir = path; } else { - strcpy(path, getenv("HOME")); strncat(path, "/tmp/", _POSIX_PATH_MAX); + path[5 + _POSIX_PATH_MAX] = '\0'; + strncpy(path, getenv("HOME"), 5 + _POSIX_PATH_MAX); + strncat(path, "/tmp/", 5 + _POSIX_PATH_MAX); if (stat(path, &st) < 0 && errno == ENOENT) { int fd; - char warnpath[1+_POSIX_PATH_MAX]; + char warnpath[6+_POSIX_PATH_MAX]; mkdir(path, 0700); /* ignore retvals */ - strcpy(warnpath, path); - strncat(warnpath, ".created_by_xemacs", _POSIX_PATH_MAX); + warnpath[_POSIX_PATH_MAX] = '\0'; + strncpy(warnpath, path, 5 + _POSIX_PATH_MAX); + strncat(warnpath, ".created_by_xemacs", 5 + _POSIX_PATH_MAX); if ((fd = open(warnpath, O_WRONLY|O_CREAT, 0644)) > 0) { write(fd, "XEmacs created this directory because /tmp/ was unavailable -- \nPlease check !\n", 89); @@ -823,7 +828,7 @@ value of `user-full-name' is returned. #endif tem = ((!NILP (user) && !pw) ? Qnil - : make_ext_string ((Extbyte *) p, (q ? q - p : strlen (p)), + : make_ext_string ((Extbyte *) p, (q ? q - p : (int) strlen (p)), Qnative)); #ifdef AMPERSAND_FULL_NAME @@ -1105,10 +1110,11 @@ characters appearing in the day and month names may be incorrect. { time_t value; size_t size; + struct tm * tm; CHECK_STRING (format_string); - if (! lisp_to_time (time_, &value)) + if (! lisp_to_time (time_, &value) || ! (tm = localtime (&value))) error ("Invalid time specification"); /* This is probably enough. */ @@ -1120,7 +1126,7 @@ characters appearing in the day and month names may be incorrect. *buf = 1; if (emacs_strftime (buf, size, (const char *) XSTRING_DATA (format_string), - localtime (&value)) + tm) || !*buf) return build_ext_string (buf, Qbinary); /* If buffer was too small, make it bigger. */ @@ -1149,10 +1155,10 @@ ZONE is an integer indicating the number of seconds east of Greenwich. struct tm *decoded_time; Lisp_Object list_args[9]; - if (! lisp_to_time (specified_time, &time_spec)) + if (! lisp_to_time (specified_time, &time_spec) + || ! (decoded_time = localtime (&time_spec))) error ("Invalid time specification"); - decoded_time = localtime (&time_spec); list_args[0] = make_int (decoded_time->tm_sec); list_args[1] = make_int (decoded_time->tm_min); list_args[2] = make_int (decoded_time->tm_hour); @@ -1174,6 +1180,15 @@ ZONE is an integer indicating the number of seconds east of Greenwich. static void set_time_zone_rule (char *tzstring); +/* from GNU Emacs 21, per Simon Josefsson, modified by stephen + The slight inefficiency is justified since negative times are weird. */ +Lisp_Object +make_time (time_t tval) +{ + return list2 (make_int (tval < 0 ? tval / 0x10000 : tval >> 16), + make_int (tval & 0xFFFF)); +} + DEFUN ("encode-time", Fencode_time, 6, MANY, 0, /* Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time. This is the reverse operation of `decode-time', which see. @@ -1247,7 +1262,7 @@ If you want them to stand for years in this century, you must do that yourself. if (the_time == (time_t) -1) error ("Specified time is not representable"); - return wasteful_word_to_lisp (the_time); + return make_time (the_time); } DEFUN ("current-time-string", Fcurrent_time_string, 0, 1, 0, /* @@ -1489,7 +1504,6 @@ buffer_insert1 (struct buffer *buf, Lisp_Object arg) arg = wrong_type_argument (Qchar_or_string_p, arg); goto retry; } - zmacs_region_stays = 0; UNGCPRO; } @@ -1550,7 +1564,6 @@ Any other markers at the point of insertion also end up after the text. goto retry; } } - zmacs_region_stays = 0; return Qnil; } @@ -1566,7 +1579,6 @@ BUFFER defaults to the current buffer. struct buffer *b = decode_buffer (buffer, 1); CHECK_STRING (string); buffer_insert_lisp_string (b, string); - zmacs_region_stays = 0; return Qnil; } @@ -1637,7 +1649,6 @@ text into. If BUFFER is nil, the current buffer is assumed. buffer_insert_raw_string (b, string, n); #endif - zmacs_region_stays = 0; return Qnil; } @@ -1717,7 +1728,7 @@ determines whether case is significant or ignored. REGISTER Charcount len1, len2, length, i; struct buffer *bp1, *bp2; Lisp_Object trt = ((!NILP (current_buffer->case_fold_search)) ? - current_buffer->case_canon_table : Qnil); + XCASE_TABLE_CANON (current_buffer->case_table) : Qnil); /* Find the first buffer and its substring. */ @@ -2003,7 +2014,6 @@ If optional third arg BUFFER is nil, the current buffer is assumed. get_buffer_range_char (buf, start, end, &bp_start, &bp_end, 0); buffer_delete_range (buf, bp_start, bp_end, 0); - zmacs_region_stays = 0; return Qnil; } @@ -2040,7 +2050,6 @@ If BUFFER is nil, the current buffer is assumed. { struct buffer *b = decode_buffer (buffer, 1); widen_buffer (b, 0); - zmacs_region_stays = 0; return Qnil; } @@ -2076,7 +2085,6 @@ or markers) bounding the text that should remain visible. /* Changing the buffer bounds invalidates any recorded current column. */ invalidate_current_column (); narrow_line_number_cache (buf); - zmacs_region_stays = 0; return Qnil; }