Changeset 31956 in webkit
- Timestamp:
- Apr 16, 2008 12:34:29 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r31955 r31956 1 2008-04-15 Adam Roben <aroben@apple.com> 2 3 Make String.format return an array of unused substitutions 4 5 String.format now returns an object with two properties: 6 formattedResult and unusedSubstitutions. 7 8 Reviewed by Tim Hatcher. 9 10 * page/inspector/utilities.js: 11 (String.vsprintf): Updated for changes to String.format. We throw away 12 the array of unused substitutions. 13 (String.format): Changed to keep track of which substitutions are used 14 when formatting. We then return both the formatted result and the 15 array of unused substitutions. 16 1 17 2008-04-15 Adam Roben <aroben@apple.com> 2 18 -
trunk/WebCore/page/inspector/utilities.js
r31955 r31956 838 838 String.vsprintf = function(format, substitutions) 839 839 { 840 return String.format(format, substitutions, String.standardFormatters, "", function(a, b) { return a + b; }) ;840 return String.format(format, substitutions, String.standardFormatters, "", function(a, b) { return a + b; }).formattedResult; 841 841 } 842 842 … … 844 844 { 845 845 if (!format || !substitutions || !substitutions.length) 846 return append(initialValue, format);846 return { formattedResult: append(initialValue, format), unusedSubstitutions: substitutions }; 847 847 848 848 function prettyFunctionName() … … 863 863 var result = initialValue; 864 864 var tokens = String.tokenizeFormatString(format); 865 var usedSubstitutionIndexes = {}; 865 866 866 867 for (var i = 0; i < tokens.length; ++i) { … … 885 886 } 886 887 888 usedSubstitutionIndexes[token.substitutionIndex] = true; 889 887 890 if (!(token.specifier in formatters)) { 888 891 // Encountered an unsupported format character, treat as a string. … … 895 898 } 896 899 897 return result; 898 } 900 var unusedSubstitutions = []; 901 for (var i = 0; i < substitutions.length; ++i) { 902 if (i in usedSubstitutionIndexes) 903 continue; 904 unusedSubstitutions.push(substitutions[i]); 905 } 906 907 return { formattedResult: result, unusedSubstitutions: unusedSubstitutions }; 908 }
Note: See TracChangeset
for help on using the changeset viewer.