gdiff 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGELOG +7 -0
  2. data/COPYING.suffix_array +278 -0
  3. data/LICENSE.suffix_array +17 -0
  4. data/README +40 -0
  5. data/README.suffix_array +274 -0
  6. data/bin/gdiff +25 -0
  7. data/bin/gpatch +25 -0
  8. data/doc/classes/Diff.html +117 -0
  9. data/doc/classes/Diff/GDiff.html +120 -0
  10. data/doc/classes/Diff/GDiff/EGdiffError.html +111 -0
  11. data/doc/classes/Diff/GDiff/ENoGdiffStream.html +113 -0
  12. data/doc/classes/Diff/GDiff/EPrematureEndOfStream.html +113 -0
  13. data/doc/classes/Diff/GDiff/Operations.html +156 -0
  14. data/doc/classes/Diff/GDiff/Operations/Copy.html +246 -0
  15. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000014.html +19 -0
  16. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000015.html +39 -0
  17. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000016.html +25 -0
  18. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000017.html +18 -0
  19. data/doc/classes/Diff/GDiff/Operations/Data.html +246 -0
  20. data/doc/classes/Diff/GDiff/Operations/Data.src/M000009.html +18 -0
  21. data/doc/classes/Diff/GDiff/Operations/Data.src/M000010.html +18 -0
  22. data/doc/classes/Diff/GDiff/Operations/Data.src/M000011.html +35 -0
  23. data/doc/classes/Diff/GDiff/Operations/Data.src/M000012.html +29 -0
  24. data/doc/classes/Diff/GDiff/Operations/Data.src/M000013.html +19 -0
  25. data/doc/classes/SAError.html +111 -0
  26. data/doc/classes/SuffixArray.html +342 -0
  27. data/doc/classes/SuffixArray.src/M000001.html +97 -0
  28. data/doc/classes/SuffixArray.src/M000002.html +73 -0
  29. data/doc/classes/SuffixArray.src/M000003.html +102 -0
  30. data/doc/classes/SuffixArray.src/M000004.html +47 -0
  31. data/doc/classes/SuffixArray.src/M000005.html +44 -0
  32. data/doc/classes/SuffixArray.src/M000006.html +33 -0
  33. data/doc/classes/SuffixArray.src/M000007.html +24 -0
  34. data/doc/classes/SuffixArray.src/M000008.html +46 -0
  35. data/doc/created.rid +1 -0
  36. data/doc/files/ext/gdiff/suffix_array/extconf_rb.html +108 -0
  37. data/doc/files/ext/gdiff/suffix_array/lcp_c.html +101 -0
  38. data/doc/files/ext/gdiff/suffix_array/sarray_c.html +101 -0
  39. data/doc/files/ext/gdiff/suffix_array/suffix_array_c.html +101 -0
  40. data/doc/files/lib/gdiff_rb.html +108 -0
  41. data/doc/fr_class_index.html +36 -0
  42. data/doc/fr_file_index.html +31 -0
  43. data/doc/fr_method_index.html +43 -0
  44. data/doc/index.html +24 -0
  45. data/doc/rdoc-style.css +208 -0
  46. data/ext/gdiff/COPYING +278 -0
  47. data/ext/gdiff/LICENSE +17 -0
  48. data/ext/gdiff/README +274 -0
  49. data/ext/gdiff/extconf.rb +3 -0
  50. data/ext/gdiff/lcp.c +97 -0
  51. data/ext/gdiff/sarray.3 +145 -0
  52. data/ext/gdiff/sarray.c +372 -0
  53. data/ext/gdiff/sarray.h +13 -0
  54. data/ext/gdiff/suffix_array.c +510 -0
  55. data/lib/gdiff.rb +255 -0
  56. data/setup.rb +1551 -0
  57. data/test/tc_gdiff.rb +66 -0
  58. metadata +119 -0
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>to_s (Diff::GDiff::Operations::Data)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/gdiff.rb, line 82</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
15
+ <span class="ruby-identifier">d</span> = <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">inspect</span>
16
+ <span class="ruby-value str">&quot;Insert &quot;</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">d</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">60</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">d</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">d</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">20</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;...&quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">d</span>[<span class="ruby-value">-37</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>])
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,111 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: SAError</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">SAError</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/ext/gdiff/suffix_array/suffix_array_c.html">
59
+ ext/gdiff/suffix_array/suffix_array.c
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ StandardError
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+
86
+ </div>
87
+
88
+
89
+ <!-- if includes -->
90
+
91
+ <div id="section">
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <!-- if method_list -->
101
+
102
+
103
+ </div>
104
+
105
+
106
+ <div id="validator-badges">
107
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
108
+ </div>
109
+
110
+ </body>
111
+ </html>
@@ -0,0 +1,342 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: SuffixArray</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">SuffixArray</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/ext/gdiff/suffix_array/suffix_array_c.html">
59
+ ext/gdiff/suffix_array/suffix_array.c
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000008">all_starts</a>&nbsp;&nbsp;
90
+ <a href="#M000004">array</a>&nbsp;&nbsp;
91
+ <a href="#M000002">longest_match</a>&nbsp;&nbsp;
92
+ <a href="#M000003">longest_nonmatch</a>&nbsp;&nbsp;
93
+ <a href="#M000001">new</a>&nbsp;&nbsp;
94
+ <a href="#M000005">raw_array</a>&nbsp;&nbsp;
95
+ <a href="#M000007">source</a>&nbsp;&nbsp;
96
+ <a href="#M000006">suffix_start</a>&nbsp;&nbsp;
97
+ </div>
98
+ </div>
99
+
100
+ </div>
101
+
102
+
103
+ <!-- if includes -->
104
+
105
+ <div id="section">
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ <!-- if method_list -->
115
+ <div id="methods">
116
+ <h3 class="section-bar">Public Class methods</h3>
117
+
118
+ <div id="method-M000001" class="method-detail">
119
+ <a name="M000001"></a>
120
+
121
+ <div class="method-heading">
122
+ <a href="SuffixArray.src/M000001.html" target="Code" class="method-signature"
123
+ onclick="popupCode('SuffixArray.src/M000001.html');return false;">
124
+ <span class="method-name">SuffixArray.new(source, [raw_array], [start]) &rarr; SuffixArray<br />
125
+ </span>
126
+ </a>
127
+ </div>
128
+
129
+ <div class="method-description">
130
+ <p>
131
+ Given a string (anything like a string really) this will generate a suffix
132
+ array for the string so that you can work with it. The source cannot be an
133
+ empty string since this is a useless operation.
134
+ </p>
135
+ <p>
136
+ Two optional parameters allow you to restore a suffix array without running
137
+ the construction process again. You basically give it the String from <a
138
+ href="SuffixArray.html#M000005">SuffixArray.raw_array</a> and the start
139
+ from <a href="SuffixArray.html#M000006">SuffixArray.suffix_start</a> and it
140
+ will skip most calculations. <b>This feature is really experimental and is
141
+ CPU dependent since the integers in the <a
142
+ href="SuffixArray.html#M000005">raw_array</a> are native.</b>
143
+ </p>
144
+ </div>
145
+ </div>
146
+
147
+ <h3 class="section-bar">Public Instance methods</h3>
148
+
149
+ <div id="method-M000008" class="method-detail">
150
+ <a name="M000008"></a>
151
+
152
+ <div class="method-heading">
153
+ <a href="SuffixArray.src/M000008.html" target="Code" class="method-signature"
154
+ onclick="popupCode('SuffixArray.src/M000008.html');return false;">
155
+ <span class="method-name">sarray.all_starts(character) &rarr; Array<br />
156
+ </span>
157
+ </a>
158
+ </div>
159
+
160
+ <div class="method-description">
161
+ <p>
162
+ Returns an array containing all the indexes into the source that start with
163
+ the given character. This is a very fast operation since the <a
164
+ href="SuffixArray.html">SuffixArray</a> already knows where each character
165
+ starts and ends in the suffix array structure internally. All it does is
166
+ copy the range of the suffix array for that region.
167
+ </p>
168
+ </div>
169
+ </div>
170
+
171
+ <div id="method-M000004" class="method-detail">
172
+ <a name="M000004"></a>
173
+
174
+ <div class="method-heading">
175
+ <a href="SuffixArray.src/M000004.html" target="Code" class="method-signature"
176
+ onclick="popupCode('SuffixArray.src/M000004.html');return false;">
177
+ <span class="method-name">sarray.array &rarr; Array <br />
178
+ </span>
179
+ </a>
180
+ </div>
181
+
182
+ <div class="method-description">
183
+ <p>
184
+ Returns a copy of the internal suffix array as an Array of Fixnum objects.
185
+ This array is a copy so you&#8217;re free to mangle it however you wish.
186
+ </p>
187
+ <p>
188
+ A suffix array is the sequence of indices into the source that mark each
189
+ suffix as if they were sorted.
190
+ </p>
191
+ </div>
192
+ </div>
193
+
194
+ <div id="method-M000002" class="method-detail">
195
+ <a name="M000002"></a>
196
+
197
+ <div class="method-heading">
198
+ <a href="SuffixArray.src/M000002.html" target="Code" class="method-signature"
199
+ onclick="popupCode('SuffixArray.src/M000002.html');return false;">
200
+ <span class="method-name">sarray.longest_match(target, from_index) &rarr; [start, length]<br />
201
+ </span>
202
+ </a>
203
+ </div>
204
+
205
+ <div class="method-description">
206
+ <p>
207
+ Takes a target string and an index inside that string, and then tries to
208
+ find the longest match from that point in the source string for this <a
209
+ href="SuffixArray.html">SuffixArray</a> object.
210
+ </p>
211
+ <p>
212
+ It returns an array of [start, length] of where in the source a length
213
+ string from the target would match.
214
+ </p>
215
+ <p>
216
+ Refer to the unit test for examples of usage.
217
+ </p>
218
+ </div>
219
+ </div>
220
+
221
+ <div id="method-M000003" class="method-detail">
222
+ <a name="M000003"></a>
223
+
224
+ <div class="method-heading">
225
+ <a href="SuffixArray.src/M000003.html" target="Code" class="method-signature"
226
+ onclick="popupCode('SuffixArray.src/M000003.html');return false;">
227
+ <span class="method-name">sarray.longest_nonmatch(target, from_index, min_match) &rarr; [non_match_length, match_start, match_length]<br />
228
+ </span>
229
+ </a>
230
+ </div>
231
+
232
+ <div class="method-description">
233
+ <p>
234
+ Mostly the inverse of <a href="SuffixArray.html#M000002">longest_match</a>,
235
+ except that it first tries to find a non-matching region, then a matching
236
+ region. The target and from_index are the same as in <a
237
+ href="SuffixArray.html#M000002">longest_match</a>. The min_match argument
238
+ is the smallest matching region that you&#8217;ll accept as significant
239
+ enough to end the non-matching search. Giving non_match=0 will stop at the
240
+ first matching region.
241
+ </p>
242
+ <p>
243
+ It works by first searching the suffix array for a non-matching region.
244
+ When it hits a character that is in the source (according to the suffix
245
+ array) it tries to find a matching region. If it can find a matching region
246
+ that is longer than min_match then it stops and returns, otherwise it adds
247
+ this match to the length of the non-matching region and continues.
248
+ </p>
249
+ <p>
250
+ The return value is an Array of [non_match_length, match_start,
251
+ match_length].
252
+ </p>
253
+ </div>
254
+ </div>
255
+
256
+ <div id="method-M000005" class="method-detail">
257
+ <a name="M000005"></a>
258
+
259
+ <div class="method-heading">
260
+ <a href="SuffixArray.src/M000005.html" target="Code" class="method-signature"
261
+ onclick="popupCode('SuffixArray.src/M000005.html');return false;">
262
+ <span class="method-name">sarray.raw_array &rarr; String<br />
263
+ </span>
264
+ </a>
265
+ </div>
266
+
267
+ <div class="method-description">
268
+ <p>
269
+ Returns the &quot;raw&quot; internal suffix array which is an array of C
270
+ int types used internally as the suffix array. The purpose of this function
271
+ is to allow you to store the suffix_array and then very quickly restore it
272
+ later without having to rebuild the suffix array.
273
+ </p>
274
+ <p>
275
+ The returned String should be treated as an opaque structure. It is just a
276
+ copy of the int[] used internally. This means that it is dependent on your
277
+ CPU. If you want something you can use that is cross platform then use the
278
+ <a href="SuffixArray.html#M000004">SuffixArray.array</a> function instead.
279
+ </p>
280
+ </div>
281
+ </div>
282
+
283
+ <div id="method-M000007" class="method-detail">
284
+ <a name="M000007"></a>
285
+
286
+ <div class="method-heading">
287
+ <a href="SuffixArray.src/M000007.html" target="Code" class="method-signature"
288
+ onclick="popupCode('SuffixArray.src/M000007.html');return false;">
289
+ <span class="method-name">sarray.source &rarr; String<br />
290
+ </span>
291
+ </a>
292
+ </div>
293
+
294
+ <div class="method-description">
295
+ <p>
296
+ Returns the source that this suffix array was constructed with.
297
+ </p>
298
+ </div>
299
+ </div>
300
+
301
+ <div id="method-M000006" class="method-detail">
302
+ <a name="M000006"></a>
303
+
304
+ <div class="method-heading">
305
+ <a href="SuffixArray.src/M000006.html" target="Code" class="method-signature"
306
+ onclick="popupCode('SuffixArray.src/M000006.html');return false;">
307
+ <span class="method-name">sarray.start &rarr; Fixnum<br />
308
+ </span>
309
+ </a>
310
+ </div>
311
+
312
+ <div class="method-description">
313
+ <p>
314
+ Tells you which index in the suffix array is the longest suffix (also known
315
+ as the start of the source string). If you want to get the beginning of the
316
+ source string in a round about way you would do this:
317
+ </p>
318
+ <p>
319
+ source = &quot;abracadabra&quot; sa = <a
320
+ href="SuffixArray.html#M000001">SuffixArray.new</a> source first = <a
321
+ href="http://sa.start">source[sa.array</a>]]
322
+ </p>
323
+ <p>
324
+ Remember that the start is the index into the suffix array where the source
325
+ starts, not an index into the source string (that would just be 0).
326
+ </p>
327
+ </div>
328
+ </div>
329
+
330
+
331
+ </div>
332
+
333
+
334
+ </div>
335
+
336
+
337
+ <div id="validator-badges">
338
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
339
+ </div>
340
+
341
+ </body>
342
+ </html>