[gobject-introspection] giscanner: accept different forms of line breaks



commit 3177c9868cc5daab1c7915c27e19f7236bb338df
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Thu Jul 18 07:29:36 2013 +0200

    giscanner: accept different forms of line breaks

 giscanner/annotationparser.py |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 625ffdf..88a8c73 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -282,6 +282,9 @@ TRANSFER_OPTIONS = [OPT_TRANSFER_CONTAINER,
                     OPT_TRANSFER_NONE]
 
 
+# Pattern used to normalize different types of line endings
+LINE_BREAK_RE = re.compile(r'\r\n|\r|\n', re.UNICODE)
+
 # Program matching the start of a comment block.
 #
 # Results in 0 symbolic groups.
@@ -1143,10 +1146,7 @@ class GtkDocCommentBlockParser(object):
         :returns: a :class:`GtkDocCommentBlock` object or ``None``
         '''
 
-        # Assign line numbers to each line of the comment block,
-        # which will later be used as the offset to calculate the
-        # real line number in the source file
-        comment_lines = list(enumerate(comment.split('\n')))
+        comment_lines = list(enumerate(re.sub(LINE_BREAK_RE, '\n', comment).split('\n')))
 
         # Check for the start the comment block.
         if COMMENT_START_RE.match(comment_lines[0][1]):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]