[Toybox] [PATCH] bloatcheck: use unified diff, no multiple input pipes

Isaac Dunham ibid.ag at gmail.com
Sat Jun 7 10:34:52 PDT 2014


bloatcheck had been breaking with busybox diff, since it defaults
to unified diff format.
Additionally, I was seeing messages along the lines of
"cannot open /dev/fd/63".

This patch fixes both issues.
--
I'm assuming that support for unified diff format will be needed for
toybox diff to work also.

GNU diff 2.8.1 (last GPL2 tarball) didn't work either, FWIW.

This came up because I was checking the size of Ivo's new md5sum patch;
here (gcc 4.2) it adds 1343 bytes; 1629 bytes with gcc 3.4.

HTH,
Isaac Dunham
-------------- next part --------------
diff --git a/scripts/bloatcheck b/scripts/bloatcheck
index a5a28f1..86ef6cd 100755
--- a/scripts/bloatcheck
+++ b/scripts/bloatcheck
@@ -14,8 +14,12 @@ addline()
     STUFF="$(printf "%s\n%s" "$STUFF" "$NEXT")"
 }
 
-diff <(nm --size-sort "$1" | sort -k3,3) \
-     <(nm --size-sort "$2" | sort -k3,3) | grep '^[<>]' | sort -k4,4 | \
+DIFF1=`mktemp base.XXXXXXX`
+DIFF2=`mktemp bloat.XXXXXXX`
+nm --size-sort "$1" | sort -k3,3 >"$DIFF1"
+nm --size-sort "$2" | sort -k3,3 >"$DIFF2"
+diff -U 0 $DIFF1 $DIFF2 | tail -n +3 | \
+	sed -ne 's/^\([+-]\)/\1 /gp' | sort -k4,4 | \
 (
 LASTNAME=
 DELTA=0
@@ -41,7 +45,7 @@ do
   fi
 
   SIZE=$(printf "%d" "0x$b")
-  if [ "$a" == "<" ]
+  if [ "$a" == "-" ]
   then
     OLD=$(($OLD+$SIZE))
     SIZE=$((-1*$SIZE))
@@ -58,3 +62,5 @@ echo "$STUFF" | sort -k4,4nr
 echo "-----------------------------------------------------------------------"
 printf "% 71d total\n" "$TOTAL"
 )
+
+rm $DIFF1 $DIFF2


More information about the Toybox mailing list