1 /* Ident --- unique handles for identifiers
2 Copyright (C) 1995, 1996 Markus Armbruster
3 All rights reserved. */
19 #define XX_USER(name) ident *id_##name;
20 #define XX_INTERNAL(name, str) XX_USER(name)
28 new_id_derived (const char *pfx, ident *id)
30 int pfx_len = strlen (pfx);
31 int len = pfx_len + ID_TO_STRLEN (id);
32 char *str = alloca (len);
34 memcpy (str, pfx, pfx_len);
35 memcpy (str+pfx_len, ID_TO_STR (id), ID_TO_STRLEN (id));
36 return ID_FROM_STR (str, pfx_len + ID_TO_STRLEN (id));
41 new_id_internal (void)
43 static char str[] = "_0000000";
47 while (++str[i] == '9'+1) {
49 /* if following assertion fails, we get called far too often ;-) */
52 assert (('0' <= str[i]) && (str[i] <= '9'));
54 return ID_FROM_STR (str, sizeof (str) - 1);
59 id_is_internal (ident *id)
61 assert (ID_TO_STRLEN (id));
62 return !!ispunct (ID_TO_STR(id)[0]);
73 for (i = 0; i < ARR_LEN (id); ++i) {
81 ident_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN)
83 ident *id = XP_GETARG (ident *, 0);
84 return XPMR (ID_TO_STR (id), ID_TO_STRLEN (id));
91 id_set = new_set (memcmp, TUNE_NIDENTS);
93 #define XX_USER(name) id_##name = ID_FROM_STR(#name, sizeof(#name)- 1);
94 #define XX_INTERNAL(name, str) id_##name = ID_FROM_STR((str), sizeof((str))-1);
101 inline ident *id_from_str (char *str, int len) {
103 return (const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len)));
106 inline const char *id_to_str (ident *id) {
107 return ((const char *)&(id)->dptr[0]);
110 inline int id_to_strlen(ident *id) {