From 2223e6d601445cc1e7e659297a6c6fb3b7d81c65 Mon Sep 17 00:00:00 2001 From: cnc Date: Thu, 4 Jun 2026 05:16:19 +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=8C=E5=AE=8C=E6=88=90=E5=B0=BD=E9=87=8F=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9=EF=BC=9A=E7=BB=93=E8=AE=BA=E4=B8=BA?= =?UTF-8?q?=20manifest=20=E6=A0=A1=E9=AA=8C=E8=A6=86=E7=9B=96=20LinuxCNC?= =?UTF-8?q?=20loadusr=20=E7=AD=89=E5=BE=85=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check-linuxcnc-inputs.sh | 80 ++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 27 deletions(-) diff --git a/check-linuxcnc-inputs.sh b/check-linuxcnc-inputs.sh index 8ef2f33..05f99e5 100755 --- a/check-linuxcnc-inputs.sh +++ b/check-linuxcnc-inputs.sh @@ -899,6 +899,57 @@ if [[ -n "$manifest" && "$require_complete" == "--require-kinematics-complete" ] fi } + extract_waited_loadusr_programs() { + # Source basis: LinuxCNC src/hal/utils/halcmd_commands.cc + # do_loadusr_cmd() parses loadusr options with getopt("+wWin:"), + # and its help text plus src/hal/utils/halcmd_completion.c list both + # "-W" and "-Wn" wait forms. + awk ' + function emit_waited_program(fields, field_count, start_index, i, token, waiting) { + waiting = 0 + for (i = start_index + 1; i <= field_count; i++) { + token = fields[i] + if (token == "-W") { + waiting = 1 + continue + } + if (token == "-Wn") { + waiting = 1 + i++ + continue + } + if (token == "-n") { + i++ + continue + } + if (token ~ /^-Wn.+/) { + waiting = 1 + continue + } + if (token ~ /^-n.+/) continue + if (token ~ /^-[wWi]+$/) { + if (token ~ /W/) waiting = 1 + continue + } + if (token ~ /^-/) continue + if (waiting && token != "") print token + return + } + } + { + line = $0 + sub(/[[:space:]]*[#;].*$/, "", line) + field_count = split(line, fields, /[[:space:]]+/) + for (i = 1; i <= field_count; i++) { + if (fields[i] == "loadusr") { + emit_waited_program(fields, field_count, i) + next + } + } + } + ' "$1" + } + m428_m430_vismach_loadusr_sources=() for source in "${manifest_m428_m430_ini_sources[@]}"; do while IFS= read -r command_name; do @@ -906,20 +957,7 @@ if [[ -n "$manifest" && "$require_complete" == "--require-kinematics-complete" ] while IFS= read -r vismach_source; do [[ -n "$vismach_source" ]] && m428_m430_vismach_loadusr_sources+=("$vismach_source") done < <(resolve_vismach_loadusr_source "$command_name") - done < <( - awk ' - BEGIN { IGNORECASE = 1 } - /^[[:space:]]*HALCMD[[:space:]]*=/ && /loadusr[[:space:]]/ { - for (i = 1; i <= NF; i++) { - if ($i == "-W" && (i + 1) <= NF) { - value = $(i + 1) - sub(/[[:space:]#;].*/, "", value) - if (value != "") print value - } - } - } - ' "$linuxcnc_root/$source" - ) + done < <(extract_waited_loadusr_programs "$linuxcnc_root/$source") done for source in "${m428_m430_config_hal_sources[@]}"; do while IFS= read -r command_name; do @@ -927,19 +965,7 @@ if [[ -n "$manifest" && "$require_complete" == "--require-kinematics-complete" ] while IFS= read -r vismach_source; do [[ -n "$vismach_source" ]] && m428_m430_vismach_loadusr_sources+=("$vismach_source") done < <(resolve_vismach_loadusr_source "$command_name") - done < <( - awk ' - /^[[:space:]]*loadusr[[:space:]]/ { - for (i = 1; i <= NF; i++) { - if ($i == "-W" && (i + 1) <= NF) { - value = $(i + 1) - sub(/[[:space:]#;].*/, "", value) - if (value != "") print value - } - } - } - ' "$linuxcnc_root/$source" - ) + done < <(extract_waited_loadusr_programs "$linuxcnc_root/$source") done mapfile -t m428_m430_vismach_loadusr_sources < <( printf '%s\n' "${m428_m430_vismach_loadusr_sources[@]}" | sed '/^$/d' | sort -u