]> code.delx.au - gnu-emacs/blobdiff - src/editfns.c
Merge from emacs--rel--22
[gnu-emacs] / src / editfns.c
index a6f275c8f8db971653f377fc30b0b77505d1b5b1..98ab2f9008149f7a022bd447d8965113c88450f5 100644 (file)
@@ -7,7 +7,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -84,6 +84,11 @@ extern char **environ;
 
 extern size_t emacs_strftimeu P_ ((char *, size_t, const char *,
                                   const struct tm *, int));
+
+#ifdef WINDOWSNT
+extern Lisp_Object w32_get_internal_run_time ();
+#endif
+
 static int tm_diff P_ ((struct tm *, struct tm *));
 static void find_field P_ ((Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *));
 static void update_buffer_properties P_ ((int, int));
@@ -274,7 +279,9 @@ clip_to_bounds (lower, num, upper)
 
 DEFUN ("goto-char", Fgoto_char, Sgoto_char, 1, 1, "NGoto char: ",
        doc: /* Set point to POSITION, a number or marker.
-Beginning of buffer is position (point-min), end is (point-max).  */)
+Beginning of buffer is position (point-min), end is (point-max).
+
+The return value is POSITION.  */)
      (position)
      register Lisp_Object position;
 {
@@ -1481,9 +1488,13 @@ on systems that do not provide resolution finer than a second.  */)
   return list3 (make_number ((secs >> 16) & 0xffff),
                make_number ((secs >> 0)  & 0xffff),
                make_number (usecs));
-#else
+#else /* ! HAVE_GETRUSAGE  */
+#if WINDOWSNT
+  return w32_get_internal_run_time ();
+#else /* ! WINDOWSNT  */
   return Fcurrent_time ();
-#endif
+#endif /* WINDOWSNT  */
+#endif /* HAVE_GETRUSAGE  */
 }
 \f
 
@@ -1837,7 +1848,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE)  */)
        tzstring = (char *) SDATA (zone);
       else if (INTEGERP (zone))
        {
-         int abszone = abs (XINT (zone));
+         int abszone = eabs (XINT (zone));
          sprintf (tzbuf, "XXX%s%d:%02d:%02d", "-" + (XINT (zone) < 0),
                   abszone / (60*60), (abszone/60) % 60, abszone % 60);
          tzstring = tzbuf;
@@ -1972,6 +1983,7 @@ the data it can't find.  */)
       int offset = tm_diff (t, &gmt);
       char *s = 0;
       char buf[6];
+
 #ifdef HAVE_TM_ZONE
       if (t->tm_zone)
        s = (char *)t->tm_zone;
@@ -1982,19 +1994,6 @@ the data it can't find.  */)
 #endif
 #endif /* not HAVE_TM_ZONE */
 
-#if defined HAVE_TM_ZONE || defined HAVE_TZNAME
-      if (s)
-       {
-         /* On Japanese w32, we can get a Japanese string as time
-            zone name.  Don't accept that.  */
-         char *p;
-         for (p = s; *p && (isalnum ((unsigned char)*p) || *p == ' '); ++p)
-           ;
-         if (p == s || *p)
-           s = NULL;
-       }
-#endif
-
       if (!s)
        {
          /* No local time zone name is available; use "+-NNNN" instead.  */
@@ -2002,6 +2001,7 @@ the data it can't find.  */)
          sprintf (buf, "%c%02d%02d", (offset < 0 ? '-' : '+'), am/60, am%60);
          s = buf;
        }
+
       return Fcons (make_number (offset), Fcons (build_string (s), Qnil));
     }
   else
@@ -3040,7 +3040,7 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region,
 {
   validate_region (&start, &end);
   if (XINT (start) == XINT (end))
-    return build_string ("");
+    return empty_unibyte_string;
   return del_range_1 (XINT (start), XINT (end), 1, 1);
 }
 \f
@@ -3514,7 +3514,7 @@ usage: (format STRING &rest OBJECTS)  */)
           precision    ::= '.' [0-9]*
 
           If a field-width is specified, it specifies to which width
-          the output should be padded with blanks, iff the output
+          the output should be padded with blanks, if the output
           string is shorter than field-width.
 
           If precision is specified, it specifies the number of
