# HG changeset patch
# User František Kučera <franta-hg@frantovo.cz>
# Date 1410026822 -7200
# Node ID 1a09966c072cb8290937b80f9ed0b7266046ec6f
# Parent  06e8667694784106ccdb12e9974b60ccc054323d
in-ini: regex clean-up

diff -r 06e866769478 -r 1a09966c072c java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java
--- a/java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java	Sat Sep 06 19:56:08 2014 +0200
+++ b/java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java	Sat Sep 06 20:07:02 2014 +0200
@@ -128,24 +128,19 @@
 
 				},
 		ENTRY(
-				"\\s*(?<key>[^=\\s]+)\\s*=\\s*\"(?<value>[^\"]+)\"", // quoted value → include spaces
-				"\\s*(?<key>[^=\\s]+)\\s*=\\s*\"(?<value>[^\"]+)\"\\s*(;|#)*\\s*(?<comment>.*)", // quoted value → include spaces | with comment
-				"\\s*(?<key>[^=\\s]+)\\s*=\\s*'(?<value>[^']+)'", // apostrophed value → include spaces
-				"\\s*(?<key>[^=\\s]+)\\s*=\\s*'(?<value>[^']+)'\\s*((;|#)\\s*(?<comment>.*)){0,1}", // apostrophed value → include spaces | with comment
-				"\\s*(?<key>[^=\\s]+)\\s*=\\s*(?<value>.+)" // unquoted value → strip spaces
+				"\\s*(?<key>[^=\\s]+)\\s*=\\s*\"(?<value>[^']+)\"\\s*((;|#)\\s*(?<comment>.*)){0,1}", // quoted value → include spaces + might have comment
+				"\\s*(?<key>[^=\\s]+)\\s*=\\s*'(?<value>[^']+)'\\s*((;|#)\\s*(?<comment>.*)){0,1}", // apostrophed value → include spaces + might have comment
+				"\\s*(?<key>[^=\\s]+)\\s*=\\s*(?<value>.+)" // unquoted value → strip spaces + no comments
 		) {
 					@Override
 					public void processLine(LineContext lc, FileContext fc) throws SAXException {
 						String key = lc.matcher.group("key");
 						String value = lc.matcher.group("value");
 
-						try {
+						if (lc.matcher.groupCount() > 2) {
 							String comment = lc.matcher.group("comment");
 							// TODO: comment → LexicalHandler
-							log.log(Level.WARNING, "Comment for entry „{0}“ is: {1}", new Object[]{key, comment});
-
-						} catch (IllegalArgumentException e) {
-							log.log(Level.WARNING, "Entry „{0}“ has no comment", key);
+							log.log(Level.FINER, "Comment for entry „{0}“ is: {1}", new Object[]{key, comment});
 
 						}