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

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


extern struct dbg_info* dbg_info_trim_head;
#undef MY_TRACE_FLAG
#define MY_TRACE_FLAG trim_head_TRACE
int trim_head_TRACE;
extern struct OPS *int_ops;
static Vlist1 owns_trim_head = {0, 1,{ {0, 2, "_init", &int_ops}
}
};
extern errcode stringOPsize();
extern errcode intOPequal();
extern errcode stringOPfetch();
extern errcode boolOPnot();
extern errcode charOPequal();
extern errcode stringOPrest();
extern errcode intOPadd();
extern errcode intOPgt();
extern OWN_req string_ownreqs;
extern struct OPS *string_ops;
CLUREF STR_;
static int trim_head_own_init = 0;

/**** BEGIN PROCEDURE trim_head ****/

errcode trim_head(s, ret_1)
CLUREF s;
CLUREF *ret_1;
    {
    struct {
        struct dbg_info *DBG_INFO;
        int DBG_LINE;
        errcode err;
        errcode ecode2;
        CLUREF len;
        CLUREF idx;
        CLUREF c;
        CLUREF s;
        } locals;
    locals.len.num = UNINIT;
    locals.idx.num = UNINIT;
    locals.c.num = UNINIT;
    locals.s.num = UNINIT;
    locals.DBG_INFO = dbg_info_trim_head;
    locals.s = s;
        if (trim_head_own_init == 0) {
        stringOPcons("", CLU_1, CLU_0, &STR_);
        trim_head_own_init = 1;
    }
    enter_proc(4);

  LINE(5);
    {
        {CLUREF T_1_1;
        locals.err = stringOPsize(locals.s, &T_1_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.len.num = T_1_1.num;
        }
        }

  LINE(6);
    {
    CLUREF T_1_1;
    T_1_1.num = (locals.len.num == 0)? true : false;
    if (T_1_1.num == true) {
        {
        {
        ret_1->num = locals.s.num;
        }
        {signal (ERR_ok);}}
        }
        }/* end if */

  LINE(7);
    {
        {locals.idx.num = 1;
        }
        }

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

  LINE(9);
        {
            {CLUREF T_2_1;
            locals.err = stringOPfetch(locals.s, locals.idx, &T_2_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.c.num = T_2_1.num;
            }
            }

  LINE(10);
        {
        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;
        T_2_2.ch = ' ';
        T_2_3.num = (locals.c.ch == T_2_2.ch)? true : false;
        T_2_4.num = T_2_3.num ^ 1;
        T_2_1.num = T_2_4.num;
        if (T_2_4.num) {
            T_2_5.ch = '\t';
            T_2_6.num = (locals.c.ch == T_2_5.ch)? true : false;
            T_2_7.num = T_2_6.num ^ 1;
            T_2_1.num = T_2_7.num;
        }
        if (T_2_1.num == true) {

  LINE(11);
            {
            {
            CLUREF T_3_1;
            locals.err = stringOPrest(locals.s, locals.idx, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            ret_1->num = T_3_1.num;
            }
            {signal (ERR_ok);}}
            }
            }/* end if */

  LINE(13);
        {
        CLUREF T_2_1;
        locals.err = intOPadd(locals.idx, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.idx.num = T_2_1.num;
        }

  LINE(14);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.idx.num > locals.len.num)? true : false;
        if (T_2_1.num == true) {
            {
            {
            ret_1->str = STR_.str;
            }
            {signal (ERR_ok);}}
            }
            }/* end if */

  LINE(15);
        {
        CLUREF T_2_1;
        locals.err = stringOPfetch(locals.s, locals.idx, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.c.num = T_2_1.num;
        }
        }
        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 trim_head ****/

extern struct OPS *char_ops;
typedef struct {
    int hdr;
    int count;
    char *name;
    char *fname;
    bool is_iter;
    int is_parmd;
    int addr;
    int nargs;
    Vlist1 *vals;
    siglist0 *sigs;
    Vlist6 *locals;
    Vlist1 *owns;
    Vlist0 *ptowns;
    Vlist0 *popowns;
    Slist0 *type_formals;
    Slist0 *op_formals;
    } dbg_info_trim_head_actual;
static Vlist1 vals_trim_head = {0, 1, { {0, 2, "", &string_ops}}
};
static siglist0 sigs_trim_head = {0, 0};
static Vlist6 locals_trim_head = {0, 6,{ {0, 2, "err", &int_ops},  {0, 2, "ecode2", &int_ops},  {0, 2, "len", &int_ops},  {0, 2, "idx", &int_ops},  {0, 2, "c", &char_ops},  {0, 2, "s", &string_ops}}
};
static Vlist0 popowns_trim_head = {0, 0};
Slist0 tformals_trim_head = {0, 0};
Slist0 opformals_trim_head = {0, 0};
dbg_info_trim_head_actual dbg_info_trim_head_data = {0, 12, 
    "trim_head", "/common/pub/dcurtis-temp/pclu/lib/clu/strim.clu", 0, 0, (int)trim_head, 1, 
    &vals_trim_head, &sigs_trim_head, &locals_trim_head, &owns_trim_head, &NO_VALS, &NO_VALS, &NO_PARMS, &NO_PARMS};
    struct dbg_info *dbg_info_trim_head = (struct dbg_info*)&dbg_info_trim_head_data;

extern struct dbg_info* dbg_info_trim_tail;
#undef MY_TRACE_FLAG
#define MY_TRACE_FLAG trim_tail_TRACE
int trim_tail_TRACE;
static Vlist1 owns_trim_tail = {0, 1,{ {0, 2, "_init", &int_ops}
}
};
extern errcode stringOPsubstr();
extern errcode intOPsub();
static int trim_tail_own_init = 0;

/**** BEGIN PROCEDURE trim_tail ****/

errcode trim_tail(s, ret_1)
CLUREF s;
CLUREF *ret_1;
    {
    struct {
        struct dbg_info *DBG_INFO;
        int DBG_LINE;
        errcode err;
        errcode ecode2;
        CLUREF len;
        CLUREF idx;
        CLUREF c;
        CLUREF s;
        } locals;
    locals.len.num = UNINIT;
    locals.idx.num = UNINIT;
    locals.c.num = UNINIT;
    locals.s.num = UNINIT;
    locals.DBG_INFO = dbg_info_trim_tail;
    locals.s = s;
        if (trim_tail_own_init == 0) {
        stringOPcons("", CLU_1, CLU_0, &STR_);
        trim_tail_own_init = 1;
    }
    enter_proc(19);

  LINE(20);
    {
        {CLUREF T_1_1;
        locals.err = stringOPsize(locals.s, &T_1_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.len.num = T_1_1.num;
        }
        }

  LINE(21);
    {
    CLUREF T_1_1;
    T_1_1.num = (locals.len.num == 0)? true : false;
    if (T_1_1.num == true) {
        {
        {
        ret_1->num = locals.s.num;
        }
        {signal (ERR_ok);}}
        }
        }/* end if */

  LINE(22);
    {
        {locals.idx.num = locals.len.num;
        }
        }

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

  LINE(24);
        {
            {CLUREF T_2_1;
            locals.err = stringOPfetch(locals.s, locals.idx, &T_2_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.c.num = T_2_1.num;
            }
            }

  LINE(25);
        {
        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;
        T_2_2.ch = ' ';
        T_2_3.num = (locals.c.ch == T_2_2.ch)? true : false;
        T_2_4.num = T_2_3.num ^ 1;
        T_2_1.num = T_2_4.num;
        if (T_2_4.num) {
            T_2_5.ch = '\t';
            T_2_6.num = (locals.c.ch == T_2_5.ch)? true : false;
            T_2_7.num = T_2_6.num ^ 1;
            T_2_1.num = T_2_7.num;
        }
        if (T_2_1.num == true) {

  LINE(26);
            {
            {
            CLUREF T_3_1;
            locals.err = stringOPsubstr(locals.s, CLU_1, locals.idx, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            ret_1->num = T_3_1.num;
            }
            {signal (ERR_ok);}}
            }
            }/* end if */

  LINE(28);
        {
        CLUREF T_2_1;
        locals.err = intOPsub(locals.idx, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.idx.num = T_2_1.num;
        }

  LINE(29);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.idx.num == 0)? true : false;
        if (T_2_1.num == true) {
            {
            {
            ret_1->str = STR_.str;
            }
            {signal (ERR_ok);}}
            }
            }/* end if */

  LINE(30);
        {
        CLUREF T_2_1;
        locals.err = stringOPfetch(locals.s, locals.idx, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.c.num = T_2_1.num;
        }
        }
        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 trim_tail ****/

typedef struct {
    int hdr;
    int count;
    char *name;
    char *fname;
    bool is_iter;
    int is_parmd;
    int addr;
    int nargs;
    Vlist1 *vals;
    siglist0 *sigs;
    Vlist6 *locals;
    Vlist1 *owns;
    Vlist0 *ptowns;
    Vlist0 *popowns;
    Slist0 *type_formals;
    Slist0 *op_formals;
    } dbg_info_trim_tail_actual;
static Vlist1 vals_trim_tail = {0, 1, { {0, 2, "", &string_ops}}
};
static siglist0 sigs_trim_tail = {0, 0};
static Vlist6 locals_trim_tail = {0, 6,{ {0, 2, "err", &int_ops},  {0, 2, "ecode2", &int_ops},  {0, 2, "len", &int_ops},  {0, 2, "idx", &int_ops},  {0, 2, "c", &char_ops},  {0, 2, "s", &string_ops}}
};
static Vlist0 popowns_trim_tail = {0, 0};
Slist0 tformals_trim_tail = {0, 0};
Slist0 opformals_trim_tail = {0, 0};
dbg_info_trim_tail_actual dbg_info_trim_tail_data = {0, 12, 
    "trim_tail", "/common/pub/dcurtis-temp/pclu/lib/clu/strim.clu", 0, 0, (int)trim_tail, 1, 
    &vals_trim_tail, &sigs_trim_tail, &locals_trim_tail, &owns_trim_tail, &NO_VALS, &NO_VALS, &NO_PARMS, &NO_PARMS};
    struct dbg_info *dbg_info_trim_tail = (struct dbg_info*)&dbg_info_trim_tail_data;

extern struct dbg_info* dbg_info_trim_both;
#undef MY_TRACE_FLAG
#define MY_TRACE_FLAG trim_both_TRACE
int trim_both_TRACE;
static Vlist1 owns_trim_both = {0, 1,{ {0, 2, "_init", &int_ops}
}
};
static int trim_both_own_init = 0;

/**** BEGIN PROCEDURE trim_both ****/

errcode trim_both(s, ret_1)
CLUREF s;
CLUREF *ret_1;
    {
    struct {
        struct dbg_info *DBG_INFO;
        int DBG_LINE;
        errcode err;
        errcode ecode2;
        CLUREF len;
        CLUREF idx;
        CLUREF c;
        CLUREF s;
        } locals;
    locals.len.num = UNINIT;
    locals.idx.num = UNINIT;
    locals.c.num = UNINIT;
    locals.s.num = UNINIT;
    locals.DBG_INFO = dbg_info_trim_both;
    locals.s = s;
        if (trim_both_own_init == 0) {
        stringOPcons("", CLU_1, CLU_0, &STR_);
        trim_both_own_init = 1;
    }
    enter_proc(34);

  LINE(35);
    {
        {CLUREF T_1_1;
        locals.err = stringOPsize(locals.s, &T_1_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.len.num = T_1_1.num;
        }
        }

  LINE(36);
    {
    CLUREF T_1_1;
    T_1_1.num = (locals.len.num == 0)? true : false;
    if (T_1_1.num == true) {
        {
        {
        ret_1->num = locals.s.num;
        }
        {signal (ERR_ok);}}
        }
        }/* end if */

  LINE(37);
    {
        {locals.idx.num = 1;
        }
        }

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

  LINE(39);
        {
            {CLUREF T_2_1;
            locals.err = stringOPfetch(locals.s, locals.idx, &T_2_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.c.num = T_2_1.num;
            }
            }

  LINE(40);
        {
        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;
        T_2_2.ch = ' ';
        T_2_3.num = (locals.c.ch == T_2_2.ch)? true : false;
        T_2_4.num = T_2_3.num ^ 1;
        T_2_1.num = T_2_4.num;
        if (T_2_4.num) {
            T_2_5.ch = '\t';
            T_2_6.num = (locals.c.ch == T_2_5.ch)? true : false;
            T_2_7.num = T_2_6.num ^ 1;
            T_2_1.num = T_2_7.num;
        }
        if (T_2_1.num == true) {
            goto end_while_1;
            }
            }/* end if */

  LINE(41);
        {
        CLUREF T_2_1;
        locals.err = intOPadd(locals.idx, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.idx.num = T_2_1.num;
        }

  LINE(42);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.idx.num > locals.len.num)? true : false;
        if (T_2_1.num == true) {
            {
            {
            ret_1->str = STR_.str;
            }
            {signal (ERR_ok);}}
            }
            }/* end if */

  LINE(43);
        {
        CLUREF T_2_1;
        locals.err = stringOPfetch(locals.s, locals.idx, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.c.num = T_2_1.num;
        }
        }
        end_while_1:;

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

  LINE(46);
        {
            {CLUREF T_2_1;
            locals.err = stringOPfetch(locals.s, locals.len, &T_2_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.c.num = T_2_1.num;
            }
            }

  LINE(47);
        {
        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;
        T_2_2.ch = ' ';
        T_2_3.num = (locals.c.ch == T_2_2.ch)? true : false;
        T_2_4.num = T_2_3.num ^ 1;
        T_2_1.num = T_2_4.num;
        if (T_2_4.num) {
            T_2_5.ch = '\t';
            T_2_6.num = (locals.c.ch == T_2_5.ch)? true : false;
            T_2_7.num = T_2_6.num ^ 1;
            T_2_1.num = T_2_7.num;
        }
        if (T_2_1.num == true) {

  LINE(48);
            {
            {
            CLUREF T_3_1;
            CLUREF T_3_2;
            CLUREF T_3_3;
            locals.err = intOPsub(locals.len, locals.idx, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = intOPadd(T_3_1, CLU_1, &T_3_2);
            if (locals.err != ERR_ok) goto ex_0;
            locals.err = stringOPsubstr(locals.s, locals.idx, T_3_2, &T_3_3);
            if (locals.err != ERR_ok) goto ex_0;
            ret_1->num = T_3_3.num;
            }
            {signal (ERR_ok);}}
            }
            }/* end if */

  LINE(50);
        {
        CLUREF T_2_1;
        locals.err = intOPsub(locals.len, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.len.num = T_2_1.num;
        }
        }
        end_while_2:;
    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 trim_both ****/

typedef struct {
    int hdr;
    int count;
    char *name;
    char *fname;
    bool is_iter;
    int is_parmd;
    int addr;
    int nargs;
    Vlist1 *vals;
    siglist0 *sigs;
    Vlist6 *locals;
    Vlist1 *owns;
    Vlist0 *ptowns;
    Vlist0 *popowns;
    Slist0 *type_formals;
    Slist0 *op_formals;
    } dbg_info_trim_both_actual;
static Vlist1 vals_trim_both = {0, 1, { {0, 2, "", &string_ops}}
};
static siglist0 sigs_trim_both = {0, 0};
static Vlist6 locals_trim_both = {0, 6,{ {0, 2, "err", &int_ops},  {0, 2, "ecode2", &int_ops},  {0, 2, "len", &int_ops},  {0, 2, "idx", &int_ops},  {0, 2, "c", &char_ops},  {0, 2, "s", &string_ops}}
};
static Vlist0 popowns_trim_both = {0, 0};
Slist0 tformals_trim_both = {0, 0};
Slist0 opformals_trim_both = {0, 0};
dbg_info_trim_both_actual dbg_info_trim_both_data = {0, 12, 
    "trim_both", "/common/pub/dcurtis-temp/pclu/lib/clu/strim.clu", 0, 0, (int)trim_both, 1, 
    &vals_trim_both, &sigs_trim_both, &locals_trim_both, &owns_trim_both, &NO_VALS, &NO_VALS, &NO_PARMS, &NO_PARMS};
    struct dbg_info *dbg_info_trim_both = (struct dbg_info*)&dbg_info_trim_both_data;
