Mercurial > emacs
comparison src/xsmfns.c @ 109748:e2f8226efb99
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*.
author | Jan D <jan.h.d@swipnet.se> |
---|---|
date | Wed, 11 Aug 2010 14:34:46 +0200 |
parents | 228a5fa4eda0 |
children | 4f757d8e8ed7 |
comparison
equal
deleted
inserted
replaced
109747:1f617baf8ae5 | 109748:e2f8226efb99 |
---|---|
85 | 85 |
86 | 86 |
87 /* The option to start Emacs without the splash screen when | 87 /* The option to start Emacs without the splash screen when |
88 restarting Emacs. */ | 88 restarting Emacs. */ |
89 | 89 |
90 #define NOSPLASH_OPT "--no-splash" | 90 static char NOSPLASH_OPT[] = "--no-splash"; |
91 | 91 |
92 /* The option to make Emacs start in the given directory. */ | 92 /* The option to make Emacs start in the given directory. */ |
93 | 93 |
94 #define CHDIR_OPT "--chdir=" | 94 #define CHDIR_OPT "--chdir=" |
95 | 95 |
196 SmProp prop_ptr[NR_PROPS]; | 196 SmProp prop_ptr[NR_PROPS]; |
197 | 197 |
198 SmPropValue values[20]; | 198 SmPropValue values[20]; |
199 int val_idx = 0; | 199 int val_idx = 0; |
200 int props_idx = 0; | 200 int props_idx = 0; |
201 | 201 int i; |
202 char *cwd = NULL; | 202 char *cwd = NULL; |
203 char *smid_opt, *chdir_opt = NULL; | 203 char *smid_opt, *chdir_opt = NULL; |
204 | 204 |
205 /* How to start a new instance of Emacs. */ | 205 /* How to start a new instance of Emacs. */ |
206 props[props_idx] = &prop_ptr[props_idx]; | 206 props[props_idx] = &prop_ptr[props_idx]; |
207 props[props_idx]->name = SmCloneCommand; | 207 props[props_idx]->name = xstrdup (SmCloneCommand); |
208 props[props_idx]->type = SmLISTofARRAY8; | 208 props[props_idx]->type = xstrdup (SmLISTofARRAY8); |
209 props[props_idx]->num_vals = 1; | 209 props[props_idx]->num_vals = 1; |
210 props[props_idx]->vals = &values[val_idx++]; | 210 props[props_idx]->vals = &values[val_idx++]; |
211 props[props_idx]->vals[0].length = strlen (emacs_program); | 211 props[props_idx]->vals[0].length = strlen (emacs_program); |
212 props[props_idx]->vals[0].value = emacs_program; | 212 props[props_idx]->vals[0].value = emacs_program; |
213 ++props_idx; | 213 ++props_idx; |
214 | 214 |
215 /* The name of the program. */ | 215 /* The name of the program. */ |
216 props[props_idx] = &prop_ptr[props_idx]; | 216 props[props_idx] = &prop_ptr[props_idx]; |
217 props[props_idx]->name = SmProgram; | 217 props[props_idx]->name = xstrdup (SmProgram); |
218 props[props_idx]->type = SmARRAY8; | 218 props[props_idx]->type = xstrdup (SmARRAY8); |
219 props[props_idx]->num_vals = 1; | 219 props[props_idx]->num_vals = 1; |
220 props[props_idx]->vals = &values[val_idx++]; | 220 props[props_idx]->vals = &values[val_idx++]; |
221 props[props_idx]->vals[0].length = strlen (SSDATA (Vinvocation_name)); | 221 props[props_idx]->vals[0].length = strlen (SSDATA (Vinvocation_name)); |
222 props[props_idx]->vals[0].value = SDATA (Vinvocation_name); | 222 props[props_idx]->vals[0].value = SDATA (Vinvocation_name); |
223 ++props_idx; | 223 ++props_idx; |
224 | 224 |
225 /* How to restart Emacs. */ | 225 /* How to restart Emacs. */ |
226 props[props_idx] = &prop_ptr[props_idx]; | 226 props[props_idx] = &prop_ptr[props_idx]; |
227 props[props_idx]->name = SmRestartCommand; | 227 props[props_idx]->name = xstrdup (SmRestartCommand); |
228 props[props_idx]->type = SmLISTofARRAY8; | 228 props[props_idx]->type = xstrdup (SmLISTofARRAY8); |
229 /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */ | 229 /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir */ |
230 props[props_idx]->num_vals = 4; | 230 props[props_idx]->num_vals = 4; |
231 props[props_idx]->vals = &values[val_idx]; | 231 props[props_idx]->vals = &values[val_idx]; |
232 props[props_idx]->vals[0].length = strlen (emacs_program); | 232 props[props_idx]->vals[0].length = strlen (emacs_program); |
233 props[props_idx]->vals[0].value = emacs_program; | 233 props[props_idx]->vals[0].value = emacs_program; |
256 val_idx += cwd ? 4 : 3; | 256 val_idx += cwd ? 4 : 3; |
257 ++props_idx; | 257 ++props_idx; |
258 | 258 |
259 /* User id. */ | 259 /* User id. */ |
260 props[props_idx] = &prop_ptr[props_idx]; | 260 props[props_idx] = &prop_ptr[props_idx]; |
261 props[props_idx]->name = SmUserID; | 261 props[props_idx]->name = xstrdup (SmUserID); |
262 props[props_idx]->type = SmARRAY8; | 262 props[props_idx]->type = xstrdup (SmARRAY8); |
263 props[props_idx]->num_vals = 1; | 263 props[props_idx]->num_vals = 1; |
264 props[props_idx]->vals = &values[val_idx++]; | 264 props[props_idx]->vals = &values[val_idx++]; |
265 props[props_idx]->vals[0].length = strlen (SSDATA (Vuser_login_name)); | 265 props[props_idx]->vals[0].length = strlen (SSDATA (Vuser_login_name)); |
266 props[props_idx]->vals[0].value = SDATA (Vuser_login_name); | 266 props[props_idx]->vals[0].value = SDATA (Vuser_login_name); |
267 ++props_idx; | 267 ++props_idx; |
268 | 268 |
269 | 269 |
270 if (cwd) | 270 if (cwd) |
271 { | 271 { |
272 props[props_idx] = &prop_ptr[props_idx]; | 272 props[props_idx] = &prop_ptr[props_idx]; |
273 props[props_idx]->name = SmCurrentDirectory; | 273 props[props_idx]->name = xstrdup (SmCurrentDirectory); |
274 props[props_idx]->type = SmARRAY8; | 274 props[props_idx]->type = xstrdup (SmARRAY8); |
275 props[props_idx]->num_vals = 1; | 275 props[props_idx]->num_vals = 1; |
276 props[props_idx]->vals = &values[val_idx++]; | 276 props[props_idx]->vals = &values[val_idx++]; |
277 props[props_idx]->vals[0].length = strlen (cwd); | 277 props[props_idx]->vals[0].length = strlen (cwd); |
278 props[props_idx]->vals[0].value = cwd; | 278 props[props_idx]->vals[0].value = cwd; |
279 ++props_idx; | 279 ++props_idx; |
284 | 284 |
285 xfree (smid_opt); | 285 xfree (smid_opt); |
286 xfree (chdir_opt); | 286 xfree (chdir_opt); |
287 | 287 |
288 free (cwd); | 288 free (cwd); |
289 for (i = 0; i < props_idx; ++i) | |
290 { | |
291 xfree (props[i]->type); | |
292 xfree (props[i]->name); | |
293 } | |
289 | 294 |
290 /* See if we maybe shall interact with the user. */ | 295 /* See if we maybe shall interact with the user. */ |
291 if (interactStyle != SmInteractStyleAny | 296 if (interactStyle != SmInteractStyleAny |
292 || ! shutdown | 297 || ! shutdown |
293 || saveType == SmSaveLocal | 298 || saveType == SmSaveLocal |