From 2dd9847a7b67c39dc872d17558f1ced00101082b Mon Sep 17 00:00:00 2001 From: cnc Date: Wed, 3 Jun 2026 09:04:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E8=80=83=E6=89=80=E6=9C=89=E5=88=86?= =?UTF-8?q?=E7=BB=84=EF=BC=9A=E8=A1=A5=20comment=20=E9=94=99=E8=AF=AF=20so?= =?UTF-8?q?urce=20=E8=A6=86=E7=9B=96=EF=BC=8C=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test-all-native.sh | 2 ++ test-linuxcnc-source-link.sh | 5 ++++- tests/gcode/linuxcnc_nested_comment_error.ngc | 2 ++ tests/gcode/linuxcnc_unclosed_comment_error.ngc | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/gcode/linuxcnc_nested_comment_error.ngc create mode 100644 tests/gcode/linuxcnc_unclosed_comment_error.ngc diff --git a/test-all-native.sh b/test-all-native.sh index bb88c59..dfb9eec 100755 --- a/test-all-native.sh +++ b/test-all-native.sh @@ -565,6 +565,8 @@ grep -F 'tests/gcode/linuxcnc_fractional_linenumbers.ngc' test-linuxcnc-source-l grep -F 'tests/gcode/linuxcnc_extended_linenumbers.ngc' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_close_and_downcase_words.ngc' test-linuxcnc-source-link.sh >/dev/null grep -F 'tests/gcode/linuxcnc_percent_file_ignores_trailing.ngc' test-linuxcnc-source-link.sh >/dev/null +grep -F 'linuxcnc_unclosed_comment_error|Unclosed comment found' test-linuxcnc-source-link.sh >/dev/null +grep -F 'linuxcnc_nested_comment_error|Nested comment found' test-linuxcnc-source-link.sh >/dev/null for script in \ test-native.sh \ diff --git a/test-linuxcnc-source-link.sh b/test-linuxcnc-source-link.sh index 2823f9c..241d439 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -1202,11 +1202,14 @@ done # Source basis: LinuxCNC src/emc/rs274ngc/interp_read.cc read_text() # rejects EOF without the matching percent/program end and overlong file # lines; read_n_number() rejects malformed N-line numbers through -# read_integer_unsigned(). +# read_integer_unsigned(); src/emc/rs274ngc/interp_internal.cc +# close_and_downcase() rejects unclosed and nested parenthesis comments. read_text_error_cases=( "linuxcnc_file_ended_no_program_end_error|File ended with no percent sign" "linuxcnc_file_ended_no_percent_error|File ended with no percent sign" "linuxcnc_bad_n_number_format_error|Bad format unsigned integer" + "linuxcnc_unclosed_comment_error|Unclosed comment found" + "linuxcnc_nested_comment_error|Nested comment found" ) for case in "${read_text_error_cases[@]}"; do fixture=${case%%|*} diff --git a/tests/gcode/linuxcnc_nested_comment_error.ngc b/tests/gcode/linuxcnc_nested_comment_error.ngc new file mode 100644 index 0000000..b279125 --- /dev/null +++ b/tests/gcode/linuxcnc_nested_comment_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G0 X1 (outer (inner)) diff --git a/tests/gcode/linuxcnc_unclosed_comment_error.ngc b/tests/gcode/linuxcnc_unclosed_comment_error.ngc new file mode 100644 index 0000000..4484093 --- /dev/null +++ b/tests/gcode/linuxcnc_unclosed_comment_error.ngc @@ -0,0 +1,2 @@ +G21 G90 +G0 X1 (missing close