Mercurial > emacs
annotate oldXMenu/XMakeAssoc.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 | 5cc91198ffb2 |
children | 132f2dfd549f |
rev | line source |
---|---|
25858 | 1 /* Copyright Massachusetts Institute of Technology 1985 */ |
2 | |
76133
995b45abe69d
Remove license text in favour of including copyright.h, as was done in
Glenn Morris <rgm@gnu.org>
parents:
75348
diff
changeset
|
3 #include "copyright.h" |
995b45abe69d
Remove license text in favour of including copyright.h, as was done in
Glenn Morris <rgm@gnu.org>
parents:
75348
diff
changeset
|
4 |
25858 | 5 |
6 #include <config.h> | |
7 #include <X11/Xlib.h> | |
8 #include <X11/Xresource.h> | |
9 #include "X10.h" | |
10 #include <errno.h> | |
11 | |
12 #ifndef NULL | |
13 #define NULL 0 | |
14 #endif | |
15 | |
16 struct qelem { | |
17 struct qelem *q_forw; | |
18 struct qelem *q_back; | |
19 char q_data[1]; | |
20 }; | |
109124
5cc91198ffb2
Convert function definitions in oldXMenu to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
77837
diff
changeset
|
21 void emacs_insque (struct qelem *elem, struct qelem *prev); |
5cc91198ffb2
Convert function definitions in oldXMenu to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
77837
diff
changeset
|
22 |
25858 | 23 /* |
24 * XMakeAssoc - Insert data into an XAssocTable keyed on an XId. | |
25 * Data is inserted into the table only once. Redundant inserts are | |
26 * meaningless (but cause no problems). The queue in each association | |
27 * bucket is sorted (lowest XId to highest XId). | |
28 */ | |
109124
5cc91198ffb2
Convert function definitions in oldXMenu to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
77837
diff
changeset
|
29 XMakeAssoc(register Display *dpy, register XAssocTable *table, register XID x_id, register caddr_t data) |
25858 | 30 { |
31 int hash; | |
32 register XAssoc *bucket; | |
33 register XAssoc *Entry; | |
34 register XAssoc *new_entry; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
35 |
25858 | 36 /* Hash the XId to get the bucket number. */ |
37 hash = x_id & (table->size - 1); | |
38 /* Look up the bucket to get the entries in that bucket. */ | |
39 bucket = &table->buckets[hash]; | |
40 /* Get the first entry in the bucket. */ | |
41 Entry = bucket->next; | |
42 | |
43 /* If (Entry != bucket), the bucket is empty so make */ | |
44 /* the new entry the first entry in the bucket. */ | |
45 /* if (Entry == bucket), the we have to search the */ | |
46 /* bucket. */ | |
47 if (Entry != bucket) { | |
48 /* The bucket isn't empty, begin searching. */ | |
49 /* If we leave the for loop then we have either passed */ | |
50 /* where the entry should be or hit the end of the bucket. */ | |
51 /* In either case we should then insert the new entry */ | |
52 /* before the current value of "Entry". */ | |
53 for (; Entry != bucket; Entry = Entry->next) { | |
54 if (Entry->x_id == x_id) { | |
55 /* Entry has the same XId... */ | |
56 if (Entry->display == dpy) { | |
57 /* Entry has the same Display... */ | |
58 /* Therefore there is already an */ | |
59 /* entry with this XId and Display, */ | |
60 /* reset its data value and return. */ | |
61 Entry->data = data; | |
62 return; | |
63 } | |
64 /* We found an association with the right */ | |
65 /* id but the wrong display! */ | |
66 continue; | |
67 } | |
68 /* If the current entry's XId is greater than the */ | |
69 /* XId of the entry to be inserted then we have */ | |
70 /* passed the location where the new XId should */ | |
71 /* be inserted. */ | |
72 if (Entry->x_id > x_id) break; | |
73 } | |
74 } | |
75 | |
76 /* If we are here then the new entry should be inserted just */ | |
77 /* before the current value of "Entry". */ | |
78 /* Create a new XAssoc and load it with new provided data. */ | |
77837
77b2ab19bece
Ulrich Mueller <ulm at gentoo.org> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
76174
diff
changeset
|
79 new_entry = (XAssoc *) malloc(sizeof(XAssoc)); |
25858 | 80 new_entry->display = dpy; |
81 new_entry->x_id = x_id; | |
82 new_entry->data = data; | |
83 | |
84 /* Insert the new entry. */ | |
85 emacs_insque((struct qelem *)new_entry, (struct qelem *)Entry->prev); | |
86 } | |
87 | |
52401 | 88 /* arch-tag: d7e3fb8a-f3b3-4c5d-a307-75ca67ec1b49 |
89 (do not change this comment) */ |