Skip to content

Commit 9535519

Browse files
committed
Merge mainline into community
2 parents b12513a + 33a7942 commit 9535519

File tree

6 files changed

+20
-44
lines changed

6 files changed

+20
-44
lines changed

src/boot/errors.r

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Note: [
3131
no-load: [{cannot load: } :arg1]
3232
exited: [{exit occurred}]
3333
deprecated: {deprecated function not allowed}
34-
else-gone: {ELSE is obsolete - use the EITHER function}
3534
]
3635

3736
Syntax: [

src/boot/natives.r

+4-6
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,10 @@ halt: native [
187187
]
188188

189189
if: native [
190-
{If TRUE condition, return arg; evaluate block args by default}
190+
{If TRUE condition, return arg; evaluate blocks by default.}
191191
condition
192192
true-branch
193-
/else "If FALSE condition, return second arg; evaluate block by default"
194-
false-branch
195-
/only "Suppress evaluation of block args."
193+
/only "Return block arg instead of evaluating it."
196194
]
197195

198196
loop: native [
@@ -308,10 +306,10 @@ try: native [
308306
]
309307

310308
unless: native [
311-
{If FALSE condition, return arg; evaluate block args by default.}
309+
{If FALSE condition, return arg; evaluate blocks by default.}
312310
condition
313311
false-branch
314-
/only "Suppress evaluation of block args."
312+
/only "Return block arg instead of evaluating it."
315313
]
316314

317315
until: native [

src/core/n-control.c

+5-30
Original file line numberDiff line numberDiff line change
@@ -602,17 +602,6 @@ enum {
602602
}
603603

604604

605-
/***********************************************************************
606-
**
607-
*/ REBNATIVE(else)
608-
/*
609-
***********************************************************************/
610-
{
611-
Trap0(RE_ELSE_GONE);
612-
DEAD_END;
613-
}
614-
615-
616605
/***********************************************************************
617606
**
618607
*/ REBNATIVE(exit)
@@ -630,27 +619,13 @@ enum {
630619
/*
631620
***********************************************************************/
632621
{
633-
REBVAL *cond = D_ARG(1);
634-
REBCNT argnum = 2;
635-
636-
if (!D_REF(3)) { // no /else
637-
if (IS_FALSE(cond)) return R_NONE;
638-
} else
639-
if (IS_FALSE(cond)) argnum = 4;
640-
641-
if (IS_BLOCK(D_ARG(argnum)) && !D_REF(5) /* not using /ONLY */) {
642-
DO_BLK(D_ARG(argnum));
622+
if (IS_FALSE(D_ARG(1))) return R_NONE;
623+
if (IS_BLOCK(D_ARG(2)) && !D_REF(3) /* not using /ONLY */) {
624+
DO_BLK(D_ARG(2));
643625
return R_TOS1;
644-
} {
645-
if (argnum == 2)
646-
return R_ARG2;
647-
else {
648-
// No R_ARG4, but IF/ELSE may get the axe (CC #2077)
649-
DS_RET_VALUE(D_ARG(argnum));
650-
return R_RET;
651-
}
626+
} else {
627+
return R_ARG2;
652628
}
653-
654629
}
655630

656631

src/core/s-crc.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,17 @@ static REBCNT *CRC_Table;
158158
{
159159
REBINT m, n;
160160
REBINT hash;
161+
REBCNT ulen;
161162

162163
if (len < 0) len = LEN_BYTES(str);
163164

164165
hash = (REBINT)len + (REBINT)((REBYTE)LO_CASE(*str));
165166

166-
for (; len > 0; str++, len--) {
167+
ulen = (REBCNT)len; // so the & operation later isn't for the wrong type
168+
169+
for (; ulen > 0; str++, ulen--) {
167170
n = *str;
168-
if (n > 127 && NZ(m = Decode_UTF8_Char(&str, &len))) n = m; // mods str, len
171+
if (n > 127 && NZ(m = Decode_UTF8_Char(&str, &ulen))) n = m; // mods str, ulen
169172
if (n < UNICODE_CASES) n = LO_CASE(n);
170173
n = (REBYTE)((hash >> CRCSHIFTS) ^ (REBYTE)n); // drop upper 8 bits
171174
hash = MASK_CRC(hash << 8) ^ (REBINT)CRC_Table[n];

src/core/s-find.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
** -3: no match, s2 > s1
258258
** -1: no match, s1 > s2
259259
** 0: exact match
260-
** 1: non-case match, s2 > s1
260+
** 1: non-case match, s2 > s1
261261
** 3: non-case match, s1 > s2
262262
**
263263
** So, result + 2 for no-match gives proper sort order.
@@ -271,7 +271,7 @@
271271
REBCNT l1 = LEN_BYTES(s1);
272272
REBINT result = 0;
273273

274-
for (; l2 > 0; s1++, s2++, l2--) {
274+
for (; l1 > 0 && l2 > 0; s1++, s2++, l1--, l2--) {
275275
c1 = (REBYTE)*s1;
276276
c2 = (REBYTE)*s2;
277277
if (c1 > 127) c1 = Decode_UTF8_Char(&s1, &l1); //!!! can return 0 on error!
@@ -284,6 +284,7 @@
284284
if (!result) result = (c1 > c2) ? 3 : 1;
285285
}
286286
}
287+
if (l1 != l2) result = (l1 > l2) ? -1 : -3;
287288

288289
return result;
289290
}

src/core/s-unicode.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ ConversionResult ConvertUTF8toUTF32 (
768768

769769
/***********************************************************************
770770
**
771-
*/ REBCNT Decode_UTF8_Char(REBYTE **str, REBINT *len)
771+
*/ REBCNT Decode_UTF8_Char(REBYTE **str, REBCNT *len)
772772
/*
773773
** Converts a single UTF8 code-point (to 32 bit).
774774
** Errors are returned as zero. (So prescan source for null.)
@@ -817,7 +817,7 @@ ConversionResult ConvertUTF8toUTF32 (
817817

818818
/***********************************************************************
819819
**
820-
*/ int Decode_UTF8(REBUNI *dst, REBYTE *src, REBINT len, REBFLG ccr)
820+
*/ int Decode_UTF8(REBUNI *dst, REBYTE *src, REBCNT len, REBFLG ccr)
821821
/*
822822
** Decode UTF8 byte string into a 16 bit preallocated array.
823823
**
@@ -853,7 +853,7 @@ ConversionResult ConvertUTF8toUTF32 (
853853

854854
/***********************************************************************
855855
**
856-
*/ int Decode_UTF16(REBUNI *dst, REBYTE *src, REBINT len, REBFLG lee, REBFLG ccr)
856+
*/ int Decode_UTF16(REBUNI *dst, REBYTE *src, REBCNT len, REBFLG lee, REBFLG ccr)
857857
/*
858858
** dst: the desination array, must always be large enough!
859859
** src: source binary data

0 commit comments

Comments
 (0)