Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: pkg/third_party/html5lib/lib/src/utils.dart

Issue 178843003: [html5lib] triple slash comment style (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove extra check Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /** Misc things that were useful when porting the code from Python. */ 1 /// Misc things that were useful when porting the code from Python.
2 library utils; 2 library utils;
3 3
4 import 'constants.dart'; 4 import 'constants.dart';
5 5
6 typedef bool Predicate(); 6 typedef bool Predicate();
7 7
8 class Pair<F, S> { 8 class Pair<F, S> {
9 final F first; 9 final F first;
10 final S second; 10 final S second;
11 11
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (str.length == size) return str; 64 if (str.length == size) return str;
65 var result = new StringBuffer(); 65 var result = new StringBuffer();
66 size -= str.length; 66 size -= str.length;
67 for (int i = 0; i < size; i++) result.write('0'); 67 for (int i = 0; i < size; i++) result.write('0');
68 result.write(str); 68 result.write(str);
69 return result.toString(); 69 return result.toString();
70 } 70 }
71 71
72 // TODO(jmesserly): this implementation is pretty wrong, but I need something 72 // TODO(jmesserly): this implementation is pretty wrong, but I need something
73 // quick until dartbug.com/1694 is fixed. 73 // quick until dartbug.com/1694 is fixed.
74 /** 74 /// Format a string like Python's % string format operator. Right now this only
75 * Format a string like Python's % string format operator. Right now this only 75 /// supports a [data] dictionary used with %s or %08x. Those were the only
76 * supports a [data] dictionary used with %s or %08x. Those were the only things 76 /// things needed for [errorMessages].
77 * needed for [errorMessages].
78 */
79 String formatStr(String format, Map data) { 77 String formatStr(String format, Map data) {
80 if (data == null) return format; 78 if (data == null) return format;
81 data.forEach((key, value) { 79 data.forEach((key, value) {
82 var result = new StringBuffer(); 80 var result = new StringBuffer();
83 var search = '%($key)'; 81 var search = '%($key)';
84 int last = 0, match; 82 int last = 0, match;
85 while ((match = format.indexOf(search, last)) >= 0) { 83 while ((match = format.indexOf(search, last)) >= 0) {
86 result.write(format.substring(last, match)); 84 result.write(format.substring(last, match));
87 match += search.length; 85 match += search.length;
88 86
(...skipping 25 matching lines...) Expand all
114 112
115 last = match + 1; 113 last = match + 1;
116 } 114 }
117 115
118 result.write(format.substring(last, format.length)); 116 result.write(format.substring(last, format.length));
119 format = result.toString(); 117 format = result.toString();
120 }); 118 });
121 119
122 return format; 120 return format;
123 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698