if (CTAGS)
if (append_to_tagfile || update)
{
- char *cmd = xmalloc (2 * strlen (tagfile) + sizeof "sort -u -o..");
/* Maybe these should be used:
setenv ("LC_COLLATE", "C", 1);
setenv ("LC_ALL", "C", 1); */
- char *z = stpcpy (cmd, "sort -u -o ");
- z = stpcpy (z, tagfile);
- *z++ = ' ';
- strcpy (z, tagfile);
+ char *cmd = xmalloc (8 * strlen (tagfile) + sizeof "sort -u -o '' ''");
+ char *z = stpcpy (cmd, "sort -u -o '");
+ char *escaped_tagfile = z;
+ for (; *tagfile; *z++ = *tagfile++)
+ if (*tagfile == '\'')
+ z = stpcpy (z, "'\\'");
+ ptrdiff_t escaped_tagfile_len = z - escaped_tagfile;
+ z = stpcpy (z, "' '");
+ z = mempcpy (z, escaped_tagfile, escaped_tagfile_len);
+ strcpy (z, "'");
return system (cmd);
}
return EXIT_SUCCESS;
size_t origpos;
origpos = pos;
- while (s + pos != NULL && (c_isalnum (s[pos]) || s[pos] == '_')) ++pos;
+ while (c_isalnum (s[pos]) || s[pos] == '_')
+ pos++;
unsigned char decl_type_length = pos - origpos;
char buf[decl_type_length + 1];
so this is the hard case. */
if (strcmp (buf, "solver") == 0)
{
- ++pos;
- while (s + pos != NULL && (c_isalnum (s[pos]) || s[pos] == '_'))
- ++pos;
+ do
+ pos++;
+ while (c_isalnum (s[pos]) || s[pos] == '_');
decl_type_length = pos - origpos;
char buf2[decl_type_length + 1];
while (c_isalnum (s[pos])
|| s[pos] == '_'
|| (s[pos] == '.' /* A module dot. */
- && s + pos + 1 != NULL
&& (c_isalnum (s[pos + 1]) || s[pos + 1] == '_')
&& (module_dot_pos = pos))) /* Record module dot position.
Erase module from name. */
}
else if (is_mercury_quantifier && s[pos] == '[') /* :- some [T] pred/func. */
{
- for (++pos; s + pos != NULL && s[pos] != ']'; ++pos) {}
- if (s + pos == NULL) return null_pos;
- ++pos;
- pos = skip_spaces (s + pos) - s;
+ char *close_bracket = strchr (s + pos + 1, ']');
+ if (!close_bracket)
+ return null_pos;
+ pos = skip_spaces (close_bracket + 1) - s;
mercury_pos_t position = mercury_decl (s, pos);
position.totlength += pos - origpos;
return position;
return;
MALLOC_BLOCK_INPUT;
+#ifndef GC_MALLOC_CHECK
+ struct mem_node *m = mem_find (block);
+#endif
free (block);
#ifndef GC_MALLOC_CHECK
- mem_delete (mem_find (block));
+ mem_delete (m);
#endif
MALLOC_UNBLOCK_INPUT;
}
value = Fgethash (key, Vdbus_registered_objects_table, Qnil);
/* Loop over the registered functions. Construct an event. */
- while (!NILP (value))
+ for (; !NILP (value); value = CDR_SAFE (value))
{
key = CAR_SAFE (value);
+ Lisp_Object key_uname = CAR_SAFE (key);
/* key has the structure (UNAME SERVICE PATH HANDLER). */
- if (((uname == NULL)
- || (NILP (CAR_SAFE (key)))
- || (strcmp (uname, SSDATA (CAR_SAFE (key))) == 0))
- && ((path == NULL)
- || (NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (key)))))
- || (strcmp (path,
- SSDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key)))))
- == 0))
- && (!NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))))))
- {
- EVENT_INIT (event);
- event.kind = DBUS_EVENT;
- event.frame_or_window = Qnil;
- /* Handler. */
- event.arg
- = Fcons (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))), args);
- break;
- }
- value = CDR_SAFE (value);
+ if (uname && !NILP (key_uname)
+ && strcmp (uname, SSDATA (key_uname)) != 0)
+ continue;
+ Lisp_Object key_service_etc = CDR_SAFE (key);
+ Lisp_Object key_path_etc = CDR_SAFE (key_service_etc);
+ Lisp_Object key_path = CAR_SAFE (key_path_etc);
+ if (path && !NILP (key_path)
+ && strcmp (path, SSDATA (key_path)) != 0)
+ continue;
+ Lisp_Object handler = CAR_SAFE (CDR_SAFE (key_path_etc));
+ if (NILP (handler))
+ continue;
+
+ /* Construct an event and exit the loop. */
+ EVENT_INIT (event);
+ event.kind = DBUS_EVENT;
+ event.frame_or_window = Qnil;
+ event.arg = Fcons (handler, args);
+ break;
}
if (NILP (value))
{
if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target))
return;
- eassume (source && target);
COPY_INTERVAL_CACHE (source, target);
set_interval_plist (target, Fcopy_sequence (source->plist));
void (*) (INTERVAL, void *), void *);
extern INTERVAL split_interval_right (INTERVAL, ptrdiff_t)
ATTRIBUTE_RETURNS_NONNULL;
-extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t);
+extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t) ATTRIBUTE_RETURNS_NONNULL;
extern INTERVAL find_interval (INTERVAL, ptrdiff_t);
extern INTERVAL next_interval (INTERVAL);
extern INTERVAL previous_interval (INTERVAL);
return REG_ESIZE; \
ptrdiff_t b_off = b - old_buffer; \
ptrdiff_t begalt_off = begalt - old_buffer; \
- bool fixup_alt_jump_set = !!fixup_alt_jump; \
- bool laststart_set = !!laststart; \
- bool pending_exact_set = !!pending_exact; \
- ptrdiff_t fixup_alt_jump_off, laststart_off, pending_exact_off; \
- if (fixup_alt_jump_set) fixup_alt_jump_off = fixup_alt_jump - old_buffer; \
- if (laststart_set) laststart_off = laststart - old_buffer; \
- if (pending_exact_set) pending_exact_off = pending_exact - old_buffer; \
+ ptrdiff_t fixup_alt_jump_off = \
+ fixup_alt_jump ? fixup_alt_jump - old_buffer : -1; \
+ ptrdiff_t laststart_off = laststart ? laststart - old_buffer : -1; \
+ ptrdiff_t pending_exact_off = \
+ pending_exact ? pending_exact - old_buffer : -1; \
bufp->buffer = xpalloc (bufp->buffer, &bufp->allocated, \
requested_extension, MAX_BUF_SIZE, 1); \
unsigned char *new_buffer = bufp->buffer; \
b = new_buffer + b_off; \
begalt = new_buffer + begalt_off; \
- if (fixup_alt_jump_set) fixup_alt_jump = new_buffer + fixup_alt_jump_off; \
- if (laststart_set) laststart = new_buffer + laststart_off; \
- if (pending_exact_set) pending_exact = new_buffer + pending_exact_off; \
+ if (0 <= fixup_alt_jump_off) \
+ fixup_alt_jump = new_buffer + fixup_alt_jump_off; \
+ if (0 <= laststart_off) \
+ laststart = new_buffer + laststart_off; \
+ if (0 <= pending_exact_off) \
+ pending_exact = new_buffer + pending_exact_off; \
} while (false)
delete_keyboard_wait_descriptor (fileno (f));
#ifndef MSDOS
- fclose (f);
if (f != t->display_info.tty->output)
fclose (t->display_info.tty->output);
+ fclose (f);
#endif
t->display_info.tty->input = 0;
}
+static void
+clear_position (struct it *it)
+{
+ it->position.charpos = 0;
+ it->position.bytepos = 0;
+}
+
/* Append one space to the glyph row of iterator IT if doing a
window-based redisplay. The space has the same face as
IT->face_id. Value is true if a space was added.
struct face *face;
it->what = IT_CHARACTER;
- memset (&it->position, 0, sizeof it->position);
+ clear_position (it);
it->object = Qnil;
it->len = 1;
const int stretch_width =
indicator_column - it->current_x - char_width;
- memset (&it->position, 0, sizeof it->position);
+ clear_position (it);
/* Only generate a stretch glyph if there is distance
between current_x and the indicator position. */
if (stretch_width > 0)
{
- memset (&it->position, 0, sizeof it->position);
+ clear_position (it);
append_stretch_glyph (it, Qnil, stretch_width,
it->ascent + it->descent,
stretch_ascent);
(((it->ascent + it->descent)
* FONT_BASE (font)) / FONT_HEIGHT (font));
saved_pos = it->position;
- memset (&it->position, 0, sizeof it->position);
+ clear_position (it);
saved_avoid_cursor = it->avoid_cursor_p;
it->avoid_cursor_p = true;
saved_face_id = it->face_id;
enum display_element_type saved_what = it->what;
it->what = IT_CHARACTER;
- memset (&it->position, 0, sizeof it->position);
+ clear_position (it);
it->object = Qnil;
it->c = it->char_to_display = ' ';
it->len = 1;
{
struct frame *f = XFRAME (w->frame);
int new_cursor_type;
- int new_cursor_width;
+ int new_cursor_width UNINIT;
bool active_cursor;
struct glyph_row *glyph_row;
struct glyph *glyph;
glyph->ascent + glyph->descent - 1);
x += glyph->pixel_width;
}
+
+ /* Defend against hypothetical bad code elsewhere that uses
+ s->char2b after this function returns. */
+ s->char2b = NULL;
}
#ifdef USE_X_TOOLKIT
#ifdef USE_XCB
xcb_connection_t *xcb_conn;
#endif
- char *cm_atom_sprintf;
+ static char const cm_atom_fmt[] = "_NET_WM_CM_S%d";
+ char cm_atom_sprintf[sizeof cm_atom_fmt - 2 + INT_STRLEN_BOUND (int)];
block_input ();
dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm;
}
- {
- int n = snprintf (NULL, 0, "_NET_WM_CM_S%d",
- XScreenNumberOfScreen (dpyinfo->screen));
- cm_atom_sprintf = alloca (n + 1);
-
- snprintf (cm_atom_sprintf, n + 1, "_NET_WM_CM_S%d",
- XScreenNumberOfScreen (dpyinfo->screen));
- }
+ sprintf (cm_atom_sprintf, cm_atom_fmt,
+ XScreenNumberOfScreen (dpyinfo->screen));
{
static const struct