[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 8a7a99e 2/2: Port to pedantic memcpy
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] master 8a7a99e 2/2: Port to pedantic memcpy |
Date: |
Fri, 31 Jul 2015 16:47:32 +0000 |
branch: master
commit 8a7a99e0280103e223b8e1a717107bdf9b8eabc7
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
Port to pedantic memcpy
* src/keyboard.c (menu_bar_items, tool_bar_items):
* src/xrdb.c (magic_db):
Port to pedantic memcpy implementations that reject memcpy (0, 0, 0).
---
src/keyboard.c | 26 ++++++++++++++------------
src/xrdb.c | 17 +++++++++--------
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/keyboard.c b/src/keyboard.c
index 6bd123c..91cca8e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7481,18 +7481,19 @@ menu_bar_items (Lisp_Object old)
properties may not work reliable, as they are only
recognized when the menu-bar (or mode-line) is updated,
which does not normally happen after every command. */
- Lisp_Object tem;
- ptrdiff_t nminor;
- nminor = current_minor_maps (NULL, &tmaps);
+ ptrdiff_t nminor = current_minor_maps (NULL, &tmaps);
SAFE_NALLOCA (maps, 1, nminor + 4);
nmaps = 0;
- tem = KVAR (current_kboard, Voverriding_terminal_local_map);
+ Lisp_Object tem = KVAR (current_kboard, Voverriding_terminal_local_map);
if (!NILP (tem) && !NILP (Voverriding_local_map_menu_flag))
maps[nmaps++] = tem;
if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem))
maps[nmaps++] = tem;
- memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0]));
- nmaps += nminor;
+ if (nminor != 0)
+ {
+ memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0]));
+ nmaps += nminor;
+ }
maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map);
}
maps[nmaps++] = current_global_map;
@@ -8030,18 +8031,19 @@ tool_bar_items (Lisp_Object reuse, int *nitems)
properties may not work reliable, as they are only
recognized when the tool-bar (or mode-line) is updated,
which does not normally happen after every command. */
- Lisp_Object tem;
- ptrdiff_t nminor;
- nminor = current_minor_maps (NULL, &tmaps);
+ ptrdiff_t nminor = current_minor_maps (NULL, &tmaps);
SAFE_NALLOCA (maps, 1, nminor + 4);
nmaps = 0;
- tem = KVAR (current_kboard, Voverriding_terminal_local_map);
+ Lisp_Object tem = KVAR (current_kboard, Voverriding_terminal_local_map);
if (!NILP (tem) && !NILP (Voverriding_local_map_menu_flag))
maps[nmaps++] = tem;
if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem))
maps[nmaps++] = tem;
- memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0]));
- nmaps += nminor;
+ if (nminor != 0)
+ {
+ memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0]));
+ nmaps += nminor;
+ }
maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map);
}
diff --git a/src/xrdb.c b/src/xrdb.c
index 9e85e5a..2235b45 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -119,8 +119,8 @@ magic_db (const char *string, ptrdiff_t string_len, const
char *class,
while (p < string + string_len)
{
/* The chunk we're about to stick on the end of result. */
- const char *next = NULL;
- ptrdiff_t next_len;
+ const char *next = p;
+ ptrdiff_t next_len = 1;
if (*p == '%')
{
@@ -137,10 +137,13 @@ magic_db (const char *string, ptrdiff_t string_len, const
char *class,
break;
case 'C':
- next = (x_customization_string
- ? x_customization_string
- : "");
- next_len = strlen (next);
+ if (x_customization_string)
+ {
+ next = x_customization_string;
+ next_len = strlen (next);
+ }
+ else
+ next_len = 0;
break;
case 'N':
@@ -176,8 +179,6 @@ magic_db (const char *string, ptrdiff_t string_len, const
char *class,
return NULL;
}
}
- else
- next = p, next_len = 1;
/* Do we have room for this component followed by a '\0'? */
if (path_size - path_len <= next_len)