This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
embed.fnc: 'm' and 'p' flags don't make sense together
[perl5.git] / regen / embed.pl
index ca466a3..8546051 100755 (executable)
@@ -81,10 +81,11 @@ my ($embed, $core, $ext, $api) = setup_embed();
        }
 
        my ($flags,$retval,$plain_func,@args) = @$_;
-        if ($flags =~ / ( [^AabDdEefiMmNnOoPpRrSsTUWXx] ) /x) {
+        if ($flags =~ / ( [^AabCDdEefGhiMmNnOoPpRrSsTUuWXx] ) /x) {
            die_at_end "flag $1 is not legal (for function $plain_func)";
        }
        my @nonnull;
+       my $args_assert_line = ( $flags !~ /G/ );
         my $has_depth = ( $flags =~ /W/ );
        my $has_context = ( $flags !~ /T/ );
        my $never_returns = ( $flags =~ /r/ );
@@ -100,7 +101,11 @@ my ($embed, $core, $ext, $api) = setup_embed();
        }
 
        die_at_end "$plain_func: S flag is mutually exclusive from the i and p plags"
-                                           if $flags =~ /S/ && $flags =~ /[ip]/;
+                                       if $flags =~ /S/ && $flags =~ /([ip])/;
+       die_at_end "$plain_func: m and $1 flags are mutually exclusive"
+                                       if $flags =~ /m/ && $flags =~ /([pS])/;
+
+       die_at_end "$plain_func: u flag only usable with m" if $flags =~ /u/ && $flags !~ /m/;
 
        my $static_inline = 0;
        if ($flags =~ /([Si])/) {
@@ -124,12 +129,15 @@ my ($embed, $core, $ext, $api) = setup_embed();
            }
        }
 
-       die_at_end "M flag requires p flag" if $flags =~ /M/ && $flags !~ /p/;
+       die_at_end "For '$plain_func', M flag requires p flag"
+                                           if $flags =~ /M/ && $flags !~ /p/;
+       die_at_end "For '$plain_func', b and m flags are mutually exclusive"
+                . " (try M flag)" if $flags =~ /b/ && $flags =~ /m/;
+       die_at_end "For '$plain_func', b flag without M flag requires D flag"
+                           if $flags =~ /b/ && $flags !~ /M/ && $flags !~ /D/;
 
        $func = full_name($plain_func, $flags);
        $ret = "";
-       $ret .= "#ifndef NO_MATHOMS\n" if $binarycompat;
-       $ret .= "#ifndef PERL_NO_INLINE_FUNCTIONS\n" if $static_inline;
        $ret .= "$retval\t$func(";
        if ( $has_context ) {
            $ret .= @args ? "pTHX_ " : "pTHX";
@@ -218,12 +226,14 @@ my ($embed, $core, $ext, $api) = setup_embed();
        }
        $ret .= ";";
        $ret = "/* $ret */" if $commented_out;
-       if (@names_of_nn) {
-           $ret .= "\n#define PERL_ARGS_ASSERT_\U$plain_func\E\t\\\n\t"
-               . join '; ', map "assert($_)", @names_of_nn;
-       }
-       $ret .= "\n#endif" if $static_inline;
-       $ret .= "\n#endif" if $binarycompat;
+
+       $ret .= "\n#define PERL_ARGS_ASSERT_\U$plain_func\E"
+                                           if $args_assert_line || @names_of_nn;
+       $ret .= "\t\\\n\t" . join '; ', map "assert($_)", @names_of_nn
+                                                               if @names_of_nn;
+
+       $ret = "#ifndef PERL_NO_INLINE_FUNCTIONS\n$ret\n#endif" if $static_inline;
+       $ret = "#ifndef NO_MATHOMS\n$ret\n#endif" if $binarycompat;
        $ret .= @attrs ? "\n\n" : "\n";
 
        print $pr $ret;