Skip to content

Commit f76d8a1

Browse files
committed
Remove unused code from oldlist
Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 3377ed2 commit f76d8a1

File tree

2 files changed

+25
-294
lines changed

2 files changed

+25
-294
lines changed

src/cutil/oldlist.cpp

+24-160
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
# File: oldlist.cpp
55
# Description: List processing procedures.
66
# Author: Mark Seaman, Software Productivity
7-
# Created: Thu Jul 23 13:24:09 1987
8-
# Modified: Thu Dec 22 10:59:52 1988 (Mark Seaman) marks@hpgrlt
9-
# Language: C
10-
# Package: N/A
11-
# Status: Reusable Software Component
127
#
138
# (c) Copyright 1987, Hewlett-Packard Company.
149
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -53,21 +48,6 @@
5348
count LENGTH x = count(l);
5449
search MEMBER if (search(l, x, nullptr))
5550
56-
To implement SETS use:
57-
58-
adjoin l = adjoin(l, x);
59-
set_union l = set_union(r, s);
60-
intersection l = intersection(r, s);
61-
set_difference l = set_difference(r, s);
62-
delete l = delete(s, x, nullptr);
63-
search if (search(l, x, nullptr))
64-
65-
To Implement Associated LISTS use:
66-
67-
lpush l = lpush(l, p);
68-
assoc s = assoc(l, x);
69-
adelete l = adelete(l, x);
70-
7151
The following rules of closure exist for the functions provided.
7252
a = first_node (push (a, b))
7353
b = list_rest (push (a, b))
@@ -87,9 +67,31 @@
8767
#define add_on(l, x) l = push(l, first_node(x))
8868
#define next_one(l) l = list_rest(l)
8969

