Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions manpage
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,10 @@ does not. When no
.I CONTEXT
is active, returns the same value as
.B recno().
.IP "ctxoffset()" 3
Returns the current effective context offset. When no
.I CONTEXT
is active, returns 0.
.IP "record()" 3
Returns the entire input record. Equivalent to
.B range(1,-1)
Expand Down
1 change: 1 addition & 0 deletions specs/docs/alu_adv.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ All three regular expression functions have an argument called `matchFlags`. Thi
| `range(n,m)` | Returns the substring from the *n*-th character (default first) to the *m*-th character (default last) |
| `recno()` | Returns the number of the currently read record. If the `READ` or `READSTOP` keywords are used this may be greater than `number()` |
| `ctxrecno()` | Returns the record number of the record that input parts work on. This is similar to `recno()`, but considers rolling context, which `recno()` does not. |
| `ctxoffset()` | Returns the current effective context offset. Returns 0 when no `CONTEXT` is in effect. |
| `record()` | Returns the entire input record. Equivalent to `@!`. |
| `cfrecord()` | Returns the entire input record, disregarding rolling context. Same as `record()` when `CONTEXT` is not in effect. Equivalent to `@@`. |
| `word(n)` | Returns the *n*-th word |
Expand Down
4 changes: 4 additions & 0 deletions specs/src/test/ProcessingTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,10 @@ int main(int argc, char** argv)
" Using cfrecord(): But I can't help falling in love with you";
VERIFY2(spec, strm.c_str(), res.c_str()); // TEST #260

// ctxoffset() function test
spec = "PRINT 'ctxoffset()' 1 CONTEXT +1 PRINT 'ctxoffset()' NW CONTEXT -1 PRINT 'ctxoffset()' NW";
VERIFY2(spec, "x", "0 1 -1"); // TEST #261

if (errorCount) {
std::cout << '\n' << errorCount << '/' << testCount << " tests failed.\n";
std::cout << "Failed tests: ";
Expand Down
5 changes: 5 additions & 0 deletions specs/src/utils/aluFunctions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ PValue AluFunc_ctxrecno()
return mkValue(g_pStateQueryAgent->getRecordCount() + g_pStateQueryAgent->getContextOffset());
}

PValue AluFunc_ctxoffset()
{
return mkValue(g_pStateQueryAgent->getContextOffset());
}

PValue AluFunc_eof()
{
bool isRunOut = g_pStateQueryAgent->isEOF();
Expand Down
2 changes: 2 additions & 0 deletions specs/src/utils/aluFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"() - Returns the record number of the current record.","Increments with every READ or READSTOP.") \
X(ctxrecno, 0, ALUFUNC_REGULAR, true, \
"() - Returns the record number of the record that input parts work on.","This is similar to recno, but considers rolling context, which recno does not.") \
X(ctxoffset, 0, ALUFUNC_REGULAR, true, \
"() - Returns the current effective context offset.","Returns 0 when no CONTEXT is in effect.") \
X(number, 0, ALUFUNC_REGULAR, true, \
"() - Returns the number of times this specification has restarted","Does not increment with READ or READSTOP. Otherwise similar to recno().") \
X(eof, 0, ALUFUNC_REGULAR, false, \
Expand Down
2 changes: 1 addition & 1 deletion specs/tests/valgrind_unit_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys, memcheck, argparse

count_ALU_tests = 832
count_processing_tests = 260
count_processing_tests = 261
count_token_tests = 17

# Parse the one command line options
Expand Down
Loading