# HG changeset patch # User Jan D # Date 1281530086 -7200 # Node ID e2f8226efb997af1794aa953c94a3fec2b7030eb # Parent 1f617baf8ae5d18c3be92b71382e73ca990b67c9 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*. diff -r 1f617baf8ae5 -r e2f8226efb99 src/ChangeLog --- a/src/ChangeLog Wed Aug 11 11:16:35 2010 +0200 +++ b/src/ChangeLog Wed Aug 11 14:34:46 2010 +0200 @@ -1,5 +1,60 @@ 2010-08-11 Jan Djärv + * 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 -r 1f617baf8ae5 -r e2f8226efb99 src/callproc.c --- a/src/callproc.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/callproc.c Wed Aug 11 14:34:46 2010 +0200 @@ -115,7 +115,7 @@ 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 @@ if (synch_process_termsig) { - char *signame; + const char *signame; synchronize_system_messages_locale (); signame = strsignal (synch_process_termsig); diff -r 1f617baf8ae5 -r e2f8226efb99 src/emacs.c --- a/src/emacs.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/emacs.c Wed Aug 11 14:34:46 2010 +0200 @@ -839,8 +839,9 @@ || 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 -r 1f617baf8ae5 -r e2f8226efb99 src/floatfns.c --- a/src/floatfns.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/floatfns.c Wed Aug 11 14:34:46 2010 +0200 @@ -987,16 +987,18 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/font.c --- a/src/font.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/font.c Wed Aug 11 14:34:46 2010 +0200 @@ -3506,7 +3506,7 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/font.h --- a/src/font.h Wed Aug 11 11:16:35 2010 +0200 +++ b/src/font.h Wed Aug 11 14:34:46 2010 +0200 @@ -783,7 +783,7 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/gtkutil.c --- a/src/gtkutil.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/gtkutil.c Wed Aug 11 14:34:46 2010 +0200 @@ -432,20 +432,22 @@ } /* 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 @@ } } - if (utf8_label && utf8_label != item->value) + if (utf8_label) g_free (utf8_label); } @@ -2076,7 +2078,7 @@ }; 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ /* 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 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/gtkutil.h --- a/src/gtkutil.h Wed Aug 11 11:16:35 2010 +0200 +++ b/src/gtkutil.h Wed Aug 11 14:34:46 2010 +0200 @@ -38,14 +38,6 @@ /* 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 @@ } 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 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 -r 1f617baf8ae5 -r e2f8226efb99 src/keyboard.h --- a/src/keyboard.h Wed Aug 11 11:16:35 2010 +0200 +++ b/src/keyboard.h Wed Aug 11 14:34:46 2010 +0200 @@ -318,10 +318,7 @@ #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 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/menu.c --- a/src/menu.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/menu.c Wed Aug 11 14:34:46 2010 +0200 @@ -1065,7 +1065,7 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/menu.h --- a/src/menu.h Wed Aug 11 11:16:35 2010 +0200 +++ b/src/menu.h Wed Aug 11 14:34:46 2010 +0200 @@ -46,11 +46,11 @@ #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 -r 1f617baf8ae5 -r e2f8226efb99 src/nsmenu.m --- a/src/nsmenu.m Wed Aug 11 11:16:35 2010 +0200 +++ b/src/nsmenu.m Wed Aug 11 14:34:46 2010 +0200 @@ -773,7 +773,7 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/process.h --- a/src/process.h Wed Aug 11 11:16:35 2010 +0200 +++ b/src/process.h Wed Aug 11 14:34:46 2010 +0200 @@ -142,7 +142,7 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/w32menu.c --- a/src/w32menu.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/w32menu.c Wed Aug 11 14:34:46 2010 +0200 @@ -662,7 +662,7 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/xmenu.c --- a/src/xmenu.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/xmenu.c Wed Aug 11 14:34:46 2010 +0200 @@ -111,7 +111,7 @@ #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 @@ #else { Lisp_Object title; - char *error_name; + const char *error_name; Lisp_Object selection; int specpdl_count = SPECPDL_INDEX (); @@ -1600,7 +1600,7 @@ 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 @@ { /* 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 @@ #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 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/xrdb.c --- a/src/xrdb.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/xrdb.c Wed Aug 11 14:34:46 2010 +0200 @@ -334,16 +334,17 @@ 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 @@ static XrmDatabase get_user_app (const char *class) { - char *path; + const char *path; char *file = 0; char *free_it = 0; diff -r 1f617baf8ae5 -r e2f8226efb99 src/xselect.c --- a/src/xselect.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/xselect.c Wed Aug 11 14:34:46 2010 +0200 @@ -2596,6 +2596,7 @@ { 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 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/xsmfns.c --- a/src/xsmfns.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/xsmfns.c Wed Aug 11 14:34:46 2010 +0200 @@ -87,7 +87,7 @@ /* 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 @@ 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 @@ /* 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 @@ /* 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 @@ /* 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 @@ 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 @@ 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 -r 1f617baf8ae5 -r e2f8226efb99 src/xterm.c --- a/src/xterm.c Wed Aug 11 11:16:35 2010 +0200 +++ b/src/xterm.c Wed Aug 11 14:34:46 2010 +0200 @@ -301,6 +301,9 @@ 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 @@ 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_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 @@ #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 @@ } 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 @@ 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 @@ /* 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));