* 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*.
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*.
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;
if (synch_process_termsig)
{
- char *signame;
+ const char *signame;
synchronize_system_messages_locale ();
signame = strsignal (synch_process_termsig);
|| 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 */
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)
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;
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);
}
/* 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)
{
}
}
- if (utf8_label && utf8_label != item->value)
+ if (utf8_label)
g_free (utf8_label);
}
};
static int
-xg_separator_p (char *label)
+xg_separator_p (const char *label)
{
if (! label) return 0;
else if (strlen (label) > 3
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));
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))
{
/* 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);
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;
}
/* 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;
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);
/* 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_
{
} 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);
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,
#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 */
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 */
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;
#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
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;
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;
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;
#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 *);
#else
{
Lisp_Object title;
- char *error_name;
+ const char *error_name;
Lisp_Object selection;
int specpdl_count = SPECPDL_INDEX ();
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;
{
/* 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);
#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];
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)
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;
static XrmDatabase
get_user_app (const char *class)
{
- char *path;
+ const char *path;
char *file = 0;
char *free_it = 0;
{
struct frame *f = check_x_frame (frame);
char *name = 0;
+ char empty[] = "";
Lisp_Object ret = Qnil;
Display *dpy = FRAME_X_DISPLAY (f);
Atom atom;
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 ();
/* 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. */
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);
/* 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));
/* 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];
/* 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));
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);
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
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 *,
if (dpyinfo->xim)
XCloseIM (dpyinfo->xim);
xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name,
- EMACS_CLASS);
+ emacs_class);
dpyinfo->xim = xim;
if (xim)
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
#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);
}
else
{
+ static char display_opt[] = "--display";
+ static char name_opt[] = "--name";
+
for (argc = 0; argc < NUM_ARGV; ++argc)
argv[argc] = 0;
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 ("");
/* 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));