This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: add -@ argument to jar


I'm checking this in to Classpath and libgcj.

This adds support for the '-@' argument to jar.  This came from
fastjar and I intended to add it (there's a field in jar's Main for
it); and I want to use it in the libgcj build.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* resource/gnu/classpath/tools/jar/messages.properties
	(Main.Stdin): New message.
	* tools/gnu/classpath/tools/jar/Main.java (initializeParser): Add
	'-@' option.
	(readNames): New method.
	(run): Use it.

Index: resource/gnu/classpath/tools/jar/messages.properties
===================================================================
--- resource/gnu/classpath/tools/jar/messages.properties	(revision 121362)
+++ resource/gnu/classpath/tools/jar/messages.properties	(working copy)
@@ -69,3 +69,4 @@
 Main.ChangeDir=change to directory before the next file
 Main.ChangeDirArg=DIR FILE
 Main.InternalError=jar: internal error:
+Main.Stdin=Read file names from stdin
Index: tools/gnu/classpath/tools/jar/Main.java
===================================================================
--- tools/gnu/classpath/tools/jar/Main.java	(revision 121362)
+++ tools/gnu/classpath/tools/jar/Main.java	(working copy)
@@ -1,5 +1,5 @@
 /* Main.java - jar program main()
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
 
  This file is part of GNU Classpath.
 
@@ -45,7 +45,9 @@
 import gnu.classpath.tools.getopt.OptionGroup;
 import gnu.classpath.tools.getopt.Parser;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.InputStreamReader;
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -232,11 +234,34 @@
         changedDirectory = argument;
       }
     });
+    grp.add(new Option('@', Messages.getString("Main.Stdin"))
+    {
+      public void parsed(String argument) throws OptionException
+      {
+	readNamesFromStdin = true;
+      }
+    });
     p.add(grp);
 
     return p;
   }
 
+  private void readNames()
+  {
+    String line;
+    try
+      {
+	BufferedReader br
+	  = new BufferedReader(new InputStreamReader(System.in));
+	while ((line = br.readLine()) != null)
+	  entries.add(new Entry(new File(line)));
+      }
+    catch (IOException _)
+      {
+	// Ignore.
+      }
+  }
+
   private void run(String[] args)
       throws InstantiationException, IllegalAccessException, IOException
   {
@@ -245,6 +270,8 @@
     if (args.length > 0 && args[0].charAt(0) != '-')
       args[0] = '-' + args[0];
     p.parse(args, new HandleFile());
+    if (readNamesFromStdin)
+      readNames();
     Action t = (Action) operationMode.newInstance();
     t.run(this);
   }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]