70+
/**********************************************************************
71+
* c o p y f i r s t
72+
*
73+
* Do the appropriate kind a push operation to copy the first node from
74+
* one list to another.
75+
*
76+
**********************************************************************/
77+
78+
#define copy_first(l1,l2) \
79+
(l2=push(l2, first_node(l1)))
80+
9081
/*----------------------------------------------------------------------
9182
F u n c t i o n s
9283
----------------------------------------------------------------------*/
84+
85+
/**********************************************************************
86+
* i s s a m e
87+
*
88+
* Compare the list node with the key value return TRUE (non-zero)
89+
* if they are equivalent strings. (Return FALSE if not)
90+
**********************************************************************/
91+
static int is_same(void *item1, void *item2) {
92+
return strcmp((char *)item1, (char *)item2) == 0;
93+
}
94+
9395
/**********************************************************************
9496
* c o u n t
9597
*
@@ -108,8 +110,7 @@ int count(LIST var_list) {
108110
* Delete all the elements out of the current list that match the key.
109111
* This operation destroys the original list. The caller will supply a
110112
* routine that will compare each node to the
111-
* key, and return a non-zero value when they match. If the value
112-
* nullptr is supplied for is_equal, the is_key routine will be used.
113+
* key, and return a non-zero value when they match.
113114
**********************************************************************/
114115
LIST delete_d(LIST list, void *key, int_compare is_equal) {
115116
LIST result = NIL_LIST;
@@ -137,31 +138,6 @@ LIST delete_d(LIST list, void *key, int_compare is_equal) {
137138
return (result);
138139
}
139140

140-
LIST delete_d(LIST list, void *key,
141-
TessResultCallback2<int, void *, void *> *is_equal) {
142-
LIST result = NIL_LIST;
143-
LIST last_one = NIL_LIST;
144-
145-
while (list != NIL_LIST) {
146-
if (!(*is_equal).Run(first_node(list), key)) {
147-
if (last_one == NIL_LIST) {
148-
last_one = list;
149-
list = list_rest(list);
150-
result = last_one;
151-
set_rest(last_one, NIL_LIST);
152-
} else {
153-
set_rest(last_one, list);
154-
last_one = list;
155-
list = list_rest(list);
156-
set_rest(last_one, NIL_LIST);
157-
}
158-
} else {
159-
list = pop(list);
160-
}
161-
}
162-
return (result);
163-
}
164-
165141
/**********************************************************************
166142
* d e s t r o y
167143
*
@@ -192,48 +168,6 @@ void destroy_nodes(LIST list, void_dest destructor) {
192168
}
193169
}
194170

195-
/**********************************************************************
196-
* i n s e r t
197-
*
198-
* Create a list element and rearange the pointers so that the first
199-
* element in the list is the second aurgment.
200-
**********************************************************************/
201-
void insert(LIST list, void *node) {
202-
LIST element;
203-
204-
if (list != NIL_LIST) {
205-
element = push(NIL_LIST, node);
206-
set_rest(element, list_rest(list));
207-
set_rest(list, element);
208-
node = first_node(list);
209-
list->node = first_node(list_rest(list));
210-
list->next->node = (LIST)node;
211-
}
212-
}
213-
214-
/**********************************************************************
215-
* i s s a m e
216-
*
217-
* Compare the list node with the key value return TRUE (non-zero)
218-
* if they are equivalent strings. (Return FALSE if not)
219-
**********************************************************************/
220-
int is_same(void *item1, void *item2) {
221-
return strcmp((char *)item1, (char *)item2) == 0 ? 1 : 0;
222-
}
223-
224-
/**********************************************************************
225-
* j o i n
226-
*
227-
* Join the two lists together. This function is similar to concat
228-
* except that concat creates a new list. This function returns the
229-
* first list updated.
230-
**********************************************************************/
231-
LIST join(LIST list1, LIST list2) {
232-
if (list1 == NIL_LIST) return (list2);
233-
set_rest(last(list1), list2);
234-
return (list1);
235-
}
236-
237171
/**********************************************************************
238172
* l a s t
239173
*
@@ -244,19 +178,6 @@ LIST last(LIST var_list) {
244178
return (var_list);
245179
}
246180

247-
/**********************************************************************
248-
* n t h c e l l
249-
*
250-
* Return nth list cell in the list.
251-
**********************************************************************/
252-
void *nth_cell(LIST var_list, int item_num) {
253-
int x = 0;
254-
iterate(var_list) {
255-
if (x++ == item_num) return (var_list);
256-
}
257-
return (var_list);
258-
}
259-
260181
/**********************************************************************
261182
* p o p
262183
*
@@ -305,73 +226,16 @@ LIST push_last(LIST list, void *item) {
305226
return (push(NIL_LIST, item));
306227
}
307228

308-
/**********************************************************************
309-
* r e v e r s e
310-
*
311-
* Create a new list with the elements reversed. The old list is not
312-
* destroyed.
313-
**********************************************************************/
314-
LIST reverse(LIST list) {
315-
LIST newlist = NIL_LIST;
316-
317-
iterate(list) copy_first(list, newlist);
318-
return (newlist);
319-
}
320-
321-
/**********************************************************************
322-
* r e v e r s e d
323-
*
324-
* Create a new list with the elements reversed. The old list is
325-
* destroyed.
326-
**********************************************************************/
327-
LIST reverse_d(LIST list) {
328-
LIST result = reverse(list);
329-
destroy(list);
330-
return (result);
331-
}
332-
333-
/**********************************************************************
334-
* s a d j o i n
335-
*
336-
* Adjoin an element to an assorted list. The original list is
337-
* modified. Returns the modified list.
338-
**********************************************************************/
339-
LIST s_adjoin(LIST var_list, void *variable, int_compare compare) {
340-
LIST l;
341-
int result;
342-
343-
if (compare == nullptr) compare = (int_compare)strcmp;
344-
345-
l = var_list;
346-
iterate(l) {
347-
result = (*compare)(variable, first_node(l));
348-
if (result == 0)
349-
return (var_list);
350-
else if (result < 0) {
351-
insert(l, variable);
352-
return (var_list);
353-
}
354-
}
355-
return (push_last(var_list, variable));
356-
}
357-
358229
/**********************************************************************
359230
* s e a r c h
360231
*
361232
* Search list, return NIL_LIST if not found. Return the list starting from
362233
* the item if found. The compare routine "is_equal" is passed in as
363-
* the third parameter to this routine. If the value nullptr is supplied
364-
* for is_equal, the is_key routine will be used.
234+
* the third parameter to this routine.
365235
**********************************************************************/
366236
LIST search(LIST list, void *key, int_compare is_equal) {
367237
if (is_equal == nullptr) is_equal = is_same;
368238

369239
iterate(list) if ((*is_equal)(first_node(list), key)) return (list);
370240
return (NIL_LIST);
371241
}
372-
373-
LIST search(LIST list, void *key,
374-
TessResultCallback2<int, void *, void *> *is_equal) {
375-
iterate(list) if ((*is_equal).Run(first_node(list), key)) return (list);
376-
return (NIL_LIST);
377-
}

0 commit comments

Comments
 (0)