mhonarc-users

Re: Small buglet in mhdb.pl (and fix)

1996-01-22 15:39:14

The '\' in the subject is not escaped. Appended is a tiny patch
that fix it.

Good catch.

The bug you found can also cause problems with the other variable
output routines.  Ie.  Your fix needs to be applied to all the
routines.

Here is the fixes I put in place for the print_* routines in
mhdb.pl.  Feel free to test them out to see they are correct:

##---------------------------------------------------------------------------
sub print_assoc {
    local($handle, $name, *assoc) = @_;

    print $handle "%$name = (\n";
    foreach (keys %assoc) {
        print $handle qq{'}, &escape_str($_), qq{', '},
                      &escape_str($assoc{$_}), qq{',\n};
    }
    print $handle ");\n";
}
##---------------------------------------------------------------------------
sub print_array {
    local($handle, $name, *array) = @_;

    print $handle "\(_at_)$name = (\n";
    foreach (@array) {
        print $handle qq{'}, &escape_str($_), qq{',\n};
    }
    print $handle ");\n";
}
##---------------------------------------------------------------------------
sub print_var {
    local($handle, $name, *var, $d) = @_;

    print $handle qq{\$$name = '}, &escape_str($var), qq{'};
    print $handle qq{  unless defined(\$$name)}  if $d;
    print $handle qq{;\n};
}
##---------------------------------------------------------------------------
sub escape_str {
    local($str) = $_[0];

    $str =~ s/\\/\\\\/g;
    $str =~ s/'/\\'/g;
    $str;
}

<Prev in Thread] Current Thread [Next in Thread>