APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1494529136 -3600
# Thu May 11 19:58:56 2017 +0100
# Node ID 50b05df76160d68a18c7afcaf4f66c0fb339dcbe
# Parent a0268c5597f37d95723b9570254be522f714986c
Work around type +/- template problems on the C++ build, text.h
src/ChangeLog addition:
2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
* alloc.c (resize_string):
Use set_string_byte() here for the zero termination.
* text.h:
Make string_byte(), set_string_byte() into inline functions to
work around g++ type (+/- template) difficulties with the macro
versions.
diff -r a0268c5597f3 -r 50b05df76160 src/ChangeLog
--- a/src/ChangeLog Thu May 11 08:13:08 2017 +0100
+++ b/src/ChangeLog Thu May 11 19:58:56 2017 +0100
@@ -1,3 +1,12 @@
+2017-05-11 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * alloc.c (resize_string):
+ Use set_string_byte() here for the zero termination.
+ * text.h:
+ Make string_byte(), set_string_byte() into inline functions to
+ work around g++ type (+/- template) difficulties with the macro
+ versions.
+
2017-04-27 Stephen J. Turnbull <stephen(a)xemacs.org>
* chartab.c (char_table_print_preprocess):
diff -r a0268c5597f3 -r 50b05df76160 src/alloc.c
--- a/src/alloc.c Thu May 11 08:13:08 2017 +0100
+++ b/src/alloc.c Thu May 11 19:58:56 2017 +0100
@@ -3143,7 +3143,7 @@
XSET_STRING_LENGTH (s, XSTRING_LENGTH (s) + delta);
/* If pos < 0, the string won't be zero-terminated.
Terminate now just to make sure. */
- XSTRING_DATA (s)[XSTRING_LENGTH (s)] = '\0';
+ set_string_byte (s, XSTRING_LENGTH (s), '\0');
if (pos >= 0)
/* We also have to adjust all of the extent indices after the
diff -r a0268c5597f3 -r 50b05df76160 src/text.h
--- a/src/text.h Thu May 11 08:13:08 2017 +0100
+++ b/src/text.h Thu May 11 19:58:56 2017 +0100
@@ -1935,11 +1935,24 @@
#define string_char_length(s) \
string_index_byte_to_char (s, XSTRING_LENGTH (s))
-/* Without the cast, C++ promotes the following expression to an int and then
- complains about a narrowing cast when it is used as an Ibyte. */
-#define string_byte(s, i) (Ibyte) (XSTRING_DATA (s)[i] + 0)
+
+DECLARE_INLINE_HEADER (
+Ibyte
+string_byte (Lisp_Object s, Bytecount i)
+)
+{
+ /* C++ deals with a macro version of this badly. */
+ return XSTRING_DATA (s)[i];
+}
/* In case we ever allow strings to be in a different format ... */
-#define set_string_byte(s, i, c) (XSTRING_DATA (s)[i] = (c))
+DECLARE_INLINE_HEADER (
+Ibyte
+set_string_byte(Lisp_Object s, Bytecount i, Ibyte c)
+)
+{
+ /* See above re C++. */
+ return XSTRING_DATA (s)[i] = (c);
+}
#define ASSERT_VALID_CHAR_STRING_INDEX_UNSAFE(s, x) do { \
text_checking_assert ((x) >= 0 && x <= string_char_length (s)); \
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)