Skip to content

Commit

Permalink
2.10.7: fix REPLACEMENT COUNT + bugfix DELETE internal (#1454)
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp authored Aug 5, 2024
1 parent a53b0e6 commit 6ef00bb
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 85 deletions.
44 changes: 22 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@
},
"homepage": "https://github.com/abaplint/transpiler_poc#readme",
"devDependencies": {
"@abaplint/core": "^2.112.9",
"@abaplint/core": "^2.112.10",
"@types/chai": "^4.3.17",
"@types/mocha": "^10.0.7",
"@types/node": "^22.0.2",
"@types/node": "^22.1.0",
"@types/sql.js": "^1.4.9",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
Expand Down
66 changes: 33 additions & 33 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abaplint/transpiler-cli",
"version": "2.10.6",
"version": "2.10.7",
"description": "Transpiler - Command Line Interface",
"funding": "https://github.com/sponsors/larshp",
"bin": {
Expand All @@ -26,12 +26,12 @@
"author": "abaplint",
"license": "MIT",
"devDependencies": {
"@abaplint/transpiler": "^2.10.6",
"@abaplint/transpiler": "^2.10.7",
"@types/glob": "^8.1.0",
"glob": "=7.2.0",
"@types/progress": "^2.0.7",
"@types/node": "^22.0.2",
"@abaplint/core": "^2.112.9",
"@types/node": "^22.1.0",
"@abaplint/core": "^2.112.10",
"progress": "^2.0.3",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abaplint/runtime",
"version": "2.10.6",
"version": "2.10.7",
"description": "Transpiler - Runtime",
"main": "build/src/index.js",
"typings": "build/src/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/src/statements/delete_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {INumeric} from "../types/_numeric";
import {loop} from "./loop";

export interface IDeleteInternalOptions {
where?: (i: any) => boolean,
where?: (i: any) => Promise<boolean>,
index?: INumeric,
adjacent?: boolean,
comparing?: string[],
Expand Down Expand Up @@ -98,7 +98,7 @@ export async function deleteInternal(target: Table | HashedTable | FieldSymbol,

if (options?.where) {
const row = i instanceof Structure ? i.get() : {table_line: i};
if (options.where(row) === true) {
if (await options.where(row) === true) {
if (target instanceof HashedTable) {
target.deleteFrom(i);
} else {
Expand Down
9 changes: 8 additions & 1 deletion packages/runtime/src/statements/replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type replaceInput = {
sectionLength?: INumeric,
sectionOffset?: INumeric,
replacementLength?: INumeric,
replacementCount?: INumeric,
regex?: ICharacter,
pcre?: ICharacter,
all: boolean,
Expand Down Expand Up @@ -53,7 +54,8 @@ export function replace(input: replaceInput): void {
search = new RegExp(regex, ignoreCase + allOccurrences);
found = temp.match(search) !== null;
} else if (input.pcre) {
const regex = ABAPRegExp.convert(input.pcre.get());
const str = input.pcre.get();
const regex = ABAPRegExp.convert(str);
if (regex.length === 0 && input.all === true) {
throw "REPLACE, zero length input";
}
Expand Down Expand Up @@ -96,6 +98,11 @@ export function replace(input: replaceInput): void {
input.replacementLength.set(replacement.length);
}

if (input.replacementCount) {
const match = temp.match(search);
input.replacementCount.set(match?.length || 0);
}

temp = temp.replace(search, rr);

const subrc = found ? 0 : 4;
Expand Down
18 changes: 9 additions & 9 deletions packages/transpiler/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6ef00bb

Please sign in to comment.