Skip to content

Commit adeb508

Browse files
committed
Merge branch 'master' into graphics
2 parents 73251bb + ead47c0 commit adeb508

25 files changed

+1929
-132
lines changed

src/boot/natives.r

+3-3
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ uppercase: native [
520520
]
521521

522522
dehex: native [
523-
{Converts URL-style hex encoded (%xx) strings.}
524-
value [any-string!] {The string to dehex}
523+
{Converts URL-style hex encoded (%xx) strings. If input is UTF-8 encode, you should first convert it to binary!}
524+
value [any-string! binary!] {The string to dehex}
525525
]
526526

527527
get: native [
@@ -546,7 +546,7 @@ parse: native [
546546

547547
set: native [
548548
{Sets a word, path, block of words, or object to specified value(s).}
549-
word [any-word! any-path! block! object!] {Word, block of words, path, or object to be set (modified)}
549+
word [word! lit-word! any-path! block! object!] {Word, block of words, path, or object to be set (modified)}
550550
value [any-type!] {Value or block of values}
551551
/any {Allows setting words to any value, including unset}
552552
/only {Block or object value argument is set as a single value}

src/boot/sysobj.r

+9
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ options: context [ ; Options supplied to REBOL during startup
145145
default-suffix: %.reb ; Used by IMPORT if no suffix is provided
146146
file-types: []
147147
result-types: none
148+
149+
; verbosity of logs per service (codecs, schemes)
150+
; 0 = nothing; 1 = info; 2 = more; 3 = debug
151+
log: make object! [
152+
http:
153+
tls:
154+
zip:
155+
tar: 1
156+
]
148157
]
149158

150159
script: context [

src/core/n-strings.c

+16-8
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ static struct digest {
346346
// /zlib {Data are in ZLIB format with Adler32 checksum}
347347
// /gzip {Data are in ZLIB format with CRC32 checksum}
348348
// /lzma {Data are in LZMA format}
349+
// /deflate {Data are raw DEFLATE data}
349350
// /size
350351
// bytes [integer!] {Number of decompressed bytes. If not used, size is detected from last 4 source data bytes.}
351352
]
@@ -357,17 +358,24 @@ static struct digest {
357358
REBOOL ref_zlib = D_REF(4);
358359
REBOOL ref_gzip = D_REF(5);
359360
REBOOL ref_lzma = D_REF(6);
360-
REBOOL ref_size = D_REF(7);
361-
REBVAL *size = D_ARG(8);
361+
REBOOL ref_defl = D_REF(7);
362+
REBOOL ref_size = D_REF(8);
363+
REBVAL *size = D_ARG(9);
362364

363-
REBINT limit = 0;
365+
REBCNT limit = 0;
364366
REBCNT len;
365-
366-
if ((ref_zlib && (ref_gzip || ref_lzma)) || (ref_gzip && ref_lzma)) Trap0(RE_BAD_REFINES);
367+
REBINT windowBits = MAX_WBITS;
368+
369+
// test if only one compression type refinement is used
370+
if (
371+
(ref_zlib && (ref_gzip || ref_lzma || ref_defl)) ||
372+
(ref_gzip && (ref_zlib || ref_lzma || ref_defl)) ||
373+
(ref_lzma && (ref_zlib || ref_gzip || ref_defl))
374+
) Trap0(RE_BAD_REFINES);
367375

368376
len = Partial1(data, length);
369377

370-
if (ref_size) limit = Int32s(size, 1); // /limit size
378+
if (ref_size) limit = (REBCNT)Int32s(size, 1); // /limit size
371379

372380
if (ref_lzma) {
373381
#ifdef USE_LZMA
@@ -376,8 +384,8 @@ static struct digest {
376384
Trap0(RE_FEATURE_NA);
377385
#endif
378386
} else {
379-
int windowBits = MAX_WBITS;
380-
if (ref_gzip) windowBits |= 16;
387+
if (ref_defl) windowBits = -windowBits;
388+
else if (ref_gzip) windowBits |= 16;
381389
Set_Binary(D_RET, DecompressZlib(VAL_SERIES(data), VAL_INDEX(data), (REBINT)len, limit, windowBits));
382390
}
383391

src/core/t-date.c

+16-6
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@
500500
REBINT i;
501501
REBINT n;
502502
REBI64 secs;
503-
REBINT tz;
503+
REBINT tz, tzp;
504504
REBDAT date;
505505
REBINT day, month, year;
506506
REBINT num;
@@ -525,6 +525,7 @@
525525
case SYM_HOUR: i = 9; break;
526526
case SYM_MINUTE: i = 10; break;
527527
case SYM_SECOND: i = 11; break;
528+
case SYM_TIMEZONE: i = 12; break;
528529
default: return PE_BAD_SELECT;
529530
}
530531
}
@@ -565,7 +566,8 @@
565566
*val = *data;
566567
VAL_SET(val, REB_TIME);
567568
return PE_USE;
568-
case 4:
569+
case 4: // zone
570+
case 12: // timezone
569571
if (secs == NO_TIME) return PE_NONE;
570572
*val = *data;
571573
VAL_TIME(val) = (i64)tz * ZONE_MINS * MIN_SEC;
@@ -612,7 +614,10 @@
612614

613615
} else {
614616

615-
if (IS_INTEGER(val) || IS_DECIMAL(val)) n = Int32s(val, 0);
617+
if (IS_INTEGER(val) || IS_DECIMAL(val)) {
618+
// allow negative time zone
619+
n = (i == 4 || i == 12) ? Int32(val) : Int32s(val, 0);
620+
}
616621
else if (IS_NONE(val)) n = 0;
617622
else if (IS_TIME(val) && (i == 3 || i == 4));
618623
else if (IS_DATE(val) && (i == 3 || i == 5));
@@ -643,12 +648,17 @@
643648
secs = DEC_TO_SECS(VAL_DECIMAL(val));
644649
else return PE_BAD_SET_TYPE;
645650
break;
646-
case 4:
647-
// zone
651+
case 4: // zone
652+
case 12: // timezone
653+
tzp = tz;
648654
if (IS_TIME(val)) tz = (REBINT)(VAL_TIME(val) / (ZONE_MINS * MIN_SEC));
649655
else if (IS_DATE(val)) tz = VAL_ZONE(val);
650656
else tz = n * (60 / ZONE_MINS);
651-
if (tz > MAX_ZONE || tz < -MAX_ZONE) return PE_BAD_RANGE;
657+
if (i == 4 && (tz > MAX_ZONE || tz < -MAX_ZONE)) return PE_BAD_RANGE;
658+
if (secs == NO_TIME) secs = 0;
659+
if (i == 12) {
660+
secs += ((i64)(tz - tzp) * ((i64)ZONE_SECS * SEC_SEC));
661+
}
652662
break;
653663
case 5:
654664
// date

src/core/u-bincode.c

+11-15
Original file line numberDiff line numberDiff line change
@@ -1219,27 +1219,23 @@ static REBCNT EncodedU32_Size(u32 value) {
12191219
}
12201220
ASSERT_READ_SIZE(value, cp, ep, n);
12211221
readNBytes:
1222-
//printf("num: %i\n", n);
1223-
if (cmd == SYM_BYTES || cmd == SYM_STRING_BYTES) {
1224-
1225-
bin_new = Copy_Series_Part(bin, VAL_INDEX(buffer_read), n);
1226-
VAL_SERIES(temp) = bin_new;
1227-
VAL_INDEX(temp) = 0;
1228-
if (cmd == SYM_BYTES) {
1229-
VAL_SET(temp, REB_BINARY);
1230-
}
1231-
else {
1232-
VAL_SET(temp, REB_STRING);
1233-
VAL_TAIL(temp) = strnlen(VAL_BIN(temp), n);
1234-
}
1235-
}
1236-
else {// octal number
1222+
// WARNING: this piece of code is also used for SYM_UI*BYTES commands!
1223+
if (cmd == SYM_OCTAL_BYTES) {
1224+
// octal number
12371225
u = 0;
12381226
i = 0;
12391227
while ((i < n) && cp[i]) {
12401228
u = (u << 3) | (u64)(cp[i++] - '0');
12411229
}
12421230
SET_INTEGER(temp, u);
1231+
} else {
1232+
VAL_SET(temp, (cmd == SYM_STRING_BYTES) ? REB_STRING: REB_BINARY);
1233+
bin_new = Copy_Series_Part(bin, VAL_INDEX(buffer_read), n);
1234+
VAL_SERIES(temp) = bin_new;
1235+
VAL_INDEX(temp) = 0;
1236+
if (cmd == SYM_STRING_BYTES) {
1237+
VAL_TAIL(temp) = strnlen(VAL_BIN(temp), n);
1238+
}
12431239
}
12441240
break;
12451241
case SYM_STRING:

src/core/u-compress.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ void Trap_ZStream_Error(z_stream *stream, int err, REBOOL while_compression)
172172
if (len < 0 || (index + len > BIN_LEN(input))) len = BIN_LEN(input) - index;
173173
if (limit > 0) {
174174
size = limit;
175+
} else if (windowBits < 0) {
176+
// limit was not specified, but data are supposed to be raw DEFLATE data
177+
// max teoretic DEFLATE ration is 1032:1, but that is quite unrealistic
178+
// it will be more around 3:1 or 4:1, so 10:1 could be enough for automatic setup.
179+
size = 10 * (REBCNT)len; //@@ fix me, if you don't agree with above claim
175180
} else {
176181
// Get the uncompressed size from last 4 source data bytes.
177182
if (len < 4) Trap0(RE_PAST_END); // !!! better msg needed
@@ -209,8 +214,8 @@ void Trap_ZStream_Error(z_stream *stream, int err, REBOOL while_compression)
209214
//printf("total_out: %i\n", stream.total_out);
210215
inflateEnd(&stream);
211216

212-
SET_STR_END(output, size);
213-
SERIES_TAIL(output) = size;
217+
SET_STR_END(output, stream.total_out);
218+
SERIES_TAIL(output) = stream.total_out;
214219

215220
return output;
216221
}

0 commit comments

Comments
 (0)