@@ -4112,12 +4112,12 @@ Transposing beyond buffer boundaries is an error.  */)
      (startr1, endr1, startr2, endr2, leave_markers)
      Lisp_Object startr1, endr1, startr2, endr2, leave_markers;
 {
-  register int start1, end1, start2, end2;
-  int start1_byte, start2_byte, len1_byte, len2_byte;
-  int gap, len1, len_mid, len2;
+  register EMACS_INT start1, end1, start2, end2;
+  EMACS_INT start1_byte, start2_byte, len1_byte, len2_byte;
+  EMACS_INT gap, len1, len_mid, len2;
   unsigned char *start1_addr, *start2_addr, *temp;
 
-  INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2;
+  INTERVAL cur_intv, tmp_interval1, tmp_interval_mid, tmp_interval2, tmp_interval3;
   Lisp_Object buf;
 
   XSETBUFFER (buf, current_buffer);
@@ -4229,8 +4229,9 @@ Transposing beyond buffer boundaries is an error.  */)
       tmp_interval2 = copy_intervals (cur_intv, start2, len2);
       /* Don't use Fset_text_properties: that can cause GC, which can
         clobber objects stored in the tmp_intervals.  */
-      set_text_properties_1 (make_number (start1), make_number (end2),
-                            Qnil, buf, NULL);
+      tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0);
+      if (!NULL_INTERVAL_P (tmp_interval3))
+       set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
 
       /* First region smaller than second.  */
       if (len1_byte < len2_byte)
@@ -4286,10 +4287,14 @@ Transposing beyond buffer boundaries is an error.  */)
           record_change (start2, len2);
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
           tmp_interval2 = copy_intervals (cur_intv, start2, len2);
-         set_text_properties_1 (make_number (start1), make_number (end1),
-                                Qnil, buf, NULL);
-          set_text_properties_1 (make_number (start2), make_number (end2),
-                                Qnil, buf, NULL);
+
+         tmp_interval3 = validate_interval_range (buf, &startr1, &endr1, 0);
+         if (!NULL_INTERVAL_P (tmp_interval3))
+           set_text_properties_1 (startr1, endr1, Qnil, buf, tmp_interval3);
+
+         tmp_interval3 = validate_interval_range (buf, &startr2, &endr2, 0);
+         if (!NULL_INTERVAL_P (tmp_interval3))
+           set_text_properties_1 (startr2, endr2, Qnil, buf, tmp_interval3);
 
          SAFE_ALLOCA (temp, unsigned char *, len1_byte);
          start1_addr = BYTE_POS_ADDR (start1_byte);
@@ -4315,8 +4320,10 @@ Transposing beyond buffer boundaries is an error.  */)
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
           tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);
           tmp_interval2 = copy_intervals (cur_intv, start2, len2);
-          set_text_properties_1 (make_number (start1), make_number (end2),
-                                Qnil, buf, NULL);
+
+         tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0);
+         if (!NULL_INTERVAL_P (tmp_interval3))
+           set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
 
          /* holds region 2 */
          SAFE_ALLOCA (temp, unsigned char *, len2_byte);
@@ -4346,8 +4353,10 @@ Transposing beyond buffer boundaries is an error.  */)
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
           tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);
           tmp_interval2 = copy_intervals (cur_intv, start2, len2);
-          set_text_properties_1 (make_number (start1), make_number (end2),
-                                Qnil, buf, NULL);
+
+         tmp_interval3 = validate_interval_range (buf, &startr1, &endr2, 0);
+         if (!NULL_INTERVAL_P (tmp_interval3))
+           set_text_properties_1 (startr1, endr2, Qnil, buf, tmp_interval3);
 
          /* holds region 1 */
          SAFE_ALLOCA (temp, unsigned char *, len1_byte);
@@ -4382,8 +4391,7 @@ Transposing beyond buffer boundaries is an error.  */)
       fix_start_end_in_overlays (start1, end2);
     }
 
-  signal_after_change (XINT (start1), XINT (end2 - start1),
-                      XINT (end2 - start1));
+  signal_after_change (start1, end2 - start1, end2 - start1);
   return Qnil;
 }