sproutit-narwhal 0.2.107 → 0.2.108
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +3 -3
- data/engines/jsc/src/io-engine.cc +13 -10
- metadata +1 -1
data/VERSION.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
:minor: 2
|
3
|
-
:patch:
|
4
|
-
:digest:
|
3
|
+
:patch: 108
|
4
|
+
:digest: 70a9910a7e325884b16db93b52d7981103be7498
|
5
5
|
:dist:
|
6
|
-
engines/jsc:
|
6
|
+
engines/jsc: 732a3d1ff2d7f99d6c0b8b6ebb05d7895ca8b35b
|
7
7
|
:major: 0
|
@@ -211,6 +211,7 @@ FUNCTION(TextInputStream_read)
|
|
211
211
|
size_t outBufferUsed = 0;
|
212
212
|
char *outBuffer = (char*)malloc(outBufferSize);
|
213
213
|
|
214
|
+
int last_errno = 0;
|
214
215
|
while (true) {
|
215
216
|
// if the outBuffer is completely filled, double it's size
|
216
217
|
if (outBufferUsed >= outBufferSize) {
|
@@ -224,18 +225,16 @@ FUNCTION(TextInputStream_read)
|
|
224
225
|
outBuffer = (char*)realloc(outBuffer, outBufferSize);
|
225
226
|
}
|
226
227
|
|
227
|
-
// if there's no data in the buffer read
|
228
|
-
if (d->inBufferUsed == 0) {
|
229
|
-
DEBUG("
|
228
|
+
// if there's no data in the buffer, or it ends in the middle of a multibyte character, read more
|
229
|
+
if (d->inBufferUsed == 0 || last_errno == EINVAL) {
|
230
|
+
DEBUG("need more data, reading\n");
|
230
231
|
size_t num = read(fd, d->inBuffer + d->inBufferUsed, d->inBufferSize - d->inBufferUsed);
|
231
|
-
if (num
|
232
|
+
if (num <= 0) {
|
233
|
+
DEBUG("couldn't read more, done reading for now\n");
|
234
|
+
break;
|
235
|
+
} else {
|
232
236
|
d->inBufferUsed += num;
|
233
|
-
|
234
|
-
|
235
|
-
// still no data to read, so stop
|
236
|
-
if (d->inBufferUsed == 0) {
|
237
|
-
DEBUG("still nothing in inBuffer, done reading for now\n");
|
238
|
-
break;
|
237
|
+
}
|
239
238
|
}
|
240
239
|
|
241
240
|
char *in = d->inBuffer;
|
@@ -243,8 +242,12 @@ FUNCTION(TextInputStream_read)
|
|
243
242
|
char *out = outBuffer + outBufferUsed;
|
244
243
|
size_t outLeft = outBufferSize - outBufferUsed;
|
245
244
|
|
245
|
+
last_errno = 0;
|
246
246
|
size_t ret = iconv(cd, &in, &inLeft, &out, &outLeft);
|
247
247
|
if (ret != (size_t)-1 || errno == EINVAL || errno == E2BIG) {
|
248
|
+
if (ret == (size_t)-1)
|
249
|
+
last_errno = errno;
|
250
|
+
|
248
251
|
if (inLeft) {
|
249
252
|
DEBUG("shifting %d bytes down by %d (had %d)\n", inLeft, in - d->inBuffer, d->inBufferUsed);
|
250
253
|
memmove(d->inBuffer, in, inLeft);
|