1 /***************************************
4 C Cross Referencing & Documentation tool. Version 1.4.
6 Handle lists of strings.
7 ******************/ /******************
8 Written by Andrew M. Bishop
10 This file Copyright 1995,96,97 Andrew M. Bishop
11 It may be distributed under the GNU Public License, version 2, or
12 any higher version. See section COPYING of the GNU Public license
13 for conditions under which this file may be redistributed.
14 ***************************************/
16 /*+ Control the debugging information from this file. +*/
27 /*++++++++++++++++++++++++++++++++++++++
28 Called to initialise a new string list.
30 StringList NewStringList Returns an initialised string list.
31 ++++++++++++++++++++++++++++++++++++++*/
33 StringList
NewStringList(void)
35 StringList sl
=(StringList
)Calloc(1,sizeof(struct _StringList
));
38 printf("#Slist.c# Initialise string list\n");
45 /*++++++++++++++++++++++++++++++++++++++
46 Called to initialise a new string list 2.
48 StringList2 NewStringList2 Returns an initialised string list 2.
49 ++++++++++++++++++++++++++++++++++++++*/
51 StringList2
NewStringList2(void)
53 StringList2 sl
=(StringList2
)Calloc(1,sizeof(struct _StringList2
));
56 printf("#Slist.c# Initialise string list 2\n");
63 /*++++++++++++++++++++++++++++++++++++++
64 Add a string to the string list, the list stores a Malloced copy of str.
66 StringList sl The string list to add to.
68 char* str The string to add.
70 int alphalist If true then the list is sorted into alphabetical order.
72 int uniqlist If true then duplicated entries are not allowed to be added.
73 ++++++++++++++++++++++++++++++++++++++*/
75 void AddToStringList(StringList sl
,char* str
,int alphalist
,int uniqlist
)
80 printf("#Slist.c# Add string %s to the string list\n",str
);
85 if(!strcmp(str
,sl
->s
[i
]))
89 sl
->s
=(char**)Malloc(8*sizeof(char*));
92 sl
->s
=(char**)Realloc(sl
->s
,(sl
->n
+8)*sizeof(char*));
106 if(strcmp(str
,sl
->s
[i
])<0)
109 sl
->s
[i
]=MallocString(str
);
113 sl
->s
[sl
->n
]=shuffle
;
115 sl
->s
[sl
->n
]=MallocString(str
);
118 sl
->s
[sl
->n
]=MallocString(str
);
124 /*++++++++++++++++++++++++++++++++++++++
125 Add a pair of strings to the string list 2, the list stores a Malloced copy of the arguments.
127 StringList2 sl The string list 2 to add to.
129 char* str1 The first string to add.
131 char* str2 The second string to add.
133 int alphalist If true then the list is sorted into alphabetical order of the first string, then second string.
135 int uniqlist If true then duplicated entries of the first string are not allowed to be added.
136 ++++++++++++++++++++++++++++++++++++++*/
138 void AddToStringList2(StringList2 sl
,char* str1
,char* str2
,int alphalist
,int uniqlist
)
143 printf("#Slist.c# Add strings %s and %s to the string list 2\n",str1
,str2
);
148 if(!strcmp(str1
,sl
->s1
[i
]))
153 sl
->s1
=(char**)Malloc(8*sizeof(char*));
154 sl
->s2
=(char**)Malloc(8*sizeof(char*));
159 sl
->s1
=(char**)Realloc(sl
->s1
,(sl
->n
+8)*sizeof(char*));
160 sl
->s2
=(char**)Realloc(sl
->s2
,(sl
->n
+8)*sizeof(char*));
171 char* temp1
=sl
->s1
[i
];
172 char* temp2
=sl
->s2
[i
];
179 if(strcmp(str1
,sl
->s1
[i
])<0 ||
180 (str2
&& sl
->s2
[i
] && strcmp(str1
,sl
->s1
[i
])==0 && strcmp(str2
,sl
->s2
[i
])<0))
184 sl
->s1
[i
]=MallocString(str1
);
185 sl
->s2
[i
]=MallocString(str2
);
190 sl
->s1
[sl
->n
]=shuffle1
;
191 sl
->s2
[sl
->n
]=shuffle2
;
195 sl
->s1
[sl
->n
]=MallocString(str1
);
196 sl
->s2
[sl
->n
]=MallocString(str2
);
201 sl
->s1
[sl
->n
]=MallocString(str1
);
202 sl
->s2
[sl
->n
]=MallocString(str2
);
209 /*++++++++++++++++++++++++++++++++++++++
210 Delete a string list.
212 StringList sl The string list to delete.
213 ++++++++++++++++++++++++++++++++++++++*/
215 void DeleteStringList(StringList sl
)
229 /*++++++++++++++++++++++++++++++++++++++
230 Delete a string list 2.
232 StringList2 sl The string list 2 to delete.
233 ++++++++++++++++++++++++++++++++++++++*/
235 void DeleteStringList2(StringList2 sl
)