
/* This file was automatically generated by pclu.*/

#include "pclu_err.h"
#include "pclu_sys.h"


extern errcode intOPfrom_to();
extern errcode stringOPconcat();
CLUREF STR_;
static int fill_own_init = 0;

/**** BEGIN PROCEDURE fill ****/

errcode fill(substring, times, ret_1)
CLUREF substring;
CLUREF times;
CLUREF *ret_1;
    {
    errcode err;
    errcode ecode2;
    CLUREF dum;
    CLUREF i;
        if (fill_own_init == 0) {
        stringOPcons("", CLU_1, CLU_0, &STR_);
        fill_own_init = 1;
    }
    enter_proc(102);

  LINE(105);
    {
        {dum = STR_;
        }
        }

  LINE(106);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
        T_1_2.num = times.num;
        for (T_1_1.num = 1; T_1_1.num <= T_1_2.num; T_1_1.num++) {
            i.num = T_1_1.num;

  LINE(107);
            {
            CLUREF T_2_1;
            err = stringOPconcat(dum, substring, &T_2_1);
            if (err != ERR_ok) goto ex_0;
            dum.num = T_2_1.num;
            }
        }
    }
    end_inline_for_1:;

  LINE(109);
    {
    {
    ret_1->num = dum.num;
    }
    {signal (ERR_ok);}}
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE fill ****/


extern errcode intOPle();
extern errcode stringOPsize();
extern errcode stringOPrest();
extern errcode streamOPputs();
extern errcode fill();
extern errcode stringOPsubstr();
extern errcode intOPsub();
extern errcode intOPadd();
CLUREF STR__033_133D;
static int insert_text_own_init = 0;

/**** BEGIN PROCEDURE insert_text ****/

errcode insert_text(str, text_to_insert, current_text, current_pos, ret_1, ret_2)
CLUREF str;
CLUREF text_to_insert;
CLUREF current_text;
CLUREF current_pos;
CLUREF *ret_1;
CLUREF *ret_2;
    {
    errcode err;
    errcode ecode2;
    CLUREF rest_of_line;
    CLUREF new_text;
        if (insert_text_own_init == 0) {
        stringOPcons("\033[D", CLU_1, CLU_3, &STR__033_133D);
        insert_text_own_init = 1;
    }
    enter_proc(113);

  LINE(121);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    err = stringOPsize(current_text, &T_1_1);
    if (err != ERR_ok) goto ex_0;
    T_1_2.num = (current_pos.num <= T_1_1.num)? true : false;
    if (T_1_2.num == true) {

  LINE(122);
        {
            {CLUREF T_2_1;
            err = stringOPrest(current_text, current_pos, &T_2_1);
            if (err != ERR_ok) goto ex_0;
            rest_of_line.num = T_2_1.num;
            }
            }

  LINE(123);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        CLUREF T_2_3;
        CLUREF T_2_4;
        err = stringOPconcat(text_to_insert, rest_of_line, &T_2_1);
        if (err != ERR_ok) goto ex_0;
        err = stringOPsize(rest_of_line, &T_2_2);
        if (err != ERR_ok) goto ex_0;
        err = fill(STR__033_133D, T_2_2, &T_2_3);
        if (err != ERR_ok) goto ex_0;
        err = stringOPconcat(T_2_1, T_2_3, &T_2_4);
        if (err != ERR_ok) goto ex_0;
        err = streamOPputs(str, T_2_4);
        if (err != ERR_ok) goto ex_0;
        }

  LINE(125);
        {
            {CLUREF T_2_1;
            CLUREF T_2_2;
            CLUREF T_2_3;
            CLUREF T_2_4;
            T_2_1.num = current_pos.num - 1;
             if ((T_2_1.num >= 0 && current_pos.num < 0 && (-1) < 0) || 
                 (T_2_1.num <= 0 && current_pos.num > 0 && (-1) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            err = stringOPsubstr(current_text, CLU_1, T_2_1, &T_2_2);
            if (err != ERR_ok) goto ex_0;
            err = stringOPconcat(T_2_2, text_to_insert, &T_2_3);
            if (err != ERR_ok) goto ex_0;
            err = stringOPconcat(T_2_3, rest_of_line, &T_2_4);
            if (err != ERR_ok) goto ex_0;
            new_text.num = T_2_4.num;
            }
            }

  LINE(127);
        {
        {
        ret_1->num = new_text.num;
        }
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        err = stringOPsize(text_to_insert, &T_2_1);
        if (err != ERR_ok) goto ex_0;
        T_2_2.num = current_pos.num + T_2_1.num;
         if ((T_2_2.num > 0 && current_pos.num < 0 && T_2_1.num < 0) || 
             (T_2_2.num < 0 && current_pos.num > 0 && T_2_1.num > 0)) {
            err = ERR_overflow;
            goto ex_0;}
        ret_2->num = T_2_2.num;
        }
        {signal (ERR_ok);}}
        }
    else {

  LINE(129);
        {
        err = streamOPputs(str, text_to_insert);
        if (err != ERR_ok) goto ex_0;
        }

  LINE(130);
        {
        {
        CLUREF T_2_1;
        err = stringOPconcat(current_text, text_to_insert, &T_2_1);
        if (err != ERR_ok) goto ex_0;
        ret_1->num = T_2_1.num;
        }
        {
        CLUREF T_2_2;
        CLUREF T_2_3;
        err = stringOPsize(text_to_insert, &T_2_2);
        if (err != ERR_ok) goto ex_0;
        T_2_3.num = current_pos.num + T_2_2.num;
         if ((T_2_3.num > 0 && current_pos.num < 0 && T_2_2.num < 0) || 
             (T_2_3.num < 0 && current_pos.num > 0 && T_2_2.num > 0)) {
            err = ERR_overflow;
            goto ex_0;}
        ret_2->num = T_2_3.num;
        }
        {signal (ERR_ok);}}
        }}/* end if */
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE insert_text ****/


extern errcode intOPge();
extern errcode intOPgt();
CLUREF STR__040;
static int delete_text_own_init = 0;

/**** BEGIN PROCEDURE delete_text ****/

