From: Florian Brosch Date: Tue, 7 Aug 2012 12:06:38 +0000 (+0200) Subject: gtkdoc: accept % X-Git-Tag: 0.37.1~3^2~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2daa05f2bd185e3de5c2e85afc86b2bc6194b41b;p=thirdparty%2Fvala.git gtkdoc: accept % --- diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala index 1fcafbc75..79392168a 100644 --- a/src/libvaladoc/documentation/gtkdoccommentparser.vala +++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala @@ -44,6 +44,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { private string[]? comment_lines; + private Regex? is_numeric_regex = null; private Regex? normalize_regex = null; private HashMap metadata = new HashMap (); @@ -76,15 +77,16 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { private string normalize (string text) { try { - if (normalize_regex == null) { - normalize_regex = new Regex ("( |\n|\t)+"); - } return normalize_regex.replace (text, -1, 0, " "); } catch (RegexError e) { assert_not_reached (); } } + private bool is_numeric (string str) { + return is_numeric_regex.match (str); + } + private inline Text? split_text (Text text) { int offset = 0; while ((offset = text.content.index_of_char ('.', offset)) >= 0) { @@ -230,6 +232,13 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { this.reporter = reporter; this.settings = settings; this.tree = tree; + + try { + is_numeric_regex = new Regex ("^[+-]?([0-9]*\\.?[0-9]+|[0-9]+\\.?[0-9]*)([eE][+-]?[0-9]+)?$", RegexCompileFlags.OPTIMIZE); + normalize_regex = new Regex ("( |\n|\t)+", RegexCompileFlags.OPTIMIZE); + } catch (RegexError e) { + assert_not_reached (); + } } private Api.Node? element; @@ -1493,7 +1502,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { } private Inline create_type_link (string name) { - if (name == "TRUE" || name == "FALSE" || name == "NULL") { + if (name == "TRUE" || name == "FALSE" || name == "NULL" || is_numeric (name)) { var monospaced = factory.create_run (Run.Style.MONOSPACED); monospaced.content.add (factory.create_text (name.down ())); return monospaced;