Package: aspell / 0.60.8-1

01_debctrl_filter.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
## 01_debctrl_filter.diff by Brian Nelson <pyro@debian.org>
##
## 
--- a/Makefile.am
+++ b/Makefile.am
@@ -166,6 +166,7 @@ dynamic_optfiles =
 
 ### Add the .info file your filter comes with
 optfiles = \
+  modules/filter/debctrl-filter.info\
   modules/filter/email-filter.info\
   modules/filter/tex-filter.info\
   modules/filter/sgml-filter.info\
@@ -177,6 +178,7 @@ optfiles = \
 
 ### Add all your aspell mode files ###
 fltfiles = \
+  modules/filter/modes/debctrl.amf \
   modules/filter/modes/html.amf \
   modules/filter/modes/sgml.amf \
   modules/filter/modes/markdown.amf \
@@ -198,6 +200,7 @@ static_optfiles += ${optfiles}
 ### starting with file containing filter class definition followed by
 ### file containing filter member implementation.
 libaspell_la_SOURCES +=\
+  modules/filter/debctrl.cpp\
   modules/filter/email.cpp\
   modules/filter/tex.cpp\
   modules/filter/sgml.cpp\
@@ -213,10 +216,15 @@ filter_ldflags = -module -avoid-version
 
 ### Add name of filter library containing your filter. Name always
 ### must look like lib<filtername>-filter.la see development manual
-filter_LTLIBRARIES = email-filter.la tex-filter.la\
+filter_LTLIBRARIES = debctrl-filter.la\
+		     email-filter.la tex-filter.la\
 	             sgml-filter.la markdown-filter.la context-filter.la\
                      nroff-filter.la texinfo-filter.la
 
+debctrl_filter_la_SOURCES = modules/filter/debctrl.cpp
+debctrl_filter_la_LIBADD = libaspell.la
+debctrl_filter_la_LDFLAGS  = ${filter_ldflags}
+
 email_filter_la_SOURCES = modules/filter/email.cpp
 email_filter_la_LIBADD = libaspell.la 
 email_filter_la_LDFLAGS  = ${filter_ldflags}
@@ -448,4 +456,3 @@ EXTRA_DIST += \
   test/suggest/run-batch \
   test/wide_test_invalid.c \
   test/wide_test_valid.c
-
--- /dev/null
+++ b/modules/filter/debctrl-filter.info
@@ -0,0 +1,9 @@
+# debctrl filter option file
+
+#This Filter is usable with the following version(s) of Aspell
+ASPELL >=0.51
+
+#This line will be printed when typing `Aspell help debctrl
+DESCRIPTION filter for Debian packaging control files
+
+STATIC filter
--- /dev/null
+++ b/modules/filter/debctrl.cpp
@@ -0,0 +1,76 @@
+// This file is part of The New Aspell
+//
+// Copyright (C) 2005 by Brian Nelson, based on the email filter,
+// Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license
+// version 2.0 or 2.1.  You should have received a copy of the LGPL
+// license along with this library if you did not you can find it at
+// http://www.gnu.org/.
+
+#include "settings.h"
+
+#include "indiv_filter.hpp"
+#include "convert.hpp"
+#include "config.hpp"
+#include "indiv_filter.hpp"
+
+namespace {
+
+  using namespace acommon;
+
+  class DebctrlFilter : public IndividualFilter 
+  {
+    bool prev_newline;
+    bool in_field;
+
+  public:
+    PosibErr<bool> setup(Config *);
+    void reset();
+    void process(FilterChar * &, FilterChar * &);
+  };
+
+  PosibErr<bool> DebctrlFilter::setup(Config * opts) 
+  {
+    name_ = "debctrl-filter";
+    order_num_ = 0.90;
+    reset();
+    return true;
+  }
+  
+  void DebctrlFilter::reset() 
+  {
+    prev_newline = true;
+    in_field = false;
+  }
+
+  void DebctrlFilter::process(FilterChar * & str, FilterChar * & end)
+  {
+    FilterChar * line_begin = str;
+    FilterChar * cur = str;
+
+    while (cur < end) {
+      if (prev_newline && *cur != ' ')
+        in_field = true;
+
+      if (*cur == '\n') {
+	if (in_field) {
+	  for (FilterChar * i = line_begin; i != cur; ++i)
+	    *i = ' ';
+	}
+	line_begin = cur;
+	in_field = false;
+	prev_newline = true;
+      } else {
+	prev_newline = false;
+      }
+      ++cur;
+    }
+    if (in_field)
+      for (FilterChar * i = line_begin; i != cur; ++i)
+	*i = ' ';
+  }
+}
+
+C_EXPORT 
+IndividualFilter * new_aspell_debctrl_filter() {
+  return new DebctrlFilter;                                
+}
--- /dev/null
+++ b/modules/filter/modes/debctrl.amf
@@ -0,0 +1,8 @@
+MODE debctrl
+
+ASPELL >=0.60
+
+DESCRIPTION mode for Debian packaging control files
+
+FILTER url
+FILTER debctrl
--- a/prog/aspell.cpp
+++ b/prog/aspell.cpp
@@ -202,6 +202,7 @@ struct ModeAbrv {
   const char * desc;
 };
 static const ModeAbrv mode_abrvs[] = {
+  {'D', "mode=debctrl", N_("enter Debctrl mode.")},
   {'e', "mode=email", N_("enter Email mode.")},
   {'H', "mode=html",  N_("enter HTML mode.")},
   {'t', "mode=tex",   N_("enter TeX mode.")},
@@ -2975,4 +2976,3 @@ void print_help (bool verbose) {
     delete els;
   }
 }
-