]>
Commit | Line | Data |
---|---|---|
5489fcc3 KR |
1 | #include "libiberty.h" |
2 | #include "gprof.h" | |
3 | #include "search_list.h" | |
4 | ||
5 | ||
6 | void | |
12516a37 KR |
7 | DEFUN (search_list_append, (list, paths), |
8 | Search_List * list AND const char *paths) | |
5489fcc3 | 9 | { |
12516a37 KR |
10 | Search_List_Elem *new_el; |
11 | const char *beg, *colon; | |
12 | int len; | |
5489fcc3 | 13 | |
12516a37 KR |
14 | colon = paths - 1; |
15 | do | |
16 | { | |
17 | beg = colon + 1; | |
18 | colon = strchr (beg, ':'); | |
19 | if (colon) | |
20 | { | |
21 | len = colon - beg; | |
22 | } | |
23 | else | |
24 | { | |
25 | len = strlen (beg); | |
03c35bcb | 26 | } |
12516a37 KR |
27 | new_el = (Search_List_Elem *) xmalloc (sizeof (*new_el) + len); |
28 | memcpy (new_el->path, beg, len); | |
29 | new_el->path[len] = '\0'; | |
5489fcc3 | 30 | |
12516a37 KR |
31 | /* append new path at end of list: */ |
32 | new_el->next = 0; | |
33 | if (list->tail) | |
34 | { | |
35 | list->tail->next = new_el; | |
36 | } | |
37 | else | |
38 | { | |
39 | list->head = new_el; | |
03c35bcb | 40 | } |
12516a37 KR |
41 | list->tail = new_el; |
42 | } | |
43 | while (colon); | |
03c35bcb | 44 | } |