require '_h2ph_pre.ph';

unless(defined(&_CHARDEFS_)) {
    eval 'sub _CHARDEFS_ () {1;}' unless defined(&_CHARDEFS_);
    require 'ctype.ph';
    unless(defined(&savestring)) {
	eval 'sub savestring {
	    local($X) = @_;
    	    eval q( &_rl_savestring($X));
	}' unless defined(&savestring);
    }
    unless(defined(&whitespace)) {
	eval 'sub whitespace {
	    local($c) = @_;
    	    eval q(((($c) == ord(\' \') || ((c) == \'\\\\t\'))));
	}' unless defined(&whitespace);
    }
    if(defined(&CTRL)) {
	undef(&CTRL) if defined(&CTRL);
    }
    eval 'sub control_character_threshold () {0x020;}' unless defined(&control_character_threshold);
    eval 'sub meta_character_threshold () {0x07f;}' unless defined(&meta_character_threshold);
    eval 'sub control_character_bit () {0x40;}' unless defined(&control_character_bit);
    eval 'sub meta_character_bit () {0x080;}' unless defined(&meta_character_bit);
    eval 'sub largest_char () {255;}' unless defined(&largest_char);
    eval 'sub META_CHAR {
        local($c) = @_;
	    eval q((($c) >  &meta_character_threshold  && ($c) <=  &largest_char));
    }' unless defined(&META_CHAR);
    eval 'sub CTRL {
        local($c) = @_;
	    eval q((($c) & (~ &control_character_bit)));
    }' unless defined(&CTRL);
    eval 'sub META {
        local($c) = @_;
	    eval q((($c) |  &meta_character_bit));
    }' unless defined(&META);
    eval 'sub UNMETA {
        local($c) = @_;
	    eval q((($c) & (~ &meta_character_bit)));
    }' unless defined(&UNMETA);
    eval 'sub UNCTRL {
        local($c) = @_;
	    eval q( &to_upper((($c)| &control_character_bit)));
    }' unless defined(&UNCTRL);
    eval 'sub lowercase_p {
        local($c) = @_;
	    eval q(((($c) > (ord(\'a\' - 1) && (c) < (\'z\') + 1))));
    }' unless defined(&lowercase_p);
    eval 'sub uppercase_p {
        local($c) = @_;
	    eval q(((($c) > (ord(\'A\' - 1) && (c) < (\'Z\') + 1))));
    }' unless defined(&uppercase_p);
    eval 'sub pure_alphabetic {
        local($c) = @_;
	    eval q(( &lowercase_p($c) ||  &uppercase_p($c)));
    }' unless defined(&pure_alphabetic);
    unless(defined(&to_upper)) {
	eval 'sub to_upper {
	    local($c) = @_;
    	    eval q(( &lowercase_p($c) ? (($c) - 32) : ($c)));
	}' unless defined(&to_upper);
	eval 'sub to_lower {
	    local($c) = @_;
    	    eval q(( &uppercase_p($c) ? (($c) + 32) : ($c)));
	}' unless defined(&to_lower);
    }
    eval 'sub CTRL_P {
        local($c) = @_;
	    eval q((($c) <  &control_character_threshold));
    }' unless defined(&CTRL_P);
    eval 'sub META_P {
        local($c) = @_;
	    eval q((($c) >  &meta_character_threshold));
    }' unless defined(&META_P);
    unless(defined(&NEWLINE)) {
	eval 'sub NEWLINE () {ord(\'\\n\');}' unless defined(&NEWLINE);
    }
    unless(defined(&RETURN)) {
	eval 'sub RETURN () { &CTRL(ord(\'M\'));}' unless defined(&RETURN);
    }
    unless(defined(&RUBOUT)) {
	eval 'sub RUBOUT () {0x07f;}' unless defined(&RUBOUT);
    }
    unless(defined(&TAB)) {
	eval 'sub TAB () {ord(\'\\t\');}' unless defined(&TAB);
    }
    if(defined(&ABORT_CHAR)) {
	undef(&ABORT_CHAR) if defined(&ABORT_CHAR);
    }
    eval 'sub ABORT_CHAR () { &CTRL(ord(\'G\'));}' unless defined(&ABORT_CHAR);
    if(defined(&PAGE)) {
	undef(&PAGE) if defined(&PAGE);
    }
    eval 'sub PAGE () { &CTRL(ord(\'L\'));}' unless defined(&PAGE);
    if(defined(&SPACE)) {
	undef(&SPACE) if defined(&SPACE);
    }
    eval 'sub SPACE () {0x020;}' unless defined(&SPACE);
    if(defined(&ESC)) {
	undef(&ESC) if defined(&ESC);
    }
    eval 'sub ESC () { &CTRL(ord(\'[\'));}' unless defined(&ESC);
}
1;
