Coverage Report

Created: 2026-03-26 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aspell/common/string_list.cpp
Line
Count
Source
1
// This file is part of The New Aspell
2
// Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license
3
// version 2.0 or 2.1.  You should have received a copy of the LGPL
4
// license along with this library if you did not you can find
5
// it at http://www.gnu.org/.
6
7
#include "string_list.hpp"
8
//#include "iostream.hpp"
9
10
namespace acommon {
11
12
  void StringList::copy(const StringList & other)
13
44.9k
  {
14
44.9k
    StringListNode * * cur = &first;
15
44.9k
    StringListNode * other_cur = other.first;
16
1.33M
    while (other_cur != 0) {
17
1.28M
      *cur = new StringListNode(other_cur->data.c_str());
18
1.28M
      cur = &(*cur)->next;
19
1.28M
      other_cur = other_cur->next;
20
1.28M
    }
21
44.9k
    *cur = 0;
22
44.9k
  }
23
24
  void StringList::destroy()
25
111k
  {
26
1.46M
    while (first != 0) {
27
1.35M
      StringListNode * next = first->next;
28
1.35M
      delete first;
29
1.35M
      first = next;
30
1.35M
    }
31
111k
  }
32
33
  bool operator==(const StringList & rhs, 
34
      const StringList & lhs)
35
16.1k
  {
36
16.1k
    StringListNode * rhs_cur = rhs.first;
37
16.1k
    StringListNode * lhs_cur = lhs.first;
38
56.4k
    while (rhs_cur != 0 && lhs_cur != 0 && rhs_cur->data == lhs_cur->data) {
39
40.3k
      rhs_cur = rhs_cur->next;
40
40.3k
      lhs_cur = lhs_cur->next;
41
40.3k
    }
42
16.1k
    return rhs_cur == 0 && lhs_cur == 0;
43
16.1k
  }
44
45
  StringEnumeration * StringListEnumeration::clone() const
46
0
  {
47
0
    return new StringListEnumeration(*this);
48
0
  }
49
50
  void StringListEnumeration::assign(const StringEnumeration * other)
51
0
  {
52
0
    *this = *(const StringListEnumeration *)other;
53
0
  }
54
55
56
  StringList * StringList::clone() const
57
0
  {
58
0
    return new StringList(*this);
59
0
  }
60
61
  void StringList::assign(const StringList * other)
62
0
  {
63
0
    *this = *(const StringList *)other;
64
0
  }
65
66
  PosibErr<bool> StringList::add(ParmStr str)
67
100k
  {
68
    //CERR.printf("ADD %s\n", str.str());
69
100k
    StringListNode * * cur = &first;
70
7.34M
    while (*cur != 0 && strcmp((*cur)->data.c_str(), str) != 0) {
71
7.24M
      cur = &(*cur)->next;
72
7.24M
    }
73
100k
    if (*cur == 0) {
74
85.1k
      *cur = new StringListNode(str);
75
85.1k
      return true;
76
85.1k
    } else {
77
15.3k
      return false;
78
15.3k
    }
79
100k
  }
80
81
  PosibErr<bool> StringList::remove(ParmStr str)
82
32.3k
  {
83
    //CERR.printf("REM %s\n", str.str());
84
32.3k
    StringListNode  * * cur  = &first;
85
101k
    while (*cur != 0 && strcmp((*cur)->data.c_str(), str)!=0 )  {
86
69.2k
      cur = &(*cur)->next;
87
69.2k
    }
88
32.3k
    if (*cur == 0) {
89
31.7k
      return false;
90
31.7k
    } else {
91
554
      StringListNode * tmp = *cur;
92
554
      *cur = (*cur)->next;
93
554
      delete tmp;
94
554
      return true;
95
554
    }
96
32.3k
  }
97
98
  PosibErr<void> StringList::clear()
99
878
  {
100
    //CERR.printf("CLEAR\n");
101
878
    StringListNode * temp;
102
878
    while (first != 0) {
103
0
      temp = first;
104
0
      first = temp->next;
105
0
      delete temp;
106
0
    }
107
878
    first = 0;
108
878
    return no_err;
109
878
  }
110
111
  StringEnumeration * StringList::elements() const
112
1.99k
  {
113
1.99k
    return new StringListEnumeration(first);
114
1.99k
  }
115
116
0
  StringList * new_string_list() {
117
0
    return new StringList;
118
0
  }
119
120
}