pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/misc show-all: use descriptive variable names



details:   https://anonhg.NetBSD.org/pkgsrc/rev/47423548d096
branches:  trunk
changeset: 438937:47423548d096
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Sep 12 21:27:15 2020 +0000

description:
show-all: use descriptive variable names

The show-all code is mostly line noise, therefore it is all the more
important to provide at least a few hints to a potential reader, by
using descriptive variable names for the iteration variables:

        g => grp
        c => cat
        v => var
        w => width
        x => word

diffstat:

 mk/misc/show.mk |  58 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 29 insertions(+), 29 deletions(-)

diffs (100 lines):

diff -r e13ad87939cb -r 47423548d096 mk/misc/show.mk
--- a/mk/misc/show.mk   Sat Sep 12 21:00:10 2020 +0000
+++ b/mk/misc/show.mk   Sat Sep 12 21:27:15 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: show.mk,v 1.25 2020/09/12 21:00:10 rillig Exp $
+# $NetBSD: show.mk,v 1.26 2020/09/12 21:27:15 rillig Exp $
 #
 # This file contains some targets that print information gathered from
 # variables. They do not modify any variables.
@@ -153,10 +153,10 @@
 _LABEL._DEF_VARS=      def
 
 show-all: .PHONY
-.for g in ${"${.TARGETS:Mshow-all*}":?${_VARGROUPS:O:u}:}
-.  for w in ${_VARGROUP_WIDTH.${g}:U23}
+.for grp in ${"${.TARGETS:Mshow-all*}":?${_VARGROUPS:O:u}:}
+.  for width in ${_VARGROUP_WIDTH.${grp}:U23}
 
-show-all: show-all-${g}
+show-all: show-all-${grp}
 
 # In the following code, the variables are evaluated as late as possible.
 # This is especially important for variables that use the :sh modifier,
@@ -166,51 +166,51 @@
 # using the :sh modifier may show warnings, for example because ${WRKDIR}
 # doesn't exist.
 
-show-all-${g}: .PHONY
-       @${RUN} printf '%s:\n' ${g:Q}
+show-all-${grp}: .PHONY
+       @${RUN} printf '%s:\n' ${grp:Q}
 
-.    for c in ${_SHOW_ALL_CATEGORIES}
-.      for v in ${${c}.${g}}
+.    for cat in ${_SHOW_ALL_CATEGORIES}
+.      for var in ${${cat}.${grp}}
 
-.        if ${_SORTED_VARS.${g}:U:@pattern@ ${v:M${pattern}} @:M*}
+.        if ${_SORTED_VARS.${grp}:U:@pattern@ ${var:M${pattern}} @:M*}
 
 # multi-valued variables, values are sorted
        ${RUN}                                                          \
-       if ${!defined(${v}) :? true : false}; then                      \
-         printf '  %-6s%-${w}s # undefined\n' ${_LABEL.${c}} ${v:Q};   \
-       elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then        \
-         printf '  %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=;      \
+       if ${!defined(${var}) :? true : false}; then                    \
+         printf '  %-6s%-${width}s # undefined\n' ${_LABEL.${cat}} ${var:Q}; \
+       elif value=${${var}:U:M*:Q} && test "x$$value" = "x"; then      \
+         printf '  %-6s%-${width}s # empty\n' ${_LABEL.${cat}} ${var:Q}=; \
        else                                                            \
-         printf '  %-6s%-${w}s \\''\n' ${_LABEL.${c}} ${v:Q}=;         \
-         printf '        %-${w}s %s \\''\n' ${${v}:O:C,\\\$,\$\$\$\$,g:@x@'' ${x:Q}@}; \
-         printf '        %-${w}s # end of %s (sorted)\n' '' ${v:Q};    \
+         printf '  %-6s%-${width}s \\''\n' ${_LABEL.${cat}} ${var:Q}=; \
+         printf '        %-${width}s %s \\''\n' ${${var}:O:C,\\\$,\$\$\$\$,g:@word@'' ${word:Q}@}; \
+         printf '        %-${width}s # end of %s (sorted)\n' '' ${var:Q}; \
        fi
 
-.        elif ${_LISTED_VARS.${g}:U:@pattern@ ${v:M${pattern}} @:M*}
+.        elif ${_LISTED_VARS.${grp}:U:@pattern@ ${var:M${pattern}} @:M*}
 
 # multi-valued variables, preserving original order
        ${RUN}                                                          \
-       if ${!defined(${v}) :? true : false}; then                      \
-         printf '  %-6s%-${w}s # undefined\n' ${_LABEL.${c}} ${v:Q};   \
-       elif value=${${v}:U:M*:Q} && test "x$$value" = "x"; then        \
-         printf '  %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=;      \
+       if ${!defined(${var}) :? true : false}; then                    \
+         printf '  %-6s%-${width}s # undefined\n' ${_LABEL.${cat}} ${var:Q}; \
+       elif value=${${var}:U:M*:Q} && test "x$$value" = "x"; then      \
+         printf '  %-6s%-${width}s # empty\n' ${_LABEL.${cat}} ${var:Q}=; \
        else                                                            \
-         printf '  %-6s%-${w}s \\''\n' ${_LABEL.${c}} ${v:Q}=;         \
-         printf '        %-${w}s %s \\''\n' ${${v}:C,\\\$,\$\$\$\$,g:@x@'' ${x:Q}@}; \
-         printf '        %-${w}s # end of %s\n' '' ${v:Q};             \
+         printf '  %-6s%-${width}s \\''\n' ${_LABEL.${cat}} ${var:Q}=; \
+         printf '        %-${width}s %s \\''\n' ${${var}:C,\\\$,\$\$\$\$,g:@word@'' ${word:Q}@}; \
+         printf '        %-${width}s # end of %s\n' '' ${var:Q};       \
        fi
 
 .        else
 
 # single-valued variables
        ${RUN}                                                          \
-       if ${!defined(${v}) :? true : false}; then                      \
-         printf '  %-6s%-${w}s # undefined\n' ${_LABEL.${c}} ${v:Q};   \
-       elif value=${${v}:U:C,\\\$,\$\$,gW:Q} && test "x$$value" = "x"; then \
-         printf '  %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=;      \
+       if ${!defined(${var}) :? true : false}; then                    \
+         printf '  %-6s%-${width}s # undefined\n' ${_LABEL.${cat}} ${var:Q}; \
+       elif value=${${var}:U:C,\\\$,\$\$,gW:Q} && test "x$$value" = "x"; then \
+         printf '  %-6s%-${width}s # empty\n' ${_LABEL.${cat}} ${var:Q}=; \
        else                                                            \
          case "$$value" in (*[\        \ ]) eol="# ends with space";; (*) eol=""; esac; \
-         printf '  %-6s%-${w}s %s\n' ${_LABEL.${c}} ${v:Q}= "$$value$$eol"; \
+         printf '  %-6s%-${width}s %s\n' ${_LABEL.${cat}} ${var:Q}= "$$value$$eol"; \
        fi
 
 .        endif



Home | Main Index | Thread Index | Old Index