aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjave2014-12-28 17:33:38 +0100
committerjave2014-12-28 17:33:38 +0100
commit703cbed72f82633cf3720ce8ad0523ea3af2c9f5 (patch)
treeb6ba0487fe9097e2efea4629d76c8661bd417c21 /src
parent5f46725992bf26f887483c14c63c03f5b5794f34 (diff)
parent807c3413c478be964f24b5ecc44712ce3358001e (diff)
downloademacs-703cbed72f82633cf3720ce8ad0523ea3af2c9f5.tar.gz
emacs-703cbed72f82633cf3720ce8ad0523ea3af2c9f5.zip
Merge branch 'master' into xwidget
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog28
-rw-r--r--src/callproc.c7
-rw-r--r--src/dbusbind.c2
-rw-r--r--src/doc.c33
-rw-r--r--src/editfns.c5
-rw-r--r--src/frame.c20
-rw-r--r--src/gtkutil.c6
-rw-r--r--src/keyboard.c2
-rw-r--r--src/nsselect.m3
-rw-r--r--src/tparam.c4
-rw-r--r--src/w32.c13
-rw-r--r--src/w32menu.c6
-rw-r--r--src/w32proc.c15
-rw-r--r--src/xfns.c34
-rw-r--r--src/xrdb.c44
-rw-r--r--src/xsmfns.c34
-rw-r--r--src/xterm.h2
17 files changed, 132 insertions, 126 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f6647826463..72601fe7c58 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,27 @@
12014-12-26 Eli Zaretskii <eliz@gnu.org>
2
3 * w32proc.c (sys_spawnve, get_lcid_callback): Use strcpy instead
4 of strcat.
5
6 * w32menu.c (add_menu_item): Use stpcpy instead of strcat.
7
8 * w32.c (sys_readdir, stat_worker, symlink): Use strcpy instead of
9 strcat.
10
112014-12-26 Paul Eggert <eggert@cs.ucla.edu>
12
13 Use bool for boolean in xsmfns.c
14 * xsmfns.c, xterm.h (x_session_have_connection):
15 * xsmfns.c (doing_interact, smc_interact_CB, Fhandle_save_session):
16 Use bool for boolean.
17 (x_session_initialize, Fhandle_save_session):
18 Prefer NILP (x) to EQ (x, Qnil).
19
202014-12-23 Didier Verna <didier@didierverna.net> (tiny change).
21
22 * nsselect.m (Fns_selection_owner_p): Return a Lisp boolean, not a
23 C one (Bug#19396).
24
12014-12-22 Jan Djärv <jan.h.d@swipnet.se> 252014-12-22 Jan Djärv <jan.h.d@swipnet.se>
2 26
3 * xterm.c (x_bitmap_icon): Partly revert change from 2014-03-21 which 27 * xterm.c (x_bitmap_icon): Partly revert change from 2014-03-21 which
@@ -197,6 +221,10 @@
197 Call gnutls_certificate_set_x509_system_trust. Log an error message if 221 Call gnutls_certificate_set_x509_system_trust. Log an error message if
198 it fails. 222 it fails.
199 223
2242014-12-14 Paul Eggert <eggert@cs.ucla.edu>
225
226 * regex.c (analyze_first): Rename from analyze_first.
227
2002014-12-13 Paul Eggert <eggert@cs.ucla.edu> 2282014-12-13 Paul Eggert <eggert@cs.ucla.edu>
201 229
202 * alloc.c (XMALLOC_BASE_ALIGNMENT): Use max_align_t instead of 230 * alloc.c (XMALLOC_BASE_ALIGNMENT): Use max_align_t instead of
diff --git a/src/callproc.c b/src/callproc.c
index a677334b3b7..f40ed3244a5 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1315,13 +1315,10 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1315 1315
1316 if (STRINGP (display)) 1316 if (STRINGP (display))
1317 { 1317 {
1318 char *vdata;
1319
1320 if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display)) 1318 if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display))
1321 exec_failed (new_argv[0], ENOMEM); 1319 exec_failed (new_argv[0], ENOMEM);
1322 vdata = alloca (sizeof "DISPLAY=" + SBYTES (display)); 1320 char *vdata = alloca (sizeof "DISPLAY=" + SBYTES (display));
1323 strcpy (vdata, "DISPLAY="); 1321 lispstpcpy (stpcpy (vdata, "DISPLAY="), display);
1324 strcat (vdata, SSDATA (display));
1325 new_env = add_env (env, new_env, vdata); 1322 new_env = add_env (env, new_env, vdata);
1326 } 1323 }
1327 1324
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 4852739d8e4..983b05c4206 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -357,7 +357,7 @@ xd_signature_cat (char *signature, char const *x)
357 ptrdiff_t xlen = strlen (x); 357 ptrdiff_t xlen = strlen (x);
358 if (DBUS_MAXIMUM_SIGNATURE_LENGTH - xlen <= siglen) 358 if (DBUS_MAXIMUM_SIGNATURE_LENGTH - xlen <= siglen)
359 string_overflow (); 359 string_overflow ();
360 strcat (signature, x); 360 strcpy (signature + siglen, x);
361} 361}
362 362
363/* Compute SIGNATURE of OBJECT. It must have a form that it can be 363/* Compute SIGNATURE of OBJECT. It must have a form that it can be
diff --git a/src/doc.c b/src/doc.c
index 1b87c23e949..1d9c330d12c 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -42,6 +42,8 @@ static ptrdiff_t get_doc_string_buffer_size;
42 42
43static unsigned char *read_bytecode_pointer; 43static unsigned char *read_bytecode_pointer;
44 44
45static char const sibling_etc[] = "../etc/";
46
45/* `readchar' in lread.c calls back here to fetch the next byte. 47/* `readchar' in lread.c calls back here to fetch the next byte.
46 If UNREADFLAG is 1, we unread a byte. */ 48 If UNREADFLAG is 1, we unread a byte. */
47 49
@@ -80,7 +82,6 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
80{ 82{
81 char *from, *to, *name, *p, *p1; 83 char *from, *to, *name, *p, *p1;
82 int fd; 84 int fd;
83 ptrdiff_t minsize;
84 int offset; 85 int offset;
85 EMACS_INT position; 86 EMACS_INT position;
86 Lisp_Object file, tem, pos; 87 Lisp_Object file, tem, pos;
@@ -113,21 +114,14 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
113 114
114 tem = Ffile_name_absolute_p (file); 115 tem = Ffile_name_absolute_p (file);
115 file = ENCODE_FILE (file); 116 file = ENCODE_FILE (file);
116 if (NILP (tem)) 117 Lisp_Object docdir
117 { 118 = NILP (tem) ? ENCODE_FILE (Vdoc_directory) : empty_unibyte_string;
118 Lisp_Object docdir = ENCODE_FILE (Vdoc_directory); 119 ptrdiff_t docdir_sizemax = SBYTES (docdir) + 1;
119 minsize = SCHARS (docdir); 120#ifndef CANNOT_DUMP
120 /* sizeof ("../etc/") == 8 */ 121 docdir_sizemax = max (docdir_sizemax, sizeof sibling_etc);
121 if (minsize < 8) 122#endif
122 minsize = 8; 123 name = SAFE_ALLOCA (docdir_sizemax + SBYTES (file));
123 name = SAFE_ALLOCA (minsize + SCHARS (file) + 8); 124 lispstpcpy (lispstpcpy (name, docdir), file);
124 char *z = lispstpcpy (name, docdir);
125 strcpy (z, SSDATA (file));
126 }
127 else
128 {
129 name = SSDATA (file);
130 }
131 125
132 fd = emacs_open (name, O_RDONLY, 0); 126 fd = emacs_open (name, O_RDONLY, 0);
133 if (fd < 0) 127 if (fd < 0)
@@ -137,8 +131,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool definition)
137 { 131 {
138 /* Preparing to dump; DOC file is probably not installed. 132 /* Preparing to dump; DOC file is probably not installed.
139 So check in ../etc. */ 133 So check in ../etc. */
140 strcpy (name, "../etc/"); 134 lispstpcpy (stpcpy (name, sibling_etc), file);
141 strcat (name, SSDATA (file));
142 135
143 fd = emacs_open (name, O_RDONLY, 0); 136 fd = emacs_open (name, O_RDONLY, 0);
144 } 137 }
@@ -580,7 +573,6 @@ the same file name is found in the `doc-directory'. */)
580 (0) 573 (0)
581#endif /* CANNOT_DUMP */ 574#endif /* CANNOT_DUMP */
582 { 575 {
583 static char const sibling_etc[] = "../etc/";
584 dirname = sibling_etc; 576 dirname = sibling_etc;
585 dirlen = sizeof sibling_etc - 1; 577 dirlen = sizeof sibling_etc - 1;
586 } 578 }
@@ -594,8 +586,7 @@ the same file name is found in the `doc-directory'. */)
594 count = SPECPDL_INDEX (); 586 count = SPECPDL_INDEX ();
595 USE_SAFE_ALLOCA; 587 USE_SAFE_ALLOCA;
596 name = SAFE_ALLOCA (dirlen + SBYTES (filename) + 1); 588 name = SAFE_ALLOCA (dirlen + SBYTES (filename) + 1);
597 strcpy (name, dirname); 589 lispstpcpy (stpcpy (name, dirname), filename); /*** Add this line ***/
598 strcat (name, SSDATA (filename)); /*** Add this line ***/
599 590
600 /* Vbuild_files is nil when temacs is run, and non-nil after that. */ 591 /* Vbuild_files is nil when temacs is run, and non-nil after that. */
601 if (NILP (Vbuild_files)) 592 if (NILP (Vbuild_files))
diff --git a/src/editfns.c b/src/editfns.c
index 0a07886934c..430c4c91fb3 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1350,10 +1350,9 @@ name, or nil if there is no such user. */)
1350 USE_SAFE_ALLOCA; 1350 USE_SAFE_ALLOCA;
1351 char *r = SAFE_ALLOCA (strlen (p) + SBYTES (login) + 1); 1351 char *r = SAFE_ALLOCA (strlen (p) + SBYTES (login) + 1);
1352 memcpy (r, p, q - p); 1352 memcpy (r, p, q - p);
1353 r[q - p] = 0; 1353 char *s = lispstpcpy (&r[q - p], login);
1354 strcat (r, SSDATA (login));
1355 r[q - p] = upcase ((unsigned char) r[q - p]); 1354 r[q - p] = upcase ((unsigned char) r[q - p]);
1356 strcat (r, q + 1); 1355 strcpy (s, q + 1);
1357 full = build_string (r); 1356 full = build_string (r);
1358 SAFE_FREE (); 1357 SAFE_FREE ();
1359 } 1358 }
diff --git a/src/frame.c b/src/frame.c
index 31273665e88..2ad1c1b52b7 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -4076,23 +4076,23 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, Li
4076 4076
4077 /* Start with emacs.FRAMENAME for the name (the specific one) 4077 /* Start with emacs.FRAMENAME for the name (the specific one)
4078 and with `Emacs' for the class key (the general one). */ 4078 and with `Emacs' for the class key (the general one). */
4079 lispstpcpy (name_key, Vx_resource_name); 4079 char *nz = lispstpcpy (name_key, Vx_resource_name);
4080 lispstpcpy (class_key, Vx_resource_class); 4080 char *cz = lispstpcpy (class_key, Vx_resource_class);
4081 4081
4082 strcat (class_key, "."); 4082 *cz++ = '.';
4083 strcat (class_key, SSDATA (class)); 4083 cz = lispstpcpy (cz, class);
4084 4084
4085 if (!NILP (component)) 4085 if (!NILP (component))
4086 { 4086 {
4087 strcat (class_key, "."); 4087 *cz++ = '.';
4088 strcat (class_key, SSDATA (subclass)); 4088 lispstpcpy (cz, subclass);
4089 4089
4090 strcat (name_key, "."); 4090 *nz++ = '.';
4091 strcat (name_key, SSDATA (component)); 4091 nz = lispstpcpy (nz, component);
4092 } 4092 }
4093 4093
4094 strcat (name_key, "."); 4094 *nz++ = '.';
4095 strcat (name_key, SSDATA (attribute)); 4095 lispstpcpy (nz, attribute);
4096 4096
4097 char *value = x_get_string_resource (rdb, name_key, class_key); 4097 char *value = x_get_string_resource (rdb, name_key, class_key);
4098 SAFE_FREE(); 4098 SAFE_FREE();
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 9465d5479df..f61cbc2c85c 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1839,12 +1839,12 @@ xg_get_file_with_chooser (struct frame *f,
1839 1839
1840 if (x_gtk_file_dialog_help_text) 1840 if (x_gtk_file_dialog_help_text)
1841 { 1841 {
1842 msgbuf[0] = '\0'; 1842 char *z = msgbuf;
1843 /* Gtk+ 2.10 has the file name text entry box integrated in the dialog. 1843 /* Gtk+ 2.10 has the file name text entry box integrated in the dialog.
1844 Show the C-l help text only for versions < 2.10. */ 1844 Show the C-l help text only for versions < 2.10. */
1845 if (gtk_check_version (2, 10, 0) && action != GTK_FILE_CHOOSER_ACTION_SAVE) 1845 if (gtk_check_version (2, 10, 0) && action != GTK_FILE_CHOOSER_ACTION_SAVE)
1846 strcat (msgbuf, "\nType C-l to display a file name text entry box.\n"); 1846 z = stpcpy (z, "\nType C-l to display a file name text entry box.\n");
1847 strcat (msgbuf, "\nIf you don't like this file selector, use the " 1847 strcpy (z, "\nIf you don't like this file selector, use the "
1848 "corresponding\nkey binding or customize " 1848 "corresponding\nkey binding or customize "
1849 "use-file-dialog to turn it off."); 1849 "use-file-dialog to turn it off.");
1850 1850
diff --git a/src/keyboard.c b/src/keyboard.c
index 215b6ea3f70..41cb5df6776 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -276,7 +276,7 @@ bool input_pending;
276/* True if more input was available last time we read an event. 276/* True if more input was available last time we read an event.
277 277
278 Since redisplay can take a significant amount of time and is not 278 Since redisplay can take a significant amount of time and is not
279 indispensible to perform the user's commands, when input arrives 279 indispensable to perform the user's commands, when input arrives
280 "too fast", Emacs skips redisplay. More specifically, if the next 280 "too fast", Emacs skips redisplay. More specifically, if the next
281 command has already been input when we finish the previous command, 281 command has already been input when we finish the previous command,
282 we skip the intermediate redisplay. 282 we skip the intermediate redisplay.
diff --git a/src/nsselect.m b/src/nsselect.m
index 3b33a97ca73..8863bd27f16 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -438,7 +438,8 @@ On Nextstep, TERMINAL is unused. */)
438 if (EQ (selection, Qnil)) selection = QPRIMARY; 438 if (EQ (selection, Qnil)) selection = QPRIMARY;
439 if (EQ (selection, Qt)) selection = QSECONDARY; 439 if (EQ (selection, Qt)) selection = QSECONDARY;
440 return ns_get_pb_change_count (selection) 440 return ns_get_pb_change_count (selection)
441 == ns_get_our_change_count_for (selection); 441 == ns_get_our_change_count_for (selection)
442 ? Qt : Qnil;
442} 443}
443 444
444 445
diff --git a/src/tparam.c b/src/tparam.c
index e02cea3689e..b0cd0047ba2 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -255,9 +255,9 @@ tparam1 (const char *string, char *outstring, int len,
255 } 255 }
256 *op = 0; 256 *op = 0;
257 while (doup-- > 0) 257 while (doup-- > 0)
258 strcat (op, up); 258 op = stpcpy (op, up);
259 while (doleft-- > 0) 259 while (doleft-- > 0)
260 strcat (op, left); 260 op = stpcpy (op, left);
261 return outstring; 261 return outstring;
262} 262}
263 263
diff --git a/src/w32.c b/src/w32.c
index 8d8f536ca40..6dea0c2a811 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3405,10 +3405,10 @@ sys_readdir (DIR *dirp)
3405 int ln; 3405 int ln;
3406 3406
3407 strcpy (filename, dir_pathname); 3407 strcpy (filename, dir_pathname);
3408 ln = strlen (filename) - 1; 3408 ln = strlen (filename);
3409 if (!IS_DIRECTORY_SEP (filename[ln])) 3409 if (!IS_DIRECTORY_SEP (filename[ln - 1]))
3410 strcat (filename, "\\"); 3410 filename[ln++] = '\\';
3411 strcat (filename, "*"); 3411 strcpy (filename + ln, "*");
3412 3412
3413 /* Note: No need to resolve symlinks in FILENAME, because 3413 /* Note: No need to resolve symlinks in FILENAME, because
3414 FindFirst opens the directory that is the target of a 3414 FindFirst opens the directory that is the target of a
@@ -4969,7 +4969,7 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks)
4969 { 4969 {
4970 /* Make sure root directories end in a slash. */ 4970 /* Make sure root directories end in a slash. */
4971 if (!IS_DIRECTORY_SEP (name[len-1])) 4971 if (!IS_DIRECTORY_SEP (name[len-1]))
4972 strcat (name, "\\"); 4972 strcpy (name + len, "\\");
4973 if (GetDriveType (name) < 2) 4973 if (GetDriveType (name) < 2)
4974 { 4974 {
4975 errno = ENOENT; 4975 errno = ENOENT;
@@ -5438,8 +5438,7 @@ symlink (char const *filename, char const *linkname)
5438 p--; 5438 p--;
5439 if (p > linkfn) 5439 if (p > linkfn)
5440 strncpy (tem, linkfn, p - linkfn); 5440 strncpy (tem, linkfn, p - linkfn);
5441 tem[p - linkfn] = '\0'; 5441 strcpy (tem + (p - linkfn), filename);
5442 strcat (tem, filename);
5443 dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); 5442 dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS);
5444 } 5443 }
5445 else 5444 else
diff --git a/src/w32menu.c b/src/w32menu.c
index 6633ffddbcf..287062c702c 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1256,9 +1256,9 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1256 if (wv->key != NULL) 1256 if (wv->key != NULL)
1257 { 1257 {
1258 out_string = SAFE_ALLOCA (strlen (wv->name) + strlen (wv->key) + 2); 1258 out_string = SAFE_ALLOCA (strlen (wv->name) + strlen (wv->key) + 2);
1259 strcpy (out_string, wv->name); 1259 p = stpcpy (out_string, wv->name);
1260 strcat (out_string, "\t"); 1260 p = stpcpy (p, "\t");
1261 strcat (out_string, wv->key); 1261 strcpy (p, wv->key);
1262 } 1262 }
1263 else 1263 else
1264 out_string = (char *)wv->name; 1264 out_string = (char *)wv->name;
diff --git a/src/w32proc.c b/src/w32proc.c
index 09e0c0530a4..c571726d70f 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1665,10 +1665,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
1665 if (egetenv ("CMDPROXY")) 1665 if (egetenv ("CMDPROXY"))
1666 strcpy (cmdname, egetenv ("CMDPROXY")); 1666 strcpy (cmdname, egetenv ("CMDPROXY"));
1667 else 1667 else
1668 { 1668 strcpy (lispstpcpy (cmdname, Vinvocation_directory), "cmdproxy.exe");
1669 lispstpcpy (cmdname, Vinvocation_directory);
1670 strcat (cmdname, "cmdproxy.exe");
1671 }
1672 1669
1673 /* Can't use unixtodos_filename here, since that needs its file 1670 /* Can't use unixtodos_filename here, since that needs its file
1674 name argument encoded in UTF-8. */ 1671 name argument encoded in UTF-8. */
@@ -3183,18 +3180,20 @@ get_lcid_callback (LPTSTR locale_num_str)
3183 if (GetLocaleInfo (try_lcid, LOCALE_SABBREVLANGNAME, 3180 if (GetLocaleInfo (try_lcid, LOCALE_SABBREVLANGNAME,
3184 locval, LOCALE_NAME_MAX_LENGTH)) 3181 locval, LOCALE_NAME_MAX_LENGTH))
3185 { 3182 {
3183 size_t locval_len;
3184
3186 /* This is for when they only specify the language, as in "ENU". */ 3185 /* This is for when they only specify the language, as in "ENU". */
3187 if (stricmp (locval, lname) == 0) 3186 if (stricmp (locval, lname) == 0)
3188 { 3187 {
3189 found_lcid = try_lcid; 3188 found_lcid = try_lcid;
3190 return FALSE; 3189 return FALSE;
3191 } 3190 }
3192 strcat (locval, "_"); 3191 locval_len = strlen (locval);
3192 strcpy (locval + locval_len, "_");
3193 if (GetLocaleInfo (try_lcid, LOCALE_SABBREVCTRYNAME, 3193 if (GetLocaleInfo (try_lcid, LOCALE_SABBREVCTRYNAME,
3194 locval + strlen (locval), LOCALE_NAME_MAX_LENGTH)) 3194 locval + locval_len + 1, LOCALE_NAME_MAX_LENGTH))
3195 { 3195 {
3196 size_t locval_len = strlen (locval); 3196 locval_len = strlen (locval);
3197
3198 if (strnicmp (locval, lname, locval_len) == 0 3197 if (strnicmp (locval, lname, locval_len) == 0
3199 && (lname[locval_len] == '.' 3198 && (lname[locval_len] == '.'
3200 || lname[locval_len] == '\0')) 3199 || lname[locval_len] == '\0'))
diff --git a/src/xfns.c b/src/xfns.c
index 1b17311f99c..ba2601daca4 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1710,13 +1710,14 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1710{ 1710{
1711 const char *sep = motif ? ";" : ","; 1711 const char *sep = motif ? ";" : ",";
1712 char *fontsetname; 1712 char *fontsetname;
1713 char *z;
1713 1714
1714 /* Make a fontset name from the base font name. */ 1715 /* Make a fontset name from the base font name. */
1715 if (xic_default_fontset == base_fontname) 1716 if (xic_default_fontset == base_fontname)
1716 { 1717 {
1717 /* There is no base font name, use the default. */ 1718 /* There is no base font name, use the default. */
1718 fontsetname = xmalloc (strlen (base_fontname) + 2); 1719 fontsetname = xmalloc (strlen (base_fontname) + 2);
1719 strcpy (fontsetname, base_fontname); 1720 z = stpcpy (fontsetname, base_fontname);
1720 } 1721 }
1721 else 1722 else
1722 { 1723 {
@@ -1737,9 +1738,9 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1737 Use the specified font plus the default. */ 1738 Use the specified font plus the default. */
1738 fontsetname = xmalloc (strlen (base_fontname) 1739 fontsetname = xmalloc (strlen (base_fontname)
1739 + strlen (xic_default_fontset) + 3); 1740 + strlen (xic_default_fontset) + 3);
1740 strcpy (fontsetname, base_fontname); 1741 z = stpcpy (fontsetname, base_fontname);
1741 strcat (fontsetname, sep); 1742 z = stpcpy (z, sep);
1742 strcat (fontsetname, xic_default_fontset); 1743 z = stpcpy (z, xic_default_fontset);
1743 } 1744 }
1744 else 1745 else
1745 { 1746 {
@@ -1800,27 +1801,26 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1800 /* Build the font spec that matches all. */ 1801 /* Build the font spec that matches all. */
1801 len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1; 1802 len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 1;
1802 font_all = alloca (len); 1803 font_all = alloca (len);
1803 strcpy (font_all, allfamilies); 1804 z = stpcpy (font_all, allfamilies);
1804 strcat (font_all, all); 1805 z = stpcpy (z, all);
1805 memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2); 1806 memcpy (z, p2, p - p2);
1806 strcpy (font_all + strlen (all) + strlen (allfamilies) + (p - p2), 1807 strcpy (z + (p - p2), allcs);
1807 allcs);
1808 1808
1809 /* Build the actual font set name. */ 1809 /* Build the actual font set name. */
1810 len = strlen (base_fontname) + strlen (font_allcs) 1810 len = strlen (base_fontname) + strlen (font_allcs)
1811 + strlen (font_allfamilies) + strlen (font_all) + 5; 1811 + strlen (font_allfamilies) + strlen (font_all) + 5;
1812 fontsetname = xmalloc (len); 1812 fontsetname = xmalloc (len);
1813 strcpy (fontsetname, base_fontname); 1813 z = stpcpy (fontsetname, base_fontname);
1814 strcat (fontsetname, sep); 1814 z = stpcpy (z, sep);
1815 strcat (fontsetname, font_allcs); 1815 z = stpcpy (z, font_allcs);
1816 strcat (fontsetname, sep); 1816 z = stpcpy (z, sep);
1817 strcat (fontsetname, font_allfamilies); 1817 z = stpcpy (z, font_allfamilies);
1818 strcat (fontsetname, sep); 1818 z = stpcpy (z, sep);
1819 strcat (fontsetname, font_all); 1819 z = stpcpy (z, font_all);
1820 } 1820 }
1821 } 1821 }
1822 if (motif) 1822 if (motif)
1823 return strcat (fontsetname, ":"); 1823 strcpy (z, ":");
1824 return fontsetname; 1824 return fontsetname;
1825} 1825}
1826#endif /* HAVE_X_WINDOWS && USE_X_TOOLKIT */ 1826#endif /* HAVE_X_WINDOWS && USE_X_TOOLKIT */
diff --git a/src/xrdb.c b/src/xrdb.c
index 32ad3c7f01e..e21206d0800 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -232,9 +232,10 @@ gethomedir (void)
232 if (ptr == NULL) 232 if (ptr == NULL)
233 return xstrdup ("/"); 233 return xstrdup ("/");
234 234
235 copy = xmalloc (strlen (ptr) + 2); 235 ptrdiff_t len = strlen (ptr);
236 strcpy (copy, ptr); 236 copy = xmalloc (len + 2);
237 return strcat (copy, "/"); 237 strcpy (copy + len, "/");
238 return memcpy (copy, ptr, len);
238} 239}
239 240
240 241
@@ -334,6 +335,7 @@ get_user_app (const char *class)
334 return db; 335 return db;
335} 336}
336 337
338static char const xdefaults[] = ".Xdefaults";
337 339
338static XrmDatabase 340static XrmDatabase
339get_user_db (Display *display) 341get_user_db (Display *display)
@@ -351,16 +353,12 @@ get_user_db (Display *display)
351 db = XrmGetStringDatabase (xdefs); 353 db = XrmGetStringDatabase (xdefs);
352 else 354 else
353 { 355 {
354 char *home; 356 char *home = gethomedir ();
355 char *xdefault; 357 ptrdiff_t homelen = strlen (home);
356 358 char *filename = xrealloc (home, homelen + sizeof xdefaults);
357 home = gethomedir (); 359 strcpy (filename + homelen, xdefaults);
358 xdefault = xmalloc (strlen (home) + sizeof ".Xdefaults"); 360 db = XrmGetFileDatabase (filename);
359 strcpy (xdefault, home); 361 xfree (filename);
360 strcat (xdefault, ".Xdefaults");
361 db = XrmGetFileDatabase (xdefault);
362 xfree (home);
363 xfree (xdefault);
364 } 362 }
365 363
366#ifdef HAVE_XSCREENRESOURCESTRING 364#ifdef HAVE_XSCREENRESOURCESTRING
@@ -380,24 +378,22 @@ static XrmDatabase
380get_environ_db (void) 378get_environ_db (void)
381{ 379{
382 XrmDatabase db; 380 XrmDatabase db;
383 char *p; 381 char *p = getenv ("XENVIRONMENT");
384 char *path = 0; 382 char *filename = 0;
385 383
386 if ((p = getenv ("XENVIRONMENT")) == NULL) 384 if (!p)
387 { 385 {
388 static char const xdefaults[] = ".Xdefaults-";
389 char *home = gethomedir (); 386 char *home = gethomedir ();
390 char const *host = SSDATA (Vsystem_name); 387 ptrdiff_t homelen = strlen (home);
391 ptrdiff_t pathsize = (strlen (home) + sizeof xdefaults 388 ptrdiff_t filenamesize = (homelen + sizeof xdefaults
392 + SBYTES (Vsystem_name)); 389 + SBYTES (Vsystem_name));
393 path = xrealloc (home, pathsize); 390 p = filename = xrealloc (home, filenamesize);
394 strcat (strcat (path, xdefaults), host); 391 lispstpcpy (stpcpy (filename + homelen, xdefaults), Vsystem_name);
395 p = path;
396 } 392 }
397 393
398 db = XrmGetFileDatabase (p); 394 db = XrmGetFileDatabase (p);
399 395
400 xfree (path); 396 xfree (filename);
401 397
402 return db; 398 return db;
403} 399}
diff --git a/src/xsmfns.c b/src/xsmfns.c
index cd4f9ce57fa..a6c69855390 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -53,7 +53,7 @@ static int ice_fd = -1;
53 53
54/* A flag that says if we are in shutdown interactions or not. */ 54/* A flag that says if we are in shutdown interactions or not. */
55 55
56static int doing_interact; 56static bool doing_interact;
57 57
58/* The session manager object for the session manager connection. */ 58/* The session manager object for the session manager connection. */
59 59
@@ -123,9 +123,9 @@ x_session_check_input (int fd, void *data)
123 kbd_buffer_store_event (&emacs_event); 123 kbd_buffer_store_event (&emacs_event);
124} 124}
125 125
126/* Return non-zero if we have a connection to a session manager. */ 126/* Return true if we have a connection to a session manager. */
127 127
128int 128bool
129x_session_have_connection (void) 129x_session_have_connection (void)
130{ 130{
131 return ice_fd != -1; 131 return ice_fd != -1;
@@ -138,7 +138,7 @@ x_session_have_connection (void)
138static void 138static void
139smc_interact_CB (SmcConn smcConn, SmPointer clientData) 139smc_interact_CB (SmcConn smcConn, SmPointer clientData)
140{ 140{
141 doing_interact = True; 141 doing_interact = true;
142 emacs_event.kind = SAVE_SESSION_EVENT; 142 emacs_event.kind = SAVE_SESSION_EVENT;
143 emacs_event.arg = Qnil; 143 emacs_event.arg = Qnil;
144} 144}
@@ -230,8 +230,7 @@ smc_save_yourself_CB (SmcConn smcConn,
230 props[props_idx]->vals[vp_idx++].value = emacs_program; 230 props[props_idx]->vals[vp_idx++].value = emacs_program;
231 231
232 smid_opt = xmalloc (strlen (SMID_OPT) + strlen (client_id) + 1); 232 smid_opt = xmalloc (strlen (SMID_OPT) + strlen (client_id) + 1);
233 strcpy (smid_opt, SMID_OPT); 233 strcpy (stpcpy (smid_opt, SMID_OPT), client_id);
234 strcat (smid_opt, client_id);
235 234
236 props[props_idx]->vals[vp_idx].length = strlen (smid_opt); 235 props[props_idx]->vals[vp_idx].length = strlen (smid_opt);
237 props[props_idx]->vals[vp_idx++].value = smid_opt; 236 props[props_idx]->vals[vp_idx++].value = smid_opt;
@@ -242,8 +241,7 @@ smc_save_yourself_CB (SmcConn smcConn,
242 if (cwd) 241 if (cwd)
243 { 242 {
244 chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1); 243 chdir_opt = xmalloc (strlen (CHDIR_OPT) + strlen (cwd) + 1);
245 strcpy (chdir_opt, CHDIR_OPT); 244 strcpy (stpcpy (chdir_opt, CHDIR_OPT), cwd);
246 strcat (chdir_opt, cwd);
247 245
248 props[props_idx]->vals[vp_idx].length = strlen (chdir_opt); 246 props[props_idx]->vals[vp_idx].length = strlen (chdir_opt);
249 props[props_idx]->vals[vp_idx++].value = chdir_opt; 247 props[props_idx]->vals[vp_idx++].value = chdir_opt;
@@ -400,15 +398,15 @@ x_session_initialize (struct x_display_info *dpyinfo)
400 ptrdiff_t name_len = 0; 398 ptrdiff_t name_len = 0;
401 399
402 ice_fd = -1; 400 ice_fd = -1;
403 doing_interact = False; 401 doing_interact = false;
404 402
405 /* Check if we where started by the session manager. If so, we will 403 /* Check if we where started by the session manager. If so, we will
406 have a previous id. */ 404 have a previous id. */
407 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) 405 if (! NILP (Vx_session_previous_id) && STRINGP (Vx_session_previous_id))
408 previous_id = SSDATA (Vx_session_previous_id); 406 previous_id = SSDATA (Vx_session_previous_id);
409 407
410 /* Construct the path to the Emacs program. */ 408 /* Construct the path to the Emacs program. */
411 if (! EQ (Vinvocation_directory, Qnil)) 409 if (! NILP (Vinvocation_directory))
412 name_len += SBYTES (Vinvocation_directory); 410 name_len += SBYTES (Vinvocation_directory);
413 name_len += SBYTES (Vinvocation_name); 411 name_len += SBYTES (Vinvocation_name);
414 412
@@ -417,7 +415,7 @@ x_session_initialize (struct x_display_info *dpyinfo)
417 emacs_program = xmalloc (name_len + 1); 415 emacs_program = xmalloc (name_len + 1);
418 char *z = emacs_program; 416 char *z = emacs_program;
419 417
420 if (! EQ (Vinvocation_directory, Qnil)) 418 if (! NILP (Vinvocation_directory))
421 z = lispstpcpy (z, Vinvocation_directory); 419 z = lispstpcpy (z, Vinvocation_directory);
422 lispstpcpy (z, Vinvocation_name); 420 lispstpcpy (z, Vinvocation_name);
423 421
@@ -491,21 +489,19 @@ is told to abort the window system shutdown.
491Do not call this function yourself. */) 489Do not call this function yourself. */)
492 (Lisp_Object event) 490 (Lisp_Object event)
493{ 491{
494 int kill_emacs = CONSP (event) && CONSP (XCDR (event)) 492 bool kill_emacs = (CONSP (event) && CONSP (XCDR (event))
495 && EQ (Qt, XCAR (XCDR (event))); 493 && EQ (Qt, XCAR (XCDR (event))));
496 494
497 /* Check doing_interact so that we don't do anything if someone called 495 /* Check doing_interact so that we don't do anything if someone called
498 this at the wrong time. */ 496 this at the wrong time. */
499 if (doing_interact && ! kill_emacs) 497 if (doing_interact && ! kill_emacs)
500 { 498 {
501 Bool cancel_shutdown = False; 499 bool cancel_shutdown = ! NILP (call0 (intern ("emacs-session-save")));
502
503 cancel_shutdown = ! EQ (call0 (intern ("emacs-session-save")), Qnil);
504 500
505 SmcInteractDone (smc_conn, cancel_shutdown); 501 SmcInteractDone (smc_conn, cancel_shutdown);
506 SmcSaveYourselfDone (smc_conn, True); 502 SmcSaveYourselfDone (smc_conn, True);
507 503
508 doing_interact = False; 504 doing_interact = false;
509 } 505 }
510 else if (kill_emacs) 506 else if (kill_emacs)
511 { 507 {
@@ -513,7 +509,7 @@ Do not call this function yourself. */)
513 prevent. Fix this in next version. */ 509 prevent. Fix this in next version. */
514 Fkill_emacs (Qnil); 510 Fkill_emacs (Qnil);
515 511
516#if 0 512#if false
517 /* This will not be reached, but we want kill-emacs-hook to be run. */ 513 /* This will not be reached, but we want kill-emacs-hook to be run. */
518 SmcCloseConnection (smc_conn, 0, 0); 514 SmcCloseConnection (smc_conn, 0, 0);
519 ice_connection_closed (); 515 ice_connection_closed ();
diff --git a/src/xterm.h b/src/xterm.h
index 31c3261e3b9..84bb58c7232 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1107,7 +1107,7 @@ extern void initialize_frame_menubar (struct frame *);
1107/* Defined in xsmfns.c */ 1107/* Defined in xsmfns.c */
1108#ifdef HAVE_X_SM 1108#ifdef HAVE_X_SM
1109extern void x_session_initialize (struct x_display_info *dpyinfo); 1109extern void x_session_initialize (struct x_display_info *dpyinfo);
1110extern int x_session_have_connection (void); 1110extern bool x_session_have_connection (void);
1111extern void x_session_close (void); 1111extern void x_session_close (void);
1112#endif 1112#endif
1113 1113