Fix glob list on Windows.

BUG=https://code.google.com/p/dart/issues/detail?id=21071
R=nweiz@google.com

Review URL: https://codereview.chromium.org//607963002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40732 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5747978..409bdec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
-## 1.0.0+1
+## 1.0.2
+
+* Fixed `Glob.list()` on Windows.
+
+## 1.0.1
 
 * Fix several analyzer warnings.
 
diff --git a/lib/glob.dart b/lib/glob.dart
index f80faa1..2d2a83f 100644
--- a/lib/glob.dart
+++ b/lib/glob.dart
@@ -155,14 +155,14 @@
     if (_patternCanMatchAbsolute &&
         (_contextIsAbsolute || context.isAbsolute(path))) {
       var absolutePath = context.normalize(context.absolute(path));
-      if (_ast.matches(_toPosixPath(absolutePath))) {
+      if (_ast.matches(toPosixPath(context, absolutePath))) {
         return new GlobMatch(path, this);
       }
     }
 
     if (_patternCanMatchRelative) {
       var relativePath = context.relative(path);
-      if (_ast.matches(_toPosixPath(relativePath))) {
+      if (_ast.matches(toPosixPath(context, relativePath))) {
         return new GlobMatch(path, this);
       }
     }
@@ -170,13 +170,6 @@
     return null;
   }
 
-  /// Returns [path] converted to the POSIX format that globs match against.
-  String _toPosixPath(String path) {
-    if (context.style == p.Style.windows) return path.replaceAll('\\', '/');
-    if (context.style == p.Style.url) return Uri.decodeFull(path);
-    return path;
-  }
-
   Iterable<Match> allMatches(String path, [int start = 0]) {
     var match = matchAsPrefix(path, start);
     return match == null ? [] : [match];
diff --git a/lib/src/ast.dart b/lib/src/ast.dart
index dbb76e6..1913477 100644
--- a/lib/src/ast.dart
+++ b/lib/src/ast.dart
@@ -334,7 +334,7 @@
   String _toRegExp() =>
       '(?:${options.map((option) => option._toRegExp()).join("|")})';
 
-  bool operator==(Object other) => other is OptionsNode && 
+  bool operator==(Object other) => other is OptionsNode &&
       const UnorderedIterableEquality().equals(options, other.options);
 
   int get hashCode => const UnorderedIterableEquality().hash(options);
diff --git a/lib/src/list_tree.dart b/lib/src/list_tree.dart
index fea2b98..44eaaf3 100644
--- a/lib/src/list_tree.dart
+++ b/lib/src/list_tree.dart
@@ -11,6 +11,7 @@
 
 import 'ast.dart';
 import 'stream_pool.dart';
+import 'utils.dart';
 
 /// A structure built from a glob that efficiently lists filesystem entities
 /// that match that glob.
@@ -371,7 +372,7 @@
   /// Returns whether the native [path] matches [_validator].
   bool _matches(String path) {
     if (_validator == null) return false;
-    return _validator.matches(path);
+    return _validator.matches(toPosixPath(p.context, path));
   }
 
   String toString() => "($_validator) $children";
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 35526c0..f17f2ed 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -68,3 +68,11 @@
   if (p.style != p.Style.windows) return path;
   return path.replaceAll('\\', '/');
 }
+
+/// Returns [path] which follows [context] converted to the POSIX format that
+/// globs match against.
+String toPosixPath(p.Context context, String path) {
+  if (context.style == p.Style.windows) return path.replaceAll('\\', '/');
+  if (context.style == p.Style.url) return Uri.decodeFull(path);
+  return path;
+}
diff --git a/pubspec.yaml b/pubspec.yaml
index 1365f27..8c4deb2 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: glob
-version: 1.0.1
+version: 1.0.2
 author: "Dart Team <misc@dartlang.org>"
 homepage: http://www.dartlang.org
 description: Bash-style filename globbing.
diff --git a/test/list_test.dart b/test/list_test.dart
index 59c5841..ff02343 100644
--- a/test/list_test.dart
+++ b/test/list_test.dart
@@ -265,10 +265,8 @@
       return schedule(() {
         return new Glob(glob, recursive: recursive)
             .list(root: sandbox, followLinks: followLinks)
-            .map((entity) {
-          return separatorToForwardSlash(
-              p.relative(entity.path, from: sandbox));
-        }).toList();
+            .map((entity) => p.relative(entity.path, from: sandbox))
+            .toList();
       }, 'listing $glob');
     });
   });
@@ -278,10 +276,8 @@
       return schedule(() {
         return new Glob(glob, recursive: recursive)
             .listSync(root: sandbox, followLinks: followLinks)
-            .map((entity) {
-          return separatorToForwardSlash(
-              p.relative(entity.path, from: sandbox));
-        }).toList();
+            .map((entity) => p.relative(entity.path, from: sandbox))
+            .toList();
       }, 'listing $glob');
     });
   });