aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c46
-rw-r--r--src/filelock.c13
-rw-r--r--src/minibuf.c18
-rw-r--r--src/process.c24
-rw-r--r--src/xdisp.c18
5 files changed, 51 insertions, 68 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 62b0bc8c6f4..0e5e64f58a1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1051,44 +1051,36 @@ it is in the sequence to be tried) even if a buffer with that name exists.
1051If NAME begins with a space (i.e., a buffer that is not normally 1051If NAME begins with a space (i.e., a buffer that is not normally
1052visible to users), then if buffer NAME already exists a random number 1052visible to users), then if buffer NAME already exists a random number
1053is first appended to NAME, to speed up finding a non-existent buffer. */) 1053is first appended to NAME, to speed up finding a non-existent buffer. */)
1054 (register Lisp_Object name, Lisp_Object ignore) 1054 (Lisp_Object name, Lisp_Object ignore)
1055{ 1055{
1056 register Lisp_Object gentemp, tem, tem2; 1056 Lisp_Object genbase;
1057 ptrdiff_t count;
1058 char number[INT_BUFSIZE_BOUND (ptrdiff_t) + sizeof "<>"];
1059 1057
1060 CHECK_STRING (name); 1058 CHECK_STRING (name);
1061 1059
1062 tem = Fstring_equal (name, ignore); 1060 if (!NILP (Fstring_equal (name, ignore)) || NILP (Fget_buffer (name)))
1063 if (!NILP (tem))
1064 return name;
1065 tem = Fget_buffer (name);
1066 if (NILP (tem))
1067 return name; 1061 return name;
1068 1062
1069 if (!strncmp (SSDATA (name), " ", 1)) /* see bug#1229 */ 1063 if (SREF (name, 0) != ' ') /* See bug#1229. */
1064 genbase = name;
1065 else
1070 { 1066 {
1071 /* Note fileio.c:make_temp_name does random differently. */ 1067 /* Note fileio.c:make_temp_name does random differently. */
1072 tem2 = concat2 (name, make_formatted_string 1068 char number[sizeof "-999999"];
1073 (number, "-%"pI"d", 1069 int i = XFASTINT (Frandom (make_number (999999)));
1074 XFASTINT (Frandom (make_number (999999))))); 1070 AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d", i));
1075 tem = Fget_buffer (tem2); 1071 genbase = concat2 (name, lnumber);
1076 if (NILP (tem)) 1072 if (NILP (Fget_buffer (genbase)))
1077 return tem2; 1073 return genbase;
1078 } 1074 }
1079 else
1080 tem2 = name;
1081 1075
1082 count = 1; 1076 for (ptrdiff_t count = 1; ; count++)
1083 while (1)
1084 { 1077 {
1085 gentemp = concat2 (tem2, make_formatted_string 1078 char number[INT_BUFSIZE_BOUND (ptrdiff_t) + sizeof "<>"];
1086 (number, "<%"pD"d>", ++count)); 1079 AUTO_STRING_WITH_LEN (lnumber, number,
1087 tem = Fstring_equal (gentemp, ignore); 1080 sprintf (number, "<%"pD"d>", count));
1088 if (!NILP (tem)) 1081 Lisp_Object gentemp = concat2 (genbase, lnumber);
1089 return gentemp; 1082 if (!NILP (Fstring_equal (gentemp, ignore))
1090 tem = Fget_buffer (gentemp); 1083 || NILP (Fget_buffer (gentemp)))
1091 if (NILP (tem))
1092 return gentemp; 1084 return gentemp;
1093 } 1085 }
1094} 1086}
diff --git a/src/filelock.c b/src/filelock.c
index 4c5d72ddb95..c58484a639b 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -191,14 +191,11 @@ get_boot_time (void)
191 /* If we did not find a boot time in wtmp, look at wtmp, and so on. */ 191 /* If we did not find a boot time in wtmp, look at wtmp, and so on. */
192 for (counter = 0; counter < 20 && ! boot_time; counter++) 192 for (counter = 0; counter < 20 && ! boot_time; counter++)
193 { 193 {
194 Lisp_Object filename = Qnil;
195 bool delete_flag = false;
194 char cmd_string[sizeof WTMP_FILE ".19.gz"]; 196 char cmd_string[sizeof WTMP_FILE ".19.gz"];
195 Lisp_Object tempname, filename; 197 AUTO_STRING_WITH_LEN (tempname, cmd_string,
196 bool delete_flag = 0; 198 sprintf (cmd_string, "%s.%d", WTMP_FILE, counter));
197
198 filename = Qnil;
199
200 tempname = make_formatted_string
201 (cmd_string, "%s.%d", WTMP_FILE, counter);
202 if (! NILP (Ffile_exists_p (tempname))) 199 if (! NILP (Ffile_exists_p (tempname)))
203 filename = tempname; 200 filename = tempname;
204 else 201 else
@@ -218,7 +215,7 @@ get_boot_time (void)
218 CALLN (Fcall_process, build_string ("gzip"), Qnil, 215 CALLN (Fcall_process, build_string ("gzip"), Qnil,
219 list2 (QCfile, filename), Qnil, 216 list2 (QCfile, filename), Qnil,
220 build_string ("-cd"), tempname); 217 build_string ("-cd"), tempname);
221 delete_flag = 1; 218 delete_flag = true;
222 } 219 }
223 } 220 }
224 221
diff --git a/src/minibuf.c b/src/minibuf.c
index 41814c2b54b..644e5276fe0 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -742,27 +742,25 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
742} 742}
743 743
744/* Return a buffer to be used as the minibuffer at depth `depth'. 744/* Return a buffer to be used as the minibuffer at depth `depth'.
745 depth = 0 is the lowest allowed argument, and that is the value 745 depth = 0 is the lowest allowed argument, and that is the value
746 used for nonrecursive minibuffer invocations. */ 746 used for nonrecursive minibuffer invocations. */
747 747
748Lisp_Object 748Lisp_Object
749get_minibuffer (EMACS_INT depth) 749get_minibuffer (EMACS_INT depth)
750{ 750{
751 Lisp_Object tail, num, buf; 751 Lisp_Object tail = Fnthcdr (make_number (depth), Vminibuffer_list);
752 char name[sizeof " *Minibuf-*" + INT_STRLEN_BOUND (EMACS_INT)];
753
754 XSETFASTINT (num, depth);
755 tail = Fnthcdr (num, Vminibuffer_list);
756 if (NILP (tail)) 752 if (NILP (tail))
757 { 753 {
758 tail = list1 (Qnil); 754 tail = list1 (Qnil);
759 Vminibuffer_list = nconc2 (Vminibuffer_list, tail); 755 Vminibuffer_list = nconc2 (Vminibuffer_list, tail);
760 } 756 }
761 buf = Fcar (tail); 757 Lisp_Object buf = Fcar (tail);
762 if (NILP (buf) || !BUFFER_LIVE_P (XBUFFER (buf))) 758 if (NILP (buf) || !BUFFER_LIVE_P (XBUFFER (buf)))
763 { 759 {
764 buf = Fget_buffer_create 760 static char const name_fmt[] = " *Minibuf-%"pI"d*";
765 (make_formatted_string (name, " *Minibuf-%"pI"d*", depth)); 761 char name[sizeof name_fmt + INT_STRLEN_BOUND (EMACS_INT)];
762 AUTO_STRING_WITH_LEN (lname, name, sprintf (name, name_fmt, depth));
763 buf = Fget_buffer_create (lname);
766 764
767 /* Although the buffer's name starts with a space, undo should be 765 /* Although the buffer's name starts with a space, undo should be
768 enabled in it. */ 766 enabled in it. */
diff --git a/src/process.c b/src/process.c
index 399cd8accde..a006ca61ac5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -675,12 +675,7 @@ allocate_process (void)
675static Lisp_Object 675static Lisp_Object
676make_process (Lisp_Object name) 676make_process (Lisp_Object name)
677{ 677{
678 register Lisp_Object val, tem, name1; 678 struct Lisp_Process *p = allocate_process ();
679 register struct Lisp_Process *p;
680 char suffix[sizeof "<>" + INT_STRLEN_BOUND (printmax_t)];
681 printmax_t i;
682
683 p = allocate_process ();
684 /* Initialize Lisp data. Note that allocate_process initializes all 679 /* Initialize Lisp data. Note that allocate_process initializes all
685 Lisp data to nil, so do it only for slots which should not be nil. */ 680 Lisp data to nil, so do it only for slots which should not be nil. */
686 pset_status (p, Qrun); 681 pset_status (p, Qrun);
@@ -690,7 +685,7 @@ make_process (Lisp_Object name)
690 non-Lisp data, so do it only for slots which should not be zero. */ 685 non-Lisp data, so do it only for slots which should not be zero. */
691 p->infd = -1; 686 p->infd = -1;
692 p->outfd = -1; 687 p->outfd = -1;
693 for (i = 0; i < PROCESS_OPEN_FDS; i++) 688 for (int i = 0; i < PROCESS_OPEN_FDS; i++)
694 p->open_fd[i] = -1; 689 p->open_fd[i] = -1;
695 690
696#ifdef HAVE_GNUTLS 691#ifdef HAVE_GNUTLS
@@ -700,17 +695,22 @@ make_process (Lisp_Object name)
700 695
701 /* If name is already in use, modify it until it is unused. */ 696 /* If name is already in use, modify it until it is unused. */
702 697
703 name1 = name; 698 Lisp_Object name1 = name;
704 for (i = 1; ; i++) 699 for (printmax_t i = 1; ; i++)
705 { 700 {
706 tem = Fget_process (name1); 701 Lisp_Object tem = Fget_process (name1);
707 if (NILP (tem)) break; 702 if (NILP (tem))
708 name1 = concat2 (name, make_formatted_string (suffix, "<%"pMd">", i)); 703 break;
704 char const suffix_fmt[] = "<%"pMd">";
705 char suffix[sizeof suffix_fmt + INT_STRLEN_BOUND (printmax_t)];
706 AUTO_STRING_WITH_LEN (lsuffix, suffix, sprintf (suffix, suffix_fmt, i));
707 name1 = concat2 (name, lsuffix);
709 } 708 }
710 name = name1; 709 name = name1;
711 pset_name (p, name); 710 pset_name (p, name);
712 pset_sentinel (p, Qinternal_default_process_sentinel); 711 pset_sentinel (p, Qinternal_default_process_sentinel);
713 pset_filter (p, Qinternal_default_process_filter); 712 pset_filter (p, Qinternal_default_process_filter);
713 Lisp_Object val;
714 XSETPROCESS (val, p); 714 XSETPROCESS (val, p);
715 Vprocess_alist = Fcons (Fcons (name, val), Vprocess_alist); 715 Vprocess_alist = Fcons (Fcons (name, val), Vprocess_alist);
716 return val; 716 return val;
diff --git a/src/xdisp.c b/src/xdisp.c
index 9b7ac3c0460..4f33c0d518a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10528,25 +10528,21 @@ update_echo_area (void)
10528static void 10528static void
10529ensure_echo_area_buffers (void) 10529ensure_echo_area_buffers (void)
10530{ 10530{
10531 int i; 10531 for (int i = 0; i < 2; i++)
10532
10533 for (i = 0; i < 2; ++i)
10534 if (!BUFFERP (echo_buffer[i]) 10532 if (!BUFFERP (echo_buffer[i])
10535 || !BUFFER_LIVE_P (XBUFFER (echo_buffer[i]))) 10533 || !BUFFER_LIVE_P (XBUFFER (echo_buffer[i])))
10536 { 10534 {
10537 char name[30]; 10535 Lisp_Object old_buffer = echo_buffer[i];
10538 Lisp_Object old_buffer; 10536 static char const name_fmt[] = " *Echo Area %d*";
10539 int j; 10537 char name[sizeof name_fmt + INT_STRLEN_BOUND (int)];
10540 10538 AUTO_STRING_WITH_LEN (lname, name, sprintf (name, name_fmt, i));
10541 old_buffer = echo_buffer[i]; 10539 echo_buffer[i] = Fget_buffer_create (lname);
10542 echo_buffer[i] = Fget_buffer_create
10543 (make_formatted_string (name, " *Echo Area %d*", i));
10544 bset_truncate_lines (XBUFFER (echo_buffer[i]), Qnil); 10540 bset_truncate_lines (XBUFFER (echo_buffer[i]), Qnil);
10545 /* to force word wrap in echo area - 10541 /* to force word wrap in echo area -
10546 it was decided to postpone this*/ 10542 it was decided to postpone this*/
10547 /* XBUFFER (echo_buffer[i])->word_wrap = Qt; */ 10543 /* XBUFFER (echo_buffer[i])->word_wrap = Qt; */
10548 10544
10549 for (j = 0; j < 2; ++j) 10545 for (int j = 0; j < 2; j++)
10550 if (EQ (old_buffer, echo_area_buffer[j])) 10546 if (EQ (old_buffer, echo_area_buffer[j]))
10551 echo_area_buffer[j] = echo_buffer[i]; 10547 echo_area_buffer[j] = echo_buffer[i];
10552 } 10548 }