aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-07-31 09:46:45 -0700
committerPaul Eggert2015-07-31 09:47:19 -0700
commit8a7a99e0280103e223b8e1a717107bdf9b8eabc7 (patch)
treebd6794e32994e43745d8764fc252f98c458b7562 /src
parentf5fc5cd5c207a4fc3bdde381ad4f74c8fe6bb5d6 (diff)
downloademacs-8a7a99e0280103e223b8e1a717107bdf9b8eabc7.tar.gz
emacs-8a7a99e0280103e223b8e1a717107bdf9b8eabc7.zip
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).
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c26
-rw-r--r--src/xrdb.c17
2 files changed, 23 insertions, 20 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 6bd123c6710..91cca8e477e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7481,18 +7481,19 @@ menu_bar_items (Lisp_Object old)
7481 properties may not work reliable, as they are only 7481 properties may not work reliable, as they are only
7482 recognized when the menu-bar (or mode-line) is updated, 7482 recognized when the menu-bar (or mode-line) is updated,
7483 which does not normally happen after every command. */ 7483 which does not normally happen after every command. */
7484 Lisp_Object tem; 7484 ptrdiff_t nminor = current_minor_maps (NULL, &tmaps);
7485 ptrdiff_t nminor;
7486 nminor = current_minor_maps (NULL, &tmaps);
7487 SAFE_NALLOCA (maps, 1, nminor + 4); 7485 SAFE_NALLOCA (maps, 1, nminor + 4);
7488 nmaps = 0; 7486 nmaps = 0;
7489 tem = KVAR (current_kboard, Voverriding_terminal_local_map); 7487 Lisp_Object tem = KVAR (current_kboard, Voverriding_terminal_local_map);
7490 if (!NILP (tem) && !NILP (Voverriding_local_map_menu_flag)) 7488 if (!NILP (tem) && !NILP (Voverriding_local_map_menu_flag))
7491 maps[nmaps++] = tem; 7489 maps[nmaps++] = tem;
7492 if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) 7490 if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem))
7493 maps[nmaps++] = tem; 7491 maps[nmaps++] = tem;
7494 memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0])); 7492 if (nminor != 0)
7495 nmaps += nminor; 7493 {
7494 memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0]));
7495 nmaps += nminor;
7496 }
7496 maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map); 7497 maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map);
7497 } 7498 }
7498 maps[nmaps++] = current_global_map; 7499 maps[nmaps++] = current_global_map;
@@ -8030,18 +8031,19 @@ tool_bar_items (Lisp_Object reuse, int *nitems)
8030 properties may not work reliable, as they are only 8031 properties may not work reliable, as they are only
8031 recognized when the tool-bar (or mode-line) is updated, 8032 recognized when the tool-bar (or mode-line) is updated,
8032 which does not normally happen after every command. */ 8033 which does not normally happen after every command. */
8033 Lisp_Object tem; 8034 ptrdiff_t nminor = current_minor_maps (NULL, &tmaps);
8034 ptrdiff_t nminor;
8035 nminor = current_minor_maps (NULL, &tmaps);
8036 SAFE_NALLOCA (maps, 1, nminor + 4); 8035 SAFE_NALLOCA (maps, 1, nminor + 4);
8037 nmaps = 0; 8036 nmaps = 0;
8038 tem = KVAR (current_kboard, Voverriding_terminal_local_map); 8037 Lisp_Object tem = KVAR (current_kboard, Voverriding_terminal_local_map);
8039 if (!NILP (tem) && !NILP (Voverriding_local_map_menu_flag)) 8038 if (!NILP (tem) && !NILP (Voverriding_local_map_menu_flag))
8040 maps[nmaps++] = tem; 8039 maps[nmaps++] = tem;
8041 if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem)) 8040 if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem))
8042 maps[nmaps++] = tem; 8041 maps[nmaps++] = tem;
8043 memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0])); 8042 if (nminor != 0)
8044 nmaps += nminor; 8043 {
8044 memcpy (maps + nmaps, tmaps, nminor * sizeof (maps[0]));
8045 nmaps += nminor;
8046 }
8045 maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map); 8047 maps[nmaps++] = get_local_map (PT, current_buffer, Qlocal_map);
8046 } 8048 }
8047 8049
diff --git a/src/xrdb.c b/src/xrdb.c
index 9e85e5a6277..2235b4535da 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,
119 while (p < string + string_len) 119 while (p < string + string_len)
120 { 120 {
121 /* The chunk we're about to stick on the end of result. */ 121 /* The chunk we're about to stick on the end of result. */
122 const char *next = NULL; 122 const char *next = p;
123 ptrdiff_t next_len; 123 ptrdiff_t next_len = 1;
124 124
125 if (*p == '%') 125 if (*p == '%')
126 { 126 {
@@ -137,10 +137,13 @@ magic_db (const char *string, ptrdiff_t string_len, const char *class,
137 break; 137 break;
138 138
139 case 'C': 139 case 'C':
140 next = (x_customization_string 140 if (x_customization_string)
141 ? x_customization_string 141 {
142 : ""); 142 next = x_customization_string;
143 next_len = strlen (next); 143 next_len = strlen (next);
144 }
145 else
146 next_len = 0;
144 break; 147 break;
145 148
146 case 'N': 149 case 'N':
@@ -176,8 +179,6 @@ magic_db (const char *string, ptrdiff_t string_len, const char *class,
176 return NULL; 179 return NULL;
177 } 180 }
178 } 181 }
179 else
180 next = p, next_len = 1;
181 182
182 /* Do we have room for this component followed by a '\0'? */ 183 /* Do we have room for this component followed by a '\0'? */
183 if (path_size - path_len <= next_len) 184 if (path_size - path_len <= next_len)