~ubuntu-branches/debian/lenny/nano/lenny

« back to all changes in this revision

Viewing changes to debian/patches/02_empty_regex.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach
  • Date: 2006-07-04 19:56:57 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20060704195657-0m31jgrthxdlvpgi
Tags: 1.3.12-1
* The "Quiebra Mítica" release.
* New upstream development release.
* debian/nanorc: sync with nanorc.sample, which now uses includes for
  highlight patterns.
* debian/patches/*.dpatch: removed, included in new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## 02_empty_regex.dpatch by  <jordi@debian.org>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: Fix segfaults on zero length regexes.
6
 
 
7
 
@DPATCH@
8
 
diff -urNad nano-1.3.11~/src/winio.c nano-1.3.11/src/winio.c
9
 
--- nano-1.3.11~/src/winio.c    2006-03-30 03:18:29.000000000 +0200
10
 
+++ nano-1.3.11/src/winio.c     2006-05-18 23:34:58.851916460 +0200
11
 
@@ -2383,10 +2383,8 @@
12
 
                                _("Refusing zero-length regex match"));
13
 
                    } else if (startmatch.rm_so < endpos &&
14
 
                        startmatch.rm_eo > startpos) {
15
 
-                       if (startmatch.rm_so <= startpos)
16
 
-                           x_start = 0;
17
 
-                       else
18
 
-                           x_start = strnlenpt(fileptr->data,
19
 
+                       x_start = (startmatch.rm_so <= startpos) ? 0 :
20
 
+                               strnlenpt(fileptr->data,
21
 
                                startmatch.rm_so) - start;
22
 
 
23
 
                        index = actual_x(converted, x_start);
24
 
@@ -2430,129 +2428,135 @@
25
 
                        goto step_two;
26
 
                    start_line = start_line->prev;
27
 
                }
28
 
-               /* No start found, so skip to the next step. */
29
 
-               if (start_line == NULL)
30
 
-                   goto step_two;
31
 
-               /* Now start_line is the first line before fileptr
32
 
-                * containing a start match.  Is there a start on this
33
 
-                * line not followed by an end on this line? */
34
 
-               start_col = 0;
35
 
