Permalink
Browse files

Merge branch 'master' of github.com:liquibase/liquibase

  • Loading branch information...
nvoxland committed Jun 30, 2012
2 parents c009334 + 8731bc5 commit b292b6f6b495e9848b11c04a989799c6950deee7
@@ -415,7 +415,7 @@ protected void printHelp(PrintStream stream) {
stream.println(" updateSQL Writes SQL to update database to current");
stream.println(" version to STDOUT");
stream.println(" updateCount <num> Applies next NUM changes to the database");
- stream.println(" updateSQL <num> Writes SQL to apply next NUM changes");
+ stream.println(" updateCountSQL <num> Writes SQL to apply next NUM changes");
stream.println(" to the database");
stream.println(" rollback <tag> Rolls back the database to the the state is was");
stream.println(" when the tag was applied");
@@ -10,6 +10,9 @@
* Various utility methods for working with strings.
*/
public class StringUtils {
+ private static final Pattern commentPattern = Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL);
+ private static final Pattern dashPattern = Pattern.compile("\\-\\-.*$", Pattern.MULTILINE);
+
public static String trimToEmpty(String string) {
if (string == null) {
return "";
@@ -78,9 +81,8 @@ public static String trimToNull(String string) {
* @return The String without the comments in
*/
public static String stripComments(String multiLineSQL) {
- String strippedSingleLines = Pattern.compile("(.*?)\\s*\\-\\-.*\n").matcher(multiLineSQL).replaceAll("$1\n");
- strippedSingleLines = Pattern.compile("(.*?)\\s*\\-\\-.*$").matcher(strippedSingleLines).replaceAll("$1\n");
- return Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL).matcher(strippedSingleLines).replaceAll("").trim();
+ String strippedDashDash = dashPattern.matcher(multiLineSQL).replaceAll("");
+ return commentPattern.matcher(strippedDashDash).replaceAll("").trim();
}
public static String join(String[] array, String delimiter) {

0 comments on commit b292b6f

Please sign in to comment.