]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gendocs: output human-readable file sizes
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 17 Jul 2026 17:50:24 +0000 (10:50 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 17 Jul 2026 17:50:44 +0000 (10:50 -0700)
* 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
build-aux/gendocs.sh
doc/gendocs_template
doc/gendocs_template_min

index 0e5b2d74ff5794b38c0c0abf4ea46601a0625cea..d1ea69185f91b5074eabb17af75ed0931382e27f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-07-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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  <P@draigBrady.com>
 
        physmem: fix typo causing configure failure
index 2b3373ecf7da5ccdb1a2c376cd21a6bfdef7abe5..1b03163345fdc97c7fc9a80dad0fc282b60e7f7d 100755 (executable)
@@ -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:
index 327d5f039f19022896f05ddccc89f04d9b65042f..7c35e9b71de3b04ed92076442e6a1a88c837d8c9 100644 (file)
@@ -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
index db46f89a8cf0b206f9bfc96bda406a340d74af55..11a304a2126974760fd9c18deb9a9079ac8271e9 100644 (file)
@@ -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%%