Re: gendocs: file sizes wrong on www.gnu.org (because of a bug in gendocs)
Paul Eggert <[email protected]> Fri, 17 Jul 2026 11:01:24 -0700
| Newsgroups | gmane.comp.lib.gnulib.bugs |
|---|---|
| Organization | UCLA Computer Science Department |
| Message-ID | <[email protected]> |
On 2026-07-17 06:59, Pádraig Brady wrote: > Maybe you could say `du -Ak` is not portable enough. Better yet, use du -h --apparent-size but fall back on wc if GNU du is not in use. That way, we can normally say something like "9.1 MiB" rather than like "9319 K bytes", which was harder to read and was ambiguous anyway. I installed James's patch, followed by the attached.
0001-gendocs-output-human-readable-file-sizes.patch
(text/x-patch, 10.1 KB)
From 74ea50427f57ef7dbc1ef78d1972e39251cbbea9 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 17 Jul 2026 10:50:24 -0700 Subject: [PATCH] gendocs: output human-readable file sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build-aux/gendocs.sh (calcsize): Output human-readable file size, rather than always size in KiB mislabled as "K bytes". But fall back on a plain byte count if GNU du is not in use. (time-stamp-time-zone): Now "UTC0" so scriptversion does not decrease. * doc/gendocs_template, doc/gendocs_template_min: Don’t assume sizes are in KiB (the old values were mislabeled anyway). Be more consistent about file type labels. --- ChangeLog | 11 +++++++++++ build-aux/gendocs.sh | 32 +++++++++++--------------------- doc/gendocs_template | 38 +++++++++++++++++++------------------- doc/gendocs_template_min | 38 +++++++++++++++++++------------------- 4 files changed, 60 insertions(+), 59 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e5b2d74ff..d1ea69185f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2026-07-17 Paul Eggert <[email protected]> + + gendocs: output human-readable file sizes + * build-aux/gendocs.sh (calcsize): Output human-readable file + size, rather than always size in KiB mislabled as "K bytes". + But fall back on a plain byte count if GNU du is not in use. + (time-stamp-time-zone): Now "UTC0" so scriptversion does not decrease. + * doc/gendocs_template, doc/gendocs_template_min: + Don’t assume sizes are in KiB (the old values were mislabeled anyway). + Be more consistent about file type labels. + 2026-07-16 Pádraig Brady <[email protected]> physmem: fix typo causing configure failure diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh index 2b3373ecf7..1b03163345 100755 --- a/build-aux/gendocs.sh +++ b/build-aux/gendocs.sh @@ -2,7 +2,7 @@ # gendocs.sh -- generate a GNU manual in many formats. This script is # mentioned in maintain.texi. See the help message below for usage details. -scriptversion=2026-07-17.13 +scriptversion=2026-07-17.17 # Copyright 2003-2026 Free Software Foundation, Inc. # @@ -229,25 +229,13 @@ if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then exit 1 fi -# Function to return size of $1 in something resembling kilobytes. -# We don't use `ls -s` because that can be longer or shorter than -# the real length of the data (because the file system compresses -# the file, for example). We don't use `du -k --apparent-size` -# because we do not want to assume `du` supports that option. -# -# Here's an example of different `ls -s` results on different file -# systems: -# -# $ cp /var/tmp/findutils-manual/find.html find.html -# $ ls -lsh /var/tmp/findutils-manual/find.html find.html -# 221K -rw-rw-r-- 1 james james 582K Jul 17 13:01 find.html -# 584K -rw-rw-r-- 1 james james 582K Jul 17 12:54 /var/tmp/findutils-manual/find.html +# Output $1's size like "7.1 MiB" if du is GNU, "7425707 bytes" otherwise. calcsize() { - # Determine size in bytes - set `env LC_ALL=C wc -c < "$1"` - # Emit the size in KiB, rounding up. - expr '(' "$1" + 1023 ')' / 1024 + duout=`LC_ALL=C du -h --apparent-size -- "$1" 2>/dev/null` || + duout=`LC_ALL=C wc -c <"$1"` + set x $duout + printf '%s\n' "$2" | sed 's/[^0-9.].*/ &iB/; s/[0-9]$/& bytes/' } # copy_images OUTDIR HTML-FILE... @@ -364,7 +352,8 @@ html_split() ln -s ${PACKAGE}.html index.html tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html ) - eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"` + size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"` + eval html_$1_tgz_size=\$size rm -f "$outdir"/html_$1/*.html mkdir -p "$outdir/html_$1/" mv ${split_html_dir}/*.html "$outdir/html_$1/" @@ -403,8 +392,8 @@ if test -z "$use_texi2html"; then cd $split_html_dir || exit 1 tar -czf "$abs_outdir/$PACKAGE.html_$split.tar.gz" -- * ) - eval \ - html_${split}_tgz_size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"` + size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"` + eval html_${split}_tgz_size=\$size rm -rf "$outdir/html_$split/" mv $split_html_dir "$outdir/html_$split/" du -s "$outdir/html_$split/" @@ -573,5 +562,6 @@ echo "Done, see $outdir/ subdirectory for new files." # eval: (add-hook 'before-save-hook 'time-stamp nil t) # time-stamp-start: "scriptversion=" # time-stamp-format: "%Y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "$" # End: diff --git a/doc/gendocs_template b/doc/gendocs_template index 327d5f039f..7c35e9b71d 100644 --- a/doc/gendocs_template +++ b/doc/gendocs_template @@ -21,7 +21,7 @@ without any warranty. <ul> <li><a href="%%PACKAGE%%.html">HTML - (%%HTML_MONO_SIZE%%K bytes)</a> - entirely on one web page.</li> + (%%HTML_MONO_SIZE%%)</a> - entirely on one web page.</li> %%IF HTML_NODE%% <li><a href="html_node/index.html">HTML</a> - with one web page per node.</li> @@ -34,36 +34,36 @@ without any warranty. <li><a href="html_chapter/index.html">HTML</a> - with one web page per chapter.</li> %%ENDIF HTML_CHAPTER%% -<li><a href="%%PACKAGE%%.html.gz">HTML compressed - (%%HTML_MONO_GZ_SIZE%%K gzipped characters)</a> - entirely on +<li><a href="%%PACKAGE%%.html.gz">HTML gzipped + (%%HTML_MONO_GZ_SIZE%%)</a> - entirely on one web page.</li> %%IF HTML_NODE%% -<li><a href="%%PACKAGE%%.html_node.tar.gz">HTML compressed - (%%HTML_NODE_TGZ_SIZE%%K gzipped tar file)</a> - +<li><a href="%%PACKAGE%%.html_node.tar.gz">HTML tar file gzipped + (%%HTML_NODE_TGZ_SIZE%%)</a> - with one web page per node.</li> %%ENDIF HTML_NODE%% %%IF HTML_SECTION%% -<li><a href="%%PACKAGE%%.html_section.tar.gz">HTML compressed - (%%HTML_SECTION_TGZ_SIZE%%K gzipped tar file)</a> - +<li><a href="%%PACKAGE%%.html_section.tar.gz">HTML tar file gzipped + (%%HTML_SECTION_TGZ_SIZE%%)</a> - with one web page per section.</li> %%ENDIF HTML_SECTION%% %%IF HTML_CHAPTER%% -<li><a href="%%PACKAGE%%.html_chapter.tar.gz">HTML compressed - (%%HTML_CHAPTER_TGZ_SIZE%%K gzipped tar file)</a> - +<li><a href="%%PACKAGE%%.html_chapter.tar.gz">HTML tar file gzipped + (%%HTML_CHAPTER_TGZ_SIZE%%)</a> - with one web page per chapter.</li> %%ENDIF HTML_CHAPTER%% -<li><a href="%%PACKAGE%%.info.tar.gz">Info document - (%%INFO_TGZ_SIZE%%K bytes gzipped tar file)</a>.</li> +<li><a href="%%PACKAGE%%.info.tar.gz">Info document tar file gzipped + (%%INFO_TGZ_SIZE%%)</a>.</li> <li><a href="%%PACKAGE%%.txt">ASCII text - (%%ASCII_SIZE%%K bytes)</a>.</li> -<li><a href="%%PACKAGE%%.txt.gz">ASCII text compressed - (%%ASCII_GZ_SIZE%%K bytes gzipped)</a>.</li> -<li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file - (%%DVI_GZ_SIZE%%K bytes gzipped)</a>.</li> + (%%ASCII_SIZE%%)</a>.</li> +<li><a href="%%PACKAGE%%.txt.gz">ASCII text gzipped + (%%ASCII_GZ_SIZE%%)</a>.</li> +<li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file gzipped + (%%DVI_GZ_SIZE%%)</a>.</li> <li><a href="%%PACKAGE%%.pdf">PDF file - (%%PDF_SIZE%%K bytes)</a>.</li> -<li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source - (%%TEXI_TGZ_SIZE%%K bytes gzipped tar file).</a></li> + (%%PDF_SIZE%%)</a>.</li> +<li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source tar file gzipped + (%%TEXI_TGZ_SIZE%%).</a></li> </ul> <p>You can <a href="https://shop.fsf.org/">buy printed copies of diff --git a/doc/gendocs_template_min b/doc/gendocs_template_min index db46f89a8c..11a304a212 100644 --- a/doc/gendocs_template_min +++ b/doc/gendocs_template_min @@ -36,7 +36,7 @@ without any warranty. <ul> <li><a href="%%PACKAGE%%.html">HTML - (%%HTML_MONO_SIZE%%K bytes)</a> - entirely on one web page.</li> + (%%HTML_MONO_SIZE%%)</a> - entirely on one web page.</li> <li><a href="html_node/index.html">HTML</a> - with one web page per node.</li> %%IF HTML_SECTION%% @@ -47,34 +47,34 @@ without any warranty. <li><a href="html_chapter/index.html">HTML</a> - with one web page per chapter.</li> %%ENDIF HTML_CHAPTER%% -<li><a href="%%PACKAGE%%.html.gz">HTML compressed - (%%HTML_MONO_GZ_SIZE%%K gzipped characters)</a> - entirely on +<li><a href="%%PACKAGE%%.html.gz">HTML gzipped + (%%HTML_MONO_GZ_SIZE%%)</a> - entirely on one web page.</li> -<li><a href="%%PACKAGE%%.html_node.tar.gz">HTML compressed - (%%HTML_NODE_TGZ_SIZE%%K gzipped tar file)</a> - +<li><a href="%%PACKAGE%%.html_node.tar.gz">HTML tar file gzipped + (%%HTML_NODE_TGZ_SIZE%%)</a> - with one web page per node.</li> %%IF HTML_SECTION%% -<li><a href="%%PACKAGE%%.html_section.tar.gz">HTML compressed - (%%HTML_SECTION_TGZ_SIZE%%K gzipped tar file)</a> - +<li><a href="%%PACKAGE%%.html_section.tar.gz">HTML tar file gzipped + (%%HTML_SECTION_TGZ_SIZE%%)</a> - with one web page per section.</li> %%ENDIF HTML_SECTION%% %%IF HTML_CHAPTER%% -<li><a href="%%PACKAGE%%.html_chapter.tar.gz">HTML compressed - (%%HTML_CHAPTER_TGZ_SIZE%%K gzipped tar file)</a> - +<li><a href="%%PACKAGE%%.html_chapter.tar.gz">HTML tar file gzipped + (%%HTML_CHAPTER_TGZ_SIZE%%)</a> - with one web page per chapter.</li> %%ENDIF HTML_CHAPTER%% -<li><a href="%%PACKAGE%%.info.tar.gz">Info document - (%%INFO_TGZ_SIZE%%K bytes gzipped tar file)</a>.</li> +<li><a href="%%PACKAGE%%.info.tar.gz">Info document tar file gzipped + (%%INFO_TGZ_SIZE%%)</a>.</li> <li><a href="%%PACKAGE%%.txt">ASCII text - (%%ASCII_SIZE%%K bytes)</a>.</li> -<li><a href="%%PACKAGE%%.txt.gz">ASCII text compressed - (%%ASCII_GZ_SIZE%%K bytes gzipped)</a>.</li> -<li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file - (%%DVI_GZ_SIZE%%K bytes gzipped)</a>.</li> + (%%ASCII_SIZE%%)</a>.</li> +<li><a href="%%PACKAGE%%.txt.gz">ASCII text gzipped + (%%ASCII_GZ_SIZE%%)</a>.</li> +<li><a href="%%PACKAGE%%.dvi.gz">TeX dvi file gzipped + (%%DVI_GZ_SIZE%%)</a>.</li> <li><a href="%%PACKAGE%%.pdf">PDF file - (%%PDF_SIZE%%K bytes)</a>.</li> -<li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source - (%%TEXI_TGZ_SIZE%%K bytes gzipped tar file).</a></li> + (%%PDF_SIZE%%)</a>.</li> +<li><a href="%%PACKAGE%%.texi.tar.gz">Texinfo source tar file gzipped + (%%TEXI_TGZ_SIZE%%).</a></li> </ul> <p>(This page generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%% -- 2.53.0