errcode delete_text(str, current_text, current_pos, del_start, del_end, ret_1, ret_2)
CLUREF str;
CLUREF current_text;
CLUREF current_pos;
CLUREF del_start;
CLUREF del_end;
CLUREF *ret_1;
CLUREF *ret_2;
    {
    errcode err;
    errcode ecode2;
    CLUREF rest_of_line;
    CLUREF get_to_start;
    CLUREF new_pos;
    CLUREF new_text;
        if (delete_text_own_init == 0) {
        stringOPcons("", CLU_1, CLU_0, &STR_);
        stringOPcons("\033[D", CLU_1, CLU_3, &STR__033_133D);
        stringOPcons(" ", CLU_1, CLU_1, &STR__040);
        delete_text_own_init = 1;
    }
    enter_proc(137);

  LINE(146);
    {
    CLUREF T_1_1;
    T_1_1.num = (del_end.num >= del_start.num)? true : false;
    if (T_1_1.num == true) {

  LINE(147);
        {
            {CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            T_3_1.num = del_end.num + 1;
             if ((T_3_1.num > 0 && del_end.num < 0 && 1 < 0) || 
                 (T_3_1.num < 0 && del_end.num > 0 && 1 > 0)) {
                err = ERR_overflow;
                goto ex_1;}
            err = stringOPsize(current_text, &T_3_2);
            if (err != ERR_ok) goto ex_1;
            err = stringOPsubstr(current_text, T_3_1, T_3_2, &T_3_3);
            if (err != ERR_ok) goto ex_1;
            rest_of_line.num = T_3_3.num;
            }
            }
            goto end_1;
            ex_1:
                if ((err == ERR_bounds)) {

  LINE(149);
                    {
                    rest_of_line = STR_;
                    }
                }
                else {
                    goto ex_0;
                }
            end_1:;

  LINE(151);
        {
            {get_to_start = STR_;
            }
            }

  LINE(153);
        {
        CLUREF T_2_1;
        T_2_1.num = (current_pos.num > del_start.num)? true : false;
        if (T_2_1.num == true) {

  LINE(154);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = current_pos.num - del_start.num;
             if ((T_3_1.num >= 0 && current_pos.num < 0 && (-del_start.num) < 0) || 
                 (T_3_1.num <= 0 && current_pos.num > 0 && (-del_start.num) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            err = fill(STR__033_133D, T_3_1, &T_3_2);
            if (err != ERR_ok) goto ex_0;
            get_to_start.num = T_3_2.num;
            }
            }
        else {

  LINE(156);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = del_start.num - current_pos.num;
             if ((T_3_1.num >= 0 && del_start.num < 0 && (-current_pos.num) < 0) || 
                 (T_3_1.num <= 0 && del_start.num > 0 && (-current_pos.num) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            err = stringOPsubstr(current_text, current_pos, T_3_1, &T_3_2);
            if (err != ERR_ok) goto ex_0;
            get_to_start.num = T_3_2.num;
            }
            }}/* end if */

  LINE(162);
        {
        CLUREF T_2_1;
        T_2_1.num = (current_pos.num <= del_start.num)? true : false;
        if (T_2_1.num == true) {

  LINE(163);
            {
            new_pos.num = current_pos.num;
            }
            }
        else {
        CLUREF T_2_2;
        T_2_2.num = (current_pos.num > del_end.num)? true : false;
        if (T_2_2.num == true) {

  LINE(165);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            T_3_1.num = current_pos.num - del_end.num;
             if ((T_3_1.num >= 0 && current_pos.num < 0 && (-del_end.num) < 0) || 
                 (T_3_1.num <= 0 && current_pos.num > 0 && (-del_end.num) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            T_3_2.num = T_3_1.num + del_start.num;
             if ((T_3_2.num > 0 && T_3_1.num < 0 && del_start.num < 0) || 
                 (T_3_2.num < 0 && T_3_1.num > 0 && del_start.num > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            T_3_3.num = T_3_2.num - 1;
             if ((T_3_3.num >= 0 && T_3_2.num < 0 && (-1) < 0) || 
                 (T_3_3.num <= 0 && T_3_2.num > 0 && (-1) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            new_pos.num = T_3_3.num;
            }
            }
        else {

  LINE(167);
            {
            new_pos.num = del_start.num;
            }
            }}}/* end if */

  LINE(170);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        err = stringOPsize(current_text, &T_2_1);
        if (err != ERR_ok) goto ex_0;
        T_2_2.num = (new_pos.num <= T_2_1.num)? true : false;
        if (T_2_2.num == true) {

  LINE(171);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            CLUREF T_3_4;
            CLUREF T_3_5;
            CLUREF T_3_6;
            CLUREF T_3_7;
            CLUREF T_3_8;
            CLUREF T_3_9;
            CLUREF T_3_10;
            err = stringOPconcat(get_to_start, rest_of_line, &T_3_1);
            if (err != ERR_ok) goto ex_0;
            T_3_2.num = del_end.num - del_start.num;
             if ((T_3_2.num >= 0 && del_end.num < 0 && (-del_start.num) < 0) || 
                 (T_3_2.num <= 0 && del_end.num > 0 && (-del_start.num) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            T_3_3.num = T_3_2.num + 1;
             if ((T_3_3.num > 0 && T_3_2.num < 0 && 1 < 0) || 
                 (T_3_3.num < 0 && T_3_2.num > 0 && 1 > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            err = fill(STR__040, T_3_3, &T_3_4);
            if (err != ERR_ok) goto ex_0;
            err = stringOPconcat(T_3_1, T_3_4, &T_3_5);
            if (err != ERR_ok) goto ex_0;
            err = stringOPsize(current_text, &T_3_6);
            if (err != ERR_ok) goto ex_0;
            T_3_7.num = T_3_6.num - new_pos.num;
             if ((T_3_7.num >= 0 && T_3_6.num < 0 && (-new_pos.num) < 0) || 
                 (T_3_7.num <= 0 && T_3_6.num > 0 && (-new_pos.num) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            T_3_8.num = T_3_7.num + 1;
             if ((T_3_8.num > 0 && T_3_7.num < 0 && 1 < 0) || 
                 (T_3_8.num < 0 && T_3_7.num > 0 && 1 > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            err = fill(STR__033_133D, T_3_8, &T_3_9);
            if (err != ERR_ok) goto ex_0;
            err = stringOPconcat(T_3_5, T_3_9, &T_3_10);
            if (err != ERR_ok) goto ex_0;
            err = streamOPputs(str, T_3_10);
            if (err != ERR_ok) goto ex_0;
            }
            }
            }/* end if */

  LINE(176);
        {
            {CLUREF T_2_1;
            CLUREF T_2_2;
            CLUREF T_2_3;
            T_2_1.num = del_start.num - 1;
             if ((T_2_1.num >= 0 && del_start.num < 0 && (-1) < 0) || 
                 (T_2_1.num <= 0 && del_start.num > 0 && (-1) > 0)) {
                err = ERR_overflow;
                goto ex_0;}
            err = stringOPsubstr(current_text, CLU_1, T_2_1, &T_2_2);
            if (err != ERR_ok) goto ex_0;
            err = stringOPconcat(T_2_2, rest_of_line, &T_2_3);
            if (err != ERR_ok) goto ex_0;
            new_text.num = T_2_3.num;
            }
            }

  LINE(178);
        {
        {
        ret_1->num = new_text.num;
        }
        {
        ret_2->num = new_pos.num;
        }
        {signal (ERR_ok);}}
        }
    else {

  LINE(181);
        {
        {
        ret_1->num = current_text.num;
        }
        {
        ret_2->num = current_pos.num;
        }
        {signal (ERR_ok);}}
        }}/* end if */
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE delete_text ****/


extern errcode intOPfrom_to_by();
extern errcode intOPequal();
extern errcode stringOPindexc();
extern errcode stringOPfetch();
extern errcode boolOPnot();

/**** BEGIN PROCEDURE find_word ****/

errcode find_word(current_text, current_pos, delim, ret_1, ret_2)
CLUREF current_text;
CLUREF current_pos;
CLUREF delim;
CLUREF *ret_1;
CLUREF *ret_2;
    {
    errcode err;
    errcode ecode2;
    CLUREF beg;
    CLUREF i;
    CLUREF ending;
    enter_proc(186);

  LINE(194);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    err = stringOPsize(current_text, &T_1_1);
    if (err != ERR_ok) goto ex_0;
    T_1_2.num = (current_pos.num > T_1_1.num)? true : false;
    if (T_1_2.num == true) {

  LINE(195);
        {
        CLUREF T_2_1;
        err = stringOPsize(current_text, &T_2_1);
        if (err != ERR_ok) goto ex_0;
        current_pos.num = T_2_1.num;
        }
        }
        }/* end if */

  LINE(198);
    {
        {beg.num = 1;
        }
        }

  LINE(199);
    {
    CLUREF T_2_1;
    CLUREF T_2_2;
    CLUREF T_2_3;
        T_2_2.num = 1;
        T_2_3.num = -1;
        for (T_2_1.num = current_pos.num; ((T_2_3.num == 0) || ((T_2_3.num > 0)? (T_2_1.num <= T_2_2.num) : (T_2_1.num >= T_2_2.num))); T_2_1.num += T_2_3.num) {
            i.num = T_2_1.num;

  LINE(200);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            err = stringOPfetch(current_text, i, &T_3_1);
            if (err != ERR_ok) goto ex_1;
            err = stringOPindexc(T_3_1, delim, &T_3_2);
            if (err != ERR_ok) goto ex_1;
            T_3_3.num = (T_3_2.num == 0)? true : false;
            if (T_3_3.num == true) {

  LINE(201);
                {
                beg.num = i.num;
                }
                }
            else {
            CLUREF T_3_4;
            CLUREF T_3_5;
            T_3_4.num = (beg.num == 1)? true : false;
            T_3_5.num = T_3_4.num ^ 1;
            if (T_3_5.num == true) {

  LINE(203);
                {
                    err = "ERR_got_it";
                    goto ex_1;
                    }
                }
                }}/* end if */
        }
    }
    end_inline_for_1:;
        goto end_1;
        ex_1:
            if (errcmp(err, "ERR_got_it")) {
            }
            else {
                goto ex_0;
            }
        end_1:;

  LINE(207);
    {
        {ending.num = 0;
        }
        }

  LINE(208);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    CLUREF T_1_3;
        err = stringOPsize(current_text, &T_1_1);
        if (err != ERR_ok) goto ex_0;
        T_1_3.num = T_1_1.num;
        for (T_1_2.num = current_pos.num; T_1_2.num <= T_1_3.num; T_1_2.num++) {
            i.num = T_1_2.num;

  LINE(209);
            {
            CLUREF T_2_1;
            CLUREF T_2_2;
            CLUREF T_2_3;
            CLUREF T_2_4;
            err = stringOPfetch(current_text, i, &T_2_1);
            if (err != ERR_ok) goto ex_0;
            err = stringOPindexc(T_2_1, delim, &T_2_2);
            if (err != ERR_ok) goto ex_0;
            T_2_3.num = (T_2_2.num == 0)? true : false;
            T_2_4.num = T_2_3.num ^ 1;
            if (T_2_4.num == true) {

  LINE(210);
                {
                ending.num = i.num;
                }
                }
            else {
            CLUREF T_2_5;
            CLUREF T_2_6;
            T_2_5.num = (ending.num == 0)? true : false;
            T_2_6.num = T_2_5.num ^ 1;
            if (T_2_6.num == true) {

  LINE(212);
                {
                {
                ret_1->num = beg.num;
                }
                {
                ret_2->num = ending.num;
                }
                {signal (ERR_ok);}}
                }
                }}/* end if */
        }
    }
    end_inline_for_2:;

  LINE(216);
    {
    {
    ret_1->num = beg.num;
    }
    {
    CLUREF T_1_1;
    err = stringOPsize(current_text, &T_1_1);
    if (err != ERR_ok) goto ex_0;
    ret_2->num = T_1_1.num;
    }
    {signal (ERR_ok);}}
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE find_word ****/


extern errcode streamOPgetc_image();
extern errcode streamOPset_eof_flag();
extern errcode charOPi2c();

/**** BEGIN PROCEDURE getc_noeof ****/

errcode getc_noeof(str, ret_1)
CLUREF str;
CLUREF *ret_1;
    {
    errcode err;
    errcode ecode2;
    enter_proc(220);

  LINE(224);
    {
    {
    CLUREF T_2_1;
    err = streamOPgetc_image(str, &T_2_1);
    if (err != ERR_ok) goto ex_1;
    ret_1->num = T_2_1.num;
    }
    {signal (ERR_ok);}}
        goto end_1;
        ex_1:
            if ((err == ERR_end_of_file)) {

  LINE(225);
                {
                err = streamOPset_eof_flag(str, CLU_0);
                if (err != ERR_ok) goto ex_0;
                }

  LINE(226);
                {
                {
                CLUREF T_2_1;
                err = charOPi2c(CLU_4, &T_2_1);
                if (err != ERR_ok) goto ex_0;
                ret_1->num = T_2_1.num;
                }
                {signal (ERR_ok);}}
            }
            else {
                goto ex_0;
            }
        end_1:;
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE getc_noeof ****/


extern errcode setup_keytable();
extern errcode getc_noeof();
extern errcode charOPge();
extern errcode charOPle();
extern errcode charOPc2i();
extern errcode stringOPc2s();
extern errcode stableOPcompletions();
extern errcode stringOPequal();
extern errcode run_time();
extern errcode streamOPpending();
extern errcode realOPlt();
extern errcode timeOPt2r();
extern errcode timeOPsub();
extern errcode stableOPlookup();
extern errcode streamOPset_rescan();
extern errcode streamOPget_rescan();
extern struct REQS *stable_of_value_t_reqs;
extern struct OPS *int_ops;
extern OWN_req stable_ownreqs;
extern struct OPS *stable_ops;
struct OPS *stable_of_int_table;
struct OPS *stable_of_int_ops;
struct OPS *stable_of_int_ops;
OWNPTR stable_of_int_owns;
static int get_key_press_own_init = 0;
CLUREF get_key_pressOPbindings;

/**** BEGIN PROCEDURE get_key_press ****/

errcode get_key_press(str, ret_1, ret_2)
CLUREF str;
CLUREF *ret_1;
CLUREF *ret_2;
    {
    errcode err;
    errcode ecode2;
    CLUREF so_far;
    CLUREF put_back;
    CLUREF last_exact;
    CLUREF ismore;
    CLUREF first_time;
    CLUREF exact;
    CLUREF partial;
    CLUREF key_press;
    CLUREF a;
        if (get_key_press_own_init == 0) {
        add_parm_info_type(0, int_ops, stable_of_value_t_reqs);
        find_type_instance(stable_ops, 1, &stable_ownreqs, &(stable_of_int_ops));
        stringOPcons("", CLU_1, CLU_0, &STR_);
        get_key_press_own_init = 1;
        {
            {CLUREF T_0_1;
            err = setup_keytable(&T_0_1);
            if (err != ERR_ok) goto ex_0;
            get_key_pressOPbindings.num = T_0_1.num;
            }
            }
    }
    enter_proc(231);

  LINE(239);
    {
        {so_far = STR_;
        }
        }

  LINE(240);
    {
        {put_back = STR_;
        }
        }

  LINE(241);
    {
        {last_exact = STR_;
        }
        }

  LINE(243);
    {
    first_time.tf = true;
    }

  LINE(249);
    for (;;) {
        if (true != true) { break; }

  LINE(253);
        {
            {CLUREF T_2_1;
            err = getc_noeof(str, &T_2_1);
            if (err != ERR_ok) goto ex_0;
            key_press.num = T_2_1.num;
            }
            }

  LINE(255);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        CLUREF T_2_3;
        CLUREF T_2_4;
        CLUREF T_2_5;
        CLUREF T_2_6;
        T_2_3.ch = ' ';
        err = charOPge(key_press, T_2_3, &T_2_4);
        if (err != ERR_ok) goto ex_0;
        T_2_2.num = T_2_4.num;
        if (T_2_4.num) {
            T_2_5.ch = '~';
            err = charOPle(key_press, T_2_5, &T_2_6);
            if (err != ERR_ok) goto ex_0;
            T_2_2.num = T_2_6.num;
        }
        T_2_1.num = T_2_2.num;
        if (T_2_2.num) {
            T_2_1.num = first_time.num;
        }
        if (T_2_1.num == true) {

  LINE(256);
            {
            {
            ret_1->num = 1;
            }
            {
            CLUREF T_3_1;
            T_3_1.num = (int)(key_press.ch & 0xff);
            ret_2->num = T_3_1.num;
            }
            {signal (ERR_ok);}}
            }
            }/* end if */

  LINE(259);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        err = stringOPc2s(key_press, &T_2_1);
        if (err != ERR_ok) goto ex_0;
        err = stringOPconcat(so_far, T_2_1, &T_2_2);
        if (err != ERR_ok) goto ex_0;
        so_far.num = T_2_2.num;
        }

  LINE(260);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
        generic_CLU_proc.proc = stableOPcompletions;
        CUR_PROC_VAR.proc = &generic_CLU_proc;
        err = stableOPcompletions(get_key_pressOPbindings, so_far, &T_2_1, &T_2_2);
        if (err != ERR_ok) goto ex_0;
        exact.num = T_2_1.num;
        partial.num = T_2_2.num;
        }

  LINE(262);
        {
        if (exact.num == true) {

  LINE(263);
            {
            last_exact.num = so_far.num;
            }

  LINE(264);
            {
            put_back = STR_;
            }
            }
        else {
        CLUREF T_2_1;
        CLUREF T_2_2;
        T_2_1.num = ((last_exact.str->size != STR_.str->size)? false :
            !(bcmp(last_exact.str->data, STR_.str->data, last_exact.str->size)));
        T_2_2.num = T_2_1.num ^ 1;
        if (T_2_2.num == true) {

  LINE(266);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            err = stringOPc2s(key_press, &T_3_1);
            if (err != ERR_ok) goto ex_0;
            err = stringOPconcat(put_back, T_3_1, &T_3_2);
            if (err != ERR_ok) goto ex_0;
            put_back.num = T_3_2.num;
            }
            }
            }}/* end if */

  LINE(274);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        CLUREF T_2_3;
        T_2_1.num = partial.num;
        if (partial.num) {
            T_2_2.num = ((last_exact.str->size != STR_.str->size)? false :
                !(bcmp(last_exact.str->data, STR_.str->data, last_exact.str->size)));
            T_2_3.num = T_2_2.num ^ 1;
            T_2_1.num = T_2_3.num;
        }
        if (T_2_1.num == true) {

  LINE(275);
            {
                {CLUREF T_3_1;
                err = run_time(&T_3_1);
                if (err != ERR_ok) goto ex_0;
                a.num = T_3_1.num;
                }
                }

  LINE(276);
            for (;;) {
                CLUREF T_3_1;
                CLUREF T_3_2;
                CLUREF T_3_3;
                CLUREF T_3_4;
                CLUREF T_3_5;
                CLUREF T_3_6;
                CLUREF T_3_7;
                CLUREF T_3_8;
                err = streamOPpending(str, &T_3_2);
                if (err != ERR_ok) goto ex_0;
                T_3_3.num = T_3_2.num ^ 1;
                T_3_1.num = T_3_3.num;
                if (T_3_3.num) {
                    err = run_time(&T_3_4);
                    if (err != ERR_ok) goto ex_0;
                    err = timeOPsub(T_3_4, a, &T_3_5);
                    if (err != ERR_ok) goto ex_0;
                    err = timeOPt2r(T_3_5, &T_3_6);
                    if (err != ERR_ok) goto ex_0;
                    T_3_7.real = 3.000000e-01;
                    err = realOPlt(T_3_6, T_3_7, &T_3_8);
                    if (err != ERR_ok) goto ex_0;
                    T_3_1.num = T_3_8.num;
                }
                if (T_3_1.num != true) { break; }
                }
                end_while_2:;
            }
            }/* end if */

  LINE(287);
        {
        CLUREF T_2_1;
        err = streamOPpending(str, &T_2_1);
        if (err != ERR_ok) goto ex_0;
        ismore.num = T_2_1.num;
        }

  LINE(288);
        {
        first_time.tf = false;
        }

  LINE(290);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        CLUREF T_2_3;
        CLUREF T_2_4;
        CLUREF T_2_5;
        CLUREF T_2_6;
        T_2_2.num = partial.num ^ 1;
        T_2_1.num = T_2_2.num;
        if (!T_2_2.num) {
            T_2_4.num = ((last_exact.str->size != STR_.str->size)? false :
                !(bcmp(last_exact.str->data, STR_.str->data, last_exact.str->size)));
            T_2_5.num = T_2_4.num ^ 1;
            T_2_3.num = T_2_5.num;
            if (T_2_5.num) {
                T_2_6.num = ismore.num ^ 1;
                T_2_3.num = T_2_6.num;
            }
            T_2_1.num = T_2_3.num;
        }
        if (T_2_1.num == true) {

  LINE(291);
            {
            if (exact.num == true) {

  LINE(292);
                {
                {
                CLUREF T_4_1;
                generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
                generic_CLU_proc.proc = stableOPlookup;
                CUR_PROC_VAR.proc = &generic_CLU_proc;
                err = stableOPlookup(get_key_pressOPbindings, so_far, &T_4_1);
                if (err != ERR_ok) goto ex_0;
                ret_1->num = T_4_1.num;
                }
                {
                ret_2->num = 1;
                }
                {signal (ERR_ok);}}
                }
            else {
            CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = ((last_exact.str->size != STR_.str->size)? false :
                !(bcmp(last_exact.str->data, STR_.str->data, last_exact.str->size)));
            T_3_2.num = T_3_1.num ^ 1;
            if (T_3_2.num == true) {

  LINE(294);
                {
                CLUREF T_4_1;
                CLUREF T_4_2;
                err = streamOPget_rescan(str, &T_4_1);
                if (err != ERR_ok) goto ex_0;
                err = stringOPconcat(put_back, T_4_1, &T_4_2);
                if (err != ERR_ok) goto ex_0;
                err = streamOPset_rescan(str, T_4_2);
                if (err != ERR_ok) goto ex_0;
                }

  LINE(295);
                {
                {
                CLUREF T_4_1;
                generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
                generic_CLU_proc.proc = stableOPlookup;
                CUR_PROC_VAR.proc = &generic_CLU_proc;
                err = stableOPlookup(get_key_pressOPbindings, last_exact, &T_4_1);
                if (err != ERR_ok) goto ex_0;
                ret_1->num = T_4_1.num;
                }
                {
                ret_2->num = 1;
                }
                {signal (ERR_ok);}}
                }
            else {

  LINE(297);
                {
                {
                ret_1->num = 0;
                }
                {
                ret_2->num = 1;
                }
                {signal (ERR_ok);}}
                }}}/* end if */
            }
            }/* end if */
        }
        end_while_1:;
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE get_key_press ****/


extern errcode stableOPcreate();
extern errcode stableOPinsert();
struct OPS *stable_of_int_table;
struct OPS *stable_of_int_ops;
struct OPS *stable_of_int_ops;
OWNPTR stable_of_int_owns;
CLUREF STR__001;
CLUREF STR__002;
CLUREF STR__004;
CLUREF STR__005;
CLUREF STR__006;
CLUREF STR__012;
CLUREF STR__013;
CLUREF STR__015;
CLUREF STR__016;
CLUREF STR__020;
CLUREF STR__025;
CLUREF STR__027;
CLUREF STR__177;
CLUREF STR__033_1332_176;
CLUREF STR__033_1333_176;
CLUREF STR__033_133A;
CLUREF STR__033_133B;
CLUREF STR__033_133C;
CLUREF STR__033_1336_176;
CLUREF STR__033_1335_176;
CLUREF STR__033;
static int setup_default_keytable_own_init = 0;

/**** BEGIN PROCEDURE setup_default_keytable ****/

errcode setup_default_keytable(ret_1)
CLUREF *ret_1;
    {
    errcode err;
    errcode ecode2;
    CLUREF temp;
        if (setup_default_keytable_own_init == 0) {
        add_parm_info_type(0, int_ops, stable_of_value_t_reqs);
        find_type_instance(stable_ops, 1, &stable_ownreqs, &(stable_of_int_ops));
        stringOPcons("\001", CLU_1, CLU_1, &STR__001);
        stringOPcons("\002", CLU_1, CLU_1, &STR__002);
        stringOPcons("\004", CLU_1, CLU_1, &STR__004);
        stringOPcons("\005", CLU_1, CLU_1, &STR__005);
        stringOPcons("\006", CLU_1, CLU_1, &STR__006);
        stringOPcons("\n", CLU_1, CLU_1, &STR__012);
        stringOPcons("\v", CLU_1, CLU_1, &STR__013);
        stringOPcons("\r", CLU_1, CLU_1, &STR__015);
        stringOPcons("\016", CLU_1, CLU_1, &STR__016);
        stringOPcons("\020", CLU_1, CLU_1, &STR__020);
        stringOPcons("\025", CLU_1, CLU_1, &STR__025);
        stringOPcons("\027", CLU_1, CLU_1, &STR__027);
        stringOPcons("\177", CLU_1, CLU_1, &STR__177);
        stringOPcons("\033[2~", CLU_1, CLU_4, &STR__033_1332_176);
        stringOPcons("\033[3~", CLU_1, CLU_4, &STR__033_1333_176);
        stringOPcons("\033[A", CLU_1, CLU_3, &STR__033_133A);
        stringOPcons("\033[B", CLU_1, CLU_3, &STR__033_133B);
        stringOPcons("\033[C", CLU_1, CLU_3, &STR__033_133C);
        stringOPcons("\033[D", CLU_1, CLU_3, &STR__033_133D);
        stringOPcons("\033[6~", CLU_1, CLU_4, &STR__033_1336_176);
        stringOPcons("\033[5~", CLU_1, CLU_4, &STR__033_1335_176);
        stringOPcons("\033", CLU_1, CLU_1, &STR__033);
        setup_default_keytable_own_init = 1;
    }
    enter_proc(306);

  LINE(307);
    {
        {CLUREF T_1_1;
        generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
        generic_CLU_proc.proc = stableOPcreate;
        CUR_PROC_VAR.proc = &generic_CLU_proc;
        err = stableOPcreate(&T_1_1);
        if (err != ERR_ok) goto ex_0;
        temp.num = T_1_1.num;
        }
        }

  LINE(308);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__001, CLU_7);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(309);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__002, CLU_2);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(310);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__004, CLU_10);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(311);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__005, CLU_6);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(312);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__006, CLU_3);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(313);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__012, CLU_8);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(314);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__013, CLU_11);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(315);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__015, CLU_8);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(316);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__016, CLU_15);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(317);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__020, CLU_14);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(318);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__025, CLU_13);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(319);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__027, CLU_16);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(320);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__177, CLU_9);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(321);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_1332_176, CLU_12);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(322);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_1333_176, CLU_11);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(323);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_133A, CLU_14);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(324);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_133B, CLU_15);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(325);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_133C, CLU_3);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(326);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_133D, CLU_2);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(327);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_1336_176, CLU_17);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(328);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033_1335_176, CLU_18);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(329);
    {
    generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
    generic_CLU_proc.proc = stableOPinsert;
    CUR_PROC_VAR.proc = &generic_CLU_proc;
    err = stableOPinsert(temp, STR__033, CLU_7);
    if (err != ERR_ok) goto ex_0;
    }

  LINE(330);
    {
    {
    ret_1->num = temp.num;
    }
    {signal (ERR_ok);}}
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE setup_default_keytable ****/


