Lines 264-269
Link Here
|
264 |
private void parse() { |
264 |
private void parse() { |
265 |
checkDelimiterStatement(); |
265 |
checkDelimiterStatement(); |
266 |
int startQuote = -1; |
266 |
int startQuote = -1; |
|
|
267 |
int commentStart = 0; |
267 |
while (pos < sqlLength) { |
268 |
while (pos < sqlLength) { |
268 |
char ch = sql.charAt(pos); |
269 |
char ch = sql.charAt(pos); |
269 |
|
270 |
|
Lines 303-308
Link Here
|
303 |
|
304 |
|
304 |
case STATE_MAYBE_LINE_COMMENT: |
305 |
case STATE_MAYBE_LINE_COMMENT: |
305 |
if (ch == '-') { |
306 |
if (ch == '-') { |
|
|
307 |
commentStart = pos + 1; |
306 |
state = STATE_LINE_COMMENT; |
308 |
state = STATE_LINE_COMMENT; |
307 |
} else { |
309 |
} else { |
308 |
state = STATE_MEANINGFUL_TEXT; |
310 |
state = STATE_MEANINGFUL_TEXT; |
Lines 313-324
Link Here
|
313 |
|
315 |
|
314 |
case STATE_LINE_COMMENT: |
316 |
case STATE_LINE_COMMENT: |
315 |
if (ch == '\n') { |
317 |
if (ch == '\n') { |
|
|
318 |
checkForDelimiterStmt(commentStart, pos - 1); |
316 |
state = STATE_MEANINGFUL_TEXT; |
319 |
state = STATE_MEANINGFUL_TEXT; |
317 |
} |
320 |
} |
318 |
break; |
321 |
break; |
319 |
|
322 |
|
320 |
case STATE_MAYBE_BLOCK_COMMENT: |
323 |
case STATE_MAYBE_BLOCK_COMMENT: |
321 |
if (ch == '*') { |
324 |
if (ch == '*') { |
|
|
325 |
commentStart = pos + 1; |
322 |
state = STATE_BLOCK_COMMENT; |
326 |
state = STATE_BLOCK_COMMENT; |
323 |
} else { |
327 |
} else { |
324 |
statement.append('/'); // previous char |
328 |
statement.append('/'); // previous char |
Lines 337-342
Link Here
|
337 |
|
341 |
|
338 |
case STATE_MAYBE_END_BLOCK_COMMENT: |
342 |
case STATE_MAYBE_END_BLOCK_COMMENT: |
339 |
if (ch == '/') { |
343 |
if (ch == '/') { |
|
|
344 |
checkForDelimiterStmt(commentStart, pos - 2); |
340 |
state = STATE_MEANINGFUL_TEXT; |
345 |
state = STATE_MEANINGFUL_TEXT; |
341 |
// avoid writing the final / to the result |
346 |
// avoid writing the final / to the result |
342 |
pos++; |
347 |
pos++; |
Lines 438-444
Link Here
|
438 |
private static boolean isEndStringQuoteChar(int start, int end) { |
443 |
private static boolean isEndStringQuoteChar(int start, int end) { |
439 |
return isStartStringQuoteChar(start) && end == getMatchingQuote(start); |
444 |
return isStartStringQuoteChar(start) && end == getMatchingQuote(start); |
440 |
} |
445 |
} |
441 |
|
446 |
|
442 |
/** |
447 |
/** |
443 |
* See if the user wants to use a different delimiter for splitting |
448 |
* See if the user wants to use a different delimiter for splitting |
444 |
* up statements. This is useful if, for example, their SQL contains |
449 |
* up statements. This is useful if, for example, their SQL contains |
Lines 486-491
Link Here
|
486 |
return true; |
491 |
return true; |
487 |
} |
492 |
} |
488 |
|
493 |
|
|
|
494 |
/** |
495 |
* Check for Delimiter Statement in comment. |
496 |
* |
497 |
* Simulates regular behaviour found in checkDelimiterStatement |
498 |
*/ |
499 |
private void checkForDelimiterStmt(int start, int end) { |
500 |
while(Character.isWhitespace(sql.charAt(start)) && start < end) { |
501 |
start++; |
502 |
} |
503 |
if(start >= end && (end - start + 1) <= DELIMITER_TOKEN.length()) { |
504 |
return; |
505 |
} |
506 |
boolean delimiterMatched = true; |
507 |
for(int i = 0; i < DELIMITER_TOKEN.length(); i++) { |
508 |
if(Character.toUpperCase(sql.charAt(start)) != |
509 |
Character.toUpperCase(DELIMITER_TOKEN.charAt(i))) { |
510 |
delimiterMatched = false; |
511 |
break; |
512 |
} |
513 |
start++; |
514 |
} |
515 |
if(! delimiterMatched) { |
516 |
return; |
517 |
} |
518 |
while (Character.isWhitespace(sql.charAt(start)) && start < end) { |
519 |
start++; |
520 |
} |
521 |
StringBuilder sb = new StringBuilder(); |
522 |
for(int i = start; i <= end; i++) { |
523 |
if(! Character.isWhitespace(sql.charAt(i))) { |
524 |
sb.append(sql.charAt(i)); |
525 |
} else { |
526 |
break; |
527 |
} |
528 |
} |
529 |
if(sb.length() > 0) { |
530 |
delimiter = sb.toString(); |
531 |
} |
532 |
} |
533 |
|
489 |
private void skipWhitespace() { |
534 |
private void skipWhitespace() { |
490 |
while ( pos < sqlLength && Character.isWhitespace(sql.charAt(pos)) ) { |
535 |
while ( pos < sqlLength && Character.isWhitespace(sql.charAt(pos)) ) { |
491 |
nextColumn(); |
536 |
nextColumn(); |