summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan D <jan.h.d@swipnet.se>2010-08-11 14:34:46 +0200
committerJan D <jan.h.d@swipnet.se>2010-08-11 14:34:46 +0200
commit42ca463309fdb17f04a72dad92696312bf242328 (patch)
treee4e9f8618dbe65ded7a6e9e5e38f6ffbb10dc983 /src
parent5e3b9a89ad0dc6fd34d91798d227ed29a905aa26 (diff)
downloademacs-42ca463309fdb17f04a72dad92696312bf242328.tar.gz
Fix -Wwrite_strings in general and for Gtk+ specific code.
* callproc.c (synch_process_death): Make const. (Fcall_process): Make signame const. * emacs.c (main): Pass char[] to putenv instead of literal. * floatfns.c (matherr): Use a const char* variable for x->name. * font.c (font_open_by_name): Make name const. * font.h (font_open_by_name): Make name const. * gtkutil.c (get_utf8_string): Always return an allocated string. Parameter is const. (create_dialog, xg_create_one_menuitem, create_menus) (xg_item_label_same_p, xg_update_menu_item): Free result from get_utf8_string. (xg_separator_p, xg_item_label_same_p): label is const. * gtkutil.h: Replace widget_value with struct _widget_value. (enum button_type, struct _widget_value): Remove and use the one from keyboard.h. * keyboard.h (_widget_value): Add defined USE_GTK. Replace Boolean with unsigned char and XtPointer with void *. * menu.c (Fx_popup_menu): error_name is const. * menu.h (w32_menu_show, ns_menu_show, xmenu_show): error parameter is const char **. * w32menu.c (w32_menu_show): * nsmenu.m (ns_menu_show): error parameter is const char **. * process.h (synch_process_death): Is const char*. * xmenu.c (Fx_popup_dialog): error_name is const char*. (xmenu_show): error parameter is const char **. pane_string is const char *. (button_names): Is const char *. (xdialog_show): error_name and pane_string is const. * xrdb.c (get_system_app): Make path const and use char *p for non-const char. * xselect.c (Fx_get_atom_name): Use char empty[] instead of literal "". * xsmfns.c (NOSPLASH_OPT): Change to char[]. (smc_save_yourself_CB): Do xstrdup on all ->type and ->name for props. Free them at the end. * xterm.c (emacs_class): New char[] for EMACS_CLASS. (xim_open_dpy, xim_initialize, xim_close_dpy): Use emacs_class. (x_term_init): Use char[] display_opt and name_opt instead of string literal. file is const char*.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog55
-rw-r--r--src/callproc.c4
-rw-r--r--src/emacs.c3
-rw-r--r--src/floatfns.c8
-rw-r--r--src/font.c2
-rw-r--r--src/font.h2
-rw-r--r--src/gtkutil.c29
-rw-r--r--src/gtkutil.h53
-rw-r--r--src/keyboard.h16
-rw-r--r--src/menu.c2
-rw-r--r--src/menu.h6
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/process.h2
-rw-r--r--src/w32menu.c2
-rw-r--r--src/xmenu.c18
-rw-r--r--src/xrdb.c13
-rw-r--r--src/xselect.c3
-rw-r--r--src/xsmfns.c29
-rw-r--r--src/xterm.c18
19 files changed, 151 insertions, 116 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 240af42ac47..89414fa4d78 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,60 @@
2010-08-11 Jan Djärv <jan.h.d@swipnet.se>
+ * xterm.c (emacs_class): New char[] for EMACS_CLASS.
+ (xim_open_dpy, xim_initialize, xim_close_dpy): Use emacs_class.
+ (x_term_init): Use char[] display_opt and name_opt instead of
+ string literal. file is const char*.
+
+ * xsmfns.c (NOSPLASH_OPT): Change to char[].
+ (smc_save_yourself_CB): Do xstrdup on all ->type and ->name for
+ props. Free them at the end.
+
+ * xselect.c (Fx_get_atom_name): Use char empty[] instead of literal "".
+
+ * xrdb.c (get_system_app): Make path const and use char *p for non-const
+ char.
+
+ * xmenu.c (Fx_popup_dialog): error_name is const char*.
+ (xmenu_show): error parameter is const char **. pane_string is const
+ char *.
+ (button_names): Is const char *.
+ (xdialog_show): error_name and pane_string is const.
+
+ * process.h (synch_process_death): Is const char*.
+
+ * w32menu.c (w32_menu_show):
+ * nsmenu.m (ns_menu_show): error parameter is const char **.
+
+ * menu.h (w32_menu_show, ns_menu_show, xmenu_show): error parameter
+ is const char **.
+
+ * menu.c (Fx_popup_menu): error_name is const.
+
+ * keyboard.h (_widget_value): Add defined USE_GTK. Replace Boolean
+ with unsigned char and XtPointer with void *.
+
+ * gtkutil.h: Replace widget_value with struct _widget_value.
+ (enum button_type, struct _widget_value): Remove and use the one from
+ keyboard.h.
+
+ * gtkutil.c (get_utf8_string): Always return an allocated string.
+ Parameter is const.
+ (create_dialog, xg_create_one_menuitem, create_menus)
+ (xg_item_label_same_p, xg_update_menu_item): Free result from
+ get_utf8_string.
+ (xg_separator_p, xg_item_label_same_p): label is const.
+
+ * font.h (font_open_by_name): Make name const.
+
+ * font.c (font_open_by_name): Make name const.
+
+ * floatfns.c (matherr): Use a const char* variable for x->name.
+
+ * emacs.c (main): Pass char[] to putenv instead of literal.
+
+ * callproc.c (synch_process_death): Make const.
+ (Fcall_process): Make signame const.
+
* nsterm.h (parseKeyEquiv, addSubmenuWithTitle)
(addDisplayItemWithImage): Use const char*.
diff --git a/src/callproc.c b/src/callproc.c
index ca9ff93a6d9..de28ffa42ef 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -115,7 +115,7 @@ Lisp_Object Qbuffer_file_type;
int synch_process_alive;
/* Nonzero => this is a string explaining death of synchronous subprocess. */
-char *synch_process_death;
+const char *synch_process_death;
/* Nonzero => this is the signal number that terminated the subprocess. */
int synch_process_termsig;
@@ -818,7 +818,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
if (synch_process_termsig)
{
- char *signame;
+ const char *signame;
synchronize_system_messages_locale ();
signame = strsignal (synch_process_termsig);
diff --git a/src/emacs.c b/src/emacs.c
index 4dc670e6032..026a210af50 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -839,8 +839,9 @@ main (int argc, char **argv)
|| strcmp (argv[argc-1], "bootstrap") == 0)
&& ! getenv ("EMACS_HEAP_EXEC"))
{
+ static char heapexec[] = "EMACS_HEAP_EXEC=true";
/* Set this so we only do this once. */
- putenv("EMACS_HEAP_EXEC=true");
+ putenv(heapexec);
/* A flag to turn off address randomization which is introduced
in linux kernel shipped with fedora core 4 */
diff --git a/src/floatfns.c b/src/floatfns.c
index 1c3e40eefde..29e5c119a1f 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -987,16 +987,18 @@ int
matherr (struct exception *x)
{
Lisp_Object args;
+ const char *name = x->name;
+
if (! in_float)
/* Not called from emacs-lisp float routines; do the default thing. */
return 0;
if (!strcmp (x->name, "pow"))
- x->name = "expt";
+ name = "expt";
args
- = Fcons (build_string (x->name),
+ = Fcons (build_string (name),
Fcons (make_float (x->arg1),
- ((!strcmp (x->name, "log") || !strcmp (x->name, "pow"))
+ ((!strcmp (name, "log") || !strcmp (name, "pow"))
? Fcons (make_float (x->arg2), Qnil)
: Qnil)));
switch (x->type)
diff --git a/src/font.c b/src/font.c
index eba75c11b2f..ae7211e92fe 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3506,7 +3506,7 @@ font_open_by_spec (FRAME_PTR f, Lisp_Object spec)
found, return Qnil. */
Lisp_Object
-font_open_by_name (FRAME_PTR f, char *name)
+font_open_by_name (FRAME_PTR f, const char *name)
{
Lisp_Object args[2];
Lisp_Object spec, ret;
diff --git a/src/font.h b/src/font.h
index 5f1a442b59e..c322b8e590f 100644
--- a/src/font.h
+++ b/src/font.h
@@ -783,7 +783,7 @@ extern void font_prepare_for_face (FRAME_PTR f, struct face *face);
extern void font_done_for_face (FRAME_PTR f, struct face *face);
extern Lisp_Object font_open_by_spec (FRAME_PTR f, Lisp_Object spec);
-extern Lisp_Object font_open_by_name (FRAME_PTR f, char *name);
+extern Lisp_Object font_open_by_name (FRAME_PTR f, const char *name);
extern void font_close_object (FRAME_PTR f, Lisp_Object font_object);
extern Lisp_Object font_intern_prop (const char *str, int len, int force_symbol);
diff --git a/src/gtkutil.c b/src/gtkutil.c
index b1591b79f9c..a9f2d103702 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -432,20 +432,22 @@ xg_list_remove (xg_list_node *list, xg_list_node *node)
}
/* Allocate and return a utf8 version of STR. If STR is already
- utf8 or NULL, just return STR.
- If not, a new string is allocated and the caller must free the result
+ utf8 or NULL, just return a copy of STR.
+ A new string is allocated and the caller must free the result
with g_free. */
static char *
-get_utf8_string (char *str)
+get_utf8_string (const char *str)
{
- char *utf8_str = str;
+ char *utf8_str;
if (!str) return NULL;
/* If not UTF-8, try current locale. */
if (!g_utf8_validate (str, -1, NULL))
utf8_str = g_locale_to_utf8 (str, -1, 0, 0, 0);
+ else
+ return g_strdup (str);
if (!utf8_str)
{
@@ -1336,7 +1338,7 @@ create_dialog (widget_value *wv,
}
}
- if (utf8_label && utf8_label != item->value)
+ if (utf8_label)
g_free (utf8_label);
}
@@ -2076,7 +2078,7 @@ static const char* separator_names[] = {
};
static int
-xg_separator_p (char *label)
+xg_separator_p (const char *label)
{
if (! label) return 0;
else if (strlen (label) > 3
@@ -2174,8 +2176,8 @@ xg_create_one_menuitem (widget_value *item,
w = make_menu_item (utf8_label, utf8_key, item, group);
- if (utf8_label && utf8_label != item->name) g_free (utf8_label);
- if (utf8_key && utf8_key != item->key) g_free (utf8_key);
+ if (utf8_label) g_free (utf8_label);
+ if (utf8_key) g_free (utf8_key);
cb_data = xmalloc (sizeof (xg_menu_item_cb_data));
@@ -2311,7 +2313,7 @@ create_menus (widget_value *data,
gtk_menu_set_title (GTK_MENU (wmenu), utf8_label);
w = gtk_menu_item_new_with_label (utf8_label);
gtk_widget_set_sensitive (w, FALSE);
- if (utf8_label && utf8_label != item->name) g_free (utf8_label);
+ if (utf8_label) g_free (utf8_label);
}
else if (xg_separator_p (item->name))
{
@@ -2432,7 +2434,7 @@ xg_get_menu_item_label (GtkMenuItem *witem)
/* Return non-zero if the menu item WITEM has the text LABEL. */
static int
-xg_item_label_same_p (GtkMenuItem *witem, char *label)
+xg_item_label_same_p (GtkMenuItem *witem, const char *label)
{
int is_same = 0;
char *utf8_label = get_utf8_string (label);
@@ -2443,7 +2445,7 @@ xg_item_label_same_p (GtkMenuItem *witem, char *label)
else if (old_label && utf8_label)
is_same = strcmp (utf8_label, old_label) == 0;
- if (utf8_label && utf8_label != label) g_free (utf8_label);
+ if (utf8_label) g_free (utf8_label);
return is_same;
}
@@ -2590,6 +2592,7 @@ xg_update_menubar (GtkWidget *menubar,
/* Set the title of the detached window. */
gtk_menu_set_title (GTK_MENU (submenu), utf8_label);
+ if (utf8_label) g_free (utf8_label);
iter = g_list_next (iter);
val = val->next;
++pos;
@@ -2729,8 +2732,8 @@ xg_update_menu_item (widget_value *val,
if (! old_label || strcmp (utf8_label, old_label) != 0)
gtk_label_set_text (wlbl, utf8_label);
- if (utf8_key && utf8_key != val->key) g_free (utf8_key);
- if (utf8_label && utf8_label != val->name) g_free (utf8_label);
+ if (utf8_key) g_free (utf8_key);
+ if (utf8_label) g_free (utf8_label);
if (! val->enabled && gtk_widget_get_sensitive (w))
gtk_widget_set_sensitive (w, FALSE);
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 75620c54d10..6e86425fb74 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -38,14 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Key for data that menu items hold. */
#define XG_ITEM_DATA "emacs_menuitem"
-/* Button types in menus. */
-enum button_type
-{
- BUTTON_TYPE_NONE,
- BUTTON_TYPE_TOGGLE,
- BUTTON_TYPE_RADIO
-};
-
/* This is a list node in a generic list implementation. */
typedef struct xg_list_node_
{
@@ -82,48 +74,13 @@ typedef struct xg_menu_item_cb_data_
} xg_menu_item_cb_data;
-/* Used to specify menus and dialogs.
- This is an adaption from lwlib for Gtk so we can use more of the same
- code as lwlib in xmenu.c. */
-typedef struct _widget_value
-{
- /* name of widget */
- Lisp_Object lname;
- char *name;
- /* value (meaning depend on widget type) */
- char *value;
- /* keyboard equivalent. no implications for XtTranslations */
- Lisp_Object lkey;
- char *key;
- /* Help string or nil if none.
- GC finds this string through the frame's menu_bar_vector
- or through menu_items. */
- Lisp_Object help;
- /* true if enabled */
- gint enabled;
- /* true if selected */
- gint selected;
- /* The type of a button. */
- enum button_type button_type;
- /* Contents of the sub-widgets, also selected slot for checkbox */
- struct _widget_value *contents;
- /* data passed to callback */
- gpointer call_data;
- /* next one in the list */
- struct _widget_value *next;
-
- /* we resource the widget_value structures; this points to the next
- one on the free list if this one has been deallocated.
- */
- struct _widget_value *free_list;
-} widget_value;
-
#ifdef HAVE_GTK_FILE_SELECTION_NEW
extern int use_old_gtk_file_dialog;
#endif
+struct _widget_value;
-extern widget_value *malloc_widget_value (void);
-extern void free_widget_value (widget_value *);
+extern struct _widget_value *malloc_widget_value (void);
+extern void free_widget_value (struct _widget_value *);
extern int xg_uses_old_file_dialog (void);
@@ -138,14 +95,14 @@ extern char *xg_get_font_name (FRAME_PTR f, const char *);
extern GtkWidget *xg_create_widget (const char *type,
const char *name,
FRAME_PTR f,
- widget_value *val,
+ struct _widget_value *val,
GCallback select_cb,
GCallback deactivate_cb,
GCallback hightlight_cb);
extern void xg_modify_menubar_widgets (GtkWidget *menubar,
FRAME_PTR f,
- widget_value *val,
+ struct _widget_value *val,
int deep_p,
GCallback select_cb,
GCallback deactivate_cb,
diff --git a/src/keyboard.h b/src/keyboard.h
index 757f538560c..4eb0b654703 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -318,10 +318,7 @@ extern Lisp_Object unuse_menu_items (Lisp_Object dummy);
#define ENCODE_MENU_STRING(str) (str)
#endif
-#if defined (HAVE_NS) || defined (HAVE_NTGUI)
-
-typedef void * XtPointer;
-typedef unsigned char Boolean;
+#if defined (HAVE_NS) || defined (HAVE_NTGUI) || defined (USE_GTK)
/* Definitions copied from lwlib.h */
@@ -349,21 +346,24 @@ typedef struct _widget_value
or through menu_items. */
Lisp_Object help;
/* true if enabled */
- Boolean enabled;
+ unsigned char enabled;
/* true if selected */
- Boolean selected;
+ unsigned char selected;
/* The type of a button. */
enum button_type button_type;
#if defined (HAVE_NTGUI)
/* true if menu title */
- Boolean title;
+ unsigned char title;
#endif
/* Contents of the sub-widgets, also selected slot for checkbox */
struct _widget_value* contents;
/* data passed to callback */
- XtPointer call_data;
+ void *call_data;
/* next one in the list */
struct _widget_value* next;
+#ifdef USE_GTK
+ struct _widget_value *free_list;
+#endif
} widget_value;
#endif /* HAVE_NS || HAVE_NTGUI */
diff --git a/src/menu.c b/src/menu.c
index ab20a47fba6..05a296e45fc 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1065,7 +1065,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
Lisp_Object keymap, tem;
int xpos = 0, ypos = 0;
Lisp_Object title;
- char *error_name = NULL;
+ const char *error_name = NULL;
Lisp_Object selection = Qnil;
FRAME_PTR f = NULL;
Lisp_Object x, y, window;
diff --git a/src/menu.h b/src/menu.h
index c8691169ccb..5e62327da9f 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -46,11 +46,11 @@ extern void mouse_position_for_popup (FRAME_PTR f, int *x, int *y);
#endif
extern Lisp_Object w32_menu_show (FRAME_PTR, int, int, int, int,
- Lisp_Object, char **);
+ Lisp_Object, const char **);
extern Lisp_Object ns_menu_show (FRAME_PTR, int, int, int, int,
- Lisp_Object, char **);
+ Lisp_Object, const char **);
extern Lisp_Object xmenu_show (FRAME_PTR, int, int, int, int,
- Lisp_Object, char **, EMACS_UINT);
+ Lisp_Object, const char **, EMACS_UINT);
#endif /* MENU_H */
/* arch-tag: c32b2778-724d-4e85-81d7-45f98530a988
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 86b3775e9e6..9534aec8f2b 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -773,7 +773,7 @@ name_is_separator ( const char *name)
Lisp_Object
ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
- Lisp_Object title, char **error)
+ Lisp_Object title, const char **error)
{
EmacsMenu *pmenu;
NSPoint p;
diff --git a/src/process.h b/src/process.h
index 6d4832ffde8..35b01aba6a4 100644
--- a/src/process.h
+++ b/src/process.h
@@ -142,7 +142,7 @@ extern int synch_process_alive;
to Fcall_process. */
/* Nonzero => this is a string explaining death of synchronous subprocess. */
-extern char *synch_process_death;
+extern const char *synch_process_death;
/* Nonzero => this is the signal number that terminated the subprocess. */
extern int synch_process_termsig;
diff --git a/src/w32menu.c b/src/w32menu.c
index 919f8505da8..bd560219a1d 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -662,7 +662,7 @@ free_frame_menubar (FRAME_PTR f)
Lisp_Object
w32_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
- Lisp_Object title, char **error)
+ Lisp_Object title, const char **error)
{
int i;
int menu_item_selection;
diff --git a/src/xmenu.c b/src/xmenu.c
index 0b24a8f2bd6..0f42a5f0892 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -111,7 +111,7 @@ Lisp_Object Qdebug_on_next_call;
#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object,
- char **);
+ const char **);
#endif
static int update_frame_menubar (struct frame *);
@@ -312,7 +312,7 @@ for instance using the window manager, then this produces a quit and
#else
{
Lisp_Object title;
- char *error_name;
+ const char *error_name;
Lisp_Object selection;
int specpdl_count = SPECPDL_INDEX ();
@@ -1600,7 +1600,7 @@ create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
Lisp_Object
xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
- Lisp_Object title, char **error, EMACS_UINT timestamp)
+ Lisp_Object title, const char **error, EMACS_UINT timestamp)
{
int i;
widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
@@ -1664,7 +1664,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
{
/* Create a new pane. */
Lisp_Object pane_name, prefix;
- char *pane_string;
+ const char *pane_string;
pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME);
prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX);
@@ -1976,12 +1976,16 @@ create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
#endif /* not USE_GTK */
-static char * button_names [] = {
+static const char * button_names [] = {
"button1", "button2", "button3", "button4", "button5",
"button6", "button7", "button8", "button9", "button10" };
static Lisp_Object
-xdialog_show (FRAME_PTR f, int keymaps, Lisp_Object title, Lisp_Object header, char **error_name)
+xdialog_show (FRAME_PTR f,
+ int keymaps,
+ Lisp_Object title,
+ Lisp_Object header,
+ const char **error_name)
{
int i, nb_buttons=0;
char dialog_name[6];
@@ -2008,7 +2012,7 @@ xdialog_show (FRAME_PTR f, int keymaps, Lisp_Object title, Lisp_Object header, c
representing the text label and buttons. */
{
Lisp_Object pane_name, prefix;
- char *pane_string;
+ const char *pane_string;
pane_name = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_NAME];
prefix = XVECTOR (menu_items)->contents[MENU_ITEMS_PANE_PREFIX];
pane_string = (NILP (pane_name)
diff --git a/src/xrdb.c b/src/xrdb.c
index e0d948fd3a6..d81f08747ac 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -334,16 +334,17 @@ static XrmDatabase
get_system_app (const char *class)
{
XrmDatabase db = NULL;
- char *path;
+ const char *path;
+ char *p;
path = getenv ("XFILESEARCHPATH");
if (! path) path = PATH_X_DEFAULTS;
- path = search_magic_path (path, class, 0, 0);
- if (path)
+ p = search_magic_path (path, class, 0, 0);
+ if (p)
{
- db = XrmGetFileDatabase (path);
- xfree (path);
+ db = XrmGetFileDatabase (p);
+ xfree (p);
}
return db;
@@ -360,7 +361,7 @@ get_fallback (Display *display)
static XrmDatabase
get_user_app (const char *class)
{
- char *path;
+ const char *path;
char *file = 0;
char *free_it = 0;
diff --git a/src/xselect.c b/src/xselect.c
index 9f15c7c2d99..b4b2ab22d6c 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2596,6 +2596,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
{
struct frame *f = check_x_frame (frame);
char *name = 0;
+ char empty[] = "";
Lisp_Object ret = Qnil;
Display *dpy = FRAME_X_DISPLAY (f);
Atom atom;
@@ -2612,7 +2613,7 @@ If the value is 0 or the atom is not known, return the empty string. */)
BLOCK_INPUT;
x_catch_errors (dpy);
- name = atom ? XGetAtomName (dpy, atom) : "";
+ name = atom ? XGetAtomName (dpy, atom) : empty;
had_errors = x_had_errors_p (dpy);
x_uncatch_errors ();
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 0096110bd46..79dccfa55e1 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -87,7 +87,7 @@ Lisp_Object Vx_session_previous_id;
/* The option to start Emacs without the splash screen when
restarting Emacs. */
-#define NOSPLASH_OPT "--no-splash"
+static char NOSPLASH_OPT[] = "--no-splash";
/* The option to make Emacs start in the given directory. */
@@ -198,14 +198,14 @@ smc_save_yourself_CB (SmcConn smcConn,
SmPropValue values[20];
int val_idx = 0;
int props_idx = 0;
-
+ int i;
char *cwd = NULL;
char *smid_opt, *chdir_opt = NULL;
/* How to start a new instance of Emacs. */
props[props_idx] = &prop_ptr[props_idx];
- props[props_idx]->name = SmCloneCommand;
- props[props_idx]->type = SmLISTofARRAY8;
+ props[props_idx]->name = xstrdup (SmCloneCommand);
+ props[props_idx]->type = xstrdup (SmLISTofARRAY8);
props[props_idx]->num_vals = 1;
props[props_idx]->vals = &values[val_idx++];
props[props_idx]->vals[0].length = strlen (emacs_program);
@@ -214,8 +214,8 @@ smc_save_yourself_CB (SmcConn smcConn,
/* The name of the program. */
props[props_idx] = &prop_ptr[props_idx];
- props[props_idx]->name = SmProgram;
- props[props_idx]->type = SmARRAY8;
+ props[props_idx]->name = xstrdup (SmProgram);
+ props[props_idx]->type = xstrdup (SmARRAY8);
props[props_idx]->num_vals = 1;
props[props_idx]->vals = &values[val_idx++];
props[props_idx]->vals[0].length = strlen (SSDATA (Vinvocation_name));
@@ -224,8 +224,8 @@ smc_save_yourself_CB (SmcConn smcConn,
/* How to restart Emacs. */
props[props_idx] = &prop_ptr[props_idx];
- props[props_idx]->name = SmRestartCommand;
- props[props_idx]->type = SmLISTofARRAY8;
+ props[props_idx]->name = xstrdup (SmRestartCommand);
+ props[props_idx]->type = xstrdup (SmLISTofARRAY8);
/* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */
props[props_idx]->num_vals = 4;
props[props_idx]->vals = &values[val_idx];
@@ -258,8 +258,8 @@ smc_save_yourself_CB (SmcConn smcConn,
/* User id. */
props[props_idx] = &prop_ptr[props_idx];
- props[props_idx]->name = SmUserID;
- props[props_idx]->type = SmARRAY8;
+ props[props_idx]->name = xstrdup (SmUserID);
+ props[props_idx]->type = xstrdup (SmARRAY8);
props[props_idx]->num_vals = 1;
props[props_idx]->vals = &values[val_idx++];
props[props_idx]->vals[0].length = strlen (SSDATA (Vuser_login_name));
@@ -270,8 +270,8 @@ smc_save_yourself_CB (SmcConn smcConn,
if (cwd)
{
props[props_idx] = &prop_ptr[props_idx];
- props[props_idx]->name = SmCurrentDirectory;
- props[props_idx]->type = SmARRAY8;
+ props[props_idx]->name = xstrdup (SmCurrentDirectory);
+ props[props_idx]->type = xstrdup (SmARRAY8);
props[props_idx]->num_vals = 1;
props[props_idx]->vals = &values[val_idx++];
props[props_idx]->vals[0].length = strlen (cwd);
@@ -286,6 +286,11 @@ smc_save_yourself_CB (SmcConn smcConn,
xfree (chdir_opt);
free (cwd);
+ for (i = 0; i < props_idx; ++i)
+ {
+ xfree (props[i]->type);
+ xfree (props[i]->name);
+ }
/* See if we maybe shall interact with the user. */
if (interactStyle != SmInteractStyleAny
diff --git a/src/xterm.c b/src/xterm.c
index e6bf82ab5a5..00516722149 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -301,6 +301,9 @@ static Lisp_Object xg_default_icon_file;
Lisp_Object Qx_gtk_map_stock;
#endif
+/* Some functions take this as char *, not const char *. */
+static char emacs_class[] = EMACS_CLASS;
+
/* Used in x_flush. */
extern XrmDatabase x_load_resources (Display *, const char *, const char *,
@@ -7872,7 +7875,7 @@ xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name)
if (dpyinfo->xim)
XCloseIM (dpyinfo->xim);
xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name,
- EMACS_CLASS);
+ emacs_class);
dpyinfo->xim = xim;
if (xim)
@@ -7973,7 +7976,7 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name)
xim_inst->resource_name = (char *) xmalloc (len + 1);
memcpy (xim_inst->resource_name, resource_name, len + 1);
XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
- resource_name, EMACS_CLASS,
+ resource_name, emacs_class,
xim_instantiate_callback,
/* This is XPointer in XFree86
but (XPointer *) on Tru64, at
@@ -7998,7 +8001,7 @@ xim_close_dpy (struct x_display_info *dpyinfo)
#ifdef HAVE_X11R6_XIM
if (dpyinfo->display)
XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
- NULL, EMACS_CLASS,
+ NULL, emacs_class,
xim_instantiate_callback, NULL);
xfree (dpyinfo->xim_callback_data->resource_name);
xfree (dpyinfo->xim_callback_data);
@@ -9709,6 +9712,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
}
else
{
+ static char display_opt[] = "--display";
+ static char name_opt[] = "--name";
+
for (argc = 0; argc < NUM_ARGV; ++argc)
argv[argc] = 0;
@@ -9717,11 +9723,11 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
if (! NILP (display_name))
{
- argv[argc++] = "--display";
+ argv[argc++] = display_opt;
argv[argc++] = SDATA (display_name);
}
- argv[argc++] = "--name";
+ argv[argc++] = name_opt;
argv[argc++] = resource_name;
XSetLocaleModifiers ("");
@@ -9744,7 +9750,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
/* Load our own gtkrc if it exists. */
{
- char *file = "~/.emacs.d/gtkrc";
+ const char *file = "~/.emacs.d/gtkrc";
Lisp_Object s, abs_file;
s = make_string (file, strlen (file));