From c894b9658c69a014ed1f57732b066a180218d126 Mon Sep 17 00:00:00 2001 From: "JesusFreke@JesusFreke.com" Date: Tue, 23 Jun 2009 06:21:29 +0000 Subject: [PATCH] - removed the ability to dump to stdout (issues with the CLI recognizing '-' as a value instead of an option) - tweaked the version and usage info git-svn-id: https://smali.googlecode.com/svn/trunk@218 55b6fa8a-2a1e-11de-a435-ffa8d773f76a --- .../src/main/java/org/jf/baksmali/dump.java | 36 ++++++++----------- .../src/main/java/org/jf/baksmali/main.java | 16 ++++----- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/baksmali/src/main/java/org/jf/baksmali/dump.java b/baksmali/src/main/java/org/jf/baksmali/dump.java index b4e77b21..e5158134 100644 --- a/baksmali/src/main/java/org/jf/baksmali/dump.java +++ b/baksmali/src/main/java/org/jf/baksmali/dump.java @@ -38,11 +38,6 @@ public class dump { public static void dump(DexFile dexFile, String dumpFileName, String outputDexFileName, boolean sort) throws IOException { - boolean dumpToStdOut = false; - if (dumpFileName != null && dumpFileName.equals("-")) { - dumpToStdOut = true; - } - if (sort) { //sort all items, to guarantee a unique ordering dexFile.setSortAllItems(true); @@ -65,23 +60,20 @@ public class dump { out.finishAnnotating(); FileWriter writer = null; - if (dumpToStdOut) { - out.writeAnnotationsTo(new OutputStreamWriter(System.out)); - } else { - try { - writer = new FileWriter(dumpFileName); - out.writeAnnotationsTo(writer); - } catch (IOException ex) { - System.err.println("\n\nThere was an error while dumping the dex file to " + dumpFileName); - ex.printStackTrace(); - } finally { - if (writer != null) { - try { - writer.close(); - } catch (IOException ex) { - System.err.println("\n\nThere was an error while closing the dump file " + dumpFileName); - ex.printStackTrace(); - } + + try { + writer = new FileWriter(dumpFileName); + out.writeAnnotationsTo(writer); + } catch (IOException ex) { + System.err.println("\n\nThere was an error while dumping the dex file to " + dumpFileName); + ex.printStackTrace(); + } finally { + if (writer != null) { + try { + writer.close(); + } catch (IOException ex) { + System.err.println("\n\nThere was an error while closing the dump file " + dumpFileName); + ex.printStackTrace(); } } } diff --git a/baksmali/src/main/java/org/jf/baksmali/main.java b/baksmali/src/main/java/org/jf/baksmali/main.java index 3d41a78a..92bb8d5b 100644 --- a/baksmali/src/main/java/org/jf/baksmali/main.java +++ b/baksmali/src/main/java/org/jf/baksmali/main.java @@ -30,9 +30,10 @@ public class main { public static final String VERSION = "0.91"; - private static Options options; + private static final Options options; static { + options = new Options(); buildOptions(); } @@ -161,16 +162,13 @@ public class main { * Prints the version message. */ private static void version() { - System.out.println("baksmali " + VERSION); + System.out.println("baksmali " + VERSION + " (http://smali.googlecode.com)"); System.out.println("Copyright (C) 2009 Ben Gruver"); - System.out.println("License: \"new\" BSD license"); - System.out.println("http://smali.googlecode.com"); + System.out.println("BSD license (http://www.opensource.org/licenses/bsd-license.php)"); System.exit(0); } private static void buildOptions() { - options = new Options(); - Option versionOption = OptionBuilder.withLongOpt("version") .withDescription("prints the version then exits") .create("v"); @@ -182,13 +180,13 @@ public class main { Option dumpOption = OptionBuilder.withLongOpt("dump-to") .withDescription("dumps the given dex file into a single annotated dump file named FILE (.dump by default), along with the normal disassembly.") .hasOptionalArg() - .withArgName("FILE|-") + .withArgName("FILE") .create("d"); Option dumpOnlyOption = OptionBuilder.withLongOpt("dump-only") .withDescription("dumps the given dex file into a single annotated dump file named FILE (.dump by default), and does not generate the disassembly") .hasOptionalArg() - .withArgName("FILE|-") + .withArgName("FILE") .create("D"); Option writeDexOption = OptionBuilder.withLongOpt("write-dex") @@ -204,7 +202,7 @@ public class main { .create("o"); Option sortOption = OptionBuilder.withLongOpt("sort") - .withDescription("when dumping or rewriting, sort the items in the dex file before dumping/writing.") + .withDescription("sort the items in the dex file into a canonical order before dumping/writing") .create("s"); Option fixSignedRegisterOption = OptionBuilder.withLongOpt("fix-signed-registers")