extern errcode _home_dir();
extern errcode overload_keytable_file();
extern errcode file_nameOPparse();
extern errcode _system_root();
extern errcode setup_default_keytable();
struct OPS *stable_of_int_table;
struct OPS *stable_of_int_ops;
struct OPS *stable_of_int_ops;
OWNPTR stable_of_int_owns;
CLUREF STR__057lineedit_056keys;
CLUREF STR__057_056inputrc;
CLUREF STR__057_056lineedit_056keys;
static int setup_keytable_own_init = 0;

/**** BEGIN PROCEDURE setup_keytable ****/

errcode setup_keytable(ret_1)
CLUREF *ret_1;
    {
    errcode err;
    errcode ecode2;
    CLUREF temp_table;
    CLUREF hd;
        if (setup_keytable_own_init == 0) {
        add_parm_info_type(0, int_ops, stable_of_value_t_reqs);
        find_type_instance(stable_ops, 1, &stable_ownreqs, &(stable_of_int_ops));
        stringOPcons("", CLU_1, CLU_0, &STR_);
        stringOPcons("/lineedit.keys", CLU_1, CLU_14, &STR__057lineedit_056keys);
        stringOPcons("/.inputrc", CLU_1, CLU_9, &STR__057_056inputrc);
        stringOPcons("/.lineedit.keys", CLU_1, CLU_15, &STR__057_056lineedit_056keys);
        setup_keytable_own_init = 1;
    }
    enter_proc(333);

  LINE(342);
    {
        {CLUREF T_1_1;
        generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
        generic_CLU_proc.proc = stableOPcreate;
        CUR_PROC_VAR.proc = &generic_CLU_proc;
        err = stableOPcreate(&T_1_1);
        if (err != ERR_ok) goto ex_0;
        temp_table.num = T_1_1.num;
        }
        }

  LINE(343);
    {
        {CLUREF T_1_1;
        err = _home_dir(STR_, &T_1_1);
        if (err != ERR_ok) goto ex_0;
        hd.num = T_1_1.num;
        }
        }

  LINE(344);
    {
    CLUREF T_2_1;
    CLUREF T_2_2;
    CLUREF T_2_3;
    err = _system_root(&T_2_1);
    if (err != ERR_ok) goto ex_1;
    err = stringOPconcat(T_2_1, STR__057lineedit_056keys, &T_2_2);
    if (err != ERR_ok) goto ex_1;
    err = file_nameOPparse(T_2_2, &T_2_3);
    if (err != ERR_ok) goto ex_1;
    err = overload_keytable_file(temp_table, T_2_3);
    if (err != ERR_ok) goto ex_1;
    }
        goto end_1;
        ex_1:
            if ((err == ERR_not_found)) {

  LINE(347);
                {
                CLUREF T_2_1;
                err = setup_default_keytable(&T_2_1);
                if (err != ERR_ok) goto ex_0;
                temp_table.num = T_2_1.num;
                }
            }
            else {
                goto ex_0;
            }
        end_1:;

  LINE(349);
    {
    CLUREF T_2_1;
    CLUREF T_2_2;
    err = stringOPconcat(hd, STR__057_056inputrc, &T_2_1);
    if (err != ERR_ok) goto ex_2;
    err = file_nameOPparse(T_2_1, &T_2_2);
    if (err != ERR_ok) goto ex_2;
    err = overload_keytable_file(temp_table, T_2_2);
    if (err != ERR_ok) goto ex_2;
    }
        goto end_2;
        ex_2:
            if ((err == ERR_not_found)) {
            }
            else {
                goto ex_0;
            }
        end_2:;

  LINE(351);
    {
    CLUREF T_2_1;
    CLUREF T_2_2;
    err = stringOPconcat(hd, STR__057_056lineedit_056keys, &T_2_1);
    if (err != ERR_ok) goto ex_3;
    err = file_nameOPparse(T_2_1, &T_2_2);
    if (err != ERR_ok) goto ex_3;
    err = overload_keytable_file(temp_table, T_2_2);
    if (err != ERR_ok) goto ex_3;
    }
        goto end_3;
        ex_3:
            if ((err == ERR_not_found)) {
            }
            else {
                goto ex_0;
            }
        end_3:;

  LINE(353);
    {
    {
    ret_1->num = temp_table.num;
    }
    {signal (ERR_ok);}}
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE setup_keytable ****/


extern errcode streamOPopen();
extern errcode replace();
extern errcode streamOPgetl();
extern errcode charOPequal();
extern errcode streamOPputl();
extern errcode streamOPerror_output();
extern errcode file_nameOPunparse();
extern errcode upper_case();
extern errcode stringOPindexs();
extern errcode stableOPdelete();
extern errcode streamOPclose();
struct OPS *stable_of_int_table;
struct OPS *stable_of_int_ops;
struct OPS *stable_of_int_ops;
OWNPTR stable_of_int_owns;
CLUREF STR_read;
CLUREF STR__011;
CLUREF STR_format_040error_040in_040;
CLUREF STR_line_072_040;
CLUREF STR_c_055;
CLUREF STR_C_055;
CLUREF STR_CTRL_055;
CLUREF STR_CONTROL_055;
CLUREF STR_ESC;
CLUREF STR_META_055;
CLUREF STR_MET_055;
CLUREF STR_M_055;
CLUREF STR_SPACE;
CLUREF STR_DEL;
CLUREF STR_RUBOUT;
CLUREF STR_NEWLINE;
CLUREF STR_RETURN;
CLUREF STR_TAB;
CLUREF STR_LFD;
CLUREF STR__054;
CLUREF STR_COMMA;
CLUREF STR_COLON;
CLUREF STR__072;
CLUREF STR_C_055_177;
CLUREF STR__037;
CLUREF STR_C_055_137;
CLUREF STR_C_055_136;
CLUREF STR__036;
CLUREF STR_C_055_176;
CLUREF STR_C_055_135;
CLUREF STR__035;
CLUREF STR_C_055_133;
CLUREF STR_C_055_040;
CLUREF STR__000;
CLUREF STR_C_055_100;
CLUREF STR__055;
CLUREF STR__137;
CLUREF STR_BEGINNING_137OF_137LINE;
CLUREF STR_END_137OF_137LINE;
CLUREF STR_FORWARD_137CHAR;
CLUREF STR_BACKWARD_137CHAR;
CLUREF STR_FORWARD_137WORD;
CLUREF STR_BACKWARD_137WORD;
CLUREF STR_ACCEPT_137LINE;
CLUREF STR_PREVIOUS_137HISTORY;
CLUREF STR_NEXT_137HISTORY;
CLUREF STR_BEGINNING_137OF_137HISTORY;
CLUREF STR_END_137OF_137HISTORY;
CLUREF STR_DELETE_137CHAR;
CLUREF STR_BACKWARD_137DELETE_137CHAR;
CLUREF STR_QUOTED_137INSERT;
CLUREF STR_UPCASE_137WORD;
CLUREF STR_DOWNCASE_137WORD;
CLUREF STR_KILL_137LINE;
CLUREF STR_KILL_137WORD;
CLUREF STR_YANK;
CLUREF STR_DELETE_137LINE;
CLUREF STR__040Indecipherable_040control_040sequence_040in_040;
static int overload_keytable_file_own_init = 0;

/**** BEGIN PROCEDURE overload_keytable_file ****/

errcode overload_keytable_file(tbl, fn)
CLUREF tbl;
CLUREF fn;
    {
    errcode err;
    errcode ecode2;
    CLUREF str;
    CLUREF why;
    CLUREF line;
    CLUREF pos;
    CLUREF key;
    CLUREF command;
    CLUREF first_ctrl;
    CLUREF ctrl_what;
    CLUREF com;
        if (overload_keytable_file_own_init == 0) {
        add_parm_info_type(0, int_ops, stable_of_value_t_reqs);
        find_type_instance(stable_ops, 1, &stable_ownreqs, &(stable_of_int_ops));
        stringOPcons("read", CLU_1, CLU_4, &STR_read);
        stringOPcons(" ", CLU_1, CLU_1, &STR__040);
        stringOPcons("", CLU_1, CLU_0, &STR_);
        stringOPcons("\t", CLU_1, CLU_1, &STR__011);
        stringOPcons("format error in ", CLU_1, CLU_16, &STR_format_040error_040in_040);
        stringOPcons("line: ", CLU_1, CLU_6, &STR_line_072_040);
        stringOPcons("c-", CLU_1, CLU_2, &STR_c_055);
        stringOPcons("C-", CLU_1, CLU_2, &STR_C_055);
        stringOPcons("CTRL-", CLU_1, CLU_5, &STR_CTRL_055);
        stringOPcons("CONTROL-", CLU_1, CLU_8, &STR_CONTROL_055);
        stringOPcons("ESC", CLU_1, CLU_3, &STR_ESC);
        stringOPcons("\033", CLU_1, CLU_1, &STR__033);
        stringOPcons("META-", CLU_1, CLU_5, &STR_META_055);
        stringOPcons("MET-", CLU_1, CLU_4, &STR_MET_055);
        stringOPcons("M-", CLU_1, CLU_2, &STR_M_055);
        stringOPcons("SPACE", CLU_1, CLU_5, &STR_SPACE);
        stringOPcons("DEL", CLU_1, CLU_3, &STR_DEL);
        stringOPcons("\177", CLU_1, CLU_1, &STR__177);
        stringOPcons("RUBOUT", CLU_1, CLU_6, &STR_RUBOUT);
        stringOPcons("NEWLINE", CLU_1, CLU_7, &STR_NEWLINE);
        stringOPcons("\n", CLU_1, CLU_1, &STR__012);
        stringOPcons("RETURN", CLU_1, CLU_6, &STR_RETURN);
        stringOPcons("TAB", CLU_1, CLU_3, &STR_TAB);
        stringOPcons("LFD", CLU_1, CLU_3, &STR_LFD);
        stringOPcons(",", CLU_1, CLU_1, &STR__054);
        stringOPcons("COMMA", CLU_1, CLU_5, &STR_COMMA);
        stringOPcons("COLON", CLU_1, CLU_5, &STR_COLON);
        stringOPcons(":", CLU_1, CLU_1, &STR__072);
        stringOPcons("C-\177", CLU_1, CLU_3, &STR_C_055_177);
        stringOPcons("\037", CLU_1, CLU_1, &STR__037);
        stringOPcons("C-_", CLU_1, CLU_3, &STR_C_055_137);
        stringOPcons("C-^", CLU_1, CLU_3, &STR_C_055_136);
        stringOPcons("\036", CLU_1, CLU_1, &STR__036);
        stringOPcons("C-~", CLU_1, CLU_3, &STR_C_055_176);
        stringOPcons("C-]", CLU_1, CLU_3, &STR_C_055_135);
        stringOPcons("\035", CLU_1, CLU_1, &STR__035);
        stringOPcons("C-[", CLU_1, CLU_3, &STR_C_055_133);
        stringOPcons("C- ", CLU_1, CLU_3, &STR_C_055_040);
        stringOPcons("\000", CLU_1, CLU_1, &STR__000);
        stringOPcons("C-@", CLU_1, CLU_3, &STR_C_055_100);
        stringOPcons("-", CLU_1, CLU_1, &STR__055);
        stringOPcons("_", CLU_1, CLU_1, &STR__137);
        stringOPcons("BEGINNING_OF_LINE", CLU_1, CLU_17, &STR_BEGINNING_137OF_137LINE);
        stringOPcons("END_OF_LINE", CLU_1, CLU_11, &STR_END_137OF_137LINE);
        stringOPcons("FORWARD_CHAR", CLU_1, CLU_12, &STR_FORWARD_137CHAR);
        stringOPcons("BACKWARD_CHAR", CLU_1, CLU_13, &STR_BACKWARD_137CHAR);
        stringOPcons("FORWARD_WORD", CLU_1, CLU_12, &STR_FORWARD_137WORD);
        stringOPcons("BACKWARD_WORD", CLU_1, CLU_13, &STR_BACKWARD_137WORD);
        stringOPcons("ACCEPT_LINE", CLU_1, CLU_11, &STR_ACCEPT_137LINE);
        stringOPcons("PREVIOUS_HISTORY", CLU_1, CLU_16, &STR_PREVIOUS_137HISTORY);
        stringOPcons("NEXT_HISTORY", CLU_1, CLU_12, &STR_NEXT_137HISTORY);
        stringOPcons("BEGINNING_OF_HISTORY", CLU_1, CLU_20, &STR_BEGINNING_137OF_137HISTORY);
        stringOPcons("END_OF_HISTORY", CLU_1, CLU_14, &STR_END_137OF_137HISTORY);
        stringOPcons("DELETE_CHAR", CLU_1, CLU_11, &STR_DELETE_137CHAR);
        stringOPcons("BACKWARD_DELETE_CHAR", CLU_1, CLU_20, &STR_BACKWARD_137DELETE_137CHAR);
        stringOPcons("QUOTED_INSERT", CLU_1, CLU_13, &STR_QUOTED_137INSERT);
        stringOPcons("UPCASE_WORD", CLU_1, CLU_11, &STR_UPCASE_137WORD);
        stringOPcons("DOWNCASE_WORD", CLU_1, CLU_13, &STR_DOWNCASE_137WORD);
        stringOPcons("KILL_LINE", CLU_1, CLU_9, &STR_KILL_137LINE);
        stringOPcons("KILL_WORD", CLU_1, CLU_9, &STR_KILL_137WORD);
        stringOPcons("YANK", CLU_1, CLU_4, &STR_YANK);
        stringOPcons("DELETE_LINE", CLU_1, CLU_11, &STR_DELETE_137LINE);
        stringOPcons(" Indecipherable control sequence in ", CLU_1, CLU_36, &STR__040Indecipherable_040control_040sequence_040in_040);
        overload_keytable_file_own_init = 1;
    }
    enter_proc(357);

  LINE(362);
    {
        {CLUREF T_2_1;
        err = streamOPopen(fn, STR_read, &T_2_1);
        if (err != ERR_ok) goto ex_1;
        str.num = T_2_1.num;
        }
        }
        goto end_1;
        ex_1:
            if ((err == ERR_not_possible)) {
            CLUREF why;
            why.num = elist[0].num;

  LINE(363);
                {
                {signal (ERR_not_found);}}
            }
            else {
                goto ex_0;
            }
        end_1:;

  LINE(365);
    for (;;) {
        if (true != true) { break; }

  LINE(366);
        {
            {CLUREF T_3_1;
            CLUREF T_3_2;
            err = streamOPgetl(str, &T_3_1);
            if (err != ERR_ok) goto ex_2;
            err = replace(STR__040, STR_, T_3_1, &T_3_2);
            if (err != ERR_ok) goto ex_2;
            line.num = T_3_2.num;
            }
            }

  LINE(367);
        {
        CLUREF T_3_1;
        err = replace(STR__011, STR_, line, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        line.num = T_3_1.num;
        }

  LINE(370);
        {
        CLUREF T_3_1;
        CLUREF T_3_2;
        CLUREF T_3_3;
        CLUREF T_3_4;
        CLUREF T_3_5;
        T_3_2.num = ((line.str->size != STR_.str->size)? false :
            !(bcmp(line.str->data, STR_.str->data, line.str->size)));
        T_3_1.num = T_3_2.num;
        if (!T_3_2.num) {
            err = stringOPfetch(line, CLU_1, &T_3_3);
            if (err != ERR_ok) goto ex_2;
            T_3_4.ch = '%';
            T_3_5.num = (T_3_3.ch == T_3_4.ch)? true : false;
            T_3_1.num = T_3_5.num;
        }
        if (T_3_1.num == true) {

  LINE(371);
            goto end_while_1;
            }
            }/* end if */

  LINE(374);
        {
            {CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.ch = ':';
            err = stringOPindexc(T_3_1, line, &T_3_2);
            if (err != ERR_ok) goto ex_2;
            pos.num = T_3_2.num;
            }
            }

  LINE(376);
        {
        CLUREF T_3_1;
        T_3_1.num = (pos.num == 0)? true : false;
        if (T_3_1.num == true) {

  LINE(377);
            {
            CLUREF T_4_1;
            CLUREF T_4_2;
            CLUREF T_4_3;
            err = streamOPerror_output(&T_4_1);
            if (err != ERR_ok) goto ex_2;
            err = file_nameOPunparse(fn, &T_4_2);
            if (err != ERR_ok) goto ex_2;
            err = stringOPconcat(STR_format_040error_040in_040, T_4_2, &T_4_3);
            if (err != ERR_ok) goto ex_2;
            err = streamOPputl(T_4_1, T_4_3);
            if (err != ERR_ok) goto ex_2;
            }

  LINE(379);
            {
            CLUREF T_4_1;
            CLUREF T_4_2;
            err = streamOPerror_output(&T_4_1);
            if (err != ERR_ok) goto ex_2;
            err = stringOPconcat(STR_line_072_040, line, &T_4_2);
            if (err != ERR_ok) goto ex_2;
            err = streamOPputl(T_4_1, T_4_2);
            if (err != ERR_ok) goto ex_2;
            }

  LINE(380);
            goto end_while_1;
            }
            }/* end if */

  LINE(383);
        {
            {CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = pos.num - 1;
             if ((T_3_1.num >= 0 && pos.num < 0 && (-1) < 0) || 
                 (T_3_1.num <= 0 && pos.num > 0 && (-1) > 0)) {
                err = ERR_overflow;
                goto ex_2;}
            err = stringOPsubstr(line, CLU_1, T_3_1, &T_3_2);
            if (err != ERR_ok) goto ex_2;
            key.num = T_3_2.num;
            }
            }

  LINE(384);
        {
            {CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            T_3_1.num = pos.num + 1;
             if ((T_3_1.num > 0 && pos.num < 0 && 1 < 0) || 
                 (T_3_1.num < 0 && pos.num > 0 && 1 > 0)) {
                err = ERR_overflow;
                goto ex_2;}
            err = stringOPrest(line, T_3_1, &T_3_2);
            if (err != ERR_ok) goto ex_2;
            err = upper_case(T_3_2, &T_3_3);
            if (err != ERR_ok) goto ex_2;
            command.num = T_3_3.num;
            }
            }

  LINE(385);
        {
        CLUREF T_3_1;
        err = replace(STR_c_055, STR_C_055, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(386);
        {
        CLUREF T_3_1;
        err = replace(STR_CTRL_055, STR_C_055, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(387);
        {
        CLUREF T_3_1;
        err = replace(STR_CONTROL_055, STR_C_055, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(388);
        {
        CLUREF T_3_1;
        err = replace(STR_ESC, STR__033, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(389);
        {
        CLUREF T_3_1;
        err = replace(STR_META_055, STR__033, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(390);
        {
        CLUREF T_3_1;
        err = replace(STR_MET_055, STR__033, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(391);
        {
        CLUREF T_3_1;
        err = replace(STR_M_055, STR__033, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(392);
        {
        CLUREF T_3_1;
        err = replace(STR_SPACE, STR__040, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(393);
        {
        CLUREF T_3_1;
        err = replace(STR_DEL, STR__177, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(394);
        {
        CLUREF T_3_1;
        err = replace(STR_RUBOUT, STR__177, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(395);
        {
        CLUREF T_3_1;
        err = replace(STR_NEWLINE, STR__012, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(396);
        {
        CLUREF T_3_1;
        err = replace(STR_RETURN, STR__012, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(397);
        {
        CLUREF T_3_1;
        err = replace(STR_TAB, STR__011, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(398);
        {
        CLUREF T_3_1;
        err = replace(STR_LFD, STR__012, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(400);
        {
        CLUREF T_3_1;
        err = replace(STR__054, STR_, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(402);
        {
        CLUREF T_3_1;
        err = replace(STR_COMMA, STR__054, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(403);
        {
        CLUREF T_3_1;
        err = replace(STR_COLON, STR__072, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(404);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_177, STR__037, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(405);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_137, STR__037, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(406);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_136, STR__036, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(407);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_176, STR__036, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(408);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_135, STR__035, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(409);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_133, STR__033, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(410);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_040, STR__000, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(411);
        {
        CLUREF T_3_1;
        err = replace(STR_C_055_100, STR__000, key, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        key.num = T_3_1.num;
        }

  LINE(413);
        for (;;) {
            CLUREF T_4_1;
            CLUREF T_4_2;
            CLUREF T_4_3;
            err = stringOPindexs(STR_C_055, key, &T_4_1);
            if (err != ERR_ok) goto ex_3;
            T_4_2.num = (T_4_1.num == 0)? true : false;
            T_4_3.num = T_4_2.num ^ 1;
            if (T_4_3.num != true) { break; }

  LINE(414);
            {
                {CLUREF T_5_1;
                err = stringOPindexs(STR_C_055, key, &T_5_1);
                if (err != ERR_ok) goto ex_3;
                first_ctrl.num = T_5_1.num;
                }
                }

  LINE(415);
            {
                {CLUREF T_5_1;
                CLUREF T_5_2;
                CLUREF T_5_3;
                err = upper_case(key, &T_5_1);
                if (err != ERR_ok) goto ex_3;
                T_5_2.num = first_ctrl.num + 2;
                 if ((T_5_2.num > 0 && first_ctrl.num < 0 && 2 < 0) || 
                     (T_5_2.num < 0 && first_ctrl.num > 0 && 2 > 0)) {
                    err = ERR_overflow;
                    goto ex_3;}
                err = stringOPfetch(T_5_1, T_5_2, &T_5_3);
                if (err != ERR_ok) goto ex_3;
                ctrl_what.num = T_5_3.num;
                }
                }

  LINE(416);
            {
            CLUREF T_5_1;
            CLUREF T_5_2;
            CLUREF T_5_3;
            CLUREF T_5_4;
            CLUREF T_5_5;
            T_5_2.ch = 'A';
            err = charOPge(ctrl_what, T_5_2, &T_5_3);
            if (err != ERR_ok) goto ex_3;
            T_5_1.num = T_5_3.num;
            if (T_5_3.num) {
                T_5_4.ch = 'Z';
                err = charOPle(ctrl_what, T_5_4, &T_5_5);
                if (err != ERR_ok) goto ex_3;
                T_5_1.num = T_5_5.num;
            }
            if (T_5_1.num == true) {

  LINE(417);
                {
                CLUREF T_6_1;
                CLUREF T_6_2;
                CLUREF T_6_3;
                CLUREF T_6_4;
                CLUREF T_6_5;
                CLUREF T_6_6;
                CLUREF T_6_7;
                CLUREF T_6_8;
                CLUREF T_6_9;
                CLUREF T_6_10;
                CLUREF T_6_11;
                T_6_1.num = first_ctrl.num - 1;
                 if ((T_6_1.num >= 0 && first_ctrl.num < 0 && (-1) < 0) || 
                     (T_6_1.num <= 0 && first_ctrl.num > 0 && (-1) > 0)) {
                    err = ERR_overflow;
                    goto ex_3;}
                err = stringOPsubstr(key, CLU_1, T_6_1, &T_6_2);
                if (err != ERR_ok) goto ex_3;
                T_6_3.num = (int)(ctrl_what.ch & 0xff);
                T_6_4.num = 64;
                T_6_5.num = T_6_3.num - T_6_4.num;
                 if ((T_6_5.num >= 0 && T_6_3.num < 0 && (-T_6_4.num) < 0) || 
                     (T_6_5.num <= 0 && T_6_3.num > 0 && (-T_6_4.num) > 0)) {
                    err = ERR_overflow;
                    goto ex_3;}
                err = charOPi2c(T_6_5, &T_6_6);
                if (err != ERR_ok) goto ex_3;
                err = stringOPc2s(T_6_6, &T_6_7);
                if (err != ERR_ok) goto ex_3;
                err = stringOPconcat(T_6_2, T_6_7, &T_6_8);
                if (err != ERR_ok) goto ex_3;
                T_6_9.num = first_ctrl.num + 3;
                 if ((T_6_9.num > 0 && first_ctrl.num < 0 && 3 < 0) || 
                     (T_6_9.num < 0 && first_ctrl.num > 0 && 3 > 0)) {
                    err = ERR_overflow;
                    goto ex_3;}
                err = stringOPrest(key, T_6_9, &T_6_10);
                if (err != ERR_ok) goto ex_3;
                err = stringOPconcat(T_6_8, T_6_10, &T_6_11);
                if (err != ERR_ok) goto ex_3;
                key.num = T_6_11.num;
                }
                }
            else {

  LINE(421);
                {
                key = STR_;
                }
                }}/* end if */
            }
            end_while_2:;
            goto end_3;
            ex_3:
                if ((err == ERR_bounds)) {

  LINE(424);
                    {
                    key = STR_;
                    }
                }
                else {
                    goto ex_2;
                }
            end_3:;

  LINE(429);
        {
        CLUREF T_3_1;
        err = replace(STR__055, STR__137, command, &T_3_1);
        if (err != ERR_ok) goto ex_2;
        command.num = T_3_1.num;
        }

  LINE(430);
        {
            {com.num = 0;
            }
            }

  LINE(431);
        {
        CLUREF T_3_1;
        CLUREF T_3_2;
        T_3_1.num = ((key.str->size != STR_.str->size)? false :
            !(bcmp(key.str->data, STR_.str->data, key.str->size)));
        T_3_2.num = T_3_1.num ^ 1;
        if (T_3_2.num == true) {

  LINE(432);
            {
            CLUREF T_4_1;
            T_4_1.num = ((command.str->size != STR_BEGINNING_137OF_137LINE.str->size)? false :
                !(bcmp(command.str->data, STR_BEGINNING_137OF_137LINE.str->data, command.str->size)));
            if (T_4_1.num == true) {

  LINE(433);
                {
                com.num = 7;
                }
                }
            else {
            CLUREF T_4_2;
            T_4_2.num = ((command.str->size != STR_END_137OF_137LINE.str->size)? false :
                !(bcmp(command.str->data, STR_END_137OF_137LINE.str->data, command.str->size)));
            if (T_4_2.num == true) {

  LINE(435);
                {
                com.num = 6;
                }
                }
            else {
            CLUREF T_4_3;
            T_4_3.num = ((command.str->size != STR_FORWARD_137CHAR.str->size)? false :
                !(bcmp(command.str->data, STR_FORWARD_137CHAR.str->data, command.str->size)));
            if (T_4_3.num == true) {

  LINE(437);
                {
                com.num = 3;
                }
                }
            else {
            CLUREF T_4_4;
            T_4_4.num = ((command.str->size != STR_BACKWARD_137CHAR.str->size)? false :
                !(bcmp(command.str->data, STR_BACKWARD_137CHAR.str->data, command.str->size)));
            if (T_4_4.num == true) {

  LINE(439);
                {
                com.num = 2;
                }
                }
            else {
            CLUREF T_4_5;
            T_4_5.num = ((command.str->size != STR_FORWARD_137WORD.str->size)? false :
                !(bcmp(command.str->data, STR_FORWARD_137WORD.str->data, command.str->size)));
            if (T_4_5.num == true) {

  LINE(441);
                {
                com.num = 17;
                }
                }
            else {
            CLUREF T_4_6;
            T_4_6.num = ((command.str->size != STR_BACKWARD_137WORD.str->size)? false :
                !(bcmp(command.str->data, STR_BACKWARD_137WORD.str->data, command.str->size)));
            if (T_4_6.num == true) {

  LINE(443);
                {
                com.num = 18;
                }
                }
            else {
            CLUREF T_4_7;
            T_4_7.num = ((command.str->size != STR_ACCEPT_137LINE.str->size)? false :
                !(bcmp(command.str->data, STR_ACCEPT_137LINE.str->data, command.str->size)));
            if (T_4_7.num == true) {

  LINE(445);
                {
                com.num = 8;
                }
                }
            else {
            CLUREF T_4_8;
            T_4_8.num = ((command.str->size != STR_PREVIOUS_137HISTORY.str->size)? false :
                !(bcmp(command.str->data, STR_PREVIOUS_137HISTORY.str->data, command.str->size)));
            if (T_4_8.num == true) {

  LINE(447);
                {
                com.num = 14;
                }
                }
            else {
            CLUREF T_4_9;
            T_4_9.num = ((command.str->size != STR_NEXT_137HISTORY.str->size)? false :
                !(bcmp(command.str->data, STR_NEXT_137HISTORY.str->data, command.str->size)));
            if (T_4_9.num == true) {

  LINE(449);
                {
                com.num = 15;
                }
                }
            else {
            CLUREF T_4_10;
            T_4_10.num = ((command.str->size != STR_BEGINNING_137OF_137HISTORY.str->size)? false :
                !(bcmp(command.str->data, STR_BEGINNING_137OF_137HISTORY.str->data, command.str->size)));
            if (T_4_10.num == true) {

  LINE(451);
                {
                com.num = 0;
                }
                }
            else {
            CLUREF T_4_11;
            T_4_11.num = ((command.str->size != STR_END_137OF_137HISTORY.str->size)? false :
                !(bcmp(command.str->data, STR_END_137OF_137HISTORY.str->data, command.str->size)));
            if (T_4_11.num == true) {

  LINE(453);
                {
                com.num = 0;
                }
                }
            else {
            CLUREF T_4_12;
            T_4_12.num = ((command.str->size != STR_DELETE_137CHAR.str->size)? false :
                !(bcmp(command.str->data, STR_DELETE_137CHAR.str->data, command.str->size)));
            if (T_4_12.num == true) {

  LINE(455);
                {
                com.num = 10;
                }
                }
            else {
            CLUREF T_4_13;
            T_4_13.num = ((command.str->size != STR_BACKWARD_137DELETE_137CHAR.str->size)? false :
                !(bcmp(command.str->data, STR_BACKWARD_137DELETE_137CHAR.str->data, command.str->size)));
            if (T_4_13.num == true) {

  LINE(457);
                {
                com.num = 9;
                }
                }
            else {
            CLUREF T_4_14;
            T_4_14.num = ((command.str->size != STR_QUOTED_137INSERT.str->size)? false :
                !(bcmp(command.str->data, STR_QUOTED_137INSERT.str->data, command.str->size)));
            if (T_4_14.num == true) {

  LINE(459);
                {
                com.num = 0;
                }
                }
            else {
            CLUREF T_4_15;
            T_4_15.num = ((command.str->size != STR_UPCASE_137WORD.str->size)? false :
                !(bcmp(command.str->data, STR_UPCASE_137WORD.str->data, command.str->size)));
            if (T_4_15.num == true) {

  LINE(461);
                {
                com.num = 0;
                }
                }
            else {
            CLUREF T_4_16;
            T_4_16.num = ((command.str->size != STR_DOWNCASE_137WORD.str->size)? false :
                !(bcmp(command.str->data, STR_DOWNCASE_137WORD.str->data, command.str->size)));
            if (T_4_16.num == true) {

  LINE(463);
                {
                com.num = 0;
                }
                }
            else {
            CLUREF T_4_17;
            T_4_17.num = ((command.str->size != STR_KILL_137LINE.str->size)? false :
                !(bcmp(command.str->data, STR_KILL_137LINE.str->data, command.str->size)));
            if (T_4_17.num == true) {

  LINE(465);
                {
                com.num = 11;
                }
                }
            else {
            CLUREF T_4_18;
            T_4_18.num = ((command.str->size != STR_KILL_137WORD.str->size)? false :
                !(bcmp(command.str->data, STR_KILL_137WORD.str->data, command.str->size)));
            if (T_4_18.num == true) {

  LINE(467);
                {
                com.num = 16;
                }
                }
            else {
            CLUREF T_4_19;
            T_4_19.num = ((command.str->size != STR_YANK.str->size)? false :
                !(bcmp(command.str->data, STR_YANK.str->data, command.str->size)));
            if (T_4_19.num == true) {

  LINE(469);
                {
                com.num = 12;
                }
                }
            else {
            CLUREF T_4_20;
            T_4_20.num = ((command.str->size != STR_DELETE_137LINE.str->size)? false :
                !(bcmp(command.str->data, STR_DELETE_137LINE.str->data, command.str->size)));
            if (T_4_20.num == true) {

  LINE(471);
                {
                com.num = 13;
                }
                }
            else {

  LINE(473);
                {
                com.num = 0;
                }
                }}}}}}}}}}}}}}}}}}}}}/* end if */

  LINE(476);
            {
            CLUREF T_4_1;
            CLUREF T_4_2;
            T_4_1.num = (com.num == 0)? true : false;
            T_4_2.num = T_4_1.num ^ 1;
            if (T_4_2.num == true) {

  LINE(477);
                {
                generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
                generic_CLU_proc.proc = stableOPinsert;
                CUR_PROC_VAR.proc = &generic_CLU_proc;
                err = stableOPinsert(tbl, key, com);
                if (err != ERR_ok) goto ex_4;
                }
                    goto end_4;
                    ex_4:
                        if ((err == ERR_duplicate)) {

  LINE(478);
                            {
                            generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
                            generic_CLU_proc.proc = stableOPdelete;
                            CUR_PROC_VAR.proc = &generic_CLU_proc;
                            err = stableOPdelete(tbl, key);
                            if (err != ERR_ok) goto ex_2;
                            }

  LINE(479);
                            {
                            generic_CLU_proc.type_owns = stable_of_int_ops->type_owns;
                            generic_CLU_proc.proc = stableOPinsert;
                            CUR_PROC_VAR.proc = &generic_CLU_proc;
                            err = stableOPinsert(tbl, key, com);
                            if (err != ERR_ok) goto ex_2;
                            }
                        }
                        else {
                            goto ex_2;
                        }
                    end_4:;
                }
                }/* end if */
            }
        else {

  LINE(483);
            {
            CLUREF T_4_1;
            CLUREF T_4_2;
            CLUREF T_4_3;
            err = streamOPerror_output(&T_4_1);
            if (err != ERR_ok) goto ex_2;
            err = file_nameOPunparse(fn, &T_4_2);
            if (err != ERR_ok) goto ex_2;
            err = stringOPconcat(STR__040Indecipherable_040control_040sequence_040in_040, T_4_2, &T_4_3);
            if (err != ERR_ok) goto ex_2;
            err = streamOPputl(T_4_1, T_4_3);
            if (err != ERR_ok) goto ex_2;
            }

  LINE(486);
            {
            CLUREF T_4_1;
            CLUREF T_4_2;
            err = streamOPerror_output(&T_4_1);
            if (err != ERR_ok) goto ex_2;
            err = stringOPconcat(STR_line_072_040, line, &T_4_2);
            if (err != ERR_ok) goto ex_2;
            err = streamOPputl(T_4_1, T_4_2);
            if (err != ERR_ok) goto ex_2;
            }
            }}/* end if */
        }
        end_while_1:;
        goto end_2;
        ex_2:
            if ((err == ERR_end_of_file)) {
            }
            else {
                goto ex_0;
            }
        end_2:;

  LINE(490);
    {
    err = streamOPclose(str);
    if (err != ERR_ok) goto ex_0;
    }
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: {signal(ERR_ok);}
    }

/**** END PROCEDURE overload_keytable_file ****/



/**** BEGIN PROCEDURE replace ****/

errcode replace(look_for, new, from, ret_1)
CLUREF look_for;
CLUREF new;
CLUREF from;
CLUREF *ret_1;
    {
    errcode err;
    errcode ecode2;
    CLUREF match_beg;
    enter_proc(494);

  LINE(498);
    {
        {CLUREF T_1_1;
        CLUREF T_1_2;
        CLUREF T_1_3;
        err = upper_case(look_for, &T_1_1);
        if (err != ERR_ok) goto ex_0;
        err = upper_case(from, &T_1_2);
        if (err != ERR_ok) goto ex_0;
        err = stringOPindexs(T_1_1, T_1_2, &T_1_3);
        if (err != ERR_ok) goto ex_0;
        match_beg.num = T_1_3.num;
        }
        }

  LINE(500);
    {
    CLUREF T_1_1;
    T_1_1.num = (match_beg.num == 0)? true : false;
    if (T_1_1.num == true) {

  LINE(501);
        {
        {
        ret_1->num = from.num;
        }
        {signal (ERR_ok);}}
        }
    else {

  LINE(503);
        {
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        CLUREF T_2_3;
        CLUREF T_2_4;
        CLUREF T_2_5;
        CLUREF T_2_6;
        CLUREF T_2_7;
        CLUREF T_2_8;
        T_2_1.num = match_beg.num - 1;
         if ((T_2_1.num >= 0 && match_beg.num < 0 && (-1) < 0) || 
             (T_2_1.num <= 0 && match_beg.num > 0 && (-1) > 0)) {
            err = ERR_overflow;
            goto ex_0;}
        err = stringOPsubstr(from, CLU_1, T_2_1, &T_2_2);
        if (err != ERR_ok) goto ex_0;
        err = stringOPconcat(T_2_2, new, &T_2_3);
        if (err != ERR_ok) goto ex_0;
        err = stringOPsize(look_for, &T_2_4);
        if (err != ERR_ok) goto ex_0;
        T_2_5.num = match_beg.num + T_2_4.num;
         if ((T_2_5.num > 0 && match_beg.num < 0 && T_2_4.num < 0) || 
             (T_2_5.num < 0 && match_beg.num > 0 && T_2_4.num > 0)) {
            err = ERR_overflow;
            goto ex_0;}
        err = stringOPrest(from, T_2_5, &T_2_6);
        if (err != ERR_ok) goto ex_0;
        err = replace(look_for, new, T_2_6, &T_2_7);
        if (err != ERR_ok) goto ex_0;
        err = stringOPconcat(T_2_3, T_2_7, &T_2_8);
        if (err != ERR_ok) goto ex_0;
        ret_1->num = T_2_8.num;
        }
        {signal (ERR_ok);}}
        }}/* end if */
    goto end_0;
    ex_0:
        {
            if (err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE replace ****/


extern errcode lineedit_IB_1();
extern errcode arrayOPnew();
extern errcode arrayOPhigh();
extern errcode streamOPscripts();
extern errcode streamOPrem_script();
extern errcode arrayOPaddh();
extern errcode get_key_press();
extern errcode insert_text();
extern errcode delete_text();
extern errcode arrayOPtop();
extern errcode arrayOPsize();
extern errcode arrayOPreml();
extern errcode arrayOPelements();
extern errcode streamOPadd_script();
extern errcode intOPlt();
extern errcode arrayOPfetch();
extern errcode arrayOPlow();
extern errcode find_word();
CLUREF STR__040_072_073_056_054_057_174;
CLUREF STR__007;
static int lineedit_own_init = 0;
CLUREF lineeditOPhistory;

/**** BEGIN PROCEDURE lineedit ****/

errcode lineedit(str, prompt, ret_1)
CLUREF str;
CLUREF prompt;
CLUREF *ret_1;
    {
    struct {
        errcode err;
        errcode ecode2;
        CLUREF scripted_streams;
        CLUREF kill_ring;
        CLUREF input_line;
        CLUREF current_pos;
        CLUREF curr_hist;
        CLUREF ss;
        CLUREF command;
        CLUREF parameter;
        CLUREF line_length;
        CLUREF left;
        CLUREF right;
        CLUREF new_pos;
        CLUREF str;
        CLUREF prompt;
        } locals;
    locals.str = str;
    locals.prompt = prompt;
        if (lineedit_own_init == 0) {
        stringOPcons("", CLU_1, CLU_0, &STR_);
        stringOPcons("\033[D", CLU_1, CLU_3, &STR__033_133D);
        stringOPcons(" :;.,/|", CLU_1, CLU_7, &STR__040_072_073_056_054_057_174);
        stringOPcons("\007", CLU_1, CLU_1, &STR__007);
        lineedit_own_init = 1;
        {
            {CLUREF T_0_1;
            locals.err = arrayOPnew(&T_0_1);
            if (locals.err != ERR_ok) goto ex_0;
            lineeditOPhistory.num = T_0_1.num;
            }
            }
    }
    enter_proc(528);

  LINE(538);
    {
        {CLUREF T_1_1;
        locals.err = arrayOPnew(&T_1_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.scripted_streams.num = T_1_1.num;
        }
        }

  LINE(539);
    {
        {locals.kill_ring = STR_;
        }
        }

  LINE(540);
    {
        {locals.input_line = STR_;
        }
        }

  LINE(541);
    {
        {locals.current_pos.num = 1;
        }
        }

  LINE(542);
    {
        {CLUREF T_1_1;
        CLUREF T_1_2;
        T_1_1.num = lineeditOPhistory.array->ext_high;
        T_1_2.num = T_1_1.num + 1;
         if ((T_1_2.num > 0 && T_1_1.num < 0 && 1 < 0) || 
             (T_1_2.num < 0 && T_1_1.num > 0 && 1 > 0)) {
            locals.err = ERR_overflow;
            goto ex_0;}
        locals.curr_hist.num = T_1_2.num;
        }
        }

  LINE(544);
    {
    locals.err = streamOPputs(locals.str, locals.prompt);
    if (locals.err != ERR_ok) goto ex_0;
    }

  LINE(546);
    {
        locals.err = streamOPscripts(locals.str, lineedit_IB_1, &locals, &locals.ecode2);
        if (locals.err == ERR_iterbodyreturn) {
        ret_1->num = elist[0].num;
        signal(ERR_ok);}
        if (locals.err == ERR_iterbodysignal) {signal(locals.ecode2);}
        if (locals.err == ERR_break) locals.err = ERR_ok;
        if (locals.err == ERR_iterbodyexit) locals.err = locals.ecode2;
        if (locals.err != ERR_ok) goto ex_0;
        }

  LINE(552);
    for (;;) {
        if (true != true) { break; }

  LINE(553);
        {
            {CLUREF T_2_1;
            CLUREF T_2_2;
            locals.err = get_key_press(locals.str, &T_2_1, &T_2_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.command.num = T_2_1.num;
            locals.parameter.num = T_2_2.num;
            }
            }

  LINE(554);
        {
            {CLUREF T_2_1;
            locals.err = stringOPsize(locals.input_line, &T_2_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.line_length.num = T_2_1.num;
            }
            }

  LINE(556);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.command.num == 1)? true : false;
        if (T_2_1.num == true) {

  LINE(557);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            CLUREF T_3_4;
            locals.err = charOPi2c(locals.parameter, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = stringOPc2s(T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = insert_text(locals.str, T_3_2, locals.input_line, locals.current_pos, &T_3_3, &T_3_4);
            if (locals.err != ERR_ok) goto ex_0;
            locals.input_line.num = T_3_3.num;
            locals.current_pos.num = T_3_4.num;
            }
            }
        else {
        CLUREF T_2_2;
        T_2_2.num = (locals.command.num == 13)? true : false;
        if (T_2_2.num == true) {

  LINE(562);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            locals.err = delete_text(locals.str, locals.input_line, locals.current_pos, CLU_1, locals.line_length, &T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.input_line.num = T_3_1.num;
            locals.current_pos.num = T_3_2.num;
            }
            }
        else {
        CLUREF T_2_3;
        T_2_3.num = (locals.command.num == 8)? true : false;
        if (T_2_3.num == true) {

  LINE(567);
            {
            CLUREF T_4_1;
            CLUREF T_4_2;
            CLUREF T_4_3;
            CLUREF T_4_4;
            CLUREF T_4_5;
            CLUREF T_4_6;
            locals.err = arrayOPtop(lineeditOPhistory, &T_4_2);
            if (locals.err != ERR_ok) goto ex_1;
            T_4_3.num = ((locals.input_line.str->size != T_4_2.str->size)? false :
                !(bcmp(locals.input_line.str->data, T_4_2.str->data, locals.input_line.str->size)));
            T_4_4.num = T_4_3.num ^ 1;
            T_4_1.num = T_4_4.num;
            if (T_4_4.num) {
                T_4_5.num = ((locals.input_line.str->size != STR_.str->size)? false :
                    !(bcmp(locals.input_line.str->data, STR_.str->data, locals.input_line.str->size)));
                T_4_6.num = T_4_5.num ^ 1;
                T_4_1.num = T_4_6.num;
            }
            if (T_4_1.num == true) {

  LINE(568);
                {
                {
                if ((lineeditOPhistory.array->int_low + lineeditOPhistory.array->ext_size + 1) < lineeditOPhistory.array->int_size) {
                    lineeditOPhistory.array->store->data[lineeditOPhistory.array->int_low + lineeditOPhistory.array->ext_size] = locals.input_line.num;
                    lineeditOPhistory.array->ext_size++; lineeditOPhistory.array->ext_high++;}
                else {
                    locals.err = arrayOPaddh(lineeditOPhistory, locals.input_line);
                    if (locals.err != ERR_ok) goto ex_1;}
                }
                }

  LINE(569);
                {
                CLUREF T_5_1;
                CLUREF T_5_2;
                T_5_1.num = lineeditOPhistory.array->ext_size;
                T_5_2.num = (T_5_1.num > 30)? true : false;
                if (T_5_2.num == true) {

  LINE(570);
                    {
                    CLUREF T_6_1;
                    locals.err = arrayOPreml(lineeditOPhistory, &T_6_1);
                    if (locals.err != ERR_ok) goto ex_1;
                    }
                    }
                    }/* end if */
                }
                }/* end if */
                goto end_1;
                ex_1:
                    if ((locals.err == ERR_bounds)) {

  LINE(572);
                        {
                        {
                        if ((lineeditOPhistory.array->int_low + lineeditOPhistory.array->ext_size + 1) < lineeditOPhistory.array->int_size) {
                            lineeditOPhistory.array->store->data[lineeditOPhistory.array->int_low + lineeditOPhistory.array->ext_size] = locals.input_line.num;
                            lineeditOPhistory.array->ext_size++; lineeditOPhistory.array->ext_high++;}
                        else {
                            locals.err = arrayOPaddh(lineeditOPhistory, locals.input_line);
                            if (locals.err != ERR_ok) goto ex_0;}
                        }
                        }
                    }
                    else {
                        goto ex_0;
                    }
                end_1:;

  LINE(574);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
                T_3_2.num = locals.scripted_streams.array->ext_high; 
                T_3_3 = locals.scripted_streams;
                for (T_3_1.num = locals.scripted_streams.array->ext_low; T_3_1.num <= T_3_2.num; T_3_1.num++) {
                    if (T_3_1.num > T_3_3.array->ext_high || T_3_1.num < T_3_3.array->ext_low) {
                        locals.err = ERR_failure;
                        elist[0].str = array_bounds_exception_STRING;
                        goto ex_0;}
                    locals.ss.num = T_3_3.array->store->data[T_3_1.num - T_3_3.array->ext_low + T_3_3.array->int_low];

  LINE(575);
                    {
                    locals.err = streamOPputs(locals.ss, locals.input_line);
                    if (locals.err != ERR_ok) goto ex_0;
                    }

  LINE(576);
                    {
                    locals.err = streamOPadd_script(locals.str, locals.ss);
                    if (locals.err != ERR_ok) goto ex_0;
                    }
                }
            }
            end_inline_for_1:;

  LINE(581);
            {
            {
            ret_1->num = locals.input_line.num;
            }
            {signal (ERR_ok);}}
            }
        else {
        CLUREF T_2_4;
        T_2_4.num = (locals.command.num == 7)? true : false;
        if (T_2_4.num == true) {

  LINE(584);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = locals.current_pos.num - 1;
             if ((T_3_1.num >= 0 && locals.current_pos.num < 0 && (-1) < 0) || 
                 (T_3_1.num <= 0 && locals.current_pos.num > 0 && (-1) > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            locals.err = fill(STR__033_133D, T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = streamOPputs(locals.str, T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            }

  LINE(585);
            {
            locals.current_pos.num = 1;
            }
            }
        else {
        CLUREF T_2_5;
        T_2_5.num = (locals.command.num == 2)? true : false;
        if (T_2_5.num == true) {

  LINE(588);
            {
            CLUREF T_3_1;
            T_3_1.num = (locals.current_pos.num > 1)? true : false;
            if (T_3_1.num == true) {

  LINE(589);
                {
                CLUREF T_4_1;
                T_4_1.num = locals.current_pos.num - 1;
                 if ((T_4_1.num >= 0 && locals.current_pos.num < 0 && (-1) < 0) || 
                     (T_4_1.num <= 0 && locals.current_pos.num > 0 && (-1) > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                locals.current_pos.num = T_4_1.num;
                }

  LINE(590);
                {
                locals.err = streamOPputs(locals.str, STR__033_133D);
                if (locals.err != ERR_ok) goto ex_0;
                }
                }
                }/* end if */
            }
        else {
        CLUREF T_2_6;
        T_2_6.num = (locals.command.num == 10)? true : false;
        if (T_2_6.num == true) {

  LINE(594);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            locals.err = delete_text(locals.str, locals.input_line, locals.current_pos, locals.current_pos, locals.current_pos, &T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.input_line.num = T_3_1.num;
            locals.current_pos.num = T_3_2.num;
            }
            }
        else {
        CLUREF T_2_7;
        T_2_7.num = (locals.command.num == 6)? true : false;
        if (T_2_7.num == true) {

  LINE(598);
            {
            CLUREF T_3_1;
            locals.err = stringOPrest(locals.input_line, locals.current_pos, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = streamOPputs(locals.str, T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            }

  LINE(600);
            {
            CLUREF T_3_1;
            T_3_1.num = locals.line_length.num + 1;
             if ((T_3_1.num > 0 && locals.line_length.num < 0 && 1 < 0) || 
                 (T_3_1.num < 0 && locals.line_length.num > 0 && 1 > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            locals.current_pos.num = T_3_1.num;
            }
            }
        else {
        CLUREF T_2_8;
        T_2_8.num = (locals.command.num == 3)? true : false;
        if (T_2_8.num == true) {

  LINE(603);
            {
            CLUREF T_3_1;
            T_3_1.num = (locals.current_pos.num <= locals.line_length.num)? true : false;
            if (T_3_1.num == true) {

  LINE(604);
                {
                CLUREF T_4_1;
                locals.err = stringOPsubstr(locals.input_line, locals.current_pos, CLU_1, &T_4_1);
                if (locals.err != ERR_ok) goto ex_0;
                locals.err = streamOPputs(locals.str, T_4_1);
                if (locals.err != ERR_ok) goto ex_0;
                }

  LINE(606);
                {
                CLUREF T_4_1;
                T_4_1.num = locals.current_pos.num + 1;
                 if ((T_4_1.num > 0 && locals.current_pos.num < 0 && 1 < 0) || 
                     (T_4_1.num < 0 && locals.current_pos.num > 0 && 1 > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                locals.current_pos.num = T_4_1.num;
                }
                }
                }/* end if */
            }
        else {
        CLUREF T_2_9;
        T_2_9.num = (locals.command.num == 11)? true : false;
        if (T_2_9.num == true) {

  LINE(610);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            T_3_1.num = locals.line_length.num - locals.current_pos.num;
             if ((T_3_1.num >= 0 && locals.line_length.num < 0 && (-locals.current_pos.num) < 0) || 
                 (T_3_1.num <= 0 && locals.line_length.num > 0 && (-locals.current_pos.num) > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            T_3_2.num = T_3_1.num + 1;
             if ((T_3_2.num > 0 && T_3_1.num < 0 && 1 < 0) || 
                 (T_3_2.num < 0 && T_3_1.num > 0 && 1 > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            locals.err = stringOPsubstr(locals.input_line, locals.current_pos, T_3_2, &T_3_3);
            if (locals.err != ERR_ok) goto ex_0;
            locals.kill_ring.num = T_3_3.num;
            }

  LINE(612);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            locals.err = delete_text(locals.str, locals.input_line, locals.current_pos, locals.current_pos, locals.line_length, &T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.input_line.num = T_3_1.num;
            locals.current_pos.num = T_3_2.num;
            }
            }
        else {
        CLUREF T_2_10;
        T_2_10.num = (locals.command.num == 12)? true : false;
        if (T_2_10.num == true) {

  LINE(616);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            locals.err = insert_text(locals.str, locals.kill_ring, locals.input_line, locals.current_pos, &T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.input_line.num = T_3_1.num;
            locals.current_pos.num = T_3_2.num;
            }
            }
        else {
        CLUREF T_2_11;
        T_2_11.num = (locals.command.num == 9)? true : false;
        if (T_2_11.num == true) {

  LINE(620);
            {
            CLUREF T_3_1;
            T_3_1.num = (locals.current_pos.num > 1)? true : false;
            if (T_3_1.num == true) {

  LINE(621);
                {
                CLUREF T_4_1;
                CLUREF T_4_2;
                CLUREF T_4_3;
                CLUREF T_4_4;
                T_4_1.num = locals.current_pos.num - 1;
                 if ((T_4_1.num >= 0 && locals.current_pos.num < 0 && (-1) < 0) || 
                     (T_4_1.num <= 0 && locals.current_pos.num > 0 && (-1) > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                T_4_2.num = locals.current_pos.num - 1;
                 if ((T_4_2.num >= 0 && locals.current_pos.num < 0 && (-1) < 0) || 
                     (T_4_2.num <= 0 && locals.current_pos.num > 0 && (-1) > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                locals.err = delete_text(locals.str, locals.input_line, locals.current_pos, T_4_1, T_4_2, &T_4_3, &T_4_4);
                if (locals.err != ERR_ok) goto ex_0;
                locals.input_line.num = T_4_3.num;
                locals.current_pos.num = T_4_4.num;
                }
                }
                }/* end if */
            }
        else {
        CLUREF T_2_12;
        T_2_12.num = (locals.command.num == 15)? true : false;
        if (T_2_12.num == true) {

  LINE(626);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            locals.err = delete_text(locals.str, locals.input_line, locals.current_pos, CLU_1, locals.line_length, &T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.input_line.num = T_3_1.num;
            locals.current_pos.num = T_3_2.num;
            }

  LINE(629);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = lineeditOPhistory.array->ext_high;
            T_3_2.num = (locals.curr_hist.num == T_3_1.num)? true : false;
            if (T_3_2.num == true) {

  LINE(630);
                {
                CLUREF T_4_1;
                T_4_1.num = locals.curr_hist.num + 1;
                 if ((T_4_1.num > 0 && locals.curr_hist.num < 0 && 1 < 0) || 
                     (T_4_1.num < 0 && locals.curr_hist.num > 0 && 1 > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                locals.curr_hist.num = T_4_1.num;
                }
                }
            else {
            CLUREF T_3_3;
            CLUREF T_3_4;
            T_3_3.num = lineeditOPhistory.array->ext_high;
            T_3_4.num = (locals.curr_hist.num < T_3_3.num)? true : false;
            if (T_3_4.num == true) {

  LINE(632);
                {
                CLUREF T_4_1;
                T_4_1.num = locals.curr_hist.num + 1;
                 if ((T_4_1.num > 0 && locals.curr_hist.num < 0 && 1 < 0) || 
                     (T_4_1.num < 0 && locals.curr_hist.num > 0 && 1 > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                locals.curr_hist.num = T_4_1.num;
                }

  LINE(633);
                {
                CLUREF T_4_1;
                CLUREF T_4_2;
                CLUREF T_4_3;
                if (locals.curr_hist.num < lineeditOPhistory.array->ext_low || locals.curr_hist.num > lineeditOPhistory.array->ext_high ) {
                    locals.err = ERR_bounds;
                    goto ex_0;}
                T_4_1.num = lineeditOPhistory.array->store->data[locals.curr_hist.num - lineeditOPhistory.array->ext_low + lineeditOPhistory.array->int_low];
                locals.err = insert_text(locals.str, T_4_1, locals.input_line, locals.current_pos, &T_4_2, &T_4_3);
                if (locals.err != ERR_ok) goto ex_0;
                locals.input_line.num = T_4_2.num;
                locals.current_pos.num = T_4_3.num;
                }
                }
                }}/* end if */
            }
        else {
        CLUREF T_2_13;
        T_2_13.num = (locals.command.num == 14)? true : false;
        if (T_2_13.num == true) {

  LINE(638);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = lineeditOPhistory.array->ext_low;
            T_3_2.num = (locals.curr_hist.num > T_3_1.num)? true : false;
            if (T_3_2.num == true) {

  LINE(639);
                {
                CLUREF T_4_1;
                T_4_1.num = locals.curr_hist.num - 1;
                 if ((T_4_1.num >= 0 && locals.curr_hist.num < 0 && (-1) < 0) || 
                     (T_4_1.num <= 0 && locals.curr_hist.num > 0 && (-1) > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                locals.curr_hist.num = T_4_1.num;
                }

  LINE(640);
                {
                CLUREF T_4_1;
                CLUREF T_4_2;
                locals.err = delete_text(locals.str, locals.input_line, locals.current_pos, CLU_1, locals.line_length, &T_4_1, &T_4_2);
                if (locals.err != ERR_ok) goto ex_0;
                locals.input_line.num = T_4_1.num;
                locals.current_pos.num = T_4_2.num;
                }

  LINE(642);
                {
                CLUREF T_4_1;
                CLUREF T_4_2;
                CLUREF T_4_3;
                if (locals.curr_hist.num < lineeditOPhistory.array->ext_low || locals.curr_hist.num > lineeditOPhistory.array->ext_high ) {
                    locals.err = ERR_bounds;
                    goto ex_0;}
                T_4_1.num = lineeditOPhistory.array->store->data[locals.curr_hist.num - lineeditOPhistory.array->ext_low + lineeditOPhistory.array->int_low];
                locals.err = insert_text(locals.str, T_4_1, locals.input_line, locals.current_pos, &T_4_2, &T_4_3);
                if (locals.err != ERR_ok) goto ex_0;
                locals.input_line.num = T_4_2.num;
                locals.current_pos.num = T_4_3.num;
                }
                }
                }/* end if */
            }
        else {
        CLUREF T_2_14;
        T_2_14.num = (locals.command.num == 17)? true : false;
        if (T_2_14.num == true) {

  LINE(647);
            {
                {CLUREF T_3_1;
                CLUREF T_3_2;
                locals.err = find_word(locals.input_line, locals.current_pos, STR__040_072_073_056_054_057_174, &T_3_1, &T_3_2);
                if (locals.err != ERR_ok) goto ex_0;
                locals.left.num = T_3_1.num;
                locals.right.num = T_3_2.num;
                }
                }

  LINE(648);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            T_3_1.num = locals.right.num - locals.current_pos.num;
             if ((T_3_1.num >= 0 && locals.right.num < 0 && (-locals.current_pos.num) < 0) || 
                 (T_3_1.num <= 0 && locals.right.num > 0 && (-locals.current_pos.num) > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            T_3_2.num = T_3_1.num + 1;
             if ((T_3_2.num > 0 && T_3_1.num < 0 && 1 < 0) || 
                 (T_3_2.num < 0 && T_3_1.num > 0 && 1 > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            locals.err = stringOPsubstr(locals.input_line, locals.current_pos, T_3_2, &T_3_3);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = streamOPputs(locals.str, T_3_3);
            if (locals.err != ERR_ok) goto ex_0;
            }

  LINE(651);
            {
            CLUREF T_3_1;
            T_3_1.num = locals.right.num + 1;
             if ((T_3_1.num > 0 && locals.right.num < 0 && 1 < 0) || 
                 (T_3_1.num < 0 && locals.right.num > 0 && 1 > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            locals.current_pos.num = T_3_1.num;
            }
            }
        else {
        CLUREF T_2_15;
        T_2_15.num = (locals.command.num == 18)? true : false;
        if (T_2_15.num == true) {

  LINE(654);
            {
                {CLUREF T_3_1;
                CLUREF T_3_2;
                locals.err = find_word(locals.input_line, locals.current_pos, STR__040_072_073_056_054_057_174, &T_3_1, &T_3_2);
                if (locals.err != ERR_ok) goto ex_0;
                locals.left.num = T_3_1.num;
                locals.right.num = T_3_2.num;
                }
                }

  LINE(656);
            {
            CLUREF T_3_1;
            T_3_1.num = (locals.left.num > 1)? true : false;
            if (T_3_1.num == true) {

  LINE(657);
                {
                CLUREF T_4_1;
                T_4_1.num = locals.left.num - 1;
                 if ((T_4_1.num >= 0 && locals.left.num < 0 && (-1) < 0) || 
                     (T_4_1.num <= 0 && locals.left.num > 0 && (-1) > 0)) {
                    locals.err = ERR_overflow;
                    goto ex_0;}
                locals.new_pos.num = T_4_1.num;
                }
                }
            else {

  LINE(659);
                {
                locals.new_pos.num = 1;
                }
                }}/* end if */

  LINE(661);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            T_3_1.num = locals.current_pos.num - locals.new_pos.num;
             if ((T_3_1.num >= 0 && locals.current_pos.num < 0 && (-locals.new_pos.num) < 0) || 
                 (T_3_1.num <= 0 && locals.current_pos.num > 0 && (-locals.new_pos.num) > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            locals.err = fill(STR__033_133D, T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = streamOPputs(locals.str, T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            }

  LINE(662);
            {
            locals.current_pos.num = locals.new_pos.num;
            }
            }
        else {
        CLUREF T_2_16;
        T_2_16.num = (locals.command.num == 16)? true : false;
        if (T_2_16.num == true) {

  LINE(665);
            {
                {CLUREF T_3_1;
                CLUREF T_3_2;
                locals.err = find_word(locals.input_line, locals.current_pos, STR__040_072_073_056_054_057_174, &T_3_1, &T_3_2);
                if (locals.err != ERR_ok) goto ex_0;
                locals.left.num = T_3_1.num;
                locals.right.num = T_3_2.num;
                }
                }

  LINE(666);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            T_3_1.num = locals.right.num - locals.left.num;
             if ((T_3_1.num >= 0 && locals.right.num < 0 && (-locals.left.num) < 0) || 
                 (T_3_1.num <= 0 && locals.right.num > 0 && (-locals.left.num) > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            T_3_2.num = T_3_1.num + 1;
             if ((T_3_2.num > 0 && T_3_1.num < 0 && 1 < 0) || 
                 (T_3_2.num < 0 && T_3_1.num > 0 && 1 > 0)) {
                locals.err = ERR_overflow;
                goto ex_0;}
            locals.err = stringOPsubstr(locals.input_line, locals.left, T_3_2, &T_3_3);
            if (locals.err != ERR_ok) goto ex_0;
            locals.kill_ring.num = T_3_3.num;
            }

  LINE(667);
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            locals.err = delete_text(locals.str, locals.input_line, locals.current_pos, locals.left, locals.right, &T_3_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.input_line.num = T_3_1.num;
            locals.current_pos.num = T_3_2.num;
            }
            }
        else {
        CLUREF T_2_17;
        T_2_17.num = (locals.command.num == 0)? true : false;
        if (T_2_17.num == true) {

  LINE(671);
            {
            locals.err = streamOPputs(locals.str, STR__007);
            if (locals.err != ERR_ok) goto ex_0;
            }
            }
            }}}}}}}}}}}}}}}}}/* end if */
        }
        end_while_1:;
    goto end_0;
    ex_0:
        {
            if (locals.err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(locals.err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE lineedit ****/


/**** BEGIN ITERATOR BODIES for lineedit ****/

errcode lineedit_IB_1(iv_1, locals, iecode)
errcode *iecode;
CLUREF iv_1;
struct {
    errcode err;
    errcode ecode2;
    CLUREF scripted_streams;
    CLUREF kill_ring;
    CLUREF input_line;
    CLUREF current_pos;
    CLUREF curr_hist;
    CLUREF ss;
    CLUREF command;
    CLUREF parameter;
    CLUREF line_length;
    CLUREF left;
    CLUREF right;
    CLUREF new_pos;
    CLUREF str;
    CLUREF prompt;
    } *locals;
{
    locals->ss.num = iv_1.num;
    enter_iter_body_proc(547);

  FB_LINE(547);
    {
    locals->err = streamOPrem_script(locals->str, locals->ss);
    if (locals->err != ERR_ok) goto ex_0;
    }

  FB_LINE(548);
    {
    {
    if ((locals->scripted_streams.array->int_low + locals->scripted_streams.array->ext_size + 1) < locals->scripted_streams.array->int_size) {
        locals->scripted_streams.array->store->data[locals->scripted_streams.array->int_low + locals->scripted_streams.array->ext_size] = locals->ss.num;
        locals->scripted_streams.array->ext_size++; locals->scripted_streams.array->ext_high++;}
    else {
        locals->err = arrayOPaddh(locals->scripted_streams, locals->ss);
        if (locals->err != ERR_ok) goto ex_0;}
    }
    }
    {signal(ERR_ok);}
    ex_0:
        {
            *iecode = locals->err;
            {signal(ERR_iterbodyexit);}}
    end_0: {signal(ERR_ok);}
    }/* end lineedit_IB_1 */

/**** END ITERATOR BODIES for lineedit ****/

