Commit Graph
35 Commits
Author SHA1 Message Date
Brad Arant 5c703f5620 Implement reverse(str) and concat(a, b, ...) in the expr engine
Both matched their function name but had empty branch bodies, silently
producing nothing regardless of arguments. reverse(str) follows the same
single-argument shape as trim/toupper/tolower; concat(a, b, ...) follows
the same variadic comma-separated shape as max/min.

reverse() converts to std::string and reverses in place via the already-
imported <algorithm> (std::reverse), then assigns back through MString's
std::string constructor. concat() starts from the first argument and
appends each subsequent one via MString's own operator<<(ZString).

Verified via real jet-2.0 runs: reverse('hello') -> "olleh",
concat('a','b','c') -> "abc", concat('x','y') -> "xy". Full 9-script
regression suite (custom tag scoping, dump tag tree, try/catch, if/else,
keyword sigil) still passes unchanged.
2026-08-26 10:45:43 -07:00
Brad Arant 97142ce9b4 Fix substring(str, start) - the 2-argument form was completely broken
Found while writing a new Expressions Reference chapter for the manual,
where every function got run for real before being documented rather
than trusted from reading the source alone - substring('helloworld', 7)
threw "operand is not valid." immediately after producing the correct
answer, confirmed via debug tracing showing an extra Operand constructed
on empty input right after the 2-arg case finished.

Root cause: a missing pair of braces around the 3-argument-only branch
meant Operand parm3(in, tag) and its own closing-paren check ran
unconditionally, even after the 2-arg form's own "if(in.ifNext(')'))"
check had already matched and produced string = parm1.string.substring(
parm2.string.asInteger()) - so it immediately tried to parse a third
argument from whatever was left (nothing, since the real closing paren
was already consumed), and construction on empty input always throws.
The 3-argument form (substring(str, start, length)) was unaffected,
since its own path never hit the first if-branch's early exit.

Fixed by properly scoping the 3-arg branch inside an else, so it only
runs when the 2-arg form's own closing paren wasn't found. Verified both
forms with real jet-2.0 runs: substring('helloworld', 7) -> "rld",
substring('helloworld', 0, 5) -> "hello".
2026-08-26 10:39:38 -07:00
Brad ArantandClaude Sonnet 5 aaed4cb4da Fix Operand treating a "false"-valued variable as boolean true
When resolving a bare $[var]/#[var] reference, Operand set .boolean =
true whenever the value's text was EITHER "true" OR "false" -
effectively "boolean = looks-boolean-ish" rather than reflecting which
of the two it actually was. <if expr="..">/<while expr="..">check
exactly this .boolean field (see __if.cpp/__while.cpp), so <if
expr="$[flag]"> took the true branch even when flag held the literal
text "false".

Fixed to boolean = (string == "true").

Verified live: a variable set to value="false" now correctly takes an
<if expr="$[var]">'s false branch, and value="true" still correctly
takes the true branch. Re-ran tests/posttest.sh - unaffected, no
regression.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 21:48:21 -07:00
Brad Arant 50a29a4238 Added stub for DATEDIFF function. 2025-12-03 14:55:26 -08:00
Brad Arant db59e9e87c fixed output of numeric output from expr(). 2025-12-02 15:56:31 -08:00
Brad Arant a91d78f524 Fixed * and / operators to prioritize over + and -. 2025-11-25 13:16:26 -08:00
Brad Arant 63916cc32a Added FLOOR and CEIL function in operand. 2025-11-24 13:19:31 -08:00
Brad Arant 3314a410e0 Added MIN and MAX functions for operand. 2025-11-24 12:15:56 -08:00
brad Arant c4f0fab8c7 Added a bunch of functions. 2025-11-08 20:04:45 -08:00
brad Arant 078a73664c Added CGI stuff and unixtime function. 2025-11-07 10:22:20 -08:00
brad Arant 7b6342b8d7 Fixed not a number issue with expression. 2025-10-20 10:56:30 -07:00
Brad Arant 167ee75658 add upper and lower to operand functions. 2025-02-13 10:27:44 -08:00
Brad Arant 6e097d8433 some small testvar updates. 2025-02-06 16:06:41 -08:00
Brad Arant 10db0e9c70 created INTEGER function on operand. 2025-02-04 09:28:28 -08:00
Brad Arant 5cefb0974b added trim operand function. 2025-01-16 13:39:09 -08:00
Brad Arant f7812821b3 fixed right() expression. 2025-01-16 09:56:22 -08:00
barant 6516aee6cc Some operand work for right. Needs work. 2025-01-09 17:11:15 -08:00
barant 5c27df59da work towards a clean compile on migrating set and get variables from Tag. 2025-01-08 10:27:30 -08:00
brad Arant f6dda8496c Made $[%name] to retrieve keyword values in a tag. Has bugs. 2025-01-03 10:50:31 -08:00
Brad Arant ca7aabd73f more sever scoping work. 2024-11-26 16:57:03 -08:00
Brad Arant e249588a19 finished expr function. 2024-11-18 13:08:28 -08:00
Brad Arant c39220d39c improved syntax checking on expr. Laid foundation for expr function. 2024-11-18 10:19:39 -08:00
brad Arant 839f7e2eb8 OPerand now does its own expression parsing. 2024-11-16 10:23:16 -08:00
brad Arant 6da620971e Finished up the keyword resolution issue and fixed for, while and until. Other tags still need work. 2024-11-10 18:45:12 -08:00
Brad Arant b46694f71b Made Operand ignore case for function names. 2024-11-05 15:50:06 -08:00
Brad Arant ed00a330a4 Heavy work on while tag. Still needs work. 2024-11-04 16:48:14 -08:00
brad Arant a0183ecb42 Added RANDOM() function. 2024-11-01 12:44:59 -07:00
Brad Arant fa711ddf86 Added LEFT() expression function. 2024-10-01 07:41:05 -07:00
Brad Arant 8299aeaea9 created >= and <= and != for the expr handling. 2024-09-30 16:53:49 -07:00
Brad Arant aa090c8a73 Fixed expressions to be able to do math with nested expressions. 2024-09-30 14:20:59 -07:00
Brad Arant 0b9f2354a3 Fixed float output format. 2024-09-30 08:15:48 -07:00
Brad Arant 5a97da3d1c Fixed some Expression and Operand memory issues. 2024-09-26 16:58:55 -07:00
Brad Arant 03fe14d075 More work on the operand. 2024-08-01 16:17:57 -07:00
Brad Arant bd25efc461 Started into the Expression and Operand obejcts. 2024-07-31 16:18:29 -07:00
Brad Arant 8475ef01d1 Some work on Expression and Operand. 2024-07-22 14:49:15 -07:00