thewml / website-meta-language

An old offline HTML preprocessor (which can be used for static site generation), written in Perl and C that is still maintained for legacy reasons, but probably not recommended for new sites.
https://www.shlomifish.org/open-source/projects/website-meta-language/
GNU General Public License v2.0
14 stars 8 forks source link

Argument "" isn't numeric in numeric ne (!=) at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 274. #11

Closed xtaran closed 5 years ago

xtaran commented 5 years ago

In my setup, wml called by wmk (after having fixed #10) bails out as follows once per skipped (!) file:

→ wmk
Use of uninitialized value $rc in numeric ne (!=) at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 274.
        TheWML::Frontends::Wml::Runner::_handle_opt_M_stdin(TheWML::Frontends::Wml::Runner=HASH(0x56240ccfb458)) called at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 922
        TheWML::Frontends::Wml::Runner::run_with_ARGV(TheWML::Frontends::Wml::Runner=HASH(0x56240ccfb458), HASH(0x56240d1a3110)) called at /usr/bin/wml line 47
/usr/bin/wml -n '-o(ALL-LANG_*)+LANG_EN:geekcode.en.html' '-o(ALL-LANG_*)+LANG_DE:geekcode.de.html' geekcode.wml  (skipped)

My .wmlrc:

-o (ALL-LANG_*)+LANG_EN:%BASE.en.html -o (ALL-LANG_*)+LANG_DE:%BASE.de.html
-I `pwd`/../wml
-i template.wml
-W 7,"-F imgsize"
-W 7,"-F center"
-W 7,"-F space"
-W 7,"-F quotes"
# 1+8 = 9 (see mp4h(1))
-W 2,"-X 9"
#-E tidy
-P ~/bin/markdown-if-md.sh
-E ~/bin/tidy-no-writeback.pl

My .wmkrc:

-o (ALL-LANG_*)+LANG_EN:%BASE.en.html -o (ALL-LANG_*)+LANG_DE:%BASE.de.html
-A *.wml
-A *.md

Here's a patch, but I'm not sure if it catches all cases properly:

--- a/src/wml_include/TheWML/Frontends/Wml/Runner.pm
+++ b/src/wml_include/TheWML/Frontends/Wml/Runner.pm
@@ -271,7 +271,7 @@
         $rc = $_pass_mgr->pass1( $_pass_mgr->pass(1)->opt_pass() . $opt_pass,
             $self->_src, $o, $self->_tmp->[2] );
     };
-    if ( $rc != 0 )
+    if ( defined($rc) and $rc ne '' and $rc != 0 )
     {
         $self->_unlink_tmp;
         die +( $rc % 256 != 0 )

A proper pull request will probably follow soon.

shlomif commented 5 years ago

@xtaran : does it work for you now?

xtaran commented 5 years ago

@xtaran : does it work for you now?

I expected so, but if I replace my patch with your patch in the Debian package of 2.10.1 which I'm currently preparing, it's failing again:

Argument "" isn't numeric in numeric ne (!=) at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 276.
        TheWML::Frontends::Wml::Runner::_handle_opt_M_stdin(TheWML::Frontends::Wml::Runner=HASH(0x55ca8e6fb458)) called at /usr/share/wml/TheWML/Frontends/Wml/Runner.pm line 926
        TheWML::Frontends::Wml::Runner::run_with_ARGV(TheWML::Frontends::Wml::Runner=HASH(0x55ca8e6fb458), HASH(0x55ca8eb21d18)) called at /usr/bin/wml line 47
/usr/bin/wml -n '-o(ALL-LANG_*)+LANG_EN:geekcode.en.html' '-o(ALL-LANG_*)+LANG_DE:geekcode.de.html' geekcode.wml  (skipped)

I think the issue is that $_pass_mgr->pass1(…) returns neither undef nor a number but an empty string.

The following change makes it working for me, but since I don't know what the pass1 method is expected to return, I'm not sure if that's the proper fix for it:

-    if ( defined $rc )
+    if ( defined $rc and $rc ne '' )
shlomif commented 5 years ago

@xtaran : please try https://github.com/thewml/website-meta-language/commit/6c19df77622bc3baa8ec09f57433038179ba3f13 .

xtaran commented 5 years ago

That fixed it, thanks!