]> git.wincent.com - wikitext.git/commitdiff
Minor clean-up in _Wikitext_rollback_failed_external_link
authorWincent Colaiuta <win@wincent.com>
Fri, 8 May 2009 12:00:31 +0000 (14:00 +0200)
committerWincent Colaiuta <win@wincent.com>
Fri, 8 May 2009 12:00:31 +0000 (14:00 +0200)
Minor reorganization to make _Wikitext_rollback_failed_external_link a
little cleaner. Avoid the almost identical calls to
_Wikitext_append_hyperlink and instead set up a link_class local
variable.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
ext/parser.c

index e51b98e9a4b75d39c0fad2f33cb7ad7767329238..3e63d4410d2e3a6470814a553d76e880ed73c5cc 100644 (file)
@@ -908,16 +908,16 @@ void _Wikitext_rollback_failed_external_link(parser_t *parser)
 {
     if (!IN(EXT_LINK_START))
         return; // nothing to do!
-    int scope_includes_space = IN(SPACE); // remember these before popping
-    int scope_includes_path  = IN(PATH);
+
+    // store a couple of values before popping
+    int scope_includes_space = IN(SPACE);
+    VALUE link_class = IN(PATH) ? Qnil : parser->external_link_class;
     _Wikitext_pop_from_stack_up_to(parser, Qnil, EXT_LINK_START, Qtrue);
+
     rb_str_cat(parser->output, ext_link_start, sizeof(ext_link_start) - 1);
     if (!NIL_P(parser->link_target))
     {
-        if (scope_includes_path) // don't use external link class
-            _Wikitext_append_hyperlink(parser, Qnil, parser->link_target, parser->link_target, Qnil, Qtrue);
-        else
-            _Wikitext_append_hyperlink(parser, Qnil, parser->link_target, parser->link_target, parser->external_link_class, Qtrue);
+        _Wikitext_append_hyperlink(parser, Qnil, parser->link_target, parser->link_target, link_class, Qtrue);
         if (scope_includes_space)
         {
             rb_str_cat(parser->output, space, sizeof(space) - 1);