bug-gnulib
[Top][All Lists]
Advanced

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

Re: Friendlier gnulib-tool error messages with multiple incompatible mod


From: Derek Price
Subject: Re: Friendlier gnulib-tool error messages with multiple incompatible modules
Date: Thu, 25 Sep 2008 11:10:31 -0400
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

Ralf Wildenhues wrote:
> a couple of nits, if I may:

The attached patch addresses all of Ralf's nits, fixes a few minor bugs,
and contains a few additional simplifications of the new functions.  Any
objections?

Regards,

Derek
-- 
Derek R. Price
Solutions Architect
Ximbiot, LLC <http://ximbiot.com>
Get CVS and Subversion Support from Ximbiot!

v: +1 248.835.1260
f: +1 248.246.1176
Index: gnulib-tool
===================================================================
RCS file: /srv/git/gnulib.git/HEAD/gnulib-tool,v
retrieving revision 1.307
diff -p -u -N gnulib-tool
--- gnulib-tool revision 1.307
+++ gnulib-tool working copy
@@ -396,11 +396,70 @@
   }
 fi
 
+# Treat the shell variable with name $1 like a space delimited stack and
+# append the rest of address@hidden  Inserts a leading space when appending 
the first
+# element.
+func_push ()
+{
+  var=$1
+  shift
+  for e; do
+    func_append $var " $e"
+  done
+}
+
+# Using $1 as a separator, join the rest of $@, then echo the result.
+#
+# e.g. `join ", " a b c d e f' yields:
+#
+#       a, b, c, d, e, f
+func_join ()
+{
+  sep=$1
+  out=$2
+  shift
+  shift
+  for e; do
+    func_append out "$sep$e"
+  done
+  echo "$out"
+}
+
+# Word wrap $1 at $3 characters, prefixing each line with $2, then echo it.
+#
+# $3 (wrap length) defaults to 80.
+#
+# e.g. `wrap "a b c d e f g h i j k xxxxxxxxxxxxxxxxxx" "gnulib: " 14' yields:
+#
+#      gnulib: a b c 
+#      gnulib: d e f 
+#      gnulib: g h i 
+#      gnulib: j k 
+#      gnulib: 
+#      xxxxxxxxxxxxxxxxxx
+#
+# NOTES
+#   This function won't currently deal correctly with EOL in $1.  Replacing `.'
+#   in the first regular expression with a portable representation of `[^\n]'
+#   should fix this.
+func_wrap ()
+{
+  plen=`echo "$2" | wc -c`
+  len=`expr ${3-80} - $plen`
+
+  # First sed command wraps, second removes the extra EOL we added, third
+  # inserts the first prefix, fourth inserts the remaining prefixes.
+  re='s#\(.\{1,'"$len"'\}\)  *#\1\
+#g'
+  echo "$1 " | sed -e "$re" -e 's#.$##' -e "s#^#$2#" -e "s#\\n#&$2#g"
+}
+
+
 # func_fatal_error message
 # outputs to stderr a fatal error message, and terminates the program.
 func_fatal_error ()
 {
-  echo "gnulib-tool: *** $1" 1>&2
+  func_wrap "$1" "gnulib-tool: *** " 1>&2
   echo "gnulib-tool: *** Stop." 1>&2
   func_exit 1
 }
@@ -2516,6 +2575,7 @@
 
   # If --lgpl, verify that the licenses of modules are compatible.
   if test -n "$lgpl"; then
+    incompatible_modules=
     for module in $main_modules; do
       license=`func_get_license $module`
       case $license in
@@ -2526,13 +2586,13 @@
             yes | 3)
               case $license in
                 LGPL | LGPLv2+) ;;
-                *) func_fatal_error "incompatible license on module $module: 
$license" ;;
+                *) func_push incompatible_modules $module/$license ;;
               esac
               ;;
             2)
               case $license in
                 LGPLv2+) ;;
-                *) func_fatal_error "incompatible license on module $module: 
$license" ;;
+                *) func_push incompatible_modules $module/$license ;;
               esac
               ;;
             *) func_fatal_error "invalid value lgpl=$lgpl" ;;
@@ -2540,6 +2600,10 @@
           ;;
       esac
     done
+    if test -n "$incompatible_modules"; then
+       list=`func_join ", " $incompatible_modules`
+       func_fatal_error "incompatible license on modules: $list"
+    fi
   fi
 
   # Show banner notice of every module.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]