From fa4296d730d75f2e7c89a4466dda3f50562b915d Mon Sep 17 00:00:00 2001 From: cnc Date: Wed, 3 Jun 2026 09:12:17 +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=20percent=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 | 6 +++++- tests/gcode/linuxcnc_commented_percent_error.ngc | 3 +++ tests/gcode/linuxcnc_mid_program_percent_error.ngc | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/gcode/linuxcnc_commented_percent_error.ngc create mode 100644 tests/gcode/linuxcnc_mid_program_percent_error.ngc diff --git a/test-all-native.sh b/test-all-native.sh index dfb9eec..6206704 100755 --- a/test-all-native.sh +++ b/test-all-native.sh @@ -567,6 +567,8 @@ grep -F 'tests/gcode/linuxcnc_close_and_downcase_words.ngc' test-linuxcnc-source 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 +grep -F 'linuxcnc_commented_percent_error|Bad character '\''%'\'' used' test-linuxcnc-source-link.sh >/dev/null +grep -F 'linuxcnc_mid_program_percent_error|Bad character '\''%'\'' used' 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 241d439..4543e68 100755 --- a/test-linuxcnc-source-link.sh +++ b/test-linuxcnc-source-link.sh @@ -1022,9 +1022,13 @@ done # read_one_item() then uses the default reader table from interp_array.cc # and rejects unknown item-start characters, including middle-of-line or # comment-prefixed N/O words, midline O-words, bracket expressions, naked numbers, and -# non-leading ATAN argument slashes. +# non-leading ATAN argument slashes. LinuxCNC src/emc/rs274ngc/rs274ngc_pre.cc +# open() only enables percent-file mode when the first nonblank line contains +# only '%', so commented or non-opening percent lines reach read_one_item(). bad_character_error_cases=( "linuxcnc_bad_character_bang_error|Bad character '!' used" + "linuxcnc_commented_percent_error|Bad character '%' used" + "linuxcnc_mid_program_percent_error|Bad character '%' used" "linuxcnc_bad_character_middle_n_word_error|Bad character 'n' used" "linuxcnc_comment_prefixed_n_word_error|Bad character 'n' used" "linuxcnc_comment_prefixed_spaced_n_word_error|Bad character 'n' used" diff --git a/tests/gcode/linuxcnc_commented_percent_error.ngc b/tests/gcode/linuxcnc_commented_percent_error.ngc new file mode 100644 index 0000000..2a838e6 --- /dev/null +++ b/tests/gcode/linuxcnc_commented_percent_error.ngc @@ -0,0 +1,3 @@ +% (not a delimiter) +G0 X1 +% diff --git a/tests/gcode/linuxcnc_mid_program_percent_error.ngc b/tests/gcode/linuxcnc_mid_program_percent_error.ngc new file mode 100644 index 0000000..19388c8 --- /dev/null +++ b/tests/gcode/linuxcnc_mid_program_percent_error.ngc @@ -0,0 +1,3 @@ +G0 X1 +% +G0 Y2