chiark / gitweb /
Progressing.
[chiark-tcl.git] / base / tcmdifgen
index aa717d4d74b1225ba3f6c889a1e67e078c990a00..21833c1d1cdc415718eb508d313fcd813208f1e4 100755 (executable)
@@ -36,7 +36,7 @@ sub parse ($$) {
        chomp; s/\s+$//;
        next if m/^\s*\#/;
        next if !m/\S/;
-       s/\t/ ' 'x(8-(length $`) % 8) /eg;
+       while (s/\t/ ' 'x(8 - (length $`) % 8) /e) { }
 
        s/^\s*//;
        $this_indent= length $&;
@@ -178,6 +178,7 @@ foreach $c_table (sort keys %tables) {
                $pa_body .= "  if (!objc--) goto end_optional;\n";
                $any_optl= 1;
            } else {
+               die if $any_optl;
                $any_mand++;
            }
            $paarg= "&a_$n";
@@ -200,13 +201,19 @@ foreach $c_table (sort keys %tables) {
            push @do_aa, "a_$n";
        }
        if (exists $r_entry->{V}) {
+           if ($any_mand) {
+               $pa_body .= "  objc -= $any_mand;\n";
+           }
            $va= $r_entry->{V};
            push @do_al, subst_in_decl("${va}c", 'int @');
            push @do_al, subst_in_decl("${va}v", 'Tcl_Obj *const *@');
-           push @do_aa, "objc-1", "objv+1";
+           push @do_aa, "objc+1", "objv-1";
        } else {
-           $pa_body .= "  if (--objc) { e=\"too many args\"; goto e_err; }\n";
-           $any_eerr= 1;
+           if (!$any_optl) {
+               $pa_argc .= "  if (objc != $any_mand) {".
+                   " e=\"wrong number of args\"; goto e_err; }\n";
+               $any_eerr= 1;
+           }
        }
        if ($any_optl) {
            $pa_body .= "end_optional:\n";