ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/recipe.C
(Generate patch)

Comparing deliantra/server/common/recipe.C (file contents):
Revision 1.6 by root, Thu Sep 14 21:16:11 2006 UTC vs.
Revision 1.20 by root, Thu May 17 21:32:08 2007 UTC

1 1/*
2 * CrossFire, A Multiplayer game
3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) Mark Wedel & Crossfire Development Team
6 * Copyright (C) Frank Tore Johansen
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
23 */
2 24
3/* Basic stuff for use with the alchemy code. Clearly some of this stuff 25/* Basic stuff for use with the alchemy code. Clearly some of this stuff
4 * could go into server/alchemy, but I left it here just in case it proves 26 * could go into server/alchemy, but I left it here just in case it proves
5 * more generally useful. 27 * more generally useful.
6 * 28 *
12 * Ingredients are just comma delimited list of archetype (or object) 34 * Ingredients are just comma delimited list of archetype (or object)
13 * names. 35 * names.
14 */ 36 */
15 37
16/* Example 'formula' entry in libdir/formulae: 38/* Example 'formula' entry in libdir/formulae:
17 * Object transparency 39 * object transparency
18 * chance 10 40 * chance 10
19 * ingred dust of beholdereye,gem 41 * ingred dust of beholdereye,gem
20 * arch potion_generic 42 * arch potion_generic
21 */ 43 */
22 44
45#include <cctype>
46
23#include <global.h> 47#include <global.h>
24#include <object.h> 48#include <object.h>
25#include <ctype.h>
26 49
27static void build_stringlist (const char *str, char ***result_list, size_t * result_size); 50static void build_stringlist (const char *str, char ***result_list, size_t * result_size);
28 51
29static recipelist *formulalist; 52static recipelist *formulalist;
30 53
33{ 56{
34 recipelist *tl = new recipelist; 57 recipelist *tl = new recipelist;
35 58
36 tl->total_chance = 0; 59 tl->total_chance = 0;
37 tl->number = 0; 60 tl->number = 0;
38 tl->items = NULL; 61 tl->items = 0;
39 tl->next = NULL; 62 tl->next = 0;
63
40 return tl; 64 return tl;
41} 65}
42 66
43static recipe * 67static recipe *
44get_empty_formula (void) 68get_empty_formula (void)
61 t->next = NULL; 85 t->next = NULL;
62 return t; 86 return t;
63} 87}
64 88
65/* get_formulalist() - returns pointer to the formula list */ 89/* get_formulalist() - returns pointer to the formula list */
66
67recipelist * 90recipelist *
68get_formulalist (int i) 91get_formulalist (int i)
69{ 92{
70 recipelist *fl = formulalist; 93 recipelist *fl = formulalist;
71 int number = i; 94 int number = i;
74 { 97 {
75 if (!(fl = fl->next)) 98 if (!(fl = fl->next))
76 break; 99 break;
77 number--; 100 number--;
78 } 101 }
102
79 return fl; 103 return fl;
80} 104}
81 105
82/* check_recipe() - makes sure we actually have the requested artifact 106/* check_recipe() - makes sure we actually have the requested artifact
83 * and archetype. */ 107 * and archetype. */
84
85static int 108static int
86check_recipe (const recipe *rp) 109check_recipe (const recipe *rp)
87{ 110{
88 size_t i; 111 size_t i;
89 int result; 112 int result = 1;
90 113
91 result = 1;
92 for (i = 0; i < rp->arch_names; i++) 114 for (i = 0; i < rp->arch_names; i++)
93 { 115 {
94 if (archetype::find (rp->arch_name[i]) != NULL) 116 if (archetype::find (rp->arch_name[i]) != NULL)
95 { 117 {
96 artifact *art = locate_recipe_artifact (rp, i); 118 artifact *art = locate_recipe_artifact (rp, i);
97 119
98 if (!art && strcmp (rp->title, "NONE") != 0) 120 if (!art && strcmp (rp->title, "NONE") != 0)
99 { 121 {
100 LOG (llevError, "\nWARNING: Formula %s of %s has no artifact.\n", rp->arch_name[i], &rp->title); 122 LOG (llevError, "WARNING: Formula %s of %s has no artifact.\n", rp->arch_name[i], &rp->title);
101 result = 0; 123 result = 0;
102 } 124 }
103 } 125 }
104 else 126 else
105 { 127 {
106 LOG (llevError, "\nWARNING: Can't find archetype %s for formula %s\n", rp->arch_name[i], &rp->title); 128 LOG (llevError, "WARNING: Can't find archetype %s for formula %s\n", rp->arch_name[i], &rp->title);
107 result = 0; 129 result = 0;
108 } 130 }
109 } 131 }
110 132
111 return result; 133 return result;
112} 134}
113
114 135
115/* 136/*
116 * init_formulae() - Builds up the lists of formula from the file in 137 * init_formulae() - Builds up the lists of formula from the file in
117 * the libdir. -b.t. 138 * the libdir. -b.t.
118 */ 139 */
119
120void 140void
121init_formulae (void) 141init_formulae (void)
122{ 142{
123 static int has_been_done = 0; 143 static int has_been_done = 0;
124 FILE *fp; 144 FILE *fp;
135 return; 155 return;
136 else 156 else
137 has_been_done = 1; 157 has_been_done = 1;
138 158
139 sprintf (filename, "%s/formulae", settings.datadir); 159 sprintf (filename, "%s/formulae", settings.datadir);
140 LOG (llevDebug, "Reading alchemical formulae from %s...", filename); 160 LOG (llevDebug, "Reading alchemical formulae from %s...\n", filename);
141 if ((fp = open_and_uncompress (filename, 0, &comp)) == NULL) 161 if ((fp = open_and_uncompress (filename, 0, &comp)) == NULL)
142 { 162 {
143 LOG (llevError, "Can't open %s.\n", filename); 163 LOG (llevError, "Can't open %s.\n", filename);
144 return; 164 return;
145 } 165 }
152 *cp = '\0'; 172 *cp = '\0';
153 cp = buf; 173 cp = buf;
154 while (*cp == ' ') /* Skip blanks */ 174 while (*cp == ' ') /* Skip blanks */
155 cp++; 175 cp++;
156 176
157 if (!strncmp (cp, "Object", 6)) 177 if (!strncmp (cp, "object", 6))
158 { 178 {
159 formula = get_empty_formula (); 179 formula = get_empty_formula ();
160 formula->title = strchr (cp, ' ') + 1; 180 formula->title = strchr (cp, ' ') + 1;
161 } 181 }
162 else if (!strncmp (cp, "keycode", 7)) 182 else if (!strncmp (cp, "keycode", 7))
163 {
164 formula->keycode = strchr (cp, ' ') + 1; 183 formula->keycode = strchr (cp, ' ') + 1;
165 }
166 else if (sscanf (cp, "trans %d", &value)) 184 else if (sscanf (cp, "trans %d", &value))
167 {
168 formula->transmute = (uint16) value; 185 formula->transmute = (uint16) value;
169 }
170 else if (sscanf (cp, "yield %d", &value)) 186 else if (sscanf (cp, "yield %d", &value))
171 {
172 formula->yield = (uint16) value; 187 formula->yield = (uint16) value;
173 }
174 else if (sscanf (cp, "chance %d", &value)) 188 else if (sscanf (cp, "chance %d", &value))
175 {
176 formula->chance = (uint16) value; 189 formula->chance = (uint16) value;
177 }
178 else if (sscanf (cp, "exp %d", &value)) 190 else if (sscanf (cp, "exp %d", &value))
179 {
180 formula->exp = (uint16) value; 191 formula->exp = (uint16) value;
181 }
182 else if (sscanf (cp, "diff %d", &value)) 192 else if (sscanf (cp, "diff %d", &value))
183 {
184 formula->diff = (uint16) value; 193 formula->diff = (uint16) value;
185 }
186 else if (!strncmp (cp, "ingred", 6)) 194 else if (!strncmp (cp, "ingred", 6))
187 { 195 {
188 int numb_ingred = 1; 196 int numb_ingred = 1;
189 197
190 cp = strchr (cp, ' ') + 1; 198 cp = strchr (cp, ' ') + 1;
193 if ((next = strchr (cp, ',')) != NULL) 201 if ((next = strchr (cp, ',')) != NULL)
194 { 202 {
195 *(next++) = '\0'; 203 *(next++) = '\0';
196 numb_ingred++; 204 numb_ingred++;
197 } 205 }
206
198 tmp = new linked_char; 207 tmp = new linked_char;
199 208
200 tmp->name = cp; 209 tmp->name = cp;
201 tmp->next = formula->ingred; 210 tmp->next = formula->ingred;
202 formula->ingred = tmp; 211 formula->ingred = tmp;
205 * quickly for the right recipe. 214 * quickly for the right recipe.
206 */ 215 */
207 formula->index += strtoint (cp); 216 formula->index += strtoint (cp);
208 } 217 }
209 while ((cp = next) != NULL); 218 while ((cp = next) != NULL);
219
210 /* now find the correct (# of ingred ordered) formulalist */ 220 /* now find the correct (# of ingred ordered) formulalist */
211 fl = formulalist; 221 fl = formulalist;
212 while (numb_ingred != 1) 222 while (numb_ingred != 1)
213 { 223 {
214 if (!fl->next) 224 if (!fl->next)
215 fl->next = init_recipelist (); 225 fl->next = init_recipelist ();
226
216 fl = fl->next; 227 fl = fl->next;
217 numb_ingred--; 228 numb_ingred--;
218 } 229 }
230
219 fl->total_chance += formula->chance; 231 fl->total_chance += formula->chance;
220 fl->number++; 232 fl->number++;
221 formula->next = fl->items; 233 formula->next = fl->items;
222 fl->items = formula; 234 fl->items = formula;
223 } 235 }
225 { 237 {
226 build_stringlist (strchr (cp, ' ') + 1, &formula->arch_name, &formula->arch_names); 238 build_stringlist (strchr (cp, ' ') + 1, &formula->arch_name, &formula->arch_names);
227 check_recipe (formula); 239 check_recipe (formula);
228 } 240 }
229 else if (!strncmp (cp, "skill", 5)) 241 else if (!strncmp (cp, "skill", 5))
230 {
231 formula->skill = strchr (cp, ' ') + 1; 242 formula->skill = strchr (cp, ' ') + 1;
232 }
233 else if (!strncmp (cp, "cauldron", 8)) 243 else if (!strncmp (cp, "cauldron", 8))
234 {
235 formula->cauldron = strchr (cp, ' ') + 1; 244 formula->cauldron = strchr (cp, ' ') + 1;
236 }
237 else 245 else
238 LOG (llevError, "Unknown input in file %s: %s\n", filename, buf); 246 LOG (llevError, "Unknown input in file %s: %s\n", filename, buf);
239 } 247 }
248
240 LOG (llevDebug, "done.\n"); 249 LOG (llevDebug, "done.\n");
241 close_and_delete (fp, comp); 250 close_and_delete (fp, comp);
242 /* Lastly, lets check for problems in formula we got */ 251 /* Lastly, lets check for problems in formula we got */
243 check_formulae (); 252 check_formulae ();
244} 253}
255{ 264{
256 recipelist *fl; 265 recipelist *fl;
257 recipe *check, *formula; 266 recipe *check, *formula;
258 int numb = 1; 267 int numb = 1;
259 268
260 LOG (llevDebug, "Checking formulae lists..."); 269 LOG (llevDebug, "Checking formulae lists...\n");
261 270
262 for (fl = formulalist; fl != NULL; fl = fl->next) 271 for (fl = formulalist; fl; fl = fl->next)
263 { 272 {
264 for (formula = fl->items; formula != NULL; formula = formula->next) 273 for (formula = fl->items; formula; formula = formula->next)
265 for (check = formula->next; check != NULL; check = check->next) 274 for (check = formula->next; check; check = check->next)
266 if (check->index == formula->index) 275 if (check->index == formula->index)
267 { 276 {
268 LOG (llevError, " ERROR: On %d ingred list: ", numb); 277 LOG (llevError, " ERROR: On %d ingred list: ", numb);
269 LOG (llevError, "Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n", 278 LOG (llevError, "Formulae [%s] of %s and [%s] of %s have matching index id (%d)\n",
270 formula->arch_name[0], &formula->title, check->arch_name[0], &check->title, formula->index); 279 formula->arch_name[0], &formula->title, check->arch_name[0], &check->title, formula->index);
289 fprintf (logfile, "\n"); 298 fprintf (logfile, "\n");
290 while (fl) 299 while (fl)
291 { 300 {
292 fprintf (logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", 301 fprintf (logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n",
293 num_ingred, num_ingred > 1 ? "s." : ".", fl->number, fl->total_chance); 302 num_ingred, num_ingred > 1 ? "s." : ".", fl->number, fl->total_chance);
294 for (formula = fl->items; formula != NULL; formula = formula->next) 303 for (formula = fl->items; formula; formula = formula->next)
295 { 304 {
296 artifact *art = NULL; 305 artifact *art = NULL;
297 char buf[MAX_BUF]; 306 char buf[MAX_BUF];
298 size_t i; 307 size_t i;
299 308
303 312
304 if (archetype::find (string) != NULL) 313 if (archetype::find (string) != NULL)
305 { 314 {
306 art = locate_recipe_artifact (formula, i); 315 art = locate_recipe_artifact (formula, i);
307 if (!art && strcmp (formula->title, "NONE")) 316 if (!art && strcmp (formula->title, "NONE"))
308 LOG (llevError, "Formula %s has no artifact\n", &formula->title); 317 LOG (llevError, "Formula %s has no artifact!\n", &formula->title);
309 else 318 else
310 { 319 {
311 if (strcmp (formula->title, "NONE")) 320 if (strcmp (formula->title, "NONE"))
312 sprintf (buf, "%s of %s", string, &formula->title); 321 sprintf (buf, "%s of %s", string, &formula->title);
313 else 322 else
352 * only there to prevent infinite loops in treasure lists (a list 361 * only there to prevent infinite loops in treasure lists (a list
353 * referencing another list pointing back to the first one). */ 362 * referencing another list pointing back to the first one). */
354archetype * 363archetype *
355find_treasure_by_name (const treasure *t, const char *name, int depth) 364find_treasure_by_name (const treasure *t, const char *name, int depth)
356{ 365{
357 treasurelist *tl;
358 archetype *at;
359
360 if (depth > 10) 366 if (depth > 10)
361 return NULL; 367 return 0;
362 while (t != NULL) 368
369 while (t)
363 { 370 {
364 if (t->name != NULL) 371 if (t->name)
365 { 372 {
366 tl = find_treasurelist (t->name); 373 if (treasurelist *tl = treasurelist::find (t->name))
374 if (tl->items)
367 at = find_treasure_by_name (tl->items, name, depth + 1); 375 if (archetype *at = find_treasure_by_name (tl->items, name, depth + 1))
368 if (at != NULL)
369 return at; 376 return at;
370 } 377 }
371 else 378 else
372 { 379 {
373 if (!strcasecmp (t->item->clone.name, name)) 380 if (t->item && !strcasecmp (t->item->clone.name, name))
374 return t->item; 381 return t->item;
375 } 382 }
383
376 if (t->next_yes != NULL) 384 if (t->next_yes)
377 {
378 at = find_treasure_by_name (t->next_yes, name, depth); 385 if (archetype *at = find_treasure_by_name (t->next_yes, name, depth))
379 if (at != NULL)
380 return at; 386 return at;
381 } 387
382 if (t->next_no != NULL) 388 if (t->next_no)
383 {
384 at = find_treasure_by_name (t->next_no, name, depth); 389 if (archetype *at = find_treasure_by_name (t->next_no, name, depth))
385 if (at != NULL)
386 return at; 390 return at;
387 } 391
388 t = t->next; 392 t = t->next;
389 } 393 }
394
390 return NULL; 395 return 0;
391} 396}
392 397
393/* If several archetypes have the same name, the value of the first 398/* If several archetypes have the same name, the value of the first
394 * one with that name will be returned. This happens for the 399 * one with that name will be returned. This happens for the
395 * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the 400 * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the
415 while (isdigit (*name)) 420 while (isdigit (*name))
416 { 421 {
417 mult = 10 * mult + (*name - '0'); 422 mult = 10 * mult + (*name - '0');
418 name++; 423 name++;
419 } 424 }
425
420 if (mult > 0) 426 if (mult > 0)
421 name++; 427 name++;
422 else 428 else
423 mult = 1; 429 mult = 1;
430
424 /* first, try to match the name of an archetype */ 431 /* first, try to match the name of an archetype */
425 for (at = first_archetype; at != NULL; at = at->next) 432 for (at = first_archetype; at != NULL; at = at->next)
426 { 433 {
427 if (at->clone.title != NULL) 434 if (at->clone.title != NULL)
428 { 435 {
432 return mult * at->clone.value; 439 return mult * at->clone.value;
433 } 440 }
434 if (!strcasecmp (at->clone.name, name)) 441 if (!strcasecmp (at->clone.name, name))
435 return mult * at->clone.value; 442 return mult * at->clone.value;
436 } 443 }
444
437 /* second, try to match an artifact ("arch of something") */ 445 /* second, try to match an artifact ("arch of something") */
438 cp = strstr (name, " of "); 446 cp = strstr (name, " of ");
439 if (cp != NULL) 447 if (cp != NULL)
440 { 448 {
441 strcpy (part1, name); 449 strcpy (part1, name);
442 part1[cp - name] = '\0'; 450 part1[cp - name] = '\0';
443 strcpy (part2, cp + 4); 451 strcpy (part2, cp + 4);
444 /* find the first archetype matching the first part of the name */ 452 /* find the first archetype matching the first part of the name */
445 for (at = first_archetype; at != NULL; at = at->next) 453 for (at = first_archetype; at; at = at->next)
446 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) 454 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL)
447 break; 455 break;
448 if (at != NULL) 456 if (at != NULL)
449 { 457 {
450 /* find the first artifact derived from that archetype (same type) */ 458 /* find the first artifact derived from that archetype (same type) */
451 for (al = first_artifactlist; al != NULL; al = al->next) 459 for (al = first_artifactlist; al; al = al->next)
452 if (al->type == at->clone.type) 460 if (al->type == at->clone.type)
453 { 461 {
454 for (art = al->items; art != NULL; art = art->next) 462 for (art = al->items; art; art = art->next)
455 if (!strcasecmp (art->item->name, part2)) 463 if (!strcasecmp (art->item->name, part2))
456 return mult * at->clone.value * art->item->value; 464 return mult * at->clone.value * art->item->value;
457 } 465 }
458 } 466 }
459 } 467 }
468
460 /* third, try to match a body part ("arch's something") */ 469 /* third, try to match a body part ("arch's something") */
461 cp = strstr (name, "'s "); 470 cp = strstr (name, "'s ");
462 if (cp != NULL) 471 if (cp)
463 { 472 {
464 strcpy (part1, name); 473 strcpy (part1, name);
465 part1[cp - name] = '\0'; 474 part1[cp - name] = '\0';
466 strcpy (part2, cp + 3); 475 strcpy (part2, cp + 3);
467 /* examine all archetypes matching the first part of the name */ 476 /* examine all archetypes matching the first part of the name */
468 for (at = first_archetype; at != NULL; at = at->next) 477 for (at = first_archetype; at; at = at->next)
469 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) 478 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL)
470 { 479 {
471 if (at->clone.randomitems != NULL) 480 if (at->clone.randomitems)
472 { 481 {
473 at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); 482 at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0);
474 if (at2 != NULL) 483 if (at2)
475 return mult * at2->clone.value * isqrt (at->clone.level * 2); 484 return mult * at2->clone.value * isqrt (at->clone.level * 2);
476 } 485 }
477 } 486 }
478 } 487 }
488
479 /* failed to find any matching items -- formula should be checked */ 489 /* failed to find any matching items -- formula should be checked */
480 return -1; 490 return -1;
481} 491}
482 492
483/* code copied from dump_alchemy() and modified by Raphael Quinet */ 493/* code copied from dump_alchemy() and modified by Raphael Quinet */
495 fprintf (logfile, "\n"); 505 fprintf (logfile, "\n");
496 while (fl) 506 while (fl)
497 { 507 {
498 fprintf (logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", 508 fprintf (logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n",
499 num_ingred, num_ingred > 1 ? "s." : ".", fl->number, fl->total_chance); 509 num_ingred, num_ingred > 1 ? "s." : ".", fl->number, fl->total_chance);
500 for (formula = fl->items; formula != NULL; formula = formula->next) 510 for (formula = fl->items; formula; formula = formula->next)
501 { 511 {
502 artifact *art = NULL; 512 artifact *art = NULL;
503 archetype *at = NULL; 513 archetype *at = NULL;
504 char buf[MAX_BUF]; 514 char buf[MAX_BUF];
505 size_t i; 515 size_t i;
603} 613}
604 614
605artifact * 615artifact *
606locate_recipe_artifact (const recipe *rp, size_t idx) 616locate_recipe_artifact (const recipe *rp, size_t idx)
607{ 617{
608 object *item = get_archetype (rp->arch_name[idx]); 618 archetype *at = archetype::find (rp->arch_name [idx]);
609 artifactlist *at = NULL;
610 artifact *art = NULL;
611 619
612 if (!item) 620 if (at)
613 return (artifact *) NULL; 621 if (artifactlist *al = find_artifactlist (at->clone.type))
614
615 if ((at = find_artifactlist (item->type)))
616 for (art = at->items; art; art = art->next) 622 for (artifact *art = al->items; art; art = art->next)
617 if (!strcmp (art->item->name, rp->title)) 623 if (art->item->name == rp->title)
618 break; 624 return art;
619 625
620 free_object (item);
621
622 return art; 626 return 0;
623} 627}
624 628
625int 629int
626numb_ingred (const char *buf) 630numb_ingred (const char *buf)
627{ 631{
643 for (fl = get_formulalist (1); fl; fl = fl->next) 647 for (fl = get_formulalist (1); fl; fl = fl->next)
644 number++; 648 number++;
645 649
646 /* now, randomly choose one */ 650 /* now, randomly choose one */
647 if (number > 0) 651 if (number > 0)
648 roll = RANDOM () % number; 652 roll = rndm (number);
649 653
650 fl = get_formulalist (1); 654 fl = get_formulalist (1);
651 while (roll && fl) 655 while (roll && fl)
652 { 656 {
653 if (fl->next) 657 if (fl->next)
676 if ((fl = get_random_recipelist ()) == NULL) 680 if ((fl = get_random_recipelist ()) == NULL)
677 return rp; 681 return rp;
678 682
679 if (fl->total_chance > 0) 683 if (fl->total_chance > 0)
680 { 684 {
681 r = RANDOM () % fl->total_chance; 685 r = rndm (fl->total_chance);
682 for (rp = fl->items; rp; rp = rp->next) 686 for (rp = fl->items; rp; rp = rp->next)
683 { 687 {
684 r -= rp->chance; 688 r -= rp->chance;
685 if (r < 0) 689 if (r < 0)
686 break; 690 break;
737 char *dup; 741 char *dup;
738 char *p; 742 char *p;
739 size_t size; 743 size_t size;
740 size_t i; 744 size_t i;
741 745
742 dup = strdup_local (str); 746 dup = strdup (str);
743 if (dup == NULL) 747 if (dup == NULL)
744 fatal (OUT_OF_MEMORY); 748 fatal (OUT_OF_MEMORY);
745 749
746 size = 0; 750 size = 0;
747 for (p = strtok (dup, ","); p != NULL; p = strtok (NULL, ",")) 751 for (p = strtok (dup, ","); p != NULL; p = strtok (NULL, ","))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines