MCPcopy Create free account
hub / github.com/NetHack/NetHack / add_custom_urep_entry

Function add_custom_urep_entry

src/utf8map.c:147–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147int
148add_custom_urep_entry(
149 const char *customization_name,
150 int glyphidx,
151 uint32 utf32ch,
152 const uint8 *utf8str,
153 enum graphics_sets which_set)
154{
155 struct symset_customization *gdc
156 = &gs.sym_customizations[which_set][custom_ureps];
157 struct customization_detail *details, *newdetails = 0;
158
159
160 if (!gdc->details) {
161 gdc->customization_name = dupstr(customization_name);
162 gdc->custtype = custom_ureps;
163 gdc->details = 0;
164 gdc->details_end = 0;
165 }
166 details = find_matching_customization(customization_name,
167 custom_ureps, which_set); /* FIXME */
168 if (details) {
169 while (details) {
170 if (details->content.urep.glyphidx == glyphidx) {
171 if (details->content.urep.u.utf8str)
172 free(details->content.urep.u.utf8str);
173 if (utf32ch) {
174 details->content.urep.u.utf8str =
175 (uint8 *) dupstr((const char *) utf8str);
176 details->content.urep.u.utf32ch = utf32ch;
177 } else {
178 details->content.urep.u.utf8str = (uint8 *) 0;
179 details->content.urep.u.utf32ch = 0;
180 }
181 return 1;
182 }
183 details = details->next;
184 }
185 }
186 /* create new details entry */
187 newdetails = (struct customization_detail *) alloc(
188 sizeof (struct customization_detail));
189 newdetails->content.urep.glyphidx = glyphidx;
190 if (utf8str && *utf8str) {
191 newdetails->content.urep.u.utf8str =
192 (uint8 *) dupstr((const char *) utf8str);
193 } else {
194 newdetails->content.urep.u.utf8str =
195 (uint8 *) 0;
196 }
197 newdetails->content.urep.u.utf32ch = utf32ch;
198 newdetails->next = (struct customization_detail *) 0;
199 if (gdc->details == NULL) {
200 gdc->details = newdetails;
201 } else {
202 gdc->details_end->next = newdetails;
203 }
204 gdc->details_end = newdetails;

Callers 1

Calls 3

dupstrFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected