felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccust...@apache.org
Subject svn commit: r904967 - /felix/trunk/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java
Date Sun, 31 Jan 2010 03:42:04 GMT
Author: ccustine
Date: Sun Jan 31 03:42:04 2010
New Revision: 904967

URL: http://svn.apache.org/viewvc?rev=904967&view=rev
Log:
FELIX-2025 - grep -v doesn't filter linefeed on Windows

Modified:
    felix/trunk/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java

Modified: felix/trunk/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java?rev=904967&r1=904966&r2=904967&view=diff
==============================================================================
--- felix/trunk/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java
(original)
+++ felix/trunk/karaf/shell/commands/src/main/java/org/apache/felix/karaf/shell/commands/GrepAction.java
Sun Jan 31 03:42:04 2010
@@ -18,12 +18,11 @@
  */
 package org.apache.felix.karaf.shell.commands;
 
+import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.Reader;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Queue;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -115,8 +114,11 @@
             int lineno = 1;
             String line;
             int lineMatch = 0;
-            Reader r = new InputStreamReader(System.in);
-            while ((line = readLine(r)) != null) {
+            BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
+            while ((line = r.readLine()) != null) {
+                if (line.length() == 1 && line.charAt(0) == '\n') {
+                    break;
+                }
                 if (p.matcher(line).matches() ^ invertMatch) {
 
                     Matcher matcher2 = p2.matcher(line);
@@ -182,18 +184,4 @@
         return null;
     }
 
-    private String readLine(Reader in) throws IOException {
-        StringBuffer buf = new StringBuffer();
-        while (true) {
-            int i = in.read();
-            if (i == -1 && buf.length() == 0) {
-                return null;
-            }
-            if (i == -1 || i == '\n' || i == '\r') {
-                return buf.toString();
-            }
-            buf.append((char) i);
-        }
-    }
-
 }



Mime
View raw message