Sync bndlib code

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1381708 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/libg/command/Command.java b/bundleplugin/src/main/java/aQute/libg/command/Command.java
index 8dd1678..f6114d9 100644
--- a/bundleplugin/src/main/java/aQute/libg/command/Command.java
+++ b/bundleplugin/src/main/java/aQute/libg/command/Command.java
@@ -68,7 +68,7 @@
 
 		if (timeout != 0) {
 			timer = new TimerTask() {
-				@Override
+				//@Override TODO why did this not work? TimerTask implements Runnable
 				public void run() {
 					timedout = true;
 					process.destroy();
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
index 2785c3d..2722ab1 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
@@ -48,4 +48,13 @@
 	public abstract T digest(byte[] bytes) throws Exception;
 
 	public abstract String getAlgorithm();
+
+	public T from(File f) throws Exception {
+		IO.copy(f, this);
+		return digest();
+	}
+	public T from(byte[] f) throws Exception {
+		IO.copy(f, this);
+		return digest();
+	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java b/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java
index a1a5a0a..c6def1b 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java
@@ -36,6 +36,13 @@
 	}
 
 	public static MD5 digest(byte [] data) throws Exception {
-		return getDigester().digest(data);
+		return getDigester().from(data);
+	}
+
+	public static MD5 digest(File f) throws NoSuchAlgorithmException, Exception {
+		return getDigester().from(f);
+	}
+	public static MD5 digest(InputStream f) throws NoSuchAlgorithmException, Exception {
+		return getDigester().from(f);
 	}
 }
\ No newline at end of file
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java
index c76f182..c2f1e8d 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java
@@ -36,6 +36,13 @@
 	}
 
 	public static SHA1 digest(byte [] data) throws Exception {
-		return getDigester().digest(data);
+		return getDigester().from(data);
+	}
+
+	public static SHA1 digest(File f) throws NoSuchAlgorithmException, Exception {
+		return getDigester().from(f);
+	}
+	public static SHA1 digest(InputStream f) throws NoSuchAlgorithmException, Exception {
+		return getDigester().from(f);
 	}
 }
\ No newline at end of file
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java
index 743a431..42baf4e 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java
@@ -35,7 +35,15 @@
 		return ALGORITHM;
 	}
 
+
 	public static SHA256 digest(byte [] data) throws Exception {
-		return getDigester().digest(data);
+		return getDigester().from(data);
+	}
+
+	public static SHA256 digest(File f) throws NoSuchAlgorithmException, Exception {
+		return getDigester().from(f);
+	}
+	public static SHA256 digest(InputStream f) throws NoSuchAlgorithmException, Exception {
+		return getDigester().from(f);
 	}
 }
\ No newline at end of file
diff --git a/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java b/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java
index c8dcb41..30e744b 100755
--- a/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java
+++ b/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java
@@ -82,7 +82,7 @@
 			c = string.charAt(index++);
 			if (c == quote)
 				break;
-			if (c == '\\' && index < string.length() && string.charAt(index + 1) == quote)
+			if (c == '\\' && index < string.length() && string.charAt(index) == quote)
 				c = string.charAt(index++);
 			sb.append(c);
 		}
diff --git a/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java b/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
index d233631..8c3f68b 100644
--- a/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
+++ b/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
@@ -246,20 +246,9 @@
 		return getInfo(other,null);
 	}
 	public boolean getInfo(Report other, String prefix) {
-		boolean ok = true;
-		if ( prefix == null)
-			prefix = "";
-		else
-			prefix = prefix + ": ";
-		for ( String error : other.getErrors()) {
-			errors.add( prefix + error);
-			ok = false;
-		}
-		
-		for ( String warning : other.getWarnings()) {
-			warnings.add( prefix + warning);
-		}
-		return ok;
+		addErrors(prefix, other.getErrors());
+		addWarnings(prefix, other.getWarnings());
+		return other.isOk();
 	}
 
 	public Location getLocation(String msg) {
@@ -285,4 +274,31 @@
 	public <T> T getMessages(Class<T> c) {
 		return ReporterMessages.base(this, c);
 	}
+	
+	/**
+	 * Add a number of errors
+	 */
+	
+	public void addErrors( String prefix, Collection<String> errors) {
+		if ( prefix == null)
+			prefix = "";
+		else
+			prefix = prefix + ": ";
+		for ( String s: errors) {
+			this.errors.add( prefix + s);
+		}
+	}
+	/**
+	 * Add a number of warnings
+	 */
+	
+	public void addWarnings( String prefix, Collection<String> warnings) {
+		if ( prefix == null)
+			prefix = "";
+		else
+			prefix = prefix + ": ";
+		for ( String s: warnings) {
+			this.warnings.add( prefix  + s);
+		}
+	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/sed/ReplacerAdapter.java b/bundleplugin/src/main/java/aQute/libg/sed/ReplacerAdapter.java
index 84a0620..1bd8e07 100644
--- a/bundleplugin/src/main/java/aQute/libg/sed/ReplacerAdapter.java
+++ b/bundleplugin/src/main/java/aQute/libg/sed/ReplacerAdapter.java
@@ -268,7 +268,7 @@
 			}
 			catch (InvocationTargetException e) {
 				if (e.getCause() instanceof IllegalArgumentException) {
-					reporter.error("%s, for cmd: %s, arguments; %s", e.getMessage(), method, Arrays.toString(args));
+					reporter.error("%s, for cmd: %s, arguments; %s", e.getCause().getMessage(), method, Arrays.toString(args));
 				} else {
 					reporter.warning("Exception in replace: " + e.getCause());
 					e.getCause().printStackTrace();