Mercurial > emacs
annotate oldXMenu/XMakeAssoc.c @ 54736:b94de166de9d
(ethio-sera-being-called-by-w3): New
variable.
(ethio-sera-to-fidel-ethio): Check ethio-sera-being-called-by-w3
instead of sera-being-called-by-w3.
(ethio-fidel-to-sera-buffer): Likewise.
(ethio-find-file): Bind ethio-sera-being-called-by-w3 to t
instead of sera-being-called-by-w3.
(ethio-write-file): Likewise.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Mon, 05 Apr 2004 23:27:37 +0000 |
| parents | 695cf19ef79e |
| children | e8824c4f5f7e 375f2633d815 |
| rev | line source |
|---|---|
| 25858 | 1 /* $XConsortium: XMakeAssoc.c,v 10.18 91/01/06 12:09:28 rws Exp $ */ |
| 2 /* Copyright Massachusetts Institute of Technology 1985 */ | |
| 3 | |
| 4 /* | |
| 5 Permission to use, copy, modify, distribute, and sell this software and its | |
| 6 documentation for any purpose is hereby granted without fee, provided that | |
| 7 the above copyright notice appear in all copies and that both that | |
| 8 copyright notice and this permission notice appear in supporting | |
| 9 documentation, and that the name of M.I.T. not be used in advertising or | |
| 10 publicity pertaining to distribution of the software without specific, | |
| 11 written prior permission. M.I.T. makes no representations about the | |
| 12 suitability of this software for any purpose. It is provided "as is" | |
| 13 without express or implied warranty. | |
| 14 */ | |
| 15 | |
| 16 #include <config.h> | |
| 17 #include <X11/Xlib.h> | |
| 18 #include <X11/Xresource.h> | |
| 19 #include "X10.h" | |
| 20 #include <errno.h> | |
| 21 | |
| 22 #ifndef NULL | |
| 23 #define NULL 0 | |
| 24 #endif | |
| 25 | |
| 26 extern int errno; | |
| 27 | |
| 28 void emacs_insque(); | |
| 29 struct qelem { | |
| 30 struct qelem *q_forw; | |
| 31 struct qelem *q_back; | |
| 32 char q_data[1]; | |
| 33 }; | |
| 34 /* | |
| 35 * XMakeAssoc - Insert data into an XAssocTable keyed on an XId. | |
| 36 * Data is inserted into the table only once. Redundant inserts are | |
| 37 * meaningless (but cause no problems). The queue in each association | |
| 38 * bucket is sorted (lowest XId to highest XId). | |
| 39 */ | |
| 40 XMakeAssoc(dpy, table, x_id, data) | |
| 41 register Display *dpy; | |
| 42 register XAssocTable *table; | |
| 43 register XID x_id; | |
| 44 register caddr_t data; | |
| 45 { | |
| 46 int hash; | |
| 47 register XAssoc *bucket; | |
| 48 register XAssoc *Entry; | |
| 49 register XAssoc *new_entry; | |
|
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
25858
diff
changeset
|
50 |
| 25858 | 51 /* Hash the XId to get the bucket number. */ |
| 52 hash = x_id & (table->size - 1); | |
| 53 /* Look up the bucket to get the entries in that bucket. */ | |
| 54 bucket = &table->buckets[hash]; | |
| 55 /* Get the first entry in the bucket. */ | |
| 56 Entry = bucket->next; | |
| 57 | |
| 58 /* If (Entry != bucket), the bucket is empty so make */ | |
| 59 /* the new entry the first entry in the bucket. */ | |
| 60 /* if (Entry == bucket), the we have to search the */ | |
| 61 /* bucket. */ | |
| 62 if (Entry != bucket) { | |
| 63 /* The bucket isn't empty, begin searching. */ | |
| 64 /* If we leave the for loop then we have either passed */ | |
| 65 /* where the entry should be or hit the end of the bucket. */ | |
| 66 /* In either case we should then insert the new entry */ | |
| 67 /* before the current value of "Entry". */ | |
| 68 for (; Entry != bucket; Entry = Entry->next) { | |
| 69 if (Entry->x_id == x_id) { | |
| 70 /* Entry has the same XId... */ | |
| 71 if (Entry->display == dpy) { | |
| 72 /* Entry has the same Display... */ | |
| 73 /* Therefore there is already an */ | |
| 74 /* entry with this XId and Display, */ | |
| 75 /* reset its data value and return. */ | |
| 76 Entry->data = data; | |
| 77 return; | |
| 78 } | |
| 79 /* We found an association with the right */ | |
| 80 /* id but the wrong display! */ | |
| 81 continue; | |
| 82 } | |
| 83 /* If the current entry's XId is greater than the */ | |
| 84 /* XId of the entry to be inserted then we have */ | |
| 85 /* passed the location where the new XId should */ | |
| 86 /* be inserted. */ | |
| 87 if (Entry->x_id > x_id) break; | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 /* If we are here then the new entry should be inserted just */ | |
| 92 /* before the current value of "Entry". */ | |
| 93 /* Create a new XAssoc and load it with new provided data. */ | |
| 94 new_entry = (XAssoc *) xmalloc(sizeof(XAssoc)); | |
| 95 new_entry->display = dpy; | |
| 96 new_entry->x_id = x_id; | |
| 97 new_entry->data = data; | |
| 98 | |
| 99 /* Insert the new entry. */ | |
| 100 emacs_insque((struct qelem *)new_entry, (struct qelem *)Entry->prev); | |
| 101 } | |
| 102 | |
| 52401 | 103 /* arch-tag: d7e3fb8a-f3b3-4c5d-a307-75ca67ec1b49 |
| 104 (do not change this comment) */ |