-               while (TRUE) {
36
 
-                   start_col += startmatch.rm_so;
37
 
-                   startmatch.rm_eo -= startmatch.rm_so;
38
 
-                   if (regexec(tmpcolor->end, start_line->data +
39
 
-                       start_col + startmatch.rm_eo, 0, NULL,
40
 
-                       (start_col + startmatch.rm_eo == 0) ? 0 :
41
 
-                       REG_NOTBOL) == REG_NOMATCH)
42
 
-                       /* No end found after this start. */
43
 
-                       break;
44
 
-                   start_col++;
45
 
-                   if (regexec(tmpcolor->start, start_line->data +
46
 
-                       start_col, 1, &startmatch,
47
 
-                       REG_NOTBOL) == REG_NOMATCH)
48
 
-                       /* No later start on this line. */
49
 
+               if (startmatch.rm_so == startmatch.rm_eo) {
50
 
+                   startmatch.rm_eo++;
51
 
+                   statusbar(_("Refusing zero-length regex match"));
52
 
+               } else {
53
 
+                   /* No start found, so skip to the next step. */
54
 
+                   if (start_line == NULL)
55
 
                        goto step_two;
56
 
-               }
57
 
-               /* Indeed, there is a start not followed on this line by
58
 
-                * an end. */
59
 
+                   /* Now start_line is the first line before fileptr
60
 
+                    * containing a start match.  Is there a start on
61
 
+                    * this line not followed by an end on this line? */
62
 
+                   start_col = 0;
63
 
+                   while (TRUE) {
64
 
+                       start_col += startmatch.rm_so;
65
 
+                       startmatch.rm_eo -= startmatch.rm_so;
66
 
+                       if (regexec(tmpcolor->end, start_line->data +
67
 
+                               start_col + startmatch.rm_eo, 0, NULL,
68
 
+                               (start_col + startmatch.rm_eo == 0) ?
69
 
+                               0 : REG_NOTBOL) == REG_NOMATCH)
70
 
+                           /* No end found after this start. */
71
 
+                           break;
72
 
+                       start_col++;
73
 
+                       if (regexec(tmpcolor->start, start_line->data +
74
 
+                               start_col, 1, &startmatch,
75
 
+                               REG_NOTBOL) == REG_NOMATCH)
76
 
+                           /* No later start on this line. */
77
 
+                           goto step_two;
78
 
+                   }
79
 
+                   /* Indeed, there is a start not followed on this
80
 
+                    * line by an end. */
81
 
 
82
 
-               /* We have already checked that there is no end before
83
 
-                * fileptr and after the start.  Is there an end after
84
 
-                * the start at all?  We don't paint unterminated
85
 
-                * starts. */
86
 
-               end_line = fileptr;
87
 
-               while (end_line != NULL && regexec(tmpcolor->end,
88
 
+                   /* We have already checked that there is no end
89
 
+                    * before fileptr and after the start.  Is there an
90
 
+                    * end after the start at all?  We don't paint
91
 
+                    * unterminated starts. */
92
 
+                   end_line = fileptr;
93
 
+                   while (end_line != NULL && regexec(tmpcolor->end,
94
 
                        end_line->data, 1, &endmatch, 0) == REG_NOMATCH)
95
 
-                   end_line = end_line->next;
96
 
+                       end_line = end_line->next;
97
 
 
98
 
-               /* No end found, or it is too early. */
99
 
-               if (end_line == NULL || (end_line == fileptr &&
100
 
+                   /* No end found, or it is too early. */
101
 
+                   if (end_line == NULL || (end_line == fileptr &&
102
 
                        endmatch.rm_eo <= startpos))
103
 
-                   goto step_two;
104
 
+                       goto step_two;
105
 
 
106
 
-               /* Now paint the start of fileptr. */
107
 
-               if (end_line != fileptr)
108
 
-                   /* If the start of fileptr is on a different line
109
 
-                    * from the end, paintlen is -1, meaning that
110
 
-                    * everything on the line gets painted. */
111
 
-                   paintlen = -1;
112
 
-               else
113
 
-                   /* Otherwise, paintlen is the expanded location of
114
 
-                    * the end of the match minus the expanded location
115
 
-                    * of the beginning of the page. */
116
 
-                   paintlen = actual_x(converted,
117
 
-                       strnlenpt(fileptr->data, endmatch.rm_eo) -
118
 
-                       start);
119
 
+                   /* Now paint the start of fileptr. */
120
 
+                   if (end_line != fileptr)
121
 
+                       /* If the start of fileptr is on a different
122
 
+                        * line from the end, paintlen is -1, meaning
123
 
+                        * that everything on the line gets painted. */
124
 
+                       paintlen = -1;
125
 
+                   else
126
 
+                       /* Otherwise, paintlen is the expanded location
127
 
+                        * of the end of the match minus the expanded
128
 
+                        * location of the beginning of the page. */
129
 
+                       paintlen = actual_x(converted,
130
 
+                               strnlenpt(fileptr->data,
131
 
+                               endmatch.rm_eo) - start);
132
 
 
133
 
-               mvwaddnstr(edit, line, 0, converted, paintlen);
134
 
+                   mvwaddnstr(edit, line, 0, converted, paintlen);
135
 
 
136
 
   step_two:
137
 
-               /* Second step, we look for starts on this line. */
138
 
-               start_col = 0;
139
 
+                   /* Second step, we look for starts on this line. */
140
 
+                   start_col = 0;
141
 
 
142
 
-               while (start_col < endpos) {
143
 
-                   if (regexec(tmpcolor->start, fileptr->data +
144
 
-                       start_col, 1, &startmatch, (start_col == 0) ?
145
 
-                       0 : REG_NOTBOL) == REG_NOMATCH || start_col +
146
 
-                       startmatch.rm_so >= endpos)
147
 
-                       /* No more starts on this line. */
148
 
-                       break;
149
 
-                   /* Translate the match to be relative to the
150
 
-                    * beginning of the line. */
151
 
-                   startmatch.rm_so += start_col;
152
 
-                   startmatch.rm_eo += start_col;
153
 
+                   while (start_col < endpos) {
154
 
+                       if (regexec(tmpcolor->start, fileptr->data +
155
 
+                               start_col, 1, &startmatch, (start_col ==
156
 
+                               0) ? 0 : REG_NOTBOL) == REG_NOMATCH ||
157
 
+                               start_col + startmatch.rm_so >= endpos)
158
 
+                           /* No more starts on this line. */
159
 
+                           break;
160
 
+                       /* Translate the match to be relative to the
161
 
+                        * beginning of the line. */
162
 
+                       startmatch.rm_so += start_col;
163
 
+                       startmatch.rm_eo += start_col;
164
 
 
165
 
-                   if (startmatch.rm_so <= startpos)
166
 
-                       x_start = 0;
167
 
-                   else
168
 
-                       x_start = strnlenpt(fileptr->data,
169
 
+                       x_start = (startmatch.rm_so <= startpos) ? 0 :
170
 
+                               strnlenpt(fileptr->data,
171
 
                                startmatch.rm_so) - start;
172
 
 
173
 
-                   index = actual_x(converted, x_start);
174
 
+                       index = actual_x(converted, x_start);
175
 
 
176
 
-                   if (regexec(tmpcolor->end, fileptr->data +
177
 
-                       startmatch.rm_eo, 1, &endmatch,
178
 
-                       (startmatch.rm_eo == 0) ? 0 : REG_NOTBOL) ==
179
 
-                       0) {
180
 
-                       /* Translate the end match to be relative to the
181
 
-                        * beginning of the line. */
182
 
-                       endmatch.rm_so += startmatch.rm_eo;
183
 
-                       endmatch.rm_eo += startmatch.rm_eo;
184
 
-                       /* There is an end on this line.  But does it
185
 
-                        * appear on this page, and is the match more
186
 
-                        * than zero characters long? */
187
 
-                       if (endmatch.rm_eo > startpos &&
188
 
+                       if (regexec(tmpcolor->end, fileptr->data +
189
 
+                               startmatch.rm_eo, 1, &endmatch,
190
 
+                               (startmatch.rm_eo == 0) ? 0 :
191
 
+                               REG_NOTBOL) == 0) {
192
 
+                           /* Translate the end match to be relative to
193
 
+                            * the beginning of the line. */
194
 
+                           endmatch.rm_so += startmatch.rm_eo;
195
 
+                           endmatch.rm_eo += startmatch.rm_eo;
196
 
+                           /* There is an end on this line.  But does
197
 
+                            * it appear on this page, and is the match
198
 
+                            * more than zero characters long? */
199
 
+                           if (endmatch.rm_eo > startpos &&
200
 
                                endmatch.rm_eo > startmatch.rm_so) {
201
 
-                           paintlen = actual_x(converted + index,
202
 
-                               strnlenpt(fileptr->data,
203
 
-                               endmatch.rm_eo) - start - x_start);
204
 
+                               paintlen = actual_x(converted + index,
205
 
+                                       strnlenpt(fileptr->data,
206
 
+                                       endmatch.rm_eo) - start -
207
 
+                                       x_start);
208
 
 
209
 
-                           assert(0 <= x_start && x_start < COLS);
210
 
+                               assert(0 <= x_start && x_start < COLS);
211
 
 
212
 
-                           mvwaddnstr(edit, line, x_start, converted +
213
 
-                               index, paintlen);
214
 
-                       }
215
 
-                   } else {
216
 
-                       /* There is no end on this line.  But we haven't
217
 
-                        * yet looked for one on later lines. */
218
 
-                       end_line = fileptr->next;
219
 
+                               mvwaddnstr(edit, line, x_start,
220
 
+                                       converted + index, paintlen);
221
 
+                           }
222
 
+                       } else {
223
 
+                           /* There is no end on this line.  But we
224
 
+                            * haven't yet looked for one on later
225
 
+                            * lines. */
226
 
+                           end_line = fileptr->next;
227
 
 
228
 
-                       while (end_line != NULL &&
229
 
+                           while (end_line != NULL &&
230
 
                                regexec(tmpcolor->end, end_line->data,
231
 
                                0, NULL, 0) == REG_NOMATCH)
232
 
-                           end_line = end_line->next;
233
 
+                               end_line = end_line->next;
234
 
 
235
 
-                       if (end_line != NULL) {
236
 
-                           assert(0 <= x_start && x_start < COLS);
237
 
+                           if (end_line != NULL) {
238
 
+                               assert(0 <= x_start && x_start < COLS);
239
 
 
240
 
-                           mvwaddnstr(edit, line, x_start, converted +
241
 
-                               index, -1);
242
 
-                           /* We painted to the end of the line, so
243
 
-                            * don't bother checking any more starts. */
244
 
-                           break;
245
 
+                               mvwaddnstr(edit, line, x_start,
246
 
+                                       converted + index, -1);
247
 
+                               /* We painted to the end of the line, so
248
 
+                                * don't bother checking any more
249
 
+                                * starts. */
250
 
+                               break;
251
 
+                           }
252
 
                        }
253
 
+                       start_col = startmatch.rm_so + 1;
254
 
                    }
255
 
-                   start_col = startmatch.rm_so + 1;
256
 
                }
257
 
            }
258