From d72512be18c4dec213b6c5a2bc75efbfdfb27d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Barbi=C4=87?= Date: Fri, 30 Oct 2020 21:28:51 +0100 Subject: [PATCH 1/4] Allow use of interface --- lxc/executors/java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc/executors/java b/lxc/executors/java index 822e67d..9cbc6f7 100755 --- a/lxc/executors/java +++ b/lxc/executors/java @@ -1,6 +1,6 @@ cd /tmp/$2 cp code.code interim.java -name=$(cat interim.java | grep -Eo 'public\s+class\s+([A-Za-z0-9]+)' | sed -n 's/ */ /gp' | cut -d' ' -f3) +name=$(cat interim.java | grep -Eo '(public\s+class|interface)\s+([A-Za-z0-9]+)' | sed -n 's/ */ /gp' | cut -d' ' -f3) mv interim.java $name.java timeout -s KILL 10 javac $name.java runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 java $name" From b7615b8126fda4e499e1e97e8d89f0585a0034f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Barbi=C4=87?= Date: Fri, 30 Oct 2020 21:39:58 +0100 Subject: [PATCH 2/4] Fix name detection --- lxc/executors/java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc/executors/java b/lxc/executors/java index 9cbc6f7..9b26c1a 100755 --- a/lxc/executors/java +++ b/lxc/executors/java @@ -1,6 +1,6 @@ cd /tmp/$2 cp code.code interim.java -name=$(cat interim.java | grep -Eo '(public\s+class|interface)\s+([A-Za-z0-9]+)' | sed -n 's/ */ /gp' | cut -d' ' -f3) +name=$(cat interim.java | sed -E 's/(public\s+class|interface)\s+([A-Za-z0-9]+)/\2/') mv interim.java $name.java timeout -s KILL 10 javac $name.java runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 java $name" From f133ce04e0670db2f0f686574c90aadb8a7e852f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Barbi=C4=87?= Date: Fri, 30 Oct 2020 22:15:01 +0100 Subject: [PATCH 3/4] Replace regex completely Now supports enums aswell --- lxc/executors/java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc/executors/java b/lxc/executors/java index 9b26c1a..08e1fb5 100755 --- a/lxc/executors/java +++ b/lxc/executors/java @@ -1,6 +1,6 @@ cd /tmp/$2 cp code.code interim.java -name=$(cat interim.java | sed -E 's/(public\s+class|interface)\s+([A-Za-z0-9]+)/\2/') +name=$(grep -Po "(?<=\n|\A)\s*(public\s+)?(class|interface|enum)\s+\K([^\n\s{]+)" interim.java) mv interim.java $name.java timeout -s KILL 10 javac $name.java runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 java $name" From 65d66aa979f1d5ef48299abda71590fc408c0f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Barbi=C4=87?= Date: Fri, 30 Oct 2020 22:17:46 +0100 Subject: [PATCH 4/4] Get rid of enum --- lxc/executors/java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc/executors/java b/lxc/executors/java index 08e1fb5..66261bb 100755 --- a/lxc/executors/java +++ b/lxc/executors/java @@ -1,6 +1,6 @@ cd /tmp/$2 cp code.code interim.java -name=$(grep -Po "(?<=\n|\A)\s*(public\s+)?(class|interface|enum)\s+\K([^\n\s{]+)" interim.java) +name=$(grep -Po "(?<=\n|\A)\s*(public\s+)?(class|interface)\s+\K([^\n\s{]+)" interim.java) mv interim.java $name.java timeout -s KILL 10 javac $name.java runuser runner$1 -c "cd /tmp/$2 ; cat args.args | xargs -d '\n' timeout -s KILL 3 java $name"