Commit Graph
37 Commits
Author SHA1 Message Date
Brad Arant b0cadc3f08 Multi-day accumulated fixes: tag dispatch, session/pooling correctness, SPA rollout, jetc compiler
JetCore engine (Tag.cpp/.h, Global.cpp/.h, __*.cpp tag classes):
- Numerous __mysql.cpp connection-pooling correctness fixes (stale
  result sets, double-indirection sessionid bugs, field caching,
  pool keying) and a session-registration-before-connection-confirmed
  ordering fix (dangling pointer on a failed connect)
- Tag.cpp: large body of fixes to the tag-dispatch/container-scanning
  logic (bare-name fallback, database aliasing, single-quote handling,
  @-prefix session variable resolution, TAGDEF caching, nested split-tag
  scanning for if/while/until/ifrow so an inner one doesn't corrupt an
  outer one's own boundary scan) plus the process-first rendering
  order fix (a <process> now runs before <checksession>/page
  resolution, fixing a real "blank page after successful login" bug)
- Global.h/.cpp: added imapSessions (parallel to the existing __mysql*
  session map) for the new <imap> tag family
- __whiledir.cpp/__include.cpp: caching and directory-name-aliasing
  fixes
- __call.cpp/.h: fixed a dangling-pointer bug
- __write.cpp: fixed an O_WRONLY-only open that couldn't create a new
  file
- __ifrow.cpp/__sql.cpp: fixed the same sessionid double-indirection
  bug __mysql.cpp had (resolveKeyword's result was being used as a map
  key lookup instead of the resolved value itself)

jetc compiler (jetc/JetParser.cpp/.h, JetCodegen.cpp/.h, JetAST.h,
jetc.cpp, build-shared.sh, build-compiled.sh):
- Parser fixes: inline <include>, nested-quote handling, void-tag
  recognition
- Codegen fixes and expanded AST support
- build-shared.sh: atomic rename into place for a freshly-built .jtc
  (a live server dlopen()ing the same path mid-rebuild was corrupting
  its own already-mapped view of the old file) and a staleness check
  so a cached JetCore .o doesn't silently keep serving yesterday's
  fixes forever
- Added -lssl to both build scripts' link lines (needed once the new
  <imap> tag's client-side TLS code existed - previously nothing in
  this codebase used OpenSSL's SSL/TLS client API, only libcrypto)

Site content (jetc/barant-site/): SPA (fetch-and-swap navigation)
rollout across essentially every .page/.jet/.section/.tag/.proc/.method
file - dynamic-content fixes, fragment-mode stripping, native
$[@name] session variables replacing older mechanisms, and this
session's own checkout.page redesign, login start-param redirect fix,
and per-page side-menu (menu.bar/$[PAGE].menu) refresh support.
Completed the earlier main.css/control.css move from assets/ to
assets/images/ (git still showed the old paths as tracked-but-deleted
until now).

Deliberately left out of this commit: dozens of .pre-<description>-
<date> manual backup files (this session's and earlier ones' own
before/after snapshots, not meant for permanent history), compiled
.jtc build outputs, ad hoc test binaries and scripts under jetc/
(login_asan, wcwc_test, optest2_bin, etc.), and jetc/__pycache__/ -
none of these are meant to be tracked; a .gitignore covering them
would be worth adding separately.
2026-09-03 05:20:48 +00:00
Brad Arant 8b2391b289 Implement datediff(a, b)
Parsed its arguments correctly but had an empty body (a literal
"// TODO: Implement DATEDIFF." comment), never setting a result - isNumber
was left uninitialized on this path.

Matches MySQL's own DATEDIFF(expr1, expr2): expr1 - expr2 expressed as a
whole number of days, ignoring time-of-day. Dates parse as YYYY-MM-DD via
strptime (a longer "YYYY-MM-DD HH:MM:SS" value parses fine too, since
strptime only consumes what the format string asks for) and are
interpreted as UTC via timegm() rather than mktime(), so the result
doesn't shift with the server's own timezone. An unparseable date throws
a clear, specific error instead of producing garbage.

Verified via real jet-2.0 runs: datediff('2026-08-26','2026-08-20') -> 6,
the reverse -> -6, same date -> 0, a full non-leap year -> 365, and an
invalid date string throws cleanly rather than crashing or silently
returning nonsense. Full 9-script regression suite still passes.
2026-08-26 10:50:57 -07:00
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