@@ -90,13 +90,18 @@ void DivSufSort::reset()
90
90
memset (&_bucketB[0 ], 0 , sizeof (int ) * 65536 );
91
91
}
92
92
93
- void DivSufSort::computeSuffixArray (const byte input[], int sa[], int length)
93
+ bool DivSufSort::computeSuffixArray (const byte input[], int sa[], int length)
94
94
{
95
95
_buffer = reinterpret_cast <const uint8*>(&input[0 ]);
96
96
_sa = sa;
97
97
reset ();
98
98
const int m = sortTypeBstar (_bucketA, _bucketB, length);
99
+
100
+ if (m < 0 )
101
+ return false ;
102
+
99
103
constructSuffixArray (_bucketA, _bucketB, length, m);
104
+ return true ;
100
105
}
101
106
102
107
void DivSufSort::constructSuffixArray (int bucketA[], int bucketB[], int n, int m)
@@ -163,16 +168,20 @@ void DivSufSort::constructSuffixArray(int bucketA[], int bucketB[], int n, int m
163
168
}
164
169
}
165
170
166
- int DivSufSort::computeBWT (const byte input[], byte output[], int bwt[], int length, int indexes[], int idxCount)
171
+ bool DivSufSort::computeBWT (const byte input[], byte output[], int bwt[], int length, int indexes[], int idxCount)
167
172
{
168
173
_buffer = reinterpret_cast <const uint8*>(&input[0 ]);
169
174
_sa = bwt;
170
175
reset ();
171
176
const int m = sortTypeBstar (_bucketA, _bucketB, length);
177
+
178
+ if (m < 0 )
179
+ return false ;
180
+
172
181
const int pIdx = constructBWT (_bucketA, _bucketB, length, m, indexes, idxCount);
173
182
174
183
if (pIdx < 0 )
175
- return - 1 ;
184
+ return false ;
176
185
177
186
output[0 ] = input[length - 1 ];
178
187
@@ -182,7 +191,7 @@ int DivSufSort::computeBWT(const byte input[], byte output[], int bwt[], int len
182
191
for (int i = pIdx + 1 ; i < length; i++)
183
192
output[i] = byte (bwt[i]);
184
193
185
- return pIdx + 1 ;
194
+ return true ;
186
195
}
187
196
188
197
int DivSufSort::constructBWT (int bucketA[], int bucketB[], int n, int m, int indexes[], int idxCount)
0 commit comments