harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhouke...@apache.org
Subject svn commit: r790833 - in /harmony/enhanced: classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
Date Fri, 03 Jul 2009 09:21:31 GMT
Author: zhoukevin
Date: Fri Jul  3 09:21:19 2009
New Revision: 790833

URL: http://svn.apache.org/viewvc?rev=790833&view=rev
Log:
Fix the wrong length of "--effort=" and "--modification-time=" in jretools/pack200/Main.java
file.

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
    harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java?rev=790833&r1=790832&r2=790833&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/pack200/PackingOptions.java
Fri Jul  3 09:21:19 2009
@@ -39,7 +39,7 @@
     private boolean gzip = true;
     private boolean stripDebug = false;
     private boolean keepFileOrder = true;
-    private long segmentLimit = 1000000;
+    private long segmentLimit = 1000000L;
     private int effort = 5;
     private String deflateHint = KEEP;
     private String modificationTime = KEEP;
@@ -132,6 +132,13 @@
     }
 
     public void setModificationTime(String modificationTime) {
+        if (!KEEP.equals(modificationTime)
+                && !"latest".equals(modificationTime)) {
+            throw new IllegalArgumentException(
+                    "Bad argument: -m "
+                            + modificationTime
+                            + " ? transmit modtimes should be either latest or keep (default)");
+        }
         this.modificationTime = modificationTime;
     }
 

Modified: harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java?rev=790833&r1=790832&r2=790833&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jretools/src/main/java/org/apache/harmony/jretools/pack200/Main.java
Fri Jul  3 09:21:19 2009
@@ -39,6 +39,7 @@
         String inputFileName = null;
         String outputFileName = null;
         PackingOptions options = new PackingOptions();
+        String value = null;
 
         for (int i = 0; i < args.length; i++) {
             if ("--help".equals(args[i]) || "-help".equals(args[i])
@@ -60,33 +61,101 @@
             } else if ("--keep-file-order".equals(args[i])) {
                 options.setKeepFileOrder(true);
             } else if (args[i].startsWith("-S")) {
-                options.setSegmentLimit(Integer.parseInt(args[i].substring(2)));
+                value = args[i].substring(2);
+                if(value.length() == 0) {
+                    if(i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -S ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                options.setSegmentLimit(Long.parseLong(value));
             } else if (args[i].startsWith("--segment-limit=")) {
-                options
-                        .setSegmentLimit(Integer
-                                .parseInt(args[i].substring(16)));
+                options.setSegmentLimit(Long.parseLong(args[i].substring(16)));
             } else if (args[i].startsWith("-E")) {
-                options.setEffort(Integer.parseInt(args[i].substring(2)));
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -E ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                options.setEffort(Integer.parseInt(value));
             } else if (args[i].startsWith("--effort=")) {
-                options.setEffort(Integer.parseInt(args[i].substring(10)));
+                options.setEffort(Integer.parseInt(args[i].substring(9)));
             } else if (args[i].startsWith("-H")) {
-                options.setDeflateHint(args[i].substring(2));
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -H ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                options.setDeflateHint(value);
             } else if (args[i].startsWith("--deflate-hint=")) {
                 options.setDeflateHint(args[i].substring(15));
             } else if (args[i].startsWith("-m")) {
-                options.setModificationTime(args[i].substring(2));
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -m ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                options.setModificationTime(value);
             } else if (args[i].startsWith("--modification-time=")) {
-                options.setModificationTime(args[i].substring(19));
+                options.setModificationTime(args[i].substring(20));
             } else if (args[i].startsWith("-P")) {
-                options.addPassFile(args[i].substring(2));
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -P ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                options.addPassFile(value);
             } else if (args[i].startsWith("--pass-file=")) {
                 options.addPassFile(args[i].substring(12));
             } else if (args[i].startsWith("-U")) {
-                options.setUnknownAttributeAction(args[i].substring(2));
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -U ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                options.setUnknownAttributeAction(value);
             } else if (args[i].startsWith("--unknown-attribute=")) {
                 options.setUnknownAttributeAction(args[i].substring(20));
             } else if (args[i].startsWith("-C")) {
-                String[] nameEqualsAction = args[i].substring(2).split("=");
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -C ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                String[] nameEqualsAction = value.split("=");
                 options.addClassAttributeAction(nameEqualsAction[0],
                         nameEqualsAction[1]);
             } else if (args[i].startsWith("--class-attribute=")) {
@@ -94,7 +163,17 @@
                 options.addClassAttributeAction(nameEqualsAction[0],
                         nameEqualsAction[1]);
             } else if (args[i].startsWith("-F")) {
-                String[] nameEqualsAction = args[i].substring(2).split("=");
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -F ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                String[] nameEqualsAction = value.split("=");
                 options.addFieldAttributeAction(nameEqualsAction[0],
                         nameEqualsAction[1]);
             } else if (args[i].startsWith("--field-attribute=")) {
@@ -102,7 +181,17 @@
                 options.addFieldAttributeAction(nameEqualsAction[0],
                         nameEqualsAction[1]);
             } else if (args[i].startsWith("-M")) {
-                String[] nameEqualsAction = args[i].substring(2).split("=");
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -M ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                String[] nameEqualsAction = value.split("=");
                 options.addMethodAttributeAction(nameEqualsAction[0],
                         nameEqualsAction[1]);
             } else if (args[i].startsWith("--method-attribute=")) {
@@ -110,7 +199,17 @@
                 options.addMethodAttributeAction(nameEqualsAction[0],
                         nameEqualsAction[1]);
             } else if (args[i].startsWith("-D")) {
-                String[] nameEqualsAction = args[i].substring(2).split("=");
+                value = args[i].substring(2);
+                if (value.length() == 0) {
+                    if (i + 1 < args.length) {
+                        value = args[++i];
+                    } else {
+                        printErrorMessage("Bad argument: -D ?");
+                        printUsage();
+                        return;
+                    }
+                }
+                String[] nameEqualsAction = value.split("=");
                 options.addCodeAttributeAction(nameEqualsAction[0],
                         nameEqualsAction[1]);
             } else if (args[i].startsWith("--code-attribute=")) {
@@ -124,33 +223,33 @@
                 options.setQuiet(true);
                 options.setVerbose(false);
             } else if (args[i].startsWith("-l")) {
-                String logFileName = args[i].substring(2);
-                if (logFileName.length() == 0) {
+                value = args[i].substring(2);
+                if (value.length() == 0) {
                     if (i + 1 < args.length) {
-                        logFileName = args[++i];
+                        value = args[++i];
                     } else {
                         printErrorMessage("Bad argument: -l ?");
                         printUsage();
                         return;
                     }
                 }
-                options.setLogFile(logFileName);
+                options.setLogFile(value);
             } else if (args[i].startsWith("--log-file=")) {
                 options.setLogFile(args[i].substring(11));
             } else if ("-r".equals(args[i]) || "--repack".equals(args[i])) {
                 options.setRepack(true);
             } else if (args[i].startsWith("-f")) {
-                String packPropertyFileName = args[i].substring(2);
-                if (packPropertyFileName.length() == 0) {
+                value = args[i].substring(2);
+                if (value.length() == 0) {
                     if (i + 1 < args.length) {
-                        packPropertyFileName = args[++i];
+                        value = args[++i];
                     } else {
                         printErrorMessage("Bad argument: -f ?");
                         printUsage();
                         return;
                     }
                 }
-                loadPackProperties(packPropertyFileName, options);
+                loadPackProperties(value, options);
             } else if (args[i].startsWith("--config-file=")) {
                 loadPackProperties(args[i].substring(14), options);
             } else {



Mime
View raw message