Add option to disable inline comments and to specify which inline comment character are allowed: https://github.com/benhoyt/inih/issues/40
diff --git a/ini.c b/ini.c
index 1c2c780..27ca85b 100644
--- a/ini.c
+++ b/ini.c
@@ -41,16 +41,23 @@
     return (char*)s;
 }
 
-/* Return pointer to first char (of chars) or ';' comment in given string, or
-   pointer to null at end of string if neither found. ';' must be prefixed by
-   a whitespace character to register as a comment. */
+/* Return pointer to first char (of chars) or inline comment in given string,
+   or pointer to null at end of string if neither found. Inline comment must
+   be prefixed by a whitespace character to register as a comment. */
 static char* find_chars_or_comment(const char* s, const char* chars)
 {
+#if INI_ALLOW_INLINE_COMMENTS
     int was_space = 0;
-    while (*s && (!chars || !strchr(chars, *s)) && !(was_space && *s == ';')) {
+    while (*s && (!chars || !strchr(chars, *s)) &&
+           !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) {
         was_space = isspace((unsigned char)(*s));
         s++;
     }
+#else
+    while (*s && (!chars || !strchr(chars, *s))) {
+        s++;
+    }
+#endif
     return (char*)s;
 }
 
@@ -104,12 +111,13 @@
         start = lskip(rstrip(start));
 
         if (*start == ';' || *start == '#') {
-            /* Per Python ConfigParser, allow '#' comments at start of line */
+            /* Per Python configparser, allow both ; and # comments at the
+               start of a line */
         }
 #if INI_ALLOW_MULTILINE
         else if (*prev_name && *start && start > line) {
-            /* Non-black line with leading whitespace, treat as continuation
-               of previous name's value (as per Python ConfigParser). */
+            /* Non-blank line with leading whitespace, treat as continuation
+               of previous name's value (as per Python configparser). */
             if (!handler(user, section, prev_name, start) && !error)
                 error = lineno;
         }
@@ -134,9 +142,11 @@
                 *end = '\0';
                 name = rstrip(start);
                 value = lskip(end + 1);
+#if INI_ALLOW_INLINE_COMMENTS
                 end = find_chars_or_comment(value, NULL);
-                if (*end == ';')
+                if (*end)
                     *end = '\0';
+#endif
                 rstrip(value);
 
                 /* Valid name[=:]value pair found, call handler */
diff --git a/ini.h b/ini.h
index d75196f..6348f62 100644
--- a/ini.h
+++ b/ini.h
@@ -27,7 +27,7 @@
 /* Parse given INI-style file. May have [section]s, name=value pairs
    (whitespace stripped), and comments starting with ';' (semicolon). Section
    is "" if name=value pair parsed before any section heading. name:value
-   pairs are also supported as a concession to Python's ConfigParser.
+   pairs are also supported as a concession to Python's configparser.
 
    For each name=value pair parsed, call handler function with given user
    pointer as well as section, name, and value (data only valid for duration
@@ -49,7 +49,7 @@
                      void* user);
 
 /* Nonzero to allow multi-line value parsing, in the style of Python's
-   ConfigParser. If allowed, ini_parse() will call the handler with the same
+   configparser. If allowed, ini_parse() will call the handler with the same
    name for each subsequent line parsed. */
 #ifndef INI_ALLOW_MULTILINE
 #define INI_ALLOW_MULTILINE 1
@@ -61,6 +61,14 @@
 #define INI_ALLOW_BOM 1
 #endif
 
+/* Nonzero to allow inline comments (with valid inline comment characters
+   specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match
+   Python 3.2+ configparser behaviour. */
+#ifndef INI_ALLOW_INLINE_COMMENTS
+#define INI_ALLOW_INLINE_COMMENTS 1
+#endif
+#define INI_INLINE_COMMENT_PREFIXES ";"
+
 /* Nonzero to use stack, zero to use heap (malloc/free). */
 #ifndef INI_USE_STACK
 #define INI_USE_STACK 1
diff --git a/tests/baseline_disallow_inline_comments.txt b/tests/baseline_disallow_inline_comments.txt
new file mode 100644
index 0000000..0e9c558
--- /dev/null
+++ b/tests/baseline_disallow_inline_comments.txt
@@ -0,0 +1,52 @@
+no_file.ini: e=-1 user=0
+... [section1]
+... one=This is a test  ; name=value comment;
+... two=1234;
+... [ section 2 ]
+... happy=4;
+... sad=;
+... [comment_test]
+... test1=1;2;3 ; only this will be a comment;
+... test2=2;3;4;this won't be a comment, needs whitespace before ';';
+... test;3=345 ; key should be "test;3";
+... test4=4#5#6 ; '#' only starts a comment at start of line;
+... [colon_tests]
+... Content-Type=text/html;
+... foo=bar;
+... adams=42;
+... funny1=with = equals;
+... funny2=with : colons;
+... funny3=two = equals;
+... funny4=two : colons;
+normal.ini: e=0 user=101
+... [section1]
+... name1=value1;
+... [section3   ; comment ]
+... name2=value2;
+bad_section.ini: e=3 user=102
+bad_comment.ini: e=1 user=102
+... [section]
+... a=b;
+... user=parse_error;
+... c=d;
+user_error.ini: e=3 user=104
+... [section1]
+... single1=abc;
+... multi=this is a;
+... multi=multi-line value;
+... single2=xyz;
+... [section2]
+... multi=a;
+... multi=b;
+... multi=c;
+... [section3]
+... single=ghi;
+... multi=the quick;
+... multi=brown fox;
+... name=bob smith  ; comment line 1;
+multi_line.ini: e=0 user=105
+bad_multi.ini: e=1 user=105
+... [bom_section]
+... bom_name=bom_value;
+... key“=value“;
+bom.ini: e=0 user=107
diff --git a/tests/unittest.bat b/tests/unittest.bat
index 20ab156..daca866 100644
--- a/tests/unittest.bat
+++ b/tests/unittest.bat
@@ -1,3 +1,4 @@
 @call tcc ..\ini.c -I..\ -run unittest.c > baseline_multi.txt
 @call tcc ..\ini.c -I..\ -DINI_ALLOW_MULTILINE=0 -run unittest.c > baseline_single.txt
+@call tcc ..\ini.c -I..\ -DINI_ALLOW_INLINE_COMMENTS=0 -run unittest.c > baseline_disallow_inline_comments.txt
 @call tcc ..\ini.c -I..\ -DINI_STOP_ON_FIRST_ERROR=1 -run unittest.c > baseline_stop_on_first_error.txt