From e64e1ef72ee367f344bd4cbb980f093237a10384 Mon Sep 17 00:00:00 2001 From: Ian Ray Date: Tue, 18 Mar 2025 15:15:55 +0200 Subject: [PATCH 1/3] scripts/count_lines: remove redundant variable 'objs' --- scripts/count_lines | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/count_lines b/scripts/count_lines index bd7a5cc..63197c4 100755 --- a/scripts/count_lines +++ b/scripts/count_lines @@ -183,10 +183,6 @@ f=$(cd ${OBJ_DIR} && find . -type f) echo "${f}" > "${FIND}" #find ${OBJ_DIR} -type f > "${FIND}" -objs=$(cd "${OBJ_DIR}" && find . -type f | grep "\.o$") - - - # first get the object files and strip off the .o and replace it with a .c # to find the .c files we want to count. #find . -type f | grep "\.o$" | sed -e 's/\.o$/\.c/' > "${C_FILES}" From 950b92d6ec4b3153d89804a3601eb78a37dd7d23 Mon Sep 17 00:00:00 2001 From: Ian Ray Date: Tue, 18 Mar 2025 14:55:55 +0200 Subject: [PATCH 2/3] scripts/count_lines: run count_lines() in SRC_DIR Behave like find_includes() in case of split object and source trees. --- scripts/count_lines | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/count_lines b/scripts/count_lines index 63197c4..2e6142f 100755 --- a/scripts/count_lines +++ b/scripts/count_lines @@ -157,6 +157,10 @@ find_includes() { count_lines() { FILES=$1 + + pushd . + cd "${SRC_DIR}" + while read -r FILE ; do if [ -f "${FILE}" ]; then LINES=$(wc -l "${FILE}" | cut -f 1 -d ' ') @@ -164,6 +168,8 @@ count_lines() { #printf "total=%08d\tlines=%06d\t%s\n" ${TOTAL_LINES} "${LINES}" "${FILE}" fi done < "${FILES}" + + popd } From 1a445c85d2f683fcf9448ddfd51f3c16eb3173f5 Mon Sep 17 00:00:00 2001 From: Ian Ray Date: Tue, 18 Mar 2025 14:59:25 +0200 Subject: [PATCH 3/3] scripts/count_lines: all source and objects in 'FIND' Search SRC_DIR and OBJ_DIR in case of split object and source trees. --- scripts/count_lines | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/count_lines b/scripts/count_lines index 2e6142f..5b796af 100755 --- a/scripts/count_lines +++ b/scripts/count_lines @@ -185,9 +185,12 @@ FIND=$(mktemp "${TMPDIR}/${SCRIPT}"_find.XXXX) || exit 1 # -----------------start here!------------------ printf "Finding all .c files used based on the .o files...\n" -f=$(cd ${OBJ_DIR} && find . -type f) -echo "${f}" > "${FIND}" -#find ${OBJ_DIR} -type f > "${FIND}" + +(cd "${SRC_DIR}" && find . -type f) > "${FIND}" + +if [ "${SRC_DIR}" != "${OBJ_DIR}" ]; then + (cd "${OBJ_DIR}" && find . -type f) >> "${FIND}" +fi # first get the object files and strip off the .o and replace it with a .c # to find the .c files we want to count.