ref: 5c0c2769456ea4e471e9b53fdee234405942490a
parent: 1350298eaa86abafed447c58fb8f292ae4b6b789
author: Lennart Augustsson <lennart@augustsson.net>
date: Thu Jan 16 08:21:18 EST 2025
Use a macro, SETBSTR, to set BSTR nodes.
--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -3010,6 +3010,7 @@
#define SETPTR(n,r) do { SETTAG((n), T_PTR); PTR(n) = (r); } while(0)
#define SETFUNPTR(n,r) do { SETTAG((n), T_FUNPTR); FUNPTR(n) = (r); } while(0)
#define SETFORPTR(n,r) do { SETTAG((n), T_FORPTR); FORPTR(n) = (r); } while(0)
+#define SETBSTR(n,r) do { SETTAG((n), T_BSTR); FORPTR(n) = (r); } while(0)
#define OPINT1(e) do { CHECK(1); xi = evalint(ARG(TOP(0))); e; POP(1); n = TOP(-1); } while(0);
#define OPPTR2(e) do { CHECK(2); xp = evalptr(ARG(TOP(0))); yp = evalptr(ARG(TOP(1))); e; POP(2); n = TOP(-1); } while(0);
#define CMPP(op) do { OPPTR2(r = xp op yp); GOIND(r ? combTrue : combFalse); } while(0)
@@ -3285,8 +3286,7 @@
struct bytestring bs = evalstring(ARG(TOP(0)));
POP(1);
n = TOP(-1);
- SETTAG(n, T_BSTR);
- FORPTR(n) = mkForPtr(bs);
+ SETBSTR(n, mkForPtr(bs));
RET;
}
@@ -3310,8 +3310,7 @@
(void)headutf8(xfp->payload, &out); /* skip one UTF8 character */
xi = (char*)out - (char*)xfp->payload.string; /* offset */
yi = xfp->payload.size - xi; /* remaining length */
- SETTAG(n, T_BSTR);
- FORPTR(n) = bssubstr(xfp, xi, yi); /* make a substring */
+ SETBSTR(n, bssubstr(xfp, xi, yi)); /* make a substring */
}
RET;
@@ -3342,8 +3341,7 @@
struct bytestring bs = evalbytestring(ARG(TOP(0)));
POP(1);
n = TOP(-1);
- SETTAG(n, T_BSTR);
- FORPTR(n) = mkForPtr(bs);
+ SETBSTR(n, mkForPtr(bs));
RET;
}
@@ -3354,8 +3352,7 @@
yi = evalint(ARG(TOP(2)));
POP(3);
n = TOP(-1);
- SETTAG(n, T_BSTR);
- FORPTR(n) = bssubstr(xfp, xi, yi);
+ SETBSTR(n, bssubstr(xfp, xi, yi));
RET;
case T_BSLENGTH:
@@ -3685,8 +3682,7 @@
//fprintf(stderr, "tag=%d\n", GETTAG(FUN(TOP(0))));
ERR("BINBS");
}
- SETTAG((n), T_BSTR);
- FORPTR(n) = mkForPtr(rbs);
+ SETBSTR(n, mkForPtr(rbs));
goto ret;
default: