mawk-1.3.4-20240123/0000755000000000000000000000000014554062467012064 5ustar rootrootmawk-1.3.4-20240123/field.h0000644000000000000000000000460214457210044013306 0ustar rootroot/******************************************** field.h copyright 2009-2020,2023 Thomas E. Dickey copyright 1991-1995,2014 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: field.h,v 1.15 2023/07/23 11:33:56 tom Exp $ */ /* field.h */ #ifndef MAWK_FIELD_H #define MAWK_FIELD_H 1 #include "nstd.h" #include "types.h" extern void set_field0(const char *, size_t); extern void split_field0(void); extern void field_assign(CELL *, CELL *); extern char *is_string_split(PTR, size_t *); extern void slow_cell_assign(CELL *, CELL *); extern CELL *slow_field_ptr(int); extern int field_addr_to_index(CELL *); extern void set_binmode(long); #define NUM_PFIELDS 5 extern CELL field[FBANK_SZ + NUM_PFIELDS]; /* $0, $1 ... $(FBANK_SZ-1), NF, RS, RS, CONVFMT, OFMT */ /* more fields if needed go here */ extern CELL **fbankv; /* fbankv[0] == field */ /* index to CELL * for a field */ #define field_ptr(i) ((i) < FBANK_SZ ? field + (i) : slow_field_ptr(i)) /* some, such as RS may be defined in system-headers */ #undef NF #undef RS #undef FS #undef CONVFMT #undef OFMT /* some compilers choke on (NF-field) in a case statement even though it's constant so ... */ #define NF_field FBANK_SZ #define RS_field (FBANK_SZ + 1) #define FS_field (FBANK_SZ + 2) #define CONVFMT_field (FBANK_SZ + 3) #define OFMT_field (FBANK_SZ + 4) /* the pseudo fields, assignment has side effects */ #define NF (field + NF_field) /* must be first */ #define RS (field + RS_field) #define FS (field + FS_field) #define CONVFMT (field + CONVFMT_field) #define OFMT (field + OFMT_field) /* must be last */ #define LAST_PFIELD OFMT extern int nf; /* shadows NF */ /* a shadow type for RS and FS */ #define SEP_SPACE 0 #define SEP_CHAR 1 #define SEP_STR 2 #define SEP_RE 3 #define SEP_MLR 4 typedef struct { char type; char c; PTR ptr; /* STRING* or RE machine* */ } SEPARATOR; extern SEPARATOR rs_shadow; extern CELL fs_shadow; /* types for splitting overflow */ typedef struct spov { struct spov *link; STRING *sval; } SPLIT_OV; extern SPLIT_OV *split_ov_list; #endif /* MAWK_FIELD_H */ mawk-1.3.4-20240123/bi_funct.h0000644000000000000000000000261614457244012014021 0ustar rootroot/******************************************** bi_funct.h copyright 2009-2016,2023 Thomas E. Dickey copyright 1991, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: bi_funct.h,v 1.7 2023/07/23 15:32:26 tom Exp $ */ #ifndef BI_FUNCT_H #define BI_FUNCT_H 1 #include "symtype.h" extern const BI_REC bi_funct[]; void bi_init(void); /* builtin string functions */ CELL *bi_print(CELL *); CELL *bi_printf(CELL *); CELL *bi_length(CELL *); CELL *bi_alength(CELL *); /* length/size of an array */ CELL *bi_index(CELL *); CELL *bi_substr(CELL *); CELL *bi_sprintf(CELL *); CELL *bi_split(CELL *); CELL *bi_match(CELL *); CELL *bi_getline(CELL *); CELL *bi_sub(CELL *); CELL *bi_gsub(CELL *); CELL *bi_toupper(CELL *); CELL *bi_tolower(CELL *); /* builtin arith functions */ CELL *bi_sin(CELL *); CELL *bi_cos(CELL *); CELL *bi_atan2(CELL *); CELL *bi_log(CELL *); CELL *bi_exp(CELL *); CELL *bi_int(CELL *); CELL *bi_sqrt(CELL *); CELL *bi_srand(CELL *); CELL *bi_rand(CELL *); /* time functions */ CELL *bi_mktime(CELL *); CELL *bi_strftime(CELL *); CELL *bi_systime(CELL *); /* other builtins */ CELL *bi_close(CELL *); CELL *bi_system(CELL *); CELL *bi_fflush(CELL *); #endif /* BI_FUNCT_H */ mawk-1.3.4-20240123/code.h0000644000000000000000000000575314467256363013164 0ustar rootroot/******************************************** code.h copyright 2009-2019,2023, Thomas E. Dickey copyright 1991-1994,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: code.h,v 1.14 2023/08/16 23:34:11 tom Exp $ */ /* code.h */ #ifndef MAWK_CODE_H #define MAWK_CODE_H #include #define PAGESZ 512 /* number of code instructions allocated at one time */ #define CODEWARN 16 /* coding scope */ #define SCOPE_MAIN 0 #define SCOPE_BEGIN 1 #define SCOPE_END 2 #define SCOPE_FUNCT 3 typedef struct { INST *base, *limit, *warn, *ptr; } CODEBLOCK; extern CODEBLOCK active_code; extern CODEBLOCK *main_code_p, *begin_code_p, *end_code_p; extern INST *main_start, *begin_start, *end_start; extern size_t main_size, begin_size; extern INST *execution_start; extern INST *next_label; /* next statements jump to here */ extern int dump_code_flag; #define CodeOffset(base) (int)(code_ptr - (base)) #define code_ptr active_code.ptr #define code_base active_code.base #define code_warn active_code.warn #define code_limit active_code.limit #define code_offset CodeOffset(code_base) #define INST_BYTES(x) (sizeof(INST)*(unsigned)(x)) extern CELL eval_stack[]; extern int exit_code; #define code1(x) code_ptr++ -> op = (x) /* shutup picky compilers */ #define code2(x,p) xcode2(x,(PTR)(p)) void xcode2(int, PTR); void code2op(int, int); INST *code_shrink(CODEBLOCK *, size_t *); void code_grow(void); void set_code(void); void be_setup(int); void dump_code(void); /* the machine opcodes */ /* to avoid confusion with a ptr FE_PUSHA must have op code 0 */ typedef enum { FE_PUSHA = 0 ,FE_PUSHI ,F_PUSHA ,F_PUSHI ,NF_PUSHI ,_HALT ,_STOP ,_PUSHC ,_PUSHD ,_PUSHS ,_PUSHINT ,_PUSHA ,_PUSHI ,L_PUSHA ,L_PUSHI ,AE_PUSHA ,AE_PUSHI ,A_PUSHA ,LAE_PUSHA ,LAE_PUSHI ,LA_PUSHA ,_POP ,_ADD ,_SUB ,_MUL ,_DIV ,_MOD ,_POW ,_NOT ,_TEST ,A_TEST ,_LENGTH ,A_LENGTH ,A_DEL ,ALOOP ,A_CAT ,_UMINUS ,_UPLUS ,_ASSIGN ,_ADD_ASG ,_SUB_ASG ,_MUL_ASG ,_DIV_ASG ,_MOD_ASG ,_POW_ASG ,F_ASSIGN ,F_ADD_ASG ,F_SUB_ASG ,F_MUL_ASG ,F_DIV_ASG ,F_MOD_ASG ,F_POW_ASG ,_CAT ,_BUILTIN ,_PRINT ,_POST_INC ,_POST_DEC ,_PRE_INC ,_PRE_DEC ,F_POST_INC ,F_POST_DEC ,F_PRE_INC ,F_PRE_DEC ,_JMP ,_JNZ ,_JZ ,_LJZ ,_LJNZ ,_EQ ,_NEQ ,_LT ,_LTE ,_GT ,_GTE ,_MATCH0 ,_MATCH1 ,_MATCH2 ,_EXIT ,_EXIT0 ,_NEXT ,_NEXTFILE ,_RANGE ,_CALL ,_CALLX ,_RET ,_RET0 ,SET_ALOOP ,POP_AL ,OL_GL ,OL_GL_NR ,_OMAIN ,_JMAIN ,DEL_A } MAWK_OPCODES; #endif /* MAWK_CODE_H */ mawk-1.3.4-20240123/symtype.h0000644000000000000000000001041314465224247013743 0ustar rootroot/******************************************** symtype.h copyright 2009-2020,2023, Thomas E. Dickey copyright 1991, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: symtype.h,v 1.25 2023/08/10 18:12:55 tom Exp $ */ /* types related to symbols are defined here */ #ifndef SYMTYPE_H #define SYMTYPE_H #include typedef unsigned char NUM_ARGS; typedef unsigned char SYM_TYPE; /* struct to hold info about builtins */ typedef struct { const char *name; PF_CP fp; /* ptr to function that does the builtin */ NUM_ARGS min_args, max_args; /* info for parser to check correct number of arguments */ } BI_REC; /*--------------------------- structures and types for arrays *--------------------------*/ #include extern ARRAY Argv; /* for parsing (i,j) in A */ typedef struct { int start; /* offset to code_base */ int cnt; } ARG2_REC; /*------------------------ user defined functions ------------------------*/ typedef struct fblock { const char *name; INST *code; size_t size; NUM_ARGS nargs; SYM_TYPE *typev; /* array of size nargs holding types */ } FBLOCK; /* function block */ extern void add_to_fdump_list(FBLOCK *); extern void dump_funcs(void); extern void dump_regex(void); /*------------------------- elements of the symbol table -----------------------*/ typedef enum { ST_NONE = 0 ,ST_KEYWORD ,ST_BUILTIN /* a pointer to a builtin record */ ,ST_FIELD /* a cell ptr to a field */ ,ST_FUNCT ,ST_NR /* NR is special */ ,ST_ENV /* and so is ENVIRON */ ,ST_VAR = 8 /* a scalar variable (bits from here) */ ,ST_ARRAY = 16 /* a void * ptr to a hash table */ ,ST_LOCAL_NONE = 32 ,ST_LOCAL_VAR = (ST_LOCAL_NONE | ST_VAR) ,ST_LOCAL_ARRAY = (ST_LOCAL_NONE | ST_ARRAY) } SYMTAB_TYPES; #define is_array(stp) (((stp)->type & ST_ARRAY) != 0) #define is_local(stp) (((stp)->type & ST_LOCAL_NONE) != 0) typedef struct { const char *name; SYM_TYPE type; unsigned char offset; /* offset in stack frame for local vars */ #ifdef NO_LEAKS char free_name; #endif union { CELL *cp; int kw; PF_CP fp; const BI_REC *bip; ARRAY array; FBLOCK *fbp; } stval; } SYMTAB; /***************************** structures for type checking function calls ******************************/ typedef struct ca_rec { struct ca_rec *link; SYM_TYPE type; NUM_ARGS arg_num; /* position in callee's stack */ /*--------- this data only set if we'll need to patch -------*/ /* happens if argument is an ID or type ST_NONE or ST_LOCAL_NONE */ int call_offset; unsigned call_lineno; /* where the type is stored */ SYMTAB *sym_p; /* if type is ST_NONE */ SYM_TYPE *type_p; /* if type is ST_LOCAL_NONE */ } CA_REC; /* call argument record */ /* type field of CA_REC matches with ST_ types */ #define CA_EXPR ST_LOCAL_VAR #define CA_ARRAY ST_LOCAL_ARRAY typedef struct fcall { struct fcall *link; FBLOCK *callee; short call_scope; short move_level; FBLOCK *call; /* only used if call_scope == SCOPE_FUNCT */ INST *call_start; /* computed later as code may be moved */ CA_REC *arg_list; NUM_ARGS arg_cnt_checked; } FCALL_REC; /* defer analysis from length() parameter for forward-references */ typedef struct { short offset; FBLOCK *fbp; } DEFER_LEN; extern FCALL_REC *resolve_list; extern void resolve_fcalls(void); extern void check_fcall(FBLOCK * callee, int call_scope, int move_level, FBLOCK * call, CA_REC * arg_list); extern void relocate_resolve_list(int, int, FBLOCK *, int, unsigned, int); /* hash.c */ extern unsigned hash(const char *); extern unsigned hash2(const char *, size_t); extern SYMTAB *insert(const char *); extern SYMTAB *find(const char *); extern const char *reverse_find(int, PTR); extern SYMTAB *save_id(const char *); extern void restore_ids(void); /* error.c */ extern const char *type_to_str(int); extern void type_error(SYMTAB *); #ifdef NO_LEAKS extern void no_leaks_array(ARRAY); #else #define no_leaks_array(a) /* nothing */ #endif #endif /* SYMTYPE_H */ mawk-1.3.4-20240123/regexp.h0000644000000000000000000000201513742421021013504 0ustar rootroot/******************************************** regexp.h copyright 2009-2014,2020, Thomas E. Dickey copyright 2005, Aleksey Cheusov copyright 1991,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: regexp.h,v 1.15 2020/10/16 22:43:29 tom Exp $ */ #ifndef MAWK_REPL_H #define MAWK_REPL_H #include #include "nstd.h" const char *REerror(void); #ifdef LOCAL_REGEXP #include "rexp.h" STATE *REcompile(char *, size_t); void REdestroy(STATE *); int REtest(char *, size_t, STATE *); char *REmatch(char *, size_t, STATE *, size_t *, int); void REmprint(STATE *, FILE *); const char *REs_type(STATE *); #else PTR REcompile(char *, size_t); void REdestroy(PTR); int REtest(char *, size_t, PTR); char *REmatch(char *, size_t, PTR, size_t *, int); void REmprint(PTR, FILE *); #endif #endif /* MAWK_REPL_H */ mawk-1.3.4-20240123/execute.c0000644000000000000000000007556014530763510013676 0ustar rootroot/******************************************** execute.c copyright 2008-2020,2023, Thomas E. Dickey copyright 1991-1995,1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: execute.c,v 1.54 2023/11/27 00:48:08 tom Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include static int compare(CELL *); static UInt d_to_index(double); #ifdef NOINFO_SIGFPE static char dz_msg[] = "division by zero"; #define CHECK_DIVZERO(x) do { if ((x) == 0.0 ) rt_error(dz_msg); } while (0) #endif #define inc_sp() if ( ++sp == stack_danger) eval_overflow() #define dec_sp() if ( sp-- == (stack_base - 1)) eval_underflow() #define SAFETY 16 #define DANGER (EVAL_STACK_SIZE-SAFETY) /* The stack machine that executes the code */ CELL eval_stack[EVAL_STACK_SIZE]; /* these can move for deep recursion */ static CELL *stack_base = eval_stack; static CELL *stack_danger = eval_stack + DANGER; static void eval_overflow(void) { overflow("eval stack", EVAL_STACK_SIZE); } static void eval_underflow(void) { bozo("eval stack underflow"); } /* holds info for array loops (on a stack) */ typedef struct aloop_state { struct aloop_state *link; CELL *var; /* for(var in A) */ STRING **base; STRING **ptr; STRING **limit; } ALOOP_STATE; /* clean up aloop stack on next, return, exit */ #define CLEAR_ALOOP_STACK() \ do { \ if (aloop_state) { \ clear_aloop_stack(aloop_state); \ aloop_state = (ALOOP_STATE *) 0; \ } \ } while (0) static void clear_aloop_stack(ALOOP_STATE * top) { ALOOP_STATE *q; do { while (top->ptr < top->limit) { free_STRING(*top->ptr); top->ptr++; } if (top->base < top->limit) { zfree(top->base, (unsigned) (top->limit - top->base) * sizeof(STRING *)); } q = top; top = q->link; ZFREE(q); } while (top); } INST *next_label; /* control flow label */ void execute(INST * cdp, /* code ptr, start execution here */ CELL *sp, /* eval_stack pointer */ CELL *fp) /* frame ptr into eval_stack for user defined functions */ { static INST *restart_label; /* control flow label */ static CELL tc; /* useful temp */ static CELL missing; /* no value (use zero) */ /* some useful temporaries */ CELL *cp; int t; UInt tu; /* save state for array loops via a stack */ ALOOP_STATE *aloop_state = (ALOOP_STATE *) 0; /* for moving the eval stack on deep recursion */ CELL *old_stack_base = 0; CELL *old_sp = 0; #ifdef DEBUG CELL *entry_sp = sp; #endif if (fp) { /* we are a function call, check for deep recursion */ if (sp > stack_danger) { /* change stacks */ old_stack_base = stack_base; old_sp = sp; stack_base = (CELL *) zmalloc(sizeof(CELL) * EVAL_STACK_SIZE); stack_danger = stack_base + DANGER; sp = stack_base; /* waste 1 slot for ANSI, actually large model msdos breaks in RET if we don't */ #ifdef DEBUG entry_sp = sp; #endif } else old_stack_base = (CELL *) 0; } while (1) { TRACE(("execute %s sp(%ld:%s)\n", da_op_name(cdp), (long) (sp - stack_base), da_type_name(sp))); switch ((cdp++)->op) { /* HALT only used by the disassemble now ; this remains so compilers don't offset the jump table */ case _HALT: case _STOP: /* only for range patterns */ #ifdef DEBUG if (sp != entry_sp + 1) bozo("stop0"); #endif return; case _PUSHC: inc_sp(); cellcpy(sp, (cdp++)->ptr); break; case _PUSHD: inc_sp(); sp->type = C_DOUBLE; sp->dval = *(double *) (cdp++)->ptr; break; case _PUSHS: inc_sp(); sp->type = C_STRING; sp->ptr = (cdp++)->ptr; string(sp)->ref_cnt++; break; case F_PUSHA: cp = (CELL *) cdp->ptr; if (cp != field) { if (nf < 0) split_field0(); if (!(cp >= NF && cp <= LAST_PFIELD)) { /* it is a real field $1, $2 ... If it is greater than $NF, we have to make sure it is set to "" so that (++|--) and g?sub() work right */ t = field_addr_to_index(cp); if (t > nf) { cp->type = C_STRING; cp->ptr = (PTR) & null_str; null_str.ref_cnt++; } } } /* FALLTHRU */ case _PUSHA: case A_PUSHA: inc_sp(); sp->ptr = (cdp++)->ptr; break; case _PUSHI: /* put contents of next address on stack */ inc_sp(); cellcpy(sp, (cdp++)->ptr); break; case L_PUSHI: /* put the contents of a local var on stack, cdp->op holds the offset from the frame pointer */ if (fp != NULL) { inc_sp(); cellcpy(sp, fp + (cdp++)->op); } break; case L_PUSHA: /* put a local address on eval stack */ if (fp != NULL) { inc_sp(); sp->ptr = (PTR) (fp + (cdp++)->op); } break; case F_PUSHI: /* push contents of $i cdp[0] holds & $i , cdp[1] holds i */ inc_sp(); if (nf < 0) split_field0(); cp = (CELL *) cdp->ptr; t = (cdp + 1)->op; cdp += 2; if (t <= nf) cellcpy(sp, cp); else { /* an unset field */ sp->type = C_STRING; sp->ptr = (PTR) & null_str; null_str.ref_cnt++; } break; case NF_PUSHI: inc_sp(); if (nf < 0) split_field0(); cellcpy(sp, NF); break; case FE_PUSHA: if (sp->type != C_DOUBLE) cast1_to_d(sp); tu = d_to_index(sp->dval); if (tu && nf < 0) split_field0(); sp->ptr = (PTR) field_ptr((int) tu); if ((int) tu > nf) { /* make sure it is set to "" */ cp = (CELL *) sp->ptr; cell_destroy(cp); cp->type = C_STRING; cp->ptr = (PTR) & null_str; null_str.ref_cnt++; } break; case FE_PUSHI: if (sp->type != C_DOUBLE) cast1_to_d(sp); tu = d_to_index(sp->dval); if (nf < 0) split_field0(); if ((int) tu <= nf) { cellcpy(sp, field_ptr((int) tu)); } else { sp->type = C_STRING; sp->ptr = (PTR) & null_str; null_str.ref_cnt++; } break; case AE_PUSHA: /* top of stack has an expr, cdp->ptr points at an array, replace the expr with the cell address inside the array */ cp = array_find((ARRAY) (cdp++)->ptr, sp, CREATE); cell_destroy(sp); sp->ptr = (PTR) cp; break; case AE_PUSHI: /* top of stack has an expr, cdp->ptr points at an array, replace the expr with the contents of the cell inside the array */ cp = array_find((ARRAY) (cdp++)->ptr, sp, CREATE); cell_destroy(sp); cellcpy(sp, cp); break; case LAE_PUSHI: /* sp[0] is an expression cdp->op is offset from frame pointer of a CELL which has an ARRAY in the ptr field, replace expr with array[expr] */ if (fp != 0) { cp = array_find((ARRAY) fp[(cdp++)->op].ptr, sp, CREATE); cell_destroy(sp); cellcpy(sp, cp); } break; case LAE_PUSHA: /* sp[0] is an expression cdp->op is offset from frame pointer of a CELL which has an ARRAY in the ptr field, replace expr with & array[expr] */ if (fp != 0) { cp = array_find((ARRAY) fp[(cdp++)->op].ptr, sp, CREATE); cell_destroy(sp); sp->ptr = (PTR) cp; } break; case LA_PUSHA: /* cdp->op is offset from frame pointer of a CELL which has an ARRAY in the ptr field. Push this ARRAY on the eval stack */ if (fp != 0) { inc_sp(); sp->ptr = fp[(cdp++)->op].ptr; } break; case A_LENGTH: /* parameter for length() was ST_NONE; improve it here */ { SYMTAB *stp = (SYMTAB *) cdp->ptr; cdp--; TRACE(("patch/alen %s\n", type_to_str(stp->type))); switch (stp->type) { case ST_VAR: cdp[0].op = _PUSHI; cdp[1].ptr = stp->stval.cp; break; case ST_ARRAY: cdp[0].op = A_PUSHA; cdp[1].ptr = stp->stval.array; assert(cdp[2].op == _BUILTIN); cdp[3].ptr = (PTR) bi_alength; break; case ST_NONE: cdp[0].op = _PUSHI; cdp[1].ptr = &missing; break; default: bozo("execute A_LENGTH"); /* NOTREACHED */ } } /* resume, interpreting the updated code */ break; case _LENGTH: /* parameter for length() was ST_LOCAL_NONE; improve it here */ { DEFER_LEN *dl = (DEFER_LEN *) cdp->ptr; FBLOCK *fbp = dl->fbp; short offset = dl->offset; int type = fbp->typev[offset]; ZFREE(dl); cdp--; TRACE(("patch/len %s\n", type_to_str(type))); switch (type) { case ST_LOCAL_VAR: cdp[0].op = L_PUSHI; cdp[1].op = offset; break; case ST_LOCAL_ARRAY: cdp[0].op = LA_PUSHA; cdp[1].op = offset; assert(cdp[2].op == _BUILTIN); cdp[3].ptr = (PTR) bi_alength; break; case ST_LOCAL_NONE: cdp[0].op = _PUSHI; cdp[1].ptr = &missing; break; default: bozo("execute _LENGTH"); /* NOTREACHED */ } } /* resume, interpreting the updated code */ break; case SET_ALOOP: { ALOOP_STATE *ap = ZMALLOC(ALOOP_STATE); size_t vector_size; ap->var = (CELL *) sp[-1].ptr; ap->base = ap->ptr = array_loop_vector((ARRAY) sp->ptr, &vector_size); ap->limit = ap->base + vector_size; sp -= 2; /* push onto aloop stack */ ap->link = aloop_state; aloop_state = ap; cdp += cdp->op; } break; case ALOOP: { ALOOP_STATE *ap = aloop_state; if (ap != 0 && (ap->ptr < ap->limit)) { cell_destroy(ap->var); ap->var->type = C_STRING; ap->var->ptr = (PTR) * ap->ptr++; cdp += cdp->op; } else { cdp++; } } break; case POP_AL: { /* finish up an array loop */ ALOOP_STATE *ap = aloop_state; if (ap != 0) { aloop_state = ap->link; while (ap->ptr < ap->limit) { free_STRING(*ap->ptr); ap->ptr++; } if (ap->base < ap->limit) { zfree(ap->base, ((unsigned) (ap->limit - ap->base) * sizeof(STRING *))); } ZFREE(ap); } } break; case _POP: cell_destroy(sp); dec_sp(); break; case _ASSIGN: /* top of stack has an expr, next down is an address, put the expression in *address and replace the address with the expression */ /* don't propagate type C_MBSTRN */ if (sp->type == C_MBSTRN) check_strnum(sp); dec_sp(); cell_destroy(((CELL *) sp->ptr)); cellcpy(sp, cellcpy(sp->ptr, sp + 1)); cell_destroy(sp + 1); break; case F_ASSIGN: /* assign to a field */ if (sp->type == C_MBSTRN) check_strnum(sp); dec_sp(); field_assign((CELL *) sp->ptr, sp + 1); cell_destroy(sp + 1); cellcpy(sp, (CELL *) sp->ptr); break; case _ADD_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); #ifdef SW_FP_CHECK /* specific to V7 and XNX23A */ clrerr(); #endif cp->dval += sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = cp->dval; break; case _SUB_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); #ifdef SW_FP_CHECK clrerr(); #endif cp->dval -= sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = cp->dval; break; case _MUL_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); #ifdef SW_FP_CHECK clrerr(); #endif cp->dval *= sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = cp->dval; break; case _DIV_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); #ifdef NOINFO_SIGFPE CHECK_DIVZERO(sp->dval); #endif #ifdef SW_FP_CHECK clrerr(); #endif cp->dval /= sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = cp->dval; break; case _MOD_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); #ifdef NOINFO_SIGFPE CHECK_DIVZERO(sp->dval); #endif cp->dval = fmod(cp->dval, sp->dval); dec_sp(); sp->type = C_DOUBLE; sp->dval = cp->dval; break; case _POW_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); cp->dval = pow(cp->dval, sp->dval); dec_sp(); sp->type = C_DOUBLE; sp->dval = cp->dval; break; case F_ADD_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; cast1_to_d(cellcpy(&tc, cp)); #ifdef SW_FP_CHECK clrerr(); #endif tc.dval += sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = tc.dval; field_assign(cp, &tc); break; case F_SUB_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; cast1_to_d(cellcpy(&tc, cp)); #ifdef SW_FP_CHECK clrerr(); #endif tc.dval -= sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = tc.dval; field_assign(cp, &tc); break; case F_MUL_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; cast1_to_d(cellcpy(&tc, cp)); #ifdef SW_FP_CHECK clrerr(); #endif tc.dval *= sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = tc.dval; field_assign(cp, &tc); break; case F_DIV_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; cast1_to_d(cellcpy(&tc, cp)); #ifdef NOINFO_SIGFPE CHECK_DIVZERO(sp->dval); #endif #ifdef SW_FP_CHECK clrerr(); #endif tc.dval /= sp->dval; dec_sp(); #ifdef SW_FP_CHECK fpcheck(); #endif sp->type = C_DOUBLE; sp->dval = tc.dval; field_assign(cp, &tc); break; case F_MOD_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; cast1_to_d(cellcpy(&tc, cp)); #ifdef NOINFO_SIGFPE CHECK_DIVZERO(sp->dval); #endif tc.dval = fmod(tc.dval, sp->dval); dec_sp(); sp->type = C_DOUBLE; sp->dval = tc.dval; field_assign(cp, &tc); break; case F_POW_ASG: if (sp->type != C_DOUBLE) cast1_to_d(sp); cp = (CELL *) (sp - 1)->ptr; cast1_to_d(cellcpy(&tc, cp)); tc.dval = pow(tc.dval, sp->dval); dec_sp(); sp->type = C_DOUBLE; sp->dval = tc.dval; field_assign(cp, &tc); break; case _ADD: dec_sp(); if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); #ifdef SW_FP_CHECK clrerr(); #endif sp[0].dval += sp[1].dval; #ifdef SW_FP_CHECK fpcheck(); #endif break; case _SUB: dec_sp(); if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); #ifdef SW_FP_CHECK clrerr(); #endif sp[0].dval -= sp[1].dval; #ifdef SW_FP_CHECK fpcheck(); #endif break; case _MUL: dec_sp(); if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); #ifdef SW_FP_CHECK clrerr(); #endif sp[0].dval *= sp[1].dval; #ifdef SW_FP_CHECK fpcheck(); #endif break; case _DIV: dec_sp(); if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); #ifdef NOINFO_SIGFPE CHECK_DIVZERO(sp[1].dval); #endif #ifdef SW_FP_CHECK clrerr(); #endif sp[0].dval /= sp[1].dval; #ifdef SW_FP_CHECK fpcheck(); #endif break; case _MOD: dec_sp(); if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); #ifdef NOINFO_SIGFPE CHECK_DIVZERO(sp[1].dval); #endif sp[0].dval = fmod(sp[0].dval, sp[1].dval); break; case _POW: dec_sp(); if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); sp[0].dval = pow(sp[0].dval, sp[1].dval); break; case _NOT: /* evaluates to 0.0 or 1.0 */ reswitch_1: switch (sp->type) { case C_NOINIT: sp->dval = 1.0; break; case C_DOUBLE: sp->dval = sp->dval != 0.0 ? 0.0 : 1.0; break; case C_STRING: sp->dval = string(sp)->len ? 0.0 : 1.0; free_STRING(string(sp)); break; case C_STRNUM: /* test as a number */ sp->dval = sp->dval != 0.0 ? 0.0 : 1.0; free_STRING(string(sp)); break; case C_MBSTRN: check_strnum(sp); goto reswitch_1; default: bozo("bad type on eval stack"); } sp->type = C_DOUBLE; break; case _TEST: /* evaluates to 0.0 or 1.0 */ reswitch_2: switch (sp->type) { case C_NOINIT: sp->dval = 0.0; break; case C_DOUBLE: sp->dval = sp->dval != 0.0 ? 1.0 : 0.0; break; case C_STRING: sp->dval = string(sp)->len ? 1.0 : 0.0; free_STRING(string(sp)); break; case C_STRNUM: /* test as a number */ sp->dval = sp->dval != 0.0 ? 1.0 : 0.0; free_STRING(string(sp)); break; case C_MBSTRN: check_strnum(sp); goto reswitch_2; default: bozo("bad type on eval stack"); } sp->type = C_DOUBLE; break; case _UMINUS: if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = -sp->dval; break; case _UPLUS: if (sp->type != C_DOUBLE) cast1_to_d(sp); break; case _CAT: { size_t len1, len2; char *str1, *str2; STRING *b; dec_sp(); if (TEST2(sp) != TWO_STRINGS) cast2_to_s(sp); str1 = string(sp)->str; len1 = string(sp)->len; str2 = string(sp + 1)->str; len2 = string(sp + 1)->len; b = new_STRING0(len1 + len2); memcpy(b->str, str1, len1); memcpy(b->str + len1, str2, len2); free_STRING(string(sp)); free_STRING(string(sp + 1)); sp->ptr = (PTR) b; break; } case _PUSHINT: inc_sp(); sp->type = (short) (cdp++)->op; break; case _BUILTIN: case _PRINT: sp = (*(PF_CP) (cdp++)->ptr) (sp); break; case _POST_INC: cp = (CELL *) sp->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); sp->type = C_DOUBLE; sp->dval = cp->dval; cp->dval += 1.0; break; case _POST_DEC: cp = (CELL *) sp->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); sp->type = C_DOUBLE; sp->dval = cp->dval; cp->dval -= 1.0; break; case _PRE_INC: cp = (CELL *) sp->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); sp->dval = cp->dval += 1.0; sp->type = C_DOUBLE; break; case _PRE_DEC: cp = (CELL *) sp->ptr; if (cp->type != C_DOUBLE) cast1_to_d(cp); sp->dval = cp->dval -= 1.0; sp->type = C_DOUBLE; break; case F_POST_INC: cp = (CELL *) sp->ptr; cellcpy(&tc, cp); cast1_to_d(&tc); sp->type = C_DOUBLE; sp->dval = tc.dval; tc.dval += 1.0; field_assign(cp, &tc); break; case F_POST_DEC: cp = (CELL *) sp->ptr; cellcpy(&tc, cp); cast1_to_d(&tc); sp->type = C_DOUBLE; sp->dval = tc.dval; tc.dval -= 1.0; field_assign(cp, &tc); break; case F_PRE_INC: cp = (CELL *) sp->ptr; cast1_to_d(cellcpy(sp, cp)); sp->dval += 1.0; field_assign(cp, sp); break; case F_PRE_DEC: cp = (CELL *) sp->ptr; cast1_to_d(cellcpy(sp, cp)); sp->dval -= 1.0; field_assign(cp, sp); break; case _JMP: cdp += cdp->op; break; case _JNZ: /* jmp if top of stack is non-zero and pop stack */ if (test(sp)) cdp += cdp->op; else cdp++; cell_destroy(sp); dec_sp(); break; case _JZ: /* jmp if top of stack is zero and pop stack */ if (!test(sp)) cdp += cdp->op; else cdp++; cell_destroy(sp); dec_sp(); break; case _LJZ: /* special jump for logical and */ /* this is always preceded by _TEST */ if (sp->dval == 0.0) { /* take jump, but don't pop stack */ cdp += cdp->op; } else { /* pop and don't jump */ dec_sp(); cdp++; } break; case _LJNZ: /* special jump for logical or */ /* this is always preceded by _TEST */ if (sp->dval != 0.0) { /* take jump, but don't pop stack */ cdp += cdp->op; } else { /* pop and don't jump */ dec_sp(); cdp++; } break; /* the relation operations */ /* compare() makes sure string ref counts are OK */ case _EQ: dec_sp(); t = compare(sp); sp->type = C_DOUBLE; sp->dval = t == 0 ? 1.0 : 0.0; break; case _NEQ: dec_sp(); t = compare(sp); sp->type = C_DOUBLE; sp->dval = t ? 1.0 : 0.0; break; case _LT: dec_sp(); t = compare(sp); sp->type = C_DOUBLE; sp->dval = t < 0 ? 1.0 : 0.0; break; case _LTE: dec_sp(); t = compare(sp); sp->type = C_DOUBLE; sp->dval = t <= 0 ? 1.0 : 0.0; break; case _GT: dec_sp(); t = compare(sp); sp->type = C_DOUBLE; sp->dval = t > 0 ? 1.0 : 0.0; break; case _GTE: dec_sp(); t = compare(sp); sp->type = C_DOUBLE; sp->dval = t >= 0 ? 1.0 : 0.0; break; case _MATCH0: /* does $0 match, the RE at cdp? */ inc_sp(); if (field->type >= C_STRING) { sp->type = C_DOUBLE; sp->dval = (REtest(string(field)->str, string(field)->len, cast_to_re((cdp++)->ptr)) ? 1.0 : 0.0); break /* the case */ ; } cellcpy(sp, field); /* FALLTHRU */ case _MATCH1: /* does expr at sp[0] match RE at cdp */ if (sp->type < C_STRING) cast1_to_s(sp); t = REtest(string(sp)->str, string(sp)->len, cast_to_re((cdp++)->ptr)); free_STRING(string(sp)); sp->type = C_DOUBLE; sp->dval = t ? 1.0 : 0.0; break; case _MATCH2: /* does sp[-1] match sp[0] as re */ cast_to_RE(sp); dec_sp(); if (sp->type < C_STRING) cast1_to_s(sp); t = REtest(string(sp)->str, string(sp)->len, cast_to_re((sp + 1)->ptr)); free_STRING(string(sp)); no_leaks_re_ptr((sp + 1)->ptr); sp->type = C_DOUBLE; sp->dval = t ? 1.0 : 0.0; break; case A_TEST: /* entry : sp[0].ptr-> an array sp[-1] is an expression we compute (expression in array) */ dec_sp(); cp = array_find((sp + 1)->ptr, sp, NO_CREATE); cell_destroy(sp); sp->type = C_DOUBLE; sp->dval = (cp != (CELL *) 0) ? 1.0 : 0.0; break; case A_DEL: /* sp[0].ptr -> array sp[-1] is an expr delete array[expr] */ array_delete(sp->ptr, sp - 1); cell_destroy(sp - 1); sp -= 2; break; case DEL_A: /* free all the array at once */ array_clear(sp->ptr); dec_sp(); break; /* form a multiple array index */ case A_CAT: sp = array_cat(sp, (cdp++)->op); break; case _EXIT: if (sp->type != C_DOUBLE) cast1_to_d(sp); exit_code = d_to_i(sp->dval); dec_sp(); /* FALLTHRU */ case _EXIT0: if (!end_start) mawk_exit(exit_code); cdp = end_start; end_start = (INST *) 0; /* makes sure next exit exits */ if (begin_start) { free_codes("BEGIN", begin_start, begin_size); begin_start = 0; begin_size = 0; } if (main_start) { free_codes("MAIN", main_start, main_size); main_start = 0; main_size = 0; } sp = eval_stack - 1; /* might be in user function */ CLEAR_ALOOP_STACK(); /* ditto */ break; case _JMAIN: /* go from BEGIN code to MAIN code */ free_codes("BEGIN", begin_start, begin_size); begin_start = 0; begin_size = 0; cdp = main_start; break; case _OMAIN: if (!main_fin) open_main(); restart_label = cdp; cdp = next_label; break; case _NEXT: /* next might be inside an aloop -- clear stack */ CLEAR_ALOOP_STACK(); cdp = next_label; break; case _NEXTFILE: /* nextfile might be inside an aloop -- clear stack */ CLEAR_ALOOP_STACK(); FINsemi_close(main_fin); cdp = next_label; break; case OL_GL: { char *p; size_t len; if (!(p = FINgets(main_fin, &len))) { if (!end_start) mawk_exit(0); cdp = end_start; zfree(main_start, main_size); main_start = end_start = (INST *) 0; } else { set_field0(p, len); cdp = restart_label; if (cdp == NULL) bozo("empty restart-label"); rt_nr++; rt_fnr++; } } break; /* two kinds of OL_GL is a historical stupidity from working on a machine with very slow floating point emulation */ case OL_GL_NR: { char *p; size_t len; if (!(p = FINgets(main_fin, &len))) { if (!end_start) mawk_exit(0); cdp = end_start; zfree(main_start, main_size); main_start = end_start = (INST *) 0; } else { set_field0(p, len); cdp = restart_label; if (cdp == NULL) bozo("empty restart-label"); if (TEST2(NR) != TWO_DOUBLES) cast2_to_d(NR); NR->dval += 1.0; rt_nr++; FNR->dval += 1.0; rt_fnr++; } } break; case _RANGE: /* test a range pattern: pat1, pat2 { action } entry : cdp[0].op -- a flag, test pat1 if on else pat2 cdp[1].op -- offset of pat2 code from cdp cdp[2].op -- offset of action code from cdp cdp[3].op -- offset of code after the action from cdp cdp[4] -- start of pat1 code */ #define FLAG cdp[0].op #define PAT2 cdp[1].op #define ACTION cdp[2].op #define FOLLOW cdp[3].op #define PAT1 4 if (FLAG) /* test against pat1 */ { execute(cdp + PAT1, sp, fp); t = test(sp + 1); cell_destroy(sp + 1); if (t) FLAG = 0; else { cdp += FOLLOW; break; /* break the switch */ } } /* test against pat2 and then perform the action */ execute(cdp + PAT2, sp, fp); FLAG = test(sp + 1); cell_destroy(sp + 1); cdp += ACTION; break; /* function calls */ case _RET0: inc_sp(); sp->type = C_NOINIT; /* FALLTHRU */ case _RET: #ifdef DEBUG if (sp != entry_sp + 1) bozo("ret"); #endif if (old_stack_base) /* reset stack */ { /* move the return value */ cellcpy(old_sp + 1, sp); cell_destroy(sp); zfree(stack_base, sizeof(CELL) * EVAL_STACK_SIZE); stack_base = old_stack_base; stack_danger = old_stack_base + DANGER; } /* return might be inside an aloop -- clear stack */ CLEAR_ALOOP_STACK(); return; case _CALLX: case _CALL: /* cdp[0] holds ptr to "function block" cdp[1] holds number of input arguments */ { FBLOCK *fbp = (FBLOCK *) (cdp++)->ptr; int a_args = (cdp++)->op; /* actual number of args */ CELL *nfp = sp - a_args + 1; /* new fp for callee */ CELL *local_p = sp + 1; /* first local argument on stack */ SYM_TYPE *type_p = 0; /* pts to type of an argument */ if (fbp->nargs) { type_p = fbp->typev + a_args - 1; /* create space for locals */ t = fbp->nargs - a_args; /* t is number of locals */ while (t > 0) { t--; inc_sp(); type_p++; if (*type_p == ST_LOCAL_ARRAY) { sp->ptr = (PTR) new_ARRAY(); } else { sp->type = C_NOINIT; } } } execute(fbp->code, sp, nfp); /* cleanup the callee's arguments */ /* putting return value at top of eval stack */ if ((type_p != 0) && (sp >= nfp)) { cp = sp + 1; /* cp -> the function return */ do { if (*type_p == ST_LOCAL_ARRAY) { if (sp >= local_p) { array_clear(sp->ptr); ZFREE((ARRAY) sp->ptr); } } else { cell_destroy(sp); } type_p--; dec_sp(); } while (sp >= nfp); inc_sp(); cellcpy(sp, cp); cell_destroy(cp); } else { inc_sp(); /* no arguments passed */ } } break; default: bozo("bad opcode"); } } } /* return 0 if a numeric is zero else return non-zero return 0 if a string is "" else return non-zero */ int test(CELL *cp) { reswitch: switch (cp->type) { case C_NOINIT: return 0; case C_STRNUM: /* test as a number */ case C_DOUBLE: return cp->dval != 0.0; case C_STRING: return (string(cp)->len != 0); case C_MBSTRN: check_strnum(cp); goto reswitch; default: bozo("bad cell type in call to test"); } return 0; /*can't get here: shutup */ } /* compare cells at cp and cp+1 and frees STRINGs at those cells */ static int compare(CELL *cp) { int result; size_t len; reswitch: result = 0; switch (TEST2(cp)) { case TWO_NOINITS: break; case TWO_DOUBLES: two_d: result = ((cp->dval > (cp + 1)->dval) ? 1 : ((cp->dval < (cp + 1)->dval) ? -1 : 0)); break; case TWO_STRINGS: case STRING_AND_STRNUM: two_s: len = string(cp)->len; if (len > string(cp + 1)->len) len = string(cp + 1)->len; result = memcmp(string(cp)->str, string(cp + 1)->str, len); if (result == 0) { if (len != string(cp)->len) { result = 1; } else if (len != string(cp + 1)->len) { result = -1; } } free_STRING(string(cp)); free_STRING(string(cp + 1)); break; case NOINIT_AND_DOUBLE: case NOINIT_AND_STRNUM: case DOUBLE_AND_STRNUM: case TWO_STRNUMS: cast2_to_d(cp); goto two_d; case NOINIT_AND_STRING: case DOUBLE_AND_STRING: cast2_to_s(cp); goto two_s; case TWO_MBSTRNS: check_strnum(cp); check_strnum(cp + 1); goto reswitch; case NOINIT_AND_MBSTRN: case DOUBLE_AND_MBSTRN: case STRING_AND_MBSTRN: case STRNUM_AND_MBSTRN: check_strnum(cp->type == C_MBSTRN ? cp : cp + 1); goto reswitch; default: /* there are no default cases */ bozo("bad cell type passed to compare"); break; } return result; } /* does not assume target was a cell, if so then caller should have made a previous call to cell_destroy */ CELL * cellcpy(CELL *target, CELL *source) { switch (target->type = source->type) { case C_NOINIT: case C_SPACE: case C_SNULL: break; case C_DOUBLE: target->dval = source->dval; break; case C_STRNUM: target->dval = source->dval; /* FALLTHRU */ case C_REPL: case C_MBSTRN: case C_STRING: string(source)->ref_cnt++; /* FALLTHRU */ case C_RE: target->ptr = source->ptr; break; case C_REPLV: replv_cpy(target, source); break; default: bozo("bad cell passed to cellcpy()"); break; } return target; } #ifdef DEBUG void DB_cell_destroy(CELL *cp) { switch (cp->type) { case C_NOINIT: case C_DOUBLE: break; case C_MBSTRN: case C_STRING: case C_STRNUM: free_STRING(string(cp)); break; case C_RE: bozo("cell destroy called on RE cell"); default: bozo("cell destroy called on bad cell type"); } } #endif /* * convert a double d to a field index $d -> $i * * Note: this used to return (unsigned) d_to_I(d), but is done inline to * aid static analysis. */ static UInt d_to_index(double d) { if (d >= (double) Max_Int) { return (UInt) Max_Int; } else if (d >= 0.0) { return (UInt) (Int) (d); } else { /* might include nan */ rt_error("negative field index $%.6g", d); return 0; /* shutup */ } } mawk-1.3.4-20240123/configure.in0000644000000000000000000001015014412413567014364 0ustar rootrootdnl $MawkId: configure.in,v 1.72 2023/04/03 00:01:59 tom Exp $ dnl configure.in for mawk dnl ########################################################################### dnl copyright 2008-2020,2023, Thomas E. Dickey dnl copyright 1991-1994,1995, Michael D. Brennan dnl dnl This is a source file for mawk, an implementation of dnl the AWK programming language. dnl dnl Mawk is distributed without warranty under the terms of dnl the GNU General Public License, version 2, 1991. dnl ########################################################################### dnl AC_PREREQ(2.52.20230114) AC_INIT(mawk.h) AC_CONFIG_HEADER(config.h:config_h.in) CF_CHECK_CACHE AC_ARG_PROGRAM AC_DEFUN([AC_PATH_XTRA],[]) CF_PROG_CC AC_PROG_MAKE_SET CF_MAKEFLAGS CF_MAKE_PHONY AC_PROG_CPP AC_PROG_INSTALL AC_PROG_YACC CF_PROG_LINT CF_MAKE_TAGS CF_XOPEN_SOURCE CF_LARGEFILE AC_CHECK_DECL(exit) CF_HELP_MESSAGE(Cross-compiling) CF_BUILD_CC CF_MAWK_MATHLIB CF_HELP_MESSAGE(Miscellaneous options) CF_DISABLE_ECHO CF_ENABLE_WARNINGS CF_WITH_MAN2HTML ############################################################################### AC_MSG_CHECKING(if you want to use mawk's own regular-expressions engine) AC_ARG_WITH([builtin-regex], [ --without-builtin-regex do not use mawk's own regular-expressions engine], [ with_builtin_regex=$withval ]) if test "x${with_builtin_regex}" != xno; then with_builtin_regex=yes AC_DEFINE(LOCAL_REGEXP,1,[define to 1 to use mawk's own regular-expressions engine]) fi AC_MSG_RESULT($with_builtin_regex) if test "x${with_builtin_regex}" = xno; then CF_REGEX fi ############################################################################### AC_MSG_CHECKING(if you want to use mawk's own srand/rand functions) CF_ARG_ENABLE([builtin-srand], [ --enable-builtin-srand use mawk's own srand/rand functions], [with_builtin_srand=yes], [with_builtin_srand=no]) if test "x${with_builtin_srand}" != xno; then with_builtin_srand=yes fi AC_MSG_RESULT($with_builtin_srand) if test "x${with_builtin_srand}" = xno; then CF_SRAND(mawk_) AC_DEFINE_UNQUOTED(NAME_RANDOM, "$cf_cv_srand_func", [Define to the name of the random-function]) fi ############################################################################### AC_MSG_CHECKING(if you want mawk to initialize random numbers at startup) CF_ARG_DISABLE([init-srand], [ --disable-init-srand suppress automatic initialization of random numbers], [with_init_srand=no], [with_init_srand=yes]) if test "x${with_init_srand}" != xno; then with_init_srand=yes else AC_DEFINE(NO_INIT_SRAND,1,[define to 1 to suppress automatic initialization of random numbers]) fi AC_MSG_RESULT($with_init_srand) ############################################################################### AC_MSG_CHECKING(if you want mawk to support regex interval expressions {m[,]n}) CF_ARG_DISABLE([interval-expr], [ --disable-interval-expr suppress regex interval expressions {m,n}], [with_interval_expr=no], [with_interval_expr=yes]) if test "x${with_interval_expr}" != xno; then with_interval_expr=yes else AC_DEFINE(NO_INTERVAL_EXPR,1,[define to 1 to suppress regex interval expressions {m,n}]) fi AC_MSG_RESULT($with_interval_expr) ############################################################################### CF_HELP_MESSAGE(Testing-options) CF_DISABLE_LEAKS CF_ENABLE_TRACE if test "x$with_trace" = xyes then EXTRAOBJS="$EXTRAOBJS trace\$o" fi AC_SUBST(EXTRAOBJS) AC_CHECK_HEADERS(errno.h fcntl.h sys/wait.h) AC_CHECK_TYPES([int64_t, uint64_t, long long]) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(int64_t) AC_CHECK_SIZEOF(long long) CF_MAWK_FIND_SIZE_T CF_LOCALE CF_CHECK_ENVIRON(environ) AC_CHECK_FUNCS(fork matherr mktime pipe strftime tsearch wait) CF_FUNC_GETTIME ### Checks for libraries. case $cf_cv_system_name in (*mingw32*) CPPFLAGS="$CPPFLAGS -DWINVER=0x0501" # LIBS=" -lpsapi $LIBS" ;; esac test "$ac_cv_func_fork" = yes && \ test "$ac_cv_func_pipe" = yes && \ test "$ac_cv_func_wait" = yes && \ AC_DEFINE(HAVE_REAL_PIPES,1,[Define to 1 if we have functions needed to setup Unix pipes]) CF_SET_MATH_LIB_VERSION CF_MAWK_FIND_MAX_INT CF_MAWK_RUN_FPE_TESTS AC_CONFIG_FILES([Makefile man/Makefile]) AC_OUTPUT mawk-1.3.4-20240123/config.guess0000755000000000000000000014267614471065400014410 0ustar rootroot#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2023 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale timestamp='2023-08-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to . # The "shellcheck disable" line above the timestamp inhibits complaints # about features and limitations of the classic Bourne shell that were # superseded or lifted in POSIX. However, this script identifies a wide # variety of pre-POSIX systems that do not have POSIX shells at all, and # even some reasonably current systems (Solaris 10 as case-in-point) still # have a pre-POSIX /bin/sh. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi # Just in case it came from the environment. GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still # use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. tmp= # shellcheck disable=SC2172 trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 set_cc_for_build() { # prevent multiple calls if $tmp is already set test "$tmp" && return 0 : "${TMPDIR=/tmp}" # shellcheck disable=SC2039,SC3028 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" for driver in cc gcc c89 c99 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD=$driver break fi done if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac } # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case $UNAME_SYSTEM in Linux|GNU|GNU/*) LIBC=unknown set_cc_for_build cat <<-EOF > "$dummy.c" #if defined(__ANDROID__) LIBC=android #else #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu #else #include /* First heuristic to detect musl libc. */ #ifdef __DEFINED_va_list LIBC=musl #endif #endif #endif EOF cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` eval "$cc_set_libc" # Second heuristic to detect musl libc. if [ "$LIBC" = unknown ] && command -v ldd >/dev/null && ldd --version 2>&1 | grep -q ^musl; then LIBC=musl fi # If the system lacks a compiler, then just pick glibc. # We could probably try harder. if [ "$LIBC" = unknown ]; then LIBC=gnu fi ;; esac # Note: order is significant - the case branches are not exclusive. case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` case $UNAME_MACHINE_ARCH in aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case $UNAME_VERSION in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. GUESS=$machine-${os}${release}${abi-} ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE ;; *:SecBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE ;; *:MidnightBSD:*:*) GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE ;; *:ekkoBSD:*:*) GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE ;; *:SolidBSD:*:*) GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE ;; *:OS108:*:*) GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE ;; macppc:MirBSD:*:*) GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE ;; *:MirBSD:*:*) GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE ;; *:Sortix:*:*) GUESS=$UNAME_MACHINE-unknown-sortix ;; *:Twizzler:*:*) GUESS=$UNAME_MACHINE-unknown-twizzler ;; *:Redox:*:*) GUESS=$UNAME_MACHINE-unknown-redox ;; mips:OSF1:*.*) GUESS=mips-dec-osf1 ;; alpha:OSF1:*:*) # Reset EXIT trap before exiting to avoid spurious non-zero exit code. trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` GUESS=$UNAME_MACHINE-dec-osf$OSF_REL ;; Amiga*:UNIX_System_V:4.0:*) GUESS=m68k-unknown-sysv4 ;; *:[Aa]miga[Oo][Ss]:*:*) GUESS=$UNAME_MACHINE-unknown-amigaos ;; *:[Mm]orph[Oo][Ss]:*:*) GUESS=$UNAME_MACHINE-unknown-morphos ;; *:OS/390:*:*) GUESS=i370-ibm-openedition ;; *:z/VM:*:*) GUESS=s390-ibm-zvmoe ;; *:OS400:*:*) GUESS=powerpc-ibm-os400 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) GUESS=arm-acorn-riscix$UNAME_RELEASE ;; arm*:riscos:*:*|arm*:RISCOS:*:*) GUESS=arm-unknown-riscos ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) GUESS=hppa1.1-hitachi-hiuxmpp ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. case `(/bin/universe) 2>/dev/null` in att) GUESS=pyramid-pyramid-sysv3 ;; *) GUESS=pyramid-pyramid-bsd ;; esac ;; NILE*:*:*:dcosx) GUESS=pyramid-pyramid-svr4 ;; DRS?6000:unix:4.0:6*) GUESS=sparc-icl-nx6 ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) GUESS=sparc-icl-nx7 ;; esac ;; s390x:SunOS:*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL ;; sun4H:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-hal-solaris2$SUN_REL ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-sun-solaris2$SUN_REL ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) GUESS=i386-pc-auroraux$UNAME_RELEASE ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=$SUN_ARCH-pc-solaris2$SUN_REL ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-sun-solaris3$SUN_REL ;; sun4*:SunOS:*:*) case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like '4.1.3-JL'. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` GUESS=sparc-sun-sunos$SUN_REL ;; sun3*:SunOS:*:*) GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case `/bin/arch` in sun3) GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac ;; aushp:SunOS:*:*) GUESS=sparc-auspex-sunos$UNAME_RELEASE ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) GUESS=m68k-milan-mint$UNAME_RELEASE ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) GUESS=m68k-hades-mint$UNAME_RELEASE ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) GUESS=m68k-unknown-mint$UNAME_RELEASE ;; m68k:machten:*:*) GUESS=m68k-apple-machten$UNAME_RELEASE ;; powerpc:machten:*:*) GUESS=powerpc-apple-machten$UNAME_RELEASE ;; RISC*:Mach:*:*) GUESS=mips-dec-mach_bsd4.3 ;; RISC*:ULTRIX:*:*) GUESS=mips-dec-ultrix$UNAME_RELEASE ;; VAX*:ULTRIX*:*:*) GUESS=vax-dec-ultrix$UNAME_RELEASE ;; 2020:CLIX:*:* | 2430:CLIX:*:*) GUESS=clipper-intergraph-clix$UNAME_RELEASE ;; mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } GUESS=mips-mips-riscos$UNAME_RELEASE ;; Motorola:PowerMAX_OS:*:*) GUESS=powerpc-motorola-powermax ;; Motorola:*:4.3:PL8-*) GUESS=powerpc-harris-powermax ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) GUESS=powerpc-harris-powermax ;; Night_Hawk:Power_UNIX:*:*) GUESS=powerpc-harris-powerunix ;; m88k:CX/UX:7*:*) GUESS=m88k-harris-cxux7 ;; m88k:*:4*:R4*) GUESS=m88k-motorola-sysv4 ;; m88k:*:3*:R3*) GUESS=m88k-motorola-sysv3 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ test "$TARGET_BINARY_INTERFACE"x = x then GUESS=m88k-dg-dgux$UNAME_RELEASE else GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else GUESS=i586-dg-dgux$UNAME_RELEASE fi ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) GUESS=m88k-dolphin-sysv3 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 GUESS=m88k-motorola-sysv3 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) GUESS=m88k-tektronix-sysv3 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) GUESS=m68k-tektronix-bsd ;; *:IRIX*:*:*) IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` GUESS=mips-sgi-irix$IRIX_REL ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) GUESS=i386-ibm-aix ;; ia64:AIX:*:*) if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then GUESS=$SYSTEM_NAME else GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then GUESS=rs6000-ibm-aix3.2.4 else GUESS=rs6000-ibm-aix3.2 fi ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if test -x /usr/bin/lslpp ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi GUESS=$IBM_ARCH-ibm-aix$IBM_REV ;; *:AIX:*:*) GUESS=rs6000-ibm-aix ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) GUESS=romp-ibm-bsd4.4 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) GUESS=rs6000-bull-bosx ;; DPX/2?00:B.O.S.:*:*) GUESS=m68k-bull-sysv3 ;; 9000/[34]??:4.3bsd:1.*:*) GUESS=m68k-hp-bsd ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) GUESS=m68k-hp-bsd4.4 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` case $UNAME_MACHINE in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if test "$HP_ARCH" = ""; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if test "$HP_ARCH" = hppa2.0w then set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi GUESS=$HP_ARCH-hp-hpux$HPUX_REV ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` GUESS=ia64-hp-hpux$HPUX_REV ;; 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } GUESS=unknown-hitachi-hiuxwe2 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) GUESS=hppa1.1-hp-bsd ;; 9000/8??:4.3bsd:*:*) GUESS=hppa1.0-hp-bsd ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) GUESS=hppa1.0-hp-mpeix ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) GUESS=hppa1.1-hp-osf ;; hp8??:OSF1:*:*) GUESS=hppa1.0-hp-osf ;; i*86:OSF1:*:*) if test -x /usr/sbin/sysversion ; then GUESS=$UNAME_MACHINE-unknown-osf1mk else GUESS=$UNAME_MACHINE-unknown-osf1 fi ;; parisc*:Lites*:*:*) GUESS=hppa1.1-hp-lites ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) GUESS=c1-convex-bsd ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) GUESS=c34-convex-bsd ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) GUESS=c38-convex-bsd ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) GUESS=c4-convex-bsd ;; CRAY*Y-MP:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=ymp-cray-unicos$CRAY_REL ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=t90-cray-unicos$CRAY_REL ;; CRAY*T3E:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=alphaev5-cray-unicosmk$CRAY_REL ;; CRAY*SV1:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=sv1-cray-unicos$CRAY_REL ;; *:UNICOS/mp:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=craynv-cray-unicosmp$CRAY_REL ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE ;; sparc*:BSD/OS:*:*) GUESS=sparc-unknown-bsdi$UNAME_RELEASE ;; *:BSD/OS:*:*) GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE ;; arm:FreeBSD:*:*) UNAME_PROCESSOR=`uname -p` set_cc_for_build if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi else FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf fi ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL ;; i*:CYGWIN*:*) GUESS=$UNAME_MACHINE-pc-cygwin ;; *:MINGW64*:*) GUESS=$UNAME_MACHINE-pc-mingw64 ;; *:MINGW*:*) GUESS=$UNAME_MACHINE-pc-mingw32 ;; *:MSYS*:*) GUESS=$UNAME_MACHINE-pc-msys ;; i*:PW*:*) GUESS=$UNAME_MACHINE-pc-pw32 ;; *:SerenityOS:*:*) GUESS=$UNAME_MACHINE-pc-serenity ;; *:Interix*:*) case $UNAME_MACHINE in x86) GUESS=i586-pc-interix$UNAME_RELEASE ;; authenticamd | genuineintel | EM64T) GUESS=x86_64-unknown-interix$UNAME_RELEASE ;; IA64) GUESS=ia64-unknown-interix$UNAME_RELEASE ;; esac ;; i*:UWIN*:*) GUESS=$UNAME_MACHINE-pc-uwin ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) GUESS=x86_64-pc-cygwin ;; prep*:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=powerpcle-unknown-solaris2$SUN_REL ;; *:GNU:*:*) # the GNU system GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL ;; *:GNU/*:*:*) # other systems with GNU libc and userland GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC ;; x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) GUESS="$UNAME_MACHINE-pc-managarm-mlibc" ;; *:[Mm]anagarm:*:*) GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" ;; *:Minix:*:*) GUESS=$UNAME_MACHINE-unknown-minix ;; aarch64:Linux:*:*) set_cc_for_build CPU=$UNAME_MACHINE LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then ABI=64 sed 's/^ //' << EOF > "$dummy.c" #ifdef __ARM_EABI__ #ifdef __ARM_PCS_VFP ABI=eabihf #else ABI=eabi #endif #endif EOF cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` eval "$cc_set_abi" case $ABI in eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; esac fi GUESS=$CPU-unknown-linux-$LIBCABI ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; arm*:Linux:*:*) set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi ;; avr32*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; cris:Linux:*:*) GUESS=$UNAME_MACHINE-axis-linux-$LIBC ;; crisv32:Linux:*:*) GUESS=$UNAME_MACHINE-axis-linux-$LIBC ;; e2k:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; frv:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; hexagon:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; i*86:Linux:*:*) GUESS=$UNAME_MACHINE-pc-linux-$LIBC ;; ia64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; k1om:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; kvx:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; kvx:cos:*:*) GUESS=$UNAME_MACHINE-unknown-cos ;; kvx:mbr:*:*) GUESS=$UNAME_MACHINE-unknown-mbr ;; loongarch32:Linux:*:* | loongarch64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; m32r*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; m68*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; mips:Linux:*:* | mips64:Linux:*:*) set_cc_for_build IS_GLIBC=0 test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef mips #undef mipsel #undef mips64 #undef mips64el #if ${IS_GLIBC} && defined(_ABI64) LIBCABI=gnuabi64 #else #if ${IS_GLIBC} && defined(_ABIN32) LIBCABI=gnuabin32 #else LIBCABI=${LIBC} #endif #endif #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa64r6 #else #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa32r6 #else #if defined(__mips64) CPU=mips64 #else CPU=mips #endif #endif #endif #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) MIPS_ENDIAN= #else MIPS_ENDIAN= #endif #endif EOF cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` eval "$cc_set_vars" test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; openrisc*:Linux:*:*) GUESS=or1k-unknown-linux-$LIBC ;; or32:Linux:*:* | or1k*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; padre:Linux:*:*) GUESS=sparc-unknown-linux-$LIBC ;; parisc64:Linux:*:* | hppa64:Linux:*:*) GUESS=hppa64-unknown-linux-$LIBC ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; *) GUESS=hppa-unknown-linux-$LIBC ;; esac ;; ppc64:Linux:*:*) GUESS=powerpc64-unknown-linux-$LIBC ;; ppc:Linux:*:*) GUESS=powerpc-unknown-linux-$LIBC ;; ppc64le:Linux:*:*) GUESS=powerpc64le-unknown-linux-$LIBC ;; ppcle:Linux:*:*) GUESS=powerpcle-unknown-linux-$LIBC ;; riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; s390:Linux:*:* | s390x:Linux:*:*) GUESS=$UNAME_MACHINE-ibm-linux-$LIBC ;; sh64*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; sh*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; sparc:Linux:*:* | sparc64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; tile*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; vax:Linux:*:*) GUESS=$UNAME_MACHINE-dec-linux-$LIBC ;; x86_64:Linux:*:*) set_cc_for_build CPU=$UNAME_MACHINE LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then ABI=64 sed 's/^ //' << EOF > "$dummy.c" #ifdef __i386__ ABI=x86 #else #ifdef __ILP32__ ABI=x32 #endif #endif EOF cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` eval "$cc_set_abi" case $ABI in x86) CPU=i686 ;; x32) LIBCABI=${LIBC}x32 ;; esac fi GUESS=$CPU-pc-linux-$LIBCABI ;; xtensa*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. GUESS=i386-sequent-sysv4 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ;; i*86:OS/2:*:*) # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. GUESS=$UNAME_MACHINE-pc-os2-emx ;; i*86:XTS-300:*:STOP) GUESS=$UNAME_MACHINE-unknown-stop ;; i*86:atheos:*:*) GUESS=$UNAME_MACHINE-unknown-atheos ;; i*86:syllable:*:*) GUESS=$UNAME_MACHINE-pc-syllable ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) GUESS=i386-unknown-lynxos$UNAME_RELEASE ;; i*86:*DOS:*:*) GUESS=$UNAME_MACHINE-pc-msdosdjgpp ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else GUESS=$UNAME_MACHINE-pc-sysv32 fi ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. GUESS=i586-pc-msdosdjgpp ;; Intel:Mach:3*:*) GUESS=i386-pc-mach3 ;; paragon:*:*:*) GUESS=i860-intel-osf1 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi ;; mini*:CTIX:SYS*5:*) # "miniframe" GUESS=m68010-convergent-sysv ;; mc68k:UNIX:SYSTEM5:3.51m) GUESS=m68k-convergent-sysv ;; M680?0:D-NIX:5.3:*) GUESS=m68k-diab-dnix ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) GUESS=m68k-unknown-lynxos$UNAME_RELEASE ;; mc68030:UNIX_System_V:4.*:*) GUESS=m68k-atari-sysv4 ;; TSUNAMI:LynxOS:2.*:*) GUESS=sparc-unknown-lynxos$UNAME_RELEASE ;; rs6000:LynxOS:2.*:*) GUESS=rs6000-unknown-lynxos$UNAME_RELEASE ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) GUESS=powerpc-unknown-lynxos$UNAME_RELEASE ;; SM[BE]S:UNIX_SV:*:*) GUESS=mips-dde-sysv$UNAME_RELEASE ;; RM*:ReliantUNIX-*:*:*) GUESS=mips-sni-sysv4 ;; RM*:SINIX-*:*:*) GUESS=mips-sni-sysv4 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` GUESS=$UNAME_MACHINE-sni-sysv4 else GUESS=ns32k-sni-sysv fi ;; PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says GUESS=i586-unisys-sysv4 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm GUESS=hppa1.1-stratus-sysv4 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. GUESS=i860-stratus-sysv4 ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. GUESS=$UNAME_MACHINE-stratus-vos ;; *:VOS:*:*) # From Paul.Green@stratus.com. GUESS=hppa1.1-stratus-vos ;; mc68*:A/UX:*:*) GUESS=m68k-apple-aux$UNAME_RELEASE ;; news*:NEWS-OS:6*:*) GUESS=mips-sony-newsos6 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if test -d /usr/nec; then GUESS=mips-nec-sysv$UNAME_RELEASE else GUESS=mips-unknown-sysv$UNAME_RELEASE fi ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. GUESS=powerpc-be-beos ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. GUESS=powerpc-apple-beos ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. GUESS=i586-pc-beos ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. GUESS=i586-pc-haiku ;; ppc:Haiku:*:*) # Haiku running on Apple PowerPC GUESS=powerpc-apple-haiku ;; *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) GUESS=$UNAME_MACHINE-unknown-haiku ;; SX-4:SUPER-UX:*:*) GUESS=sx4-nec-superux$UNAME_RELEASE ;; SX-5:SUPER-UX:*:*) GUESS=sx5-nec-superux$UNAME_RELEASE ;; SX-6:SUPER-UX:*:*) GUESS=sx6-nec-superux$UNAME_RELEASE ;; SX-7:SUPER-UX:*:*) GUESS=sx7-nec-superux$UNAME_RELEASE ;; SX-8:SUPER-UX:*:*) GUESS=sx8-nec-superux$UNAME_RELEASE ;; SX-8R:SUPER-UX:*:*) GUESS=sx8r-nec-superux$UNAME_RELEASE ;; SX-ACE:SUPER-UX:*:*) GUESS=sxace-nec-superux$UNAME_RELEASE ;; Power*:Rhapsody:*:*) GUESS=powerpc-apple-rhapsody$UNAME_RELEASE ;; *:Rhapsody:*:*) GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE ;; arm64:Darwin:*:*) GUESS=aarch64-apple-darwin$UNAME_RELEASE ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac if command -v xcode-select > /dev/null 2> /dev/null && \ ! xcode-select --print-path > /dev/null 2> /dev/null ; then # Avoid executing cc if there is no toolchain installed as # cc will be a stub that puts up a graphical alert # prompting the user to install developer tools. CC_FOR_BUILD=no_compiler_found else set_cc_for_build fi if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then # uname -m returns i386 or x86_64 UNAME_PROCESSOR=$UNAME_MACHINE fi GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE ;; *:QNX:*:4*) GUESS=i386-pc-qnx ;; NEO-*:NONSTOP_KERNEL:*:*) GUESS=neo-tandem-nsk$UNAME_RELEASE ;; NSE-*:NONSTOP_KERNEL:*:*) GUESS=nse-tandem-nsk$UNAME_RELEASE ;; NSR-*:NONSTOP_KERNEL:*:*) GUESS=nsr-tandem-nsk$UNAME_RELEASE ;; NSV-*:NONSTOP_KERNEL:*:*) GUESS=nsv-tandem-nsk$UNAME_RELEASE ;; NSX-*:NONSTOP_KERNEL:*:*) GUESS=nsx-tandem-nsk$UNAME_RELEASE ;; *:NonStop-UX:*:*) GUESS=mips-compaq-nonstopux ;; BS2000:POSIX*:*:*) GUESS=bs2000-siemens-sysv ;; DS/*:UNIX_System_V:*:*) GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "${cputype-}" = 386; then UNAME_MACHINE=i386 elif test "x${cputype-}" != x; then UNAME_MACHINE=$cputype fi GUESS=$UNAME_MACHINE-unknown-plan9 ;; *:TOPS-10:*:*) GUESS=pdp10-unknown-tops10 ;; *:TENEX:*:*) GUESS=pdp10-unknown-tenex ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) GUESS=pdp10-dec-tops20 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) GUESS=pdp10-xkl-tops20 ;; *:TOPS-20:*:*) GUESS=pdp10-unknown-tops20 ;; *:ITS:*:*) GUESS=pdp10-unknown-its ;; SEI:*:*:SEIUX) GUESS=mips-sei-seiux$UNAME_RELEASE ;; *:DragonFly:*:*) DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case $UNAME_MACHINE in A*) GUESS=alpha-dec-vms ;; I*) GUESS=ia64-dec-vms ;; V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) GUESS=i386-pc-xenix ;; i*86:skyos:*:*) SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL ;; i*86:rdos:*:*) GUESS=$UNAME_MACHINE-pc-rdos ;; i*86:Fiwix:*:*) GUESS=$UNAME_MACHINE-pc-fiwix ;; *:AROS:*:*) GUESS=$UNAME_MACHINE-unknown-aros ;; x86_64:VMkernel:*:*) GUESS=$UNAME_MACHINE-unknown-esx ;; amd64:Isilon\ OneFS:*:*) GUESS=x86_64-unknown-onefs ;; *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; esac # Do we have a guess based on uname results? if test "x$GUESS" != x; then echo "$GUESS" exit fi # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" < #include #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #include #if defined(_SIZE_T_) || defined(SIGLOST) #include #endif #endif #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) #include #if defined (BSD) #if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); #else #if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); #else printf ("vax-dec-bsd\n"); exit (0); #endif #endif #else printf ("vax-dec-bsd\n"); exit (0); #endif #else #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname un; uname (&un); printf ("vax-dec-ultrix%s\n", un.release); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname *un; uname (&un); printf ("mips-dec-ultrix%s\n", un.release); exit (0); #else printf ("mips-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } echo "$0: unable to guess system type" >&2 case $UNAME_MACHINE:$UNAME_SYSTEM in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 <&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF fi exit 1 # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: mawk-1.3.4-20240123/types.h0000644000000000000000000000470214457207704013401 0ustar rootroot/******************************************** types.h copyright 2009-2016,2023 Thomas E. Dickey copyright 1991-1993,2014 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: types.h,v 1.14 2023/07/23 11:32:20 tom Exp $ */ /* types.h */ #ifndef MAWK_TYPES_H #define MAWK_TYPES_H #include "nstd.h" #include "sizes.h" /* CELL types */ typedef enum { C_NOINIT ,C_DOUBLE ,C_STRING ,C_STRNUM ,C_MBSTRN /*could be STRNUM, has not been checked */ ,C_RE ,C_SPACE /* split on space */ ,C_SNULL /* split on the empty string */ ,C_REPL /* a replacement string '\&' changed to & */ ,C_REPLV /* a vector replacement -- broken on & */ ,NUM_CELL_TYPES } MAWK_CELL_TYPES; /* these defines are used to check types for two CELLs which are adjacent in memory */ #define TWO_NOINITS (2*(1< #ifdef HAVE_SYS_WAIT_H #include #endif #ifdef V7 #include /* defines FIOCLEX */ #endif #ifdef HAVE_FCNTL_H #include #define CLOSE_ON_EXEC(fd) fcntl(fd, F_SETFD, 1) #else #define CLOSE_ON_EXEC(fd) ioctl(fd, FIOCLEX, (PTR) 0) #endif /* We store dynamically created files on a linked linear list with move to the front (big surprise) */ typedef struct file { struct file *link; STRING *name; short type; int pid; /* we need to wait() when we close a pipe */ /* holds temp file index under MSDOS */ #ifdef HAVE_FAKE_PIPES int inpipe_exit; #endif PTR ptr; /* FIN* or FILE* */ } FILE_NODE; static FILE_NODE *file_list; /* Prototypes for local functions */ static FILE *tfopen(const char *, const char *); static int efflush(FILE *); static void close_error(FILE_NODE * p); static FILE_NODE * alloc_filenode(void) { FILE_NODE *result; result = ZMALLOC(FILE_NODE); #ifdef NO_LEAKS result->name = 0; #endif result->ptr = 0; return result; } static void free_filenode(FILE_NODE * p) { #ifdef NO_LEAKS if (p->name != 0) { free_STRING(p->name); } #endif zfree(p, sizeof(FILE_NODE)); } static void output_failed(const char *name) { errmsg(errno, "cannot open \"%s\" for output", name); mawk_exit(2); /* NOTREACHED */ } /* * Most open-failures are recoverable, or affect only certain files. * However, running out of file-descriptors indicates a problem with * the script, and it is unlikely that recovery is possible. */ #ifdef EMFILE /* (POSIX.1-2001) */ #define input_failed(name, p) \ do { \ if (errno == EMFILE) { \ errmsg(errno, "cannot open \"%s\" for input", name); \ mawk_exit(2); \ } \ free_filenode(p); \ return (PTR) 0; \ } while (0) #else #define input_failed(name, p) \ do { \ free_filenode(p); \ return (PTR) 0; \ } while (0) #endif #if USE_BINMODE #define BinMode2(t,f) ((binmode() & 2) ? (t) : (f)) #else #define BinMode2(t,f) (f) #endif /* * Find a file on file_list. Outputs return a FILE*, while inputs return FIN*. */ PTR file_find(STRING * sval, int type) { FILE_NODE *p = file_list; FILE_NODE *q = (FILE_NODE *) 0; char *name = sval->str; TRACE(("file_find(%s, %d)\n", name, type)); while (1) { if (!p) { /* open a new one */ p = alloc_filenode(); switch (p->type = (short) type) { case F_TRUNC: if (!(p->ptr = (PTR) tfopen(name, BinMode2("wb", "w")))) output_failed(name); break; case F_APPEND: if (!(p->ptr = (PTR) tfopen(name, BinMode2("ab", "a")))) output_failed(name); break; case F_IN: if (!(p->ptr = (PTR) FINopen(name, 0))) input_failed(name, p); break; case PIPE_OUT: case PIPE_IN: #if defined(HAVE_REAL_PIPES) || defined(HAVE_FAKE_PIPES) if (!(p->ptr = get_pipe(name, type, &p->pid))) { if (type == PIPE_OUT) output_failed(name); else input_failed(name, p); } #else rt_error("pipes not supported"); #endif break; #ifdef DEBUG default: bozo("bad file type"); #endif } /* successful open */ p->name = sval; sval->ref_cnt++; break; /* while loop */ } /* search is by name and type */ if (strcmp(name, p->name->str) == 0 && (p->ptr != 0) && (p->type == type || /* no distinction between F_APPEND and F_TRUNC here */ (p->type >= F_APPEND && type >= F_APPEND))) { /* found */ if (!q) /*at front of list */ return p->ptr; /* delete from list for move to front */ q->link = p->link; break; /* while loop */ } q = p; p = p->link; } /* end while loop */ /* put p at the front of the list */ p->link = file_list; return (PTR) (file_list = p)->ptr; } /* Close a file and delete its node from the file_list. Walk the whole list, in case a name has two nodes, e.g. < "/dev/tty" and > "/dev/tty" */ int file_close(STRING * sval) { FILE_NODE *p; FILE_NODE *q = 0; /* trails p */ FILE_NODE *hold; char *name = sval->str; int retval = -1; TRACE(("file_close(%s)\n", name)); p = file_list; while (p) { if (strcmp(name, p->name->str) == 0) { /* found */ /* Remove it from the list first because we might be called again if an error occurs leading to an infinite loop. Note that we don't have to consider the list corruption caused by a recursive call because it will never return. */ if (q == 0) file_list = p->link; else q->link = p->link; switch (p->type) { case F_TRUNC: case F_APPEND: if (fclose((FILE *) p->ptr) != 0) { close_error(p); } retval = 0; break; case PIPE_OUT: if (fclose((FILE *) p->ptr) != 0) { close_error(p); } #ifdef HAVE_REAL_PIPES retval = wait_for(p->pid); #endif #ifdef HAVE_FAKE_PIPES retval = close_fake_outpipe(p->name->str, p->pid); #endif break; case F_IN: FINclose((FIN *) p->ptr); retval = 0; break; case PIPE_IN: FINclose((FIN *) p->ptr); #ifdef HAVE_REAL_PIPES retval = wait_for(p->pid); #endif #ifdef HAVE_FAKE_PIPES { char xbuff[100]; unlink(tmp_file_name(p->pid, xbuff)); retval = p->inpipe_exit; } #endif break; } hold = p; p = p->link; free_filenode(hold); } else { q = p; p = p->link; } } return retval; } /* find an output file with name == sval and fflush it */ int file_flush(STRING * sval) { int ret = 0; FILE_NODE *p = file_list; size_t len = sval->len; char *str = sval->str; if (len == 0) { /* for consistency with gawk */ ret = flush_all_output(); } else { int found = 0; while (p) { if (IS_OUTPUT(p->type) && len == p->name->len && strcmp(str, p->name->str) == 0) { found = 1; if (efflush((FILE *) p->ptr) != 0) ret = -1; /* it's possible for a command and a file to have the same name -- so keep looking */ } p = p->link; } if (!found) ret = -1; } return ret; } int flush_all_output(void) { int ret = 0; FILE_NODE *p; for (p = file_list; p; p = p->link) { if (IS_OUTPUT(p->type)) { if (efflush((FILE *) p->ptr) != 0) ret = -1; } } return ret; } static int efflush(FILE *fp) { int ret; if ((ret = fflush(fp)) < 0) { errmsg(errno, "unexpected write error"); } return ret; } /* When we exit, we need to close and wait for all output pipes */ #ifdef HAVE_REAL_PIPES /* work around for bug in AIX 4.1 -- If there are exactly 16 or 32 or 48 ..., open files then the last one doesn't get flushed on exit. So the following is now a misnomer as we'll really close all output. */ void close_out_pipes(void) { FILE_NODE *p = file_list; FILE_NODE *q = 0; while (p) { if (IS_OUTPUT(p->type)) { if (fclose((FILE *) p->ptr) != 0) { /* if another error occurs we do not want to be called for the same file again */ if (q != 0) q->link = p->link; else file_list = p->link; close_error(p); } else if (p->type == PIPE_OUT) { wait_for(p->pid); } } q = p; p = p->link; } } #else #ifdef HAVE_FAKE_PIPES /* pipes are faked with temp files */ void close_fake_pipes(void) { FILE_NODE *p = file_list; char xbuff[100]; /* close input pipes first to free descriptors for children */ while (p) { if (p->type == PIPE_IN) { FINclose((FIN *) p->ptr); unlink(tmp_file_name(p->pid, xbuff)); } p = p->link; } /* doit again */ p = file_list; while (p) { if (p->type == PIPE_OUT) { if (fclose(p->ptr) != 0) { close_error(p); } close_fake_outpipe(p->name->str, p->pid); } p = p->link; } } #endif /* HAVE_FAKE_PIPES */ #endif /* ! HAVE_REAL_PIPES */ /* hardwire to /bin/sh for portability of programs */ const char *shell = "/bin/sh"; #ifdef HAVE_REAL_PIPES PTR get_pipe(char *name, int type, int *pid_ptr) { int the_pipe[2], local_fd, remote_fd; if (pipe(the_pipe) == -1) return (PTR) 0; /* * If this is an input-pipe then local_fd is reader, remote_fd is writer * If this is an output-pipe then local_fd is writer, remote_fd is reader */ local_fd = the_pipe[type == PIPE_OUT]; remote_fd = the_pipe[type == PIPE_IN]; /* to keep output ordered correctly */ fflush(stdout); fflush(stderr); switch (*pid_ptr = fork()) { case -1: close(local_fd); close(remote_fd); return (PTR) 0; case 0: /* * This is the child process. Close the unused end of the pipe, i.e, * (local_fd) and then close the input/output file descriptor that * corresponds to the direction we want to read/write. * * The dup() call uses the first unused file descriptor, which happens * to be the one that we just closed, e.g., 0 or 1 for stdin and stdout * respectively. */ close(local_fd); close(type == PIPE_IN); IGNORE_RC(dup(remote_fd)); close(remote_fd); execl(shell, shell, "-c", name, (char *) 0); errmsg(errno, "failed to exec %s -c \"%s\"", shell, name); fflush(stderr); _exit(128); default: close(remote_fd); /* we could deadlock if future child inherit the local fd , set close on exec flag */ (void) CLOSE_ON_EXEC(local_fd); break; } return ((type == PIPE_IN) ? (PTR) FINdopen(local_fd, 0) : (PTR) fdopen(local_fd, "w")); } /*------------ children ------------------*/ /* we need to wait for children at the end of output pipes to complete so we know any files they have created are complete */ /* dead children are kept on this list */ static struct child { int pid; int exit_status; struct child *link; } *child_list; static void add_to_child_list(int pid, int exit_status) { struct child *p = ZMALLOC(struct child); p->pid = pid; p->exit_status = exit_status; p->link = child_list; child_list = p; } static struct child * remove_from_child_list(int pid) { struct child dummy; struct child *p; struct child *q = &dummy; dummy.link = p = child_list; while (p) { if (p->pid == pid) { q->link = p->link; break; } else { q = p; p = p->link; } } child_list = dummy.link; return p; /* null return if not in the list */ } /* wait for a specific child to complete and return its exit status If pid is zero, wait for any single child and put it on the dead children list */ int wait_for(int pid) { int exit_status = 0; struct child *p; int id; TRACE(("wait_for %d\n", pid)); if (pid == 0) { id = wait(&exit_status); add_to_child_list(id, exit_status); } /* see if an earlier wait() caught our child */ else if ((p = remove_from_child_list(pid))) { exit_status = p->exit_status; ZFREE(p); } else { /* need to really wait */ while ((id = wait(&exit_status)) != pid) { if (id == -1) /* can't happen */ bozo("wait_for"); else { /* we got the exit status of another child put it on the child list and try again */ add_to_child_list(id, exit_status); } } } return wait_status(exit_status); } /* * POSIX system() call returns a value from wait(), which should be tested * using the POSIX macros. */ int wait_status(int status) { if (status != -1) { if (WIFEXITED(status)) { status = WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { status = 256 + WTERMSIG(status); } } return status; } #endif /* HAVE_REAL_PIPES */ /* * Create names by which the standard streams can be referenced in a script. */ void set_stdio(void) { FILE_NODE *p, *q, *r; /* We insert stderr first to get it at the end of the list. This is needed because we want to output errors encountered on closing stdout. */ q = alloc_filenode(); q->link = (FILE_NODE *) 0; q->type = F_TRUNC; q->name = new_STRING("/dev/stderr"); q->ptr = (PTR) stderr; p = alloc_filenode(); p->link = q; p->type = F_TRUNC; p->name = new_STRING("/dev/stdout"); p->ptr = (PTR) stdout; r = alloc_filenode(); r->link = p; r->type = F_IN; r->name = new_STRING("/dev/stdin"); /* Note: ptr is set in file_find() */ file_list = r; } /* fopen() but no buffering to ttys */ static FILE * tfopen(const char *name, const char *mode) { FILE *retval = fopen(name, mode); if (retval) { if (isatty(fileno(retval))) setbuf(retval, (char *) 0); else { #ifdef MSDOS enlarge_output_buffer(retval); #endif } } return retval; } #ifdef MSDOS void enlarge_output_buffer(FILE *fp) { if (setvbuf(fp, (char *) 0, _IOFBF, BUFFSZ) < 0) { errmsg(errno, "setvbuf failed on fileno %d", fileno(fp)); mawk_exit(2); } } #endif #if USE_BINMODE void stdout_init(void) { #ifdef MSDOS if (!isatty(1)) enlarge_output_buffer(stdout); #endif if (binmode() & 2) { setmode(1, O_BINARY); setmode(2, O_BINARY); } } #endif /* USE_BINMODE */ /* An error occurred closing the file referred to by P. We tell the user and terminate the program. */ static void close_error(FILE_NODE * p) { TRACE(("close_error(%s)\n", p->name->str)); errmsg(errno, "close failed on file \"%s\"", p->name->str); #ifdef NO_LEAKS free_filenode(p); #endif mawk_exit(2); } #ifdef NO_LEAKS void files_leaks(void) { TRACE(("files_leaks\n")); while (file_list != 0) { FILE_NODE *p = file_list; file_list = p->link; free_filenode(p); } } #endif mawk-1.3.4-20240123/fin.h0000644000000000000000000000257614464533063013016 0ustar rootroot/******************************************** fin.h copyright 2009-2014,2023 Thomas E. Dickey copyright 1991-1992,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: fin.h,v 1.15 2023/08/08 21:40:03 tom Exp $ */ /* fin.h */ #ifndef FIN_H #define FIN_H #include /* structure to control input files */ typedef struct { int fd; /* file-descriptor */ FILE *fp; /* NULL unless interactive */ char *buff; /* base of data read from file */ char *buffp; /* current position to read-next */ char *limit; /* points past the data in *buff */ size_t buff_size; /* allocated size of buff[] */ int flags; } FIN; #define MAIN_FLAG 1 /* part of main input stream if on */ #define EOF_FLAG 2 #define START_FLAG 4 /* used when RS == "" */ #define FIN_FLAG 8 /* set if fin->buff is no longer beginning */ extern FIN *FINdopen(int, int); extern FIN *FINopen(char *, int); extern void FINclose(FIN *); extern void FINsemi_close(FIN *); extern char *FINgets(FIN *, size_t *); extern size_t fillbuff(int, char *, size_t); extern void open_main(void); extern FIN *main_fin; /* for the main input stream */ #endif /* FIN_H */ mawk-1.3.4-20240123/code.c0000644000000000000000000002051714467004435013141 0ustar rootroot/******************************************** code.c copyright 2009-2019,2023, Thomas E. Dickey copyright 1991-1994,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: code.c,v 1.44 2023/08/15 23:24:13 tom Exp $ */ #include #include #include #include #include #ifdef NO_LEAKS #include #include #endif static CODEBLOCK *new_code(void); CODEBLOCK active_code; CODEBLOCK *main_code_p, *begin_code_p, *end_code_p; INST *begin_start, *main_start, *end_start; size_t begin_size, main_size, end_size; INST *execution_start = 0; /* grow the active code */ void code_grow(void) { size_t oldsize = (size_t) (code_limit - code_base); size_t newsize = PAGESZ + oldsize; size_t delta = (size_t) (code_ptr - code_base); if (code_ptr > code_limit) bozo("CODEWARN is too small"); code_base = (INST *) zrealloc(code_base, INST_BYTES(oldsize), INST_BYTES(newsize)); code_limit = code_base + newsize; code_warn = code_limit - CODEWARN; code_ptr = code_base + delta; } /* shrinks executable code that's done to its final size */ INST * code_shrink(CODEBLOCK * p, size_t *sizep) { size_t oldsize = INST_BYTES(p->limit - p->base); size_t newsize = INST_BYTES(p->ptr - p->base); INST *retval; *sizep = newsize; retval = (INST *) zrealloc(p->base, oldsize, newsize); TRACE(("code_shrink old %p %lu, new %p %lu\n", (void *) p->base, (unsigned long) oldsize, (void *) retval, (unsigned long) newsize)); ZFREE(p); return retval; } /* code an op and a pointer in the active_code */ void xcode2(int op, PTR ptr) { register INST *p = code_ptr + 2; if (p >= code_warn) { code_grow(); p = code_ptr + 2; } p[-2].op = op; p[-1].ptr = ptr; code_ptr = p; } /* code two ops in the active_code */ void code2op(int x, int y) { register INST *p = code_ptr + 2; if (p >= code_warn) { code_grow(); p = code_ptr + 2; } p[-2].op = x; p[-1].op = y; code_ptr = p; } void code_init(void) { main_code_p = new_code(); active_code = *main_code_p; code1(_OMAIN); } /* final code relocation set_code() as in set concrete */ void set_code(void) { /* set the main code which is active_code */ if (end_code_p || code_offset > 1) { int gl_offset = code_offset; if (NR_flag) code2op(OL_GL_NR, _HALT); else code2op(OL_GL, _HALT); *main_code_p = active_code; main_start = code_shrink(main_code_p, &main_size); next_label = main_start + gl_offset; execution_start = main_start; } else { /* only BEGIN */ zfree(code_base, INST_BYTES(PAGESZ)); code_base = 0; ZFREE(main_code_p); } /* set the END code */ if (end_code_p) { active_code = *end_code_p; code2op(_EXIT0, _HALT); *end_code_p = active_code; end_start = code_shrink(end_code_p, &end_size); } /* set the BEGIN code */ if (begin_code_p) { active_code = *begin_code_p; if (main_start) code2op(_JMAIN, _HALT); else code2op(_EXIT0, _HALT); *begin_code_p = active_code; begin_start = code_shrink(begin_code_p, &begin_size); execution_start = begin_start; } if (!execution_start) { /* program had functions but no pattern-action bodies */ execution_start = begin_start = (INST *) zmalloc(2 * sizeof(INST)); execution_start[0].op = _EXIT0; execution_start[1].op = _HALT; } } void dump_code(void) { dump_funcs(); /* dumps all user functions */ if (begin_start) { fprintf(stdout, "BEGIN\n"); da(begin_start, stdout); } if (end_start) { fprintf(stdout, "END\n"); da(end_start, stdout); } if (main_start) { fprintf(stdout, "MAIN\n"); da(main_start, stdout); } dump_regex(); /* dumps all regular expressions */ } static CODEBLOCK * new_code(void) { CODEBLOCK *p = ZMALLOC(CODEBLOCK); p->base = (INST *) zmalloc(INST_BYTES(PAGESZ)); p->limit = p->base + PAGESZ; p->warn = p->limit - CODEWARN; p->ptr = p->base; return p; } /* moves the active_code from MAIN to a BEGIN or END */ void be_setup(int scope) { *main_code_p = active_code; if (scope == SCOPE_BEGIN) { if (!begin_code_p) { TRACE(("be_setup: BEGIN\n")); begin_code_p = new_code(); } else { TRACE(("be_setup: BEGIN (again)\n")); } active_code = *begin_code_p; } else { if (!end_code_p) { TRACE(("be_setup: END\n")); end_code_p = new_code(); } else { TRACE(("be_setup: END (again)\n")); } active_code = *end_code_p; } } #ifdef NO_LEAKS void free_cell_data(CELL *cp) { switch (cp->type) { case C_RE: TRACE(("\t... C_RE\n")); re_destroy(cp->ptr); zfree(cp, sizeof(CELL)); break; case C_REPL: TRACE(("\t... C_REPL\n")); repl_destroy(cp); zfree(cp, sizeof(CELL)); break; case C_REPLV: TRACE(("\t... C_REPLV\n")); repl_destroy(cp); zfree(cp, sizeof(CELL)); break; case C_MBSTRN: case C_STRING: case C_STRNUM: if (cp >= (field + (nf < 1 ? 1 : nf)) || (cp < field)) { cell_destroy(cp); } break; } } void free_codes(const char *tag, INST * base, size_t size) { INST *cdp; INST *last = base + (size / sizeof(*last)); CELL *cp; (void) tag; TRACE(("free_codes(%s) base %p, size %lu\n", tag, (void *) base, (unsigned long) size)); if (base != 0 && size != 0) { for (cdp = base; cdp < last; ++cdp) { #ifndef NO_LEAKS TRACE_INST(cdp, base); #endif switch ((MAWK_OPCODES) (cdp->op)) { case AE_PUSHA: case AE_PUSHI: ++cdp; /* skip pointer */ cp = (CELL *) (cdp->ptr); if (cp != 0) { free_cell_data(cp); } break; case _MATCH0: case _MATCH1: ++cdp; /* skip pointer */ re_destroy(cdp->ptr); break; case LAE_PUSHA: case LA_PUSHA: case A_CAT: ++cdp; /* skip value */ break; case A_PUSHA: case L_PUSHA: case L_PUSHI: case _LENGTH: case _BUILTIN: case _PRINT: case _PUSHA: case _PUSHI: case _PUSHINT: ++cdp; /* skip value */ break; case _PUSHD: ++cdp; /* skip value */ if (cdp->ptr != &double_one && cdp->ptr != &double_zero) zfree(cdp->ptr, sizeof(double)); break; case F_PUSHI: ++cdp; /* skip pointer */ ++cdp; /* skip integer */ break; case _PUSHS: ++cdp; /* skip value */ free_STRING((STRING *) (cdp->ptr)); break; case _RANGE: cdp += 4; /* PAT1 */ break; case _CALLX: case _CALL: cdp += 1 + cdp[2].op; break; case A_DEL: case A_LENGTH: case A_TEST: case DEL_A: case FE_PUSHA: case FE_PUSHI: case F_ADD_ASG: case F_ASSIGN: case F_DIV_ASG: case F_MOD_ASG: case F_MUL_ASG: case F_POST_DEC: case F_POST_INC: case F_POW_ASG: case F_PRE_DEC: case F_PRE_INC: case F_PUSHA: case F_SUB_ASG: case NF_PUSHI: case OL_GL: case OL_GL_NR: case POP_AL: case _ADD: case _ADD_ASG: case _ASSIGN: case _CAT: case _DIV: case _DIV_ASG: case _EQ: case _EXIT0: /* this does free memory... */ case _EXIT: case _GT: case _GTE: case _HALT: case _JMAIN: case _LT: case _LTE: case _MATCH2: case _MOD: case _MOD_ASG: case _MUL: case _MUL_ASG: case _NEQ: case _NEXT: case _NEXTFILE: case _NOT: case _OMAIN: case _POP: case _POST_DEC: case _POST_INC: case _POW: case _POW_ASG: case _PRE_DEC: case _PRE_INC: case _RET0: case _RET: case _STOP: case _SUB: case _SUB_ASG: case _TEST: case _UMINUS: case _UPLUS: break; case _JNZ: case _JZ: case _LJZ: case _LJNZ: case _JMP: case _PUSHC: case ALOOP: case LAE_PUSHI: case SET_ALOOP: ++cdp; /* cdp->op is literal param */ break; } } zfree(base, size); } } void code_leaks(void) { TRACE(("code_leaks\n")); if (begin_start != 0) { free_codes("BEGIN", begin_start, begin_size); begin_start = 0; begin_size = 0; } if (end_start != 0) { free_codes("END", end_start, end_size); end_start = 0; end_size = 0; } if (main_start != 0) { free_codes("MAIN", main_start, main_size); main_start = 0; main_size = 0; } } #endif mawk-1.3.4-20240123/parse.y0000644000000000000000000011454214465521000013357 0ustar rootroot/******************************************** parse.y copyright 2008-2020,2023, Thomas E. Dickey copyright 1991-1994,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: parse.y,v 1.34 2023/08/11 21:02:56 tom Exp $ */ %{ #include #include #include #include #include #include #include #include #include #define YYMAXDEPTH 200 #if defined(YYBYACC) && (YYBYACC < 2) extern int yylex(void); #endif extern void eat_nl(void); static SYMTAB *save_arglist(const char *); static int init_arglist(void); static void RE_as_arg(void); static void check_array(SYMTAB *); static void check_var(SYMTAB *); static void code_array(SYMTAB *); static void code_call_id(CA_REC *, SYMTAB *); static void field_A2I(void); static void free_arglist(void); static void improve_arglist(const char *); static void resize_fblock(FBLOCK *); static void switch_code_to_main(void); static int scope; static FBLOCK *active_funct; static CA_REC *active_arglist; /* when scope is SCOPE_FUNCT */ #define code_address(x) if( is_local(x) ) \ code2op(L_PUSHA, (x)->offset) ;\ else code2(_PUSHA, (x)->stval.cp) #define CDP(x) (code_base+(x)) /* WARNING: These CDP() calculations become invalid after calls that might change code_base. Which are: code2(), code2op(), code_jmp() and code_pop(). */ /* this nonsense caters to MSDOS large model */ #define CODE_FE_PUSHA() code_ptr->ptr = (PTR) 0 ; code1(FE_PUSHA) %} %union{ CELL *cp ; SYMTAB *stp ; int start ; /* code starting address as offset from code_base */ PF_CP fp ; /* ptr to a (print/printf) or (sub/gsub) function */ const BI_REC *bip ; /* ptr to info about a builtin */ FBLOCK *fbp ; /* ptr to a function block */ ARG2_REC *arg2p ; CA_REC *ca_p ; int ival ; PTR ptr ; } /* two tokens to help with errors */ %token UNEXPECTED /* unexpected character */ %token BAD_DECIMAL %token NL %token SEMI_COLON %token LBRACE RBRACE %token LBOX RBOX %token COMMA %token IO_OUT /* > or output pipe */ %right ASSIGN ADD_ASG SUB_ASG MUL_ASG DIV_ASG MOD_ASG POW_ASG %right QMARK COLON %left OR %left AND %left IN %left MATCH /* ~ or !~ */ %left EQ NEQ LT LTE GT GTE %left CAT %left GETLINE %left PLUS MINUS %left MUL DIV MOD %left NOT UMINUS %nonassoc IO_IN PIPE %right POW %left INC_or_DEC %left DOLLAR FIELD /* last to remove a SR conflict with getline */ %right LPAREN RPAREN /* removes some SR conflicts */ %token DOUBLE STRING_ RE %token ID D_ID %token FUNCT_ID %token BUILTIN LENGTH %token FIELD %token PRINT PRINTF SPLIT MATCH_FUNC SUB GSUB /* keywords */ %token DO WHILE FOR BREAK CONTINUE IF ELSE IN %token DELETE BEGIN END EXIT NEXT NEXTFILE RETURN FUNCTION %type block block_or_separator %type statement_list statement mark %type pr_args %type arg2 %type builtin %type getline_file %type lvalue field fvalue %type expr cat_expr p_expr %type while_front if_front %type for1 for2 %type array_loop_front %type return_statement %type split_front re_arg sub_back %type arglist args %type print sub_or_gsub %type funct_start funct_head %type call_args ca_front ca_back %type f_arglist f_args %% /* productions */ program : program_block | program program_block ; program_block : PA_block /* pattern-action */ | function_def | outside_error block ; PA_block : block { /* this do nothing action removes a vacuous warning from Bison */ } | BEGIN { be_setup(scope = SCOPE_BEGIN) ; } block { switch_code_to_main() ; } | END { be_setup(scope = SCOPE_END) ; } block { switch_code_to_main() ; } | expr /* this works just like an if statement */ { code_jmp(_JZ, (INST*)0) ; } block_or_separator { patch_jmp( code_ptr ) ; } /* range pattern, see comment in execute.c near _RANGE */ | expr COMMA { INST *p1 = CDP($1) ; int len ; code_push(p1, (unsigned) CodeOffset(p1), scope, active_funct) ; code_ptr = p1 ; code2op(_RANGE, 1) ; code_ptr += 3 ; len = (int) code_pop(code_ptr) ; code_ptr += len ; code1(_STOP) ; p1 = CDP($1) ; p1[2].op = CodeOffset(p1 + 1) ; } expr { code1(_STOP) ; } block_or_separator { INST *p1 = CDP($1) ; p1[3].op = (int) (CDP($6) - (p1 + 1)) ; p1[4].op = CodeOffset(p1 + 1) ; } ; block : LBRACE statement_list RBRACE { $$ = $2 ; } | LBRACE error RBRACE { $$ = code_offset ; /* does nothing won't be executed */ print_flag = getline_flag = paren_cnt = 0 ; yyerrok ; } ; block_or_separator : block | separator /* default print action */ { $$ = code_offset ; code1(_PUSHINT) ; code1(0) ; code2(_PRINT, bi_print) ; } ; statement_list : statement | statement_list statement ; statement : block | expr separator { code1(_POP) ; } | /* empty */ separator { $$ = code_offset ; } | error separator { $$ = code_offset ; print_flag = getline_flag = 0 ; paren_cnt = 0 ; yyerrok ; } | BREAK separator { $$ = code_offset ; BC_insert('B', code_ptr+1) ; code2(_JMP, 0) /* don't use code_jmp ! */ ; } | CONTINUE separator { $$ = code_offset ; BC_insert('C', code_ptr+1) ; code2(_JMP, 0) ; } | return_statement { if ( scope != SCOPE_FUNCT ) compile_error("return outside function body") ; } | NEXT separator { if ( scope != SCOPE_MAIN ) compile_error( "improper use of next" ) ; $$ = code_offset ; code1(_NEXT) ; } | NEXTFILE separator { if ( scope != SCOPE_MAIN ) compile_error( "improper use of nextfile" ) ; $$ = code_offset ; code1(_NEXTFILE) ; } ; separator : NL | SEMI_COLON ; expr : cat_expr | lvalue ASSIGN expr { code1(_ASSIGN) ; } | lvalue ADD_ASG expr { code1(_ADD_ASG) ; } | lvalue SUB_ASG expr { code1(_SUB_ASG) ; } | lvalue MUL_ASG expr { code1(_MUL_ASG) ; } | lvalue DIV_ASG expr { code1(_DIV_ASG) ; } | lvalue MOD_ASG expr { code1(_MOD_ASG) ; } | lvalue POW_ASG expr { code1(_POW_ASG) ; } | expr EQ expr { code1(_EQ) ; } | expr NEQ expr { code1(_NEQ) ; } | expr LT expr { code1(_LT) ; } | expr LTE expr { code1(_LTE) ; } | expr GT expr { code1(_GT) ; } | expr GTE expr { code1(_GTE) ; } | expr MATCH expr { INST *p3 = CDP($3) ; if ( p3 == code_ptr - 2 ) { if ( p3->op == _MATCH0 ) p3->op = _MATCH1 ; else /* check for string */ if ( p3->op == _PUSHS ) { CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = p3[1].ptr ; cast_to_RE(cp) ; no_leaks_re_ptr(cp->ptr) ; code_ptr -= 2 ; code2(_MATCH1, cp->ptr) ; ZFREE(cp) ; } else code1(_MATCH2) ; } else code1(_MATCH2) ; if ( !$2 ) code1(_NOT) ; } /* short circuit boolean evaluation */ | expr OR { code1(_TEST) ; code_jmp(_LJNZ, (INST*)0) ; } expr { code1(_TEST) ; patch_jmp(code_ptr) ; } | expr AND { code1(_TEST) ; code_jmp(_LJZ, (INST*)0) ; } expr { code1(_TEST) ; patch_jmp(code_ptr) ; } | expr QMARK { code_jmp(_JZ, (INST*)0) ; } expr COLON { code_jmp(_JMP, (INST*)0) ; } expr { patch_jmp(code_ptr) ; patch_jmp(CDP($7)) ; } ; cat_expr : p_expr %prec CAT | cat_expr p_expr %prec CAT { code1(_CAT) ; } ; p_expr : DOUBLE { $$ = code_offset ; code2(_PUSHD, $1) ; } | STRING_ { $$ = code_offset ; code2(_PUSHS, $1) ; } | ID %prec AND /* anything less than IN */ { check_var($1) ; $$ = code_offset ; if ( is_local($1) ) { code2op(L_PUSHI, $1->offset) ; } else code2(_PUSHI, $1->stval.cp) ; } | LPAREN expr RPAREN { $$ = $2 ; } ; p_expr : RE { $$ = code_offset ; code2(_MATCH0, $1) ; no_leaks_re_ptr($1); } ; p_expr : p_expr PLUS p_expr { code1(_ADD) ; } | p_expr MINUS p_expr { code1(_SUB) ; } | p_expr MUL p_expr { code1(_MUL) ; } | p_expr DIV p_expr { code1(_DIV) ; } | p_expr MOD p_expr { code1(_MOD) ; } | p_expr POW p_expr { code1(_POW) ; } | NOT p_expr { $$ = $2 ; code1(_NOT) ; } | PLUS p_expr %prec UMINUS { $$ = $2 ; code1(_UPLUS) ; } | MINUS p_expr %prec UMINUS { $$ = $2 ; code1(_UMINUS) ; } | builtin ; p_expr : ID INC_or_DEC { check_var($1) ; $$ = code_offset ; code_address($1) ; if ( $2 == '+' ) code1(_POST_INC) ; else code1(_POST_DEC) ; } | INC_or_DEC lvalue { $$ = $2 ; if ( $1 == '+' ) code1(_PRE_INC) ; else code1(_PRE_DEC) ; } ; p_expr : field INC_or_DEC { if ($2 == '+' ) code1(F_POST_INC ) ; else code1(F_POST_DEC) ; } | INC_or_DEC field { $$ = $2 ; if ( $1 == '+' ) code1(F_PRE_INC) ; else code1( F_PRE_DEC) ; } ; lvalue : ID { $$ = code_offset ; check_var($1) ; code_address($1) ; } ; arglist : /* empty */ { $$ = 0 ; } | args ; args : expr %prec LPAREN { $$ = 1 ; } | args COMMA expr { $$ = $1 + 1 ; } ; builtin : BUILTIN mark LPAREN arglist RPAREN { const BI_REC *p = $1 ; $$ = $2 ; if ( (int)p->min_args > $4 || (int)p->max_args < $4 ) compile_error( "wrong number of arguments in call to %s" , p->name ) ; if ( p->min_args != p->max_args ) /* variable args */ { code1(_PUSHINT) ; code1($4) ; } code2(_BUILTIN , p->fp) ; } ; /* an empty production to store the code_ptr */ mark : /* empty */ { $$ = code_offset ; } ; /* print_statement */ statement : print mark pr_args pr_direction separator { code2(_PRINT, $1) ; if ( $1 == bi_printf && $3 == 0 ) compile_error("no arguments in call to printf") ; print_flag = 0 ; $$ = $2 ; } ; print : PRINT { $$ = bi_print ; print_flag = 1 ;} | PRINTF { $$ = bi_printf ; print_flag = 1 ; } ; pr_args : arglist { code2op(_PUSHINT, $1) ; } | LPAREN arg2 RPAREN { $$ = $2->cnt ; zfree($2,sizeof(ARG2_REC)) ; code2op(_PUSHINT, $$) ; } | LPAREN RPAREN { $$=0 ; code2op(_PUSHINT, 0) ; } ; arg2 : expr COMMA expr { $$ = ZMALLOC(ARG2_REC) ; $$->start = $1 ; $$->cnt = 2 ; } | arg2 COMMA expr { $$ = $1 ; $$->cnt++ ; } ; pr_direction : /* empty */ | IO_OUT expr { code2op(_PUSHINT, $1) ; } ; /* IF and IF-ELSE */ if_front : IF LPAREN expr RPAREN { $$ = $3 ; eat_nl() ; code_jmp(_JZ, (INST*)0) ; } ; /* if_statement */ statement : if_front statement { patch_jmp( code_ptr ) ; } ; else_back : ELSE { eat_nl() ; code_jmp(_JMP, (INST*)0) ; } ; /* if_else_statement */ statement : if_front statement else_back statement { patch_jmp(code_ptr) ; patch_jmp(CDP($4)) ; } ; /* LOOPS */ do : DO { eat_nl() ; BC_new() ; } ; /* do_statement */ statement : do statement WHILE LPAREN expr RPAREN separator { $$ = $2 ; code_jmp(_JNZ, CDP($2)) ; BC_clear(code_ptr, CDP($5)) ; } ; while_front : WHILE LPAREN expr RPAREN { eat_nl() ; BC_new() ; $$ = $3 ; /* check if const expression */ if ( code_ptr - 2 == CDP($3) && code_ptr[-2].op == _PUSHD && *(double*)code_ptr[-1].ptr != 0.0 ) code_ptr -= 2 ; else { INST *p3 = CDP($3) ; code_push(p3, (unsigned) CodeOffset(p3), scope, active_funct) ; code_ptr = p3 ; code2(_JMP, (INST*)0) ; /* code2() not code_jmp() */ } } ; /* while_statement */ statement : while_front statement { INST *p1 = CDP($1) ; INST *p2 = CDP($2) ; if ( p1 != p2 ) /* real test in loop */ { int saved_offset ; int len ; p1[1].op = CodeOffset(p1 + 1) ; saved_offset = code_offset ; len = (int) code_pop(code_ptr) ; code_ptr += len ; code_jmp(_JNZ, CDP($2)) ; BC_clear(code_ptr, CDP(saved_offset)) ; } else /* while(1) */ { code_jmp(_JMP, p1) ; BC_clear(code_ptr, CDP($2)) ; } } ; /* for_statement */ statement : for1 for2 for3 statement { int cont_offset = code_offset ; unsigned len = code_pop(code_ptr) ; INST *p2 = CDP($2) ; INST *p4 = CDP($4) ; code_ptr += len ; if ( p2 != p4 ) /* real test in for2 */ { p4[-1].op = CodeOffset(p4 - 1) ; len = code_pop(code_ptr) ; code_ptr += len ; code_jmp(_JNZ, CDP($4)) ; } else /* for(;;) */ code_jmp(_JMP, p4) ; BC_clear(code_ptr, CDP(cont_offset)) ; } ; for1 : FOR LPAREN SEMI_COLON { $$ = code_offset ; } | FOR LPAREN expr SEMI_COLON { $$ = $3 ; code1(_POP) ; } ; for2 : SEMI_COLON { $$ = code_offset ; } | expr SEMI_COLON { if ( code_ptr - 2 == CDP($1) && code_ptr[-2].op == _PUSHD && * (double*) code_ptr[-1].ptr != 0.0 ) code_ptr -= 2 ; else { INST *p1 = CDP($1) ; code_push(p1, (unsigned) CodeOffset(p1), scope, active_funct) ; code_ptr = p1 ; code2(_JMP, (INST*)0) ; } } ; for3 : RPAREN { eat_nl() ; BC_new() ; code_push((INST*)0,0, scope, active_funct) ; } | expr RPAREN { INST *p1 = CDP($1) ; eat_nl() ; BC_new() ; code1(_POP) ; code_push(p1, (unsigned) CodeOffset(p1), scope, active_funct) ; code_ptr -= code_ptr - p1 ; } ; /* arrays */ expr : expr IN ID { check_array($3) ; code_array($3) ; code1(A_TEST) ; } | LPAREN arg2 RPAREN IN ID { $$ = $2->start ; code2op(A_CAT, $2->cnt) ; zfree($2, sizeof(ARG2_REC)) ; check_array($5) ; code_array($5) ; code1(A_TEST) ; } ; lvalue : ID mark LBOX args RBOX { if ( $4 > 1 ) { code2op(A_CAT, $4) ; } check_array($1) ; if( is_local($1) ) { code2op(LAE_PUSHA, $1->offset) ; } else code2(AE_PUSHA, $1->stval.array) ; $$ = $2 ; } ; p_expr : ID mark LBOX args RBOX %prec AND { if ( $4 > 1 ) { code2op(A_CAT, $4) ; } check_array($1) ; if( is_local($1) ) { code2op(LAE_PUSHI, $1->offset) ; } else code2(AE_PUSHI, $1->stval.array) ; $$ = $2 ; } | ID mark LBOX args RBOX INC_or_DEC { if ( $4 > 1 ) { code2op(A_CAT,$4) ; } check_array($1) ; if( is_local($1) ) { code2op(LAE_PUSHA, $1->offset) ; } else code2(AE_PUSHA, $1->stval.array) ; if ( $6 == '+' ) code1(_POST_INC) ; else code1(_POST_DEC) ; $$ = $2 ; } ; /* delete A[i] or delete A */ statement : DELETE ID mark LBOX args RBOX separator { $$ = $3 ; if ( $5 > 1 ) { code2op(A_CAT, $5) ; } check_array($2) ; code_array($2) ; code1(A_DEL) ; } | DELETE ID separator { $$ = code_offset ; check_array($2) ; code_array($2) ; code1(DEL_A) ; } ; /* for ( i in A ) statement */ array_loop_front : FOR LPAREN ID IN ID RPAREN { eat_nl() ; BC_new() ; $$ = code_offset ; check_var($3) ; code_address($3) ; check_array($5) ; code_array($5) ; code2(SET_ALOOP, (INST*)0) ; } ; /* array_loop */ statement : array_loop_front statement { INST *p2 = CDP($2) ; p2[-1].op = CodeOffset(p2 - 1) ; BC_clear( code_ptr+2 , code_ptr) ; code_jmp(ALOOP, p2) ; code1(POP_AL) ; } ; /* fields D_ID is a special token , same as an ID, but yylex() only returns it after a '$'. In essence, DOLLAR D_ID is really one token. */ field : FIELD { $$ = code_offset ; code2(F_PUSHA, $1) ; } | DOLLAR D_ID { check_var($2) ; $$ = code_offset ; if ( is_local($2) ) { code2op(L_PUSHI, $2->offset) ; } else code2(_PUSHI, $2->stval.cp) ; CODE_FE_PUSHA() ; } | DOLLAR D_ID mark LBOX args RBOX { if ( $5 > 1 ) { code2op(A_CAT, $5) ; } check_array($2) ; if( is_local($2) ) { code2op(LAE_PUSHI, $2->offset) ; } else code2(AE_PUSHI, $2->stval.array) ; CODE_FE_PUSHA() ; $$ = $3 ; } | DOLLAR p_expr { $$ = $2 ; CODE_FE_PUSHA() ; } | LPAREN field RPAREN { $$ = $2 ; } ; p_expr : field %prec CAT /* removes field (++|--) sr conflict */ { field_A2I() ; } ; expr : field ASSIGN expr { code1(F_ASSIGN) ; } | field ADD_ASG expr { code1(F_ADD_ASG) ; } | field SUB_ASG expr { code1(F_SUB_ASG) ; } | field MUL_ASG expr { code1(F_MUL_ASG) ; } | field DIV_ASG expr { code1(F_DIV_ASG) ; } | field MOD_ASG expr { code1(F_MOD_ASG) ; } | field POW_ASG expr { code1(F_POW_ASG) ; } ; /* split is handled different than a builtin because it takes an array and optionally a regular expression as args */ p_expr : split_front split_back { code2(_BUILTIN, bi_split) ; } ; split_front : SPLIT LPAREN expr COMMA ID { $$ = $3 ; check_array($5) ; code_array($5) ; } ; split_back : RPAREN { code2(_PUSHI, &fs_shadow) ; } | COMMA expr RPAREN { if ( CDP($2) == code_ptr - 2 ) { if ( code_ptr[-2].op == _MATCH0 ) { RE_as_arg() ; } else if ( code_ptr[-2].op == _PUSHS ) { CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = code_ptr[-1].ptr ; cast_for_split(cp) ; code_ptr[-2].op = _PUSHC ; code_ptr[-1].ptr = (PTR) cp ; no_leaks_cell(cp); } } } ; /* distinguish length vs length(string) vs length(array) */ p_expr : LENGTH LPAREN RPAREN { $$ = code_offset ; code2(_PUSHI,field) ; code2(_BUILTIN,bi_length) ; } | LENGTH LPAREN expr RPAREN { $$ = $3 ; code2(_BUILTIN,bi_length) ; } | LENGTH LPAREN ID RPAREN { SYMTAB* stp = $3; $$ = code_offset; switch (stp->type) { case ST_VAR: code2(_PUSHI, stp->stval.cp); code2(_BUILTIN, bi_length); break; case ST_ARRAY: code2(A_PUSHA, stp->stval.array); code2(_BUILTIN, bi_alength); break; case ST_LOCAL_VAR: code2op(L_PUSHI, stp->offset); code2(_BUILTIN, bi_length); break; case ST_LOCAL_ARRAY: code2op(LA_PUSHA, stp->offset); code2(_BUILTIN, bi_alength); break; case ST_NONE: /* defer_alen */ code2(A_LENGTH, stp); code2(_BUILTIN, bi_length); break; case ST_LOCAL_NONE: /* defer_len */ { DEFER_LEN* pi = ZMALLOC(DEFER_LEN); pi->fbp = active_funct; pi->offset = stp->offset; code2(_LENGTH, pi); code2(_BUILTIN, bi_length); } break; default: type_error(stp); break; } } ; p_expr : LENGTH %prec CAT /* fixes s/r conflict length vs length() */ { $$ = code_offset ; code2(_PUSHI,field) ; code2(_BUILTIN,bi_length) ; } ; /* match(expr, RE) */ p_expr : MATCH_FUNC LPAREN expr COMMA re_arg RPAREN { $$ = $3 ; code2(_BUILTIN, bi_match) ; } ; re_arg : expr { INST *p1 = CDP($1) ; if ( p1 == code_ptr - 2 ) { if ( p1->op == _MATCH0 ) RE_as_arg() ; else if ( p1->op == _PUSHS ) { CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = p1[1].ptr ; cast_to_RE(cp) ; p1->op = _PUSHC ; p1[1].ptr = (PTR) cp ; no_leaks_cell(cp); } } } ; /* exit_statement */ statement : EXIT separator { $$ = code_offset ; code1(_EXIT0) ; } | EXIT expr separator { $$ = $2 ; code1(_EXIT) ; } ; return_statement : RETURN separator { $$ = code_offset ; code1(_RET0) ; } | RETURN expr separator { $$ = $2 ; code1(_RET) ; } ; /* getline */ p_expr : getline %prec GETLINE { $$ = code_offset ; code2(F_PUSHA, &field[0]) ; code1(_PUSHINT) ; code1(0) ; code2(_BUILTIN, bi_getline) ; getline_flag = 0 ; } | getline fvalue %prec GETLINE { $$ = $2 ; code1(_PUSHINT) ; code1(0) ; code2(_BUILTIN, bi_getline) ; getline_flag = 0 ; } | getline_file p_expr %prec IO_IN { code1(_PUSHINT) ; code1(F_IN) ; code2(_BUILTIN, bi_getline) ; /* getline_flag already off in yylex() */ } | p_expr PIPE GETLINE { code2(F_PUSHA, &field[0]) ; code1(_PUSHINT) ; code1(PIPE_IN) ; code2(_BUILTIN, bi_getline) ; } | p_expr PIPE GETLINE fvalue { code1(_PUSHINT) ; code1(PIPE_IN) ; code2(_BUILTIN, bi_getline) ; } ; getline : GETLINE { getline_flag = 1 ; } ; fvalue : lvalue | field ; getline_file : getline IO_IN { $$ = code_offset ; code2(F_PUSHA, field+0) ; } | getline fvalue IO_IN { $$ = $2 ; } ; /*========================================== sub and gsub ==========================================*/ p_expr : sub_or_gsub LPAREN re_arg COMMA expr sub_back { INST *p5 = CDP($5) ; INST *p6 = CDP($6) ; if ( p6 - p5 == 2 && p5->op == _PUSHS ) { /* cast from STRING to REPL at compile time */ CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = p5[1].ptr ; cast_to_REPL(cp) ; p5->op = _PUSHC ; p5[1].ptr = (PTR) cp ; no_leaks_cell(cp); } code2(_BUILTIN, $1) ; $$ = $3 ; } ; sub_or_gsub : SUB { $$ = bi_sub ; } | GSUB { $$ = bi_gsub ; } ; sub_back : RPAREN /* substitute into $0 */ { $$ = code_offset ; code2(F_PUSHA, &field[0]) ; } | COMMA fvalue RPAREN { $$ = $2 ; } ; /*================================================ user defined functions *=================================*/ function_def : funct_start block { resize_fblock($1) ; restore_ids() ; switch_code_to_main() ; } ; funct_start : funct_head LPAREN f_arglist RPAREN { eat_nl() ; scope = SCOPE_FUNCT ; active_funct = $1 ; *main_code_p = active_code ; $1->nargs = (NUM_ARGS) $3 ; if ( $3 ) $1->typev = (SYM_TYPE *) memset( zmalloc((size_t) $3), ST_LOCAL_NONE, (size_t) $3) ; else $1->typev = (SYM_TYPE *) 0 ; code_ptr = code_base = (INST *) zmalloc(INST_BYTES(PAGESZ)); code_limit = code_base + PAGESZ ; code_warn = code_limit - CODEWARN ; improve_arglist($1->name); free_arglist(); } ; funct_head : FUNCTION ID { FBLOCK *fbp ; if ( $2->type == ST_NONE ) { $2->type = ST_FUNCT ; fbp = $2->stval.fbp = ZMALLOC(FBLOCK) ; fbp->name = $2->name ; fbp->code = (INST*) 0 ; } else { type_error( $2 ) ; /* this FBLOCK will not be put in the symbol table */ fbp = ZMALLOC(FBLOCK) ; fbp->name = "" ; } $$ = fbp ; } | FUNCTION FUNCT_ID { $$ = $2 ; if ( $2->code ) compile_error("redefinition of %s" , $2->name) ; } ; f_arglist : /* empty */ { $$ = init_arglist() ; } | f_args ; f_args : ID { init_arglist(); $1 = save_arglist($1->name) ; $1->offset = 0 ; $$ = 1 ; } | f_args COMMA ID { if ( is_local($3) ) compile_error("%s is duplicated in argument list", $3->name) ; else { $3 = save_arglist($3->name) ; $3->offset = (unsigned char) $1 ; $$ = $1 + 1 ; } } ; outside_error : error { /* we may have to recover from a bungled function definition */ /* can have local ids, before code scope changes */ restore_ids() ; switch_code_to_main() ; } ; /* a call to a user defined function */ p_expr : FUNCT_ID mark call_args { $$ = $2 ; code2(_CALL, $1) ; if ( $3 ) code1($3->arg_num+1) ; else code1(0) ; check_fcall($1, scope, code_move_level, active_funct, $3) ; } ; call_args : LPAREN RPAREN { $$ = (CA_REC *) 0 ; } | ca_front ca_back { $$ = $2 ; $$->link = $1 ; $$->arg_num = (NUM_ARGS) ($1 ? $1->arg_num+1 : 0) ; $$->call_lineno = token_lineno; } ; /* The funny definition of ca_front with the COMMA bound to the ID is to force a shift to avoid a reduce/reduce conflict ID->id or ID->array Or to avoid a decision, if the type of the ID has not yet been determined */ ca_front : LPAREN { $$ = (CA_REC *) 0 ; } | ca_front expr COMMA { $$ = ZMALLOC(CA_REC) ; $$->link = $1 ; $$->type = CA_EXPR ; $$->arg_num = (NUM_ARGS) ($1 ? $1->arg_num+1 : 0) ; $$->call_offset = code_offset ; $$->call_lineno = token_lineno; } | ca_front ID COMMA { $$ = ZMALLOC(CA_REC) ; $$->type = ST_NONE ; $$->link = $1 ; $$->arg_num = (NUM_ARGS) ($1 ? $1->arg_num+1 : 0) ; $$->call_lineno = token_lineno; code_call_id($$, $2) ; } ; ca_back : expr RPAREN { $$ = ZMALLOC(CA_REC) ; $$->type = CA_EXPR ; $$->call_offset = code_offset ; } | ID RPAREN { $$ = ZMALLOC(CA_REC) ; $$->type = ST_NONE ; code_call_id($$, $1) ; } ; %% /* * Check for special case where there is a forward reference to a newly * declared function using an array parameter. Because the parameter * mechanism for arrays uses a different byte code, we would like to know * if this is the case so that the function's contents can handle the array * type. */ static void improve_arglist(const char *name) { CA_REC *p, *p2; FCALL_REC *q; TRACE(("improve_arglist(%s)\n", name)); for (p = active_arglist; p != 0; p = p->link) { if (p->type == ST_LOCAL_NONE) { for (q = resolve_list; q != 0; q = q->link) { if (!strcmp(q->callee->name, name)) { for (p2 = q->arg_list; p2 != 0; p2 = p2->link) { if (p2->arg_num == p->arg_num) { switch (p2->type) { case ST_NONE: case ST_LOCAL_NONE: break; default: p->type = p2->type; p->sym_p->type = p2->type; TRACE(("...set arg %d of %s to %s\n", p->arg_num + 1, name, type_to_str(p->type))); break; } } } if (p->type != ST_LOCAL_NONE) break; } } if (p->type != ST_LOCAL_NONE) break; } } } /* maintain data for f_arglist to make it visible in funct_start */ static int init_arglist(void) { free_arglist(); return 0; } static SYMTAB * save_arglist(const char *s) { SYMTAB *result = save_id(s); CA_REC *saveit = ZMALLOC(CA_REC); if (saveit != 0) { CA_REC *p, *q; int arg_num = 0; for (p = active_arglist, q = 0; p != 0; q = p, p = p->link) { ++arg_num; } saveit->link = 0; saveit->type = ST_LOCAL_NONE; saveit->arg_num = (NUM_ARGS) arg_num; saveit->call_lineno = token_lineno; saveit->sym_p = result; if (q != 0) { q->link = saveit; } else { active_arglist = saveit; } } return result; } static void free_arglist(void) { while (active_arglist != 0) { CA_REC *next = active_arglist->link; ZFREE(active_arglist); active_arglist = next; } } /* resize the code for a user function */ static void resize_fblock(FBLOCK * fbp) { CODEBLOCK *p = ZMALLOC(CODEBLOCK); code2op(_RET0, _HALT); /* make sure there is always a return */ *p = active_code; fbp->code = code_shrink(p, &fbp->size); /* code_shrink() zfrees p */ if (dump_code_flag) add_to_fdump_list(fbp); } /* convert FE_PUSHA to FE_PUSHI or F_PUSH to F_PUSHI */ static void field_A2I(void) { if (code_ptr[-1].op == FE_PUSHA && code_ptr[-1].ptr == (PTR) 0) { /* On most architectures, the two tests are the same; a good compiler might eliminate one. On LM_DOS, and possibly other segmented architectures, they are not */ code_ptr[-1].op = FE_PUSHI; } else { CELL *cp = (CELL *) code_ptr[-1].ptr; if ((cp == field) || ((cp > NF) && (cp <= LAST_PFIELD))) { code_ptr[-2].op = _PUSHI; } else if (cp == NF) { code_ptr[-2].op = NF_PUSHI; code_ptr--; } else { code_ptr[-2].op = F_PUSHI; code_ptr->op = field_addr_to_index(code_ptr[-1].ptr); code_ptr++; } } } /* we've seen an ID in a context where it should be a VAR, check that's consistent with previous usage */ static void check_var(SYMTAB * p) { switch (p->type) { case ST_NONE: /* new id */ p->type = ST_VAR; p->stval.cp = ZMALLOC(CELL); p->stval.cp->type = C_NOINIT; break; case ST_LOCAL_NONE: p->type = ST_LOCAL_VAR; active_funct->typev[p->offset] = ST_LOCAL_VAR; break; case ST_VAR: case ST_LOCAL_VAR: break; default: type_error(p); break; } } /* we've seen an ID in a context where it should be an ARRAY, check that's consistent with previous usage */ static void check_array(SYMTAB * p) { switch (p->type) { case ST_NONE: /* a new array */ p->type = ST_ARRAY; p->stval.array = new_ARRAY(); no_leaks_array(p->stval.array); break; case ST_ARRAY: case ST_LOCAL_ARRAY: break; case ST_LOCAL_NONE: p->type = ST_LOCAL_ARRAY; active_funct->typev[p->offset] = ST_LOCAL_ARRAY; break; default: type_error(p); break; } } static void code_array(SYMTAB * p) { if (is_local(p)) code2op(LA_PUSHA, p->offset); else code2(A_PUSHA, p->stval.array); } /* we've seen an ID as an argument to a user defined function */ static void code_call_id(CA_REC * p, SYMTAB * ip) { static CELL dummy; p->call_offset = code_offset; /* This always gets set now. So that fcall:relocate_arglist works. */ switch (ip->type) { case ST_VAR: p->type = CA_EXPR; code2(_PUSHI, ip->stval.cp); break; case ST_LOCAL_VAR: p->type = CA_EXPR; code2op(L_PUSHI, ip->offset); break; case ST_ARRAY: p->type = CA_ARRAY; code2(A_PUSHA, ip->stval.array); break; case ST_LOCAL_ARRAY: p->type = CA_ARRAY; code2op(LA_PUSHA, ip->offset); break; /* not enough info to code it now; it will have to be patched later */ case ST_NONE: p->type = ST_NONE; p->sym_p = ip; code2(_PUSHI, &dummy); break; case ST_LOCAL_NONE: p->type = ST_LOCAL_NONE; p->type_p = &active_funct->typev[ip->offset]; code2op(L_PUSHI, ip->offset); break; #ifdef DEBUG default: bozo("code_call_id"); #endif } } /* an RE by itself was coded as _MATCH0 , change to push as an expression */ static void RE_as_arg(void) { CELL *cp = ZMALLOC(CELL); code_ptr -= 2; cp->type = C_RE; cp->ptr = code_ptr[1].ptr; code2(_PUSHC, cp); no_leaks_cell_ptr(cp); } /* reset the active_code back to the MAIN block */ static void switch_code_to_main(void) { switch (scope) { case SCOPE_BEGIN: *begin_code_p = active_code; active_code = *main_code_p; break; case SCOPE_END: *end_code_p = active_code; active_code = *main_code_p; break; case SCOPE_FUNCT: active_code = *main_code_p; break; case SCOPE_MAIN: break; } active_funct = (FBLOCK *) 0; scope = SCOPE_MAIN; } void parse(void) { if (yyparse() || compile_error_count != 0) mawk_exit(2); scan_cleanup(); set_code(); /* code must be set before call to resolve_fcalls() */ if (resolve_list) resolve_fcalls(); if (compile_error_count != 0) mawk_exit(2); if (dump_code_flag) { dump_code(); mawk_exit(0); } } mawk-1.3.4-20240123/init.h0000644000000000000000000000212613721331066013166 0ustar rootroot/******************************************** init.h copyright 2009-2016,2020, Thomas E. Dickey copyright 1991, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: init.h,v 1.7 2020/08/26 00:52:06 tom Exp $ */ /* init.h */ #ifndef INIT_H #define INIT_H #include "symtype.h" /* nodes to link file names for multiple -f option */ typedef struct pfile { struct pfile *link; char *fname; } PFILE; extern PFILE *pfile_list; extern char *sprintf_buff, *sprintf_limit; void initialize(int, char **); void code_init(void); void code_cleanup(void); void compile_cleanup(void); void scan_init(const char *); void bi_vars_init(void); void bi_funct_init(void); void print_init(void); void kw_init(void); void field_init(void); void fpe_init(void); void load_environ(ARRAY); void set_stdio(void); void print_version(FILE *fp); int is_cmdline_assign(char *); #endif /* INIT_H */ mawk-1.3.4-20240123/init.c0000644000000000000000000004140714520402063013160 0ustar rootroot/******************************************** init.c copyright 2008-2021,2023, Thomas E. Dickey copyright 1991-1994,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: init.c,v 1.77 2023/11/01 07:54:27 tom Exp $ */ /* init.c */ #include #include #include #include #include #include #include #include #include #include typedef enum { W_UNKNOWN = 0, W_VERSION, #if USE_BINMODE W_BINMODE, #endif W_DUMP, W_EXEC, W_HELP, W_INTERACTIVE, W_POSIX, W_RANDOM, W_RE_INTERVAL, W_SPRINTF, W_TRADITIONAL, W_USAGE, W__IGNORE } W_OPTIONS; #ifdef MSDOS #if HAVE_REARGV extern void reargv(int *, char ***); #endif #endif const char *progname; short interactive_flag = 0; #ifndef SET_PROGNAME #define SET_PROGNAME() \ {char *p = strrchr(argv[0],'/') ;\ progname = p ? p+1 : argv[0] ; } #endif int dump_code_flag = 0; /* if on dump internal code */ short posix_space_flag = 0; short traditional_flag = 0; #ifndef NO_INTERVAL_EXPR #define enable_repetitions(flag) repetitions_flag = flag short repetitions_flag = 1; #else #define enable_repetitions(flag) /* nothing */ #endif #ifdef DEBUG int dump_RE = 1; /* if on dump compiled REs */ #endif /* *INDENT-OFF* */ static const struct { W_OPTIONS code; int mode; /* 0=mawk, 1=both, 2=gawk */ int args; /* nonzero if argument */ const char name[20]; } w_options[] = { { W_VERSION, 1, 0, "version" }, #if USE_BINMODE { W_BINMODE, 0, 0, "binmode" }, #endif { W_DUMP, 0, 0, "dump" }, { W_EXEC, 1, 1, "exec" }, { W_HELP, 1, 0, "help" }, { W_INTERACTIVE, 0, 0, "interactive" }, { W_POSIX, 1, 0, "posix" }, { W_RANDOM, 0, 1, "random" }, { W_RE_INTERVAL, 2, 0, "re-interval" }, { W_SPRINTF, 0, 1, "sprintf" }, { W_TRADITIONAL, 1, 0, "traditional" }, { W_USAGE, 0, 0, "usage" }, { W__IGNORE, 2, 0, "lint" }, { W__IGNORE, 2, 0, "lint-old" }, { W__IGNORE, 2, 0, "non-decimal-data" }, }; /* *INDENT-ON* */ static void no_program(void) { mawk_exit(0); } static void usage(FILE *fp) { static const char msg[][80] = { "Usage: mawk [Options] [Program] [file ...]", "", "Program:", " The -f option value is the name of a file containing program text.", " If no -f option is given, a \"--\" ends option processing; the following", " parameters are the program text.", "", "Options:", " -f program-file Program text is read from file instead of from the", " command-line. Multiple -f options are accepted.", " -F value sets the field separator, FS, to value.", " -v var=value assigns value to program variable var.", " -- unambiguous end of options.", "", " Implementation-specific options are prefixed with \"-W\". They can be", " abbreviated:", "", " -W version show version information and exit.", #if USE_BINMODE " -W binmode", #endif " -W compat pre-POSIX 2001.", " -W dump show assembler-like listing of program and exit.", " -W help show this message and exit.", " -W interactive set unbuffered output, line-buffered input.", " -W exec file use file as program as well as last option.", " -W posix stricter POSIX checking.", " -W random=number set initial random seed.", " -W sprintf=number adjust size of sprintf buffer.", " -W usage show this message and exit.", }; size_t n; for (n = 0; n < TABLESIZE(msg); ++n) { fprintf(fp, "%s\n", msg[n]); } mawk_exit(0); } /* * Compare ignoring case, but warn about mismatches. */ static int ok_abbrev(const char *fullName, const char *partName, int partLen) { int result = 1; int n; for (n = 0; n < partLen; ++n) { UChar ch = (UChar) partName[n]; if (isalpha(ch)) ch = (UChar) toupper(ch); if (ch != (UChar) toupper(fullName[n])) { result = 0; break; } } return result; } static char * skipValue(char *value) { while (*value != '\0' && *value != ',') { ++value; } return value; } static int haveValue(char *value) { int result = 0; if (*value++ == '=') { if (*value != '\0' && strchr("=,", *value) == 0) result = 1; } return result; } static W_OPTIONS parse_w_opt(char *source, char **next, int *args) { W_OPTIONS result = W_UNKNOWN; int match = -1; const char *first; *args = 0; /* forgive and ignore empty options */ while (*source == ',') { ++source; } first = source; if (*source != '\0') { int n; char mark; while (*source != '\0' && *source != ',' && *source != '=') { ++source; } mark = *source; *source = '\0'; for (n = 0; n < (int) TABLESIZE(w_options); ++n) { if (w_options[n].mode > 1) continue; if (!strcmp(w_options[n].name, first)) { match = n; break; } if (ok_abbrev(w_options[n].name, first, (int) (source - first))) { if (match >= 0) { errmsg(0, "ambiguous -W value: \"%.*s\" (%s vs %s)", (int) (source - first), first, w_options[match].name, w_options[n].name); } else { match = n; } } } if (match < 0 && ok_abbrev("POSIX_SPACE", first, (int) (source - first))) { errmsg(0, "deprecated option, use -W posix"); for (n = 0; n < (int) TABLESIZE(w_options); ++n) { if (w_options[n].code == W_POSIX) { match = n; break; } } } *source = mark; } *next = source; if (match >= 0) { result = w_options[match].code; *args = w_options[match].args; } return result; } static W_OPTIONS parse_long_opt(char *source, char **next, int *args) { int n; int match = -1; W_OPTIONS result = W_UNKNOWN; const char *first = source; char mark; *args = 0; while (*source != '\0' && *source != '=') { ++source; } mark = *source; *source = '\0'; for (n = 0; n < (int) TABLESIZE(w_options); ++n) { if (!strcmp(w_options[n].name, first)) { match = n; break; } if (ok_abbrev(w_options[n].name, first, (int) (source - first))) { if (match >= 0) { errmsg(0, "ambiguous long option: \"--%.*s\" (--%s vs --%s)", (int) (source - first), first, w_options[match].name, w_options[n].name); } else { match = n; } } } if (match >= 0) { result = w_options[match].code; *args = w_options[match].args; } *source = mark; *next = source; return result; } static long numeric_option(const char *source) { char *next = NULL; long result = strtol(source, &next, 0); if (next == source || next == NULL || (*next != '\0' && *next != ',')) { errmsg(0, "invalid numeric option: \"%s\"", source); mawk_exit(2); } return result; } /* * mawk allows the -W option to have multiple parts, separated by commas. It * does that, to allow multiple -W options in a "sharpbang" line. * * Regarding "sharpbang: * While that is also referred to as a "shebang" or "hashbang" line, those * terms appear to have taken hold after Larry Wall referred to it as * "sharpbang" for changes to rn in 1985. mawk's manual page refers to "magic * number", which is still older, but "sharpbang" is more descriptive. Both * "sharpbang" and "magic number" were used in 4.3BSD, which of course predates * mawk. * * Within each comma-separated chunk, we can have an option value. * For instance: * -Wname1 * -Wname1=value1 * -Wname1=value1,name2 * -Wname1=value1,name2=value2 * * The corresponding long-options are blank-separated, but the "=" mark can * be used: * --name1 * --name1 value1 * --name1=value1 * --name1=value1 --name2 * --name1=value1 --name2=value2 * --name1=value1 --name2 value2 * * The caller has to allow for these cases, by checking the updated "value" * after each call. */ static int handle_w_opt(W_OPTIONS code, int glue, char *option, char **value) { char *optNext = *value; int result = 1; int wantArg = 0; switch (code) { case W_VERSION: print_version(stdout); break; #if USE_BINMODE case W_BINMODE: wantArg = 1; if (optNext != 0) { set_binmode(numeric_option(optNext)); wantArg = 2; } break; #endif case W_TRADITIONAL: traditional_flag = 1; enable_repetitions(0); posix_space_flag = 0; break; case W_DUMP: dump_code_flag = 1; break; case W_EXEC: if (pfile_name) { errmsg(0, "-W exec is incompatible with -f"); mawk_exit(2); } wantArg = 1; if (optNext != 0) { pfile_name = optNext; wantArg = 2; } else { no_program(); } result = 0; /* no_more_opts */ break; case W_INTERACTIVE: interactive_flag = 1; setbuf(stdout, (char *) 0); break; case W_POSIX: posix_space_flag = 1; break; case W_RANDOM: wantArg = 1; if (optNext != 0) { long x = numeric_option(optNext); CELL c[2]; memset(c, 0, sizeof(c)); c[1].type = C_DOUBLE; c[1].dval = (double) x; /* c[1] is input, c[0] is output */ bi_srand(c + 1); wantArg = 2; } break; #ifndef NO_INTERVAL_EXPR case W_RE_INTERVAL: enable_repetitions(1); break; #endif case W_SPRINTF: wantArg = 1; if (optNext != 0) { long x = numeric_option(optNext); if (x > (long) sizeof(string_buff)) { if (sprintf_buff != string_buff && sprintf_buff != 0) { zfree(sprintf_buff, (size_t) (sprintf_limit - sprintf_buff)); } sprintf_buff = (char *) zmalloc((size_t) x); sprintf_limit = sprintf_buff + x; } wantArg = 2; } break; case W_HELP: /* FALLTHRU */ case W_USAGE: usage(stdout); /* NOTREACHED */ break; case W_UNKNOWN: errmsg(0, "vacuous option: -W \"%s\"", option); break; case W__IGNORE: break; } if (wantArg) { if (wantArg == 1) { int length = (int) (skipValue(option) - option); errmsg(0, "missing value for -W \"%.*s\"", length, option); mawk_exit(2); } optNext = skipValue(optNext); } else if (glue) { while (glue) { errmsg(0, "unexpected option value \"%s\"", option); optNext = skipValue(optNext); glue = haveValue(optNext); } } else if (*value == NULL) { optNext = skipValue(option); if (*optNext == ',') ++optNext; } *value = optNext; return result; } static void bad_option(const char *s) { errmsg(0, "not an option: %s", s); mawk_exit(2); } static int allow_long_options(char *arg, W_OPTIONS seen) { char *env = getenv("MAWK_LONG_OPTIONS"); int result = 0; if (env != 0) { switch (*env) { default: case 'e': /* error */ bad_option(arg); break; case 'w': /* warn */ errmsg(0, "ignored option: %s", arg); break; case 'i': /* ignore */ result = (seen != W_UNKNOWN); break; case 'a': /* allow */ result = 1; break; } } else { result = (seen != W_UNKNOWN); } return result; } /* argv[i] = ARGV[i] */ static void set_ARGV(int argc, char **argv, int i) { SYMTAB *st_p; CELL argi; register CELL *cp; st_p = insert("ARGV"); st_p->type = ST_ARRAY; Argv = st_p->stval.array = new_ARRAY(); no_leaks_array(Argv); argi.type = C_DOUBLE; argi.dval = 0.0; cp = array_find(st_p->stval.array, &argi, CREATE); cp->type = C_STRING; cp->ptr = (PTR) new_STRING(progname); /* ARGV[0] is set, do the rest The type of ARGV[1] ... should be C_MBSTRN because the user might enter numbers from the command line */ for (argi.dval = 1.0; i < argc; i++, argi.dval += 1.0) { cp = array_find(st_p->stval.array, &argi, CREATE); cp->type = C_MBSTRN; cp->ptr = (PTR) new_STRING(argv[i]); } ARGC->type = C_DOUBLE; ARGC->dval = argi.dval; } static void process_cmdline(int argc, char **argv) { int i, j, nextarg; char *curArg = NULL; char *optArg; char *optNext; PFILE dummy; /* starts linked list of filenames */ PFILE *tail = &dummy; size_t length; if (argc <= 1) usage(stderr); for (i = 1; i < argc && *(curArg = argv[i]) == '-'; i = nextarg) { if (curArg[1] == 0) { /* "-" alone */ if (!pfile_name) no_program(); break; /* the for loop */ } /* safe to look at argv[i][2] */ /* * Check for "long" options and decide how to handle them. */ if (strlen(curArg) > 2 && !strncmp(curArg, "--", (size_t) 2)) { char *name = curArg + 2; int args; W_OPTIONS code = parse_long_opt(name, &optNext, &args); nextarg = i + 1; if (allow_long_options(curArg, code)) { int glue = haveValue(optNext); char *optValue = (glue ? (optNext + 1) : (args ? argv[nextarg++] : NULL)); if (!handle_w_opt(code, glue, name, &optValue)) { goto no_more_opts; } optNext = optValue; } else { bad_option(curArg); } continue; } if (curArg[2] == 0) { if (i == argc - 1 && curArg[1] != '-') { if (strchr("WFvf", curArg[1])) { errmsg(0, "option %s lacks argument", curArg); mawk_exit(2); } bad_option(curArg); } optArg = argv[i + 1]; nextarg = i + 2; } else { /* argument glued to option */ optArg = &curArg[2]; nextarg = i + 1; } switch (curArg[1]) { case 'W': for (j = 0; j < (int) strlen(optArg); j = (optNext ? (int) (optNext - optArg) : (int) strlen(optArg))) { char *name = optArg + j; int args = 0; W_OPTIONS code = parse_w_opt(name, &optNext, &args); int glue = haveValue(optNext); char *optValue = (glue ? (optNext + 1) : ((strchr(optNext, ',') == NULL) ? (args && argv[nextarg] ? argv[nextarg++] : NULL) : NULL)); int done = !handle_w_opt(code, glue, name, &optValue); i = nextarg; if (done) goto no_more_opts; optNext = optValue; } break; #ifndef NO_INTERVAL_EXPR case 'r': enable_repetitions(1); break; #endif case 'v': if (!is_cmdline_assign(optArg)) { errmsg(0, "improper assignment: -v %s", optArg); mawk_exit(2); } break; case 'F': rm_escape(optArg, &length); /* recognize escape sequences */ cell_destroy(FS); FS->type = C_STRING; FS->ptr = (PTR) new_STRING1(optArg, length); cast_for_split(cellcpy(&fs_shadow, FS)); break; case '-': if (curArg[2] != 0) { bad_option(curArg); } curArg = argv[++i]; goto no_more_opts; case 'f': /* first file goes in pfile_name ; any more go on a list */ if (!pfile_name) pfile_name = optArg; else { tail = tail->link = ZMALLOC(PFILE); tail->fname = optArg; } break; default: bad_option(curArg); } } no_more_opts: tail->link = (PFILE *) 0; pfile_list = dummy.link; if (pfile_name) { set_ARGV(argc, argv, i); scan_init((char *) 0); } else { /* program on command line */ if (i == argc) no_program(); set_ARGV(argc, argv, i + 1); #if defined(MSDOS) && ! HAVE_REARGV /* reversed quotes */ { char *p; for (p = curArg; *p; p++) if (*p == '\'') *p = '\"'; } #endif scan_init(curArg); /* #endif */ } } /*----- ENVIRON ----------*/ #ifdef DECL_ENVIRON #ifndef MSDOS_MSC /* MSC declares it near */ #ifndef environ extern char **environ; #endif #endif #endif void load_environ(ARRAY ENV) { CELL c; register char **p = environ; /* walks environ */ c.type = C_STRING; while (*p) { char *s; /* looks for the '=' */ if ((s = strchr(*p, '='))) { /* shouldn't fail */ CELL *cp; /* pts at ENV[&c] */ size_t len = (size_t) (s - *p); c.ptr = (PTR) new_STRING0(len); memcpy(string(&c)->str, *p, len); s++; cp = array_find(ENV, &c, CREATE); cp->type = C_MBSTRN; cp->ptr = (PTR) new_STRING(s); free_STRING(string(&c)); } p++; } } void initialize(int argc, char **argv) { SET_PROGNAME(); bi_vars_init(); /* load the builtin variables */ bi_funct_init(); /* load the builtin functions */ kw_init(); /* load the keywords */ field_init(); #if USE_BINMODE { char *p = getenv("MAWKBINMODE"); if (p) set_binmode(numeric_option(p)); } #endif process_cmdline(argc, argv); code_init(); fpe_init(); set_stdio(); #if USE_BINMODE stdout_init(); #endif } #ifdef NO_LEAKS typedef struct _all_arrays { struct _all_arrays *next; ARRAY a; } ALL_ARRAYS; static ALL_ARRAYS *all_arrays; void array_leaks(void) { while (all_arrays != 0) { ALL_ARRAYS *next = all_arrays->next; array_clear(all_arrays->a); ZFREE(all_arrays->a); free(all_arrays); all_arrays = next; } } /* use this to identify array leaks */ void no_leaks_array(ARRAY a) { ALL_ARRAYS *p = calloc(1, sizeof(ALL_ARRAYS)); p->next = all_arrays; p->a = a; all_arrays = p; } #endif mawk-1.3.4-20240123/rexp0.c0000644000000000000000000005100413742416200013250 0ustar rootroot/******************************************** rexp0.c copyright 2008-2016,2020, Thomas E. Dickey copyright 2010, Jonathan Nieder copyright 1991-1994,1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: rexp0.c,v 1.46 2020/10/16 22:19:44 tom Exp $ */ /* lexical scanner */ #undef LOCAL_REGEXP /* no need for push/pop */ #include "rexp.h" #include typedef struct { int first; int last; } CCLASS; /* static functions */ static int do_str(int, char **, MACHINE *); static int do_class(char **, MACHINE *); static int escape(char **); static BV *store_bvp(BV *); /* make next array visible */ /* *INDENT-OFF* */ static const char char2token[] = { T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*07*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*0f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*17*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*1f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_END, T_CHAR, T_CHAR, T_CHAR, /*27*/ T_LP, T_RP, T_STAR, T_PLUS, T_CHAR, T_CHAR, T_ANY, T_CHAR, /*2f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*37*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_Q, /*3f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*47*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*4f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*57*/ T_CHAR, T_CHAR, T_CHAR, T_CLASS,T_SLASH,T_CHAR, T_START,T_CHAR, /*5f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*67*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*6f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*77*/ T_CHAR, T_CHAR, T_CHAR, T_LB, T_OR, T_RB, T_CHAR, T_CHAR, /*7f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*87*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*8f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*97*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*9f*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*a7*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*af*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*b7*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*bf*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*c7*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*cf*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*d7*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*df*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*e7*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*ef*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, /*f7*/ T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR, T_CHAR /*ff*/ }; /* *INDENT-ON* */ #define NOT_STARTED (-1) static int prev; static size_t nest; char *re_exp; /* ptr to reg exp string */ static char *re_str; /* base of 're_exp' */ static size_t re_len; #ifndef NO_INTERVAL_EXPR Int intrvalmin; Int intrvalmax; /* * Given a string beginning with T_LB, check if that is an interval expression. */ static int ok_intervals(const char *p) { int result = 0; int comma = 0; int ch; while ((ch = (UChar) * ++p) != '\0') { if (ch == R_CURL) { result = 1; break; } else if (isdigit(ch)) { ; /* zero or more digits */ } else if (ch == ',') { if (++comma > 1) { break; /* zero or one commas */ } } else { break; } } return result; } /* Collect two numbers between T_LB and T_RB, saving the values in intrvalmin and intrvalmax. There are three ways the interval expressions are formed: {n} => previous regexp is repeated n times {n,m} => previous regexp is repeated n to m times {n,} => previous regexp is repeated n or more times {,m} => {0,m} Note: awk doesn't define {,m} returns: T_RB, or on error T_CHAR */ static int do_intervals( char **pp) /* where to put the re_char pointer on exit */ { register char *p; /* runs thru the input */ p = *pp; intrvalmin = 0; intrvalmax = 0; if (!isdigit((UChar) * p) && *p != ',') /* error */ { RE_error_trap(-ERR_7); } if (*p != ',') { intrvalmin = intrvalmin * 10 + *p++ - '0'; while (*p != '\0') { if (isdigit((UChar) * p)) { intrvalmin = intrvalmin * 10 + *p++ - '0'; } else if ((UChar) * p == R_CURL) { p++; *pp = p; intrvalmax = intrvalmin; /* {n} */ return T_RB; } else if ((UChar) * p == ',') { if ((UChar) * ++p == R_CURL) { p++; *pp = p; intrvalmax = MAX__INT; return T_RB; /* {n,} */ } break; } else { p++; *pp = p; RE_error_trap(-ERR_7); } } } else { p++; } while (*p != '\0') { if (isdigit((UChar) * p)) { intrvalmax = intrvalmax * 10 + *p++ - '0'; } else if ((UChar) * p == R_CURL) { if (intrvalmax < intrvalmin) { RE_error_trap(-ERR_7); } p++; break; } else { p++; *pp = p; RE_error_trap(-ERR_7); } } *pp = p; return T_RB; } #endif /* ! NO_INTERVAL_EXPR */ void RE_lex_init(char *re, size_t len) { re_str = re_exp = re; re_len = len + 1; prev = NOT_STARTED; nest = 0; #ifndef NO_INTERVAL_EXPR intrvalmin = 0; intrvalmax = 0; /* {n,} sets max to -1 */ #endif RE_run_stack_init(); RE_pos_stack_init(); } /* * Get the next token from re_str. * * For nullary operations (T_STR, T_ANY, T_U, T_CLASS, T_START, T_END), * before returning the appropriate token, this will write the * corresponding machine to *mp. * * For the rest (T_PLUS, T_STAR, T_OR, T_Q, T_RP, T_LP, T_LB, * T_RB, T_CAT), *mp is left alone. * * Returns 0 for end of regexp. */ int RE_lex(MACHINE * mp) { /* * re_exp records the current position while parsing. * nest records the parenthesis nesting level. * prev records the last token returned. */ register int c; if ((unsigned) (1 + re_exp - re_str) >= re_len) { return 0; } c = char2token[(UChar) (*re_exp)]; #ifndef NO_INTERVAL_EXPR if (repetitions_flag) { if (c == T_LB && !ok_intervals(re_exp)) c = T_CHAR; } else { if (c == T_LB || c == T_RB) { c = T_CHAR; } } #endif switch (c) { case T_PLUS: case T_STAR: if (prev == T_START) RE_error_trap(6); /* fall thru */ case T_OR: case T_Q: re_exp++; return prev = c; #ifndef NO_INTERVAL_EXPR case T_LB: re_exp++; prev = T_LB; break; #endif case T_RP: if (!nest) { /* ) without matching ( is ordinary */ c = T_CHAR; break; } nest--; re_exp++; return prev = c; case 0: return 0; case T_LP: switch (prev) { case T_CHAR: case T_STR: case T_ANY: case T_CLASS: case T_START: case T_RP: case T_PLUS: case T_STAR: case T_Q: case T_U: return prev = T_CAT; #ifndef NO_INTERVAL_EXPR case T_RB: if (!repetitions_flag) { return prev = T_CAT; } #endif /* FALLTHRU */ default: nest++; re_exp++; return prev = T_LP; } /* T_LP switch */ } /* *re_exp is an operand, but implicit cat op is possible */ switch (prev) { case NOT_STARTED: case T_OR: case T_LP: case T_CAT: switch (c) { case T_ANY: { static int plus_is_star_flag = 0; if (*++re_exp == '*') { re_exp++; *mp = RE_u(); return prev = T_U; } else if (*re_exp == '+') { if (plus_is_star_flag) { re_exp++; *mp = RE_u(); plus_is_star_flag = 0; return prev = T_U; } else { plus_is_star_flag = 1; re_exp--; *mp = RE_any(); return prev = T_ANY; } } else { *mp = RE_any(); prev = T_ANY; } } break; case T_SLASH: re_exp++; c = escape(&re_exp); prev = do_str(c, &re_exp, mp); break; #ifndef NO_INTERVAL_EXPR case T_LB: case T_RB: #endif case T_CHAR: c = *re_exp++; prev = do_str(c, &re_exp, mp); break; case T_CLASS: prev = do_class(&re_exp, mp); break; case T_START: *mp = RE_start(); re_exp++; prev = T_START; break; case T_END: re_exp++; *mp = RE_end(); return prev = T_END; default: RE_panic("bad switch in RE_lex"); } /* T_CAT switch */ break; #ifndef NO_INTERVAL_EXPR case T_LB: /* get interval expression numbers until closing T_RB */ prev = do_intervals(&re_exp); return prev = T_RB; case T_RB: /* FALLTHRU */ #endif default: /* don't advance the pointer */ return prev = T_CAT; } /* check for end character */ if (*re_exp == '$') { mp->start->s_type = (SType) (mp->start->s_type + END_ON); re_exp++; } return prev; } /* Collect a run of characters into a string machine. If the run ends at *,+, or ?, then don't take the last character unless the string has length one. */ static int do_str( int c, /* the first character */ char **pp, /* where to put the re_char pointer on exit */ MACHINE * mp) /* where to put the string machine */ { register char *p; /* runs thru the input */ char *pt = 0; /* trails p by one */ char *str; /* collect it here */ register char *s; /* runs thru the output */ size_t len; /* length collected */ p = *pp; s = str = RE_malloc(re_len); *s++ = (char) c; len = 1; while ((1 + p - re_str) < (int) re_len) { char *save; c = char2token[(UChar) (*p)]; #ifndef NO_INTERVAL_EXPR if (!repetitions_flag && (c == T_LB || c == T_RB)) { c = T_CHAR; } #endif switch (c) { case T_CHAR: pt = p; *s++ = *p++; break; case T_SLASH: pt = p; save = p + 1; /* keep p in a register */ *s++ = (char) escape(&save); p = save; break; default: goto out; } len++; } out: /* if len > 1 and we stopped on a ? + or * , need to back up */ if (len > 1 && (*p == '*' || *p == '+' || *p == '?' #ifndef NO_INTERVAL_EXPR || (repetitions_flag == 1 && *p == L_CURL) #endif )) { len--; p = pt; s--; } *s = 0; *pp = p; *mp = RE_str((char *) RE_realloc(str, len + 1), len); return T_STR; } /*-------------------------------------------- BUILD A CHARACTER CLASS *---------------------------*/ #define char_on(b,x) ((b)[(x)>>3] |= (UChar) ( 1 << ((x)&7) )) static void block_on(BV b, int x, int y) /* caller makes sure x<=y and x>0 y>0 */ { int lo = x >> 3; int hi = y >> 3; int r_lo = x & 7; int r_hi = y & 7; if (lo == hi) { b[lo] |= (UChar) ((1 << (r_hi + 1)) - (1 << r_lo)); } else { int i; for (i = lo + 1; i < hi; i++) b[i] = 0xff; b[lo] |= (UChar) (0xff << r_lo); b[hi] |= (UChar) (~(0xff << (r_hi + 1))); } } #define CCLASS_DATA(name) { CCLASS_##name, #name, sizeof(#name) - 1 } typedef enum { CCLASS_NONE = 0, CCLASS_alnum, CCLASS_alpha, CCLASS_blank, CCLASS_cntrl, CCLASS_digit, CCLASS_graph, CCLASS_lower, CCLASS_print, CCLASS_punct, CCLASS_space, CCLASS_upper, CCLASS_xdigit } CCLASS_ENUM; #ifndef isblank #define isblank(c) ((c) == ' ' || (c) == '\t') #endif static CCLASS * lookup_cclass(char **start) { static CCLASS *cclass_data[CCLASS_xdigit]; static const struct { CCLASS_ENUM code; const char name[8]; unsigned size; } cclass_table[] = { CCLASS_DATA(alnum), CCLASS_DATA(alpha), CCLASS_DATA(blank), CCLASS_DATA(cntrl), CCLASS_DATA(digit), CCLASS_DATA(graph), CCLASS_DATA(lower), CCLASS_DATA(print), CCLASS_DATA(punct), CCLASS_DATA(space), CCLASS_DATA(upper), CCLASS_DATA(xdigit), }; CCLASS *result = 0; CCLASS_ENUM code = CCLASS_NONE; const char *name; char *colon; size_t size; size_t item; #ifdef NO_LEAKS if (start == 0) { for (item = 0; item < (sizeof(cclass_data) / sizeof(cclass_data[0])); ++item) { if (cclass_data[item]) { free(cclass_data[item]); cclass_data[item] = 0; } } return 0; } #endif name = (*start += 2); /* point past "[:" */ colon = strchr(name, ':'); if (colon == 0 || colon[1] != ']') { RE_error_trap(-ERR_3); } size = (size_t) (colon - *start); /* length of name */ if (size < 5 || size > 6) { RE_error_trap(-ERR_3); } *start = colon + 2; switch (name[0]) { case 'a': item = ((name[2] == 'n') ? CCLASS_alnum : CCLASS_alpha); break; case 'b': item = CCLASS_blank; break; case 'c': item = CCLASS_cntrl; break; case 'd': item = CCLASS_digit; break; case 'g': item = CCLASS_graph; break; case 'l': item = CCLASS_lower; break; case 'p': item = ((name[1] == 'r') ? CCLASS_print : CCLASS_punct); break; case 's': item = CCLASS_space; break; case 'u': item = CCLASS_upper; break; case 'x': item = CCLASS_xdigit; break; default: item = CCLASS_NONE; break; } if (item-- != CCLASS_NONE && (size == cclass_table[item].size) && !strncmp(name, cclass_table[item].name, size)) { code = cclass_table[item].code; } else { RE_error_trap(-ERR_3); } if ((result = cclass_data[item]) == 0) { int ch = 0; size_t have = 4; size_t used = 0; CCLASS *data = malloc(sizeof(CCLASS) * have); int in_class = 0; int first = -2; int last = -2; for (ch = 0; ch < 256; ++ch) { switch (code) { case CCLASS_NONE: in_class = 0; break; case CCLASS_alnum: in_class = isalnum(ch); break; case CCLASS_alpha: in_class = isalpha(ch); break; case CCLASS_blank: in_class = isblank(ch); break; case CCLASS_cntrl: in_class = iscntrl(ch); break; case CCLASS_digit: in_class = isdigit(ch); break; case CCLASS_graph: in_class = isgraph(ch); break; case CCLASS_lower: in_class = islower(ch); break; case CCLASS_print: in_class = isprint(ch); break; case CCLASS_punct: in_class = ispunct(ch); break; case CCLASS_space: in_class = isspace(ch); break; case CCLASS_upper: in_class = isupper(ch); break; case CCLASS_xdigit: in_class = isxdigit(ch); break; } if (in_class) { if (first >= 0) { last = ch; } else { first = last = ch; } } else if (first >= 0) { if (used + 2 >= have) { have *= 2; data = realloc(data, sizeof(CCLASS) * have); } data[used].first = first; data[used].last = last; ++used; first = last = -2; } } if (first >= 0) { if (used + 2 >= have) { have *= 2; data = realloc(data, sizeof(CCLASS) * have); } data[used].first = first; data[used].last = last; ++used; } data[used].first = -1; cclass_data[item] = data; result = data; } return result; } static CCLASS * get_cclass(char *start, char **next) { CCLASS *result = 0; if (start[0] == '[' && start[1] == ':') { result = lookup_cclass(&start); if (next != 0) { *next = start; } } return result; } /* * Check if we're pointing to a left square-bracket. If so, return nonzero * if that is a literal one, not part of character class, etc. * * http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03_05 */ static int literal_leftsq(char *start) { int result = 0; if (start[0] == '[') { if (get_cclass(start, 0) == 0) result = 1; } return result; } /* build a BV for a character class. *start points at the '[' on exit: *start points at the character after ']' mp points at a machine that recognizes the class */ static int do_class(char **start, MACHINE * mp) { char *p, *q; BV *bvp; int prevc; int comp_flag; int level; CCLASS *cclass; p = (*start) + 1; /* []...] puts ] in a class [^]..] negates a class with ] */ if (literal_leftsq(p) || p[0] == ']') p++; else if (p[0] == '^' && (literal_leftsq(p + 1) || p[1] == ']')) p += 2; /* XXX. Does not handle collating symbols or equivalence * class expressions. See also collect_RE(). */ for (level = 0, q = p;; ++q) { if (*q == '[' && q[1] == ':') { if (++level > 1) RE_error_trap(-ERR_3); } else if (*q == ']') { if (level == 0) break; if (q[-1] != ':') RE_error_trap(-ERR_3); --level; } else if (*q == '\\') { ++q; } if (*q == '\0' && q == (re_str + re_len - 1)) { /* no closing bracket */ RE_error_trap(-ERR_3); } } /* q now pts at the back of the class */ p = *start + 1; *start = q + 1; bvp = (BV *) RE_malloc(sizeof(BV)); memset(bvp, 0, sizeof(BV)); if (*p == '^') { comp_flag = 1; p++; } else comp_flag = 0; prevc = -1; /* indicates - cannot be part of a range */ while (p < q) { switch (*p) { case '\\': ++p; prevc = escape(&p); char_on(*bvp, prevc); break; case '[': if ((cclass = get_cclass(p, &p)) != 0) { while (cclass->first >= 0) { block_on(*bvp, cclass->first, cclass->last); ++cclass; } } else { prevc = (UChar) * p++; char_on(*bvp, prevc); } break; case '-': if (prevc == -1 || p + 1 == q) { prevc = '-'; char_on(*bvp, '-'); p++; } else { int c; char *mark = ++p; if (*p != '\\') c = (UChar) * p++; else { ++p; c = escape(&p); } if (prevc <= c) { block_on(*bvp, prevc, c); prevc = -1; } else { /* back up */ p = mark; prevc = '-'; char_on(*bvp, '-'); } } break; default: prevc = (UChar) * p++; char_on(*bvp, prevc); break; } } if (comp_flag) { for (p = (char *) bvp; p < (char *) bvp + sizeof(BV); p++) { *p = (char) (~*p); } } *mp = RE_class(store_bvp(bvp)); return T_CLASS; } /* storage for bit vectors so they can be reused , stored in an unsorted linear array the array grows as needed */ #define BV_GROWTH 6 static BV **bv_base, **bv_limit; static BV **bv_next; /* next empty slot in the array */ static BV * store_bvp(BV * bvp) { register BV **p; unsigned t; if (bv_next == bv_limit) { /* need to grow */ if (!bv_base) { /* first growth */ t = 0; bv_base = (BV **) RE_malloc(BV_GROWTH * sizeof(BV *)); } else { t = (unsigned) (bv_next - bv_base); bv_base = (BV **) RE_realloc(bv_base, (t + BV_GROWTH) * sizeof(BV *)); } bv_next = bv_base + t; bv_limit = bv_next + BV_GROWTH; } /* put bvp in bv_next as a sentinel */ *bv_next = bvp; p = bv_base; while (memcmp(*p, bvp, sizeof(BV))) p++; if (p == bv_next) { /* it is new */ bv_next++; } else { /* we already have it */ RE_free(bvp); } return *p; } /* ---------- convert escape sequences -------------*/ #define isoctal(x) ((x)>='0'&&(x)<='7') #define NOT_HEX 16 static const char hex_val['f' - 'A' + 1] = { 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15}; /* interpret 1 character as hex */ static int ctohex(int c) { int t; if (isdigit((UChar) c)) return c - '0'; if (isxdigit((UChar) c) && (t = hex_val[c - 'A'])) return t; return NOT_HEX; } /* * Return the char and move the pointer forward. * On entry *s -> at the character after the slash. */ static int escape(char **start_p) { register char *p = *start_p; register unsigned x; unsigned xx; switch (*p) { case 'n': *start_p = p + 1; return '\n'; case 't': *start_p = p + 1; return '\t'; case 'f': *start_p = p + 1; return '\f'; case 'b': *start_p = p + 1; return '\b'; case 'r': *start_p = p + 1; return '\r'; case 'a': *start_p = p + 1; return '\07'; case 'v': *start_p = p + 1; return '\013'; case '\0': return '\\'; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': x = (unsigned) (*p++ - '0'); if (isoctal(*p)) { x = (x << 3) + (unsigned) (*p++ - '0'); if (isoctal(*p)) x = (x << 3) + (unsigned) (*p++ - '0'); } *start_p = p; return (int) (x & 0xff); case 'x': ++p; if ((x = (unsigned) ctohex(*p)) == NOT_HEX) { *start_p = p; return 'x'; } /* look for another hex digit */ if ((xx = (unsigned) ctohex(*++p)) != NOT_HEX) { x = (x << 4) + xx; p++; } *start_p = p; return (int) x; default: /* anything else \c -> c */ *start_p = p + 1; return (UChar) * p; } } mawk-1.3.4-20240123/zmalloc.c0000644000000000000000000001617114464530774013700 0ustar rootroot/******************************************** zmalloc.c copyright 2008-2019,2023, Thomas E. Dickey copyright 1991-1993,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: zmalloc.c,v 1.34 2023/08/08 21:22:04 tom Exp $ */ /* zmalloc.c */ #include "mawk.h" #include "zmalloc.h" #if defined(NO_LEAKS) && defined(HAVE_TSEARCH) #define USE_TSEARCH 1 #endif #ifdef USE_TSEARCH #include #endif #define ZSHIFT 3 #define ZBLOCKSZ BlocksToBytes(1) #define BytesToBlocks(size) ((((unsigned)size) + ZBLOCKSZ - 1) >> ZSHIFT) #define BlocksToBytes(size) ((size) << ZSHIFT) /* * zmalloc() gets memory from malloc() in chunks and cuts these blocks into * smaller pieces that are multiples of eight bytes. When a piece is returned * via zfree(), it goes on a linked linear list indexed by its size. The lists * are an array, pool[]. * * For examples, if you ask for 22 bytes with p = zmalloc(22), you actually get * a piece of size 24. When you free it with zfree(p,22), it is added to the * list at pool[2]. */ #define POOLSZ 16 /* size of zmalloc's pool[] array */ #define CHUNK 256 /* number of ZBLOCKSZ's to get from malloc */ /*****************************************************************************/ /* * zmalloc() implements a scheme which makes it hard to use memory-checking * tools such as valgrind to audit the program to find where there are leaks. * That is due to its maintaining (for speed...) pools of memory chunks. * * Define DEBUG_ZMALLOC to build mawk with a simpler interface to the system * malloc, which verifies whether the size-parameter passed to zfree() is * consistent with the zmalloc() parameter. * * The NO_LEAKS code relies upon this simpler interface. */ #if !defined(DEBUG_ZMALLOC) && defined(NO_LEAKS) #define DEBUG_ZMALLOC 1 #endif #ifdef DEBUG_ZMALLOC #define IsPoolable(blocks) 0 #define Malloc(n) calloc(1,n) #else #define IsPoolable(blocks) ((blocks) <= POOLSZ) #define Malloc(n) malloc(n) #endif #ifdef USE_TSEARCH typedef struct { PTR ptr; size_t size; } PTR_DATA; static void *ptr_data; #if 0 static void show_tsearch(const void *nodep, const VISIT which, const int depth) { const PTR_DATA *p = *(PTR_DATA * const *) nodep; if (which == postorder || which == leaf) { TRACE(("show_data %d:%p ->%p %lu\n", depth, p, p->ptr, p->size)); } } static void show_ptr_data(void) { twalk(ptr_data, show_tsearch); } #define ShowPtrData() show_ptr_data() #else #define ShowPtrData() /* nothing */ #endif static void free_ptr_data(void *a) { TRACE(("free_ptr_data %p -> %p\n", a, ((PTR_DATA *) (a))->ptr)); free(a); } static int compare_ptr_data(const void *a, const void *b) { const PTR_DATA *p = (const PTR_DATA *) a; const PTR_DATA *q = (const PTR_DATA *) b; int result; TRACE2(("compare %p->%p %p->%p\n", p, p->ptr, q, q->ptr)); if (p->ptr > q->ptr) { result = 1; } else if (p->ptr < q->ptr) { result = -1; } else { result = 0; } return result; } static void record_ptr(PTR ptr, size_t size) { PTR_DATA *item; PTR_DATA **result; item = malloc(sizeof(PTR_DATA)); item->ptr = ptr; item->size = size; TRACE(("record_ptr %p -> %p %lu\n", (void *) item, ptr, (unsigned long) size)); result = tsearch(item, &ptr_data, compare_ptr_data); assert(result != 0); assert(*result != 0); TRACE2(("->%p (%p %lu)\n", (*result), (*result)->ptr, (unsigned long) (*result)->size)); ShowPtrData(); } static void finish_ptr(PTR ptr, size_t size) { PTR_DATA dummy; PTR_DATA *later; PTR_DATA **item; void *check; dummy.ptr = ptr; dummy.size = size; TRACE2(("finish_ptr (%p) -> %p %lu\n", &dummy, ptr, (unsigned long) size)); item = tfind(&dummy, &ptr_data, compare_ptr_data); assert(item != 0); assert(*item != 0); TRACE(("finish_ptr %p -> %p %lu\n", (void *) (*item), (*item)->ptr, (unsigned long) (*item)->size)); later = *item; check = tdelete(&dummy, &ptr_data, compare_ptr_data); if (check) { free(later); } ShowPtrData(); } #define FinishPtr(ptr,size) finish_ptr(ptr,size) #define RecordPtr(ptr,size) record_ptr(ptr,size) #else #define FinishPtr(ptr,size) /* nothing */ #define RecordPtr(ptr,size) /* nothing */ #endif /*****************************************************************************/ static void out_of_mem(void) { static char out[] = "out of memory"; if (mawk_state == EXECUTION) { rt_error("%s", out); } else { /* I don't think this will ever happen */ compile_error("%s", out); mawk_exit(2); } } typedef union zblock { char dummy[ZBLOCKSZ]; union zblock *link; } ZBLOCK; /* ZBLOCKS of sizes 1, 2, ... 16 which is bytes of sizes 8, 16, ... , 128 are stored on the linked linear lists in pool[0], pool[1], ... , pool[15] */ static ZBLOCK *pool[POOLSZ]; PTR zmalloc(size_t size) { unsigned blocks = BytesToBlocks(size); size_t bytes = (size_t) BlocksToBytes(blocks); register ZBLOCK *p; static unsigned amt_avail; static ZBLOCK *avail; if (!IsPoolable(blocks)) { p = (ZBLOCK *) Malloc(bytes); if (!p) out_of_mem(); RecordPtr(p, size); } else { if ((p = pool[blocks - 1]) != 0) { pool[blocks - 1] = p->link; } else { if (blocks > amt_avail) { if (amt_avail != 0) /* free avail */ { avail->link = pool[--amt_avail]; pool[amt_avail] = avail; } if (!(avail = (ZBLOCK *) Malloc((size_t) (CHUNK * ZBLOCKSZ)))) { /* if we get here, almost out of memory */ amt_avail = 0; p = (ZBLOCK *) Malloc(bytes); if (!p) out_of_mem(); RecordPtr(p, bytes); return (PTR) p; } else { RecordPtr(avail, CHUNK * ZBLOCKSZ); amt_avail = CHUNK; } } /* get p from the avail pile */ p = avail; avail += blocks; amt_avail -= blocks; } } return (PTR) p; } void zfree(PTR p, size_t size) { unsigned blocks = BytesToBlocks(size); if (!IsPoolable(blocks)) { FinishPtr(p, size); free(p); } else { ((ZBLOCK *) p)->link = pool[--blocks]; pool[blocks] = (ZBLOCK *) p; } } PTR zrealloc(PTR p, size_t old_size, size_t new_size) { register PTR q; TRACE(("zrealloc %p %lu ->%lu\n", p, (unsigned long) old_size, (unsigned long) new_size)); if (new_size > (BlocksToBytes(POOLSZ)) && old_size > (BlocksToBytes(POOLSZ))) { if (!(q = realloc(p, new_size))) { out_of_mem(); } FinishPtr(p, old_size); RecordPtr(q, new_size); #ifdef DEBUG_ZMALLOC if (new_size > old_size) { memset((char *) q + old_size, 0, new_size - old_size); } #endif } else { q = zmalloc(new_size); memcpy(q, p, old_size < new_size ? old_size : new_size); zfree(p, old_size); } return q; } #ifdef NO_LEAKS void zmalloc_leaks(void) { #ifdef USE_TSEARCH TRACE(("zmalloc_leaks\n")); while (ptr_data != 0) { PTR_DATA *data = *(PTR_DATA **) ptr_data; tdelete(data, &ptr_data, compare_ptr_data); free_ptr_data(data); } #endif } #endif mawk-1.3.4-20240123/memory.c0000644000000000000000000000307514457054024013535 0ustar rootroot/******************************************** memory.c copyright 2009-2010,2023 Thomas E. Dickey copyright 1991-1992,1993 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: memory.c,v 1.9 2023/07/22 22:28:36 tom Exp $ */ /* memory.c */ #include "mawk.h" #include "memory.h" STRING null_str = {0, 1, ""}; static STRING * xnew_STRING(size_t len) { STRING *sval = (STRING *) zmalloc(len + STRING_OH); sval->len = len; sval->ref_cnt = 1; return sval; } /* allocate space for a STRING */ STRING * new_STRING0(size_t len) { if (len == 0) { null_str.ref_cnt++; return &null_str; } else { STRING *sval = xnew_STRING(len); sval->str[len] = 0; return sval; } } /* * Create a new string which may contain embedded nulls. */ STRING * new_STRING1(const char *s, size_t len) { if (len == 0) { null_str.ref_cnt++; return &null_str; } else { STRING *sval = xnew_STRING(len); memcpy(sval->str, s, len); sval->str[len] = 0; return sval; } } /* convert char* to STRING* */ STRING * new_STRING(const char *s) { if (s[0] == 0) { null_str.ref_cnt++; return &null_str; } else { STRING *sval = xnew_STRING(strlen(s)); strcpy(sval->str, s); return sval; } } #ifdef DEBUG void DB_free_STRING(STRING * sval) { if (--sval->ref_cnt == 0 && sval != &null_str) { zfree(sval, sval->len + STRING_OH); } } #endif mawk-1.3.4-20240123/zmalloc.h0000644000000000000000000000131714460036266013672 0ustar rootroot/******************************************** zmalloc.h copyright 2009-2010,2023 Thomas E. Dickey copyright 1991,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: zmalloc.h,v 1.8 2023/07/25 21:20:54 tom Exp $ */ #ifndef ZMALLOC_H #define ZMALLOC_H #include extern PTR zmalloc(size_t); extern void zfree(PTR, size_t); extern PTR zrealloc(PTR, size_t, size_t); #define ZMALLOC(type) ((type*)zmalloc(sizeof(type))) #define ZFREE(p) zfree(p,sizeof(*(p))) #endif /* ZMALLOC_H */ mawk-1.3.4-20240123/regexp_system.c0000644000000000000000000001733713705065477015142 0ustar rootroot/* regexp_system.c copyright 2009-2014,2020 Thomas E. Dickey copyright 2005, Aleksey Cheusov This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. */ /* * $MawkId: regexp_system.c,v 1.37 2020/07/19 15:48:15 tom Exp $ */ #include #include #include #include #include #include #include "regexp.h" typedef struct { regex_t re; char *regexp; } mawk_re_t; static mawk_re_t *last_used_regexp = NULL; static int err_code = 0; #define AT_LAST() ((size_t) (source - base) >= limit) #define MORE_CH() ((size_t) (source - base) < limit) #define NEXT_CH() (char) (MORE_CH() ? *source : 0) #define LIMITED() (char) (MORE_CH() ? *source++ : 0) #define IgnoreNull() errmsg(-1, "ignoring embedded null in pattern") #define IgnoreEscaped() errmsg(-1, "ignoring escaped '%c' in pattern", ch) /* * Keep track, for octal and hex escapes: * octal: 2,3,4 * hex: 3,4 */ #define MORE_DIGITS (escape < 4) static char * prepare_regexp(char *regexp, const char *source, size_t limit) { const char *base = source; const char *range = 0; int escape = 0; int cclass = 0; int radix = 0; int state = 0; char *tail = regexp; char ch; int value = 0; int added; TRACE(("in : \"%s\"\n", base)); while ((ch = LIMITED()) != 0) { if (escape) { added = 0; ++escape; switch (radix) { case 16: switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': value = (value << 4) | (ch - '0'); state = MORE_DIGITS; added = 1; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': value = (value << 4) | (10 + (ch - 'a')); state = MORE_DIGITS; added = 1; break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': value = (value << 4) | (10 + (ch - 'A')); state = MORE_DIGITS; added = 1; break; default: state = 0; /* number ended */ break; } if (state) { continue; } else { escape = 0; radix = 0; if (value) { *tail++ = (char) value; } else { IgnoreNull(); } if (added) /* ate the current character? */ continue; } break; case 8: switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': value = (value << 3) | (ch - '0'); state = MORE_DIGITS; added = 1; break; default: state = 0; /* number ended */ break; } if (state) { continue; } else { escape = 0; radix = 0; if (value) { *tail++ = (char) value; } else { IgnoreNull(); } if (added) /* ate the current character? */ continue; } break; } switch (ch) { case '\\': /* FALLTHRU */ case '[': /* FALLTHRU */ case '(': /* FALLTHRU */ case ')': /* FALLTHRU */ case '$': /* FALLTHRU */ case '?': /* FALLTHRU */ case '*': /* FALLTHRU */ case '.': /* FALLTHRU */ case '+': /* FALLTHRU */ case '{': /* FALLTHRU */ case '|': /* FALLTHRU */ *tail++ = '\\'; *tail++ = ch; break; case ']': if (range) { IgnoreEscaped(); } else { *tail++ = ch; } break; case 'n': *tail++ = '\n'; break; case 't': *tail++ = '\t'; break; case 'f': *tail++ = '\f'; break; case 'b': *tail++ = '\b'; break; case 'r': *tail++ = '\r'; break; case 'a': *tail++ = '\07'; break; case 'v': *tail++ = '\013'; break; case 'x': radix = 16; value = 0; state = 1; continue; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': radix = 8; value = (ch - '0'); state = 1; continue; case '^': if (tail - range == 1) *tail++ = '\\'; *tail++ = ch; break; default: *tail++ = ch; break; } escape = 0; } else { switch (ch) { case '\\': if (AT_LAST()) { errmsg(-1, "dangling backslash"); *tail++ = '\\'; *tail++ = '\\'; } else { escape = 1; } break; case '[': if (range == 0) { range = tail; } else { if (NEXT_CH() == ':') { cclass = ':'; } } *tail++ = ch; break; case ']': if (range != 0) { if (cclass != 0) { if (source[-2] == cclass) { cclass = 0; } } else if (tail == range + 1 || (tail == range + 2 && range[1] == '^') || (tail > range + 2)) { range = 0; } } *tail++ = ch; break; case '{': #ifndef NO_INTERVAL_EXPR if (repetitions_flag) { *tail++ = ch; break; } else #endif if (range == 0 && ((tail == regexp) || (tail[-1] == '*') || (tail[-1] == '?'))) { *tail++ = '\\'; *tail++ = ch; break; } /* FALLTHRU */ case '}': #ifndef NO_INTERVAL_EXPR if (repetitions_flag) { *tail++ = ch; break; } else #endif if (range == 0) *tail++ = '\\'; *tail++ = ch; break; default: *tail++ = ch; break; } } } *tail = '\0'; TRACE(("out: \"%s\"\n", regexp)); return tail; } void * REcompile(char *regexp, size_t len) { mawk_re_t *re = (mawk_re_t *) malloc(sizeof(mawk_re_t)); if (re != 0) { size_t need = (len * 2) + 8; /* might double, with escaping */ char *new_regexp = (char *) malloc(need); if (new_regexp != NULL) { char *buffer = new_regexp; assert(need > len); *buffer++ = '('; buffer = prepare_regexp(buffer, regexp, len); *buffer++ = ')'; *buffer = '\0'; assert(strlen(new_regexp) < need); last_used_regexp = re; memset(re, 0, sizeof(mawk_re_t)); re->regexp = strdup(new_regexp); err_code = regcomp(&re->re, new_regexp, REG_EXTENDED); free(new_regexp); if (err_code) { re = NULL; } } else { free(re); re = NULL; } } TRACE(("REcompile(%s) ->%p\n", regexp, re)); return re; } void REdestroy(PTR ptr) { (void) ptr; } /* * Test the regular expression in 'q' against the string 'str'. * The 'len' parameter is ignored since POSIX regular expressions assume 'str' * is a null-terminated string. */ int REtest(char *str, size_t str_len GCC_UNUSED, PTR q) { mawk_re_t *re = (mawk_re_t *) q; TRACE(("REtest: \"%s\" ~ /%s/ @%p", str, re->regexp, re)); last_used_regexp = re; if (regexec(&re->re, str, (size_t) 0, NULL, 0)) { TRACE(("=1\n")); return 0; } else { TRACE(("=0\n")); return 1; } } #define MAX_MATCHES 100 char * REmatch(char *str, size_t str_len GCC_UNUSED, PTR q, size_t *lenp, int no_bol) { mawk_re_t *re = (mawk_re_t *) q; regmatch_t match[MAX_MATCHES]; int flags = (no_bol ? REG_NOTBOL : 0); TRACE(("REmatch: %s \"%s\" ~ /%s/", no_bol ? "any" : "1st", str, re->regexp)); last_used_regexp = re; if (!regexec(&re->re, str, (size_t) MAX_MATCHES, match, flags)) { *lenp = (size_t) (match[0].rm_eo - match[0].rm_so); TRACE(("=%i/%lu\n", match[0].rm_so, (unsigned long) *lenp)); return str + match[0].rm_so; } else { TRACE(("=0\n")); return NULL; } } void REmprint(void *m, FILE *f) { (void) m; (void) f; /* no debugging code available */ abort(); } static char error_buffer[2048]; const char * REerror(void) { if (last_used_regexp) { (void) regerror(err_code, &last_used_regexp->re, error_buffer, sizeof(error_buffer)); } else { char *msg = strerror(errno); const char fmt[] = "malloc failed: %.*s"; sprintf(error_buffer, fmt, (int) (sizeof(error_buffer) - sizeof(fmt) - strlen(msg)), msg); } return error_buffer; } mawk-1.3.4-20240123/bi_vars.h0000644000000000000000000000211314457053772013660 0ustar rootroot/******************************************** bi_vars.h copyright 2010,2023 Thomas E. Dickey copyright 1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: bi_vars.h,v 1.9 2023/07/22 22:28:10 tom Exp $ */ /* bi_vars.h */ #ifndef BI_VARS_H #define BI_VARS_H 1 #include "types.h" /* builtin variables NF, RS, FS, OFMT are stored internally in field[], so side effects of assignment can be handled */ /* NR and FNR must be next to each other */ #define NR bi_vars #define FNR (bi_vars+1) #define ARGC (bi_vars+2) #define FILENAME (bi_vars+3) #define OFS (bi_vars+4) #define ORS (bi_vars+5) #define RLENGTH (bi_vars+6) #define RSTART (bi_vars+7) #define SUBSEP (bi_vars+8) #if USE_BINMODE #define BINMODE (bi_vars+9) #define NUM_BI_VAR 10 #else #define NUM_BI_VAR 9 #endif extern CELL bi_vars[NUM_BI_VAR]; #endif mawk-1.3.4-20240123/hash.c0000644000000000000000000001353114054301730013136 0ustar rootroot/******************************************** hash.c copyright 2008-2012,2021, Thomas E. Dickey copyright 1991-1993,1994, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: hash.c,v 1.20 2021/05/28 23:59:20 tom Exp $ */ /* hash.c */ #include "mawk.h" #include "memory.h" #include "symtype.h" #ifdef NO_LEAKS #include "bi_vars.h" #endif /* * FNV-1 hash function * http://www.isthe.com/chongo/tech/comp/fnv/index.html */ unsigned hash(const char *s) { /* FNV-1 */ register unsigned h = 2166136261U; while (*s) { h ^= (UChar) (*s++); h *= 16777619U; } return h; } unsigned hash2(const char *s, size_t len) { /* FNV-1 */ register unsigned h = 2166136261U; while (len-- != 0) { h ^= (UChar) (*s++); h *= 16777619U; } return h; } typedef struct hash { struct hash *link; SYMTAB symtab; } HASHNODE; static HASHNODE *hash_table[HASH_PRIME]; #ifdef NO_LEAKS static void free_hashnode(HASHNODE *); #else #define free_hashnode(p) zfree(delete(p->symtab.name), sizeof(HASHNODE)) #endif /* insert a string in the symbol table. Caller knows the symbol is not there -- used for initialization */ SYMTAB * insert(const char *s) { register HASHNODE *p = ZMALLOC(HASHNODE); register unsigned h; p->link = hash_table[h = hash(s) % HASH_PRIME]; p->symtab.name = s; #ifdef NO_LEAKS p->symtab.free_name = 0; #endif hash_table[h] = p; return &p->symtab; } /* Find s in the symbol table, if not there insert it, s must be dup'ed */ SYMTAB * find(const char *s) { register HASHNODE *p; HASHNODE *q; unsigned h; p = hash_table[h = hash(s) % HASH_PRIME]; q = (HASHNODE *) 0; while (1) { if (!p) { p = ZMALLOC(HASHNODE); p->symtab.type = ST_NONE; p->symtab.name = strcpy(zmalloc(strlen(s) + 1), s); #ifdef NO_LEAKS p->symtab.free_name = 1; #endif break; } if (strcmp(p->symtab.name, s) == 0) /* found */ { if (!q) /* already at the front */ return &p->symtab; else { /* delete from the list */ q->link = p->link; break; } } q = p; p = p->link; } /* put p on front of the list */ p->link = hash_table[h]; hash_table[h] = p; return &p->symtab; } /* remove a node from the hash table return a ptr to the node */ static unsigned last_hash; static HASHNODE * delete(const char *s) { register HASHNODE *p; HASHNODE *q = (HASHNODE *) 0; unsigned h; p = hash_table[last_hash = h = hash(s) % HASH_PRIME]; while (p) { if (strcmp(p->symtab.name, s) == 0) /* found */ { if (q) q->link = p->link; else hash_table[h] = p->link; return p; } else { q = p; p = p->link; } } #ifdef DEBUG /* we should not ever get here */ bozo("delete"); #endif return (HASHNODE *) 0; } /* when processing user functions, global ids which are replaced by local ids are saved on this list */ static HASHNODE *save_list; /* store a global id on the save list, return a ptr to the local symtab */ SYMTAB * save_id(const char *s) { HASHNODE *p, *q; unsigned h; p = delete(s); q = ZMALLOC(HASHNODE); q->symtab.type = ST_LOCAL_NONE; q->symtab.name = p->symtab.name; /* put q in the hash table */ q->link = hash_table[h = last_hash]; hash_table[h] = q; /* save p */ p->link = save_list; save_list = p; return &q->symtab; } /* restore all global identifiers */ void restore_ids(void) { register HASHNODE *p, *q; q = save_list; save_list = (HASHNODE *) 0; while (q) { register unsigned h; p = q; q = q->link; free_hashnode(p); p->link = hash_table[h = last_hash]; hash_table[h] = p; } } /* search the symbol table backwards for the disassembler. This is slow -- so what */ const char * reverse_find(int type, PTR ptr) { CELL *cp = 0; ARRAY array = 0; static char uk[] = "unknown"; int i; HASHNODE *p; switch (type) { case ST_VAR: case ST_FIELD: cp = *(CELL **) ptr; break; case ST_ARRAY: array = *(ARRAY *) ptr; break; default: return uk; } for (i = 0; i < HASH_PRIME; i++) { p = hash_table[i]; while (p) { if (p->symtab.type == type) { switch (type) { case ST_VAR: case ST_FIELD: if (cp == p->symtab.stval.cp) return p->symtab.name; break; case ST_ARRAY: if (array == p->symtab.stval.array) return p->symtab.name; break; } } p = p->link; } } return uk; } #ifdef NO_LEAKS static void free_symtab_name(HASHNODE * p) { if (p->symtab.free_name) { zfree((PTR) (p->symtab.name), strlen(p->symtab.name) + 1); } } static void free_hashnode(HASHNODE * p) { CELL *cp; TRACE(("...deleting hash %p (%p) %s %d\n", (void *) p, (void *) &(p->symtab), p->symtab.name, p->symtab.type)); p = delete(p->symtab.name); switch (p->symtab.type) { case ST_FUNCT: free_codes(p->symtab.name, p->symtab.stval.fbp->code, p->symtab.stval.fbp->size); if (p->symtab.stval.fbp->nargs) zfree(p->symtab.stval.fbp->typev, p->symtab.stval.fbp->nargs); zfree(p->symtab.stval.fbp, sizeof(FBLOCK)); break; case ST_NONE: break; case ST_VAR: cp = p->symtab.stval.cp; if (cp != 0 && (cp < bi_vars || cp > bi_vars + NUM_BI_VAR)) { switch (cp->type) { case C_STRING: case C_STRNUM: case C_MBSTRN: free_STRING(string(cp)); break; } zfree(cp, sizeof(CELL)); } break; default: break; } free_symtab_name(p); zfree(p, sizeof(HASHNODE)); } void hash_leaks(void) { int i; HASHNODE *p; TRACE(("hash_leaks\n")); for (i = 0; i < HASH_PRIME; i++) { while ((p = hash_table[i]) != 0) { free_hashnode(p); } } } #endif mawk-1.3.4-20240123/package/0000755000000000000000000000000014554027553013454 5ustar rootrootmawk-1.3.4-20240123/package/freebsd/0000755000000000000000000000000014554027553015066 5ustar rootrootmawk-1.3.4-20240123/package/freebsd/Makefile0000644000000000000000000000077214554027553016534 0ustar rootroot# Created by: Pedro F. Giffuni # $FreeBSD: head/lang/mawk/Makefile 516890 2019-11-06 14:17:48Z wen $ PORTNAME= mawk DISTVERSION= 1.3.4.20240123 CATEGORIES= lang MASTER_SITES= https://invisible-island.net/archives/${PORTNAME}/ \ https://invisible-mirror.net/archives/${PORTNAME}/ MAINTAINER= wen@FreeBSD.org COMMENT= Interpreter for the AWK Programming Language LICENSE= GPLv2 GNU_CONFIGURE= yes USES= tar:tgz PLIST_FILES= bin/mawk \ man/man1/mawk.1.gz .include mawk-1.3.4-20240123/package/freebsd/pkg-descr0000644000000000000000000000117413626264446016676 0ustar rootrootmawk is an interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms. mawk is a new awk meaning it implements the AWK language as defined in Aho, Kernighan and Weinberger, The AWK Programming Language, Addison-Wesley Publishing, 1988 (hereafter referred to as the AWK book.) mawk conforms to the Posix 1003.2 (draft 11.3) definition of the AWK language which contains a few features not described in the AWK book, and mawk provides a small number of extensions. WWW: https://invisible-island.net/mawk/ mawk-1.3.4-20240123/package/freebsd/distinfo0000644000000000000000000000024313560553014016617 0ustar rootrootTIMESTAMP = 1573049632 SHA256 (mawk-1.3.4-20190203.tgz) = daacb314029185bbef86b0df5627ad8591378d420fc32236f99f15a9a8a6b840 SIZE (mawk-1.3.4-20190203.tgz) = 466481 mawk-1.3.4-20240123/package/debian/0000755000000000000000000000000014554027553014676 5ustar rootrootmawk-1.3.4-20240123/package/debian/copyright0000644000000000000000000001201114553336360016622 0ustar rootrootUpstream source https://invisible-island.net/mawk/mawk.html Current maintainer: Thomas Dickey ------------------------------------------------------------------------------- mawk 1.3.4 and updates, Copyright: 2008-2023,2024 by Thomas E. Dickey mawk 1.3.4 includes substantial work by others: Copyright 2009-2010 by Jonathan Nieder Copyright 2005 by Aleksey Cheusov mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ------------------------------------------------------------------------------- Files: aclocal.m4 Licence: other-BSD Copyright: 2008-2023,2024 by Thomas E. Dickey Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, distribute with modifications, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. Files: install-sh Copyright: 1994 X Consortium Licence: other-BSD Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other deal- ings in this Software without prior written authorization from the X Consor- tium. FSF changes to this file are in the public domain. Calling this script install-sh is preferred over install.sh, to prevent `make' implicit rules from creating a file called install from it when there is no Makefile. This script is compatible with the BSD install script, but was written from scratch. It can only install one file at a time, a restriction shared with many OS's install programs. Files: debian/* Copyright: 2012-2023,2024 Thomas E. Dickey Licence: other-BSD Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the above listed copyright holder(s) not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. On Debian systems, the complete text of the GNU General Public License can be found in '/usr/share/common-licenses/GPL-2' mawk-1.3.4-20240123/package/debian/docs0000644000000000000000000000001711410227237015534 0ustar rootrootACKNOWLEDGMENT mawk-1.3.4-20240123/package/debian/compat0000644000000000000000000000000314353323347016072 0ustar rootroot12 mawk-1.3.4-20240123/package/debian/postinst0000644000000000000000000000052513707323553016504 0ustar rootroot#! /bin/sh echo "** postinst script for mawk: $*" set -e PRI=50 ALT=mawk PKG=mawk-cur BINDIR=/usr/bin MANDIR=/usr/share/man/man1 if [ $1 != "upgrade" ] then update-alternatives \ --force \ --install \ $BINDIR/$ALT $ALT \ $BINDIR/$PKG $PRI \ --slave $MANDIR/$ALT.1.gz $ALT.1.gz \ $MANDIR/$PKG.1.gz fi #DEBHELPER# exit 0 mawk-1.3.4-20240123/package/debian/prerm0000644000000000000000000000024612370544537015750 0ustar rootroot#! /bin/sh echo "** prerm script for mawk: $*" set -e if [ "x$1" != "xupgrade" ]; then update-alternatives --remove mawk /usr/bin/mawk-cur fi #DEBHELPER# exit 0 mawk-1.3.4-20240123/package/debian/rules0000755000000000000000000000424613726774447015777 0ustar rootroot#!/usr/bin/make -f # MAde with the aid of dh_make, by Craig Small # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Cristoph Lameter. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) CFLAGS = $(shell dpkg-buildflags --get CFLAGS) CXXFLAGS = $(shell dpkg-buildflags --get CXXFLAGS) CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS) LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS) ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif configure: configure-stamp configure-stamp: dh_testdir CFLAGS="$(CFLAGS)" \ CPPFLAGS="$(CPPFLAGS)" \ LDFLAGS="$(LDFLAGS)" ./configure \ --host=$(DEB_HOST_GNU_TYPE) \ --build=$(DEB_BUILD_GNU_TYPE) \ --program-suffix=-cur \ --prefix=/usr \ --mandir=\$${prefix}/share/man \ --sysconfdir=/etc touch configure-stamp build: build-stamp build-stamp: configure-stamp dh_testdir $(MAKE) touch build-stamp clean: dh_testdir dh_testroot [ ! -f Makefile ] || $(MAKE) clean rm -f configure-stamp build-stamp install-stamp \ config.cache config.h config.status config.log makefile rm -f *.o mawk dh_clean install: install-stamp install-stamp: build-stamp dh_testdir dh_testroot dh_prep dh_installdirs $(MAKE) install DESTDIR=$(CURDIR)/debian/mawk-cur touch install-stamp # Build architecture-independent files here. binary-indep: build install # No binary-indep target. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installdocs dh_installexamples dh_installchangelogs CHANGES dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install install-stamp mawk-1.3.4-20240123/package/debian/control0000644000000000000000000000107014353323447016275 0ustar rootrootSource: mawk-cur Maintainer: Thomas E. Dickey Section: interpreters Priority: optional Standards-Version: 4.6.0.1 Build-Depends: debhelper (>= 12) Homepage: https://invisible-island.net/mawk/ Package: mawk-cur Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: pattern scanning and text processing language mawk is an interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms. mawk-1.3.4-20240123/package/debian/source/0000755000000000000000000000000012370244244016166 5ustar rootrootmawk-1.3.4-20240123/package/debian/source/format0000644000000000000000000000001412370244244017374 0ustar rootroot3.0 (quilt) mawk-1.3.4-20240123/package/debian/postrm0000644000000000000000000000075512370544775016160 0ustar rootroot#! /bin/sh echo "** postrm script for mawk: $*" set -e ALT=mawk PKG=mawk-base ETCDIR=/etc/alternatives BINDIR=/usr/bin MANDIR=/usr/share/man/man1 if [ "x$1" = "xremove" ] then # update-alternatives --config mawk if [ -f $BINDIR/$PKG ] then rm -fv $ETCDIR/$ALT rm -fv $BINDIR/$ALT mv -fv $BINDIR/$PKG $BINDIR/$ALT fi if [ -f $MANDIR/$PKG.1.gz ] then rm -fv $ETCDIR/$ALT.1.gz rm -fv $MANDIR/$ALT.1.gz mv -fv $MANDIR/$PKG.1.gz $MANDIR/$ALT.1.gz fi fi #DEBHELPER# exit 0 mawk-1.3.4-20240123/package/debian/watch0000644000000000000000000000016114373273234015723 0ustar rootrootversion=3 opts=passive https://invisible-island.net/archives/mawk/mawk-(\d.\d.\d)-(\d+)\.tgz \ debian uupdate mawk-1.3.4-20240123/package/debian/preinst0000644000000000000000000000066313707323535016310 0ustar rootroot#! /bin/sh echo "** preinst script for mawk: $*" set -e PRI=10 ALT=mawk PKG=mawk-base BINDIR=/usr/bin MANDIR=/usr/share/man/man1 if [ ! -f /usr/bin/mawk-base ] then mv -fv $BINDIR/$ALT $BINDIR/$PKG mv -fv $MANDIR/$ALT.1.gz $MANDIR/$PKG.1.gz fi update-alternatives \ --force \ --install \ $BINDIR/$ALT $ALT \ $BINDIR/$PKG $PRI \ --slave $MANDIR/$ALT.1.gz $ALT.1.gz \ $MANDIR/$PKG.1.gz #DEBHELPER# exit 0 mawk-1.3.4-20240123/package/debian/changelog0000644000000000000000000002222614554027553016554 0ustar rootrootmawk-cur (1.3.4-20240123) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 21 Jan 2024 19:53:26 -0500 mawk-cur (1.3.4-20231210) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 10 Dec 2023 05:50:33 -0500 mawk-cur (1.3.4-20231126) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 26 Nov 2023 04:58:54 -0500 mawk-cur (1.3.4-20231102) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Thu, 02 Nov 2023 19:19:05 -0400 mawk-cur (1.3.4-20231101) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Tue, 31 Oct 2023 17:22:51 -0400 mawk-cur (1.3.4-20230816) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 09 Aug 2023 17:12:22 -0400 mawk-cur (1.3.4-20230808) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 04 Aug 2023 15:21:57 -0400 mawk-cur (1.3.4-20230804) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Tue, 01 Aug 2023 03:38:57 -0400 mawk-cur (1.3.4-20230731) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 31 Jul 2023 04:03:54 -0400 mawk-cur (1.3.4-20230730) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 30 Jul 2023 12:02:57 -0400 mawk-cur (1.3.4-20230726) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 26 Jul 2023 04:09:45 -0400 mawk-cur (1.3.4-20230725) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 17 Jul 2023 16:42:46 -0400 mawk-cur (1.3.4-20230716) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 16 Jul 2023 18:20:07 -0400 mawk-cur (1.3.4-20230712) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 12 Jul 2023 19:23:14 -0400 mawk-cur (1.3.4-20230525) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Thu, 25 May 2023 19:29:39 -0400 mawk-cur (1.3.4-20230404) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 03 Apr 2023 04:26:09 -0400 mawk-cur (1.3.4-20230322) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 22 Mar 2023 19:46:37 -0400 mawk-cur (1.3.4-20230215) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Tue, 14 Feb 2023 03:53:07 -0500 mawk-cur (1.3.4-20230203) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 01 Feb 2023 17:22:34 -0500 mawk-cur (1.3.4-20221229) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Thu, 29 Dec 2022 09:34:47 -0500 mawk-cur (1.3.4-20210824) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Tue, 24 Aug 2021 04:26:27 -0400 mawk-cur (1.3.4-20210528) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 28 May 2021 03:58:39 -0400 mawk-cur (1.3.4-20201023) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 17 Oct 2020 04:19:38 -0400 mawk-cur (1.3.4-20201016) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 10 Oct 2020 04:31:31 -0400 mawk-cur (1.3.4-20201002) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 26 Sep 2020 04:56:07 -0400 mawk-cur (1.3.4-20200925) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 19 Sep 2020 04:27:08 -0400 mawk-cur (1.3.4-20200918) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 08 Jul 2020 19:25:05 -0400 mawk-cur (1.3.4-20200120) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 19 Jan 2020 20:39:59 -0500 mawk-cur (1.3.4-20200106) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 06 Jan 2020 04:38:20 -0500 mawk-cur (1.3.4-20191231) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Tue, 31 Dec 2019 13:58:22 -0500 mawk-cur (1.3.4-20190203) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 03 Feb 2019 17:12:28 -0400 mawk-cur (1.3.4-20190128) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 28 Jan 2019 21:06:36 -0500 mawk-cur (1.3.4-20181114) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 14 Nov 2018 19:35:11 -0500 mawk-cur (1.3.4-20171017) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 16 Oct 2017 20:39:56 -0400 mawk-cur (1.3.4-20161120) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 20 Nov 2016 19:24:02 -0500 mawk-cur (1.3.4-20161107) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 07 Nov 2016 16:36:53 -0500 mawk-cur (1.3.4-20160930) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 30 Sep 2016 13:10:38 -0400 mawk-cur (1.3.4-20160927) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 26 Sep 2016 21:00:51 -0400 mawk-cur (1.3.4-20160918) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 18 Sep 2016 11:50:44 -0400 mawk-cur (1.3.4-20160905) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 05 Sep 2016 09:36:11 -0400 mawk-cur (1.3.4-20160615) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 31 Jul 2016 20:41:40 -0400 mawk-cur (1.3.4-20160313) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 13 Mar 2016 10:23:10 -0400 mawk-cur (1.3.4-20160226) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 26 Feb 2016 16:34:13 -0500 mawk-cur (1.3.4-20150503) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 02 May 2015 07:49:51 -0400 mawk-cur (1.3.4-20141206) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 06 Dec 2014 19:32:21 -0500 mawk-cur (1.3.4-20141027) unstable; urgency=high * fix regression in gsub -- Thomas E. Dickey Mon, 27 Oct 2014 04:24:49 -0400 mawk-cur (1.3.4-20140914) unstable; urgency=low * improve gsub performance * improve field- and buffer-limits * configure-script updates * minor fixes -- Thomas E. Dickey Thu, 05 Jun 2014 19:03:20 -0400 mawk-cur (1.3.4-20131226) unstable; urgency=low * configure-script updates -- Thomas E. Dickey Thu, 26 Dec 2013 18:04:43 -0500 mawk-cur (1.3.4-20130803) unstable; urgency=low * miscellaneous bug-fixes -- Thomas E. Dickey Sat, 03 Aug 2013 09:29:37 -0400 mawk-cur (1.3.4-20130220) unstable; urgency=low * miscellaneous bug-fixes -- Thomas E. Dickey Tue, 19 Feb 2013 06:45:33 -0500 mawk-cur (1.3.4-20121209) unstable; urgency=low * fix regression with LC_NUMERIC feature -- Thomas E. Dickey Thu, 06 Dec 2012 05:23:52 -0500 mawk-cur (1.3.4-20121129) unstable; urgency=low * implement length(array) * make srand/rand more configurable * add strftime and related functions * fix bug in "/dev/stdin" change * improved configure script -- Thomas E. Dickey Fri, 26 Oct 2012 20:06:08 -0400 mawk-cur (1.3.4-20120901) unstable; urgency=low * add icons for webpage -- Thomas E. Dickey Sat, 01 Sep 2012 09:49:14 -0400 mawk-cur (1.3.4-20120627) unstable; urgency=low * implement 'nextfile' -- Thomas E. Dickey Wed, 27 Jun 2012 09:37:01 -0400 mawk-cur (1.3.4-20101210) unstable; urgency=low * update copyright notices -- Thomas E. Dickey Fri, 12 Dec 2010 04:37:19 -0400 mawk-cur (1.3.4-20101207) unstable; urgency=low * bug-fixes -- Thomas E. Dickey Sun, 18 Jul 2010 05:26:54 -0400 mawk-cur (1.3.4-20100625) unstable; urgency=low * Add package scripts to upstream source, for test-builds. -- Thomas E. Dickey Tue, 22 Jun 2010 04:27:28 -0400 mawk-1.3.4-20240123/package/mawk.spec0000644000000000000000000000322314554027553015267 0ustar rootrootSummary: mawk - pattern scanning and text processing language %global AppProgram mawk %global AppVersion 1.3.4 %global AppPatched 20240123 %global MySite https://invisible-island.net # $MawkId: mawk.spec,v 1.118 2024/01/23 21:28:11 tom Exp $ Name: %{AppProgram} Version: %{AppVersion} Release: %{AppPatched} License: GPLv2 Group: Applications/Development URL: %{MySite}/%{AppProgram} Source0: %{MySite}/archives/%{AppProgram}-%{AppVersion}-%{AppPatched}.tgz Packager: Thomas Dickey %description mawk is an interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms. %prep %define debug_package %{nil} %setup -q -n %{AppProgram}-%{AppVersion}-%{AppPatched} %build INSTALL_PROGRAM='${INSTALL}' \ %configure \ --target %{_target_platform} \ --prefix=%{_prefix} \ --bindir=%{_bindir} \ --libdir=%{_libdir} \ --mandir=%{_mandir} make %install [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT strip $RPM_BUILD_ROOT%{_bindir}/%{AppProgram} %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %{_prefix}/bin/%{AppProgram} %{_mandir}/man1/%{AppProgram}.* %{_mandir}/man7/%{AppProgram}-*.* %changelog # each patch should add its ChangeLog entries here * Wed Aug 02 2023 Thomas Dickey - add man7-pages for array/code * Thu Dec 29 2022 Thomas Dickey - update URLs * Mon Jan 06 2020 Thomas Dickey - use hardening flags * Sat Oct 27 2012 Thomas Dickey - cancel any debug-rpm * Sun Jun 20 2010 Thomas Dickey - initial version mawk-1.3.4-20240123/da.c0000644000000000000000000003234714467256336012630 0ustar rootroot/******************************************** da.c copyright 2008-2021,2023, Thomas E. Dickey copyright 1991-1994,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: da.c,v 1.46 2023/08/16 23:33:50 tom Exp $ */ /* da.c */ /* disassemble code */ #include #include #include #include #include typedef struct fdump { struct fdump *link; FBLOCK *data; } DUMP_FUNCS; static DUMP_FUNCS *fdump_list; /* linked list of all user functions */ #ifdef LOCAL_REGEXP #include typedef struct regex { struct regex *link; PTR data; } DUMP_REGEX; static DUMP_REGEX *regex_list; /* list regular expressions dumped */ static void add_to_regex_list(PTR); #else #define add_to_regex_list(p) /* nothing */ #endif /* LOCAL_REGEXP */ typedef struct { char op; const char name[12]; } OP_NAME; static const char *find_bi_name(PF_CP); /* *INDENT-OFF* */ static const OP_NAME simple_code[] = { { _STOP, "stop" }, { FE_PUSHA, "fe_pusha" }, { FE_PUSHI, "fe_pushi" }, { A_TEST, "a_test" }, { A_DEL, "a_del" }, { DEL_A, "del_a" }, { POP_AL, "pop_al" }, { _POP, "pop" }, { _ADD, "add" }, { _SUB, "sub" }, { _MUL, "mul" }, { _DIV, "div" }, { _MOD, "mod" }, { _POW, "pow" }, { _NOT, "not" }, { _UMINUS, "uminus" }, { _UPLUS, "uplus" }, { _TEST, "test" }, { _CAT, "cat" }, { _ASSIGN, "assign" }, { _ADD_ASG, "add_asg" }, { _SUB_ASG, "sub_asg" }, { _MUL_ASG, "mul_asg" }, { _DIV_ASG, "div_asg" }, { _MOD_ASG, "mod_asg" }, { _POW_ASG, "pow_asg" }, { NF_PUSHI, "nf_pushi" }, { F_ASSIGN, "f_assign" }, { F_ADD_ASG, "f_add_asg" }, { F_SUB_ASG, "f_sub_asg" }, { F_MUL_ASG, "f_mul_asg" }, { F_DIV_ASG, "f_div_asg" }, { F_MOD_ASG, "f_mod_asg" }, { F_POW_ASG, "f_pow_asg" }, { _POST_INC, "post_inc" }, { _POST_DEC, "post_dec" }, { _PRE_INC, "pre_inc" }, { _PRE_DEC, "pre_dec" }, { F_POST_INC, "f_post_inc" }, { F_POST_DEC, "f_post_dec" }, { F_PRE_INC, "f_pre_inc" }, { F_PRE_DEC, "f_pre_dec" }, { _EQ, "eq" }, { _NEQ, "neq" }, { _LT, "lt" }, { _LTE, "lte" }, { _GT, "gt" }, { _GTE, "gte" }, { _MATCH2, "match2" }, { _EXIT, "exit" }, { _EXIT0, "exit0" }, { _NEXT, "next" }, { _NEXTFILE, "nextfile" }, { _RET, "ret" }, { _RET0, "ret0" }, { _OMAIN, "omain" }, { _JMAIN, "jmain" }, { OL_GL, "ol_gl" }, { OL_GL_NR, "ol_gl_nr" }, { _HALT, "" } } ; /* *INDENT-ON* */ static const char *jfmt = "%s%s%03d\n"; /* format to print jumps */ static const char *tab2 = "\t\t"; #if OPT_TRACE static FBLOCK * inst2fblock(INST * p) { DUMP_FUNCS *q; FBLOCK *result = NULL; for (q = fdump_list; q != NULL; q = q->link) { if (q->data->code == p) { result = q->data; break; } } return result; } #endif void da_string2(FILE *fp, const char *value, size_t length, int delim) { size_t n; fputc(delim, fp); for (n = 0; n < length; ++n) { UChar ch = (UChar) value[n]; switch (ch) { case '\\': fputc(ch, fp); break; case '\a': /* alert, ascii 7 */ fputs("\\\\", fp); break; case '\b': /* backspace, ascii 8 */ fputs("\\b", fp); break; case '\t': /* tab, ascii 9 */ fputs("\\t", fp); break; case '\n': /* newline, ascii 10 */ fputs("\\n", fp); break; case '\v': /* vertical tab, ascii 11 */ fputs("\\v", fp); break; case '\f': /* formfeed, ascii 12 */ fputs("\\f", fp); break; case '\r': /* carriage return, ascii 13 */ fputs("\\r", fp); break; default: if (ch == delim) fprintf(fp, "\\%c", ch); else if (ch >= 32 && ch < 127) fputc(ch, fp); else fprintf(fp, "\\%03o", ch); break; } } fputc(delim, fp); } void da_string(FILE *fp, const STRING * sparm, int delim) { da_string2(fp, sparm->str, sparm->len, delim); } #define NORMAL_FORM "%03ld .\t" #define ADJUST_FORM "# patching %s\n .\t" INST * da_this(INST * p, INST * start, FILE *fp) { CELL *cp; const char *op_name = da_op_name(p); /* print the relative code address (label) */ fprintf(fp, NORMAL_FORM, (long) (p - start)); switch ((MAWK_OPCODES) (p++->op)) { case _PUSHC: cp = (CELL *) p++->ptr; switch (cp->type) { case C_RE: add_to_regex_list(cp->ptr); fprintf(fp, "%s\t%p\t", op_name, cp->ptr); da_string(fp, re_uncompile(cp->ptr), '/'); fputc('\n', fp); break; case C_SPACE: fprintf(fp, "%s\tspace split\n", op_name); break; case C_SNULL: fprintf(fp, "%s\tnull split\n", op_name); break; case C_REPL: fprintf(fp, "%s\trepl\t", op_name); da_string(fp, repl_uncompile(cp), '"'); fputc('\n', fp); break; case C_REPLV: fprintf(fp, "%s\treplv\t", op_name); da_string(fp, repl_uncompile(cp), '"'); fputc('\n', fp); break; default: fprintf(fp, "%s\tWEIRD\n", op_name);; break; } break; case _PUSHD: fprintf(fp, "%s\t%.6g\n", op_name, *(double *) p++->ptr); break; case _PUSHS: fprintf(fp, "%s\t", op_name); da_string(fp, (STRING *) p++->ptr, '"'); fputc('\n', fp); break; case _MATCH0: case _MATCH1: add_to_regex_list(p->ptr); fprintf(fp, "%s\t%p\t", op_name, p->ptr); da_string(fp, re_uncompile(p->ptr), '/'); fputc('\n', fp); p++; break; case _PUSHA: fprintf(fp, "%s\t%s\n", op_name, reverse_find(ST_VAR, &p++->ptr)); break; case _PUSHI: cp = (CELL *) p++->ptr; if (cp == field) fprintf(fp, "%s\t$0\n", op_name); else if (cp == &fs_shadow) fprintf(fp, "%s\t@fs_shadow\n", op_name); else { const char *name; if (cp > NF && cp <= LAST_PFIELD) name = reverse_find(ST_FIELD, &cp); else name = reverse_find(ST_VAR, &cp); fprintf(fp, "%s\t%s\n", op_name, name); } break; case L_PUSHA: case L_PUSHI: case LAE_PUSHI: case LAE_PUSHA: case LA_PUSHA: fprintf(fp, "%s\t%d\n", op_name, p++->op); break; case F_PUSHA: cp = (CELL *) p++->ptr; if (cp >= NF && cp <= LAST_PFIELD) fprintf(fp, "%s\t%s\n", op_name, reverse_find(ST_FIELD, &cp)); else fprintf(fp, "%s\t$%d\n", op_name, field_addr_to_index(cp)); break; case F_PUSHI: p++; fprintf(fp, "%s\t$%d\n", op_name, p++->op); break; case AE_PUSHA: case AE_PUSHI: case A_PUSHA: fprintf(fp, "%s\t%s\n", op_name, reverse_find(ST_ARRAY, &p++->ptr)); break; case A_LENGTH: { SYMTAB *stp = (SYMTAB *) p++->ptr; fprintf(fp, ADJUST_FORM, type_to_str(stp->type)); TRACE((NORMAL_FORM, (long) (p - 2 - start))); TRACE(("patch/alen %s\n", type_to_str(stp->type))); switch (stp->type) { case ST_VAR: fprintf(fp, "pushi\t%s\t# defer_alen\n", stp->name); break; case ST_ARRAY: fprintf(fp, "a_pusha\t%s\t# defer_alen\n", stp->name); p[1].ptr = (PTR) bi_alength; break; case ST_NONE: fprintf(fp, "pushi\t%s\t# defer_alen\n", "@missing"); break; default: bozo("da A_LENGTH"); /* NOTREACHED */ } } break; case _LENGTH: { DEFER_LEN *dl = (DEFER_LEN *) p++->ptr; FBLOCK *fbp = dl->fbp; short offset = dl->offset; int type = fbp->typev[offset]; fprintf(fp, ADJUST_FORM, type_to_str(type)); TRACE((NORMAL_FORM, (long) (p - 2 - start))); TRACE(("patch/len %s\n", type_to_str(type))); switch (type) { case ST_LOCAL_VAR: fprintf(fp, "l_pushi\t@%hd\t# defer_len\n", offset); break; case ST_LOCAL_ARRAY: fprintf(fp, "la_pusha\t@%hd\t# defer_len\n", offset); p[1].ptr = (PTR) bi_alength; break; case ST_LOCAL_NONE: fprintf(fp, "pushi\t%s\t# defer_len\n", "@missing"); break; default: bozo("da _LENGTH"); /* NOTREACHED */ } } break; case _PUSHINT: fprintf(fp, "%s\t%d\n", op_name, p++->op); break; case _BUILTIN: case _PRINT: fprintf(fp, "%s\n", op_name); ++p; break; case _JMP: case _JNZ: case _JZ: case _LJZ: case _LJNZ: fprintf(fp, jfmt, op_name, (strlen(op_name) < 8) ? tab2 : (tab2 + 1), (p - start) + p->op); p++; break; case SET_ALOOP: fprintf(fp, "%s\t%03ld\n", op_name, (long) (p + p->op - start)); p++; break; case ALOOP: fprintf(fp, "%s\t%03ld\n", op_name, (long) (p - start + p->op)); p++; break; case A_CAT: fprintf(fp, "%s\t%d\n", op_name, p++->op); break; case _CALL: fprintf(fp, "%s\t%s\t%d\n", op_name, ((FBLOCK *) p->ptr)->name, p[1].op); p += 2; break; case _RANGE: fprintf(fp, "%s\t%03ld %03ld %03ld\n", op_name, /* label for pat2, action, follow */ (long) (p - start + p[1].op), (long) (p - start + p[2].op), (long) (p - start + p[3].op)); p += 4; break; default: fprintf(fp, "%s\n", op_name); break; } return p; } void da(INST * p, FILE *fp) { INST *base = p; TRACE(("dump-asm %s\n", ((p == begin_start) ? "BEGIN" : ((p == end_start) ? "END" : ((p == main_start) ? "MAIN" : inst2fblock(p)->name))))); while (p->op != _HALT) { p = da_this(p, base, fp); } fflush(fp); } /* *INDENT-OFF* */ static const struct { PF_CP action ; const char name[10] ; } special_cases[] = { { bi_split, "split" }, { bi_length, "length" }, { bi_alength, "alength" }, { bi_match, "match" }, { bi_getline, "getline" }, { bi_sub, "sub" }, { bi_gsub, "gsub" }, { (PF_CP) 0, "" } } ; /* *INDENT-ON* */ static const char * find_bi_name(PF_CP p) { const BI_REC *q; int i; for (q = bi_funct; q->name; q++) { if (q->fp == p) { /* found */ return q->name; } } /* next check some special cases */ for (i = 0; special_cases[i].action; i++) { if (special_cases[i].action == p) { return special_cases[i].name; } } return "unknown builtin"; } void add_to_fdump_list(FBLOCK * fbp) { DUMP_FUNCS *p = ZMALLOC(DUMP_FUNCS); p->data = fbp; p->link = fdump_list; fdump_list = p; } void dump_funcs(void) { DUMP_FUNCS *p; TRACE(("dump_funcs\n")); while ((p = fdump_list) != NULL) { fprintf(stdout, "function %s\n", p->data->name); da(p->data->code, stdout); fdump_list = p->link; ZFREE(p); } } #ifdef LOCAL_REGEXP static void add_to_regex_list(PTR re) { DUMP_REGEX *p = ZMALLOC(DUMP_REGEX); p->data = re; p->link = regex_list; regex_list = p; } void dump_regex(void) { register DUMP_REGEX *p, *q = regex_list; while (q) { p = q; q = p->link; fprintf(stdout, "# regex %p\n", p->data); REmprint(cast_to_re(p->data), stdout); ZFREE(p); } } #else /* using system regex */ void dump_regex(void) { } #endif /* LOCAL_REGEXP */ /* *INDENT-OFF* */ static const OP_NAME type_names[] = { {C_NOINIT, "noinit"}, {C_DOUBLE, "double"}, {C_STRING, "string"}, {C_STRNUM, "strnum"}, {C_MBSTRN, "mbstrn"}, {C_RE, "re"}, {C_SPACE, "space"}, {C_SNULL, "snull"}, {C_REPL, "repl"}, {C_REPLV, "replv"} }; /* *INDENT-ON* */ const char * da_type_name(CELL *cdp) { int n; const char *result = "?"; for (n = 0; n < (int) TABLESIZE(type_names); ++n) { if (cdp->type == (int) type_names[n].op) { result = type_names[n].name; break; } } return result; } /* *INDENT-OFF* */ static const OP_NAME other_codes[] = { { AE_PUSHA, "ae_pusha" }, { AE_PUSHI, "ae_pushi" }, { ALOOP, "aloop" }, { A_CAT, "a_cat" }, { A_PUSHA, "a_pusha" }, { F_PUSHA, "f_pusha" }, { F_PUSHI, "f_pushi" }, { LAE_PUSHA, "lae_pusha" }, { LAE_PUSHI, "lae_pushi" }, { LA_PUSHA, "la_pusha" }, { L_PUSHA, "l_pusha" }, { L_PUSHI, "l_pushi" }, { SET_ALOOP, "set_al" }, { _CALL, "call" }, { _CALLX, "callx" }, { _JMP, "jmp" }, { _JNZ, "jnz" }, { _JZ, "jz" }, { _LJNZ, "ljnz" }, { _LJZ, "ljz" }, { _MATCH0, "match0" }, { _MATCH1, "match1" }, { _PUSHA, "pusha" }, { _PUSHC, "pushc" }, { _PUSHD, "pushd" }, { _PUSHI, "pushi" }, { _PUSHINT, "pushint" }, { _PUSHS, "pushs" }, { _RANGE, "range" }, { _LENGTH, "defer_len" }, { A_LENGTH, "defer_alen" }, { _HALT, "" } }; /* *INDENT-ON* */ const char * da_op_name(INST * cdp) { int n; const char *result = 0; if (cdp->op == _BUILTIN) { result = find_bi_name((PF_CP) cdp[1].ptr); } else if (cdp->op == _PRINT) { result = ((PF_CP) cdp->ptr == bi_printf ? "printf" : "print"); } else if (cdp->op == _HALT) { result = "halt"; } else { for (n = 0; simple_code[n].op != _HALT; ++n) { if (simple_code[n].op == cdp->op) { result = simple_code[n].name; break; } } if (result == 0) { for (n = 0; other_codes[n].op != _HALT; ++n) { if (other_codes[n].op == cdp->op) { result = other_codes[n].name; break; } } } if (result == 0) { result = "bad instruction"; } } return result; } mawk-1.3.4-20240123/jmp.h0000644000000000000000000000161214457054006013013 0ustar rootroot/******************************************** jmp.h copyright 2009-2010,2023 Thomas E. Dickey copyright 1991, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: jmp.h,v 1.6 2023/07/22 22:28:22 tom Exp $ */ #ifndef MAWK_JMP_H #define MAWK_JMP_H #include "types.h" #include "symtype.h" void BC_new(void); void BC_insert(int, INST *); void BC_clear(INST *, INST *); void code_push(INST *, unsigned, int, FBLOCK *); unsigned code_pop(INST *); void code_jmp(int, INST *); void patch_jmp(INST *); extern int code_move_level; /* used to as one part of unique identification of context when moving code. Global for communication with parser. */ #endif /* MAWK_JMP_H */ mawk-1.3.4-20240123/rexp2.c0000644000000000000000000002074713742423671013276 0ustar rootroot/******************************************** rexp2.c copyright 2009-2017,2020, Thomas E. Dickey copyright 2010, Jonathan Nieder copyright 1991-1992,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: rexp2.c,v 1.32 2020/10/16 23:07:37 tom Exp $ */ /* test a string against a machine */ #include "rexp.h" #define STACKGROWTH 16 RT_STATE *RE_run_stack_base; RT_STATE *RE_run_stack_limit; /* Large model DOS segment arithmetic breaks the current stack. This hack fixes it without rewriting the whole thing, 5/31/91 */ RT_STATE *RE_run_stack_empty; RT_POS_ENTRY *RE_pos_stack_base; RT_POS_ENTRY *RE_pos_stack_limit; RT_POS_ENTRY *RE_pos_stack_empty; void RE_run_stack_init(void) { if (!RE_run_stack_base) { RE_run_stack_base = (RT_STATE *) RE_malloc(sizeof(RT_STATE) * STACKGROWTH); RE_run_stack_limit = RE_run_stack_base + STACKGROWTH; RE_run_stack_empty = RE_run_stack_base - 1; } } void RE_pos_stack_init(void) { if (!RE_pos_stack_base) { RE_pos_stack_base = (RT_POS_ENTRY *) RE_malloc(sizeof(RT_POS_ENTRY) * STACKGROWTH); RE_pos_stack_limit = RE_pos_stack_base + STACKGROWTH; RE_pos_stack_empty = RE_pos_stack_base; RE_pos_stack_base->pos = NULL; /* RE_pos_peek(RE_pos_stack_empty) */ RE_pos_stack_base->owner = -1; /* avoid popping base */ RE_pos_stack_base->prev_offset = 0; /* avoid popping below base */ } } /* sometimes during REmatch(), this stack can grow pretty large. In real life cases, the back tracking usually fails. Some work is needed here to improve the algorithm. I.e., figure out how not to stack useless paths. */ RT_STATE * RE_new_run_stack(void) { size_t oldsize = (size_t) (RE_run_stack_limit - RE_run_stack_base); size_t newsize = oldsize + STACKGROWTH; #ifdef LMDOS /* large model DOS */ /* have to worry about overflow on multiplication (ugh) */ if (newsize >= 4096) RE_run_stack_base = (RT_STATE *) 0; else #endif RE_run_stack_base = (RT_STATE *) realloc(RE_run_stack_base, newsize * sizeof(RT_STATE)); if (!RE_run_stack_base) { fprintf(stderr, "out of memory for RE run time stack\n"); /* this is pretty unusual, I've only seen it happen on weird input to REmatch() under 16bit DOS , the same situation worked easily on 32bit machine. */ mawk_exit(100); } RE_run_stack_limit = RE_run_stack_base + newsize; RE_run_stack_empty = RE_run_stack_base - 1; /* return the new stackp */ return RE_run_stack_base + oldsize; } RT_POS_ENTRY * RE_new_pos_stack(void) { size_t oldsize = (size_t) (RE_pos_stack_limit - RE_pos_stack_base); size_t newsize = oldsize + STACKGROWTH; /* FIXME: handle overflow on multiplication for large model DOS * (see RE_new_run_stack()). */ RE_pos_stack_base = (RT_POS_ENTRY *) realloc(RE_pos_stack_base, newsize * sizeof(RT_POS_ENTRY)); if (!RE_pos_stack_base) { fprintf(stderr, "out of memory for RE string position stack\n"); mawk_exit(100); } RE_pos_stack_limit = RE_pos_stack_base + newsize; RE_pos_stack_empty = RE_pos_stack_base; /* return the new stackp */ return RE_pos_stack_base + oldsize; } #ifdef DEBUG static RT_STATE * slow_push( RT_STATE * sp, STATE * m, char *s, RT_POS_ENTRY * pos_top, int u) { if (sp == RE_run_stack_limit) sp = RE_new_run_stack(); sp->m = m; sp->s = s; sp->u = u; sp->sp = pos_top - RE_pos_stack_base; sp->tp = pos_top->prev_offset; return sp; } #endif #ifdef DEBUG #define push(mx,sx,px,ux) do { \ stackp = slow_push(++stackp, mx, sx, px, ux); \ } while(0) #else #define push(mx,sx,px,ux) do { \ if (++stackp == RE_run_stack_limit) \ stackp = RE_new_run_stack(); \ stackp->m = (mx); \ stackp->s = (sx); \ stackp->u = (ux); \ stackp->sp = (int) ((px) - RE_pos_stack_base); \ stackp->tp = (px)->prev_offset; \ } while(0) #endif #define CASE_UANY(x) case (x)+U_OFF: /* FALLTHRU */ case (x)+U_ON /* * test if str ~ /machine/ */ int REtest(char *str, /* string to test */ size_t len, /* ...its length */ STATE * machine) /* compiled regular-expression */ { register STATE *m = machine; char *s = str; register RT_STATE *stackp; int u_flag; char *str_end = str + len; RT_POS_ENTRY *sp; int t; /*convenient temps */ STATE *tm; TRACE(("REtest: \"%s\" ~ /pattern/\n", str)); /* handle the easy case quickly */ if (m->s_type == M_STR && (m + 1)->s_type == M_ACCEPT) { return str_str(s, len, m->s_data.str, (size_t) m->s_len) != (char *) 0; } else { u_flag = U_ON; stackp = RE_run_stack_empty; sp = RE_pos_stack_empty; RE_init_it_cnt(m); RE_CASE(); } refill: if (stackp == RE_run_stack_empty) { return 0; } m = stackp->m; s = stackp->s; sp = RE_pos_stack_base + stackp->sp; sp->prev_offset = stackp->tp; u_flag = (stackp--)->u; reswitch: switch (m->s_type + u_flag) { case M_STR + U_OFF + END_OFF: if (strncmp(s, m->s_data.str, (size_t) m->s_len)) { RE_FILL(); } s += m->s_len; m++; RE_CASE(); case M_STR + U_OFF + END_ON: if (strcmp(s, m->s_data.str)) { RE_FILL(); } s += m->s_len; m++; RE_CASE(); case M_STR + U_ON + END_OFF: if (!(s = str_str(s, (size_t) (str_end - s), m->s_data.str, (size_t) m->s_len))) { RE_FILL(); } push(m, s + 1, sp, U_ON); s += m->s_len; m++; u_flag = U_OFF; RE_CASE(); case M_STR + U_ON + END_ON: t = (int) (str_end - s) - (int) m->s_len; if (t < 0 || memcmp(s + t, m->s_data.str, (size_t) m->s_len)) { RE_FILL(); } s = str_end; m++; u_flag = U_OFF; RE_CASE(); case M_CLASS + U_OFF + END_OFF: if (s >= str_end || !ison(*m->s_data.bvp, s[0])) { RE_FILL(); } s++; m++; RE_CASE(); case M_CLASS + U_OFF + END_ON: if (s >= str_end) { RE_FILL(); } if ((s + 1) < str_end || !ison(*m->s_data.bvp, s[0])) { RE_FILL(); } s++; m++; RE_CASE(); case M_CLASS + U_ON + END_OFF: for (;;) { if (s >= str_end) { RE_FILL(); } else if (ison(*m->s_data.bvp, s[0])) { break; } s++; } s++; push(m, s, sp, U_ON); m++; u_flag = U_OFF; RE_CASE(); case M_CLASS + U_ON + END_ON: if (s >= str_end || !ison(*m->s_data.bvp, str_end[-1])) { RE_FILL(); } s = str_end; m++; u_flag = U_OFF; RE_CASE(); case M_ANY + U_OFF + END_OFF: if (s >= str_end) { RE_FILL(); } s++; m++; RE_CASE(); case M_ANY + U_OFF + END_ON: if (s >= str_end || (s + 1) < str_end) { RE_FILL(); } s++; m++; RE_CASE(); case M_ANY + U_ON + END_OFF: if (s >= str_end) { RE_FILL(); } s++; push(m, s, sp, U_ON); m++; u_flag = U_OFF; RE_CASE(); case M_ANY + U_ON + END_ON: if (s >= str_end) { RE_FILL(); } s = str_end; m++; u_flag = U_OFF; RE_CASE(); case M_START + U_OFF + END_OFF: case M_START + U_ON + END_OFF: if (s != str) { RE_FILL(); } m++; u_flag = U_OFF; RE_CASE(); case M_START + U_OFF + END_ON: case M_START + U_ON + END_ON: if (s != str || s < str_end) { RE_FILL(); } m++; u_flag = U_OFF; RE_CASE(); case M_END + U_OFF: if (s < str_end) { RE_FILL(); } m++; RE_CASE(); case M_END + U_ON: s += strlen(s); m++; u_flag = U_OFF; RE_CASE(); CASE_UANY(M_U): u_flag = U_ON; m++; RE_CASE(); CASE_UANY(M_1J): m += m->s_data.jump; RE_CASE(); CASE_UANY(M_SAVE_POS): /* save position for a later M_2JC */ sp = RE_pos_push(sp, stackp, s); m++; RE_CASE(); CASE_UANY(M_2JA): /* take the non jump branch */ /* don't stack an ACCEPT */ if ((tm = m + m->s_data.jump)->s_type == M_ACCEPT) { return 1; } push(tm, s, sp, u_flag); m++; RE_CASE(); CASE_UANY(M_2JC): /* take the jump branch if position changed */ #ifndef NO_INTERVAL_EXPR if (m->it_max < MAX__INT && ++(m->it_cnt) >= m->it_max) { RE_pos_pop(&sp, stackp); m++; RE_CASE(); /* test the next thing */ } else #endif /* ! NO_INTERVAL_EXPR */ if (RE_pos_pop(&sp, stackp) == s) { /* did not advance: do not jump back */ m++; RE_CASE(); } /* FALLTHRU */ case (M_2JB) + U_OFF: /* take the jump branch */ /* FALLTHRU */ case (M_2JB) + U_ON: /* don't stack an ACCEPT */ if ((tm = m + 1)->s_type == M_ACCEPT) { return 1; } push(tm, s, sp, u_flag); m += m->s_data.jump; RE_CASE(); CASE_UANY(M_ACCEPT): return 1; default: RE_panic("unexpected case in REtest"); } } #undef push mawk-1.3.4-20240123/trace.c0000644000000000000000000001170214467004457013325 0ustar rootroot/******************************************** trace.c copyright 2012-2019,2023 Thomas E. Dickey This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: trace.c,v 1.19 2023/08/15 23:24:31 tom Exp $ */ #include #include #include static FILE *trace_fp; void Trace(const char *format, ...) { va_list args; if (trace_fp == 0) trace_fp = fopen("Trace.out", "w"); if (trace_fp == 0) rt_error("cannot open Trace.out"); va_start(args, format); vfprintf(trace_fp, format, args); va_end(args); fflush(trace_fp); } void TraceVA(const char *format, va_list args) { vfprintf(trace_fp, format, args); } void TraceCell(CELL *cp) { TRACE(("cell %p ", (void *) cp)); if (cp != 0) { switch ((MAWK_CELL_TYPES) cp->type) { case C_NOINIT: TRACE(("is empty\n")); break; case C_DOUBLE: TRACE(("double %g\n", cp->dval)); break; case C_MBSTRN: case C_STRNUM: case C_STRING: TRACE(("string ")); TraceString(string(cp)); TRACE((" (%d)\n", string(cp)->ref_cnt)); break; case C_SPACE: TRACE(("split on space\n")); break; case C_SNULL: TRACE(("split on the empty string\n")); break; case C_RE: TRACE(("a regular expression at %p: ", cp->ptr)); da_string(trace_fp, re_uncompile(cp->ptr), '/'); fputc('\n', trace_fp); break; case C_REPL: TRACE(("a replacement string at %p: ", cp->ptr)); TraceString(string(cp)); TRACE(("\n")); break; case C_REPLV: TRACE(("a vector replacement, count %d at %p\n", cp->vcnt, cp->ptr)); break; case NUM_CELL_TYPES: /* FALLTHRU */ default: TRACE(("unknown type %d\n", cp->type)); break; } } else { TRACE(("no cell\n")); } } void TraceFunc(const char *name, CELL *sp) { int nargs = sp->type; int n; TRACE(("** %s <-%p\n", name, (void *) sp)); for (n = 0; n < nargs; ++n) { TRACE(("...arg%d: ", n)); TraceCell(sp + n - nargs); } } void TraceInst(INST * p, INST * base) { INST *q = da_this(p, base, trace_fp); TRACE((" ...%ld\n", (long) (q - p))); if (p++ != q) { switch ((MAWK_OPCODES) (base->op)) { case AE_PUSHA: case AE_PUSHI: case A_PUSHA: TRACE(("\tST_ARRAY *%p\n", p->ptr)); break; case F_PUSHA: TRACE(("\tST_FIELD *%p\n", p->ptr)); break; case _BUILTIN: case _PRINT: TRACE(("\tPF_CP *%p\n", p->ptr)); break; case _CALLX: case _CALL: TRACE(("\tFBLOCK *%p\n", p->ptr)); break; case _MATCH0: case _MATCH1: TRACE(("\tregex *%p\n", p->ptr)); break; case _PUSHA: TRACE(("\tST_VAR *%p\n", p->ptr)); break; case _PUSHC: case _PUSHI: TRACE(("\tCELL *%p\n", p->ptr)); break; case _PUSHD: TRACE(("\tdouble *%p\n", p->ptr)); break; case _PUSHS: TRACE(("\tSTRING *%p\n", p->ptr)); break; case ALOOP: case A_CAT: case A_DEL: case A_TEST: case DEL_A: case FE_PUSHA: case FE_PUSHI: case F_ADD_ASG: case F_ASSIGN: case F_DIV_ASG: case F_MOD_ASG: case F_MUL_ASG: case F_POST_DEC: case F_POST_INC: case F_POW_ASG: case F_PRE_DEC: case F_PRE_INC: case F_PUSHI: case F_SUB_ASG: case LAE_PUSHA: case LAE_PUSHI: case LA_PUSHA: case L_PUSHA: case L_PUSHI: case _LENGTH: case A_LENGTH: case NF_PUSHI: case OL_GL: case OL_GL_NR: case POP_AL: case SET_ALOOP: case _ADD: case _ADD_ASG: case _ASSIGN: case _CAT: case _DIV: case _DIV_ASG: case _EQ: case _EXIT0: case _EXIT: case _GT: case _GTE: case _HALT: case _JMAIN: case _JMP: case _JNZ: case _JZ: case _LJNZ: case _LJZ: case _LT: case _LTE: case _MATCH2: case _MOD: case _MOD_ASG: case _MUL: case _MUL_ASG: case _NEQ: case _NEXT: case _NEXTFILE: case _NOT: case _OMAIN: case _POP: case _POST_DEC: case _POST_INC: case _POW: case _POW_ASG: case _PRE_DEC: case _PRE_INC: case _PUSHINT: case _RANGE: case _RET0: case _RET: case _STOP: case _SUB: case _SUB_ASG: case _TEST: case _UMINUS: case _UPLUS: break; } } } void TraceString2(const char *str, size_t len) { size_t limit = len; size_t n; TRACE(("\"")); if (limit) { for (n = 0; n < limit; ++n) { UChar ch = (UChar) str[n]; switch (ch) { case '\"': TRACE(("\\\"")); break; case '\\': TRACE(("\\\\")); break; case '\b': TRACE(("\\b")); break; case '\f': TRACE(("\\f")); break; case '\n': TRACE(("\\n")); break; case '\r': TRACE(("\\r")); break; case '\t': TRACE(("\\t")); break; default: if (ch < 32 || ch > 126) TRACE(("\\%03o", ch)); else TRACE(("%c", ch)); break; } } } TRACE(("\"")); } void TraceString(STRING * sp) { TraceString2(sp ? sp->str : "", sp ? sp->len : 0); } #ifdef NO_LEAKS void trace_leaks(void) { if (trace_fp != 0) { fclose(trace_fp); trace_fp = 0; } } #endif mawk-1.3.4-20240123/parse.c0000644000000000000000000045626714465521004013352 0ustar rootroot/* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ #define YYBYACC 1 #define YYMAJOR 2 #define YYMINOR 0 #define YYPATCH 20230521 #define YYEMPTY (-1) #define yyclearin (yychar = YYEMPTY) #define yyerrok (yyerrflag = 0) #define YYRECOVERING() (yyerrflag != 0) #define YYENOMEM (-2) #define YYEOF 0 #undef YYBTYACC #define YYBTYACC 0 #define YYDEBUGSTR YYPREFIX "debug" #define YYPREFIX "yy" #define YYPURE 0 #line 18 "parse.y" #include #include #include #include #include #include #include #include #include #define YYMAXDEPTH 200 #if defined(YYBYACC) && (YYBYACC < 2) extern int yylex(void); #endif extern void eat_nl(void); static SYMTAB *save_arglist(const char *); static int init_arglist(void); static void RE_as_arg(void); static void check_array(SYMTAB *); static void check_var(SYMTAB *); static void code_array(SYMTAB *); static void code_call_id(CA_REC *, SYMTAB *); static void field_A2I(void); static void free_arglist(void); static void improve_arglist(const char *); static void resize_fblock(FBLOCK *); static void switch_code_to_main(void); static int scope; static FBLOCK *active_funct; static CA_REC *active_arglist; /* when scope is SCOPE_FUNCT */ #define code_address(x) if( is_local(x) ) \ code2op(L_PUSHA, (x)->offset) ;\ else code2(_PUSHA, (x)->stval.cp) #define CDP(x) (code_base+(x)) /* WARNING: These CDP() calculations become invalid after calls that might change code_base. Which are: code2(), code2op(), code_jmp() and code_pop(). */ /* this nonsense caters to MSDOS large model */ #define CODE_FE_PUSHA() code_ptr->ptr = (PTR) 0 ; code1(FE_PUSHA) #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #line 70 "parse.y" typedef union YYSTYPE{ CELL *cp ; SYMTAB *stp ; int start ; /* code starting address as offset from code_base */ PF_CP fp ; /* ptr to a (print/printf) or (sub/gsub) function */ const BI_REC *bip ; /* ptr to info about a builtin */ FBLOCK *fbp ; /* ptr to a function block */ ARG2_REC *arg2p ; CA_REC *ca_p ; int ival ; PTR ptr ; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ #line 95 "parse.c" /* compatibility with bison */ #ifdef YYPARSE_PARAM /* compatibility with FreeBSD */ # ifdef YYPARSE_PARAM_TYPE # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) # else # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) # endif #else # define YYPARSE_DECL() yyparse(void) #endif /* Parameters sent to lex. */ #ifdef YYLEX_PARAM # define YYLEX_DECL() yylex(void *YYLEX_PARAM) # define YYLEX yylex(YYLEX_PARAM) #else # define YYLEX_DECL() yylex(void) # define YYLEX yylex() #endif #if !(defined(yylex) || defined(YYSTATE)) int YYLEX_DECL(); #endif /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) #endif #ifndef YYERROR_CALL #define YYERROR_CALL(msg) yyerror(msg) #endif extern int YYPARSE_DECL(); #define UNEXPECTED 257 #define BAD_DECIMAL 258 #define NL 259 #define SEMI_COLON 260 #define LBRACE 261 #define RBRACE 262 #define LBOX 263 #define RBOX 264 #define COMMA 265 #define IO_OUT 266 #define ASSIGN 267 #define ADD_ASG 268 #define SUB_ASG 269 #define MUL_ASG 270 #define DIV_ASG 271 #define MOD_ASG 272 #define POW_ASG 273 #define QMARK 274 #define COLON 275 #define OR 276 #define AND 277 #define IN 278 #define MATCH 279 #define EQ 280 #define NEQ 281 #define LT 282 #define LTE 283 #define GT 284 #define GTE 285 #define CAT 286 #define GETLINE 287 #define PLUS 288 #define MINUS 289 #define MUL 290 #define DIV 291 #define MOD 292 #define NOT 293 #define UMINUS 294 #define IO_IN 295 #define PIPE 296 #define POW 297 #define INC_or_DEC 298 #define DOLLAR 299 #define FIELD 300 #define LPAREN 301 #define RPAREN 302 #define DOUBLE 303 #define STRING_ 304 #define RE 305 #define ID 306 #define D_ID 307 #define FUNCT_ID 308 #define BUILTIN 309 #define LENGTH 310 #define PRINT 311 #define PRINTF 312 #define SPLIT 313 #define MATCH_FUNC 314 #define SUB 315 #define GSUB 316 #define DO 317 #define WHILE 318 #define FOR 319 #define BREAK 320 #define CONTINUE 321 #define IF 322 #define ELSE 323 #define DELETE 324 #define BEGIN 325 #define END 326 #define EXIT 327 #define NEXT 328 #define NEXTFILE 329 #define RETURN 330 #define FUNCTION 331 #define YYERRCODE 256 typedef short YYINT; static const YYINT yylhs[] = { -1, 0, 0, 36, 36, 36, 37, 40, 37, 41, 37, 42, 37, 43, 44, 37, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 45, 45, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 46, 13, 47, 13, 48, 49, 13, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 10, 25, 25, 26, 26, 8, 5, 4, 27, 27, 6, 6, 6, 7, 7, 50, 50, 17, 4, 51, 4, 52, 4, 16, 4, 4, 18, 18, 19, 19, 53, 53, 13, 13, 10, 15, 15, 4, 4, 20, 4, 11, 11, 11, 11, 11, 15, 13, 13, 13, 13, 13, 13, 13, 15, 22, 54, 54, 15, 15, 15, 15, 15, 23, 4, 4, 21, 21, 15, 15, 15, 15, 15, 55, 12, 12, 9, 9, 15, 28, 28, 24, 24, 38, 29, 30, 30, 34, 34, 35, 35, 39, 15, 31, 31, 32, 32, 32, 33, 33, }; static const YYINT yylen[] = { 2, 1, 2, 1, 1, 2, 1, 0, 3, 0, 3, 0, 3, 0, 0, 6, 3, 3, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 4, 0, 4, 0, 0, 7, 1, 2, 1, 1, 1, 3, 1, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 2, 2, 2, 2, 1, 0, 1, 1, 3, 5, 0, 5, 1, 1, 1, 3, 2, 3, 3, 0, 2, 4, 2, 1, 4, 1, 7, 4, 2, 4, 3, 4, 1, 2, 1, 2, 3, 5, 5, 5, 6, 7, 3, 6, 2, 1, 2, 6, 2, 3, 1, 3, 3, 3, 3, 3, 3, 3, 2, 5, 1, 3, 3, 4, 4, 1, 6, 1, 2, 3, 2, 3, 1, 2, 2, 3, 4, 1, 1, 1, 2, 3, 6, 1, 1, 1, 3, 2, 4, 2, 2, 0, 1, 1, 3, 1, 3, 2, 2, 1, 3, 3, 2, 2, }; static const YYINT yydefred[] = { 0, 167, 0, 149, 0, 0, 0, 0, 0, 117, 0, 57, 58, 61, 0, 82, 82, 0, 0, 0, 155, 156, 7, 9, 0, 0, 6, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 4, 0, 0, 0, 31, 32, 84, 85, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 20, 0, 0, 0, 0, 0, 28, 82, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 75, 0, 120, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 161, 162, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 13, 52, 48, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 130, 0, 159, 0, 5, 152, 150, 151, 0, 17, 25, 0, 0, 26, 27, 0, 0, 0, 140, 29, 30, 0, 142, 0, 16, 21, 23, 100, 0, 104, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 121, 0, 60, 0, 0, 168, 0, 0, 134, 0, 0, 0, 0, 8, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 0, 41, 42, 43, 44, 45, 46, 18, 12, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 153, 0, 102, 0, 0, 0, 0, 114, 141, 143, 95, 0, 105, 106, 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 169, 0, 0, 170, 0, 136, 135, 0, 0, 0, 0, 0, 0, 148, 133, 0, 160, 0, 99, 0, 103, 93, 0, 96, 107, 101, 88, 0, 0, 0, 0, 0, 0, 0, 0, 109, 0, 173, 175, 172, 174, 81, 131, 0, 0, 53, 0, 166, 0, 0, 0, 0, 83, 0, 0, 0, 110, 119, 112, 138, 15, 0, 0, 157, 154, 115, 0, 0, 0, 0, 113, 98, 158, }; #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) static const YYINT yystos[] = { 0, 256, 261, 287, 288, 289, 293, 298, 299, 300, 301, 303, 304, 305, 306, 308, 309, 310, 313, 314, 315, 316, 325, 326, 331, 333, 334, 341, 342, 343, 344, 346, 347, 348, 355, 361, 362, 363, 369, 370, 371, 372, 388, 256, 259, 260, 311, 312, 317, 318, 319, 320, 321, 322, 324, 327, 328, 329, 330, 334, 336, 337, 346, 349, 350, 351, 353, 354, 360, 378, 385, 301, 306, 344, 348, 348, 348, 301, 306, 343, 344, 307, 348, 340, 344, 346, 298, 338, 338, 338, 301, 301, 301, 373, 374, 306, 308, 369, 348, 267, 268, 269, 270, 271, 272, 273, 267, 268, 269, 270, 271, 272, 273, 298, 265, 274, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 375, 348, 288, 289, 290, 291, 292, 296, 297, 265, 302, 387, 301, 334, 301, 334, 295, 343, 344, 345, 262, 378, 301, 301, 378, 378, 301, 306, 346, 378, 378, 378, 346, 378, 256, 262, 337, 378, 337, 337, 260, 346, 352, 337, 338, 337, 346, 338, 344, 338, 338, 265, 302, 302, 265, 302, 263, 301, 364, 365, 301, 302, 306, 346, 346, 346, 334, 334, 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, 346, 376, 381, 379, 380, 306, 346, 346, 346, 346, 346, 346, 346, 334, 335, 378, 348, 348, 348, 348, 348, 287, 348, 346, 346, 356, 306, 367, 368, 295, 346, 260, 306, 346, 346, 338, 378, 378, 378, 323, 384, 260, 302, 346, 386, 301, 339, 346, 358, 359, 318, 263, 263, 263, 346, 278, 346, 359, 302, 306, 346, 366, 358, 302, 302, 265, 265, 346, 346, 346, 346, 345, 302, 265, 302, 265, 302, 278, 260, 302, 263, 337, 302, 337, 302, 340, 266, 383, 265, 301, 359, 359, 359, 306, 264, 265, 302, 265, 302, 302, 306, 356, 377, 275, 346, 306, 306, 359, 302, 346, 378, 346, 346, 264, 264, 264, 298, 302, 335, 382, 265, 302, 357, 302, 264, 302, 346, 345, 378, 378, 302, }; #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ static const YYINT yydgoto[] = { 25, 59, 221, 60, 61, 87, 253, 83, 27, 28, 29, 30, 145, 62, 32, 33, 63, 64, 65, 168, 66, 67, 34, 232, 329, 255, 256, 68, 35, 36, 37, 184, 185, 268, 234, 235, 38, 39, 40, 41, 93, 94, 126, 208, 309, 69, 210, 211, 209, 326, 294, 247, 70, 251, 137, 42, }; static const YYINT yysindex[] = { 57, 0, 268, 0, 2322, 2322, 2322, 23, 2202, 0, 2352, 0, 0, 0, -286, 0, 0, -246, -243, -207, 0, 0, 0, 0, -174, 57, 0, 0, 2322, 349, 122, 2637, 2322, -13, -263, -166, -144, -142, 0, 0, 0, -144, -43, -163, 0, 0, 0, 0, 0, -136, -113, -122, -122, -99, -291, -70, -122, -122, -70, 0, 118, 0, 2578, 343, 343, 1840, 343, 0, 0, 0, 343, 2352, -286, -152, -155, -155, -155, -271, 0, 0, 0, 0, 0, -257, -3, 2143, 0, -84, -81, -79, 2232, 2352, 2352, -144, -144, 0, 0, 0, -65, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 2352, 0, 0, 0, 0, 0, -64, 2352, 2352, 2352, 2352, 2352, 2352, 2352, -68, -13, 2322, 2322, 2322, 2322, 2322, -40, 2322, 2352, 0, 0, 2352, 0, -44, 0, 0, 0, 0, -58, 0, 0, 2352, 1870, 0, 0, 2352, -122, 2578, 0, 0, 0, 2578, 0, -122, 0, 0, 0, 0, -41, 0, 2604, 2262, 0, 2382, -45, 2485, 30, -22, 35, 49, 2352, 11, 0, 2352, 0, 2352, 15, 0, 2412, 2352, 0, -215, 2497, 2658, 2679, 0, 0, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2703, 2352, 2352, 2352, 2352, 0, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, -42, -42, -155, -155, -155, 23, -65, 2512, 2703, 54, 0, 19, 60, 0, 2524, 0, -256, 2616, 2539, 79, 0, 0, 0, 0, 343, 0, 0, 2551, 343, 2292, 77, 2703, 0, 86, 51, 2352, 2352, 2352, 2703, 53, 2703, -110, 0, -125, 2170, 0, 62, 0, 0, 63, 2352, 2703, 2691, 119, 262, 0, 0, 2352, 0, 70, 0, 75, 0, 0, 2352, 0, 0, 0, 0, -231, 2352, -122, 2352, 2352, -80, -69, 7, 0, 87, 0, 0, 0, 0, 0, 0, 66, -68, 0, 2197, 0, 82, 50, 11, 2703, 0, 2703, 2566, 87, 0, 0, 0, 0, 0, 2352, 23, 0, 0, 0, -122, -122, 2703, 84, 0, 0, 0, }; static const YYINT yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 589, 0, 0, 647, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1633, -53, 26, 1691, 0, 0, 0, 0, 0, 0, 0, 0, 1459, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 531, 705, 937, 995, 1053, 0, 415, 0, 0, 473, 0, 0, 1970, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1749, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, 0, 0, 763, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 193, 0, 0, 0, 0, -191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2442, 0, 0, 107, 0, 1924, 0, 0, 0, 0, 0, -212, 273, 348, 2028, 2036, 2048, 2056, 2068, 2076, 2088, 2096, 2108, 2116, 2128, 0, 0, 0, 0, 0, 198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1517, 1575, 1169, 1227, 1285, 1401, 821, 0, -214, 0, 0, 0, 108, 0, 0, 0, 1806, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, -241, 0, -216, 0, 0, 0, 0, -184, 0, -183, 0, 0, 1924, 0, 0, 0, 0, 0, 0, 0, -35, 0, 73, -61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1343, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -92, 81, 0, -108, 0, 879, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2136, 0, 0, 0, 0, }; #if YYBTYACC static const YYINT yycindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #endif static const YYINT yygindex[] = { 0, 21, 103, 0, -50, 17, 0, 161, 0, 0, -7, -1, -211, 1, 0, 32, 0, 0, 0, 0, 0, 0, 0, 141, 0, 229, -115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #define YYTABLESIZE 2988 static const YYINT yytable[] = { 79, 31, 135, 73, 73, 73, 80, 73, 177, 84, 162, 85, 86, 164, 165, 153, 169, 278, 79, 79, 171, 26, 284, 79, 79, 79, 31, 73, 8, 9, 77, 73, 88, 89, 177, 143, 74, 75, 76, 136, 82, 144, 86, 78, 78, 178, 26, 34, 34, 34, 78, 139, 34, 34, 34, 90, 154, 139, 91, 158, 98, 79, 141, 34, 127, 147, 167, 264, 77, 77, 84, 315, 172, 150, 151, 77, 174, 155, 156, 157, 159, 90, 89, 86, 163, 170, 78, 270, 139, 173, 34, 189, 190, 191, 92, 175, 44, 45, 176, 146, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 192, 193, 334, 2, 90, 89, 213, 214, 215, 216, 217, 218, 219, 73, 73, 73, 73, 73, 95, 73, 96, 138, 230, 44, 45, 231, 302, 133, 134, 297, 298, 299, 113, 220, 222, 237, 240, 80, 80, 241, 301, 295, 80, 80, 80, 140, 223, 224, 225, 226, 227, 148, 229, 87, 87, 250, 242, 254, 314, 86, 87, 243, 244, 303, 261, 182, 245, 263, 147, 254, 320, 295, 267, 254, 149, 44, 45, 44, 45, 2, 80, 321, 295, 288, 51, 51, 51, 290, 152, 51, 51, 51, 11, 11, 11, 274, 275, 276, 277, 51, 51, 51, 51, 3, 4, 5, 183, 143, 186, 6, 14, 14, 14, 144, 7, 8, 9, 10, 134, 11, 12, 13, 14, 236, 15, 16, 17, 51, 212, 18, 19, 20, 21, 228, 130, 131, 132, 84, 142, 85, 133, 134, 8, 9, 77, 254, 254, 254, 233, 78, 106, 107, 108, 109, 110, 111, 112, 322, 295, 257, 231, 128, 129, 130, 131, 132, 179, 311, 246, 133, 134, 33, 33, 33, 254, 262, 33, 33, 33, 258, 316, 113, 318, 319, 259, 179, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 260, 1, 331, 295, 317, 265, 2, 280, 143, 281, 8, 9, 77, 282, 144, 333, 33, 78, 220, 222, 49, 49, 49, 91, 91, 49, 49, 49, 92, 92, 287, 293, 3, 4, 5, 49, 49, 49, 6, 295, 296, 335, 336, 7, 8, 9, 10, 300, 11, 12, 13, 14, 306, 15, 16, 17, 324, 307, 18, 19, 20, 21, 160, 49, 312, 44, 45, 2, 161, 313, 22, 23, 330, 323, 337, 163, 24, 106, 107, 108, 109, 110, 111, 112, 117, 118, 119, 120, 121, 122, 123, 124, 125, 3, 4, 5, 82, 77, 164, 6, 325, 292, 308, 269, 7, 8, 9, 10, 113, 11, 12, 13, 14, 97, 15, 16, 17, 46, 47, 18, 19, 20, 21, 48, 49, 50, 51, 52, 53, 0, 54, 0, 0, 55, 56, 57, 58, 94, 0, 0, 94, 94, 94, 94, 0, 47, 47, 47, 0, 0, 47, 47, 47, 120, 121, 122, 123, 124, 125, 0, 47, 47, 47, 47, 47, 47, 0, 0, 94, 94, 94, 0, 0, 0, 94, 0, 0, 0, 0, 94, 94, 94, 94, 0, 94, 94, 94, 94, 47, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 0, 94, 0, 0, 94, 94, 94, 94, 43, 0, 0, 44, 45, 2, 0, 0, 35, 35, 35, 0, 0, 35, 35, 35, 118, 119, 120, 121, 122, 123, 124, 125, 35, 0, 0, 0, 0, 0, 0, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 0, 11, 12, 13, 14, 35, 15, 16, 17, 46, 47, 18, 19, 20, 21, 48, 49, 50, 51, 52, 53, 0, 54, 0, 0, 55, 56, 57, 58, 160, 0, 0, 44, 45, 2, 0, 0, 36, 36, 36, 0, 0, 36, 36, 36, 0, 99, 100, 101, 102, 103, 104, 105, 36, 0, 0, 0, 0, 0, 0, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 0, 11, 12, 13, 14, 36, 15, 16, 17, 46, 47, 18, 19, 20, 21, 48, 49, 50, 51, 52, 53, 0, 54, 0, 0, 55, 56, 57, 58, 76, 76, 76, 0, 82, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 0, 76, 76, 76, 76, 76, 76, 76, 0, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 0, 76, 76, 76, 0, 0, 76, 76, 76, 76, 118, 118, 118, 0, 82, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 0, 118, 118, 118, 118, 118, 118, 118, 0, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 0, 118, 118, 118, 0, 0, 118, 118, 118, 118, 59, 59, 59, 0, 82, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, 0, 59, 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, 59, 0, 59, 59, 59, 0, 0, 59, 59, 59, 59, 59, 59, 59, 0, 82, 59, 59, 59, 76, 76, 76, 76, 76, 76, 76, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, 0, 0, 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, 59, 0, 59, 59, 59, 0, 0, 59, 59, 59, 59, 137, 137, 137, 0, 0, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 0, 137, 137, 137, 137, 137, 137, 137, 0, 137, 137, 137, 137, 137, 137, 0, 137, 137, 137, 137, 137, 0, 137, 137, 137, 0, 0, 137, 137, 137, 137, 122, 122, 122, 0, 0, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 0, 122, 122, 122, 122, 122, 122, 122, 0, 122, 122, 122, 0, 122, 122, 122, 122, 122, 122, 122, 122, 0, 122, 122, 122, 0, 0, 122, 122, 122, 122, 145, 145, 145, 0, 0, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 0, 145, 145, 145, 145, 145, 145, 145, 0, 0, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 0, 145, 145, 145, 0, 0, 145, 145, 145, 145, 67, 67, 67, 0, 0, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 0, 67, 67, 67, 67, 67, 67, 67, 0, 67, 67, 0, 67, 67, 67, 67, 67, 67, 67, 67, 67, 0, 67, 67, 67, 0, 0, 67, 67, 67, 67, 111, 111, 111, 0, 0, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 0, 111, 111, 111, 111, 111, 111, 111, 0, 111, 111, 111, 0, 111, 111, 111, 111, 111, 111, 111, 111, 0, 111, 111, 111, 0, 0, 111, 111, 111, 111, 69, 69, 69, 0, 0, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 0, 69, 69, 69, 69, 69, 69, 69, 0, 69, 0, 0, 69, 69, 69, 69, 69, 69, 69, 69, 69, 0, 69, 69, 69, 0, 0, 69, 69, 69, 69, 70, 70, 70, 0, 0, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 0, 70, 70, 70, 70, 70, 70, 70, 0, 70, 0, 0, 70, 70, 70, 70, 70, 70, 70, 70, 70, 0, 70, 70, 70, 0, 0, 70, 70, 70, 70, 68, 68, 68, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 68, 68, 68, 68, 68, 0, 68, 0, 0, 68, 68, 68, 68, 68, 68, 68, 68, 68, 0, 68, 68, 68, 0, 0, 68, 68, 68, 68, 146, 146, 146, 0, 0, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 0, 146, 146, 146, 146, 146, 146, 146, 0, 146, 0, 0, 146, 146, 146, 146, 146, 146, 146, 146, 146, 0, 146, 146, 146, 0, 0, 146, 146, 146, 146, 64, 64, 64, 0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64, 0, 64, 0, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 64, 64, 64, 0, 0, 64, 64, 64, 64, 65, 65, 65, 0, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65, 65, 0, 65, 0, 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, 0, 65, 65, 65, 0, 0, 65, 65, 65, 65, 66, 66, 66, 0, 0, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 0, 66, 66, 66, 66, 66, 66, 66, 0, 66, 0, 0, 66, 66, 66, 66, 66, 66, 66, 66, 66, 0, 66, 66, 66, 0, 0, 66, 66, 66, 66, 111, 111, 111, 0, 0, 111, 111, 111, 110, 110, 110, 110, 110, 110, 110, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 0, 111, 111, 111, 111, 111, 111, 111, 0, 0, 111, 111, 0, 111, 111, 111, 111, 111, 111, 111, 111, 0, 111, 111, 111, 0, 0, 111, 111, 111, 111, 147, 147, 147, 0, 0, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 0, 147, 147, 147, 147, 147, 147, 147, 0, 147, 147, 147, 147, 0, 0, 0, 147, 147, 147, 147, 0, 0, 147, 147, 147, 0, 0, 147, 147, 147, 147, 144, 144, 144, 0, 0, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 0, 144, 144, 144, 144, 144, 144, 144, 0, 0, 144, 144, 144, 0, 0, 0, 144, 144, 144, 144, 0, 0, 144, 144, 144, 0, 0, 144, 144, 144, 144, 62, 62, 62, 0, 0, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, 62, 62, 62, 0, 0, 0, 62, 0, 62, 0, 0, 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, 62, 62, 62, 0, 0, 62, 62, 62, 62, 63, 63, 63, 0, 0, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 0, 63, 63, 63, 0, 0, 0, 63, 0, 63, 0, 0, 63, 63, 63, 63, 63, 63, 63, 63, 63, 0, 63, 63, 63, 0, 0, 63, 63, 63, 63, 122, 122, 122, 0, 0, 122, 122, 122, 0, 0, 0, 0, 0, 0, 0, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 0, 122, 122, 122, 122, 122, 122, 122, 0, 0, 122, 122, 0, 122, 122, 122, 122, 122, 122, 122, 122, 0, 122, 122, 122, 0, 0, 122, 122, 122, 122, 55, 55, 55, 0, 0, 55, 55, 55, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 55, 55, 55, 55, 55, 55, 55, 55, 55, 0, 55, 55, 55, 0, 0, 55, 55, 55, 55, 56, 56, 56, 0, 0, 56, 56, 56, 0, 0, 0, 0, 0, 0, 0, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 0, 56, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 56, 56, 56, 56, 56, 56, 56, 56, 56, 0, 56, 56, 56, 0, 0, 56, 56, 56, 56, 59, 0, 0, 82, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 59, 0, 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, 166, 0, 59, 59, 0, 59, 59, 59, 0, 59, 59, 59, 59, 0, 59, 59, 59, 0, 0, 59, 59, 59, 59, 0, 0, 0, 0, 3, 4, 5, 238, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 0, 11, 12, 13, 14, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 0, 11, 12, 13, 239, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 82, 0, 0, 0, 76, 76, 76, 76, 76, 76, 76, 59, 0, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, 0, 0, 59, 59, 0, 59, 59, 59, 0, 59, 59, 59, 59, 0, 59, 59, 59, 122, 0, 59, 59, 59, 59, 0, 0, 0, 122, 0, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 0, 122, 122, 122, 122, 122, 122, 122, 0, 0, 122, 122, 0, 122, 122, 122, 0, 122, 122, 122, 122, 0, 122, 122, 122, 0, 0, 122, 122, 122, 122, 37, 37, 37, 0, 0, 37, 37, 37, 38, 38, 38, 0, 0, 38, 38, 38, 37, 0, 0, 0, 39, 39, 39, 0, 38, 39, 39, 39, 40, 40, 40, 0, 0, 40, 40, 40, 39, 0, 0, 0, 123, 123, 123, 37, 40, 123, 123, 123, 124, 124, 124, 38, 0, 124, 124, 124, 123, 0, 0, 0, 125, 125, 125, 39, 124, 125, 125, 125, 126, 126, 126, 40, 0, 126, 126, 126, 125, 0, 0, 0, 127, 127, 127, 123, 126, 127, 127, 127, 128, 128, 128, 124, 0, 128, 128, 128, 127, 0, 0, 0, 129, 129, 129, 125, 128, 129, 129, 129, 54, 54, 54, 126, 0, 54, 54, 54, 129, 0, 0, 0, 0, 180, 0, 127, 54, 0, 0, 0, 0, 0, 115, 128, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, 129, 0, 0, 0, 0, 304, 0, 0, 54, 0, 0, 0, 0, 0, 115, 181, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, 0, 0, 0, 0, 0, 327, 0, 0, 0, 0, 0, 0, 0, 0, 115, 305, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, 0, 0, 0, 0, 0, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 328, 7, 8, 9, 71, 0, 11, 12, 13, 72, 81, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 187, 11, 12, 13, 188, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 249, 11, 12, 13, 14, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 291, 11, 12, 13, 14, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 71, 0, 11, 12, 13, 72, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 0, 11, 12, 13, 14, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 252, 0, 11, 12, 13, 14, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 0, 7, 8, 9, 10, 0, 11, 12, 13, 266, 0, 15, 16, 17, 0, 0, 18, 19, 20, 21, 171, 171, 171, 0, 0, 0, 171, 0, 0, 0, 0, 171, 171, 171, 171, 0, 171, 171, 171, 171, 0, 171, 171, 171, 0, 0, 171, 171, 171, 171, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, 0, 0, 115, 181, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 115, 271, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 0, 0, 0, 115, 279, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 115, 283, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 44, 45, 0, 115, 286, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 115, 289, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 248, 0, 0, 0, 332, 0, 0, 0, 0, 0, 0, 0, 285, 0, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 114, 0, 0, 0, 0, 0, 0, 0, 0, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 272, 0, 0, 0, 0, 0, 0, 0, 0, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 273, 0, 0, 0, 0, 0, 0, 0, 0, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 115, 310, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 115, 0, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, }; static const YYINT yycheck[] = { 7, 0, 265, 4, 5, 6, 7, 8, 265, 10, 60, 10, 298, 63, 64, 306, 66, 228, 259, 260, 70, 0, 278, 264, 265, 266, 25, 28, 299, 300, 301, 32, 15, 16, 265, 42, 4, 5, 6, 302, 8, 42, 298, 259, 260, 302, 25, 259, 260, 261, 266, 265, 264, 265, 266, 301, 55, 36, 301, 58, 28, 302, 41, 275, 32, 43, 65, 182, 259, 260, 71, 302, 71, 51, 52, 266, 77, 55, 56, 57, 58, 265, 265, 298, 62, 68, 302, 302, 302, 72, 302, 90, 91, 92, 301, 78, 259, 260, 81, 262, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 93, 94, 327, 261, 302, 302, 119, 120, 121, 122, 123, 124, 125, 128, 129, 130, 131, 132, 306, 134, 308, 301, 135, 259, 260, 138, 265, 296, 297, 258, 259, 260, 298, 126, 126, 148, 149, 259, 260, 152, 264, 265, 264, 265, 266, 301, 128, 129, 130, 131, 132, 301, 134, 259, 260, 168, 153, 170, 287, 298, 266, 153, 154, 302, 177, 263, 158, 180, 160, 182, 264, 265, 185, 186, 301, 259, 260, 259, 260, 261, 302, 264, 265, 247, 259, 260, 261, 251, 301, 264, 265, 266, 259, 260, 261, 208, 209, 210, 211, 274, 275, 276, 277, 287, 288, 289, 301, 228, 301, 293, 259, 260, 261, 228, 298, 299, 300, 301, 297, 303, 304, 305, 306, 295, 308, 309, 310, 302, 306, 313, 314, 315, 316, 287, 290, 291, 292, 252, 295, 252, 296, 297, 299, 300, 301, 258, 259, 260, 306, 306, 267, 268, 269, 270, 271, 272, 273, 264, 265, 318, 273, 288, 289, 290, 291, 292, 302, 280, 323, 296, 297, 259, 260, 261, 287, 278, 264, 265, 266, 263, 293, 298, 295, 296, 263, 302, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 263, 256, 264, 265, 294, 302, 261, 265, 327, 302, 299, 300, 301, 265, 327, 326, 302, 306, 309, 309, 259, 260, 261, 259, 260, 264, 265, 266, 259, 260, 263, 266, 287, 288, 289, 274, 275, 276, 293, 265, 301, 331, 332, 298, 299, 300, 301, 306, 303, 304, 305, 306, 302, 308, 309, 310, 302, 306, 313, 314, 315, 316, 256, 302, 306, 259, 260, 261, 262, 306, 325, 326, 302, 298, 302, 302, 331, 267, 268, 269, 270, 271, 272, 273, 277, 278, 279, 280, 281, 282, 283, 284, 285, 287, 288, 289, 263, 302, 302, 293, 309, 252, 273, 186, 298, 299, 300, 301, 298, 303, 304, 305, 306, 25, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, -1, 324, -1, -1, 327, 328, 329, 330, 256, -1, -1, 259, 260, 261, 262, -1, 259, 260, 261, -1, -1, 264, 265, 266, 280, 281, 282, 283, 284, 285, -1, 274, 275, 276, 277, 278, 279, -1, -1, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, 302, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, -1, 324, -1, -1, 327, 328, 329, 330, 256, -1, -1, 259, 260, 261, -1, -1, 259, 260, 261, -1, -1, 264, 265, 266, 278, 279, 280, 281, 282, 283, 284, 285, 275, -1, -1, -1, -1, -1, -1, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, 302, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, -1, 324, -1, -1, 327, 328, 329, 330, 256, -1, -1, 259, 260, 261, -1, -1, 259, 260, 261, -1, -1, 264, 265, 266, -1, 267, 268, 269, 270, 271, 272, 273, 275, -1, -1, -1, -1, -1, -1, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, 302, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, -1, 324, -1, -1, 327, 328, 329, 330, 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, 297, -1, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, -1, 296, 297, -1, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, 297, 298, 299, 300, -1, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, 297, -1, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, -1, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, 297, -1, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, -1, 296, 297, -1, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, 295, 296, 297, 298, -1, -1, -1, 302, 303, 304, 305, -1, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, -1, 296, 297, 298, -1, -1, -1, 302, 303, 304, 305, -1, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, -1, -1, -1, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, -1, -1, -1, 293, -1, 295, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, -1, -1, -1, -1, -1, -1, -1, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, -1, 296, 297, -1, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, -1, -1, -1, -1, -1, -1, -1, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, -1, -1, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, -1, -1, -1, -1, -1, -1, -1, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, -1, -1, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 260, -1, -1, 263, -1, -1, -1, 267, 268, 269, 270, 271, 272, 273, 274, -1, 276, 277, -1, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, 260, -1, 296, 297, -1, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, -1, -1, -1, -1, 287, 288, 289, 260, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 263, -1, -1, -1, 267, 268, 269, 270, 271, 272, 273, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, -1, 296, 297, -1, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, 265, -1, 313, 314, 315, 316, -1, -1, -1, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 287, 288, 289, 290, 291, 292, 293, -1, -1, 296, 297, -1, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 259, 260, 261, -1, -1, 264, 265, 266, 259, 260, 261, -1, -1, 264, 265, 266, 275, -1, -1, -1, 259, 260, 261, -1, 275, 264, 265, 266, 259, 260, 261, -1, -1, 264, 265, 266, 275, -1, -1, -1, 259, 260, 261, 302, 275, 264, 265, 266, 259, 260, 261, 302, -1, 264, 265, 266, 275, -1, -1, -1, 259, 260, 261, 302, 275, 264, 265, 266, 259, 260, 261, 302, -1, 264, 265, 266, 275, -1, -1, -1, 259, 260, 261, 302, 275, 264, 265, 266, 259, 260, 261, 302, -1, 264, 265, 266, 275, -1, -1, -1, 259, 260, 261, 302, 275, 264, 265, 266, 259, 260, 261, 302, -1, 264, 265, 266, 275, -1, -1, -1, -1, 265, -1, 302, 275, -1, -1, -1, -1, -1, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, 302, -1, -1, -1, -1, 265, -1, -1, 302, -1, -1, -1, -1, -1, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, 265, -1, -1, -1, -1, -1, -1, -1, -1, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, -1, -1, -1, -1, -1, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, 302, 298, 299, 300, 301, -1, 303, 304, 305, 306, 307, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, 302, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 287, 288, 289, -1, -1, -1, 293, -1, -1, -1, -1, 298, 299, 300, 301, -1, 303, 304, 305, 306, -1, 308, 309, 310, -1, -1, 313, 314, 315, 316, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, -1, -1, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, -1, -1, -1, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 259, 260, -1, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 274, 302, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 260, -1, -1, -1, 302, -1, -1, -1, -1, -1, -1, -1, 260, -1, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 265, -1, -1, -1, -1, -1, -1, -1, -1, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 265, -1, -1, -1, -1, -1, -1, -1, -1, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 265, -1, -1, -1, -1, -1, -1, -1, -1, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 274, -1, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, }; #if YYBTYACC static const YYINT yyctable[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, }; #endif #define YYFINAL 25 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 331 #define YYUNDFTOKEN 389 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) #if YYDEBUG static const char *const yyname[] = { "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","UNEXPECTED","BAD_DECIMAL","NL", "SEMI_COLON","LBRACE","RBRACE","LBOX","RBOX","COMMA","IO_OUT","ASSIGN", "ADD_ASG","SUB_ASG","MUL_ASG","DIV_ASG","MOD_ASG","POW_ASG","QMARK","COLON", "OR","AND","IN","MATCH","EQ","NEQ","LT","LTE","GT","GTE","CAT","GETLINE","PLUS", "MINUS","MUL","DIV","MOD","NOT","UMINUS","IO_IN","PIPE","POW","INC_or_DEC", "DOLLAR","FIELD","LPAREN","RPAREN","DOUBLE","STRING_","RE","ID","D_ID", "FUNCT_ID","BUILTIN","LENGTH","PRINT","PRINTF","SPLIT","MATCH_FUNC","SUB", "GSUB","DO","WHILE","FOR","BREAK","CONTINUE","IF","ELSE","DELETE","BEGIN","END", "EXIT","NEXT","NEXTFILE","RETURN","FUNCTION","$accept","program","block", "block_or_separator","statement_list","statement","mark","pr_args","arg2", "builtin","getline_file","lvalue","field","fvalue","expr","cat_expr","p_expr", "while_front","if_front","for1","for2","array_loop_front","return_statement", "split_front","re_arg","sub_back","arglist","args","print","sub_or_gsub", "funct_start","funct_head","call_args","ca_front","ca_back","f_arglist", "f_args","program_block","PA_block","function_def","outside_error","$$1","$$2", "$$3","$$4","$$5","separator","$$6","$$7","$$8","$$9","pr_direction", "else_back","do","for3","split_back","getline","illegal-symbol", }; static const char *const yyrule[] = { "$accept : program", "program : program_block", "program : program program_block", "program_block : PA_block", "program_block : function_def", "program_block : outside_error block", "PA_block : block", "$$1 :", "PA_block : BEGIN $$1 block", "$$2 :", "PA_block : END $$2 block", "$$3 :", "PA_block : expr $$3 block_or_separator", "$$4 :", "$$5 :", "PA_block : expr COMMA $$4 expr $$5 block_or_separator", "block : LBRACE statement_list RBRACE", "block : LBRACE error RBRACE", "block_or_separator : block", "block_or_separator : separator", "statement_list : statement", "statement_list : statement_list statement", "statement : block", "statement : expr separator", "statement : separator", "statement : error separator", "statement : BREAK separator", "statement : CONTINUE separator", "statement : return_statement", "statement : NEXT separator", "statement : NEXTFILE separator", "separator : NL", "separator : SEMI_COLON", "expr : cat_expr", "expr : lvalue ASSIGN expr", "expr : lvalue ADD_ASG expr", "expr : lvalue SUB_ASG expr", "expr : lvalue MUL_ASG expr", "expr : lvalue DIV_ASG expr", "expr : lvalue MOD_ASG expr", "expr : lvalue POW_ASG expr", "expr : expr EQ expr", "expr : expr NEQ expr", "expr : expr LT expr", "expr : expr LTE expr", "expr : expr GT expr", "expr : expr GTE expr", "expr : expr MATCH expr", "$$6 :", "expr : expr OR $$6 expr", "$$7 :", "expr : expr AND $$7 expr", "$$8 :", "$$9 :", "expr : expr QMARK $$8 expr COLON $$9 expr", "cat_expr : p_expr", "cat_expr : cat_expr p_expr", "p_expr : DOUBLE", "p_expr : STRING_", "p_expr : ID", "p_expr : LPAREN expr RPAREN", "p_expr : RE", "p_expr : p_expr PLUS p_expr", "p_expr : p_expr MINUS p_expr", "p_expr : p_expr MUL p_expr", "p_expr : p_expr DIV p_expr", "p_expr : p_expr MOD p_expr", "p_expr : p_expr POW p_expr", "p_expr : NOT p_expr", "p_expr : PLUS p_expr", "p_expr : MINUS p_expr", "p_expr : builtin", "p_expr : ID INC_or_DEC", "p_expr : INC_or_DEC lvalue", "p_expr : field INC_or_DEC", "p_expr : INC_or_DEC field", "lvalue : ID", "arglist :", "arglist : args", "args : expr", "args : args COMMA expr", "builtin : BUILTIN mark LPAREN arglist RPAREN", "mark :", "statement : print mark pr_args pr_direction separator", "print : PRINT", "print : PRINTF", "pr_args : arglist", "pr_args : LPAREN arg2 RPAREN", "pr_args : LPAREN RPAREN", "arg2 : expr COMMA expr", "arg2 : arg2 COMMA expr", "pr_direction :", "pr_direction : IO_OUT expr", "if_front : IF LPAREN expr RPAREN", "statement : if_front statement", "else_back : ELSE", "statement : if_front statement else_back statement", "do : DO", "statement : do statement WHILE LPAREN expr RPAREN separator", "while_front : WHILE LPAREN expr RPAREN", "statement : while_front statement", "statement : for1 for2 for3 statement", "for1 : FOR LPAREN SEMI_COLON", "for1 : FOR LPAREN expr SEMI_COLON", "for2 : SEMI_COLON", "for2 : expr SEMI_COLON", "for3 : RPAREN", "for3 : expr RPAREN", "expr : expr IN ID", "expr : LPAREN arg2 RPAREN IN ID", "lvalue : ID mark LBOX args RBOX", "p_expr : ID mark LBOX args RBOX", "p_expr : ID mark LBOX args RBOX INC_or_DEC", "statement : DELETE ID mark LBOX args RBOX separator", "statement : DELETE ID separator", "array_loop_front : FOR LPAREN ID IN ID RPAREN", "statement : array_loop_front statement", "field : FIELD", "field : DOLLAR D_ID", "field : DOLLAR D_ID mark LBOX args RBOX", "field : DOLLAR p_expr", "field : LPAREN field RPAREN", "p_expr : field", "expr : field ASSIGN expr", "expr : field ADD_ASG expr", "expr : field SUB_ASG expr", "expr : field MUL_ASG expr", "expr : field DIV_ASG expr", "expr : field MOD_ASG expr", "expr : field POW_ASG expr", "p_expr : split_front split_back", "split_front : SPLIT LPAREN expr COMMA ID", "split_back : RPAREN", "split_back : COMMA expr RPAREN", "p_expr : LENGTH LPAREN RPAREN", "p_expr : LENGTH LPAREN expr RPAREN", "p_expr : LENGTH LPAREN ID RPAREN", "p_expr : LENGTH", "p_expr : MATCH_FUNC LPAREN expr COMMA re_arg RPAREN", "re_arg : expr", "statement : EXIT separator", "statement : EXIT expr separator", "return_statement : RETURN separator", "return_statement : RETURN expr separator", "p_expr : getline", "p_expr : getline fvalue", "p_expr : getline_file p_expr", "p_expr : p_expr PIPE GETLINE", "p_expr : p_expr PIPE GETLINE fvalue", "getline : GETLINE", "fvalue : lvalue", "fvalue : field", "getline_file : getline IO_IN", "getline_file : getline fvalue IO_IN", "p_expr : sub_or_gsub LPAREN re_arg COMMA expr sub_back", "sub_or_gsub : SUB", "sub_or_gsub : GSUB", "sub_back : RPAREN", "sub_back : COMMA fvalue RPAREN", "function_def : funct_start block", "funct_start : funct_head LPAREN f_arglist RPAREN", "funct_head : FUNCTION ID", "funct_head : FUNCTION FUNCT_ID", "f_arglist :", "f_arglist : f_args", "f_args : ID", "f_args : f_args COMMA ID", "outside_error : error", "p_expr : FUNCT_ID mark call_args", "call_args : LPAREN RPAREN", "call_args : ca_front ca_back", "ca_front : LPAREN", "ca_front : ca_front expr COMMA", "ca_front : ca_front ID COMMA", "ca_back : expr RPAREN", "ca_back : ID RPAREN", }; #endif #if YYDEBUG int yydebug; #endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; int yynerrs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyloc; /* position returned by actions */ YYLTYPE yylloc; /* position from the lexer */ #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) #ifndef YYLLOC_DEFAULT #define YYLLOC_DEFAULT(loc, rhs, n) \ do \ { \ if (n == 0) \ { \ (loc).first_line = YYRHSLOC(rhs, 0).last_line; \ (loc).first_column = YYRHSLOC(rhs, 0).last_column; \ (loc).last_line = YYRHSLOC(rhs, 0).last_line; \ (loc).last_column = YYRHSLOC(rhs, 0).last_column; \ } \ else \ { \ (loc).first_line = YYRHSLOC(rhs, 1).first_line; \ (loc).first_column = YYRHSLOC(rhs, 1).first_column; \ (loc).last_line = YYRHSLOC(rhs, n).last_line; \ (loc).last_column = YYRHSLOC(rhs, n).last_column; \ } \ } while (0) #endif /* YYLLOC_DEFAULT */ #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #if YYBTYACC #ifndef YYLVQUEUEGROWTH #define YYLVQUEUEGROWTH 32 #endif #endif /* YYBTYACC */ /* define the initial stack-sizes */ #ifdef YYSTACKSIZE #undef YYMAXDEPTH #define YYMAXDEPTH YYSTACKSIZE #else #ifdef YYMAXDEPTH #define YYSTACKSIZE YYMAXDEPTH #else #define YYSTACKSIZE 10000 #define YYMAXDEPTH 10000 #endif #endif #ifndef YYINITSTACKSIZE #define YYINITSTACKSIZE 200 #endif typedef struct { unsigned stacksize; YYINT *s_base; YYINT *s_mark; YYINT *s_last; YYSTYPE *l_base; YYSTYPE *l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *p_base; YYLTYPE *p_mark; #endif } YYSTACKDATA; #if YYBTYACC struct YYParseState_s { struct YYParseState_s *save; /* Previously saved parser state */ YYSTACKDATA yystack; /* saved parser stack */ int state; /* saved parser state */ int errflag; /* saved error recovery status */ int lexeme; /* saved index of the conflict lexeme in the lexical queue */ YYINT ctry; /* saved index in yyctable[] for this conflict */ }; typedef struct YYParseState_s YYParseState; #endif /* YYBTYACC */ /* variables for the parser stack */ static YYSTACKDATA yystack; #if YYBTYACC /* Current parser state */ static YYParseState *yyps = 0; /* yypath != NULL: do the full parse, starting at *yypath parser state. */ static YYParseState *yypath = 0; /* Base of the lexical value queue */ static YYSTYPE *yylvals = 0; /* Current position at lexical value queue */ static YYSTYPE *yylvp = 0; /* End position of lexical value queue */ static YYSTYPE *yylve = 0; /* The last allocated position at the lexical value queue */ static YYSTYPE *yylvlim = 0; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Base of the lexical position queue */ static YYLTYPE *yylpsns = 0; /* Current position at lexical position queue */ static YYLTYPE *yylpp = 0; /* End position of lexical position queue */ static YYLTYPE *yylpe = 0; /* The last allocated position at the lexical position queue */ static YYLTYPE *yylplim = 0; #endif /* Current position at lexical token queue */ static YYINT *yylexp = 0; static YYINT *yylexemes = 0; #endif /* YYBTYACC */ #line 1168 "parse.y" /* * Check for special case where there is a forward reference to a newly * declared function using an array parameter. Because the parameter * mechanism for arrays uses a different byte code, we would like to know * if this is the case so that the function's contents can handle the array * type. */ static void improve_arglist(const char *name) { CA_REC *p, *p2; FCALL_REC *q; TRACE(("improve_arglist(%s)\n", name)); for (p = active_arglist; p != 0; p = p->link) { if (p->type == ST_LOCAL_NONE) { for (q = resolve_list; q != 0; q = q->link) { if (!strcmp(q->callee->name, name)) { for (p2 = q->arg_list; p2 != 0; p2 = p2->link) { if (p2->arg_num == p->arg_num) { switch (p2->type) { case ST_NONE: case ST_LOCAL_NONE: break; default: p->type = p2->type; p->sym_p->type = p2->type; TRACE(("...set arg %d of %s to %s\n", p->arg_num + 1, name, type_to_str(p->type))); break; } } } if (p->type != ST_LOCAL_NONE) break; } } if (p->type != ST_LOCAL_NONE) break; } } } /* maintain data for f_arglist to make it visible in funct_start */ static int init_arglist(void) { free_arglist(); return 0; } static SYMTAB * save_arglist(const char *s) { SYMTAB *result = save_id(s); CA_REC *saveit = ZMALLOC(CA_REC); if (saveit != 0) { CA_REC *p, *q; int arg_num = 0; for (p = active_arglist, q = 0; p != 0; q = p, p = p->link) { ++arg_num; } saveit->link = 0; saveit->type = ST_LOCAL_NONE; saveit->arg_num = (NUM_ARGS) arg_num; saveit->call_lineno = token_lineno; saveit->sym_p = result; if (q != 0) { q->link = saveit; } else { active_arglist = saveit; } } return result; } static void free_arglist(void) { while (active_arglist != 0) { CA_REC *next = active_arglist->link; ZFREE(active_arglist); active_arglist = next; } } /* resize the code for a user function */ static void resize_fblock(FBLOCK * fbp) { CODEBLOCK *p = ZMALLOC(CODEBLOCK); code2op(_RET0, _HALT); /* make sure there is always a return */ *p = active_code; fbp->code = code_shrink(p, &fbp->size); /* code_shrink() zfrees p */ if (dump_code_flag) add_to_fdump_list(fbp); } /* convert FE_PUSHA to FE_PUSHI or F_PUSH to F_PUSHI */ static void field_A2I(void) { if (code_ptr[-1].op == FE_PUSHA && code_ptr[-1].ptr == (PTR) 0) { /* On most architectures, the two tests are the same; a good compiler might eliminate one. On LM_DOS, and possibly other segmented architectures, they are not */ code_ptr[-1].op = FE_PUSHI; } else { CELL *cp = (CELL *) code_ptr[-1].ptr; if ((cp == field) || ((cp > NF) && (cp <= LAST_PFIELD))) { code_ptr[-2].op = _PUSHI; } else if (cp == NF) { code_ptr[-2].op = NF_PUSHI; code_ptr--; } else { code_ptr[-2].op = F_PUSHI; code_ptr->op = field_addr_to_index(code_ptr[-1].ptr); code_ptr++; } } } /* we've seen an ID in a context where it should be a VAR, check that's consistent with previous usage */ static void check_var(SYMTAB * p) { switch (p->type) { case ST_NONE: /* new id */ p->type = ST_VAR; p->stval.cp = ZMALLOC(CELL); p->stval.cp->type = C_NOINIT; break; case ST_LOCAL_NONE: p->type = ST_LOCAL_VAR; active_funct->typev[p->offset] = ST_LOCAL_VAR; break; case ST_VAR: case ST_LOCAL_VAR: break; default: type_error(p); break; } } /* we've seen an ID in a context where it should be an ARRAY, check that's consistent with previous usage */ static void check_array(SYMTAB * p) { switch (p->type) { case ST_NONE: /* a new array */ p->type = ST_ARRAY; p->stval.array = new_ARRAY(); no_leaks_array(p->stval.array); break; case ST_ARRAY: case ST_LOCAL_ARRAY: break; case ST_LOCAL_NONE: p->type = ST_LOCAL_ARRAY; active_funct->typev[p->offset] = ST_LOCAL_ARRAY; break; default: type_error(p); break; } } static void code_array(SYMTAB * p) { if (is_local(p)) code2op(LA_PUSHA, p->offset); else code2(A_PUSHA, p->stval.array); } /* we've seen an ID as an argument to a user defined function */ static void code_call_id(CA_REC * p, SYMTAB * ip) { static CELL dummy; p->call_offset = code_offset; /* This always gets set now. So that fcall:relocate_arglist works. */ switch (ip->type) { case ST_VAR: p->type = CA_EXPR; code2(_PUSHI, ip->stval.cp); break; case ST_LOCAL_VAR: p->type = CA_EXPR; code2op(L_PUSHI, ip->offset); break; case ST_ARRAY: p->type = CA_ARRAY; code2(A_PUSHA, ip->stval.array); break; case ST_LOCAL_ARRAY: p->type = CA_ARRAY; code2op(LA_PUSHA, ip->offset); break; /* not enough info to code it now; it will have to be patched later */ case ST_NONE: p->type = ST_NONE; p->sym_p = ip; code2(_PUSHI, &dummy); break; case ST_LOCAL_NONE: p->type = ST_LOCAL_NONE; p->type_p = &active_funct->typev[ip->offset]; code2op(L_PUSHI, ip->offset); break; #ifdef DEBUG default: bozo("code_call_id"); #endif } } /* an RE by itself was coded as _MATCH0 , change to push as an expression */ static void RE_as_arg(void) { CELL *cp = ZMALLOC(CELL); code_ptr -= 2; cp->type = C_RE; cp->ptr = code_ptr[1].ptr; code2(_PUSHC, cp); no_leaks_cell_ptr(cp); } /* reset the active_code back to the MAIN block */ static void switch_code_to_main(void) { switch (scope) { case SCOPE_BEGIN: *begin_code_p = active_code; active_code = *main_code_p; break; case SCOPE_END: *end_code_p = active_code; active_code = *main_code_p; break; case SCOPE_FUNCT: active_code = *main_code_p; break; case SCOPE_MAIN: break; } active_funct = (FBLOCK *) 0; scope = SCOPE_MAIN; } void parse(void) { if (yyparse() || compile_error_count != 0) mawk_exit(2); scan_cleanup(); set_code(); /* code must be set before call to resolve_fcalls() */ if (resolve_list) resolve_fcalls(); if (compile_error_count != 0) mawk_exit(2); if (dump_code_flag) { dump_code(); mawk_exit(0); } } #line 2018 "parse.c" /* For use in generated program */ #define yydepth (int)(yystack.s_mark - yystack.s_base) #if YYBTYACC #define yytrial (yyps->save) #endif /* YYBTYACC */ #if YYDEBUG #include /* needed for printf */ #endif #include /* needed for malloc, etc */ #include /* needed for memset */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack(YYSTACKDATA *data) { int i; unsigned newsize; YYINT *newss; YYSTYPE *newvs; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *newps; #endif if ((newsize = data->stacksize) == 0) newsize = YYINITSTACKSIZE; else if (newsize >= YYMAXDEPTH) return YYENOMEM; else if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; i = (int) (data->s_mark - data->s_base); newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); if (newss == 0) return YYENOMEM; data->s_base = newss; data->s_mark = newss + i; newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); if (newvs == 0) return YYENOMEM; data->l_base = newvs; data->l_mark = newvs + i; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); if (newps == 0) return YYENOMEM; data->p_base = newps; data->p_mark = newps + i; #endif data->stacksize = newsize; data->s_last = data->s_base + newsize - 1; #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); #endif return 0; } #if YYPURE || defined(YY_NO_LEAKS) static void yyfreestack(YYSTACKDATA *data) { free(data->s_base); free(data->l_base); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) free(data->p_base); #endif memset(data, 0, sizeof(*data)); } #else #define yyfreestack(data) /* nothing */ #endif /* YYPURE || defined(YY_NO_LEAKS) */ #if YYBTYACC static YYParseState * yyNewState(unsigned size) { YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); if (p == NULL) return NULL; p->yystack.stacksize = size; if (size == 0) { p->yystack.s_base = NULL; p->yystack.l_base = NULL; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = NULL; #endif return p; } p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); if (p->yystack.s_base == NULL) return NULL; p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); if (p->yystack.l_base == NULL) return NULL; memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); if (p->yystack.p_base == NULL) return NULL; memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); #endif return p; } static void yyFreeState(YYParseState *p) { yyfreestack(&p->yystack); free(p); } #endif /* YYBTYACC */ #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab #if YYBTYACC #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) #define YYVALID_NESTED do { if (yyps->save && \ yyps->save->save == 0) goto yyvalid; } while(0) #endif /* YYBTYACC */ int YYPARSE_DECL() { int yym, yyn, yystate, yyresult; #if YYBTYACC int yynewerrflag; YYParseState *yyerrctx = NULL; #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */ #endif #if YYDEBUG const char *yys; if ((yys = getenv("YYDEBUG")) != 0) { yyn = *yys; if (yyn >= '0' && yyn <= '9') yydebug = yyn - '0'; } if (yydebug) fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); #endif #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range)); #endif #if YYBTYACC yyps = yyNewState(0); if (yyps == 0) goto yyenomem; yyps->save = 0; #endif /* YYBTYACC */ yym = 0; /* yyn is set below */ yynerrs = 0; yyerrflag = 0; yychar = YYEMPTY; yystate = 0; #if YYPURE memset(&yystack, 0, sizeof(yystack)); #endif if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystack.s_mark = yystack.s_base; yystack.l_mark = yystack.l_base; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base; #endif yystate = 0; *yystack.s_mark = 0; yyloop: if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", YYDEBUGSTR, yydepth, yystate, yychar, yys); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); #endif fputc('\n', stderr); } #endif } #if YYBTYACC /* Do we have a conflict? */ if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { YYINT ctry; if (yypath) { YYParseState *save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", YYDEBUGSTR, yydepth, yystate); #endif /* Switch to the next conflict context */ save = yypath; yypath = save->save; save->save = NULL; ctry = save->ctry; if (save->state != yystate) YYABORT; yyFreeState(save); } else { /* Unresolved conflict - start/continue trial parse */ YYParseState *save; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); if (yyps->save) fputs("ALREADY in conflict, continuing trial parse.\n", stderr); else fputs("Starting trial parse.\n", stderr); } #endif save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (save == NULL) goto yyenomem; save->save = yyps->save; save->state = yystate; save->errflag = yyerrflag; save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = yytable[yyn]; if (yyctable[ctry] == -1) { #if YYDEBUG if (yydebug && yychar >= YYEOF) fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); #endif ctry++; } save->ctry = ctry; if (yyps->save == NULL) { /* If this is a first conflict in the stack, start saving lexemes */ if (!yylexemes) { yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); if (yylexemes == NULL) goto yyenomem; yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); if (yylvals == NULL) goto yyenomem; yylvlim = yylvals + YYLVQUEUEGROWTH; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); if (yylpsns == NULL) goto yyenomem; yylplim = yylpsns + YYLVQUEUEGROWTH; #endif } if (yylvp == yylve) { yylvp = yylve = yylvals; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns; #endif yylexp = yylexemes; if (yychar >= YYEOF) { *yylve++ = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpe++ = yylloc; #endif *yylexp = (YYINT) yychar; yychar = YYEMPTY; } } } if (yychar >= YYEOF) { yylvp--; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp--; #endif yylexp--; yychar = YYEMPTY; } save->lexeme = (int) (yylvp - yylvals); yyps->save = save; } if (yytable[yyn] == ctry) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); #endif if (yychar < 0) { yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp++; #endif yylexp++; } if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yyctable[ctry]; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } else { yyn = yyctable[ctry]; goto yyreduce; } } /* End of code dealing with conflicts */ #endif /* YYBTYACC */ if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", YYDEBUGSTR, yydepth, yystate, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yylloc; #endif yychar = YYEMPTY; if (yyerrflag > 0) --yyerrflag; goto yyloop; } if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag != 0) goto yyinrecovery; #if YYBTYACC yynewerrflag = 1; goto yyerrhandler; goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: /* explicit YYERROR from an action -- pop the rhs of the rule reduced * before looking for error recovery */ yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yynewerrflag = 0; yyerrhandler: while (yyps->save) { int ctry; YYParseState *save = yyps->save; #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yyps->save->state, (int)(yylvp - yylvals - yyps->save->lexeme)); #endif /* Memorize most forward-looking error state in case it's really an error. */ if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) { /* Free old saved error context state */ if (yyerrctx) yyFreeState(yyerrctx); /* Create and fill out new saved error context state */ yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); if (yyerrctx == NULL) goto yyenomem; yyerrctx->save = yyps->save; yyerrctx->state = yystate; yyerrctx->errflag = yyerrflag; yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yyerrctx->lexeme = (int) (yylvp - yylvals); } yylvp = yylvals + save->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + save->lexeme; #endif yylexp = yylexemes + save->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif ctry = ++save->ctry; yystate = save->state; /* We tried shift, try reduce now */ if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; yyps->save = save->save; save->save = NULL; yyFreeState(save); /* Nothing left on the stack -- error */ if (!yyps->save) { #if YYDEBUG if (yydebug) fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", YYPREFIX, yydepth); #endif /* Restore state as it was in the most forward-advanced error */ yylvp = yylvals + yyerrctx->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yyerrctx->lexeme; #endif yylexp = yylexemes + yyerrctx->lexeme; yychar = yylexp[-1]; yylval = yylvp[-1]; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = yylpp[-1]; #endif yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yyerrctx->state; yyFreeState(yyerrctx); yyerrctx = NULL; } yynewerrflag = 1; } if (yynewerrflag == 0) goto yyinrecovery; #endif /* YYBTYACC */ YYERROR_CALL("syntax error"); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */ #endif #if !YYBTYACC goto yyerrlab; /* redundant goto avoids 'unused label' warning */ yyerrlab: #endif ++yynerrs; yyinrecovery: if (yyerrflag < 3) { yyerrflag = 3; for (;;) { if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; yystate = yytable[yyn]; *++yystack.s_mark = yytable[yyn]; *++yystack.l_mark = yylval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* lookahead position is error end position */ yyerror_loc_range[2] = yylloc; YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ *++yystack.p_mark = yyloc; #endif goto yyloop; } else { #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", YYDEBUGSTR, yydepth, *yystack.s_mark); #endif if (yystack.s_mark <= yystack.s_base) goto yyabort; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* the current TOS position is the error start position */ yyerror_loc_range[1] = *yystack.p_mark; #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); #else YYDESTRUCT_CALL("error: discarding state", yystos[*yystack.s_mark], yystack.l_mark); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ --yystack.s_mark; --yystack.l_mark; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) --yystack.p_mark; #endif } } } else { if (yychar == YYEOF) goto yyabort; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", YYDEBUGSTR, yydepth, yystate, yychar, yys); } #endif #if defined(YYDESTRUCT_CALL) #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ #endif /* defined(YYDESTRUCT_CALL) */ yychar = YYEMPTY; goto yyloop; } yyreduce: yym = yylen[yyn]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ if (yym > 0) { int i; fputc('<', stderr); for (i = yym; i > 0; i--) { if (i != yym) fputs(", ", stderr); fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], yystack.l_mark[1-i]), stderr); } fputc('>', stderr); } #endif fputc('\n', stderr); } #endif if (yym > 0) yyval = yystack.l_mark[1-yym]; else memset(&yyval, 0, sizeof yyval); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) /* Perform position reduction */ memset(&yyloc, 0, sizeof(yyloc)); #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ { YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym); /* just in case YYERROR is invoked within the action, save the start of the rhs as the error start position */ yyerror_loc_range[1] = yystack.p_mark[1-yym]; } #endif switch (yyn) { case 6: #line 156 "parse.y" { /* this do nothing action removes a vacuous warning from Bison */ } #line 2693 "parse.c" break; case 7: #line 161 "parse.y" { be_setup(scope = SCOPE_BEGIN) ; } #line 2698 "parse.c" break; case 8: #line 164 "parse.y" { switch_code_to_main() ; } #line 2703 "parse.c" break; case 9: #line 167 "parse.y" { be_setup(scope = SCOPE_END) ; } #line 2708 "parse.c" break; case 10: #line 170 "parse.y" { switch_code_to_main() ; } #line 2713 "parse.c" break; case 11: #line 173 "parse.y" { code_jmp(_JZ, (INST*)0) ; } #line 2718 "parse.c" break; case 12: #line 176 "parse.y" { patch_jmp( code_ptr ) ; } #line 2723 "parse.c" break; case 13: #line 180 "parse.y" { INST *p1 = CDP(yystack.l_mark[-1].start) ; int len ; code_push(p1, (unsigned) CodeOffset(p1), scope, active_funct) ; code_ptr = p1 ; code2op(_RANGE, 1) ; code_ptr += 3 ; len = (int) code_pop(code_ptr) ; code_ptr += len ; code1(_STOP) ; p1 = CDP(yystack.l_mark[-1].start) ; p1[2].op = CodeOffset(p1 + 1) ; } #line 2742 "parse.c" break; case 14: #line 196 "parse.y" { code1(_STOP) ; } #line 2747 "parse.c" break; case 15: #line 199 "parse.y" { INST *p1 = CDP(yystack.l_mark[-5].start) ; p1[3].op = (int) (CDP(yystack.l_mark[0].start) - (p1 + 1)) ; p1[4].op = CodeOffset(p1 + 1) ; } #line 2757 "parse.c" break; case 16: #line 210 "parse.y" { yyval.start = yystack.l_mark[-1].start ; } #line 2762 "parse.c" break; case 17: #line 212 "parse.y" { yyval.start = code_offset ; /* does nothing won't be executed */ print_flag = getline_flag = paren_cnt = 0 ; yyerrok ; } #line 2769 "parse.c" break; case 19: #line 219 "parse.y" { yyval.start = code_offset ; code1(_PUSHINT) ; code1(0) ; code2(_PRINT, bi_print) ; } #line 2777 "parse.c" break; case 23: #line 232 "parse.y" { code1(_POP) ; } #line 2782 "parse.c" break; case 24: #line 234 "parse.y" { yyval.start = code_offset ; } #line 2787 "parse.c" break; case 25: #line 236 "parse.y" { yyval.start = code_offset ; print_flag = getline_flag = 0 ; paren_cnt = 0 ; yyerrok ; } #line 2796 "parse.c" break; case 26: #line 242 "parse.y" { yyval.start = code_offset ; BC_insert('B', code_ptr+1) ; code2(_JMP, 0) /* don't use code_jmp ! */ ; } #line 2802 "parse.c" break; case 27: #line 245 "parse.y" { yyval.start = code_offset ; BC_insert('C', code_ptr+1) ; code2(_JMP, 0) ; } #line 2808 "parse.c" break; case 28: #line 248 "parse.y" { if ( scope != SCOPE_FUNCT ) compile_error("return outside function body") ; } #line 2815 "parse.c" break; case 29: #line 252 "parse.y" { if ( scope != SCOPE_MAIN ) compile_error( "improper use of next" ) ; yyval.start = code_offset ; code1(_NEXT) ; } #line 2824 "parse.c" break; case 30: #line 258 "parse.y" { if ( scope != SCOPE_MAIN ) compile_error( "improper use of nextfile" ) ; yyval.start = code_offset ; code1(_NEXTFILE) ; } #line 2833 "parse.c" break; case 34: #line 269 "parse.y" { code1(_ASSIGN) ; } #line 2838 "parse.c" break; case 35: #line 270 "parse.y" { code1(_ADD_ASG) ; } #line 2843 "parse.c" break; case 36: #line 271 "parse.y" { code1(_SUB_ASG) ; } #line 2848 "parse.c" break; case 37: #line 272 "parse.y" { code1(_MUL_ASG) ; } #line 2853 "parse.c" break; case 38: #line 273 "parse.y" { code1(_DIV_ASG) ; } #line 2858 "parse.c" break; case 39: #line 274 "parse.y" { code1(_MOD_ASG) ; } #line 2863 "parse.c" break; case 40: #line 275 "parse.y" { code1(_POW_ASG) ; } #line 2868 "parse.c" break; case 41: #line 276 "parse.y" { code1(_EQ) ; } #line 2873 "parse.c" break; case 42: #line 277 "parse.y" { code1(_NEQ) ; } #line 2878 "parse.c" break; case 43: #line 278 "parse.y" { code1(_LT) ; } #line 2883 "parse.c" break; case 44: #line 279 "parse.y" { code1(_LTE) ; } #line 2888 "parse.c" break; case 45: #line 280 "parse.y" { code1(_GT) ; } #line 2893 "parse.c" break; case 46: #line 281 "parse.y" { code1(_GTE) ; } #line 2898 "parse.c" break; case 47: #line 284 "parse.y" { INST *p3 = CDP(yystack.l_mark[0].start) ; if ( p3 == code_ptr - 2 ) { if ( p3->op == _MATCH0 ) p3->op = _MATCH1 ; else /* check for string */ if ( p3->op == _PUSHS ) { CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = p3[1].ptr ; cast_to_RE(cp) ; no_leaks_re_ptr(cp->ptr) ; code_ptr -= 2 ; code2(_MATCH1, cp->ptr) ; ZFREE(cp) ; } else code1(_MATCH2) ; } else code1(_MATCH2) ; if ( !yystack.l_mark[-1].ival ) code1(_NOT) ; } #line 2927 "parse.c" break; case 48: #line 312 "parse.y" { code1(_TEST) ; code_jmp(_LJNZ, (INST*)0) ; } #line 2934 "parse.c" break; case 49: #line 316 "parse.y" { code1(_TEST) ; patch_jmp(code_ptr) ; } #line 2939 "parse.c" break; case 50: #line 319 "parse.y" { code1(_TEST) ; code_jmp(_LJZ, (INST*)0) ; } #line 2946 "parse.c" break; case 51: #line 323 "parse.y" { code1(_TEST) ; patch_jmp(code_ptr) ; } #line 2951 "parse.c" break; case 52: #line 325 "parse.y" { code_jmp(_JZ, (INST*)0) ; } #line 2956 "parse.c" break; case 53: #line 326 "parse.y" { code_jmp(_JMP, (INST*)0) ; } #line 2961 "parse.c" break; case 54: #line 328 "parse.y" { patch_jmp(code_ptr) ; patch_jmp(CDP(yystack.l_mark[0].start)) ; } #line 2966 "parse.c" break; case 56: #line 333 "parse.y" { code1(_CAT) ; } #line 2971 "parse.c" break; case 57: #line 337 "parse.y" { yyval.start = code_offset ; code2(_PUSHD, yystack.l_mark[0].ptr) ; } #line 2976 "parse.c" break; case 58: #line 339 "parse.y" { yyval.start = code_offset ; code2(_PUSHS, yystack.l_mark[0].ptr) ; } #line 2981 "parse.c" break; case 59: #line 341 "parse.y" { check_var(yystack.l_mark[0].stp) ; yyval.start = code_offset ; if ( is_local(yystack.l_mark[0].stp) ) { code2op(L_PUSHI, yystack.l_mark[0].stp->offset) ; } else code2(_PUSHI, yystack.l_mark[0].stp->stval.cp) ; } #line 2991 "parse.c" break; case 60: #line 349 "parse.y" { yyval.start = yystack.l_mark[-1].start ; } #line 2996 "parse.c" break; case 61: #line 353 "parse.y" { yyval.start = code_offset ; code2(_MATCH0, yystack.l_mark[0].ptr) ; no_leaks_re_ptr(yystack.l_mark[0].ptr); } #line 3004 "parse.c" break; case 62: #line 359 "parse.y" { code1(_ADD) ; } #line 3009 "parse.c" break; case 63: #line 360 "parse.y" { code1(_SUB) ; } #line 3014 "parse.c" break; case 64: #line 361 "parse.y" { code1(_MUL) ; } #line 3019 "parse.c" break; case 65: #line 362 "parse.y" { code1(_DIV) ; } #line 3024 "parse.c" break; case 66: #line 363 "parse.y" { code1(_MOD) ; } #line 3029 "parse.c" break; case 67: #line 364 "parse.y" { code1(_POW) ; } #line 3034 "parse.c" break; case 68: #line 366 "parse.y" { yyval.start = yystack.l_mark[0].start ; code1(_NOT) ; } #line 3039 "parse.c" break; case 69: #line 368 "parse.y" { yyval.start = yystack.l_mark[0].start ; code1(_UPLUS) ; } #line 3044 "parse.c" break; case 70: #line 370 "parse.y" { yyval.start = yystack.l_mark[0].start ; code1(_UMINUS) ; } #line 3049 "parse.c" break; case 72: #line 375 "parse.y" { check_var(yystack.l_mark[-1].stp) ; yyval.start = code_offset ; code_address(yystack.l_mark[-1].stp) ; if ( yystack.l_mark[0].ival == '+' ) code1(_POST_INC) ; else code1(_POST_DEC) ; } #line 3060 "parse.c" break; case 73: #line 383 "parse.y" { yyval.start = yystack.l_mark[0].start ; if ( yystack.l_mark[-1].ival == '+' ) code1(_PRE_INC) ; else code1(_PRE_DEC) ; } #line 3068 "parse.c" break; case 74: #line 390 "parse.y" { if (yystack.l_mark[0].ival == '+' ) code1(F_POST_INC ) ; else code1(F_POST_DEC) ; } #line 3075 "parse.c" break; case 75: #line 394 "parse.y" { yyval.start = yystack.l_mark[0].start ; if ( yystack.l_mark[-1].ival == '+' ) code1(F_PRE_INC) ; else code1( F_PRE_DEC) ; } #line 3083 "parse.c" break; case 76: #line 401 "parse.y" { yyval.start = code_offset ; check_var(yystack.l_mark[0].stp) ; code_address(yystack.l_mark[0].stp) ; } #line 3091 "parse.c" break; case 77: #line 409 "parse.y" { yyval.ival = 0 ; } #line 3096 "parse.c" break; case 79: #line 414 "parse.y" { yyval.ival = 1 ; } #line 3101 "parse.c" break; case 80: #line 416 "parse.y" { yyval.ival = yystack.l_mark[-2].ival + 1 ; } #line 3106 "parse.c" break; case 81: #line 421 "parse.y" { const BI_REC *p = yystack.l_mark[-4].bip ; yyval.start = yystack.l_mark[-3].start ; if ( (int)p->min_args > yystack.l_mark[-1].ival || (int)p->max_args < yystack.l_mark[-1].ival ) compile_error( "wrong number of arguments in call to %s" , p->name ) ; if ( p->min_args != p->max_args ) /* variable args */ { code1(_PUSHINT) ; code1(yystack.l_mark[-1].ival) ; } code2(_BUILTIN , p->fp) ; } #line 3120 "parse.c" break; case 82: #line 435 "parse.y" { yyval.start = code_offset ; } #line 3125 "parse.c" break; case 83: #line 440 "parse.y" { code2(_PRINT, yystack.l_mark[-4].fp) ; if ( yystack.l_mark[-4].fp == bi_printf && yystack.l_mark[-2].ival == 0 ) compile_error("no arguments in call to printf") ; print_flag = 0 ; yyval.start = yystack.l_mark[-3].start ; } #line 3135 "parse.c" break; case 84: #line 448 "parse.y" { yyval.fp = bi_print ; print_flag = 1 ;} #line 3140 "parse.c" break; case 85: #line 449 "parse.y" { yyval.fp = bi_printf ; print_flag = 1 ; } #line 3145 "parse.c" break; case 86: #line 452 "parse.y" { code2op(_PUSHINT, yystack.l_mark[0].ival) ; } #line 3150 "parse.c" break; case 87: #line 454 "parse.y" { yyval.ival = yystack.l_mark[-1].arg2p->cnt ; zfree(yystack.l_mark[-1].arg2p,sizeof(ARG2_REC)) ; code2op(_PUSHINT, yyval.ival) ; } #line 3157 "parse.c" break; case 88: #line 458 "parse.y" { yyval.ival=0 ; code2op(_PUSHINT, 0) ; } #line 3162 "parse.c" break; case 89: #line 462 "parse.y" { yyval.arg2p = ZMALLOC(ARG2_REC) ; yyval.arg2p->start = yystack.l_mark[-2].start ; yyval.arg2p->cnt = 2 ; } #line 3170 "parse.c" break; case 90: #line 467 "parse.y" { yyval.arg2p = yystack.l_mark[-2].arg2p ; yyval.arg2p->cnt++ ; } #line 3175 "parse.c" break; case 92: #line 472 "parse.y" { code2op(_PUSHINT, yystack.l_mark[-1].ival) ; } #line 3180 "parse.c" break; case 93: #line 479 "parse.y" { yyval.start = yystack.l_mark[-1].start ; eat_nl() ; code_jmp(_JZ, (INST*)0) ; } #line 3185 "parse.c" break; case 94: #line 484 "parse.y" { patch_jmp( code_ptr ) ; } #line 3190 "parse.c" break; case 95: #line 487 "parse.y" { eat_nl() ; code_jmp(_JMP, (INST*)0) ; } #line 3195 "parse.c" break; case 96: #line 492 "parse.y" { patch_jmp(code_ptr) ; patch_jmp(CDP(yystack.l_mark[0].start)) ; } #line 3202 "parse.c" break; case 97: #line 501 "parse.y" { eat_nl() ; BC_new() ; } #line 3207 "parse.c" break; case 98: #line 506 "parse.y" { yyval.start = yystack.l_mark[-5].start ; code_jmp(_JNZ, CDP(yystack.l_mark[-5].start)) ; BC_clear(code_ptr, CDP(yystack.l_mark[-2].start)) ; } #line 3214 "parse.c" break; case 99: #line 512 "parse.y" { eat_nl() ; BC_new() ; yyval.start = yystack.l_mark[-1].start ; /* check if const expression */ if ( code_ptr - 2 == CDP(yystack.l_mark[-1].start) && code_ptr[-2].op == _PUSHD && *(double*)code_ptr[-1].ptr != 0.0 ) code_ptr -= 2 ; else { INST *p3 = CDP(yystack.l_mark[-1].start) ; code_push(p3, (unsigned) CodeOffset(p3), scope, active_funct) ; code_ptr = p3 ; code2(_JMP, (INST*)0) ; /* code2() not code_jmp() */ } } #line 3234 "parse.c" break; case 100: #line 532 "parse.y" { INST *p1 = CDP(yystack.l_mark[-1].start) ; INST *p2 = CDP(yystack.l_mark[0].start) ; if ( p1 != p2 ) /* real test in loop */ { int saved_offset ; int len ; p1[1].op = CodeOffset(p1 + 1) ; saved_offset = code_offset ; len = (int) code_pop(code_ptr) ; code_ptr += len ; code_jmp(_JNZ, CDP(yystack.l_mark[0].start)) ; BC_clear(code_ptr, CDP(saved_offset)) ; } else /* while(1) */ { code_jmp(_JMP, p1) ; BC_clear(code_ptr, CDP(yystack.l_mark[0].start)) ; } } #line 3260 "parse.c" break; case 101: #line 559 "parse.y" { int cont_offset = code_offset ; unsigned len = code_pop(code_ptr) ; INST *p2 = CDP(yystack.l_mark[-2].start) ; INST *p4 = CDP(yystack.l_mark[0].start) ; code_ptr += len ; if ( p2 != p4 ) /* real test in for2 */ { p4[-1].op = CodeOffset(p4 - 1) ; len = code_pop(code_ptr) ; code_ptr += len ; code_jmp(_JNZ, CDP(yystack.l_mark[0].start)) ; } else /* for(;;) */ code_jmp(_JMP, p4) ; BC_clear(code_ptr, CDP(cont_offset)) ; } #line 3285 "parse.c" break; case 102: #line 582 "parse.y" { yyval.start = code_offset ; } #line 3290 "parse.c" break; case 103: #line 584 "parse.y" { yyval.start = yystack.l_mark[-1].start ; code1(_POP) ; } #line 3295 "parse.c" break; case 104: #line 587 "parse.y" { yyval.start = code_offset ; } #line 3300 "parse.c" break; case 105: #line 589 "parse.y" { if ( code_ptr - 2 == CDP(yystack.l_mark[-1].start) && code_ptr[-2].op == _PUSHD && * (double*) code_ptr[-1].ptr != 0.0 ) code_ptr -= 2 ; else { INST *p1 = CDP(yystack.l_mark[-1].start) ; code_push(p1, (unsigned) CodeOffset(p1), scope, active_funct) ; code_ptr = p1 ; code2(_JMP, (INST*)0) ; } } #line 3318 "parse.c" break; case 106: #line 606 "parse.y" { eat_nl() ; BC_new() ; code_push((INST*)0,0, scope, active_funct) ; } #line 3325 "parse.c" break; case 107: #line 610 "parse.y" { INST *p1 = CDP(yystack.l_mark[-1].start) ; eat_nl() ; BC_new() ; code1(_POP) ; code_push(p1, (unsigned) CodeOffset(p1), scope, active_funct) ; code_ptr -= code_ptr - p1 ; } #line 3336 "parse.c" break; case 108: #line 623 "parse.y" { check_array(yystack.l_mark[0].stp) ; code_array(yystack.l_mark[0].stp) ; code1(A_TEST) ; } #line 3344 "parse.c" break; case 109: #line 628 "parse.y" { yyval.start = yystack.l_mark[-3].arg2p->start ; code2op(A_CAT, yystack.l_mark[-3].arg2p->cnt) ; zfree(yystack.l_mark[-3].arg2p, sizeof(ARG2_REC)) ; check_array(yystack.l_mark[0].stp) ; code_array(yystack.l_mark[0].stp) ; code1(A_TEST) ; } #line 3356 "parse.c" break; case 110: #line 639 "parse.y" { if ( yystack.l_mark[-1].ival > 1 ) { code2op(A_CAT, yystack.l_mark[-1].ival) ; } check_array(yystack.l_mark[-4].stp) ; if( is_local(yystack.l_mark[-4].stp) ) { code2op(LAE_PUSHA, yystack.l_mark[-4].stp->offset) ; } else code2(AE_PUSHA, yystack.l_mark[-4].stp->stval.array) ; yyval.start = yystack.l_mark[-3].start ; } #line 3370 "parse.c" break; case 111: #line 652 "parse.y" { if ( yystack.l_mark[-1].ival > 1 ) { code2op(A_CAT, yystack.l_mark[-1].ival) ; } check_array(yystack.l_mark[-4].stp) ; if( is_local(yystack.l_mark[-4].stp) ) { code2op(LAE_PUSHI, yystack.l_mark[-4].stp->offset) ; } else code2(AE_PUSHI, yystack.l_mark[-4].stp->stval.array) ; yyval.start = yystack.l_mark[-3].start ; } #line 3384 "parse.c" break; case 112: #line 664 "parse.y" { if ( yystack.l_mark[-2].ival > 1 ) { code2op(A_CAT,yystack.l_mark[-2].ival) ; } check_array(yystack.l_mark[-5].stp) ; if( is_local(yystack.l_mark[-5].stp) ) { code2op(LAE_PUSHA, yystack.l_mark[-5].stp->offset) ; } else code2(AE_PUSHA, yystack.l_mark[-5].stp->stval.array) ; if ( yystack.l_mark[0].ival == '+' ) code1(_POST_INC) ; else code1(_POST_DEC) ; yyval.start = yystack.l_mark[-4].start ; } #line 3401 "parse.c" break; case 113: #line 681 "parse.y" { yyval.start = yystack.l_mark[-4].start ; if ( yystack.l_mark[-2].ival > 1 ) { code2op(A_CAT, yystack.l_mark[-2].ival) ; } check_array(yystack.l_mark[-5].stp) ; code_array(yystack.l_mark[-5].stp) ; code1(A_DEL) ; } #line 3412 "parse.c" break; case 114: #line 689 "parse.y" { yyval.start = code_offset ; check_array(yystack.l_mark[-1].stp) ; code_array(yystack.l_mark[-1].stp) ; code1(DEL_A) ; } #line 3422 "parse.c" break; case 115: #line 700 "parse.y" { eat_nl() ; BC_new() ; yyval.start = code_offset ; check_var(yystack.l_mark[-3].stp) ; code_address(yystack.l_mark[-3].stp) ; check_array(yystack.l_mark[-1].stp) ; code_array(yystack.l_mark[-1].stp) ; code2(SET_ALOOP, (INST*)0) ; } #line 3436 "parse.c" break; case 116: #line 714 "parse.y" { INST *p2 = CDP(yystack.l_mark[0].start) ; p2[-1].op = CodeOffset(p2 - 1) ; BC_clear( code_ptr+2 , code_ptr) ; code_jmp(ALOOP, p2) ; code1(POP_AL) ; } #line 3448 "parse.c" break; case 117: #line 731 "parse.y" { yyval.start = code_offset ; code2(F_PUSHA, yystack.l_mark[0].cp) ; } #line 3453 "parse.c" break; case 118: #line 733 "parse.y" { check_var(yystack.l_mark[0].stp) ; yyval.start = code_offset ; if ( is_local(yystack.l_mark[0].stp) ) { code2op(L_PUSHI, yystack.l_mark[0].stp->offset) ; } else code2(_PUSHI, yystack.l_mark[0].stp->stval.cp) ; CODE_FE_PUSHA() ; } #line 3465 "parse.c" break; case 119: #line 742 "parse.y" { if ( yystack.l_mark[-1].ival > 1 ) { code2op(A_CAT, yystack.l_mark[-1].ival) ; } check_array(yystack.l_mark[-4].stp) ; if( is_local(yystack.l_mark[-4].stp) ) { code2op(LAE_PUSHI, yystack.l_mark[-4].stp->offset) ; } else code2(AE_PUSHI, yystack.l_mark[-4].stp->stval.array) ; CODE_FE_PUSHA() ; yyval.start = yystack.l_mark[-3].start ; } #line 3482 "parse.c" break; case 120: #line 756 "parse.y" { yyval.start = yystack.l_mark[0].start ; CODE_FE_PUSHA() ; } #line 3487 "parse.c" break; case 121: #line 758 "parse.y" { yyval.start = yystack.l_mark[-1].start ; } #line 3492 "parse.c" break; case 122: #line 762 "parse.y" { field_A2I() ; } #line 3497 "parse.c" break; case 123: #line 765 "parse.y" { code1(F_ASSIGN) ; } #line 3502 "parse.c" break; case 124: #line 766 "parse.y" { code1(F_ADD_ASG) ; } #line 3507 "parse.c" break; case 125: #line 767 "parse.y" { code1(F_SUB_ASG) ; } #line 3512 "parse.c" break; case 126: #line 768 "parse.y" { code1(F_MUL_ASG) ; } #line 3517 "parse.c" break; case 127: #line 769 "parse.y" { code1(F_DIV_ASG) ; } #line 3522 "parse.c" break; case 128: #line 770 "parse.y" { code1(F_MOD_ASG) ; } #line 3527 "parse.c" break; case 129: #line 771 "parse.y" { code1(F_POW_ASG) ; } #line 3532 "parse.c" break; case 130: #line 778 "parse.y" { code2(_BUILTIN, bi_split) ; } #line 3537 "parse.c" break; case 131: #line 782 "parse.y" { yyval.start = yystack.l_mark[-2].start ; check_array(yystack.l_mark[0].stp) ; code_array(yystack.l_mark[0].stp) ; } #line 3545 "parse.c" break; case 132: #line 789 "parse.y" { code2(_PUSHI, &fs_shadow) ; } #line 3550 "parse.c" break; case 133: #line 791 "parse.y" { if ( CDP(yystack.l_mark[-1].start) == code_ptr - 2 ) { if ( code_ptr[-2].op == _MATCH0 ) { RE_as_arg() ; } else if ( code_ptr[-2].op == _PUSHS ) { CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = code_ptr[-1].ptr ; cast_for_split(cp) ; code_ptr[-2].op = _PUSHC ; code_ptr[-1].ptr = (PTR) cp ; no_leaks_cell(cp); } } } #line 3573 "parse.c" break; case 134: #line 814 "parse.y" { yyval.start = code_offset ; code2(_PUSHI,field) ; code2(_BUILTIN,bi_length) ; } #line 3581 "parse.c" break; case 135: #line 819 "parse.y" { yyval.start = yystack.l_mark[-1].start ; code2(_BUILTIN,bi_length) ; } #line 3588 "parse.c" break; case 136: #line 823 "parse.y" { SYMTAB* stp = yystack.l_mark[-1].stp; yyval.start = code_offset; switch (stp->type) { case ST_VAR: code2(_PUSHI, stp->stval.cp); code2(_BUILTIN, bi_length); break; case ST_ARRAY: code2(A_PUSHA, stp->stval.array); code2(_BUILTIN, bi_alength); break; case ST_LOCAL_VAR: code2op(L_PUSHI, stp->offset); code2(_BUILTIN, bi_length); break; case ST_LOCAL_ARRAY: code2op(LA_PUSHA, stp->offset); code2(_BUILTIN, bi_alength); break; case ST_NONE: /* defer_alen */ code2(A_LENGTH, stp); code2(_BUILTIN, bi_length); break; case ST_LOCAL_NONE: /* defer_len */ { DEFER_LEN* pi = ZMALLOC(DEFER_LEN); pi->fbp = active_funct; pi->offset = stp->offset; code2(_LENGTH, pi); code2(_BUILTIN, bi_length); } break; default: type_error(stp); break; } } #line 3638 "parse.c" break; case 137: #line 871 "parse.y" { yyval.start = code_offset ; code2(_PUSHI,field) ; code2(_BUILTIN,bi_length) ; } #line 3646 "parse.c" break; case 138: #line 880 "parse.y" { yyval.start = yystack.l_mark[-3].start ; code2(_BUILTIN, bi_match) ; } #line 3653 "parse.c" break; case 139: #line 887 "parse.y" { INST *p1 = CDP(yystack.l_mark[0].start) ; if ( p1 == code_ptr - 2 ) { if ( p1->op == _MATCH0 ) RE_as_arg() ; else if ( p1->op == _PUSHS ) { CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = p1[1].ptr ; cast_to_RE(cp) ; p1->op = _PUSHC ; p1[1].ptr = (PTR) cp ; no_leaks_cell(cp); } } } #line 3676 "parse.c" break; case 140: #line 911 "parse.y" { yyval.start = code_offset ; code1(_EXIT0) ; } #line 3682 "parse.c" break; case 141: #line 914 "parse.y" { yyval.start = yystack.l_mark[-1].start ; code1(_EXIT) ; } #line 3687 "parse.c" break; case 142: #line 918 "parse.y" { yyval.start = code_offset ; code1(_RET0) ; } #line 3693 "parse.c" break; case 143: #line 921 "parse.y" { yyval.start = yystack.l_mark[-1].start ; code1(_RET) ; } #line 3698 "parse.c" break; case 144: #line 927 "parse.y" { yyval.start = code_offset ; code2(F_PUSHA, &field[0]) ; code1(_PUSHINT) ; code1(0) ; code2(_BUILTIN, bi_getline) ; getline_flag = 0 ; } #line 3708 "parse.c" break; case 145: #line 934 "parse.y" { yyval.start = yystack.l_mark[0].start ; code1(_PUSHINT) ; code1(0) ; code2(_BUILTIN, bi_getline) ; getline_flag = 0 ; } #line 3717 "parse.c" break; case 146: #line 940 "parse.y" { code1(_PUSHINT) ; code1(F_IN) ; code2(_BUILTIN, bi_getline) ; /* getline_flag already off in yylex() */ } #line 3725 "parse.c" break; case 147: #line 945 "parse.y" { code2(F_PUSHA, &field[0]) ; code1(_PUSHINT) ; code1(PIPE_IN) ; code2(_BUILTIN, bi_getline) ; } #line 3733 "parse.c" break; case 148: #line 950 "parse.y" { code1(_PUSHINT) ; code1(PIPE_IN) ; code2(_BUILTIN, bi_getline) ; } #line 3741 "parse.c" break; case 149: #line 956 "parse.y" { getline_flag = 1 ; } #line 3746 "parse.c" break; case 152: #line 961 "parse.y" { yyval.start = code_offset ; code2(F_PUSHA, field+0) ; } #line 3753 "parse.c" break; case 153: #line 965 "parse.y" { yyval.start = yystack.l_mark[-1].start ; } #line 3758 "parse.c" break; case 154: #line 973 "parse.y" { INST *p5 = CDP(yystack.l_mark[-1].start) ; INST *p6 = CDP(yystack.l_mark[0].start) ; if ( p6 - p5 == 2 && p5->op == _PUSHS ) { /* cast from STRING to REPL at compile time */ CELL *cp = ZMALLOC(CELL) ; cp->type = C_STRING ; cp->ptr = p5[1].ptr ; cast_to_REPL(cp) ; p5->op = _PUSHC ; p5[1].ptr = (PTR) cp ; no_leaks_cell(cp); } code2(_BUILTIN, yystack.l_mark[-5].fp) ; yyval.start = yystack.l_mark[-3].start ; } #line 3779 "parse.c" break; case 155: #line 992 "parse.y" { yyval.fp = bi_sub ; } #line 3784 "parse.c" break; case 156: #line 993 "parse.y" { yyval.fp = bi_gsub ; } #line 3789 "parse.c" break; case 157: #line 998 "parse.y" { yyval.start = code_offset ; code2(F_PUSHA, &field[0]) ; } #line 3796 "parse.c" break; case 158: #line 1003 "parse.y" { yyval.start = yystack.l_mark[-1].start ; } #line 3801 "parse.c" break; case 159: #line 1011 "parse.y" { resize_fblock(yystack.l_mark[-1].fbp) ; restore_ids() ; switch_code_to_main() ; } #line 3810 "parse.c" break; case 160: #line 1020 "parse.y" { eat_nl() ; scope = SCOPE_FUNCT ; active_funct = yystack.l_mark[-3].fbp ; *main_code_p = active_code ; yystack.l_mark[-3].fbp->nargs = (NUM_ARGS) yystack.l_mark[-1].ival ; if ( yystack.l_mark[-1].ival ) yystack.l_mark[-3].fbp->typev = (SYM_TYPE *) memset( zmalloc((size_t) yystack.l_mark[-1].ival), ST_LOCAL_NONE, (size_t) yystack.l_mark[-1].ival) ; else yystack.l_mark[-3].fbp->typev = (SYM_TYPE *) 0 ; code_ptr = code_base = (INST *) zmalloc(INST_BYTES(PAGESZ)); code_limit = code_base + PAGESZ ; code_warn = code_limit - CODEWARN ; improve_arglist(yystack.l_mark[-3].fbp->name); free_arglist(); } #line 3832 "parse.c" break; case 161: #line 1041 "parse.y" { FBLOCK *fbp ; if ( yystack.l_mark[0].stp->type == ST_NONE ) { yystack.l_mark[0].stp->type = ST_FUNCT ; fbp = yystack.l_mark[0].stp->stval.fbp = ZMALLOC(FBLOCK) ; fbp->name = yystack.l_mark[0].stp->name ; fbp->code = (INST*) 0 ; } else { type_error( yystack.l_mark[0].stp ) ; /* this FBLOCK will not be put in the symbol table */ fbp = ZMALLOC(FBLOCK) ; fbp->name = "" ; } yyval.fbp = fbp ; } #line 3856 "parse.c" break; case 162: #line 1063 "parse.y" { yyval.fbp = yystack.l_mark[0].fbp ; if ( yystack.l_mark[0].fbp->code ) compile_error("redefinition of %s" , yystack.l_mark[0].fbp->name) ; } #line 3864 "parse.c" break; case 163: #line 1069 "parse.y" { yyval.ival = init_arglist() ; } #line 3869 "parse.c" break; case 165: #line 1074 "parse.y" { init_arglist(); yystack.l_mark[0].stp = save_arglist(yystack.l_mark[0].stp->name) ; yystack.l_mark[0].stp->offset = 0 ; yyval.ival = 1 ; } #line 3878 "parse.c" break; case 166: #line 1080 "parse.y" { if ( is_local(yystack.l_mark[0].stp) ) compile_error("%s is duplicated in argument list", yystack.l_mark[0].stp->name) ; else { yystack.l_mark[0].stp = save_arglist(yystack.l_mark[0].stp->name) ; yystack.l_mark[0].stp->offset = (unsigned char) yystack.l_mark[-2].ival ; yyval.ival = yystack.l_mark[-2].ival + 1 ; } } #line 3891 "parse.c" break; case 167: #line 1092 "parse.y" { /* we may have to recover from a bungled function definition */ /* can have local ids, before code scope changes */ restore_ids() ; switch_code_to_main() ; } #line 3903 "parse.c" break; case 168: #line 1105 "parse.y" { yyval.start = yystack.l_mark[-1].start ; code2(_CALL, yystack.l_mark[-2].fbp) ; if ( yystack.l_mark[0].ca_p ) code1(yystack.l_mark[0].ca_p->arg_num+1) ; else code1(0) ; check_fcall(yystack.l_mark[-2].fbp, scope, code_move_level, active_funct, yystack.l_mark[0].ca_p) ; } #line 3915 "parse.c" break; case 169: #line 1116 "parse.y" { yyval.ca_p = (CA_REC *) 0 ; } #line 3920 "parse.c" break; case 170: #line 1118 "parse.y" { yyval.ca_p = yystack.l_mark[0].ca_p ; yyval.ca_p->link = yystack.l_mark[-1].ca_p ; yyval.ca_p->arg_num = (NUM_ARGS) (yystack.l_mark[-1].ca_p ? yystack.l_mark[-1].ca_p->arg_num+1 : 0) ; yyval.ca_p->call_lineno = token_lineno; } #line 3929 "parse.c" break; case 171: #line 1134 "parse.y" { yyval.ca_p = (CA_REC *) 0 ; } #line 3934 "parse.c" break; case 172: #line 1136 "parse.y" { yyval.ca_p = ZMALLOC(CA_REC) ; yyval.ca_p->link = yystack.l_mark[-2].ca_p ; yyval.ca_p->type = CA_EXPR ; yyval.ca_p->arg_num = (NUM_ARGS) (yystack.l_mark[-2].ca_p ? yystack.l_mark[-2].ca_p->arg_num+1 : 0) ; yyval.ca_p->call_offset = code_offset ; yyval.ca_p->call_lineno = token_lineno; } #line 3945 "parse.c" break; case 173: #line 1144 "parse.y" { yyval.ca_p = ZMALLOC(CA_REC) ; yyval.ca_p->type = ST_NONE ; yyval.ca_p->link = yystack.l_mark[-2].ca_p ; yyval.ca_p->arg_num = (NUM_ARGS) (yystack.l_mark[-2].ca_p ? yystack.l_mark[-2].ca_p->arg_num+1 : 0) ; yyval.ca_p->call_lineno = token_lineno; code_call_id(yyval.ca_p, yystack.l_mark[-1].stp) ; } #line 3957 "parse.c" break; case 174: #line 1155 "parse.y" { yyval.ca_p = ZMALLOC(CA_REC) ; yyval.ca_p->type = CA_EXPR ; yyval.ca_p->call_offset = code_offset ; } #line 3965 "parse.c" break; case 175: #line 1161 "parse.y" { yyval.ca_p = ZMALLOC(CA_REC) ; yyval.ca_p->type = ST_NONE ; code_call_id(yyval.ca_p, yystack.l_mark[-1].stp) ; } #line 3973 "parse.c" break; #line 3975 "parse.c" default: break; } yystack.s_mark -= yym; yystate = *yystack.s_mark; yystack.l_mark -= yym; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark -= yym; #endif yym = yylhs[yyn]; if (yystate == 0 && yym == 0) { #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); #endif fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); } #endif yystate = YYFINAL; *++yystack.s_mark = YYFINAL; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif if (yychar < 0) { #if YYBTYACC do { if (yylvp < yylve) { /* we're currently re-reading tokens */ yylval = *yylvp++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylloc = *yylpp++; #endif yychar = *yylexp++; break; } if (yyps->save) { /* in trial mode; save scanner results for future parse attempts */ if (yylvp == yylvlim) { /* Enlarge lexical value queue */ size_t p = (size_t) (yylvp - yylvals); size_t s = (size_t) (yylvlim - yylvals); s += YYLVQUEUEGROWTH; if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; #endif yylvp = yylve = yylvals + p; yylvlim = yylvals + s; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpe = yylpsns + p; yylplim = yylpsns + s; #endif yylexp = yylexemes + p; } *yylexp = (YYINT) YYLEX; *yylvp++ = yylval; yylve++; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *yylpp++ = yylloc; yylpe++; #endif yychar = *yylexp++; break; } /* normal operation, no conflict encountered */ #endif /* YYBTYACC */ yychar = YYLEX; #if YYBTYACC } while (0); #endif /* YYBTYACC */ if (yychar < 0) yychar = YYEOF; #if YYDEBUG if (yydebug) { if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); } #endif } if (yychar == YYEOF) goto yyaccept; goto yyloop; } if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) yystate = yytable[yyn]; else yystate = yydgoto[yym]; #if YYDEBUG if (yydebug) { fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); #ifdef YYSTYPE_TOSTRING #if YYBTYACC if (!yytrial) #endif /* YYBTYACC */ fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); #endif fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); } #endif if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; *++yystack.s_mark = (YYINT) yystate; *++yystack.l_mark = yyval; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) *++yystack.p_mark = yyloc; #endif goto yyloop; #if YYBTYACC /* Reduction declares that this path is valid. Set yypath and do a full parse */ yyvalid: if (yypath) YYABORT; while (yyps->save) { YYParseState *save = yyps->save; yyps->save = save->save; save->save = yypath; yypath = save; } #if YYDEBUG if (yydebug) fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); #endif if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } yylvp = yylvals + yypath->lexeme; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yylpp = yylpsns + yypath->lexeme; #endif yylexp = yylexemes + yypath->lexeme; yychar = YYEMPTY; yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); #endif yystate = yypath->state; goto yyloop; #endif /* YYBTYACC */ yyoverflow: YYERROR_CALL("yacc stack overflow"); #if YYBTYACC goto yyabort_nomem; yyenomem: YYERROR_CALL("memory exhausted"); yyabort_nomem: #endif /* YYBTYACC */ yyresult = 2; goto yyreturn; yyabort: yyresult = 1; goto yyreturn; yyaccept: #if YYBTYACC if (yyps->save) goto yyvalid; #endif /* YYBTYACC */ yyresult = 0; yyreturn: #if defined(YYDESTRUCT_CALL) if (yychar != YYEOF && yychar != YYEMPTY) #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); #else YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ { YYSTYPE *pv; #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) YYLTYPE *pp; for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); #else for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) YYDESTRUCT_CALL("cleanup: discarding state", yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ } #endif /* defined(YYDESTRUCT_CALL) */ #if YYBTYACC if (yyerrctx) { yyFreeState(yyerrctx); yyerrctx = NULL; } while (yyps) { YYParseState *save = yyps; yyps = save->save; save->save = NULL; yyFreeState(save); } while (yypath) { YYParseState *save = yypath; yypath = save->save; save->save = NULL; yyFreeState(save); } #endif /* YYBTYACC */ yyfreestack(&yystack); return (yyresult); } mawk-1.3.4-20240123/sizes.h0000644000000000000000000000717313736053470013375 0ustar rootroot/******************************************** sizes.h copyright 2009-2017,2020 Thomas E. Dickey copyright 1991-1995,2014. Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: sizes.h,v 1.22 2020/10/03 10:49:28 tom Exp $ */ /* sizes.h */ #ifndef SIZES_H #define SIZES_H /* *INDENT-OFF* */ #include "config.h" #ifndef SIZEOF_LONG #define SIZEOF_LONG 4 #endif #ifndef SIZEOF_LONG_LONG #define SIZEOF_LONG_LONG 4 #endif #if defined(HAVE_STDINT_H) && defined(HAVE_INT64_T) && defined(HAVE_UINT64_T) #include #include #if defined(INT64_MAX) #define MAX__INT INT64_MAX #elif defined(LLONG_MAX) #define MAX__INT LLONG_MAX #elif defined(LONG_LONG_MAX) #define MAX__INT LONG_LONG_MAX #endif #if defined(UINT64_MAX) #define MAX__UINT UINT64_MAX #elif defined(LLONG_MAX) #define MAX__UINT ULLONG_MAX #elif defined(LONG_LONG_MAX) #define MAX__UINT ULONG_LONG_MAX #endif #define MAX__LONG MAX__INT #define MAX__ULONG MAX__UINT typedef int64_t Int; typedef int64_t Long; #define Max_Int MAX__INT #define Max_Long MAX__LONG typedef uint64_t UInt; typedef uint64_t ULong; #define Max_UInt MAX__UINT #define Max_ULong MAX__ULONG #if (SIZEOF_LONG_LONG > SIZEOF_LONG) || defined(__APPLE__) || defined(__OpenBSD__) #define INT_FMT "%lld" #define UINT_FMT "%llu" #define LONG_FMT "%lld" #define ULONG_FMT "%llu" #define USE_LL_FORMAT 1 #else #define INT_FMT "%ld" #define UINT_FMT "%lu" #define LONG_FMT "%ld" #define ULONG_FMT "%lu" #endif #else /* !defined(HAVE_STDINT_H), etc */ #ifndef MAX__INT #include #define MAX__INT INT_MAX #define MAX__LONG LONG_MAX #define MAX__UINT UINT_MAX #define MAX__ULONG ULONG_MAX #endif /* MAX__INT */ #if MAX__INT <= 0x7fff #define SHORT_INTS #define INT_FMT "%ld" typedef long Int; typedef long Long; #define Max_Int MAX__LONG #define Max_Long MAX__LONG #else #define INT_FMT "%d" typedef int Int; typedef long Long; #define Max_Int MAX__INT #define Max_Long MAX__LONG #endif #if MAX__UINT <= 0xffff #define SHORT_UINTS #define UINT_FMT "%lu" typedef unsigned long UInt; typedef unsigned long ULong; #define Max_UInt MAX__ULONG #define Max_ULong MAX__ULONG #else #define UINT_FMT "%u" typedef unsigned int UInt; typedef unsigned long ULong; #define Max_UInt MAX__UINT #define Max_ULong MAX__ULONG #endif #define LONG_FMT "%ld" #define ULONG_FMT "%lu" #endif /* HAVE_STDINT_H */ #define EVAL_STACK_SIZE 1024 /* initial size , can grow */ /* * FBANK_SZ, the number of fields at startup, must be a power of 2. * */ #define FBANK_SZ 1024 #define FB_SHIFT 10 /* lg(FBANK_SZ) */ /* * hardwired limit on sprintf size, can be overridden with -Ws=xxx * TBD to remove hard wired limit */ #define SPRINTF_LIMIT 8192 #define BUFFSZ 4096 /* starting buffer size for input files, grows if necessary */ #ifdef MSDOS /* trade some space for IO speed */ #undef BUFFSZ #define BUFFSZ 8192 /* maximum input buffers that will fit in 64K */ #define MAX_BUFFS ((int)(0x10000L/BUFFSZ) - 1) #endif #define HASH_PRIME 53 #define A_HASH_PRIME 199 #define MAX_COMPILE_ERRORS 5 /* quit if more than 4 errors */ /* *INDENT-ON* */ #endif /* SIZES_H */ mawk-1.3.4-20240123/repl.h0000644000000000000000000000231314456100232013156 0ustar rootroot/******************************************** repl.h copyright 2009-2020,2023, Thomas E. Dickey copyright 1991,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: repl.h,v 1.11 2023/07/20 00:32:26 tom Exp $ */ /* repl.h */ #ifndef REPL_H #define REPL_H #include "types.h" typedef struct re_data { PTR compiled; /* must be first... */ int anchored; /* use to limit recursion in gsub */ int is_empty; /* check if pattern is empty */ } RE_DATA; /* * re_compile returns a RE_DATA*, but mawk handles it as a PTR thereafter. */ #define isAnchored(ptr) (((RE_DATA *)(ptr))->anchored) #define isEmpty_RE(ptr) (((RE_DATA *)(ptr))->is_empty) #define cast_to_re(ptr) (((RE_DATA *)(ptr))->compiled) #define refRE_DATA(re) ((PTR) &(re)) PTR re_compile(STRING *); STRING *re_uncompile(PTR); CELL *repl_compile(STRING *); const STRING *repl_uncompile(CELL *); void re_destroy(PTR); void repl_destroy(CELL *); CELL *replv_cpy(CELL *, CELL *); CELL *replv_to_repl(CELL *, STRING *); #endif mawk-1.3.4-20240123/re_cmpl.c0000644000000000000000000002266014530741560013647 0ustar rootroot/******************************************** re_cmpl.c copyright 2008-2020,2023, Thomas E. Dickey copyright 1991-1994,2014, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: re_cmpl.c,v 1.35 2023/11/26 22:15:12 tom Exp $ */ /* re_cmpl.c */ #include "mawk.h" #include "memory.h" #include "scan.h" #include "regexp.h" #include "repl.h" typedef struct re_node { RE_DATA re; /* keep this first, for re_destroy() */ STRING *sval; struct re_node *link; } RE_NODE; /* a list of compiled regular expressions */ static RE_NODE *re_list; static const char efmt[] = "regular expression compile failed (%s)\n%s"; /* compile a STRING to a regular expression machine. Search a list of pre-compiled strings first */ PTR re_compile(STRING * sval) { register RE_NODE *p; RE_NODE *q; char *s; /* search list */ s = sval->str; p = re_list; q = (RE_NODE *) 0; while (p) { if (sval->len == p->sval->len && memcmp(s, p->sval->str, sval->len) == 0) { /* found */ if (!q) /* already at front */ goto _return; else { /* delete from list for move to front */ q->link = p->link; goto found; } } else { q = p; p = p->link; } } /* not found */ p = ZMALLOC(RE_NODE); p->sval = sval; sval->ref_cnt++; p->re.anchored = (*s == '^'); p->re.is_empty = (sval->len == 0); if (!(p->re.compiled = REcompile(s, sval->len))) { ZFREE(p); sval->ref_cnt--; if (mawk_state == EXECUTION) rt_error(efmt, REerror(), s); else { /* compiling */ compile_error(efmt, REerror(), s); return (PTR) 0; } } found: /* insert p at the front of the list */ p->link = re_list; re_list = p; _return: #ifdef DEBUG if (dump_RE) REmprint(p->re.compiled, stderr); #endif return refRE_DATA(p->re); } /* this is only used by da() */ STRING * re_uncompile(PTR m) { register RE_NODE *p; for (p = re_list; p; p = p->link) if (p->re.compiled == cast_to_re(m)) return p->sval; #ifdef DEBUG bozo("non compiled machine"); #else return NULL; #endif } #ifdef NO_LEAKS void re_destroy(PTR m) { RE_NODE *p = (RE_NODE *) m; RE_NODE *q; RE_NODE *r; if (p != 0) { for (q = re_list, r = 0; q != 0; r = q, q = q->link) { if (q == p) { free_STRING(p->sval); REdestroy(p->re.compiled); if (r != 0) r->link = q->link; else re_list = q->link; free(q); break; } } } } #endif /*=================================================*/ /* replacement operations */ /* create a replacement CELL from a STRING * */ /* Here the replacement string gets scanned for & * which calls for using the matched text in the replacement * So to get a literal & in the replacement requires a convention * which is \& is literal & not a matched text &. * Here are the Posix rules which this code supports: \& --> & \\ --> \ \c --> \c & --> matched text */ /* FIXME -- this function doesn't handle embedded nulls split_buff is obsolete, but needed by this function. Putting them here is temporary until the rewrite to handle nulls. */ #define SPLIT_SIZE 256 static STRING **split_buff; static size_t split_size; static CELL * REPL_compile(STRING * sval) { VCount count = 0; register char *p = sval->str; register char *q; register char *r; char *xbuff; CELL *cp; size_t limit = sval->len + 1; if (limit > split_size) { size_t new_size = limit + SPLIT_SIZE; if (split_buff != NULL) { size_t old_size = split_size; split_buff = (STRING **) zrealloc(split_buff, old_size * sizeof(STRING *), new_size * sizeof(STRING *)); } else { split_buff = (STRING **) zmalloc(new_size * sizeof(STRING *)); } split_size = new_size; } q = xbuff = (char *) zmalloc(limit); while (1) { switch (*p) { case 0: *q = 0; goto done; case '\\': if (p[1] == '\\') { int merge = 0; for (r = p + 2; *r; ++r) { if (r[0] == '&') { /* gotcha! */ merge = 1; } else if (r[0] != '\\') { /* give up: do not alter */ break; } } if (merge) { *q++ = p[1]; p += 2; } else { *q++ = *p++; *q++ = *p++; } continue; } else if (p[1] == '&') { *q++ = p[1]; p += 2; continue; } else break; case '&': /* if empty we don't need to make a node */ if (q != xbuff) { *q = 0; split_buff[count++] = new_STRING(xbuff); } /* and a null node for the '&' */ split_buff[count++] = (STRING *) 0; /* reset */ p++; q = xbuff; continue; default: break; } *q++ = *p++; } done: /* if we have one empty string it will get made now */ if (q > xbuff || count == 0) split_buff[count++] = new_STRING(xbuff); cp = ZMALLOC(CELL); if (count == 1 && split_buff[0]) { cp->type = C_REPL; cp->ptr = (PTR) split_buff[0]; USED_SPLIT_BUFF(0); } else { STRING **sp = (STRING **) (cp->ptr = zmalloc(sizeof(STRING *) * count)); VCount j = 0; while (j < count) { *sp++ = split_buff[j++]; USED_SPLIT_BUFF(j - 1); } cp->type = C_REPLV; cp->vcnt = count; } zfree(xbuff, limit); return cp; } /* free memory used by a replacement CELL */ void repl_destroy(CELL *cp) { register STRING **p; VCount cnt; if (cp->type == C_REPL) { free_STRING(string(cp)); } else if (cp->ptr != 0) { /* an C_REPLV */ p = (STRING **) cp->ptr; for (cnt = cp->vcnt; cnt; cnt--) { if (*p) { free_STRING(*p); } p++; } zfree(cp->ptr, cp->vcnt * sizeof(STRING *)); } } /* copy a C_REPLV cell to another CELL */ CELL * replv_cpy(CELL *target, CELL *source) { STRING **t, **s; VCount cnt; target->type = C_REPLV; cnt = target->vcnt = source->vcnt; target->ptr = (PTR) zmalloc(cnt * sizeof(STRING *)); t = (STRING **) target->ptr; s = (STRING **) source->ptr; while (cnt) { cnt--; if (*s) (*s)->ref_cnt++; *t++ = *s++; } return target; } /* here's our old friend linked linear list with move to the front for compilation of replacement CELLs */ typedef struct repl_node { struct repl_node *link; STRING *sval; /* the input */ CELL *cp; /* the output */ } REPL_NODE; static REPL_NODE *repl_list; /* search the list (with move to the front) for a compiled separator. return a ptr to a CELL (C_REPL or C_REPLV) */ CELL * repl_compile(STRING * sval) { register REPL_NODE *p; REPL_NODE *q; char *s; /* search the list */ s = sval->str; p = repl_list; q = (REPL_NODE *) 0; while (p) { if (strcmp(s, p->sval->str) == 0) /* found */ { if (!q) /* already at front */ return p->cp; else { /* delete from list for move to front */ q->link = p->link; goto found; } } else { q = p; p = p->link; } } /* not found */ p = ZMALLOC(REPL_NODE); p->sval = sval; sval->ref_cnt++; p->cp = REPL_compile(sval); found: /* insert p at the front of the list */ p->link = repl_list; repl_list = p; return p->cp; } /* return the string for a CELL or type REPL or REPLV, this is only used by da() */ const STRING * repl_uncompile(CELL *cp) { register REPL_NODE *p = repl_list; if (cp->type == C_REPL) { while (p) { if (p->cp->type == C_REPL && p->cp->ptr == cp->ptr) return p->sval; else p = p->link; } } else { while (p) { if (p->cp->type == C_REPLV && memcmp(cp->ptr, p->cp->ptr, cp->vcnt * sizeof(STRING *)) == 0) return p->sval; else p = p->link; } } #ifdef DEBUG bozo("unable to uncompile an repl"); #else return NULL; #endif } /* convert a C_REPLV to C_REPL replacing the &s with sval */ CELL * replv_to_repl(CELL *cp, STRING * sval) { register STRING **p; STRING **sblock = (STRING **) cp->ptr; unsigned cnt, vcnt = cp->vcnt; size_t len; char *target; #ifdef DEBUG if (cp->type != C_REPLV) bozo("not replv"); #endif p = sblock; cnt = vcnt; len = 0; while (cnt--) { if (*p) len += (*p++)->len; else { *p++ = sval; sval->ref_cnt++; len += sval->len; } } cp->type = C_REPL; cp->ptr = (PTR) new_STRING0(len); p = sblock; cnt = vcnt; target = string(cp)->str; while (cnt--) { memcpy(target, (*p)->str, (*p)->len); target += (*p)->len; free_STRING(*p); p++; } zfree(sblock, vcnt * sizeof(STRING *)); return cp; } #ifdef NO_LEAKS typedef struct _all_ptrs { struct _all_ptrs *next; PTR m; } ALL_PTRS; static ALL_PTRS *all_ptrs; /* * Some regular expressions are parsed, and the pointer stored in the byte-code * where we cannot distinguish it from other constants. Keep a list here, to * free on exit for auditing. */ void no_leaks_re_ptr(PTR m) { ALL_PTRS *p = calloc(1, sizeof(ALL_PTRS)); p->next = all_ptrs; p->m = m; all_ptrs = p; } void re_leaks(void) { while (all_ptrs != 0) { ALL_PTRS *next = all_ptrs->next; re_destroy(all_ptrs->m); free(all_ptrs); all_ptrs = next; } while (repl_list != 0) { REPL_NODE *p = repl_list->link; free_STRING(repl_list->sval); free_cell_data(repl_list->cp); ZFREE(repl_list); repl_list = p; } if (split_size != 0) { zfree(split_buff, split_size * sizeof(STRING *)); } } #endif mawk-1.3.4-20240123/kw.c0000644000000000000000000000337714457430744012662 0ustar rootroot/******************************************** kw.c copyright 2008-2021,2023, Thomas E. Dickey copyright 1991-1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: kw.c,v 1.10 2023/07/24 08:10:12 tom Exp $ */ /* kw.c */ #include #include #include #include /* *INDENT-OFF* */ static const struct kw { const char text[12]; short kw; } keywords[] = { { "BEGIN", BEGIN }, { "END", END }, { "break", BREAK }, { "continue", CONTINUE }, { "delete", DELETE }, { "do", DO }, { "else", ELSE }, { "exit", EXIT }, { "for", FOR }, { "function", FUNCTION }, { "getline", GETLINE }, { "gsub", GSUB }, { "if", IF }, { "in", IN }, { "length", LENGTH }, { "match", MATCH_FUNC }, { "next", NEXT }, { "nextfile", NEXTFILE }, { "print", PRINT }, { "printf", PRINTF }, { "return", RETURN }, { "split", SPLIT }, { "sub", SUB }, { "while", WHILE }, { "", 0 } }; /* *INDENT-ON* */ /* put keywords in the symbol table */ void kw_init(void) { register const struct kw *p = keywords; while (p->text[0]) { register SYMTAB *q; q = insert(p->text); q->type = ST_KEYWORD; q->stval.kw = p++->kw; } } /* find a keyword to emit an error message */ const char * find_kw_str(int kw_token) { const struct kw *p; for (p = keywords; p->text[0]; p++) if (p->kw == kw_token) return p->text; /* search failed */ return (char *) 0; } mawk-1.3.4-20240123/fin.c0000644000000000000000000003164114520267724013005 0ustar rootroot/******************************************** fin.c copyright 2008-2021,2023, Thomas E. Dickey copyright 1991-1995,1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: fin.c,v 1.52 2023/10/31 21:21:24 tom Exp $ */ /* fin.c */ #include "mawk.h" #include "fin.h" #include "memory.h" #include "bi_vars.h" #include "field.h" #include "symtype.h" #include "scan.h" #ifdef HAVE_FCNTL_H #include #endif /* This file handles input files. Opening, closing, buffering and (most important) splitting files into records, FINgets(). */ /* * An input buffer can grow much larger than the memory pool, and the number * of open files is fairly constrained. We allow for that in zmalloc(), by * bypassing the memory pool. */ #ifdef MSDOS #define JUMPSZ BUFFSZ #else #define JUMPSZ (BUFFSZ * 64) #endif static FIN *next_main(int); static char *enlarge_fin_buffer(FIN *); int is_cmdline_assign(char *); /* also used by init */ /* this is how we mark EOF on main_fin */ static char dead_buff = 0; static FIN dead_main = {0, (FILE *) 0, &dead_buff, &dead_buff, &dead_buff, 1, EOF_FLAG}; static void free_fin_data(FIN * fin) { if (fin != &dead_main) { zfree(fin->buff, fin->buff_size); ZFREE(fin); } } /* convert file-descriptor to FIN*. It's the main stream if main_flag is set */ FIN * FINdopen(int fd, int main_flag) { FIN *fin = ZMALLOC(FIN); fin->fd = fd; fin->flags = main_flag ? (MAIN_FLAG | START_FLAG) : START_FLAG; fin->buff_size = JUMPSZ; fin->buffp = fin->buff = (char *) zmalloc(fin->buff_size); fin->limit = fin->buffp; fin->buff[0] = 0; if ((isatty(fd) && rs_shadow.type == SEP_CHAR && rs_shadow.c == '\n') || interactive_flag) { /* interactive, i.e., line buffer this file */ if (fd == 0) { fin->fp = stdin; } else if (!(fin->fp = fdopen(fd, "r"))) { errmsg(errno, "fdopen failed"); free_fin_data(fin); mawk_exit(2); } } else { fin->fp = (FILE *) 0; } return fin; } /* open a FIN* by filename. It's the main stream if main_flag is set. Recognizes "-" as stdin. */ FIN * FINopen(char *filename, int main_flag) { FIN *result = 0; int fd; int oflag = O_RDONLY; #if USE_BINMODE int bm = binmode() & 1; if (bm) oflag |= O_BINARY; #endif TRACE(("FINopen(%s)\n", filename)); if ((filename[0] == '-' && filename[1] == 0) || (filename[0] == '/' && !strcmp(filename, "/dev/stdin"))) { #if USE_BINMODE if (bm) setmode(0, O_BINARY); #endif result = FINdopen(0, main_flag); } else if ((fd = open(filename, oflag, 0)) != -1) { result = FINdopen(fd, main_flag); } return result; } /* frees the buffer and fd, but leaves FIN structure until the user calls close() */ void FINsemi_close(FIN * fin) { static char dead = 0; if (fin->buff != &dead) { zfree(fin->buff, fin->buff_size); if (fin->fd) { if (fin->fp) fclose(fin->fp); else close(fin->fd); } fin->flags |= EOF_FLAG; fin->limit = fin->buff = fin->buffp = &dead; /* marks it semi_closed */ } /* else was already semi_closed */ } /* user called close() on input file */ void FINclose(FIN * fin) { FINsemi_close(fin); ZFREE(fin); } /* return one input record as determined by RS, from input file (FIN) fin */ char * FINgets(FIN * fin, size_t *len_p) { char *p; char *q = 0; size_t match_len; size_t r; restart: if ((p = fin->buffp) >= fin->limit) { /* need a refill */ if (fin->flags & EOF_FLAG) { if (fin->flags & MAIN_FLAG) { fin = next_main(0); goto restart; } else { *len_p = 0; return (char *) 0; } } if (fin->fp) { int have_nl = 0; int got_any = 0; char *my_buff = fin->buff; do { /* line buffering */ if (!fgets(my_buff, BUFFSZ + 1, fin->fp)) { if (got_any) { /* no newline, but we have data -- okay */ break; } fin->flags |= EOF_FLAG; fin->buff[0] = 0; fin->buffp = fin->buff; fin->limit = fin->buffp; goto restart; /* might be main_fin */ } else { /* return this line */ /* * Using fgets, we cannot detect embedded nulls in the * input. Assume that a null is the one added by fgets * after reading data. If we have a newline, that is * better, since fgets has the complete line. */ p = my_buff; while (*p != '\n' && *p != 0) p++; if (*p == '\n') { have_nl = 1; *p = 0; } else { /* * Increase the buffer size to allow reading more data, * and point 'my_buff' to the beginning of the extra * space. Doing it this way assumes very-long lines * are rare. */ size_t my_size = (size_t) (p - fin->buff); enlarge_fin_buffer(fin); p = my_buff = my_size + fin->buff; got_any = 1; } } } while (!have_nl); /* * At this point, 'p' points to the terminating null for the * input line. Fill in the FIN structure details. */ *len_p = (size_t) (p - fin->buff); fin->buffp = p; fin->limit = fin->buffp + strlen(fin->buffp); return fin->buff; } else { /* block buffering */ r = fillbuff(fin->fd, fin->buff, fin->buff_size); if (r == 0) { fin->flags |= EOF_FLAG; fin->buffp = fin->buff; fin->limit = fin->buffp; goto restart; /* might be main */ } else if (r < fin->buff_size) { fin->flags |= EOF_FLAG; } fin->limit = fin->buff + r; p = fin->buffp = fin->buff; if (fin->flags & START_FLAG) { fin->flags &= ~START_FLAG; if (rs_shadow.type == SEP_MLR) { /* trim blank lines from front of file */ while (*p == '\n') p++; fin->buffp = p; if (p >= fin->limit) goto restart; } } } } retry: switch (rs_shadow.type) { case SEP_CHAR: q = memchr(p, rs_shadow.c, (size_t) (fin->limit - p)); match_len = 1; break; case SEP_STR: q = str_str(p, (size_t) (fin->limit - p), ((STRING *) rs_shadow.ptr)->str, match_len = ((STRING *) rs_shadow.ptr)->len); break; case SEP_MLR: case SEP_RE: q = re_pos_match(p, (size_t) (fin->limit - p), rs_shadow.ptr, &match_len, (p != fin->buff) || (fin->flags & FIN_FLAG)); /* if the match is at the end, there might still be more to match in the file */ if (q && q[match_len] == 0 && !(fin->flags & EOF_FLAG)) { TRACE(("re_pos_match cancelled\n")); q = (char *) 0; } break; default: bozo("type of rs_shadow"); } if (q) { /* the easy and normal case */ *q = 0; *len_p = (unsigned) (q - p); fin->buffp = q + match_len; return p; } if (fin->flags & EOF_FLAG) { /* last line without a record terminator */ *len_p = r = (unsigned) (fin->limit - p); fin->buffp = p + r; if (rs_shadow.type == SEP_MLR && fin->buffp[-1] == '\n' && r != 0) { (*len_p)--; *--fin->buffp = 0; fin->limit--; } return p; } if (p == fin->buff) { /* current record is too big for the input buffer, grow buffer */ p = enlarge_fin_buffer(fin); } else { /* move a partial line to front of buffer and try again */ size_t rr; size_t amount = (size_t) (fin->limit - p); fin->flags |= FIN_FLAG; r = amount; if (fin->buff_size < r) { fin->flags |= EOF_FLAG; return 0; } p = (char *) memmove(fin->buff, p, r); q = p + r; rr = fin->buff_size - r; if ((r = fillbuff(fin->fd, q, rr)) < rr) { fin->flags |= EOF_FLAG; fin->limit = fin->buff + amount + r; } } goto retry; } static char * enlarge_fin_buffer(FIN * fin) { size_t r; size_t oldsize = fin->buff_size; size_t newsize = ((oldsize < JUMPSZ) ? (oldsize * 2) : (oldsize + JUMPSZ)); size_t limit = (size_t) (fin->limit - fin->buff); size_t extra = (newsize - oldsize); #ifdef MSDOS /* I'm not sure this can really happen: avoid "16bit wrap" */ if (fin->buff_size >= MAX_BUFFS) { errmsg(0, "out of input buffer space"); mawk_exit(2); } #endif fin->buff_size = newsize; fin->buffp = fin->buff = (char *) zrealloc(fin->buff, oldsize, newsize); r = fillbuff(fin->fd, fin->buff + oldsize, extra); if (r < extra) fin->flags |= EOF_FLAG; fin->limit = fin->buff + limit + r; return fin->buff; } /* fill the target with at most the number of bytes requested */ size_t fillbuff(int fd, char *target, size_t size) { register int r; size_t entry_size = size; while (size) switch (r = (int) read(fd, target, size)) { case -1: errmsg(errno, "read error"); mawk_exit(2); case 0: goto out; default: target += r; size -= (unsigned) r; break; } out: return (size_t) (entry_size - size); } /* main_fin is a handle to the main input stream == 0 never been opened */ FIN *main_fin; ARRAY Argv; /* to the user this is ARGV */ static double argi = 1.0; /* index of next ARGV[argi] to try to open */ static void set_main_to_stdin(void) { cell_destroy(FILENAME); FILENAME->type = C_STRING; FILENAME->ptr = (PTR) new_STRING("-"); cell_destroy(FNR); FNR->type = C_DOUBLE; FNR->dval = 0.0; rt_fnr = 0; main_fin = FINdopen(0, 1); } /* this gets called once to get the input stream going. It is called after the execution of the BEGIN block unless there is a getline inside BEGIN {} */ void open_main(void) { CELL argc; #if USE_BINMODE int k = binmode(); if (k & 1) setmode(0, O_BINARY); if (k & 2) { setmode(1, O_BINARY); setmode(2, O_BINARY); } #endif cellcpy(&argc, ARGC); if (argc.type != C_DOUBLE) cast1_to_d(&argc); if (argc.dval == 1.0) set_main_to_stdin(); else next_main(1); } /* get the next command line file open */ static FIN * next_main(int open_flag) /* called by open_main() if on */ { CELL argc; /* copy of ARGC */ CELL c_argi; /* cell copy of argi */ CELL argval; /* copy of ARGV[c_argi] */ int failed = 1; argval.type = C_NOINIT; c_argi.type = C_DOUBLE; if (main_fin) { FINclose(main_fin); main_fin = 0; } /* FILENAME and FNR don't change unless we really open a new file */ /* make a copy of ARGC to avoid side effect */ if (cellcpy(&argc, ARGC)->type != C_DOUBLE) cast1_to_d(&argc); while (argi < argc.dval) { register CELL *cp; c_argi.dval = argi; argi += 1.0; if (!(cp = array_find(Argv, &c_argi, NO_CREATE))) continue; /* its deleted */ /* make a copy so we can cast w/o side effect */ cell_destroy(&argval); cp = cellcpy(&argval, cp); if (cp->type < C_STRING) cast1_to_s(cp); if (string(cp)->len == 0) { /* file argument is "" */ cell_destroy(cp); continue; } /* it might be a command line assignment */ if (is_cmdline_assign(string(cp)->str)) { continue; } /* try to open it -- we used to continue on failure, but posix says we should quit */ if (!(main_fin = FINopen(string(cp)->str, 1))) { errmsg(errno, "cannot open \"%s\"", string(cp)->str); mawk_exit(2); } /* success -- set FILENAME and FNR */ cell_destroy(FILENAME); cellcpy(FILENAME, cp); cell_destroy(cp); cell_destroy(FNR); FNR->type = C_DOUBLE; FNR->dval = 0.0; rt_fnr = 0; failed = 0; break; } if (failed) { cell_destroy(&argval); if (open_flag) { /* all arguments were null or assignment */ set_main_to_stdin(); } else { main_fin = &dead_main; /* since MAIN_FLAG is not set, FINgets won't call next_main() */ } } return main_fin; } int is_cmdline_assign(char *s) { register char *p; int c; SYMTAB *stp; CELL *cp = 0; size_t len; CELL cell; /* used if command line assign to pseudo field */ CELL *fp = (CELL *) 0; /* ditto */ size_t length; if (scan_code[*(unsigned char *) s] != SC_IDCHAR) return 0; p = s + 1; while ((c = scan_code[*(unsigned char *) p]) == SC_IDCHAR || c == SC_DIGIT) p++; if (*p != '=') return 0; *p = 0; stp = find(s); switch (stp->type) { case ST_NONE: stp->type = ST_VAR; stp->stval.cp = cp = ZMALLOC(CELL); break; case ST_VAR: case ST_NR: /* !! no one will do this */ cp = stp->stval.cp; cell_destroy(cp); break; case ST_FIELD: /* must be pseudo field */ fp = stp->stval.cp; cp = &cell; break; default: rt_error( "cannot command line assign to %s\n\ttype clash or keyword" ,s); } /* we need to keep ARGV[i] intact */ *p++ = '='; len = strlen(p) + 1; /* posix says escape sequences are on from command line */ p = rm_escape(strcpy((char *) zmalloc(len), p), &length); cp->ptr = (PTR) new_STRING1(p, length); zfree(p, len); check_strnum(cp); /* sets cp->type */ if (fp) /* move it from cell to pfield[] */ { field_assign(fp, cp); free_STRING(string(cp)); } return 1; } #ifdef NO_LEAKS void fin_leaks(void) { TRACE(("fin_leaks\n")); if (main_fin) { free_fin_data(main_fin); main_fin = 0; } } #endif mawk-1.3.4-20240123/array.h0000644000000000000000000000267413711225346013353 0ustar rootroot/* array.h */ /* $MawkId: array.h,v 1.21 2020/08/01 08:42:14 tom Exp $ copyright 2009-2019,2020 Thomas E. Dickey copyright 1991-1996,2014 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. array.c and array.h were originally generated with the commands notangle -R'"array.c"' array.w > array.c notangle -R'"array.h"' array.w > array.h Notangle is part of Norman Ramsey's noweb literate programming package available from CTAN(ftp.shsu.edu). */ #ifndef ARRAY_H #define ARRAY_H 1 #include "nstd.h" #include "types.h" typedef struct array { PTR ptr; /* What this points to depends on the type */ size_t size; /* number of elts in the table */ size_t limit; /* Meaning depends on type */ unsigned hmask; /* bitwise and with hash value to get table index */ short type; /* values in AY_NULL .. AY_SPLIT */ } *ARRAY; #define AY_NULL 0 #define AY_INT 1 #define AY_STR 2 #define AY_SPLIT 4 #define NO_CREATE 0 #define CREATE 1 #define new_ARRAY() ((ARRAY)memset(ZMALLOC(struct array),0,sizeof(struct array))) CELL *array_find(ARRAY, CELL *, int); void array_delete(ARRAY, CELL *); void array_load(ARRAY, size_t); void array_clear(ARRAY); STRING **array_loop_vector(ARRAY, size_t *); CELL *array_cat(CELL *, int); #endif /* ARRAY_H */ mawk-1.3.4-20240123/nstd.h0000644000000000000000000000220114457053677013205 0ustar rootroot/******************************************** nstd.h copyright 2009-2017,2023 Thomas E. Dickey copyright 1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* Never Standard.h This has all the prototypes that are supposed to be in a standard place but never are, and when they are the standard place isn't standard */ /* * $MawkId: nstd.h,v 1.12 2023/07/22 22:27:11 tom Exp $ */ #ifndef NSTD_H #define NSTD_H 1 #include /* types */ typedef void *PTR; #ifdef SIZE_T_STDDEF_H #include #else #ifdef SIZE_T_TYPES_H #include #else typedef unsigned size_t; #endif #endif #include #include #include #include /* if have to diddle with errno to get errors from the math library */ #ifndef STDC_MATHERR #if (defined(FPE_TRAPS_ON) && !defined(HAVE_MATHERR)) #define STDC_MATHERR 1 #else #define STDC_MATHERR 0 #endif #endif #endif /* NSTD_H */ mawk-1.3.4-20240123/examples/0000755000000000000000000000000014520303251013660 5ustar rootrootmawk-1.3.4-20240123/examples/eatc.awk0000755000000000000000000000117313731370273015320 0ustar rootroot#!/usr/bin/mawk -f # $MawkId: eatc.awk,v 1.3 2020/09/19 11:51:23 tom Exp $ # eatc.awk # another program to remove comments { while( ( t = index($0 , "/*") ) > 0 ) { if ( t > 1 ) printf "%s" , substr($0,1,t-1) $0 = eat_comment( ( t + 2 <= length($0) ) ? substr($0, t+2) : "" ) } print } function eat_comment(s, t2) { #replace comment by one space printf " " while ( (t2 = index(s, "*/")) == 0 ) if ( getline s == 0 ) { # input error -- unterminated comment system("/bin/sh -c 'echo unterminated comment' 1>&2") exit 1 } return ( t2 + 2 <= length(s) ) ? substr(s,t2+2) : "" } mawk-1.3.4-20240123/examples/qsort.awk0000755000000000000000000000215513731411675015557 0ustar rootroot#!/usr/bin/mawk -f # $MawkId: qsort.awk,v 1.4 2020/09/19 14:20:45 tom Exp $ # qsort text files function middle(x,y,z) #return middle of 3 { if ( x <= y ) { if ( z >= y ) return y if ( z < x ) return x return z } if ( z >= x ) return x if ( z < y ) return y return z } function isort(A , n, i, j, hold) { # if needed a sentinel at A[0] will be created for( i = 2 ; i <= n ; i++) { hold = A[ j = i ] while ( A[j-1] > hold ) { j-- ; A[j+1] = A[j] } A[j] = hold } } # recursive quicksort function qsort(A, left, right ,i , j, pivot, hold) { pivot = middle(A[left], A[int((left+right)/2)], A[right]) i = left j = right while ( i <= j ) { while ( A[i] < pivot ) i++ while ( A[j] > pivot ) j-- if ( i <= j ) { hold = A[i] A[i++] = A[j] A[j--] = hold } } if ( j - left > BLOCK ) qsort(A,left,j) if ( right - i > BLOCK ) qsort(A,i,right) } BEGIN { BLOCK = 5 } { line[NR] = $0 "" # sort as string } END { if ( NR > BLOCK ) qsort(line, 1, NR) isort(line, NR) for(ie = 1 ; ie <= NR ; ie++) print line[ie] } mawk-1.3.4-20240123/examples/gdecl.awk0000755000000000000000000000561113731407751015465 0ustar rootroot#!/usr/bin/mawk -f # $MawkId: gdecl.awk,v 1.6 2020/09/19 14:04:25 tom Exp $ # parse a C declaration by recursive descent # # decl.awk with extra escapes \ ################################################ ############################################ # lexical scanner -- gobble() # input : string s -- treated as a regular expression # gobble eats SPACE, then eats longest match of s off front # of global variable line. # Cuts the matched part off of line function gobble(s, xg) { sub( /^ /, "", line) # eat SPACE if any # surround s with parenthesis to make sure ^ acts on the # whole thing if ( match(line, "^" "(" s ")") > 0 ) { xg = substr(line, 1, RLENGTH) line = (RLENGTH < length(line)) ? substr(line, RLENGTH+1) : "" return xg } else { return "" } } function ptr_to(n, xp) # print "pointer to" , n times { n = int(n) if ( n <= 0 ) return "" xp = "pointer to" ; n-- while ( n-- ) xp = xp " pointer to" return xp } #recursively get a decl # returns an english description of the declaration or # "" if not a C declaration. function decl( xd, t, ptr_part) { xd = gobble("[* ]+") # get list of *** ... gsub(/ /, "", xd) # remove all SPACES ptr_part = ptr_to( length(xd) ) # We expect to see either an identifier or '(' if ( gobble("\\(") ) { # this is the recursive descent part # we expect to match a declaration and closing ')' # If not return "" to indicate failure if ( (xd = decl()) == "" || gobble( "\\)" ) == "" ) return "" } else # expecting an identifier { if ( (xd = gobble(id)) == "" ) return "" xd = xd ":" } # finally look for () # or [ opt_size ] while ( 1 ) if ( gobble( funct_mark ) ) xd = xd " function returning" else if ( ( t = gobble( array_mark ) ) != "" ) { gsub(/ /, "", t) xd = xd " array" t " of" } else break xd = xd " " ptr_part return xd } BEGIN { id = "[_A-Za-z][_A-Za-z0-9]*" funct_mark = "\\([ \t]*\\)" array_mark = "\\[[ \t]*[_A-Za-z0-9]*[ \t]*\\]" # I've assumed types are keywords or all CAPS or end in _t # Other conventions could be added. type0 = "int|char|short|long|double|float|void" type1 = "[_A-Z][_A-Z0-9]*" # types are CAPS type2 = "[_A-Za-z][_A-Za-z0-9]*_t" # end in _t types = "(" type0 "|" type1 "|" type2 ")" } { gsub( /\/\*([^*]|\*[^\/])*(\*\/|$)/ , " ") # remove comments gsub( /[ \t]+/, " ") # squeeze white space to a single space line = $0 scope = gobble( "extern|static" ) if ( ( type = gobble("(struct|union|enum) ") ) != "" ) { type = type gobble(id) # get the tag } else { type = gobble("(un)?signed ") gobble( types ) } if ( ! type ) next if ( ( (x = decl()) != "" ) && gobble( ";") ) { x = x " " type if ( scope ) x = x " (" scope ")" gsub( / +/, " ", x) # print x } } mawk-1.3.4-20240123/examples/ct_length.awk0000755000000000000000000000073013731415146016350 0ustar rootroot#!/usr/bin/mawk -f # $MawkId: ct_length.awk,v 1.3 2020/09/19 14:49:10 tom Exp $ # ct_length.awk # # replaces all length # by length($0) { while ( ( i = index($0, "length") ) > 0 ) { printf "%s" , substr($0,1, i+5) # ...length $0 = substr($0,i+6) if ( match($0, /^[ \t]*\(/) ) { # its OK printf "%s", substr($0, 1, RLENGTH) $0 = substr($0, RLENGTH+1) } else # length alone printf "($0)" } print } mawk-1.3.4-20240123/examples/decl.awk0000755000000000000000000000630513731405667015323 0ustar rootroot#!/usr/bin/awk -f # $MawkId: decl.awk,v 1.12 2020/09/19 13:46:31 tom Exp $ # parse a C declaration by recursive descent # based on a C program in K&R ANSI edition # # run on a C file it finds the declarations # # restrictions: one declaration per line # doesn't understand struct {...} # makes assumptions about type names # # # some awks need double escapes on strings used as # regular expressions. If not run on mawk, use gdecl.awk ################################################ # lexical scanner -- gobble() # input : string s -- treated as a regular expression # gobble eats SPACE, then eats longest match of s off front # of global variable line. # Cuts the matched part off of line function gobble(s, xg) { if ( length(line) > 0 ) { sub( /^ /, "", line) # eat SPACE if any # surround s with parenthesis to make sure ^ acts on the # whole thing if ( match(line, "^" "(" s ")") > 0 ) { xg = substr(line, 1, RLENGTH) line = (RLENGTH < length(line)) ? substr(line, RLENGTH+1) : "" return xg } else { return ""; } } else { return ""; } } function ptr_to(n, xp) # print "pointer to" , n times { n = int(n) if ( n <= 0 ) return "" xp = "pointer to" ; n-- while ( n-- ) xp = xp " pointer to" return xp } #recursively get a decl # returns an english description of the declaration or # "" if not a C declaration. function decl( xd, t, ptr_part) { xd = gobble("[* ]+") # get list of *** ... gsub(/ /, "", xd) # remove all SPACES ptr_part = ptr_to( length(xd) ) # We expect to see either an identifier or '(' # if ( gobble("[(]") ) { # this is the recursive descent part # we expect to match a declaration and closing ')' # If not return "" to indicate failure if ( (xd = decl()) == "" || gobble( "[)]" ) == "" ) return "" } else # expecting an identifier { if ( (xd = gobble(id)) == "" ) return "" xd = xd ":" } # finally look for () # or [ opt_size ] while ( 1 ) if ( gobble( funct_mark ) ) xd = xd " function returning" else if ( ( t = gobble( array_mark ) ) != "" ) { gsub(/ /, "", t) xd = xd " array" t " of" } else break xd = xd " " ptr_part return xd } BEGIN { id = "[_A-Za-z][_A-Za-z0-9]*" funct_mark = "[(][ \t]*[)]" array_mark = "[[ \t]*[_A-Za-z0-9]*[ \t]*]" # I've assumed types are keywords or all CAPS or end in _t # Other conventions could be added. type0 = "int|char|short|long|double|float|void" type1 = "[_A-Z][_A-Z0-9]*" # types are CAPS type2 = "[_A-Za-z][_A-Za-z0-9]*_t" # end in _t types = "(" type0 "|" type1 "|" type2 ")" } { gsub( "/[*]([^*]|[*][^/])*([*]/|$)" , " ") # remove comments gsub( /[ \t]+/, " ") # squeeze white space to a single space line = $0 scope = gobble( "extern|static" ) if ( ( type = gobble("(struct|union|enum) ") ) != "" ) type = type gobble(id) # get the tag else { type = gobble("(un)?signed ") gobble( types ) } if ( ! type ) next if ( (x = decl()) != "" && gobble( ";") ) { x = x " " type if ( scope ) x = x " (" scope ")" gsub( / +/, " ", x) # print x } } mawk-1.3.4-20240123/examples/hical0000755000000000000000000000562011243366022014675 0ustar rootroot#!/bin/sh # $MawkId: hical,v 1.4 2009/08/21 00:36:34 tom Exp $ # @(#) hical - displays previous, current & next months - today highlighted # @(#) an "internationalizationable" version of a 3-month 'cal' display, it # @(#) may be edited for week to start with Sun or Mon & for local language prog=${TMPDIR-/tmp}/hical.$$ ; trap 'rm -f $prog ; trap 0 ; exit' 0 1 2 3 15 : ${so:=`tput smso`} ${se:=`tput rmso`} # USER EDITS MAY BE REQUIRED for the arguments to the 'date' command # the script presumes 'date' recognizes these arguments in these ways: # w - Day of the week - Sunday = 0 # m - Month of year - 01 to 12 # d - Day of month - 01 to 31 # T - Time as HH:MM:SS # Y - Year (including century), as decimal numbers DATE_ARGS='%w %m %d %T %Y' # the 'awk' program file is written to a temporary file to avoid any # "arg list too long" error messages, yet have all the code in one file. cat >$prog <<'EOF' { # USER EDITS MAY BE REQUIRED (for FMT, day & month names, and the time stuff) # FMT = 0 # for weekdays ordered "Mo Tu We Th Fr Sa Su" FMT = 1 # for weekdays ordered "Su Mo Tu We Th Fr Sa" Header[0] = "Mo Tu We Th Fr Sa Su" Header[1] = "Su Mo Tu We Th Fr Sa" months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" time_is = "The time is:" ; time_fmt = "%s %s %s %s\n" # NO MORE USER EDITS REQUIRED (I think!) split(months,M_Name) ; split("31 28 31 30 31 30 31 31 30 31 30 31",M_Len) daynum = $1 + FMT Mon[2] = $2 + 0 today = $3 + 0 time = $4 Year[1] = Year[2] = Year[3] = $NF if ( Mon[2] == 1 ) { Year[1] = Year[1] - 1 ; Mon[1] = 12 } else { Mon[1] = Mon[2] - 1 } if ( Mon[2] == 12 ) { Year[3] = Year[3] + 1 ; Mon[3] = 1 } else { Mon[3] = Mon[2] + 1 } if ( Year[2] % 4 == 0 && Year[2] % 100 != 0 || Year[2] % 400 == 0 ) M_Len[2] = 29 Start[2] = 7 - ( ( today - daynum ) % 7 ) Start[1] = 7 - ( ( M_Len[Mon[1]] - Start[2] ) % 7 ) Start[3] = ( M_Len[Mon[2]] + Start[2] ) % 7 for (i=1;i<=3;i++) { while ( Start[i] >= 7 ) Start[i] -= 7 } for (mm=1;mm<=3;mm++) { if ( Year[mm] != Year[mm-1] ) printf( "%s %s %s\n", so, Year[mm], se ) if ( mm == 1 ) printf( "%s %s %s\n", so, Header[FMT], se ) j = k = 1 while ( j <= M_Len[Mon[mm]] ) { line = "" for (i=1;i<=7;i++) { if ( Start[mm] > 0 || j > M_Len[Mon[mm]] ) { date = "" ; Start[mm]-- } else date = j++ if ( mm == 2 && date == today ) { So = so ; Se = se } else { So = Se = "" } line = sprintf( "%s%s%2s%s ", line, So, date, Se ) } m1 = substr(M_Name[Mon[mm]],k++,1) printf( "%s %1s %s %s%s %s\n", so, m1, se, line, so, se ) } } printf( time_fmt, so, time_is, time, se ) } EOF date +"$DATE_ARGS" | ${AWK:=mawk} -f $prog so=$so se=$se exit 0 # EOF 'hical' - Tue Dec 19 19:19:19 EST 1994 # Bob Stockler - bob@trebor.iglou.com - CIS: 72726,452 mawk-1.3.4-20240123/examples/primes.awk0000755000000000000000000000204211061561047015672 0ustar rootroot#!/usr/bin/mawk -f # primes.awk # # mawk -f primes.awk [START] STOP # find all primes between 2 and STOP # or START and STOP # function usage() { ustr = sprintf("usage: %s [start] stop", ARGV[0]) system( "echo " ustr) exit 1 } BEGIN { if (ARGC == 1 || ARGC > 3 ) usage() if ( ARGC == 2 ) { start = 2 ; stop = ARGV[1]+0 } else if ( ARGC == 3 ) { start = ARGV[1]+0 ; stop = ARGV[2]+0 } if ( start < 2 ) start = 2 if ( stop < start ) stop = start prime[ p_cnt = 1 ] = 3 # keep primes in prime[] # keep track of integer part of square root by adding # odd integers odd = test = 5 root = 2 squares = 9 while ( test <= stop ) { if ( test >= squares ) { root++ odd += 2 squares += odd } flag = 1 for ( i = 1 ; prime[i] <= root ; i++ ) if ( test % prime[i] == 0 ) # not prime { flag = 0 ; break } if ( flag ) prime[ ++p_cnt ] = test test += 2 } prime[0] = 2 for( i = 0 ; prime[i] < start ; i++) ; for ( ; i <= p_cnt ; i++ ) print prime[i] } mawk-1.3.4-20240123/examples/nocomment.awk0000755000000000000000000000121613731400526016374 0ustar rootroot#!/usr/bin/mawk -f # $MawkId: nocomment.awk,v 1.3 2020/09/19 13:02:14 tom Exp $ # remove C comments from a list of files # using a comment as the record separator # # this is trickier than I first thought # The first version in .97-.9993 was wrong BEGIN { # RS is set to a comment (this is mildly tricky, I blew it here RS = "/[*]([^*]|[*]+[^*/])*[*]+/" ORS = " " getline hold filename = FILENAME } # if changing files filename != FILENAME { filename = FILENAME printf "%s" , hold hold = $0 next } { # hold one record because we don't want ORS on the last # record in each file print hold hold = $0 } END { printf "%s", hold } mawk-1.3.4-20240123/examples/deps.awk0000755000000000000000000000350414520303251015324 0ustar rootroot#!/usr/bin/mawk -f # $MawkId: deps.awk,v 1.4 2023/10/31 22:58:49 tom Exp $ # vile: notab ts=4 sw=4 # find include dependencies in C source # # mawk -f deps.awk C_source_files # -- prints a dependency list suitable for make BEGIN { stack_index = 0 # stack[] holds the input files for(i = 1 ; i < ARGC ; i++) { file = ARGV[i] if ( file !~ /\.[cC]$/ ) continue # skip it outfile = substr(file, 1, length(file)-2) ".o" # INCLUDED[] stores the set of included files # -- start with the empty set for( j in INCLUDED ) delete INCLUDED[j] while ( 1 ) { if ( getline line < file <= 0 ) # no open or EOF { if ( stack_index == 0 ) break # empty stack else { file = stack[ stack_index-- ] continue } } if ( line ~ /^#include[ \t]+".*"/ ) split(line, X, "\"") # filename is in X[2] else if ( line ~ /^#include[ \t]+<.*>/ ) split(line, X, "[<>]") # filename is in X[2] else continue; if ( X[2] in INCLUDED ) # we've already included it continue if ( getline line < X[2] <= 0 ) # no open or EOF continue; #push current file stack[ ++stack_index ] = file INCLUDED[ file = X[2] ] = "" } # end of while # test if INCLUDED is empty flag = 0 # on once the front is printed for( j in INCLUDED ) { if ( ! flag ) { printf "%s : %s" , outfile, j ; flag = 1 } else printf " %s" , j close(j); } if ( flag ) print "" }# end of loop over files in ARGV[i] } mawk-1.3.4-20240123/examples/hcal0000755000000000000000000003374213733214037014536 0ustar rootroot#!/usr/bin/mawk -We # $MawkId: hcal,v 1.6 2020/09/24 22:05:19 tom Exp $ # vile:ts=4 sw=4 # edit the above to be the full pathname of 'mawk' # @(#) hcal - v01.00.02 - Tue Feb 27 21:21:21 EST 1996 # @(#) prints a 3-month (highlighted) calendar centered on the target month # @(#) may be edited for week to start with Sun or Mon & for local language # @(#) to display a usage screen, execute: hcal -h # NOTE: to edit, set ts=4 in 'vi' (or equivalent) # to print, pipe through 'pr -t -e4' # Using ideas from a KornShell script by Mikhail Kuperblum (mikhail@klm.com) # Bob Stockler - bob@trebor.iglou.com - Sysop CompuServe SCOForum [75162,1612] BEGIN { # Local Edits: PROG = "hcal" # Program name given to this script # FMT = 0 # date format dd/mm/yyyy # FMT1 = 0 # for weekdays ordered "Mo Tu We Th Fr Sa Su" FMT = 1 # date format mm/dd/yyyy FMT1 = 1 # for weekdays ordered "Su Mo Tu We Th Fr Sa" # edit day & month names and abbreviations for local language names Days[0] = "Mo Tu We Th Fr Sa Su" Days[1] = "Su Mo Tu We Th Fr Sa" MONTHS = "January February March April May June July August" MONTHS = MONTHS " September October November December" Months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" # STDOUT = 0 # emulate SCO Unix 'cal' (NO highlighting) STDOUT = 1 # default to highlight mode MINUS = "-" # possible input date field delimiter SLASH = "/" # possible input date field delimiter DOT = "." # possible input date field delimiter IDFD = "[" MINUS # make MINUS the first character in this series IDFD = IDFD SLASH # so that it stands for itself in the RE IDFD = IDFD DOT "]" # Input Date Field Delimiters RE ODFD = SLASH # Output Date Field Delimiter (default) DATE_FMT = "%.2d%s%.2d%s%.4d" # date format ## this script presumes 'date' recognizes these arguments in these ways: ## w - Day of the week - Sunday = 0 ## m - Month of year - 01 to 12 ## d - Day of month - 01 to 31 ## y Last 2 digits of year - 00 to 99 ## Y - Year (including century), as decimal numbers ## j - Day of the year - 001 to 366 (Julian date) ## T - Time as HH:MM:SS ## X Current time, as defined by the locale ## a - Abbreviated weekday - Sun to Sat ## b - Abbreviated month name ## Z - Timezone name, or no characters if no timezone exists ## Command to get today's date information: ## DATE = "/bin/date '+%w %m %d 19%y %j~%a %b %d %T %Z 19%y'" ## For sunos4 ## DATE = DATE = "/bin/date '+%w %m %d 19%y %j~%a %h %d %T 19%y'" DATE = "/bin/date '+%w %m %d %Y %j~%a %b %d %X %Z %Y'" # End of Local Edits INT_RE = "^[0-9]+$" # unsigned integer RE S_INT_RE = "^[-+][0-9]+$" # signed integer RE MNAM_RE = "^[A-Za-z]+$" # month name RE YEAR_RE = "^[0-9]?[0-9]?[0-9]?[0-9]$" DATE_RE = "^[0-9]?[0-9]" IDFD "[0-9]?[0-9]" IDFD "[0-9]?[0-9]?[0-9]?[0-9]$" DAT1_RE = "^[0-9]?[0-9]" IDFD "[0-9]?[0-9]$" split(Months,M_Name) split("31 28 31 30 31 30 31 31 30 31 30 31",Mdays) ; Mdays[0] = 0 ERR = 0 HELP = 0 RMSO = 0 NUM_ARGS = ARGC - 1 if ( ARGV[1] == "-x" ) { # standout mode switch if ( STDOUT == 1 ) STDOUT = 0 ; else STDOUT = 1 ARG1 = ARGV[2] ; ARG2 = ARGV[3] ; NUM_ARGS -= 1 } else if ( ARGV[1] ~ /^-[h?]$/ ) { HELP = 1 ; exit } else { ARG1 = ARGV[1] ; ARG2 = ARGV[2] } if ( STDOUT == 1 ) { # get the terminal standout-start & standout-end control codes so = ENVIRON["so"] ; if ( ! so ) "tput smso" | getline so se = ENVIRON["se"] ; if ( ! se ) "tput rmso" | getline se } if ( NUM_ARGS == 0 ) { # no arguments - print a calendar display centered on today DEFAULT = 1 } else if ( NUM_ARGS == 1 ) { # one argument - may be a month name, date, year, or interval of days if ( ARG1 ~ DATE_RE ) DATE1 = Fmt_Date(ARG1) else if ( ARG1 ~ DAT1_RE ) DATE1 = ARG1 else if ( ARG1 ~ MNAM_RE ) { Get_Mnum() ; DATE1 = RMSO = ARG1 "/1" } else if ( ARG1 ~ S_INT_RE ) INTERVAL = ARG1 + 0 else if ( ARG1 ~ INT_RE ) { if ( ARG1 > 0 && ARG1 <= 9999 ) YEAR = ARG1 + 0 else if ( ARG1 > 9999 ) { ERR = 9 ; exit } else { ERR = 7 ; exit } } else { ERR = 1 ; exit } } else if ( NUM_ARGS == 2 ) { # two arguments, the second of which must be an integer if ( ARG2 ~ INT_RE ) { ARG2 = ARG2 + 0 if ( ARG2 < 1 ) { ERR = 7 ; exit } else if ( ARG2 > 9999 ) { ERR = 9 ; exit } } else { ERR = 1 ; exit } RMSO = 1 # the first may be a string or an integer if ( ARG1 ~ INT_RE ) { # a month number and a year if ( ARG1 < 1 || ARG1 > 12 ) { ERR = 4 ; mm = ARG1 ; exit } } else if ( ARG1 ~ MNAM_RE ) { Get_Mnum() } else { ERR = 6 ; exit } DATE1 = ARG1 "/1/" ARG2 } else { ERR = 2 ; exit } if ( DEFAULT ) { Get_Now() } else if ( INTERVAL ) { Get_Now() daynum = daynum + ( INTERVAL % 7 ) this_date = "" DATE1 = Get_Date(INTERVAL,m,d,y,j) split(DATE1,mdy,IDFD) Mon[2] = mdy[1] + 0 today = mdy[2] + 0 Year[1] = Year[2] = Year[3] = mdy[3] + 0 } else if ( DATE1 ) { Get_Now() if ( split(DATE1,mdy,IDFD) == 2 ) DATE1 = DATE1 "/" This_Year Chk_Date(DATE1) Mon[2] = mdy[1] + 0 today = mdy[2] + 0 Year[1] = Year[2] = Year[3] = mdy[3] + 0 DATE1 = sprintf( "%.2d/%.2d/%.4d", Mon[2], today, Year[2] ) INTERVAL = Get_Num(DATE1,m,d,y,j) daynum = daynum + ( INTERVAL % 7 ) this_date = "" } else if ( YEAR ) { so = se = "" Get_Now() Mon[2] = 2 today = 1 Year[1] = Year[2] = Year[3] = YEAR DATE1 = sprintf( "%.2d/%.2d/%.4d", Mon[2], today, Year[2] ) INTERVAL = Get_Num(DATE1,m,d,y,j) daynum = daynum + ( INTERVAL % 7 ) this_date = "" } else { ERR = 5 ; exit } if ( Mon[2] != 1 ) Mon[1] = Mon[2] - 1 else { Mon[1] = 12 ; Year[1] -= 1 } if ( Mon[2] != 12 ) Mon[3] = Mon[2] + 1 else { Mon[3] = 1 ; Year[3] += 1 } if ( Mon[1] == 2 ) Leap(Year[1]) else if ( Mon[2] == 2 ) Leap(Year[2]) else if ( Mon[3] == 2 ) Leap(Year[3]) Start[2] = 7 - ( ( today - daynum ) % 7 ) Start[1] = 7 - ( ( Mdays[Mon[1]] - Start[2] ) % 7 ) Start[3] = ( Mdays[Mon[2]] + Start[2] ) % 7 if ( ! YEAR ) quarters = 1 else { quarters = 4 ; s[3] = Start[3] for (i=4;i<=12;i++) { s[i] = ( Mdays[i-1] + s[i-1] ) % 7 } } ll = 0 for ( quarter = 1 ; quarter <= quarters ; quarter++ ) { if ( quarter > 1 ) { delete cal ll = 0 ; Mon[1] += 3 ; Mon[2] += 3 ; Mon[3] += 3 Start[1] = s[Mon[1]] ; Start[2] = s[Mon[2]] ; Start[3] = s[Mon[3]] } if ( Year[2] == 1752 && Mon[2] ~ /8|9|10/ ) Kludge_1752() if ( ARG1 ) print "" ; else printf( "\n%s\n\n", this_date ) for (i=1;i<=3;i++) { while ( Start[i] >= 7 ) Start[i] -= 7 } for (mm=1;mm<=3;mm++) { l = 1 if ( mm != 2 ) { So = Se = "" } else { So = so ; Se = se } cal[mm SUBSEP l++] = sprintf( "%s %-4s%.4d %s ", \ So, M_Name[Mon[mm]], Year[mm], Se ) cal[mm SUBSEP l++] = sprintf( "%s%3s", Days[FMT1], "" ) j = k = 1 while ( j <= Mdays[Mon[mm]] ) { line = "" for (i=1;i<=7;i++) { if ( Start[mm] > 0 || j > Mdays[Mon[mm]] ) { date = "" ; Start[mm]-- } else date = j++ if ( Year[mm] == 1752 && Mon[mm] == 9 && date == 3 ) { date = 14 ; j = 15 } if ( date == today && mm == 2 && ! RMSO ) { So = so ; Se = se } else { So = Se = "" } line = sprintf( "%s%s%2s%s ", line, So, date, Se ) } cal[mm SUBSEP l++] = sprintf( "%s ", line ) } if ( l > ll ) ll = l } for (l=1;l"/dev/tty" print usage >"/dev/tty" exit ERR } function Get_Now() { # get the week, month, date & year numbers and the time-of-day DATE | getline date split(date,Date,"~") split(Date[1],field) daynum = field[1] + FMT1 m = field[2] ; This_Mon = Mon[2] = m + 0 d = field[3] ; This_Date = today = d + 0 y = This_Year = Year[1] = Year[2] = Year[3] = field[4] j = julian = field[5] + 0 this_date = Date[2] } function Fmt_Date(fmt_date) { # format dates as mm/dd/yyyy or dd/mm/yyyy split(fmt_date,MorD_DorM_Y,IDFD) if ( FMT == 1 ) { Dt_Fld1 = MorD_DorM_Y[1] ; Dt_Fld2 = MorD_DorM_Y[2] } else { Dt_Fld1 = MorD_DorM_Y[2] ; Dt_Fld2 = MorD_DorM_Y[1] } Dt_Fld3 = MorD_DorM_Y[3] return sprintf( DATE_FMT, Dt_Fld1, ODFD, Dt_Fld2, ODFD, Dt_Fld3 ) } function Kludge_1752() { # kludge for September 1752 & the change to the Gregorian Calendar Mdays[9] = 30 if ( Mon[2] == 9 ) { Start[1] = Start[2] = 1 + FMT1 ; Start[3] = -1 + FMT1 } else if ( Mon[2] == 8 ) { Start[1] = 2 + FMT1 ; Start[2] = 5 + FMT1 ; Start[3] = 1 + FMT1 } else if ( Mon[2] == 10 ) { Start[1] = 1 + FMT1 ; Start[2] = -1 + FMT1 ; Start[3] = 3 } } function Get_Mnum() { ARG1 = tolower(ARG1) months = tolower(MONTHS) split(months,month) for (i=1;i<=12;i++) { if ( index(month[i],ARG1) == 1 ) { ARG = i ; n++ } } if ( n == 1 ) ARG1 = ARG else if ( n == 0 ) { ERR = 1 ; exit } else { ERR = 8 ; exit } } function Get_Num(get_date,get_m,get_d,get_y,get_j) { # get the number of days from one date to another date NOW = get_y get_m get_d ; N = 0 ; M = get_m + 0 ; D = get_d + 0 ; Y = get_y + 0 ; J = get_j + 0 split(get_date,mdy,IDFD) M2 = mdy[1] ; D2 = mdy[2] ; Y2 = mdy[3] THEN = Y2 M2 D2 ; M2 = M2 + 0 ; D2 = D2 + 0 ; Y2 = Y2 + 0 Leap(Y2) if ( M2 > 12 ) { ERR = 4 ; exit } if ( D2 > Mdays[M2] && Y2 != 1752 && M2 != 9 ) { ERR = 5 ; exit } if ( THEN ~ /^1752090[3-9]$|^1752091[0-3]$/ ) { ERR = 6 ; exit } Leap(Y) if ( THEN > NOW ) { Ydays = Ydays - J + 1 ; mdays = Mdays[M] - D + 1 while ( Y < Y2 ) Next_Y() while ( M < M2 ) Next_M() while ( D < D2 ) Next_D() N *= -1 } else { Ydays = J ; mdays = D while ( Y > Y2 ) Prev_Y() while ( M > M2 ) Prev_M() if ( Y == 1752 && M == 9 && D == 19 ) D = 30 while ( D > D2 ) Prev_D() } return N } function Get_Date(get_n,get_m,get_d,get_y,get_j) { # get the date a number of days before or after a date N = get_n + 0 ; M = get_m + 0 ; D = get_d + 0 ; Y = get_y + 0 ; J = get_j + 0 if ( N != 0 ) { Leap(Y) if ( N > 0 ) { Ydays = Ydays - J + 1 ; mdays = Mdays[M] - D + 1 while ( N >= Ydays ) { Next_Y() ; Leap(Y) } while ( N >= ( ( mdays > 0 ) ? mdays : Mdays[M] ) ) { Next_M() } while ( N > 0 ) Next_D() } else { Ydays = J ; mdays = D ; N *= -1 while ( N >= Ydays ) { Prev_Y() ; Leap(Y) } while ( N >= ( ( mdays > 0 ) ? mdays : Mdays[M] ) ) { Prev_M() } if ( Y == 1752 && M == 9 && D == 19 ) D = 30 while ( N > 0 ) Prev_D() } if ( Y < 1 ) { ERR = 3 ; exit } } return M ODFD D ODFD Y } function Leap(YR) { # adjust for Leap Years if ( YR % 4 == 0 && ( YR % 100 != 0 || YR % 400 == 0 || YR < 1800 ) ) { Ydays = 366 ; Mdays[2] = 29 } else { Ydays = 365 ; Mdays[2] = 28 } if ( YR != 1752 ) Mdays[9] = 30 else { Ydays = 355 ; Mdays[9] = 19 } } function Chk_Date(chk_date) { # check validity of input dates split(chk_date,mdy,IDFD) mm = mdy[1] + 0 ; dd = mdy[2] + 0 ; yy = mdy[3] + 0 if ( mm == 2 ) Leap(yy) if ( yy < 1 ) { ERR = 3 ; exit } if ( mm < 1 || mm > 12 ) { ERR = 4 ; exit } if ( dd < 1 || dd > Mdays[mm] ) { ERR = 5 ; exit } } # day counting functions for next or previous year, month and day function Next_Y() { N -= Ydays ; Y += 1 ; M = 1 ; D = 1 ; mdays = 0 ; Leap(Y) } function Next_M() { if ( mdays != 0 ) N -= mdays ; else N -= Mdays[M] M += 1 ; D = 1 ; mdays = 0 } function Next_D() { N -= 1 ; D += 1 if ( D > Mdays[M] ) { M += 1 ; D = 1 } else if ( Y == 1752 && M == 9 && D == 2 ) D = 13 } function Prev_Y() { N -= Ydays ; Y -= 1 ; M = 12 ; D = 31 ; mdays = 0 ; Leap(Y) } function Prev_M() { if ( mdays != 0 ) N -= mdays ; else N -= Mdays[M] M -= 1 ; D = Mdays[M] ; mdays = 0 } function Prev_D() { N -= 1 ; D -= 1 ; if ( Y == 1752 && M == 9 && D == 13 ) D = 2 } function Get_J(get_m,get_d,get_y) { # get the Julian date for an input date get_m = get_m + 0 ; get_d = get_d + 0 ; get_y = get_y + 0 Leap(get_y) j = get_d for (i=1;i #include "scancode.h" #include "symtype.h" #include "parse.h" extern double double_zero; extern double double_one; extern void eat_nl(void); /* in error.c */ extern void unexpected_char(void); #endif /* MAWK_SCAN_H */ mawk-1.3.4-20240123/config_h.in0000644000000000000000000000404214373270264014163 0ustar rootroot/******************************************** config_h.in copyright 2009-2020,2023 Thomas E. Dickey vile:cmode This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: config_h.in,v 1.39 2023/02/15 23:54:28 tom Exp $ * template for config.h */ #undef DECL_ENVIRON #undef FPE_TRAPS_ON #undef GCC_NORETURN #undef GCC_PRINTF #undef GCC_PRINTFLIKE #undef GCC_SCANF #undef GCC_SCANFLIKE #undef GCC_UNUSED #undef HAVE_BSD_STDLIB_H #undef HAVE_ERRNO_H #undef HAVE_FCNTL_H #undef HAVE_FORK #undef HAVE_INT64_T #undef HAVE_INTTYPES_H #undef HAVE_ISNAN #undef HAVE_LIMITS_H #undef HAVE_LONG_LONG #undef HAVE_MATHERR #undef HAVE_MATH__LIB_VERSION #undef HAVE_MEMORY_H #undef HAVE_MKTIME #undef HAVE_PIPE #undef HAVE_REAL_PIPES #undef HAVE_REGEXPR_H_FUNCS #undef HAVE_REGEXP_H_FUNCS #undef HAVE_REGEX_H_FUNCS #undef HAVE_SIGACTION #undef HAVE_SIGACTION_SA_SIGACTION #undef HAVE_SIGINFO_H #undef HAVE_STDINT_H #undef HAVE_STDLIB_H #undef HAVE_STRFTIME #undef HAVE_STRINGS_H #undef HAVE_STRING_H #undef HAVE_STRTOD_OVF_BUG #undef HAVE_SYS_STAT_H #undef HAVE_SYS_TYPES_H #undef HAVE_SYS_WAIT_H #undef HAVE_TDESTROY #undef HAVE_TSEARCH #undef HAVE_UINT64_T #undef HAVE_UNISTD_H #undef HAVE_WAIT #undef LOCALE #undef LOCAL_REGEXP #undef MAWK_RAND_MAX #undef MAX__INT #undef MAX__LONG #undef MAX__UINT #undef MAX__ULONG #undef NAME_RANDOM #undef NOINFO_SIGFPE #undef NO_GAWK_OPTIONS #undef NO_INIT_SRAND #undef NO_INTERVAL_EXPR #undef NO_LEAKS #undef SIZEOF_INT64_T #undef SIZEOF_LONG #undef SIZEOF_LONG_LONG #undef SIZE_T_STDDEF_H #undef SIZE_T_TYPES_H #undef STDC_HEADERS #undef SYSTEM_NAME #undef TURN_OFF_FPE_TRAPS #undef TURN_ON_FPE_TRAPS #undef USE_IEEEFP_H #undef YY_NO_LEAKS #undef const #undef mawk_rand #undef mawk_srand #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #ifndef GCC_UNUSED #define GCC_UNUSED /* nothing */ #endif #ifndef OPT_TRACE #define OPT_TRACE 0 #endif mawk-1.3.4-20240123/msdos/0000755000000000000000000000000014460037064013200 5ustar rootrootmawk-1.3.4-20240123/msdos/vs2008.h0000644000000000000000000000204212405413374014310 0ustar rootroot/******************************************** vs2008.h copyright 2014, Thomas E. Dickey This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* Microsoft C++ Visual Studio 2008 */ /* * $MawkId: vs2008.h,v 1.1 2014/09/14 22:30:20 tom Exp $ */ #ifndef CONFIG_H #define CONFIG_H 1 #define HAVE_FCNTL_H 1 #define SIZE_T_STDDEF_H 1 #define MAX__INT 0x7fffffff #define MAX__LONG 0x7fffffff #define MAX__ULONG 0xffffffff #define HAVE_FAKE_PIPES 1 #if HAVE_REARGV #define SET_PROGNAME() reargv(&argc,&argv) ; progname = argv[0] #else #define SET_PROGNAME() progname = "mawk" #endif __declspec(noreturn) void bozo(const char *); __declspec(noreturn) void mawk_exit(int); __declspec(noreturn) void RE_panic(const char *); __declspec(noreturn) void rt_error(const char *,...); #include /* isatty() */ #endif /* CONFIG_H */ mawk-1.3.4-20240123/msdos/examples/0000755000000000000000000000000005415353355015022 5ustar rootrootmawk-1.3.4-20240123/msdos/examples/winobj.awk0000644000000000000000000000532105415353355017017 0ustar rootroot# Ben Myers <0003571400@mcimail.com> # Sum up sizes of Windows OBJ files in current directory # requires DOS 5.0 and Borland TDUMP # A clumsy script to count Windows OBJs and sum up the CODE sizes # run with # awk -fwinobj.awk work1 # where work1 is a work file # You must have at least one filename as an arg, else awk will want to read # from con:, hence the requirement for work1 BEGIN { # redirection done by shelled command ocount = 0 # obj module counter otsize = 0 # text size accumulator odsize = 0 # data size accumulator system("del workfile.$%$") # Will probably cause a File Not Found message # Generate a list of OBJs system("dir *.obj /b >" ARGV[1]) while (getline < ARGV[1] > 0) { # TDUMP selects only the SEGDEFs to speed things up a lot # and keeps on piping to the workfile system("tdump " $1 " -oiSEGDEF >>workfile.$%$") ocount++ } # Now read workfile back, processing lines that are module ids and SEGDEF info # Print one line for each SEGDEF processed j = 1 while (getline < "workfile.$%$" > 0) { # module name if($1 == "Display" && $2 == "of" && $3 == "File") { module_name = $4 } # SEGDEF CODE if($2 == "SEGDEF" && $9 =="'CODE'") { decval = hexdec($11) otsize += decval printf ("%12s CODE %4s %7i\n", module_name, $11, decval) j++ } # SEGDEF DATA if($2 == "SEGDEF" && $9 =="'DATA'") { decval = hexdec($11) odsize += decval printf ("%12s DATA %4s %7i\n", module_name, $11, decval) j++ } } # while } # end of BEGIN section # no main loop at all! END { # print summary and delete work files printf ("%i OBJ files\n", ocount) printf ("Total CODE size %04x %7li bytes\n", otsize, otsize) printf ("Total DATA size %04x %7li bytes\n", odsize, odsize) system("del "ARGV[1]) system("del workfile.$%$") } # end of END section # No scanf in awk, so convert hex string x to decimal the hard way function hexdec (x) { result = 0 for (i=1; i<=length(x); i++) { thechar = substr(x,i,1) # digits 0-9 and lower case hex produced by TDUMP # use brute force if (thechar == "0") {result = result*16} if (thechar == "1") {result = result*16 + 1} if (thechar == "2") {result = result*16 + 2} if (thechar == "3") {result = result*16 + 3} if (thechar == "4") {result = result*16 + 4} if (thechar == "5") {result = result*16 + 5} if (thechar == "6") {result = result*16 + 6} if (thechar == "7") {result = result*16 + 7} if (thechar == "8") {result = result*16 + 8} if (thechar == "9") {result = result*16 + 9} if (thechar == "a") {result = result*16 + 10} if (thechar == "b") {result = result*16 + 11} if (thechar == "c") {result = result*16 + 12} if (thechar == "d") {result = result*16 + 13} if (thechar == "e") {result = result*16 + 14} if (thechar == "f") {result = result*16 + 15} } # for (i=1;i list # mawk -f add_cr.awk @list # # read arguments for @file into ARGV[] function reset_argv(T, i, j, flag, file) #all args local { for( i = 1 ; i < ARGC ; i++ ) { T[i] = ARGV[i] if ( T[i] ~ /^@/ ) flag = 1 } if ( ! flag ) return # need to read from a @file into ARGV j = 1 for( i = 1 ; i < ARGC ; i++ ) { if ( T[i] !~ /^@/ ) ARGV[j++] = T[i] else { T[i] = substr(T[i],2) # read arguments from T[i] while ( (getline file < T[i]) > 0 ) ARGV[j++] = file } } ARGC = j } BEGIN { COPY = "copy" # unix: "cp" DEL = "del" # unix: "rm" tmpfile = ENVIRON["MAWKTMPDIR"] "MAWK.TMP" reset_argv() } FILENAME == "-" { # just write to stdout printf "%s\r\n" , $0 next } FILENAME != filename { if ( filename ) { close(tmpfile) syscmd = sprintf( "%s %s %s", COPY, tmpfile, filename ) system(syscmd) } filename = FILENAME } { printf "%s\r\n" , $0 > tmpfile } END { if ( filename ) { close(tmpfile) syscmd = sprintf( "%s %s %s", COPY, tmpfile, filename ) system(syscmd) system(DEL " " tmpfile) } } mawk-1.3.4-20240123/msdos/examples/texttest.awk0000644000000000000000000000045305415353355017414 0ustar rootroot# Ben Myers <0003571400@mcimail.com> /^#include/ { # got #include, see if it has at least one quote. We don't want #include <> z = gsub(/"/, "", $2) while ((z > 0) && (getline x <$2 > 0)) # while (getline x <$2 > 0) print x next } { print } mawk-1.3.4-20240123/msdos/examples/doslist.awk0000644000000000000000000000104105415353353017201 0ustar rootroot # print truncated DOS file names # from packing.list (packing.lis) # # mawk -f doslist.awk packing.lis # discard blanks and comments /^#/ || /^[ \t]*$/ {next} function dos_name(s, n, front, X) { #lowercase, split on extension and truncate pieces s = tolower(s) n = split(s, X, ".") front = substr(X[1],1,8) if ( n == 1 ) return front else return front "." substr(X[2], 1, 3) } { n = split($1, X, "/") new = dos_name(X[1]) for( i = 2 ; i <= n ; i++ ) new = new "\\" dos_name(X[i]) printf "%-30s%s\n", $1, new } mawk-1.3.4-20240123/msdos/examples/srcstat.awk0000644000000000000000000000132305415353354017207 0ustar rootroot# Ben Myers <0003571400@mcimail.com> # Sum up number, line count, and sizes of SOURCE files in current directory # run with # bmawk -fsrcsize.awk workfile # or similar command syntax with your awk program # where workfile is a work file BEGIN { # redirection done by shelled command # system("dir *.* >workfile") system("dir *.* >" ARGV[1]) ssize = 0 # size accumulator slines = 0 # line counter scount = 0 # obj counter } # Now read workfile back in $2 == "C" || $2 == "H" || $2 == "CPP" || $2 == "HPP" { filename = sprintf("%s.%s", $1, $2) ssize += $3 while (getline < filename > 0) {slines++} scount++ } END { print scount " files, " slines " lines, total size " ssize " bytes" system("del " ARGV[1]) } mawk-1.3.4-20240123/msdos/examples/shell.awk0000644000000000000000000000055705415353354016643 0ustar rootroot# Ben Myers <0003571400@mcimail.com> # Test pipes under DOS. comment/uncomment print statements below BEGIN { # redirection done by shelled command system("dir *.* /b >pippo.") lcount = 0 } { # print # Below is redirection done by mawk # print >"pippo2." print $0 | "sort" lcount++ } END { print "mawk NR line count=" NR " our line count=" lcount " lines in pippo"} mawk-1.3.4-20240123/msdos/examples/srcstat2.awk0000644000000000000000000000136105415353355017274 0ustar rootroot# Ben Myers <0003571400@mcimail.com> # Sum up number, line count, and sizes of SOURCE files in current directory # run with # bmawk -fsrcsize.awk workfile # or similar command syntax with your awk program # where workfile is a work file BEGIN { # redirection done by shelled command system("dir *.* >workfile") ssize = 0 # size accumulator slines = 0 # line counter scount = 0 # obj counter exit } END { # Now read workfile back in while (getline < "workfile" > 0) { if ($2 == "C" || $2 == "H" || $2 == "CPP" || $2 == "HPP") { filename = sprintf("%s.%s", $1, $2) ssize += $3 while (getline < filename > 0) {slines++} scount++ } } print scount " files, " slines " lines, total size " ssize " bytes" system("del workfile") } mawk-1.3.4-20240123/msdos/examples/winexe.awk0000644000000000000000000000707105415353355017032 0ustar rootroot# Ben Myers <0003571400@mcimail.com> # Sum up segment sizes of all Windows EXEs in current directory # requires DOS 5.0 and Borland TDUMP # run with # awk -fwinexe.awk work1 # where work1 is a work file # You must have at least one filename as an arg, else awk will want to read # from con:, hence the requirement for work1 BEGIN { # redirection done by shelled command system("del workfile.$%$") # Will probably cause a File Not Found message # Generate a list of EXEs system("dir *.exe /b > workfile.$%$") while (getline < "workfile.$%$" > 0) { # TDUMP keeps on piping to the workfile system("tdump " $1 ">> " ARGV[1]) } module_name = "" # initialize # Now read workfile back, processing lines that: # 1. contain EXE file name # 2. contain segment type # Print EXE name and stats for each segment type processed # When there is a new EXE name, print summary for EXE just processed j = 1 while (getline < ARGV[1] > 0) { # module name if($1 == "Display" && $2 == "of" && $3 == "File") { # Print program summary for all but last program if(module_name != "") { Print_Summary() } otcount = 0 # text segment counter odcount = 0 # data segment counter otsize = 0 # text size accumulator odsize = 0 # data size accumulator module_name = $4 } # File Size if($1 == "DOS" && $2 == "File" && $3 == "Size") { # 6+ digit file size with leading left paren DOS_Size = substr($5,2,7) # file size < 6 digits if(DOS_Size == 0 || DOS_Size == "") { DOS_Size = $6 } } # CODE segment if($1 == "Segment" && $2 == "Type:" && $3 =="CODE") { decval = hexdec(substr($7,1,4)) otsize += decval # printf ("%12s CODE %4s %7u\n", module_name, $7, decval) otcount++ } # DATA segment if($1 == "Segment" && $2 == "Type:" && $3 =="DATA") { decval = hexdec(substr($7,1,4)) odsize += decval # printf ("%12s DATA %4s %7u\n", module_name, $7, decval) odcount++ } } # while } # end of BEGIN section # no main loop at all! END { # print record for last program Print_Summary() # delete work files system("del "ARGV[1]) system("del workfile.$%$") } # end of END section # No scanf in awk, so convert hex string x to decimal the hard way function hexdec (x) { result = 0 for (i=1; i<=length(x); i++) { thechar = substr(x,i,1) # digits 0-9 and lower case hex produced by TDUMP # use brute force if (thechar == "0") {result = result*16} if (thechar == "1") {result = result*16 + 1} if (thechar == "2") {result = result*16 + 2} if (thechar == "3") {result = result*16 + 3} if (thechar == "4") {result = result*16 + 4} if (thechar == "5") {result = result*16 + 5} if (thechar == "6") {result = result*16 + 6} if (thechar == "7") {result = result*16 + 7} if (thechar == "8") {result = result*16 + 8} if (thechar == "9") {result = result*16 + 9} if (thechar == "a") {result = result*16 + 10} if (thechar == "b") {result = result*16 + 11} if (thechar == "c") {result = result*16 + 12} if (thechar == "d") {result = result*16 + 13} if (thechar == "e") {result = result*16 + 14} if (thechar == "f") {result = result*16 + 15} if (thechar == "A") {result = result*16 + 10} if (thechar == "B") {result = result*16 + 11} if (thechar == "C") {result = result*16 + 12} if (thechar == "D") {result = result*16 + 13} if (thechar == "E") {result = result*16 + 14} if (thechar == "F") {result = result*16 + 15} } # for (i=1;i # Sum up sizes of OBJ files in current directory # A clumsy script to count OBJs and sum up their sizes # run with # bmawk -fobjsize.awk workfile # or similar command syntax with your awk program # where workfile is a work file BEGIN { # redirection done by shelled command system("dir *.obj >" ARGV[1]) osize = 0 # size accumulator ocount = 0 # obj counter } # Now read workfile back, skipping lines that are not files $2 == "OBJ" { osize += $3 ; ocount++ } END { print ocount " OBJs, total size " osize " bytes" system("del "ARGV[1]) } mawk-1.3.4-20240123/msdos/vs2008.mak0000644000000000000000000001246012405413413014630 0ustar rootroot# $MawkId: vs2008.mak,v 1.1 2014/09/14 22:30:35 tom Exp $ # Microsoft C makefile for mawk using Visual Studio 2008 and nmake. # ############################################################################### # copyright 2014 Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### !include #======================================================================== CFLAGS = -I. -D_POSIX_ -DWINVER=0x501 -DLOCAL_REGEXP $(cflags) .c.obj: $(CC) $(CFLAGS) -c $< OBJ1 = parse.obj array.obj bi_funct.obj bi_vars.obj cast.obj code.obj \ da.obj error.obj execute.obj fcall.obj OBJ2 = field.obj files.obj fin.obj hash.obj jmp.obj init.obj \ kw.obj main.obj matherr.obj OBJ3 = memory.obj print.obj re_cmpl.obj scan.obj scancode.obj split.obj \ zmalloc.obj version.obj regexp.obj dosexec.obj MAWK_OBJ = $(OBJ1) $(OBJ2) $(OBJ3) mawk.exe : $(MAWK_OBJ) $(link) $(LDFLAGS) $(MAWK_OBJ) $(LIBS) -out:mawk.exe -map:mawk.map $(MAWK_OBJ) : config.h config.h : msdos/vs2008.h copy msdos\vs2008.h config.h dosexec.c : msdos/dosexec.c copy msdos\dosexec.c dosexec.c mawk_test : mawk.exe # test that we have a sane mawk @echo you may have to run the test manually cd test && mawktest.bat fpe_test : mawk.exe # test FPEs are handled OK @echo testing floating point exception handling @echo you may have to run the test manually cd test && fpe_test.bat check : mawk_test fpe_test ################################################### # FIXME # parse.c is provided # so you don't need to make it. # # But if you do: here's how: # To make it with byacc # YACC=byacc # parse.c : parse.y # $(YACC) -d parse.y # rename y_tab.h parse.h # rename y_tab.c parse.c ######################################## scancode.c : makescan.c scan.h $(CC) $(CFLAGS) makescan.c $(link) $(LDFLAGS) makescan.obj $(LIBS) -out:makescan.exe -map:makescan.map makescan.exe > scancode.c del makescan.exe clean : -del *.bak -del *.exe -del *.ilk -del *.map -del *.pdb -del *.obj distclean : clean -del dosexec.c -del scancode.c -del config.h # dependencies of .objs on .h array.o : symtype.h split.h sizes.h mawk.h config.h types.h nstd.h bi_vars.h zmalloc.h memory.h field.h bi_vars.o : symtype.h sizes.h mawk.h config.h types.h init.h nstd.h bi_vars.h zmalloc.h memory.h field.h cast.o : scancode.h parse.h symtype.h sizes.h mawk.h config.h types.h nstd.h repl.h zmalloc.h scan.h memory.h field.h code.o : scancode.h parse.h symtype.h sizes.h mawk.h config.h types.h init.h nstd.h repl.h jmp.h zmalloc.h scan.h code.h memory.h field.h da.o : symtype.h sizes.h mawk.h config.h types.h nstd.h repl.h zmalloc.h code.h bi_funct.h memory.h field.h execute.o : symtype.h sizes.h mawk.h config.h fin.h types.h regexp.h nstd.h repl.h bi_vars.h zmalloc.h code.h bi_funct.h files.h memory.h field.h fcall.o : symtype.h sizes.h mawk.h config.h types.h nstd.h zmalloc.h code.h memory.h field.o : scancode.h parse.h symtype.h split.h sizes.h mawk.h config.h types.h init.h regexp.h nstd.h repl.h bi_vars.h zmalloc.h scan.h memory.h field.h files.o : symtype.h sizes.h mawk.h config.h fin.h types.h init.h nstd.h zmalloc.h files.h memory.h fin.o : scancode.h parse.h symtype.h sizes.h mawk.h config.h types.h fin.h nstd.h bi_vars.h zmalloc.h scan.h memory.h field.h hash.o : symtype.h sizes.h mawk.h config.h types.h nstd.h bi_vars.h zmalloc.h memory.h jmp.o : symtype.h sizes.h mawk.h config.h types.h init.h nstd.h jmp.h zmalloc.h code.h memory.h kw.o : symtype.h parse.h sizes.h mawk.h config.h types.h init.h nstd.h main.o : symtype.h sizes.h mawk.h config.h types.h init.h nstd.h bi_vars.h zmalloc.h code.h files.h memory.h makescan.o : scancode.h nstd.h matherr.o : symtype.h sizes.h mawk.h config.h types.h init.h nstd.h memory.o : sizes.h mawk.h config.h types.h nstd.h zmalloc.h memory.h parse.o : symtype.h sizes.h mawk.h config.h types.h nstd.h bi_vars.h jmp.h zmalloc.h code.h bi_funct.h files.h memory.h field.h print.o : scancode.h symtype.h parse.h sizes.h mawk.h config.h types.h init.h nstd.h bi_vars.h zmalloc.h scan.h bi_funct.h files.h memory.h field.h re_cmpl.o : scancode.h parse.h symtype.h sizes.h mawk.h config.h types.h regexp.h nstd.h repl.h zmalloc.h scan.h memory.h regexp_system.o : regexp.h nstd.h rexp.o : sizes.h config.h types.h regexp.h rexp.h nstd.h rexp0.o : sizes.h config.h types.h rexp.h nstd.h rexp1.o : sizes.h config.h types.h rexp.h nstd.h rexp2.o : sizes.h config.h types.h rexp.h nstd.h rexp3.o : sizes.h config.h types.h rexp.h nstd.h rexp4.o : sizes.h mawk.h config.h types.h rexp.h nstd.h field.h rexpdb.o : sizes.h config.h types.h rexp.h nstd.h scan.o : scancode.h symtype.h parse.h sizes.h mawk.h config.h types.h fin.h init.h nstd.h repl.h zmalloc.h scan.h code.h files.h memory.h field.h scancode.o : scancode.h split.o : scancode.h parse.h symtype.h split.h sizes.h mawk.h config.h types.h regexp.h nstd.h repl.h bi_vars.h zmalloc.h scan.h bi_funct.h memory.h field.h version.o : symtype.h sizes.h mawk.h config.h types.h init.h nstd.h patchlev.h zmalloc.o : sizes.h mawk.h config.h types.h nstd.h zmalloc.h mawk-1.3.4-20240123/msdos/dosexec.c0000644000000000000000000000621214460037064014777 0ustar rootroot/******************************************** dosexec.c copyright 2009-2014,2023, Thomas E. Dickey copyright 1991-1994,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: dosexec.c,v 1.6 2023/07/25 21:27:16 tom Exp $ */ /* system() and pipes() for MSDOS and Win32 console */ #include "mawk.h" #if defined(MSDOS) || defined(_WINNT) #include "memory.h" #include "files.h" #include "fin.h" #undef _POSIX_ #include #ifndef P_WAIT #define P_WAIT _P_WAIT /* works with VS2008 */ #endif static char *my_shell; /* e.g. "c:\\sys\\command.com" */ static char *command_opt; /* " /c" */ static void get_shell(void) { char *s, *p; int len; if ((s = getenv("MAWKSHELL")) != 0) { /* break into shell part and option part */ p = s; while (*p != ' ' && *p != '\t') p++; len = p - s; my_shell = (char *) zmalloc(len + 1); memcpy(my_shell, s, len); my_shell[len] = 0; command_opt = p; } else if ((s = getenv("COMSPEC")) != 0) { my_shell = s; command_opt = " /c"; /* leading space needed because of bug in command.com */ } else { errmsg(0, "cannot exec(), must set MAWKSHELL or COMSPEC in environment"); exit(2); } } int DOSexec(char *command) { char xbuff[256]; if (!my_shell) get_shell(); sprintf(xbuff, "%s %s", command_opt, command); fflush(stderr); fflush(stdout); return spawnl(P_WAIT, my_shell, my_shell, xbuff, (char *) 0); } static int next_tmp; /* index for naming temp files */ static char *tmpdir; /* directory to hold temp files */ static unsigned mawkid; /* unique to this mawk process */ /* compute the unique temp file name associated with id */ char * tmp_file_name(int id, char *buffer) { if (mawkid == 0) { /* first time */ union { void *ptr; unsigned w[2]; } xptr; memset(&xptr, 0, sizeof(xptr)); xptr.ptr = (void *) &mawkid; mawkid = xptr.w[1]; tmpdir = getenv("MAWKTMPDIR"); if (!tmpdir || strlen(tmpdir) > 80) tmpdir = ""; } (void) sprintf(buffer, "%sMAWK%04X.%03X", tmpdir, mawkid, id); return buffer; } /* open a pipe, returning a temp file identifier by reference */ PTR get_pipe(char *command, int type, int *tmp_idp) { PTR retval; char xbuff[256]; char *tmpname; *tmp_idp = next_tmp; tmpname = tmp_file_name(next_tmp, xbuff + 163); if (type == PIPE_OUT) { retval = (PTR) fopen(tmpname, (binmode() & 2) ? "wb" : "w"); } else { sprintf(xbuff, "%s > %s", command, tmpname); tmp_idp[1] = DOSexec(xbuff); retval = (PTR) FINopen(tmpname, 0); } next_tmp++; return retval; } /* closing a fake pipes involves running the out pipe command */ int close_fake_outpipe(char *command, int tid) /* identifies the temp file */ { char xbuff[256]; char *tmpname = tmp_file_name(tid, xbuff + 163); int retval; sprintf(xbuff, "%s < %s", command, tmpname); retval = DOSexec(xbuff); (void) unlink(tmpname); return retval; } #endif /* MSDOS */ mawk-1.3.4-20240123/README0000644000000000000000000000643414373273211012741 0ustar rootroot-- $MawkId: README,v 1.7 2023/02/16 00:19:21 tom Exp $ -- vile:txtmode fc=78 mawk -- an implementation of new/posix awk version 1.3.4 Generic installation instructions are in file INSTALL. This file gives more specific information. Send bug reports, comments, questions, etc. to Thomas E. Dickey https://invisible-island.net/mawk/ ------------------------------------------------------------------------------- Portability: ----------- This program builds/runs on several POSIX-style platforms. It has been recently tested for these: AIX (5.1 and 5.3, using cc and gcc) Cygwin (1.5.21 on Windows/XP) FreeBSD (6.0) HPUX (10.20, 11.00, 11.11 and 11.23, using cc and gcc) IRIX64 (using cc and gcc) Linux (several flavors, using gcc and icc) MinGW/MSYS (on Windows/XP) OpenBSD (4.1) Solaris (2.6 to 10, using cc and gcc) Tru64 (4.0D and 5.1, using cc and gcc) Options: ------- The configure script has these application-specific options: --disable-echo display "compiling" commands Show "compiling foo.c" rather than the full compiler and options. Those are clutter useful only to a developer. Developers focus on compiler warnings anyway. --enable-warnings test: turn on gcc compiler warnings This turns on the usual gcc compiler warnings needed to do useful development. If you happen to be using the Intel compiler icc, it does the right thing for that. --with-builtin-regex use mawk's own regular-expressions engine Normally mawk's configure script uses the built-in regular expressions. The choice of default is based on where the greatest lossage occurs. More scripts use gawk's null-character extension than use POSIX brace expressions. If your needs are different, build mawk using an external library. Limitations: ----------- mawk 1.3.3 was developed to correspond with a POSIX draft. POSIX continued, and incorporated some of mawk's extensions as features. The 1.3.4 release fills in the major areas in which POSIX grew past the mawk 1.3.3 implementation. mawk's built-in regular expression engine does not yet support brace expressions, e.g., /a{,4}/ Use an external regular expression library if you require brace expressions. Aside from that, mawk's built-in regular expressions provide POSIX functionality. Using an external regular expression library means that mawk cannot match expressions containing the null character. That is a nonstandard feature provided by gawk. Using mawk's built-in regular expressions, there is some support for this feature. Aside from supporting nulls, using an external regular expression library is usually advantageous. The Cygwin math library has some problems (which are also visible in the gawk port). For instance, its log() function returns Inf (infinity) for log(-8) rather than NaN (not a number) as all of the Unix and similar platforms would do. The MSYS package for regular expressions is unusable as an external library for mawk because it generates a runtime error when asked to compile a newline, e.g., "\n". mawk does this during initialization. The MinGW/MSYS port does not currently support pipes. There is source-code from the obsolete MS-DOS port which can be reused for this purpose; however that is not the focus of the 1.3.4 release. mawk-1.3.4-20240123/fpe_check.c0000644000000000000000000001103414457053742014134 0ustar rootroot/******************************************** fpe_check.c copyright 2008-2013,2023 Thomas E. Dickey copyright 1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* This code attempts to figure out what the default floating point exception handling does. */ /* * $MawkId: fpe_check.c,v 1.17 2023/07/22 22:27:46 tom Exp $ */ #include #include #include #include #include #include #ifdef HAVE_SIGINFO_H #include #endif #ifdef HAVE_SIGACTION_SA_SIGACTION #define FPE_ARGS int sig, siginfo_t *sip, void *data #define FPE_DECL int why = sip->si_code #else #define FPE_ARGS int sig, int why #define FPE_DECL /* nothing */ #endif static void message(const char *s) { printf("\t%s\n", s); } jmp_buf jbuff; int may_be_safe_to_look_at_why = 0; int why_v; int checking_for_strtod_ovf_bug = 0; static void catch_FPEs(void); static int is_nan(double); static void check_strtod_ovf(void); static double div_by(double x, double y) { return x / y; } static double overflow(double x) { double y; do { y = x; x *= x; } while (y != x); return x; } static void check_fpe_traps(void) { int traps = 0; if (setjmp(jbuff) == 0) { div_by(44.0, 0.0); message("division by zero does not generate an exception"); } else { traps = 1; message("division by zero generates an exception"); catch_FPEs(); /* set again if sysV */ } if (setjmp(jbuff) == 0) { overflow(1000.0); message("overflow does not generate an exception"); } else { traps |= 2; message("overflow generates an exception"); catch_FPEs(); } if (traps == 0) { double maybe_nan; maybe_nan = sqrt(-8.0); if (is_nan(maybe_nan)) { message("math library supports ieee754"); } else { traps |= 4; message("math library does not support ieee754"); } } exit(traps); } static int is_nan(double d) { int result; char command[128]; #ifdef HAVE_ISNAN result = isnan(d); #else if (!(d == d)) { result = 1; } else { /* on some systems with an ieee754 bug, we need to make another check */ sprintf(command, "echo '%f' | egrep '[nN][aA][nN]|\\?' >/dev/null", d); result = system(command) == 0; } #endif return result; } /* Only get here if we think we have Berkeley type signals so we can look at a second argument to fpe_catch() to get the reason for an exception */ static void get_fpe_codes(void) { int divz = 0; int ovf = 0; may_be_safe_to_look_at_why = 1; if (setjmp(jbuff) == 0) div_by(1000.0, 0.0); else { divz = why_v; catch_FPEs(); } if (setjmp(jbuff) == 0) overflow(1000.0); else { ovf = why_v; catch_FPEs(); } /* make some guesses if sane values */ if (divz > 0 && ovf > 0 && divz != ovf) { printf("X FPE_ZERODIVIDE %d\n", divz); printf("X FPE_OVERFLOW %d\n", ovf); exit(0); } else exit(1); } int main(int argc, char *argv[]) { #ifdef HAVE_MATH__LIB_VERSION _LIB_VERSION = _IEEE_; #endif catch_FPEs(); switch (argc) { case 1: check_fpe_traps(); break; case 2: get_fpe_codes(); break; default: check_strtod_ovf(); break; } /* not reached */ return 0; } static RETSIGTYPE fpe_catch(FPE_ARGS) { FPE_DECL; if (checking_for_strtod_ovf_bug) exit(1); if (may_be_safe_to_look_at_why) why_v = why; longjmp(jbuff, 1); } static void catch_FPEs(void) { #if defined(HAVE_SIGACTION_SA_SIGACTION) { struct sigaction x; memset(&x, 0, sizeof(x)); x.sa_sigaction = fpe_catch; x.sa_flags = SA_SIGINFO; sigaction(SIGFPE, &x, (struct sigaction *) 0); } #else signal(SIGFPE, fpe_catch); #endif } char longstr[] = "1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890\ 1234567890"; #ifdef USE_IEEEFP_H #include #endif static void check_strtod_ovf(void) { #ifdef USE_IEEEFP_H fpsetmask(fpgetmask() | FP_X_OFL | FP_X_DZ); #endif checking_for_strtod_ovf_bug = 1; strtod(longstr, (char **) 0); exit(0); } mawk-1.3.4-20240123/icons/0000755000000000000000000000000012020406320013147 5ustar rootrootmawk-1.3.4-20240123/icons/mawk48.png0000644000000000000000000000600412020406320014770 0ustar rootroot‰PNG  IHDR00Wù‡bKGDÿÿÿ ½§“ pHYs × ×B(›xtIMEÜ  $³_­z ‘IDAThÞÍ™ylÕÇ?ofvwvíµw×W|„ܱsQˆ¡ @R.QJÛ U@Õª•R[!UTUUµåªV­ªJ­ZZ¡¡‚–¥ä€@B.âÜàıMŒµ×ö^3ïõy»¯íÄ!‘š'­vgßù}¿ßïû;Fp‘4µ„r†Y¢ÉNÑ͇әgMkñ&.ÜeÂ’÷E7ôðwcæ·ñ­G©jOÜPEƒšÉèäØÙæÓÙ £¸msйûÆXŒÉê }ûîVÖŸÌ“x5I¨#‹x>IHºÜ2¹Æ4-Ø1ŠùB’¨£X¬šh¼`·ßÄ‚¼`åÆ>l©ÿ;šÁ¤á‚ ¬1 Y /%1%Ü©@œ÷áë(sàûŒÊÓÿ; Cµ8o DF‘¯ÓÖ²{„`Ò!A—Ÿ/€œÅúÝ£ŽfÇ_ÆìHŰØIþ¼P®dóQ€ž¤ÌÜ¢îÆüÜ· qà o ,í[Áq».˜ •U°mQeêÑ'²ˆ~Á»´~îÛw¸iû¯:–E dÛ ‘Ê*†›|ùâ Q©¸áóHA55—nMM¤ñy!ÈKN‰º`¤âð<ûôó‰â3ƒ-\vÎ×?B[{•–»Ú8áMw©3°Pá¡ÒàÓpÉèדDSט¨Ëz˜¢Óåºë…òˆö@E¡¿1„ÓåÒ©×ó³Po\ HågwØTܸ«·ÇyìQ¼w–qŸÉní—º¯ÙÏû_³y³tþ o¯Ò5Ÿõ­µ£¤ï¯g’@дM5¦z}~bxs’aKJ¾É(VWC9 Xn­…ôøæîÞö=¿téßí…¾©Ø¥˜7Ù€ïóô­ÿ Ê›j6?šdØbÿ·j 4hž™£ãaøs’‹á½oÃs­ÐñˆÅ“•ÃzΕÀï|kýx øL_ì%Ðæû½b2¦¸¾™€>€Ã9l\–– ‹sÆ1Xzl Y Î<„0X˜6PAÈéÇщBçëÀïôÙŒ¸Š‘`›vïv^o|‰{uê…§‡rÔIÅò’5š9n,È*–4æ{ ‚y×ø8òŒ6yŸ6ì?L‡…Z?ù%ƒòÌijq 0V½Í»%U(f©šq̰è×zÛòLá€Á%‡²^gÇ&ÔC²0!+ALc™ÀƒÀßðÙÞT ü-ªå€i@$ëx¢&®TtßZÆ •‚DG–,6‹Jô¿]B†YÛ•Á-pÿ)ˆ ·(ÈXÑÀ™Àzm‹¿žŽhÅÓíÀ.­Ë‹EyVo^i¡ Ø¾ÔÆ ÃPʶ¤©DÖ`?@¿ËõûÆNû•QA¬Î$™ðùqW‚ò(²´=¼ ˜€6}pì,ügAM¯ë=$, ,:²Šá„ðÔè­ Õªk‹á_ôI.+¨@Þ$Vo’¬,9œàR`-ðøt=q+óÑZWM¢Ÿ9Z— ‚”Óï Ú›L@‡K"é’åsµž§o¬à¨KMÒ9½É¢²RÐQ]â¿]5A…öo €]~–àŠ”‹“—PcAÒb?¹˜ÅÞ– ýxÖߟÁ E3á—Àq‡šÂ1 ñaÅ»õN‰üj€ úöÕt ¸à Î+–ÊyqI£—l`Ç—‡<*‚Dû¶#Y¦ÕgèËC}’*WnN3)‰¦]vW'…˜É¾ƒÇROM7˜kF€£¾ìn·„Às£Ì˜k“³•×/6âÎ69„wÚħ9ª6X¡o^©»1gZ º`õxžŒA/¨Ûm Xpš˜|ˆN(N  Më›ô ø`[ÖpItúW™l6@Ž@\‡Ò8AA[‘1¶3«AðžC¨ Ð%¨rIèL9ôÍ M<Øò.ÞóÜàös‘À¸Tn©å©K§bFµIW1¨¢6¾jƒA‚½PöÑ(eEsA÷Å‚í±OAõœìÈbnÀäàl{âÁòŠ @ó÷ž €{ãÚttù±6Ò Ã(©8(üõ ½3Lï€ÝØŸÇJJjjM/É;,‰I¯ªšmò»ò…P%bÒ>?8Þ’ üüŽ0÷èǵ}ž@Á€#úw P¥ ¬c—ê™6nÐdoiÒ_&ø/LŒ"‰KFÈ«%C&5e®ÇTCPµÐFp©(ÚÙ\NĈhIrùÁÆÓqÀaJÜs6­^ÈC¹æñ°j`yW-¿ŠAc—KµžÑú›ïëNtCµ ÎT1ÈÜSYœrI:£#PeÈ´bfAâmœQ—Ž–;Ø9†m–F žÔm8€6Dä}±É•;F&àÀÆ1Ädµšc’­ZJ‰>¨ŠB¿ \ƒÅ‡sƒT@¿ —Ó ³}Ñ.a“m—EŠú@ÊcY²qHû€•À‚³I XV³‰‚{Òˆ: `K–èd·0àxñΨ >UПtÉ Xq$ãqLç¿¡ZçºG‹Ý|Ì¢JÕhS’èZÄéÔvôds\³g ÒZ€~EËdÐm@6¥ˆ Am ú÷Œ@·–W­ðì`OŽ•š¦‹T,ÞÆv9rYxü¢½tfq×Ùlñ±‘˜ À8¬æ2+·éºÍýôÏ©µhÇ2¡êbÀQ Æ(Äk¡¿} »#‹pµGYð$àÂ5Ãåü $LÞXUŽ[½2Dô‰*Ú³ÏÓª4@«¾•}Nš«ŽePŽ·,³q…—ÿ ˜¼&êxa‡W¾>¶Ÿ–ðͶ@{Õ uÑÅI e– èÉ!rd›­qR˜ M;ž15Ÿpݦ”»_Å•‚Ò+kLš#ëvDG®n#^Uí°/|¾!JÊð24üú_Rˆ}Ûš$yqŠG*Š™Ø=þ3†¾Õ•…Û'ÇšÃDo*,XAËØEþ¿Fóri; Pc0ô…"µA ò²°“¿y9\Ï:ˆÃñÙgÒE’Ž AöO7úìÕ)ÛÚ<½=Í­oèŠñÚ(®R¼'ñ3à»zÎm~,•@½IocIèµ0„r% áÅnjÛÉ;ÒË•ÿ_}ÉWy}˜²[좚þø7PgK5ÏV»p׎4vA÷—D!ÂVMÚ’Ú[O&l™`Ï’6Yl“ [ìÕ$ÑWVI[\(Ô4~ês^l$!Ÿ'd´®BESTåàáßž"rà®8Ns›í“¼rN•ç™4¤|¼S!~Ø€kUò±<óLÕêør·Ãšgú'&ø÷W“šæ}ÑÉkãü@^qû–Œ” Z"ÈÅεð,:é6Ù‚5{åò®é ^Íëólò“dÏ&‰:’5ªŽÚ"5‹9yÁÜm)Ï8¯¯Ä1ÿd>ÏË‹QÅ›7ÇP1 ¾à ¼zN—°Ÿ\ÆeÓÍ•L(u ;°9…›7ù €¡@8w¾>@ /¡1èÕè­úq…Õsj5=l | –Œ£Ø*NNA›gh±5lNÈ´„'ö½3L8-©V3YaÑÀåCñ=iOßn©$„—§ó‚íLïÕø”¿œÏ @±7[ÏÓë*ùæ±,FÞ' ÓÃ$„"iäë^H’ÀÒ0T¦Ë ÿß-Ôà W•/×F‘–â˜8É#-±?ÉBØ€u œ°â)’‹¤Åmž¼ª 7a‹j¬,ǵmþ `H‰0€;ãH%Ù!ztÉä"i¢ƒä¨dóÍ1/½-N^Â[…—€†©ûjQ AzË{xž‹°Å×ðÚÌ c·Æ¡ÞbÌ^í#5ŸŠž¬ôÕ4/Ê6Ü@‹ÛÄcª‰ùþÿÿÙBÝ,™¿³IEND®B`‚mawk-1.3.4-20240123/icons/mawk144.png0000644000000000000000000002433312020406244015057 0ustar rootroot‰PNG  IHDRçFâ¸bKGDÿÿÿ ½§“ pHYs × ×B(›xtIMEÜ  4·óŒ_ IDATxÚíyp÷•ß?¿ž€8 ‚ Þ§HŠ’HÝ’eÊ”dYönym+ήeIU{Äëòî&©¤ìJ¥*©lòÇVìx½v²›ØŽ½ÎnŸµ’eI–i‘”,K²DŠâMà…ƒ7î0Wwþèîé߯§{¦çA¯ŠÅéAÏL÷¯¿¿÷¾ïýÞ{?Á‚Ü0b¬ ƒÇ€[1ˆZoOß ^k 庸IÀ‘O˜Áà[bˆó7 €ŒuÔd-ËÉ0I”£â,£ pqÓNÂôò °Ñ~/ œ›Î(ÔkÙS§ˆð·â —æ=€Œ•¬&ÃgEÒÛ{1¥–ƒ¢—Ä‚æAÐÅSnµß;>/ÃhšÃðl´„³¸Äz¾&ö’ž·2V²Œ „òœöc1Ào8»Ðù°}üüì«ç´†ásíP£eAô²äÕÙºFmÖGEç6x†’ðWàí8è*¬ïºéÁ³Š >d¿ÏÀp~1¦<чUÔÎKÝta° ü`N%àÅøîÓ¶[³h¥Ñņ›<Ô‘æY "—“ðò˜ÿùïÅa$»ÒÜ6_5Ð6ûÅ©)ÓŽÛr.Ǧ¤3C|ÒXGÍMÈ{4ŸZmÂü£aHéù”:˜V4ø–ù ƒöËм{¦õ쨴0ÃGo:õÓ͇¬µ_Ë(qï´2ÎËç'€öË¡TîŸ'Ò¦9“äc¹3˜ó^û,ã`§}üƈû쥴Â#ë¥ÔÏ+¦ÇW'ƒÅKM+¦LŸ¾L™±”vÂüíš‚WÆ‚>£»Ì\GÀñ†Ö@«¨‘Ã3yN}Q6eÍLóè¼÷„ø†9QFÒðb !UeLCó @i!~Df~™°'²™¾3€p9 oO(#þ„ÑMl™®;€õö„ùé¨I†K¢˜eö™wn¼ø ž³·ÕAGš·gÆœA]„pÖ†nhí³ƒ!·ß‰Ã`²´ïª×`Y­B —Ì;Y<¨Áqû‡ï  …R:¼2¢h¡{Œ.ßðºÂC4ƒI˜÷Œ•þU;=Ib>/¦ÂkY-T/­"ç‘cÓ0”æ× ®…Œ4`ð°}ü«±â½.ùÞSøÏ^q‰ø¼è§¸Šåv®"ÔÝê ½Íè¦ë†EPœÇd⼿ŒÇ½ºÚÂYð¤ÈðîlÞŠv}¦ Çì—Râ3 虑æŽë{CiŸ54wÚÇ¿+Ë'·×+3í}1ÄÔüP˜£öËõµ x»Ç•ÁÞpC®“¥y+j i¦³”* 6Ö)OsÿlßÎõÐ9Îi§ctG‚}ìbŽL)3î†Zâ0:©Ãàûøõ‰ò¾o} Î"¡`Œ~Nߦ"éµW‘?·GÖB‚5ÆJVß0 ó€Ì}NM— 5xxH€qsh S{œµ_®ŠÿØpÚ•x–á‘Bûì$ŒÎý²öÑË|pëcÊxž¸÷uý¤9êŽw!¯O*ƒ¿ÞètÕæ¬œb˜9::.³æ¤-*­' R¬›½èóÜЀi0cAËŠH>¸˜„“júë®9 ÷Ù/ÄK_²ùäÕžžÍRž9 :†Cún/2îµIe7«Y:gÍ×r:íb³Â¢\Y[£˜ñS×Ï\בåý²3RÜG‡’pFŽ ¥xpî Gûœœ‚ñ2uEHƒå2®½y4SÎÇ3¡¨´íF'us;«¨Ep‡}¼¿Ú§3,­} Æg»œyîH8ng)Ò›0½2 Œ„c™3’äNÛuNC_ ¶;Tm=x=oïú¨†ì:ûâhñ£¿žPîæãIBsÇr!ÐxÀ>~7^žëžÕ@Qe\Ï{¬dÞl=f1œ°þ¥ ÎŽ•\£Ðj€ú°µ†Ÿš†G›¬tNƒFÞd 8ÜêºJ7kÁL=IK4_ˆŒ5¶‘0âjÆèÑ@“5æš4þöëËø›€véÜ ÿ§€÷ª ü¥t< 4‚¿{)ö’6ºµ€Gk¨0€¬AÄÐ„ŽØ7 w×›ÇÓ:;s®·n¼XYĤï'~@î¾’!úÓ:û“p@7¯]·¾Ïú?{l˜ÿ0@<„ü&|ò2NÄý¯®(¿ñ®!†Ì“æ×%çÀ,¨4€vx\ø-Àáz~a¨©€ ûOðo½Þÿ«q "Ž|ÍuÊÃÀÞîé k†ÊǼ=‹Ðßz IãçFx²Ø–4—E«"€€]6ÙˆNL›Sc³Ø€Í­ lƒ¹ÃÇæ:€ÚÁ³;€²4¸!<§Æf³Ç{-0`)œœŸ•¦}€ƒ(œ¨mÎ(ßûŽùZJ;˜ës•ðºšáZ˜¢;¶]^)p §€}· 9~X /Ì@·a¦¬$òøâ© †Dš¢ëäÏÃPþ¤õˆ3qB:Óípö ¬ R©Az¹‹ÿüsØì€&=JûS|xÊð,oº< ¼o½.$¯a6sÀJà§à=-9|óú«åÆïðJ¸òäéê¤l=-0¼ÿþöMØtnÿÔùÞ('­¥çΗž›tÒggCYý}¶ÛŽóÄ ñÏÁF vÖõÀÆ+°Ê ¦F¸| ºŽ5øL¸n{(ÆØêZBÿaœßñ8åó–Ö)!dÅY`·€þµžªÆòUŒÞ•@šãæbœuÚ‡wÁá°ôÇðÝõ±¤^ZÌKÍ!ÒtˆÒtKI&l1h³Òâh"Kž¦íkÿ6üÎ l²?Ò}bÎþ@»ßÈ ý´Ìçè¾·…¼×J°Ž%>:‘–LX´ÀÕlŽ™yÀ›àRŒ¸Ïi\meAyG‰÷Ô¾Uùb»ýòð´wÚÆ68âú±À&6LÕ–6BNC¯ÿJ,G­ÊÚ§0‘æ@Qx¦ ã“‹Ñ¿Ôé¸û 5h”êé—]tWPûئÍÓì ‚pæyžq5Òh&xl­zކ; yøñlxa…<­-§[–Rœ}®¦5kjaÐÂÀ-±,oÈPêߘ”ˆ¶æh„ ðŸü¿ÌF»1æ˜|J•‡Íp@VÚŠPuÀÓ <ãzï«P8Im64ܞDŽe9Œáãpº“·Æ²w=âuþ?M)h[ ma6—ø÷­ö‹ÓþþófI³-K‹PZ¯ €þ”T˜1àÛ³h@ÓEó lr‚ÜÝuc«k͆K|t0EkÂépÖÈŠ¢+7ІCŒç)ï›$@ïp/ÄäPåÁ¾àzïïÌˬ>€Üú‡EHs¨O2 Ò,BÝé «-ÇgÞ^u d®¼×Äu³m±ŸLJªƒ±pñÆ*èI—þ>[&Õm¾~ž…ýwæÑ@YùuDŠx\å–´ÃdÈc•}Zºú&Áïu‘T+@yî™ñGD h°ë)nƒ™LeM˜ÀÌ¢åÿRD’Z¥t)WD’ ¸ì¾ä…… Í®:«\i™±z-4­} ÌXË›±M®ã”g´Gº‹ce›{ÏS08d†²ÒP$€’•ЃÏð¿ó•Ð%à"øÖgû‘ílzxÒ'â y_øæ˜·+‡–ŒŠ3œ.ùEj—Ý]ýn:í^?Iò§­^tM¤æ"4]Y¹µÏ/(2¯\ɦé=I w÷ g˧¸Ïà¸Ò<²éT·Æ É@ˆ\†E.3¶9 7æÐ ž'm-Ð7•[‚a€Z‹P¼rZ|ÜõÞ—‹ý’rä&Эÿ÷E¤ ‡øe#Ök :ÞŠŽ.¯…váM¤¡õLBÙÀ¥‰®@=…Üú™Û,ñ¸,€ uÛp»ðO71º³)ø OT®u柣N¨÷_Í&€Ü&ÉÖ@'|Üù;}®  R8P ý&•°ºsE|<1hIé¦F~ks‘ºhi¼S~çÝ´"XfâNh˜0î ">QÇØ­5³®š€?t½WpÙ¢Ú:(9S=Î_ii-_ Ïx_`cXñÚÆäúH7€®YyÖŠFÐ îb³T»-Ç\ÿçM8ÁÃþ™Â8.i &ÉÖ©HKÚÓzE\ù?DÝ-r OfVú¤ãàfLä×@õaeLç̧BáhóuåxTgÈP¼KÀµdYú¸+Î5|«Ô/+@K¬è6_Åi „cÒFÓÞA²Å!åáƒÕszì·;B¹š‚¦´u'Tolk:ž@+Âì²Çðb²°f¸ä"Ð+,i@KOâryDÚíºÿO‚§´V @~Zø„ÿɦEŒø ~SX¹ÚQ Y´6œ ´AË\W´*O·{?õàA=’†3'd,»]øµaç~ZЍß.Ý„Ý N“+ëžþ¦4V @n ”²Ìš[:×]$]õ™U­aåá_‘,y–Ýõ&Ò-36œ†«iéžõ@Ù†#8yÅIYãeµ¦nnSÐ3]<€¶DœD²Ö"ˆô•TÅ´ÏÿÃ#Ïy¶”ñ!™˜±¬ »âc×Û#ŠZÉ&Š‹³Œ¢s`[W>«!¦ ºó5˜•¨²ö1<øPV†2fÝXB¶MA\¨Ú欩.‚I_-M-‡œǯ”ëÎU@Ç}â>û iáÔXy©e h—6iÆ­…îöÐ0ŽÇå2c9 ëQó«ùjçûuš‡3DÎÎ[NŸ‘4P`úÖ°³lÐ\„ +q9ã ®ûÛín©:€Ú è@È*ýmµ=0¯=TÊ‹›á!®¹üâ“™©¹ —4˜”Â5ô:ÞSþƒŸ+o¿NÒ´e˸ ZèG8÷³¸º5q‹0“Ædùr%¾X+Sûxh[Ž ­$xéå6¡M{Ϫöò´®æìÕÁ„In—iž®|‹ãÀAŸº¸º1  O>Olж ŠkÔ' g>¤L€fÔ­j¯gQù×J+ÿ© €ü4PïÆ -ÀÂÎ:Ú€è¬U®t('¹Ÿ:ç:ÞùÑ‹â’sÝMEj SxXªÃ)á$zXå?SÇ`ÔŽŸEEÕ)íÖÈM˜ÿ2ê)] €ÜkZïç9×ߌI{ÈùÌ`¥obÆ×[èXòæA’êK(Q饯*å¡nVÃH9¿—@jŽnˉT°­§¦µœ|¨>«áúˆgÌ«rò1—s0|¿’è,G—ÕpQDÚ4[ÚULŽ7€ ó¡®{è’ ¸îÚ45c̤7YûxQÕ£žXAE49êu{–íÕÑ@n×ýk>ÔbV”@çÕ@µ‚°J}ÒÀÅ´7–Ò82tæš0k> Óy\yeí«'áɃÖZ ò3_¾Vƒ@g)Ü”ÁíI‹@÷Ïx'`¹Úþ^û½û¬~Ó}÷úÇ\é.´Îê©xKÂìõ¾¢ßõnÙƒ!@ Ë”€Á…,€"å=Lc]Nã ·öù&E&°U@…4ÐŒ—ÚÏ@ík S3œöá?kÔ XÎç9z—†H6ŠÜ„þq—º”<>A-o³2ö5að7cæ¦(—u@§³&RwÔ^®'–T¸Î2à÷]gœ«C¯&€|yО3 ËÏ^®F óoc¤›DziÈ3?ºU=ÕåÎël à›Zz¼vĹâSê Ð…qƒhÜP ÷œÔ—A†æºasŒ’EW<ËÏ»Ì2ÀS×@²6Ñž<è@’¥ Ÿòߘæâ±ü‰ˆ‹\A0Öå 4D¯ºJ«3fä(eiˆ\MÃb-׌äÑ@ëcðNÒ‡ÿ˜&Ø ãh¡îòÌØ+ï;|Îçùm¾^ò"ÐF©èdše§}––G” »*zTnêô¬ññĆ\¥/åünRÐéŠ Â/é/Éšá\¯s,€6ÖÀáTGês=…³²Æ*UúÒ,ù»%ÜüþZñéë b ´-‡¼\âþ íGÞ¿¯ð#à.|½|bAW\šH›ù;ïšÚ¡6X·:dnì6“i±l ›š´7ããÂ;O!«ÉW•¡Ö]ä z…äOÑxŠ 6ÿ,@A⦼JB/ÎxÏ’µêVF}~¥ŽÞmï>;nW^vçßNähãÞøD X³9’« Ðú= '7Z÷q.íoÂ,Ÿì¬­Í[£®*”ÊKð¡ @¾fìDÆ$ÒîY+­ÀA·2½ŒßYã},t$bo ´Š¥@ýŽˆwàtÈÃdØ; ©˜Ž«Y¹µÏûUûtE¨¶TŸ?jCMÄ>BqYüžèš€”ø„“uHÒô, ù”:»ªRmwþ¼ |4ž0·o ‘j…=±Ust 4¢+«ÏÃyšð"¤N0mý›21í4ŒŸšM•c¾À\pÍñØ& -!Uí„4X[«¢8ÕsºKËÕh\M NL#.èʃ?ǾÿÉ6gh¤°'fßÇþdv#”üj Ç£öhiMׇ—ñx߈wñß.Ä\ßKWÓ+@}˜Ýé—bF<;nÌŸ•˜›q¬Á\cZt5ïÛ#m'°&"5Œs¡@:—%Z4o¯í‚‡Û› !i8Á¶‘»ÚnÑÎ.¬Þ? ¹žØ$´ÊZÎÖ"‡R<0ûÚO2ÕVEskâ€rXMÛÝai¡|Nß 9Iu³ ÿ‚ÓcȺñ~Ì%‡³À d½–I81axÇJú%3¶¡N1&'JÙ½!äÝ]ⲑ>­jV‡])³Î(e«U’Ðæ¡tÛZ®!ìD”OòÀ\Ü>{-%èˆÚm³µ6öÝ.ýuPÅä’ §y¦¥žŽ”ò}ƒ_{½?ê¡.º<§û#¾õ×Ú/Î$ Ã'…¥ß2ck¥@è±TNá©?€äR¥Úâ— Î%¤ò(ƒ¦Ù¼ˆÔÑÄÃŒ‰jh1…;v•,Àºä}Ð fØàcN ÈÉ8oxi./WÞM|?#äÞñÐ0Ë€²üçtVúÈ^[-M„Þ4µt/gíŠÛz­ø¨´NΞ¬÷ZÎÎ?ø|d½uNUT5ícq‡ÅqˆÞZ¯ÌĥfêEô›ø~0Êoº:™uÒ…0A`¯ÝÕAªÎ£šsØÊ—+ª™¼Bžæ•âGddÏsK¬øû?—X³`™ÑÁªfì™ÙPÜr‡MOœ+>|èp¶Np¡Mct‰ÆHTxgÂÖXº5¦\ÕûåÜTÄc–Ï@ÔkuzB2aÍKC$åN«ÖCÈÊå; >žX›¤I“IJ£óÂQuÉto*@qŽM)ƒq/ær’_zñ§ÚjÈ}&ŸXlŇÚ1ÍÐ2Ì0y7æ¢ë*ÖÄ»øë+|ór'ßÚòƨ C ßǹ§¼Ýú& ïß’–.â´”pß²!rV«êS‰!5{h¯Š8œâ7 ÆP›oPŒv¥IKصÁn@ùí¤r¸ÍØÂ¢'…+^Jä¬z÷·£åð €·'”ï»ÏØÁð¼Ïét'Æ"äæ?®Õc›LîVˆW3¨k:ÍgÒÄ0¸$+²z+ß*^ùoMº ³“YØ1_îÌI?OìX*«Ù&ûr×Ù‚HçV½X[‰fìpBé·TÏ%¶ç1c!àæ€Èp§½ñÈpÚéÜÞ쳓ÞK3t *¢}°‚™9^Ü„¤ÜXM’kRÒR—±‚2N©OŸk£’µ[dg=¨õX$†˜’½±m%h¡ŒïL( üÀ³õRž˜PÕt ˜Fâ>ûøÝ¸ã½,Æ›½™¢hà$µB’öâj²+/{`Q˜ªÕ™>7£L€ûæ2‹nÝâµ&vÎPšSrÒò^/ÔÉŽÅÖúÒ’íßKËþíGV°ø?>§ß.[Œjh" ´b'dò| .ÿÉ@¿MÐ(N—Þ)+ˆKAíÄ®B}Jr]¬ ß\}¥´£´CIïÚ}/Oì‚N›ÆHŒ^€úŠâ³“í4XYÂÒÆ´ïÅPîþ>ÏGž®$€£.¶ è¦ !§ Ö¡¸:ø«}Tè™ ŽQzò AhíwóË£:™Pn0äÇlYâá‰ÍD÷'™i=MÄTRÁ=0ÅŒ™up٘жºÒá׊-_nt“À ÒÏPä6¨Z¥ùÑM«Œ{Ç•Ö £”‰”A»Kª*€.A‹Û[li’ñ´«ôÙ‡ÿزԇHŠT©üÇÅÈf¬”mÑÇÓªÀ`ð_½V @‚MGõŸŸq’×]3ÞÈÝUAy&† C‹Ûk—€pÌÕe(í¾Ÿ'öÊ µ.óU€èÅj[ÅÙh¯XycBYÞXó÷Kxÿúøg®›²šFݽpŸdÔná̓(¼}fÙhRÐ:êÐr îvÎÎøo±Ô‰³Þ\‘iÚ+ kQ8kn¶×—6£i“Jd‰N wÏùœþq<’ïÊФߌvÝñ½vßçá4œòiI Å kUˆ—|N}ÐCƒ ;‹á?Vûþfï6îݲEîj0ÿ_öÕBU'Ò²´zèbÒœ±}z?o û6ØŠ•êÂçÚ|Ž"̨wL+-2m{drtúëÍžà·å³å¨8ÝÉmX=Ÿ“¸Bè’lŠ9-ýׇ}×¼ªN¤ý<0ÅŒMû»ï²CÙ57ʵ©È°àyÀ«Í€4H/óÙhd(YxﯫyBW8¯)¨€ÄQ&)r?S?ysÂY©ÿw œÕÊÈÒèýyµT¨¿?î¿må•ÃCÏÅ9ž߈”X¦ YÔSÁp¨Œv·ëk,>§4c}¹›Œ³5B9’ÒáU«~·;D⮨ïD{ÒÅå(8ÿéf«½Ýc3âéI‘¢f›·,+HV%3fäÓBMâ/¾²ÁZàÜ)¨NWâfÄýÛÝCÓβÍÓu¾-mÉݘ·22@Ãà± Úç¡EÒg³Xáý4ªhÆV„JPHƒµÖç푼ß3„÷^"¥N‰½• ’½bï?ZÄÙf-7¢$&¤xxÓà“ྜ6÷IûÆüµÏ-uÒíG•hµ5P^í¨)@k"N¶ü}µyMToï1ĉ¸áLÙ8êL¬f‚±«Æ×{Œ<‹ÜZ}Ä+fì$Œàûø­<ž×)³ç˜8£,cø]ô™VP €q-T"]—˰ׇ8€ÿq–{.{[_’Ö!ƒÊËãf½Ûyw µ0ò¿Ï‡]'º[~l ûÇ]á¹»ÑÌôÐiÝdõ^Ò…M²öìv²%OM±¯”9Þ§|FE¨–ÑkWóñ€Á³1ÅÇlLµ´J˜åR[mGSü ÏÐÜ—†ðbn‡á.i†¼Ñ¬‰´¡~¬‰áµ!û2Ò†€Žü g¥‡±° áYÌ­ WçDà¯Zª¸÷èF+¬­\IDATçaÛwy+î¿Õ‹×+ÌÍEî´.æÌ}üä?ÿ³¶û{ÀO*©Ú5Fë™MuŨ= MN‘Ëècˆ£ÀÃUÐs¨ÝÒ!tÌUªüEøjMe”·âæÓÇcùʤ'€–’»Ïüß cvÔȧȟ–‰Ô³=|÷·í¦Vȧ}ZðµN™¶¿Âìœþ—E \ø]ë_©‹¬W0“ß•@B—µqK ~>4ÕÒ2_ªcÛce«¢ «ü&rt@‡GàÓMœûÊdñÚ¸(°:ä´:Ù3fÚOOîÓ x^§ÅùʸŸ•råW†LÎR_B¾ñFµ hÞ«Áª!} 8— è½‹¦!‹7 §á]ç´= ·«Í~uÇ'‡5 §üysùÆ j–Am^€wOŹ(oMÿ™’=_Žùgê}¨QÑ>}b°ðšT•%ç÷ë4öÙá‚[bðR@3fGŸ-”š _±þ-©‚öÑ-oذ^öëhaAÈni“1²£Ø]ÓôVÁÕZ Ãâ ú¥ —ÒæR‡üÛºíu†]ª^¾8å8 ZH ÕhdÎ'œ·tEa£ìyJÎÉ5+®$_HÐ×åÈ놳÷u)Â+nà Ú`õâé°‹Ö†E»kðby–öuï«€žðûCz)õ„ù¢Ý‚æ…‘ÜB† Òñ¿|çó‹¥=; މAÿö0ˆ©±Œ•„ø< tà_öìgÛœö¶ƒ|o®ªl£‹Ï"¸ÌEà—G ˜o ¾Ô)1Zƒ¿©P)vy÷±‚GÐÍU¸_½è˜çÖÀÓKMûbÀ{!· ²ªL³^б)𬯑À:ߌ·¹!2Š 9úŒÆÈ\K؇0³ ê5Ó)GÎ$̪VI>a,aQi$º‹m˜ÝWI¿÷g㩹üe«+K9ŽÕôªIƒeœewÐ93ö“Âp‚´÷5”Ö&X–ÝcJs†:j½cvyd-Y|$‹ˆ ³DÄK¶Æ¤D'AŠZ~9×½k×笇–¯•JNP½¨NýÕ—ÞA7kï£ÀCej¡„?»¦˜¢íF—²¯l tŠ»±$t3Òop?ؤ˜†·mÑ4DwÖ€¶Ö›<ÇK–×HM@íèóœ²ÆègÒn¯‡æ2µPOŽO)?ò{ƵM /€ŒnbhN™ëëyLï¨7ûØX?’ Á«7J샎b¥[4ip«OPq—:£ùíáz]eC`ò²0°«±ü¯üù¸,^Ì%µôYË£³ÁªŸIÃo|\È«Úçµb6H¹î3÷,3hNoéMfåƒ,Ûë•tÜ ÆÜ4ÏVÜ'ë¸l­+'è‰4üBMÕyÈèvÖË<dt°Ýé°±;OÐðEµOå5n4IóVÆAK~¿ÕÑÚøH‹ò”Þs7º,èÁ œjÀcÐBïÅAꤟ´J¹|4P„b%'Oæ6°¥!lH"Z¯XM"o(CLÿˆ°\Y ÖÚO-QV2içç7À-½ˆ…^[[úî?M„çG•%ýnºù€'€ŒnÖc˜­nuàåQÿ0ðÎep¯qŸo†áÜѽ~‚0¹M½µñ¯´$3„Æ÷æ$÷ɽ—A„³£ÒMþÎAP¹š†½ª){ÜXÉjåk­<çlÞÉ‘)sc6/içÔi¿Xn{Þë>ðý¼Cˆ¯c.¾Úó&ìa=ßç¹an&‹vŒ«- wÇÊÿÊ7&”Nµ!tžP½.îF˜=’“ø iVfç1ÈaæX ÿßòˆ³ÜX÷qš1c{0ø0˜ŽÎ¡éµnù¤#ê ö8XE-Âü10ÅÆ}‚†«k`£\¦?cA枬aVéRj*ý«4ࣲÒç9昰»l·}¢@Ðð1Õmoά -ˆª…ö’Fs6œÛ^_ZÏi0c}ÝÎJCÝlZ®YĹÕjMÀ«cþ«¹wÈ!Hâå…G5‡Atž£§C>ÒX|a½ªJc45›f¡ÙnûPRmD$KLƒ]êíµ -È\–Ïcõ7XQ[|¯Å©ÁÕa–8Åš±Ž4§«ê yÜö‡›L4Z aIŦ¤šZè—1œºúGZ‚7©êŠº¼í4ÏË¡ )¶`˜™‰—“yÜö(ìPóœ_¸b" ’uëwcõ‚l ˜3¤sç‹jî·†pª,Žç‰!?Þ(å¿ô‰ùá¶ß4Zè,3^´h0K¯òÉ•ï¦0r;»jHK¯úhŸíõÊ6Ž:aßmƒd.K?ûœ«à®9?qÎá»k€ÂYðÜ" 7)ŸxCœóíî¹ sY ÆOmB½ºÖ¿ßâ#*q¾Æöø™¹ì:«; 2¤Á'š¥û—X²à¶ßÐ :Ǥ­ÑoÉM_銺êú2<ï· ²†ætKÝàZµ}¢É•?X Îó@:xÃ\׫×LmãKœ މ þé»ib-ýo¬sö* î”Q¨óÂBÄyžh!3üŸdŽ»<êCœE~¾«‰!ú1[u O¶ÂG[\˯‹¡Êôç[9¢ Çpžûï6›f—;â\ yÎÔTa^@ÊÈ»[MÓxŸóÎzÊ‚Ì#‰ñ†ÉÛ£ðÇí9Äyo¡¯Ð¬Á(:ß±“©²FË`|_”ÑÉtAæ°êeÃqŠš4åé?çGœ]ž#FKÐØˆFˆ0'¥f˜ 2OÅA7_À*µÞ<*óné  ¹IAdVYüf\0…àËA³/µ…á[1À v'ÝŤîþÂËœ’.ˆ¹ÊIEND®B`‚mawk-1.3.4-20240123/icons/mawk48.svg0000644000000000000000000001045212020166305015013 0ustar rootroot Mawk image/svg+xml Mawk August 31, 2012 Thomas E. Dickey M AWK mawk-1.3.4-20240123/makescan.c0000644000000000000000000000513612773576071014021 0ustar rootroot/******************************************** makescan.c copyright 2009-2010,2016, Thomas E. Dickey copyright 1991, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: makescan.c,v 1.11 2016/09/30 23:58:49 tom Exp $ */ /* source for makescan.exe which builds the scancode[] via: makescan.exe > scancode.c */ #include #include #include "nstd.h" #include "scancode.h" char scan_code[256]; static void scan_init(void) { register char *p; memset(scan_code, SC_UNEXPECTED, sizeof(scan_code)); for (p = &scan_code['0']; p <= &scan_code['9']; p++) *p = SC_DIGIT; scan_code[0] = 0; scan_code[' '] = scan_code['\t'] = scan_code['\f'] = SC_SPACE; scan_code['\r'] = scan_code['\013'] = SC_SPACE; scan_code[';'] = SC_SEMI_COLON; scan_code['\n'] = SC_NL; scan_code['{'] = SC_LBRACE; scan_code['}'] = SC_RBRACE; scan_code['+'] = SC_PLUS; scan_code['-'] = SC_MINUS; scan_code['*'] = SC_MUL; scan_code['/'] = SC_DIV; scan_code['%'] = SC_MOD; scan_code['^'] = SC_POW; scan_code['('] = SC_LPAREN; scan_code[')'] = SC_RPAREN; scan_code['_'] = SC_IDCHAR; scan_code['='] = SC_EQUAL; scan_code['#'] = SC_COMMENT; scan_code['\"'] = SC_DQUOTE; scan_code[','] = SC_COMMA; scan_code['!'] = SC_NOT; scan_code['<'] = SC_LT; scan_code['>'] = SC_GT; scan_code['|'] = SC_OR; scan_code['&'] = SC_AND; scan_code['?'] = SC_QMARK; scan_code[':'] = SC_COLON; scan_code['['] = SC_LBOX; scan_code[']'] = SC_RBOX; scan_code['\\'] = SC_ESCAPE; scan_code['.'] = SC_DOT; scan_code['~'] = SC_MATCH; scan_code['$'] = SC_DOLLAR; for (p = &scan_code['A']; p <= &scan_code['Z']; p++) p[0] = p['a' - 'A'] = SC_IDCHAR; } static void scan_print(void) { time_t now = time((time_t *) 0); register char *p = scan_code; register int c; /* column */ register int r; /* row */ printf("/*\n * %cMawkId%c\n * generated by makescan.c\n * date: %s */\n", '$', '$', ctime(&now)); printf("#include \"scancode.h\"\n"); printf("/* *INDENT-OFF* */\n"); printf("char scan_code[256] = {\n"); for (r = 1; r <= 16; r++) { for (c = 1; c <= 16; c++) { printf("%2d", *p++); if (r != 16 || c != 16) putchar(','); } putchar('\n'); } printf("} ;\n"); printf("/* *INDENT-ON* */\n"); } int main(void) { scan_init(); scan_print(); return 0; } mawk-1.3.4-20240123/mawk.h0000644000000000000000000001562514530765370013202 0ustar rootroot/******************************************** mawk.h copyright 2008-2021,2023 Thomas E. Dickey copyright 1991-1995,1996 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: mawk.h,v 1.67 2023/11/27 01:03:52 tom Exp $ */ /* mawk.h */ #ifndef MAWK_H #define MAWK_H #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include #ifdef HAVE_STDNORETURN_H #include #undef GCC_NORETURN #define GCC_NORETURN STDC_NORETURN #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #ifndef GCC_PRINTFLIKE #define GCC_PRINTFLIKE(fmt,var) /* nothing */ #endif #ifndef GCC_UNUSED #define GCC_UNUSED /* nothing */ #endif #if defined(__GNUC__) && defined(_FORTIFY_SOURCE) #define IGNORE_RC(func) ignore_unused = (int) func extern int ignore_unused; #else #define IGNORE_RC(func) (void) func #endif /* gcc workarounds */ #ifdef DEBUG #define YYDEBUG 1 extern int yydebug; /* print parse if on */ extern int dump_RE; #endif #if defined(MSDOS) || defined(__MINGW32__) || defined(_WINNT) #define USE_BINMODE 1 #else #define USE_BINMODE 0 #endif extern short interactive_flag; extern short posix_space_flag; extern short traditional_flag; #ifndef NO_INTERVAL_EXPR extern short repetitions_flag; #endif /*---------------- * GLOBAL VARIABLES *----------------*/ /* a well known string */ extern STRING null_str; /* a useful scratch area */ extern char string_buff[SPRINTF_LIMIT]; /* help with casts */ extern const int mpow2[]; /* these are used by the parser, scanner and error messages from the compile */ extern char *pfile_name; /* program input file */ extern int current_token; extern unsigned token_lineno; /* lineno of current token */ extern unsigned compile_error_count; extern int NR_flag; extern int paren_cnt; extern int brace_cnt; extern int print_flag, getline_flag; extern short mawk_state; #define EXECUTION 1 /* other state is 0 compiling */ #ifdef LOCALE extern char decimal_dot; #endif extern const char *progname; /* for error messages */ extern unsigned rt_nr, rt_fnr; /* ditto */ #define TABLESIZE(name) (sizeof(name)/sizeof(name[0])) /* macro to test the type of two adjacent cells */ #define TEST2(cp) (mpow2[(cp)->type]+mpow2[((cp)+1)->type]) /* macro to get at the string part of a CELL */ #define string(cp) ((STRING *)(cp)->ptr) #ifdef DEBUG #define cell_destroy(cp) DB_cell_destroy(cp) #else /* Note: type is only C_STRING to C_MBSTRN */ #define cell_destroy(cp) \ do { \ if ( (cp)->type >= C_STRING && \ (cp)->type <= C_MBSTRN ) { \ unsigned final = string(cp)->ref_cnt; \ free_STRING(string(cp)); \ if (final <= 1) { \ (cp)->ptr = NULL; \ } \ } \ } while (0) #endif /* prototypes */ extern void cast1_to_s(CELL *); extern void cast1_to_d(CELL *); extern void cast2_to_s(CELL *); extern void cast2_to_d(CELL *); extern void cast_to_RE(CELL *); extern void cast_for_split(CELL *); extern void check_strnum(CELL *); extern void cast_to_REPL(CELL *); extern Int d_to_I(double); extern Long d_to_L(double); extern ULong d_to_UL(double d); #define d_to_i(d) ((int)d_to_I(d)) #define d_to_l(d) ((long)d_to_L(d)) extern int test(CELL *); /* test for null non-null */ extern CELL *cellcpy(CELL *, CELL *); extern CELL *repl_cpy(CELL *, CELL *); extern void DB_cell_destroy(CELL *); extern void overflow(const char *, unsigned); extern void rt_overflow(const char *, unsigned); extern GCC_NORETURN void rt_error(const char *,...) GCC_PRINTFLIKE(1,2); extern GCC_NORETURN void mawk_exit(int); extern void da(INST *, FILE *); extern INST *da_this(INST *, INST *, FILE *); extern char *rm_escape(char *, size_t *); extern char *re_pos_match(char *, size_t, PTR, size_t *, int); extern int binmode(void); #ifndef REXP_H extern char *str_str(char *, size_t, const char *, size_t); #endif extern void parse(void); extern void scan_cleanup(void); #ifndef YYBYACC extern int yylex(void); #endif extern void yyerror(const char *); extern GCC_NORETURN void bozo(const char *); extern void errmsg(int, const char *, ...) GCC_PRINTFLIKE(2,3); extern void compile_error(const char *, ...) GCC_PRINTFLIKE(1,2); extern void execute(INST *, CELL *, CELL *); extern const char *find_kw_str(int); extern void da_string(FILE *fp, const STRING *, int); extern void da_string2(FILE *fp, const char *, size_t, int); #ifdef HAVE_STRTOD_OVF_BUG extern double strtod_with_ovf_bug(const char *, char **); #define strtod strtod_with_ovf_bug #endif #ifndef OPT_CALLX #define OPT_CALLX 0 #endif #if OPT_TRACE > 0 extern void Trace(const char *, ...) GCC_PRINTFLIKE(1,2); extern void TraceVA(const char *, va_list); #define TRACE(params) Trace params #if OPT_TRACE > 1 #define TRACE2(params) Trace params #endif #endif #ifndef TRACE #define TRACE(params) /* nothing */ #endif #ifndef TRACE2 #define TRACE2(params) /* nothing */ #endif #if OPT_TRACE > 0 extern void TraceCell(CELL *); extern void TraceString(STRING *); extern void TraceString2(const char *, size_t); #define TRACE_CELL(cp) TraceCell(cp) #define TRACE_STRING(cp) TraceString(cp) #define TRACE_STRING2(str,len) TraceString2(str,len) #else #define TRACE_CELL(cp) /* nothing */ #define TRACE_STRING(cp) /* nothing */ #define TRACE_STRING2(str,len) /* nothing */ #endif #if OPT_TRACE > 0 extern void TraceFunc(const char *, CELL *); #define TRACE_FUNC(name,cp) TraceFunc(name,cp) #else #define TRACE_FUNC(name,cp) /* nothing */ #endif #if OPT_TRACE > 0 extern void TraceInst(INST *, INST *); #define TRACE_INST(cp,base) TraceInst(cp,base) #else #define TRACE_INST(cp,base) /* nothing */ #endif extern const char *da_type_name(CELL *); extern const char *da_op_name(INST *); #ifdef NO_LEAKS extern void free_cell_data(CELL *); extern void free_codes(const char *, INST *, size_t); extern void no_leaks_cell(CELL *); extern void no_leaks_cell_ptr(CELL *); extern void no_leaks_re_ptr(PTR); extern void array_leaks(void); extern void bi_vars_leaks(void); extern void cell_leaks(void); extern void code_leaks(void); extern void field_leaks(void); extern void files_leaks(void); extern void fin_leaks(void); extern void hash_leaks(void); extern void re_leaks(void); extern void rexp_leaks(void); extern void scan_leaks(void); extern void trace_leaks(void); extern void zmalloc_leaks(void); #else #define free_codes(tag, base, size) zfree(base, size) #define no_leaks_cell(ptr) /* nothing */ #define no_leaks_cell_ptr(ptr) /* nothing */ #define no_leaks_re_ptr(ptr) /* nothing */ #endif /* * Sometimes split_buff[] pointers are moved rather than copied. * Optimize-out the assignment to clear the pointer in the array. */ #ifdef NO_LEAKS #define USED_SPLIT_BUFF(n) split_buff[n] = 0 #else #define USED_SPLIT_BUFF(n) /* nothing */ #endif #endif /* MAWK_H */ mawk-1.3.4-20240123/CHANGES0000644000000000000000000012061214554032361013047 0ustar rootroot-- $MawkId: CHANGES,v 1.376 2024/01/23 21:51:45 tom Exp $ 20240123 + improve manpage style/formatting. + improve conversion of parameter of srand() when using srandom() (Original-Mawk #66). + minor improvement for configure script 20231210 + correct interator type in REcompile (Original-Mawk #73) + improve configure script check for arc4random + reduce compiler warnings in configure script checks 20231126 + fix a couple of problems reported by Coverity: + modify cell_destroy() to set the string pointer to NULL if zfree() might have freed it. + replace a couple of strcpy's with loop. + eliminate a fixed-size array in re_cmpl.c + change casts in strftime() and srand() to avoid truncation on 64-bit machines (report by John Naman). 20231102 + environment-fixes for building with Solaris 10. 20231101 + repair parsing for comma-separated -W options used in "#" lines (report by Leif Baron). + updated makedeps.sh and examples/deps.awk, to update Makefile.in + remove obsolete/incorrect zero-termination assignment from fillbuff() (Original-Mawk #71). + updated configure macros + update config.guess and config.sub 20230816 + start work on _CALLX + da.c: replace most of the string-literals in fprintf's with result from da_op_name() + da.c, mawk.h: simplify ifdef for da_op_name(), to reuse in refactoring of _CALL + da.c: dumping the function name in front of the offset is distracting, use just "@" + da.c: make the trace show offsets like the -Wdump option + da.c: add traces to show which function is being dumped (and possibly patched). this improves on the fix for dump_funcs() as well, freeing the linked-list + code.c: fix a use-after-free when no-leaks and traces are combined. + code.c: add trace to be_setup() + parse.y: make trace message consistent with fcall.c + execute.c: eliminate a couple of comparisons + change SYMTAB_TYPES to mixed enum/masks, to reduce comparisons for array types. + some cleanup, using NUM_ARGS and SYM_TYPE typedefs. 20230808 + modify input buffer-resizing to improve performance with very long longs (report/testcase by Leif LeBaron). 20230804 > fixes for nulls (patches by Miguel Pineiro Jr). + support nulls in toupper() and tolower(). + modify str_str() to ensure lengths for key/target are large enough for the memcmp() call. + treat special case of failure to open input file due to too many open files as a fatal error (report/testcase by Christoph Brunhuber). + fix a shift/reduce conflict for length vs length() + quote string-parameter in a few error-messages + add MinGW-code for system() calls (Original-Mawk #51). 20230730 + rexp.c: do not unroll repetition into loops if the repetition applies to more than one character. + rexp3.c: increment machine on completing M_2JC step to fix a case with infinite loop. + print.c: improve parameter-passing, eliminating a duplicate check. 20230726 + modify makefile to install mawk-array and mawk-code manpages. 20230725 + use da_string more consistently in dumps. + improve scanner to some type-checks of arrays versus scalars by deferring this into the runtime execution (report by Rajeev V Pillai). 20230716 + modify scanner to accommodate scripts which use the same name for some function-parameters as for a function (report by Kaz Kylheku). + amend/limit special case optimization for redundant wildwards (Original-Mawk #36). + regenerate parse.c using byacc 20230521 20230525 + fix a regression for big-endian machines caused by mismatch between printf/sprintf format and long integer types (Original-Mawk #69, cf: 20200731). 20230404 + add a null-pointer check in bi_mktime() (Original-Mawk #57). + cast parameter of srand() to double if it is not already (patch by "q3cpma", Original-Mawk #66). + manpage fixes (report/suggested by David Apps). + fix parsing of "--" token on command-line, from 20200828 changes (report by Pavel Vinogradov). + add a null-pointer check in the case for "-W" when parsing command options (Original-Mawk #68). + improve CF_XOPEN_SOURCE configure macro to avoid clearing the host's definition for _XOPEN_SOURCE if _POSIX_C_SOURCE is defined (report by A. Wilcox). + modify makefile "clean" rule to remove ".i" files. + modify configure script to allow for using clock_gettime vs gettimeofday. 20230322 + remove an unwanted string/number conversion in print.c, from changes in 20200717 (report by Jan Psota). + reduce compiler-warnings in configure script checks. 20230215 + update URLs, changing ftp to https + modify configure.in, moving checks for standard headers before the options, to improve check for arc4random (Redhat #2167291). 20230203 + split up do_printf to fix build with fortified mingw stdio.h + reduce compiler-warnings in configure script checks. 20221229 + fix shellcheck warnings in test-scripts. + updated configure macros + update config.guess, config.sub, and install-sh 20210824 + updated configure macros + update config.guess and config.sub 20210528 + add FreeBSD build-scripts, for test-builds + updated configure macros + update config.guess and config.sub 20201023 + start work on experimental approach to interval-expressions which does not involve loop-unrolling. + improve type-checking for builtin-regex's by using PTR only for the external-regex's. + improve dump format, showing intervals in curly-brace format. 20201016 + improve dump format, showing the jump-targets rather than offsets. 20201009 + show limits for brace-expressions in dump. + change RE_panic to stdarg, and log its message in trace file 20200925 + improve compatibility vs gawk/bwk in gsub handling of backslash by only escaping backslash with itself if those backslashes happen to precede a "&", e.g., "\\&" vs "\\" (Original-Mawk #14). + fix a regression in recent command-line option parsing. + modify configure/makefile to use .PHONY if available. + review/improve example-scripts 20200918 + build-fix for HP-UX 11.23, which lacks #define's for maximum of int64_t and uint64_t + build-fix for OpenBSD, which mis-types int64_t, just like macOS. + build-fix for macOS, which mis-types int64_t 20200911 + improve range of printf/sprintf for decimal formats by using the unsigned limit if the value is positive. + improve checks for command-line numeric options. + allow long-options to be abbreviated. 20200828 + modify configure script to move gcc -Werror flags to EXTRA_CFLAGS to avoid breaking configure-checks. + use sprintf-buffer for intermediate output of strftime, to handle extra-long format strings. + modify MAWK_LONG_OPTIONS "ignore" to limit that to the "-xxx" options in this set of changes, plus the existing --lint/--lint-old options. + allow -Wxxx options to use long-option format as -xxx, for better script-compatibility with gawk. + use standard output for -Whelp, but show usage message in standard error when no command arguments are given. + print version for -Wversion consistently in standard output. + improve use of const for making tables readonly. + change -W compat to -W traditional for better script-compatibility with gawk. 20200821 + completed first draft of mawk-code.7 20200807 + begin man/mawk-code.7 + drop noweb dependency, move docs to man/mawk-arrays.7 20200731 + amend fix for Debian #303825 to more closely match gawk and BWK. Those use larger data types, e.g., long vs int, for limits, and also provide for using int64_t and uint64_t. Internally, mawk now uses long long's where those are supported. + add --help and --version options 20200724 + modify logic for "{0}" in rexp.c so that a left-parenthesis is not trimmed when cancelling the previous token. + modify RE_cat to add a dummy M_ACCEPT as a workaround for logic in the new RE_init_it_cnt and RE_set_limit functions. + modify regexp_system.c to work with interval-expressions. + recognize gawk's --traditional and --posix as aliases for mawk's -W options, as well as -r and --re-interval to improve scripting compatibility. + add -W compat and -W posix, using the former to replace -W repetitions and the latter to replace -W posix_space + enable interval-expressions by default. 20200717 + add configure option "--disable-interval-expr" > integrated/adapted changes by James Parkinson (jlp765): + add regexp intervals, + add tests for intervals to test/mawktest and associated test/repetitions files, + add -W repetitions to enable r{m,n} + add man page updates to man/mawk.1 20200708 + update manpage comment about "nextfile" (AustinGroup #607). + amend manpage comment about "fflush" (AustinGroup #634). + amend manpage comment about "delete array" (AustinGroup #544). + updated configure macros + update config.guess and config.sub 20200120 + resync with my-autoconf. + fix typos found with codespell. + when reading input in interactive mode, provide for extending the buffer size for very long lines (Original-Mawk #59). 20200106 + correct line-number shown in too-many-arguments error message for the case where the function is a forward reference (report by "mukti"). + fix install for manpage when configure --srcdir option is used (report by Rajeev V Pillai). + use both CFLAGS/LDFLAGS when linking in makefile (report by Rajeev V Pillai). + fix clang-9 warning in bi_funct.c (report by Rajeev V Pillai). + minor improvement to gcc warning options, from vile 20191231 + updated configure macros + update config.guess and config.sub 20190203 + improve manpage formatting, e.g., for man2html + improve debug-traces 20190129 + eliminate non-portable tdestroy() from zmalloc no-leaks code. + updated configure macros + update config.guess and config.sub 20181114 + revert a change for memory-leaks which made the forced-exit via a user function inconsistent with earlier versions (report by Andre Sihera). + amend a change for memory-leaks to avoid a double-free (Original-Mawk #56). 20171017 + add Debian compile/link flags to test-package. + cleanup spurious warnings from latest gcc. + changes for Original-Mawk #48: + add checks for stack overflow and underflow + increase stack limit to 1024 + updated configure macros + update config.guess and config.sub 20161120 + add runtime check for assignments to OFMT and CONVFMT to ensure they use a single parameter (Original-Mawk #47). + repair build for --with-valgrind, broken in 20160930 const-fixes. 20161107 + correct sign-extension from 20160615 change to rand() (report by Christian Neukirchen). 20160930 + optimize closes on regular expressions to filter out redundant wildcards, fixing a special case leftover by changes in 20100224 (Original-Mawk #34). + add regular-expressions to the -Wdump option when using mawk's built-in regular expressions. + fix a sign-extension in character-class parser (Original-Mawk #46). + minor optimizations. + improve use of const in tables. 20160927 + allow single-quote as a flag in printf, to complete the change for LC_NUMERIC in 20121129 (report by Graham Monteith). + revert one of the fixes made for a Coverity warning about loss of precision in 20121209, which unnecessarily exposed a different problem (Original-Mawk #45). 20160918 + simplify "system()" function by calling C "system()" function, and use POSIX macros for wait-status to provide a less-ambiguous return value (suggested by Aharon Robbins). + add a null-pointer check in bi_mktime (patch by Ismael Luceno). 20160905 + escape '/' in range for test/reg4.awk to allow test-comparison with gawk and BWK. + updated configure macros, e.g., for compiler warnings and static analysis: + CF_CC_ENV_FLAGS + CF_GNU_SOURCE + CF_PROG_LINT + CF_RAND + CF_XOPEN_SOURCE + minor build-fix for HPUX 11.11 "make", which is confused by the recursive use of "make" in clean/distclean rules. + amend fix for Gentoo #424137 to eliminate a memory leak when opening files (Original-Mawk #44). + update config.guess and config.sub 20160615 + correct range when using system rand() function, which was 0..2 rather than 0..1 on BSD systems (report/patch by Masaki Waga). 20160313 + correct order of checks for machine state in REtest which caused an out-of-bounds reference (Original-Mawk #36). 20160226 + update COPYING from https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt (Original-Mawk #38). + minor updates to configure script macros + update config.guess and config.sub 20150503 + add --with-man2html configure option + improve description of -W options and how they can be combined into a comma-separated list (adapted from Leif LeBaron). + modify parsing for -Wexec to permit its value to be separated by '=' in addition to a space, for consistency with the other -W options. + cosmetic changes to configure script macros, from work on xterm. + update config.guess and config.sub 20141206 + Mawk behaves incorrectly when using the nextfile statement. It marks the file as dead, but does not check such state and thus ends reading from a closed fd (patch by Ismael Luceno). 20141027 + remove a special check for anchored regular expressions in gsub3 which did not handle expressions with "|" alternation (report by "Ypnose"). 20140914 + rename vs6.mak / vs6.h to vs2008 for Visual Studio 2008 compiles. + remove MS-DOS support. + add a check in split for empty regex, treating that the same as an empty string (Original-Mawk #9). + correct inconsistently-ifdef'd reset of errno in check_strnum() function, which caused some values to be internally classified as strings rather than strnums (Original-Mawk #26). + add parameter to REmatch to control use of REG_NOTBOL and its equivalent in mawk (prompted by discussion with Mike Brennan, Original-Mawk #24). + settle on "gsub3" implementation (suggested by Mike Brennan, Original-Mawk #11). + change default for configure option --enable-init-srand to enable this (discussion with Mike Brennan). + add -W random option to set initial srand() seed. + add TraceVA, use to provide debug-traces for errmsg(). + add note in manpage about "nextfile", see for example: http://www.opengroup.org/austin/docs/austin_578.txt http://austingroupbugs.net/view.php?id=607 + make it possible to build with "bsd" library ported to Linux by setting LIBS=-lbsd before running configure script. + show random-function names in version message, as well as maximum integer-value. + modify initialization of srand default seed from time of day to use gettimeofday, etc., so that successive runs of mawk are less likely to use the same seed value (suggested by Mike Brennan). + make a further refinement, "gsub3" which uses a single pass. + change SType and SLen types to improve performance as well as handling larger regular expressions (suggested by Mike Brennan). + fix some minor issues reported by Coverity. + regenerate parse.c using byacc 20140422 + modify makefile-rule for generating parse.c to keep the "#line" preprocessor lines consistent with the actual filename. This is needed by lcov. + add test/reg7.awk to help with recent testing. + discard intermediate new_gsub used for regression-testing, will do further improvements based on "gsub2". + fix a comparison in rexp3.c to work with embedded nulls (patch by Mike Brennan). + in-progress changes to implement "gsub2", which will reduce copying. + discard intermediate old_gsub used for regression-testing, using original gsub function renamed to "gsub0" for that purpose. + remove old compiler information from version message. + remove NF value from version message. + patches by Mike Brennan: + changed the intermediate storage of STRINGS used by split. + cleaned up the xxx_split() functions. a) removed hand loop unrolling. What was an optimization for intel 8086/88 is silly today. b) consequence of a) some macros went away so the code is easier to read/understand. c) handles null in input string Note: re_split() does \x00 null correctly, but it calls REmatch() which does not. I have examples where REmatch works with nulls and examples of not working. That needs to be fixed. + changed field allocation to support no upper limit. + when comparing two strings, allow for embedded nulls. + add checks in rexp3.c for infinite loop for testcase noloop.awk (report by Tibor Palinkas). + improve test-package for debian by adding postrm script to restore "mawk-base" to its unalternatized configuration, as well as adding messages to the other pre/post scripts. + patches by Mike Brennan: + increase some limits: NF is now 1048575, sprintf limit is 8192. + updated array.w; mostly documentation improvements + add array.pdf generated from array.w + add -Wu / -Wusage / -Wh / -Whelp to show usage message, like gawk. If long options are enabled, honor --help and --usage as well. + if no command-line parameters are given, show usage message like gawk and BWK (report by Michael Sanders). + improve configure macros CF_ADD_CFLAGS, CF_ADD_LIBS, CF_XOPEN_SOURCE, e.g., for Minix3.2 port. + restore in-progress change to gsub; resolved problem handling its internal use of vectors for second parameter when "&" marker is used. + improve configure check for Intel compiler warnings; trim unwanted -no-gcc option. + for Solaris suppress the followup check for defining _XOPEN_SOURCE + update config.guess and config.sub 20131226 + add configure check to work around recent breakage in Cygwin's math.h which declares _LIB_VERSION without allowing it to be updated (report by Gert Hulselmans). + minor updates to configure script, for clang and mingw + update config.guess and config.sub 20130803 + minor updates to configure script + add limit-checks, improve index computation in scan.c to fix old 1.3.3 problems with very long string-literals in the parsed script (report by Marcin Krol). + update config.guess and config.sub 20130219 + modify missing-operand check in rexp.c to allow the case of empty "()", matching behavior of gawk and BWK (report by Arkadiusz Miskiewicz). + revert in-progress change to gsub retain ifdef'd for additional development since it did not handle array as the second parameter (report by Arkadiusz Miskiewicz). 20121209 + build-fix for cygwin in matherr.c, which declares a different type for _LIB_VERSION + add missing "-f" option in examples/gdecl.awk + fix a regression in fflush, ensuring that it returns an error if the argument does not match any output filename (report by Nathan Weeks). + modify wording of configure --help message to make it clear that the default for --with-builtin-regex uses the builtin regular expression engine of mawk. + fix issues reported by Coverity scan. Most of these were minor, and were addressed by modifying the source to allow Coverity to improve its analysis of the code. + amend support for LC_NUMERIC by translating period to the local decimal separator as needed to work with strtod() which is used to validate decimal constants when scanning source files. This fixes an infinite loop with mawk 'BEGIN { print 1.0 }' (report by Jan Psota). + regenerate man/mawk.doc, overlooked in previous updates. 20121129 + change behavior if internal fflush call fails: rather than exiting with an error, propagate the return value to the script as -1, for consistency with gawk and BWK (discussion with Aharon Robbins and Nathan Weeks). + add special case for forward reference to a function using an array parameter, updating the function's parameter type so that the array is passed properly. + support length(array), as done in gawk and BWK awk (Original-Mawk #1). + support LC_NUMERIC, which will modify the displayed decimal point in some locales. It does not modify the decimal point used for input, matching the behavior of nawk and BWK awk (prompted by request from Yechiel Bardov for thousands-separator). + add configure option --enable-init-srand to allow choice whether to initialize random numbers automatically at startup or not. Not doing this makes programs more predictable (Debian #63843, Original-Mawk #3). + add configure option --enable-builtin-srand, use that to deprecate mawk's builtin srand/rand functions which generally are not as good as the system-provided functions. + extend --enable-trace configure option to show builtin functions. + add systime and mktime functions + when warning about unrecognized options, do not exit with error on these gawk options: --lint --lint-old --posix --re-interval --traditional + integrate strftime function (patch by Dominic Letz, Original-Mawk #2). + correct logic for "/dev/stdin" special device (GenToo #424137, Original-Mawk #17). + updates for configure script macros: + modify configure script and makefile to support cross-compiles. + remove Turbo C++ and Zortech C++ makefiles. + remove obsolete function-checks: fmod, memcpy, strchr, strerror, strtod, vfprintf. + remove obsolete checks for some headers: math.h, stdarg.h, stdlib.h, string.h time.h + support --datarootdir option. + add 3rd parameter to AC_DEFINE's to allow autoheader to run. + remove unused macros. + update config.guess and config.sub + add icons for webpage artwork 20120627 + add "/dev/stdin" name for stdin for consistency with other implementations of awk (suggested by Aharon Robbins). + improve overflow check in check_strnum() (Ubuntu #485574). + implement gawk extension "nextfile" (suggested by Aharon Robbins). + updates for configure macros CF_ANSI_CC_CHECK, CF_ENABLE_TRACE, CF_GCC_ATTRIBUTES, CF_GCC_WARNINGS, CF_MAKE_TAGS, CF_MSG_LOG, CF_REGEX, CF_XOPEN_SOURCE. + update config.guess and config.sub 20101210 + update copyright notices to reflect changes made starting 20080909. This commit was made in May 2012, updates only copyright notices needed for project registration on Savannah as discussed in Debian #554167. However, since current policy on Savannah discriminates against GPLv2, it will be hosted elsewhere. See http://invisible-island.net/mawk/ http://github.com/ThomasDickey 20101207 + add configure --enable-trace, to consolidate various debugging traces which were written to stderr. This writes to Trace.out. + modify zmalloc.c to make it simpler to use the --disable-leaks configure script option to analyze memory leaks. The memory pool which interferes with analysis can be disabled by defining DEBUG_ZMALLOC. + (IN-PROGRESS) convert gsub() function from recursive, to non-recursive to lessen use of program stack (Debian #158481). + escape some dashes in manpage, to work with groff. + change section for Debian package to "interpreters" (Debian #442071). + fix printable token value for SC_MATCH in scan.c (report by Heiner Marxen). 20100625 + correct translation of octal and hex escapes for system regular expression library. + modify configure script to support --program-suffix, etc. + add Debian package scripts, for "mawk-cur". + add RPM spec-file. + move release- and patch-level values from version.c to patchlev.h to simplify packaging scripts. 20100618 + correct translation of "^{" pattern for system regular expression library (report by Elias Pipping). + fix sentence fragment in README (report by Elias Pipping). 20100507 + cleanup gcc warnings for 64-bit platform, e.g., use size_t rather than unsigned, etc. + fix warnings from clang --analyze + update/improve configure script + modify CF_GCC_VERSION to ignore stderr, e.g., from c89 alias + modify CF_GCC_WARNINGS, moving -W and -Wall into the list to check, since c89 alias for gcc complains about these options. + add --disable-leaks and related options, for testing. + add lint rule to makefile. + add configure-check for ctags to work with pkgsrc. + amend change of array.w, fixes a regression in "delete" (report by Heiner Marxen). 20100419 + modify split() to handle embedded nulls in the string to split, e.g., BEGIN{s="a\0b"; print length(s); n = split(s,f,""); print n} (report by Morris Lee). + modify array.w to update table pointers in the special case where an array is known to have string-indices, but is later indexed via integers. The problem occurs when the array grows large enough to rehash it, e.g., BEGIN{a["n"];for(i=1;i<1000;++i)printf "%d\n", a[i]; } (report by Morris Lee). + increase size of reference-count for strings to unsigned. It was an unsigned short, which prevented using arrays larger than 64k, e.g., BEGIN{for(i = 1; i <= 65550; ++i){if(i >= 65534 && i<= 65537) print i; s[i] = "a"}; delete s;} (report by Morris Lee). + add special case for Solaris 10 (and up) to configure check CF_XOPEN_SOURCE + refactored configure check CF_REGEX 20100224 + add a configure check for large files (report by Sean Kumar). + modify check in collect_RE() to show the actual limit value, e.g., MIN_SPRINTF-2 used for built-in regular expressions. + increase MIN_SPRINTF, used as limit on regular-expression size, to match the MAX_SPLIT value, i.e., slightly more than doubling the size (report by Markus Gnam). + further modify makefile to build outside the source-tree. + modify makefile and mawktest to use relative path again, since the existing script did not work with openSUSE's build (patch by Guido Berhoerster). + fix makefile's .c.i rule, which lacked CPP definition. + update mawktest.bat script to more/less correspond with mawktest, for Win32 console except where echo command does not handle the required quoting syntax. + add vs6.mak, for Visual Studio 6. + modify mawktest script to report results from all tests, rather than halting on the first failure. + add limit-check after processing match(test, "[^0-9A-Za-z]") to ensure the internal trailing null of the test-string is not mistaken for part of the string, i.e., RSTART, RLENGTH are computed correctly (report by Markus Gnam). + modify parsing of -W option to use comma-separated values, e.g., "-Wi,e" for "-Winteractive" and "-Werror". + add timestamp to scancode.c, to help manage revisions. + improve configure macro CF_XOPEN_SOURCE, making it remove possibly conflicting definitions before adding new ones. + update config.guess and config.sub > patches by Jan Psota: + improve buffering for -Winteractive option. + allow multiple single-character flags after -W, e.g., "-Wie" for "-Winteractive" and "-Werror" to permit these to be passed on a "#"-line of a shell script, e.g., #!/usr/bin/mawk -Wie > patches by Jonathan Nieder: + add new M_SAVE_POS and M_2JC operation codes (states) to the built-in regular expression engine. Use these to reimplement m* (closure), to provide a way to avoid infinite looping on matches against empty strings. This change requires reimplementing the workaround for gawk's noloop1 testcase from 20090726. + improve buffer-overflow check for string_buff. + fix collect_RE to treat "[^]]" as a character class (meaning "not a closing bracket") but "[^^]]" not as one. This also requires initializing the local "start of character class" variable to NULL rather than the beginning of the string, to avoid an invalid array access when collecting expressions such as "^text". + within a character class and not followed by a :, ., or ~, a "[" is just like any other character. This way, you can tell mawk to scan for a literal [ character with "mawk /[[]/", and you can scan for a [ or ] with "mawk /[][]/". Also clean up the relevant loop in do_class() to make it a bit more readable. + outside a character class, a "]" is just like any other character. + prevent do_class() from scanning past the end, e.g., if the terminating zero byte was escaped. + fix regular-expression parsing when a right parenthesis ")" is found without a preceding left parenthesis. + fix resetting of position stack when backtracking. + modify regular-expression engine to avoid exponential running time for some regular expression matches in which the first match mawk finds extends to the end of the string. This is a new fix for the gawk noloop2 test, added here for regression testing. 20091220 + bump version to 1.3.4 + update INSTALL and README files. + improve configure checks for math library. + change test for NaN to use sqrt() rather than log() to work around cygwin's partly broken math functions. + add/use isnanf() to work around other breakage in cygwin math functions. + add configure check for _XOPEN_SOURCE, etc., needed to define proper function pointer for sigaction, e.g., on Tru64. + add check for sigaction function pointer, whose POSIX form is absent from the cygwin header. + extend MAWKBINMODE, adding a third bit which when set will suppress the change for RS or ORS to use CR/LF rather than LF. This is used for MinGW to make the "check" rule in a build work, for instance. + add configure check for functions used for pipe/system calls, e.g., for MinGW where these are absent. + add runtime check for floating-point underflow exceptions + fix an old 1.3.3 bug in re_split(), which did not check properly for the end of buffer; this broke on Tru64. + drop obsolete config-user, v7 and atarist subdirectories + improve configure checks for sigaction, making the definitions used in fpe_check.c consistent with matherr.c + build fixes for AIX, Tru64. + add configure check for 'environ'. + remove redundant setlocale() calls; only LC_CTYPE and LC_NUMERIC are used. 20091213 + add makedeps.sh script to aid in updating object dependencies in Makefile.in + use "mkdir -p" rather than mkdirs.sh (suggested by Aleksey Cheusov). + reformatted this file, to simplify extraction of contributor names. + update config.guess and config.sub > patches by Jonathan Nieder: + modify CF_DISABLE_ECHO autoconf macro to ensure that command lines in Makefile.in begin with a tab. + the makefile does not use $(MAKE); remove the SET_MAKE substitution. + add some files to the "make clean" rule, in case make gets interrupted in the middle of a rule. + add a maintainer-clean rule to the makefile, to remove files which could be regenerated. + fix an unescaped "-" in man/mawk.1 + remove an unneeded cast in bi_funct.c + fix an unused parameter warning in matherr.c + drop unused line_no parameter from compile_error() and its callers. + convert makescan.c to ANSI C, do further cleanup of that file. + split-out scancode.h from scan.h 20090920 + improve hash function by using FNV-1 algorithm (patch/analysis by Jim Mellander). This greatly improves speed for accessing arrays with a large number of distinct keys; however the unsorted order in "for" loops will differ. + add "internal regex" or "external regex" string to version message to allow scripting based on support for embedded nulls. + drop obsolete CF_MAWK_PROG_GCC and CF_MAWK_PROG_YACC macros from configure script (report by Mike Frysinger). + fixes to allow build outside source-tree (report by Mike Frysinger). + correct logic in scan.c to handle expression "[[]" (report by Aleksey Cheusov). + add MAWK_LONG_OPTIONS feature to allow mawk to ignore long options which are not implemented. + two changes for embedded nulls, allows FS to be either a null or contain a character class with null, e.g., '\000' or '[ \000]': + modify built-in regular expression functions to accept embedded nulls. + modify input reader FINgets() to accept embedded nulls in data read from files. Data read from standard input is line-buffered, and is still null-terminated. + update config.guess and config.sub 20090820 + minor portability/standards fixes for examples/hical + add WHINY_USERS sorted-array feature, for compatibility with gawk (patch by Aharon Robbins). + correct lower-limit for d_to_U() function, which broke conversion of zero in "%x" format, added in fix for Debian #303825 (report by Masami Hiramatsu). + modify "%s" and "%c" formatting in printf/sprintf commands to ensure that "%02s" does not do zero-padding, for standards conformance (discussion with Aharon Robbins, Mike Brennan, prompted by Debian #339799). 20090728 + add fallback definitions for GCC_NORETURN and GCC_UNUSED to build with non-gcc compilers (report by Jan Wells). 20090727 + add check/fix to prevent gsub from recurring to modify on a substring of the current line when the regular expression is anchored to the beginning of the line; fixes gawk's anchgsub testcase. + add check for implicit concatenation mistaken for exponent; fixes gawk's hex testcase. + add character-classes to built-in regular expressions. + add 8-bit locale support 20090726 + improve configure checks for MAX__UINT. + add a check for infinite loop in REmatch(), to work with gawk's noloop1 testcase. + modify logic to allow setting RS to an explicit null character, e.g., RS="\0" (Ubuntu #400409). + modify workaround for (incorrect) scripts which use a zero-parameter for substr to ensure the overall length of the result stays the same. For example, from makewhatis: filename_no_gz = substr(filename, 0, RSTART - 1); + move regular-expression files into main directory to simplify building using configure --srcdir and VPATH. + modify internal functions for gsub() to handle a case from makewhatis script from man 1.6f which substitutes embedded zero bytes to a different value (report by Gabor Z Papp). + change default for configure --with-builtin-regex to prefer the builtin regular expressions. They are incomplete, but POSIX regular expressions cannot match nulls embedded in strings. + require standard C compiler; converted to ANSI C. + rename #define'd SV_SIGINFO to MAWK_SV_SIGINFO to avoid predefined name on Mac OS X (report on comp.lang.awk). + revise configure script to use conventional scheme for generating config.h 20090721 + port to cygwin, modifying test-script to work with executable-suffix and fp-exception code to allow const in declaration. 20090712 + bump patch-date. + fix Debian #127293 "mawk does not understand unescaped '/' in character classes", noting that gawk 3.1.6 also has problems with this area. + drop support for varargs; use stdarg only. + add tags rule to makefile. + rename configure option "--with-local-regexp" to "--with-builtin-regex" + add build-fix from NetBSD port: enable vax FP support when defined(__vax__) as well as BSD43_VAX. from ragge. + add configure --disable-echo option + identify updated files with "MawkId" keywords, retaining old log comments for reference. Ongoing changes are recorded here. + change maintainer email address to my own. 20090711 + use conventional install/uninstall rules in makefile. + add install-sh script, mkdirs.sh, config.guess and config.sub + add $DESTDIR support to makefile + add uninstall make-target + add configure --enable-warnings option (fixed some warnings...) + change configure script to autoconf 2.52 to permit cross-compiles. + drop config.user file; replace with conventional autoconf --prefix, etc. + fill-in CA_REC.type in two places in parse.y which weren't initialized. + fix Debian #38353 (absent expression on last part of "for" statement caused core-dump). + fix Debian #303825 (printf %x clamps numbers to signed range rather than unsigned range). + apply fix from Debian #355966 (null-pointer check in is_string_split()) + apply fix from Debian #391051 (limit-check in scan.c) 20090709 + add support for external regexp libraries (patch by Aleksey Cheusov) (originally comp.lang.awk June 15 2005, also cited in Debian #355442 March 6, 2006). 20090705 + fixes to build on BeOS (if LIBS is set to -lroot), and QNX (redefinition of setmode). 20080909 + fix gcc 4.3.1 -Wall warnings + transform mawk.ac.m4 to aclocal.m4, renaming macros to use "CF_" or "CF_MAWK_" prefixes depending on their reusability. Modified macros to use quoting consistent with recent autoconf versions. + regenerate configure with autoconf version 2.13.20030927 + regenerate parse.c with byacc - 1.9 20080827 + ifdef'd prototypes in nstd.h which belong to stdlib.h, string.h to use standard C by default. + source-in Debian patches 01-08 (see below). Changes for 20080909 fix Debian #496980 as well. ------------------------------------------------------------------------------- Debian patches: (Peter Eisentraut Sat, 05 Apr 2008 17:11:11 +0200) 08_fix-for-gcc3.3 Debian #195371 (James Troup Fri, 30 May 2003 15:24:50 +0100) 07_mawktest-check-devfull Debian #51875 06_parse.y-semicolons Debian #170973 05_-Wall-fixes 04_mawk.1-fix-pi Debian #103699 03_read-and-close-redefinition Debian #104124 02_fix-examples Debian #36011 01_error-on-full-fs Debian #28249 Debian #4293 ------------------------------------------------------------------------------- 1.3.1 -> 1.3.2 Sep 1996 1) Numeric but not integer indices caused core dump in new array scheme. Fixed bug and fired test division. 2) Added ferror() checks on writes. 3) Added some static storage specs to array.c to keep non-ansi compilers happy. 1.3 -> 1.3.1 Sep 1996 Release to new ftp site ftp://ftp.whidbey.net. 1) Workaround for overflow exception in strtod, sunos5.5 solaris. 2) []...] and [^]...] put ] in a class (or not in a class) without having to use back-slash escape. 1.2.2 -> 1.3 Jul 1996 Extensive redesign of array data structures to support large arrays and fast access to arrays created with split. Many of the ideas in the new design were inspired by reading "The Design and Implementation of Dynamic Hashing Sets and Tables in Icon" by William Griswold and Gregg Townsend, SPE 23,351-367. 1.2.1 -> 1.2.2 Jan 1996 1) Improved autoconfig, in particular, fpe tests. This is far from perfect and never will be until C standardizes an interface to ieee754. 2) Removed automatic error message on open failure for getline. 3) Flush all output before system(). Previous behavior was to only flush std{out,err}. 4) Explicitly fclose() all output on exit to work around AIX4.1 bug. 5) Fixed random number generator to work with longs larger than 32bits. 6) Added a type Int which is int on real machines and long on dos machines. Believe that all implicit assumptions that int=32bits are now gone. ------------------------------------------------------------------------------- Changes from version 1.1.4 to 1.2: 1) Limit on code size set by #define in sizes.h is gone. 2) A number of obscure bugs have been fixed such as, you can now make a recursive function call inside a for( i in A) loop. Function calls with array parameters in loop expressions sometimes generated erroneous internal code. See RCS log comments in code for details. Reported bugs are fixed. 3) new -W options -We file : reads commands from file and next argument, regardless of form, is ARGV[1]. Useful for passing -v , -f etc to an awk program started with #!/.../mawk #!/usr/local/bin/mawk -We myprogram -v works, while #!/usr/local/bin/mawk -f myprogram -v gives error message mawk: option -v lacks argument This is really a posix bozo. Posix says you end arguments with "--" , but this doesn't work with the "#!" convention. -W interactive : forces stdout to be unbuffered and stdin to be line buffered. Records from stdin are lines regardless of the value of RS. Useful for interaction with a mawk on a pipe. -W dump, -Wd : disassembles internal code to stdout (used to be stderr) and exits 0. 4) FS = "" causes each record to be broken into characters and placed into $1,$2 ... same with split(x,A,"") and split(x,A,//) 5) print > "/dev/stdout" writes to stdout, exactly the same as print This is useful for passing stdout to function my_special_output_routine(s, file) { # do something fancy with s print s > file } 6) New built-in function fflush() -- copied from the lastest att awk. fflush() : flushes stdout and returns 0 fflush(file) flushes file and returns 0; if file was not an open output file then returns -1. 7) delete A ; -- removes all elements of the array A intended to replace: for( i in A) delete A[i] 8) mawk errors such as compilation failure, file open failure, etc. now exit 2 which reserves exit 1 for the user. 9) No program now silently exits 0, prior behavior was to exit 2 with an error message mawk-1.3.4-20240123/Makefile.in0000644000000000000000000001747214554062467014144 0ustar rootroot# $MawkId: Makefile.in,v 1.63 2024/01/24 01:17:43 tom Exp $ # Makefile-template for MAWK ############################################################################### # copyright 2009-2023,2024 Thomas E. Dickey # copyright 2010, Guido Berhoerster # copyright 2009, Jonathan Nieder # copyright 2005, Aleksey Cheusov # copyright 1996, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### SHELL=/bin/sh #################################### srcdir = @srcdir@ VPATH = @srcdir@ x = @EXEEXT@ o = .@OBJEXT@ prefix = @prefix@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ bindir = @bindir@ CC = @CC@ CPP = @CPP@ BUILD_CC = @BUILD_CC@ CPPFLAGS = -I. -I$(srcdir) -DHAVE_CONFIG_H @CPPFLAGS@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ CFLAGS = @CFLAGS@ $(EXTRA_CFLAGS) LDFLAGS = @CFLAGS@ @LDFLAGS@ LIBS = @LIBS@ BUILD_CFLAGS = @BUILD_CFLAGS@ BUILD_CPPFLAGS = -I. -I$(srcdir) -DHAVE_CONFIG_H @BUILD_CPPFLAGS@ BUILD_LDFLAGS = @BUILD_LDFLAGS@ BUILD_LIBS = @BUILD_LIBS@ BUILD_EXEEXT = @BUILD_EXEEXT@ BUILD_OBJEXT = @BUILD_OBJEXT@ MAKE_RECUR = @cf_cv_makeflags@ prefix="$(prefix)" DESTDIR="$(DESTDIR)" PROGRAM="$(actual_PROG)" YACC = @YACC@ CTAGS = @CTAGS@ ETAGS = @ETAGS@ LINT = @LINT@ LINTOPTS = @LINT_OPTS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ transform = @program_transform_name@ # where to put mawk BINDIR = $(DESTDIR)$(bindir) ####################################### actual_PROG = `echo mawk| sed '$(transform)'` binary_PROG = $(actual_PROG)$x PROGRAM = mawk$x OBJS = parse$o scan$o memory$o main$o hash$o execute$o code$o \ da$o error$o init$o bi_vars$o cast$o print$o bi_funct$o \ kw$o jmp$o array$o field$o split$o re_cmpl$o regexp$o zmalloc$o \ fin$o files$o scancode$o matherr$o fcall$o version$o @EXTRAOBJS@ .SUFFIXES: .c .i .s $o .c.i : @RULE_CC@ @ECHO_CC@$(CPP) -C $(CPPFLAGS) $< >$@ .c.s : @echo compiling $< @$(CC) -S $(CFLAGS) $(CPPFLAGS) $< -o $@ # >$@ .c$o : @RULE_CC@ @ECHO_CC@$(CC) -c $(CPPFLAGS) $(CFLAGS) $< @MAKE_PHONY@.PHONY: all check mawk_test fpe_test install uninstall clean distclean maintainer-clean lint all : $(PROGRAM) check : mawk_test fpe_test $(PROGRAM) : $(OBJS) @ECHO_LD@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) CHECK = AWK=`pwd`/$(PROGRAM); export AWK; \ EGREP="@EGREP@"; export EGREP; \ FGREP="@FGREP@"; export FGREP; \ cd $(srcdir)/test; echo "** $@" mawk_test : $(PROGRAM) # test that we have a sane mawk @sh -c '$(CHECK); ./mawktest' fpe_test : $(PROGRAM) # test FPEs are handled OK @sh -c '$(CHECK); ./fpe_test' parse.c : parse.y @echo expect 4 shift/reduce conflicts $(YACC) -d parse.y sed -e '/^#line/s%"y.tab.c"%"parse.c"%' -e '/typedef.*YYINT;/s,int,short,' y.tab.c >$@ rm -f y.tab.c -if cmp -s y.tab.h parse.h ;\ then rm y.tab.h ;\ else mv y.tab.h parse.h ; fi NOIDENT = sed -e 's/[$$]MawkId\([^$$]*\)[$$]/@MawkId\1@/' scancode.c : $(srcdir)/makescan.c scancode.h nstd.h config.h @ECHO_LD@$(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -o makescan$x $(srcdir)/makescan.c rm -f scancode.c ./makescan$x > scancode.c rm makescan$x install :: $(BINDIR) $(PROGRAM) install \ uninstall :: @echo "$@ing $(binary_PROG) executable" @$(INSTALL_PROGRAM) $(PROGRAM) $(BINDIR)/$(binary_PROG) @echo "$@ing $(actual_PROG) manpages" @cd man && $(MAKE) $(MAKE_RECUR) $@ @cd man && $(MAKE) $(MAKE_RECUR) $@ TOPIC=-arrays SECTION=7 @cd man && $(MAKE) $(MAKE_RECUR) $@ TOPIC=-code SECTION=7 clean : -cd man && $(MAKE) $(MAKE_RECUR) $@ -rm -f y.tab.c y.tab.h makescan$x -rm -f *$o *.i test/$(PROGRAM) *core* test/*core* $(PROGRAM) distclean : clean -cd man && $(MAKE) $(MAKE_RECUR) $@ -rm -f scancode.c -rm -f man2html.tmp -rm -f defines.out maxint.out fpe_check$x tags makedeps.awk -rm -f config.h Makefile config.status config.log config.cache maintainer-clean : distclean -rm -f parse.c parse.h -rm -f array.c array.h -rm -f configure config.guess config.sub install-sh -rm -fr autom4te.cache lint : $(LINT) $(LINTOPTS) $(CPPFLAGS) $(OBJS:$o=.c) tags : $(CTAGS) *.[ch] */*.[ch] @MAKE_UPPER_TAGS@TAGS : @MAKE_UPPER_TAGS@ $(ETAGS) *.[ch] */*.[ch] $(BINDIR) : mkdir -p "$@" # output from makedeps.sh array.o : array.h bi_vars.h config.h field.h mawk.h memory.h nstd.h sizes.h split.h symtype.h types.h zmalloc.h bi_funct.o : array.h bi_funct.h bi_vars.h config.h field.h files.h fin.h init.h mawk.h memory.h nstd.h regexp.h repl.h rexp.h sizes.h symtype.h types.h zmalloc.h bi_vars.o : array.h bi_vars.h config.h field.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h cast.o : array.h config.h field.h mawk.h memory.h nstd.h parse.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h code.o : array.h code.h config.h field.h init.h jmp.h mawk.h memory.h nstd.h parse.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h da.o : array.h bi_funct.h code.h config.h field.h mawk.h memory.h nstd.h regexp.h repl.h rexp.h sizes.h symtype.h types.h zmalloc.h error.o : array.h bi_vars.h config.h mawk.h nstd.h parse.h scan.h scancode.h sizes.h symtype.h types.h execute.o : array.h bi_funct.h bi_vars.h code.h config.h field.h files.h fin.h mawk.h memory.h nstd.h regexp.h repl.h rexp.h sizes.h symtype.h types.h zmalloc.h fcall.o : array.h code.h config.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h field.o : array.h bi_vars.h config.h field.h init.h mawk.h memory.h nstd.h parse.h regexp.h repl.h rexp.h scan.h scancode.h sizes.h split.h symtype.h types.h zmalloc.h files.o : array.h config.h files.h fin.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h fin.o : array.h bi_vars.h config.h field.h fin.h mawk.h memory.h nstd.h parse.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h hash.o : array.h bi_vars.h config.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h init.o : array.h bi_funct.h bi_vars.h code.h config.h field.h files.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h jmp.o : array.h code.h config.h init.h jmp.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h kw.o : array.h config.h init.h mawk.h nstd.h parse.h sizes.h symtype.h types.h main.o : array.h bi_vars.h code.h config.h files.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h makescan.o : config.h nstd.h scancode.h matherr.o : array.h config.h init.h mawk.h nstd.h sizes.h symtype.h types.h memory.o : config.h mawk.h memory.h nstd.h sizes.h types.h zmalloc.h parse.o : array.h bi_funct.h bi_vars.h code.h config.h field.h files.h jmp.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h print.o : array.h bi_funct.h bi_vars.h config.h field.h files.h init.h mawk.h memory.h nstd.h parse.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h re_cmpl.o : array.h config.h mawk.h memory.h nstd.h parse.h regexp.h repl.h rexp.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h regexp.o : config.h scan.o : array.h code.h config.h field.h files.h fin.h init.h mawk.h memory.h nstd.h parse.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h scancode.o : scancode.h split.o : array.h bi_funct.h bi_vars.h config.h field.h mawk.h memory.h nstd.h parse.h regexp.h repl.h rexp.h scan.h scancode.h sizes.h split.h symtype.h types.h zmalloc.h trace.o : code.h config.h mawk.h memory.h nstd.h repl.h sizes.h types.h zmalloc.h version.o : array.h config.h init.h mawk.h nstd.h patchlev.h sizes.h symtype.h types.h zmalloc.o : config.h mawk.h nstd.h sizes.h types.h zmalloc.h regexp.o : rexpdb.c rexp4.c rexp2.c regexp_system.c sizes.h mawk.h rexp0.c rexp1.c config.h rexp.h regexp.h nstd.h rexp3.c rexp.c field.h mawk-1.3.4-20240123/fcall.c0000644000000000000000000002726514467521313013316 0ustar rootroot/******************************************** fcall.c copyright 2009-2020,2023 Thomas E. Dickey copyright 1991-1993,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: fcall.c,v 1.18 2023/08/17 22:44:27 tom Exp $ */ #include #include #include /* This file has functions involved with type checking of function calls */ static void relocate_arglist(CA_REC *, int, unsigned, int); static int check_progress; /* flag that indicates call_arg_check() was able to type check some call arguments */ #if OPT_TRACE static void trace_arg_list(CA_REC * arg_list) { CA_REC *item; int count = 0; TRACE(("trace_arg_list\n")); while ((item = arg_list) != 0) { arg_list = item->link; TRACE(("...arg %d is %s\n", item->arg_num + 1, type_to_str(item->type))); ++count; } } #else #define trace_arg_list(arg_list) /* nothing */ #endif #if OPT_TRACE /* * FIXME: pass in the maximum offset, but keep track of jumps forward (and * range) which extend beyond the last halt/stop/ret/ret0, to give a more * precise value for the code size. */ static int inst_len(INST * p) { int result = 0; while (p != 0 && p->op != _HALT) { ++result; switch ((MAWK_OPCODES) (p++->op)) { case _HALT: case _STOP: case FE_PUSHA: case FE_PUSHI: case A_TEST: case A_DEL: case DEL_A: case POP_AL: case _POP: case _ADD: case _SUB: case _MUL: case _DIV: case _MOD: case _POW: case _NOT: case _UMINUS: case _UPLUS: case _TEST: case _CAT: case _ASSIGN: case _ADD_ASG: case _SUB_ASG: case _MUL_ASG: case _DIV_ASG: case _MOD_ASG: case _POW_ASG: case NF_PUSHI: case F_ASSIGN: case F_ADD_ASG: case F_SUB_ASG: case F_MUL_ASG: case F_DIV_ASG: case F_MOD_ASG: case F_POW_ASG: case _POST_INC: case _POST_DEC: case _PRE_INC: case _PRE_DEC: case F_POST_INC: case F_POST_DEC: case F_PRE_INC: case F_PRE_DEC: case _EQ: case _NEQ: case _LT: case _LTE: case _GT: case _GTE: case _MATCH2: case _EXIT: case _EXIT0: case _NEXT: case _NEXTFILE: case _RET: case _RET0: case _OMAIN: case _JMAIN: case OL_GL: case OL_GL_NR: /* simple_codes */ break; case L_PUSHA: case L_PUSHI: case LAE_PUSHI: case LAE_PUSHA: case LA_PUSHA: case F_PUSHA: case F_PUSHI: case AE_PUSHA: case AE_PUSHI: case A_PUSHA: case _PUSHI: case _PUSHA: case _MATCH0: case _MATCH1: case _PUSHS: case _PUSHD: case _PUSHC: case _PUSHINT: case _BUILTIN: case _PRINT: case _JMP: case _JNZ: case _JZ: case _LJZ: case _LJNZ: case SET_ALOOP: case ALOOP: case A_CAT: ++result; break; case A_LENGTH: case _LENGTH: ++result; break; case _CALLX: case _CALL: result += 2; break; case _RANGE: result += 4; break; } } return result; } #endif /* OPT_TRACE */ /* type checks a list of call arguments, returns a list of arguments whose type is still unknown */ static CA_REC * call_arg_check(FBLOCK * callee, CA_REC * entry_list, INST * start) { register CA_REC *q; CA_REC *exit_list = (CA_REC *) 0; TRACE(("call_arg_check\n")); check_progress = 0; /* loop : take q off entry_list test it if OK zfree(q) else put on exit_list */ while ((q = entry_list)) { entry_list = q->link; TRACE(("...arg %d is %s\n", q->arg_num + 1, type_to_str(q->type))); if (q->type == ST_NONE) { /* try to infer the type */ /* it might now be in symbol table */ if (q->sym_p->type == ST_VAR) { TRACE(("...use CA_EXPR\n")); /* set type and patch */ q->type = CA_EXPR; start[q->call_offset + 1].ptr = (PTR) q->sym_p->stval.cp; } else if (q->sym_p->type == ST_ARRAY) { TRACE(("...use CA_ARRAY\n")); q->type = CA_ARRAY; start[q->call_offset].op = A_PUSHA; start[q->call_offset + 1].ptr = (PTR) q->sym_p->stval.array; } else { /* try to infer from callee */ TRACE(("...infer?\n")); switch (callee->typev[q->arg_num]) { case ST_LOCAL_VAR: q->type = CA_EXPR; q->sym_p->type = ST_VAR; q->sym_p->stval.cp = ZMALLOC(CELL); q->sym_p->stval.cp->type = C_NOINIT; start[q->call_offset + 1].ptr = (PTR) q->sym_p->stval.cp; break; case ST_LOCAL_ARRAY: q->type = CA_ARRAY; q->sym_p->type = ST_ARRAY; q->sym_p->stval.array = new_ARRAY(); start[q->call_offset].op = A_PUSHA; start[q->call_offset + 1].ptr = (PTR) q->sym_p->stval.array; break; } } } else if (q->type == ST_LOCAL_NONE) { TRACE(("...infer2?\n")); /* try to infer the type */ if (*q->type_p == ST_LOCAL_VAR) { /* set type , don't need to patch */ q->type = CA_EXPR; } else if (*q->type_p == ST_LOCAL_ARRAY) { q->type = CA_ARRAY; start[q->call_offset].op = LA_PUSHA; /* offset+1 op is OK */ } else { /* try to infer from callee */ switch (callee->typev[q->arg_num]) { case ST_LOCAL_VAR: q->type = CA_EXPR; *q->type_p = ST_LOCAL_VAR; /* do not need to patch */ break; case ST_LOCAL_ARRAY: q->type = CA_ARRAY; *q->type_p = ST_LOCAL_ARRAY; start[q->call_offset].op = LA_PUSHA; break; } } } /* if we still do not know the type put on the new list else type check */ if (q->type == ST_NONE || q->type == ST_LOCAL_NONE) { q->link = exit_list; exit_list = q; } else { /* type known */ if (callee->typev[q->arg_num] == ST_LOCAL_NONE) { callee->typev[q->arg_num] = q->type; } else if (q->type != callee->typev[q->arg_num]) { #if OPT_CALLX TRACE(("OOPS: arg %d (code %p, size %ld), actual %s vs %s\n", q->arg_num + 1, callee->code, callee->size, type_to_str(q->type), type_to_str(callee->typev[q->arg_num]))); callee->typev[q->arg_num] = q->type; callee->defer = 1; #else token_lineno = q->call_lineno; compile_error("type error in arg(%d) in call to %s (actual %s vs %s)", q->arg_num + 1, callee->name, type_to_str(q->type), type_to_str(callee->typev[q->arg_num])); #endif } ZFREE(q); check_progress = 1; } TRACE(("%s: code %p size %ld.%ld:%d\n", callee->name, callee->code, callee->size / sizeof(INST), callee->size % sizeof(INST), inst_len(callee->code))); } /* while */ return exit_list; } static int arg_cnt_ok(FBLOCK * fbp, CA_REC * q) { if ((int) q->arg_num >= (int) fbp->nargs) { token_lineno = q->call_lineno; compile_error("too many arguments in call to %s", fbp->name); return 0; } else return 1; } FCALL_REC *resolve_list; /* function calls whose arg types need checking are stored on this list */ /* on first pass thru the resolve list we check : if forward referenced functions were really defined if right number of arguments and compute call_start which is now known */ static FCALL_REC * first_pass(FCALL_REC * p) { FCALL_REC dummy; register FCALL_REC *q = &dummy; /* trails p */ q->link = p; while (p) { if (!p->callee->code) { /* callee never defined */ compile_error("function %s never defined", p->callee->name); /* delete p from list */ q->link = p->link; /* don't worry about freeing memory, we'll exit soon */ } /* note p->arg_list starts with last argument */ else if (!p->arg_list /* nothing to do */ || (!p->arg_cnt_checked && !arg_cnt_ok(p->callee, p->arg_list))) { q->link = p->link; /* delete p */ /* the ! arg_list case is not an error so free memory */ ZFREE(p); } else { /* keep p and set call_start */ q = p; switch (p->call_scope) { case SCOPE_MAIN: p->call_start = main_start; break; case SCOPE_BEGIN: p->call_start = begin_start; break; case SCOPE_END: p->call_start = end_start; break; case SCOPE_FUNCT: p->call_start = p->call->code; break; } } p = q->link; } return dummy.link; } /* continuously walk the resolve_list making type deductions until this list goes empty or no more progress can be made (An example where no more progress can be made is at end of file */ void resolve_fcalls(void) { register FCALL_REC *p, *old_list, *new_list; int progress; /* a flag */ TRACE(("resolve_fcalls\n")); old_list = first_pass(resolve_list); new_list = (FCALL_REC *) 0; progress = 0; while (1) { if (!old_list) { /* flop the lists */ old_list = new_list; if (!old_list /* nothing left */ || !progress /* can't do any more */ ) return; new_list = (FCALL_REC *) 0; progress = 0; } p = old_list; old_list = p->link; TRACE(("%s@%d ", __FILE__, __LINE__)); if ((p->arg_list = call_arg_check(p->callee, p->arg_list, p->call_start))) { /* still have work to do , put on new_list */ progress |= check_progress; p->link = new_list; new_list = p; } else { /* done with p */ progress = 1; ZFREE(p); } } } /* the parser has just reduced a function call ; the info needed to type check is passed in. If type checking can not be done yet (most common reason -- function referenced but not defined), a node is added to the resolve list. */ void check_fcall( FBLOCK * callee, int call_scope, int move_level, FBLOCK * call, CA_REC * arg_list) { FCALL_REC *p; TRACE(("check_fcall(%s)\n", callee->name)); if (!callee->code) { TRACE(("...forward reference\n")); /* forward reference to a function to be defined later */ p = ZMALLOC(FCALL_REC); p->callee = callee; p->call_scope = (short) call_scope; p->move_level = (short) move_level; p->call = call; p->arg_list = arg_list; p->arg_cnt_checked = 0; trace_arg_list(arg_list); /* add to resolve list */ p->link = resolve_list; resolve_list = p; } else if (arg_list && arg_cnt_ok(callee, arg_list)) { /* usually arg_list disappears here and all is well otherwise add to resolve list */ TRACE(("%s@%d ", __FILE__, __LINE__)); if ((arg_list = call_arg_check(callee, arg_list, code_base))) { p = ZMALLOC(FCALL_REC); p->callee = callee; p->call_scope = (short) call_scope; p->move_level = (short) move_level; p->call = call; p->arg_list = arg_list; p->arg_cnt_checked = 1; /* add to resolve list */ p->link = resolve_list; resolve_list = p; } } } /* code_pop() has just moved some code. If this code contains a function call, it might need to be relocated on the resolve list too. This function does it. delta == relocation distance */ void relocate_resolve_list( int scope, int move_level, FBLOCK * fbp, int orig_offset, unsigned len, int delta) { FCALL_REC *p = resolve_list; while (p) { if (scope == p->call_scope && move_level == p->move_level && (scope == SCOPE_FUNCT ? fbp == p->call : 1)) { relocate_arglist(p->arg_list, orig_offset, len, delta); } p = p->link; } } static void relocate_arglist( CA_REC * arg_list, int offset, unsigned len, int delta) { register CA_REC *p; if (!arg_list) return; p = arg_list; /* all nodes must be relocated or none, so test the first one */ /* Note: call_offset is always set even for args that don't need to be patched so that this check works. */ if (p->call_offset < offset || (unsigned) p->call_offset >= (unsigned) offset + len) return; /* relocate the whole list */ do { p->call_offset += delta; p = p->link; } while (p); } /* example where typing cannot progress { f(z) } function f(x) { print NR } # this is legal, does something useful, but absurdly written # We have to design so this works */ mawk-1.3.4-20240123/rexp1.c0000644000000000000000000001722014460604756013270 0ustar rootroot/******************************************** rexp1.c copyright 2009-2020,2023, Thomas E. Dickey copyright 1991,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: rexp1.c,v 1.25 2023/07/28 00:21:02 tom Exp $ */ /* re machine operations */ #include "rexp.h" /* initialize a two state machine */ static void new_TWO( int type, MACHINE * mp) /* init mp-> */ { mp->start = (STATE *) RE_malloc(2 * STATESZ); mp->stop = mp->start + 1; mp->start->s_type = (SType) type; mp->stop->s_type = M_ACCEPT; #ifndef NO_INTERVAL_EXPR mp->start->it_min = 1; mp->start->it_max = MAX__INT; mp->start->it_cnt = 0; #endif } /* build a machine that recognizes any */ MACHINE RE_any(void) { MACHINE x; new_TWO(M_ANY, &x); return x; } /* build a machine that recognizes the start of string */ MACHINE RE_start(void) { MACHINE x; new_TWO(M_START, &x); return x; } MACHINE RE_end(void) { MACHINE x; new_TWO(M_END, &x); return x; } /* build a machine that recognizes a class */ MACHINE RE_class(BV * bvp) { MACHINE x; new_TWO(M_CLASS, &x); x.start->s_data.bvp = bvp; return x; } MACHINE RE_u(void) { MACHINE x; new_TWO(M_U, &x); return x; } MACHINE RE_str(char *str, size_t len) { MACHINE x; new_TWO(M_STR, &x); x.start->s_len = len; x.start->s_data.str = str; return x; } /* replace m and n by a machine that recognizes mn */ void RE_cat(MACHINE * mp, MACHINE * np) { size_t sz1, sz2, sz; sz1 = (size_t) (mp->stop - mp->start); sz2 = (size_t) (np->stop - np->start + 1); sz = sz1 + sz2; #ifndef NO_INTERVAL_EXPR ++sz; /* allocate dummy for workaround */ #endif mp->start = (STATE *) RE_realloc(mp->start, sz * STATESZ); #ifndef NO_INTERVAL_EXPR --sz; #endif mp->stop = mp->start + (sz - 1); RE_copy_states(mp->start + sz1, np->start, sz2); #ifndef NO_INTERVAL_EXPR mp->start[sz].s_type = M_ACCEPT; /* this is needed in RE_init_it_cnt */ #endif RE_free(np->start); } /* replace m by a machine that recognizes m|n */ void RE_or(MACHINE * mp, MACHINE * np) { register STATE *p; size_t szm, szn; szm = (size_t) (mp->stop - mp->start + 1); szn = (size_t) (np->stop - np->start + 1); p = (STATE *) RE_malloc((szm + szn + 1) * STATESZ); RE_copy_states(p + 1, mp->start, szm); RE_free(mp->start); mp->start = p; (mp->stop = p + szm + szn)->s_type = M_ACCEPT; p->s_type = M_2JA; p->s_data.jump = (int) (szm + 1); RE_copy_states(p + szm + 1, np->start, szn); RE_free(np->start); (p += szm)->s_type = M_1J; p->s_data.jump = (int) szn; } /* * Ignore attempts to wrap an atom using zero-or-more repetitions in another * loop with the same condition. */ #define ignore_star_star(mp, sz) \ { \ if (sz == 5) { \ STATE *ps = mp->start; \ \ if ((ps->s_type % U_ON) != M_2JA) { \ ; \ } else if (ps->s_data.jump != 4) { \ TRACE((".. expected jump %d\n", ps->s_data.jump)); \ } else if (((ps + 1)->s_type % U_ON) != M_SAVE_POS) { \ TRACE((".. expected save %s\n", REs_type(ps + 1))); \ } else if (((ps + 2)->s_type % U_ON) != M_CLASS && \ ((ps + 2)->s_type % U_ON) != M_STR && \ ((ps + 2)->s_type % U_ON) != M_U) { \ TRACE((".. expected atom %s\n", REs_type(ps + 2))); \ } else if (((ps + 3)->s_type % U_ON) != M_2JC) { \ TRACE((".. expected loop %s\n", REs_type(ps + 3))); \ } else { \ TRACE(("ignore repeated loop\n")); \ return NULL; \ } \ } \ } #ifndef NO_INTERVAL_EXPR /* replace m with m* limited to the max iterations (variation of m* closure) */ void RE_close_limit(MACHINE * mp, Int min_limit, Int max_limit) { #ifdef NO_RI_LOOP_UNROLL STATE *s; TRACE(("RE_close_limit " INT_FMT ".." INT_FMT "\n", min_limit, max_limit)); if ((s = RE_close(mp)) != 0) { if (s->s_type == M_2JC) { s->it_min = min_limit; s->it_max = max_limit; } } #else RE_close(mp); RE_set_limit(mp->start, min_limit, max_limit); #endif } /* replace m with m+ limited to the max iterations which is one or more, limited (variation of m+ positive closure) */ void RE_poscl_limit(MACHINE * mp, Int min_limit, Int max_limit) { #ifdef NO_RI_LOOP_UNROLL STATE *s; TRACE(("RE_poscl_limit " INT_FMT ".." INT_FMT "\n", min_limit, max_limit)); if ((s = RE_poscl(mp)) != NULL) { if (s->s_type == M_2JC) { s->it_min = min_limit; s->it_max = max_limit; } } #else RE_poscl(mp); RE_set_limit(mp->start, min_limit, max_limit); #endif } #endif /* ! NO_INTERVAL_EXPR */ /* UNARY OPERATIONS */ /* replace m by m* (zero or more) */ STATE * RE_close(MACHINE * mp) { register STATE *p; size_t sz; /* * 2JA end * loop: * SAVE_POS * m * 2JC loop * end: * ACCEPT */ sz = (size_t) (mp->stop - mp->start + 1); ignore_star_star(mp, sz); p = (STATE *) RE_malloc((sz + 3) * STATESZ); RE_copy_states(p + 2, mp->start, sz); RE_free(mp->start); mp->start = p; mp->stop = p + (sz + 2); p->s_type = M_2JA; p->s_data.jump = (int) (sz + 2); (++p)->s_type = M_SAVE_POS; (p += sz)->s_type = M_2JC; #ifndef NO_INTERVAL_EXPR p->it_min = 1; p->it_max = MAX__INT; #endif p->s_data.jump = -(int) sz; (p + 1)->s_type = M_ACCEPT; return p; } /* replace m by m+ (positive closure - one or more) */ STATE * RE_poscl(MACHINE * mp) { register STATE *p; size_t sz; /* * loop: * SAVE_POS * m * 2JC loop * ACCEPT */ sz = (size_t) (mp->stop - mp->start + 1); ignore_star_star(mp, sz); p = (STATE *) RE_malloc((sz + 2) * STATESZ); RE_copy_states(p + 1, mp->start, sz); RE_free(mp->start); mp->start = p; mp->stop = p + (sz + 1); p++->s_type = M_SAVE_POS; p += sz - 1; p->s_type = M_2JC; #ifndef NO_INTERVAL_EXPR p->it_min = 1; p->it_max = MAX__INT; #endif p->s_data.jump = -((int) sz); (p + 1)->s_type = M_ACCEPT; return p; } /* replace m by m? (zero or one) */ void RE_01(MACHINE * mp) { size_t sz; register STATE *p; /* * 2JB end (jump desirable if not found) * m * end: * ACCEPT */ sz = (size_t) (mp->stop - mp->start + 1); p = (STATE *) RE_malloc((sz + 1) * STATESZ); RE_copy_states(p + 1, mp->start, sz); RE_free(mp->start); mp->start = p; mp->stop = p + sz; p->s_type = M_2JB; p->s_data.jump = (int) sz; } /*=================================== MEMORY ALLOCATION *==============================*/ PTR RE_malloc(size_t sz) { PTR p; p = malloc(sz); TRACE(("RE_malloc(%lu) ->%p\n", (unsigned long) sz, p)); if (p == 0) RE_error_trap(MEMORY_FAILURE); return p; } PTR RE_realloc(PTR p, size_t sz) { PTR q; q = realloc(p, sz); TRACE(("RE_realloc(%p, %lu) ->%p\n", p, (unsigned long) sz, q)); if (q == 0) RE_error_trap(MEMORY_FAILURE); return q; } #ifdef NO_LEAKS void RE_free(PTR p) { TRACE(("RE_free(%p)\n", p)); free(p); } /* when copying states, ensure strings are new copies so we can destroy ok */ void RE_copy_states(STATE * target, const STATE * source, size_t length) { size_t n; for (n = 0; n < length; ++n) { memcpy(target + n, source + n, STATESZ); switch (source[n].s_type) { case M_STR: target[n].s_data.str = strdup(target[n].s_data.str); break; } } } #endif mawk-1.3.4-20240123/MANIFEST0000644000000000000000000002520614554027541013214 0ustar rootrootMANIFEST for mawk, version t20240123 -------------------------------------------------------------------------------- MANIFEST this file ACKNOWLEDGMENT acknowledgements CHANGES change-log for mawk COPYING GNU General Public License, version 2 INSTALL installation instructions Makefile.in template for makefile README description of mawk aclocal.m4 mawk-specific macros for autoconf array.c array functions (C source) array.h array functions (C header) bi_funct.c mawk built-in functions bi_funct.h mawk built-in functions header bi_vars.c mawk predefined variables bi_vars.h mawk predefined variables header cast.c mawk type-conversions code.c machine opcode functions code.h machine opcodes header config.guess configure-script config.sub configure-script config_h.in template for config.h configure Configuration script for UNIX configure.in template for autoconf script da.c disassemble mawk-code error.c error-reporting functions execute.c command-interpreter fcall.c utilities for function-calls field.c field- and cell-utilities field.h field- and cell utilities headers files.c file- and pipe-functions files.h file- and pipe-functions header fin.c file-input functions fin.h file-input functions header fpe_check.c configure-utility for floating-point checks hash.c symbol table hashing/lookup init.c interpreter initialization functions init.h interpreter initialization functions header install-sh configure-script jmp.c byte-code jumps/branches jmp.h byte-code jumps/branches header kw.c keyword table and lookup functions main.c main program makedeps.sh script to regenerate object-dependencies for Makefile.in makescan.c utility which builds scancode.c matherr.c catch/report math-errors mawk.h main header file for mawk memory.c string-allocation functions memory.h string-allocation functions header nstd.h header for missing.c parse.c generated C parser parse.h generated C parser header parse.y mawk grammar patchlev.h patch-level (see version.c) print.c printf- and sprintf-functions for interpreter re_cmpl.c compile regular expressions regexp.c regular expressions (main) regexp.h interface to main regular expressions regexp_system.c wrapper for system's regular expressions repl.h header for re_cmpl.c rexp.c regular expressions rexp.h regular expression details header rexp0.c built-in regular expression parsing rexp1.c built-in regular expression operations rexp2.c built-in regular expressions matching functions rexp3.c built-in regular expressions matching - main rexp4.c regular expressions utility functions rexpdb.c debugging utilities for regular expressions scan.c program file-management scan.h program file-management header scancode.h list of scan-codes for mawk sizes.h data-type sizes header split.c functions for splitting field, strings, etc. split.h prototypes for split.c symtype.h types related to symbols are defined here trace.c mawk trace-functions types.h mawk datatypes header version.c print mawk's version string vs6.mak makefile for Visual Studio 6 zmalloc.c memory allocation functions zmalloc.h memory allocation functions header examples subdirectory examples/ct_length.awk change length to length() examples/decl.awk parse a C declaration by recursive descent examples/deps.awk find include dependencies in C source examples/eatc.awk another program to remove comments examples/gdecl.awk parse a C declaration by recursive descent examples/hcal Bob's latest examples/hical calendar program by Bob Stockler examples/nocomment.awk remove C comments from a list of files examples/primes.awk find all primes between 2 and STOP (parameter) examples/qsort.awk qsort text files icons subdirectory icons/mawk144.png artwork for my webpage icons/mawk48.png artwork for my webpage icons/mawk48.svg a suitable icon for mawk man subdirectory man/Makefile.in makefile for mawk's man-directory man/TODO to-do list (update to conform with POSIX-1003.1-2004) man/mawk-arrays.7 documentation for mawk-arrays man/mawk-code.7 documentation for mawk's dump-option man/mawk-externs.dat manpages to exclude from man2html linking man/mawk.1 troff source for unix style man pages man/mawk.doc formatted-text manpage man/mawk.txt plain-text manpage msdos subdirectory msdos/dosexec.c system() and pipes() for DOS msdos/examples subdirectory msdos/examples/add_cr.awk convert files from Unix to Dos line-endings msdos/examples/doslist.awk print truncated DOS file names msdos/examples/objstat.awk Sum up sizes of OBJ files in current directory msdos/examples/shell.awk Test pipes under DOS msdos/examples/srcstat.awk show sizes (line, char) of files msdos/examples/srcstat2.awk show sizes (line, char) of files msdos/examples/texttest.awk print contents of quoted #include's msdos/examples/winexe.awk sum segment-sizes of exe's in current directory msdos/examples/winobj.awk sum sizes of obj's in current directory msdos subdirectory msdos/vs2008.h definitions for building with Visual Studio 2008 msdos/vs2008.mak nmakefile for building with Visual Studio 2008 package/debian subdirectory package/debian/changelog start working on debian package package/debian/compat debian build-script package/debian/control debian build-script package/debian/copyright debian build-script package/debian/docs debian build-script package/debian/postinst debian build-script package/debian/postrm post-removal script package/debian/preinst debian build script package/debian/prerm debian build-script package/debian/rules debian build-script package/debian/source subdirectory package/debian/source/format debian build script package/debian subdirectory package/debian/watch debian build-script package/freebsd subdirectory package/freebsd/Makefile FreeBSD build-script package/freebsd/distinfo FreeBSD build-script package/freebsd/pkg-descr FreeBSD build-script package subdirectory package/mawk.spec RPM script for mawk test subdirectory test/decl-awk.out reference for test using decl.awk test/fpe_test scripts to test if fpe handling compiled OK test/fpe_test.bat scripts to test if fpe handling compiled OK test/fpetest1.awk test exception for divide-by-zero test/fpetest2.awk test exception for floating point overflow test/fpetest3.awk test exception for domain error test/full-awk.dat test-data for /dev/full test/interval0.awk test-case for empty interval-expressions test/interval0.out reference for empty interval-expressions test/mawknull.dat test-file for embedded nulls test/mawktest scripts to test mawk compiled OK test/mawktest.bat scripts to test mawk compiled OK test/mawktest.dat input data for the test test/nextfile.awk script for testing nextfile test/nextfile.out reference data for nextfile test test/noloop.awk test-script from gawk test/null-rs.awk test-script for setting RS to explicit null test/null-rs.dat input-data for null-rs.awk test/null-rs.out reference for null-rs.awk test/nulls.out output from nulls0.awk test/nulls0.awk script for testing FS containing nulls test/reg-awk.out reference for testing regular expressions test/reg0.awk test simple pattern matching test/reg1.awk test pattern with "|" OR test/reg2.awk test pattern with ranges test/reg3.awk testcase for pattern test/reg4.awk test-case for square-brackets and embedded "/" or "]" test/reg5.awk test-case for character-classes test/reg6.awk testcase for J2C machine state test/reg7.awk test-script for gsub test/repetitions.awk test-case for regex-repetitions test/repetitions.dat data for testing regex-repetitions test/repetitions.out reference for regex-repetitions test test/wc-awk.out reference for wc.awk test/wc.awk test-script which counts words test/wfrq-awk.out reference for wfrq0.awk test/wfrq0.awk test-script which counts word-frequencies mawk-1.3.4-20240123/split.c0000644000000000000000000001622413727427601013364 0ustar rootroot/******************************************** split.c copyright 2008-2014,2020 Thomas E. Dickey copyright 1991-1996,2014 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: split.c,v 1.32 2020/09/13 14:41:05 tom Exp $ */ /* split.c */ #include "mawk.h" #include "split.h" #include "symtype.h" #include "bi_vars.h" #include "bi_funct.h" #include "memory.h" #include "scan.h" #include "regexp.h" #include "repl.h" #include "field.h" #ifdef NO_LEAKS #define SP_SIZE 4 /* exercises split_block_list code */ #else #define SP_SIZE 2048 #endif typedef struct split_block { STRING *strings[SP_SIZE]; struct split_block *link; } Split_Block_Node; static Split_Block_Node split_block_base; static Split_Block_Node *split_block_list = &split_block_base; /* * Usually the list is of size 1. * The list never gets smaller than size 1. * This function returns a bigger list to size 1. */ static void spb_list_shrink(void) { Split_Block_Node *p = split_block_list->link; split_block_list->link = 0; while (p) { Split_Block_Node *hold = p; p = p->link; zfree(hold, sizeof(Split_Block_Node)); } } /* * This function is passed a pointer to the tail of the list, * adds a new node and returns the new tail * This makes the list one node bigger */ static Split_Block_Node * grow_sp_list(Split_Block_Node * tail) { tail->link = (Split_Block_Node *) zmalloc(sizeof(Split_Block_Node)); tail = tail->link; tail->link = 0; return tail; } /* * Split string s of length slen on SPACE without changing s. * Load the pieces into STRINGS * return the number of pieces */ size_t space_split(const char *s, size_t slen) { size_t cnt = 0; const char *end = s + slen; Split_Block_Node *node_p = split_block_list; unsigned idx = 0; while (1) { /* eat space */ while (scan_code[*(const unsigned char *) s] == SC_SPACE) s++; if (s == end) return cnt; /* find one field */ { const char *q = s++; /* q is front of field */ while (s < end && scan_code[*(const unsigned char *) s] != SC_SPACE) s++; /* create and store the string field */ node_p->strings[idx] = new_STRING1(q, (size_t) (s - q)); cnt++; if (++idx == SP_SIZE) { idx = 0; node_p = grow_sp_list(node_p); } } } /* not reached */ } /* * re is an (RE_DATA *) with compiled PTR holding the compiled RE */ size_t re_split(char *s, size_t slen, PTR re) { size_t cnt = 0; const char *end = s + slen; Split_Block_Node *node_p = split_block_list; unsigned idx = 0; int no_bol = 0; if (slen == 0) return 0; while (s < end) { size_t mlen; char *m = re_pos_match(s, (size_t) (end - s), re, &mlen, no_bol); if (m) { /* stuff in front of match is a field, might have length zero */ node_p->strings[idx] = new_STRING1(s, (size_t) (m - s)); cnt++; if (++idx == SP_SIZE) { idx = 0; node_p = grow_sp_list(node_p); } s = m + mlen; no_bol = 1; } else { /* no match so last field is what's left */ node_p->strings[idx] = new_STRING1(s, (size_t) (end - s)); /* done so don't need to increment idx */ return ++cnt; } } /* last match at end of s, so last field is "" */ node_p->strings[idx] = new_STRING0((size_t) 0); return ++cnt; } /* * Matches a string with a regular expression, but only matches of positive * length count. * input is a string str and its length. * return is match point else 0 if no match * length of match is returned in *lenp */ char * re_pos_match(char *str, size_t str_len, PTR re, size_t *lenp, int no_bol) { const char *end = str + str_len; while (str < end) { char *match = REmatch(str, (size_t) (end - str), cast_to_re(re), lenp, no_bol); if (match) { if (*lenp) { /* match of positive length so done */ return match; } else { /* match but zero length, move str forward and try again */ /* note this match must have occurred at front of str */ str = match + 1; no_bol = 1; } } else { /* no match */ *lenp = 0; return 0; } } *lenp = 0; return 0; } /* * like space split but splits s into single character strings */ size_t null_split(const char *s, size_t slen) { const char *end = s + slen; Split_Block_Node *node_p = split_block_list; unsigned idx = 0; while (s < end) { node_p->strings[idx] = new_STRING1(s++, (size_t) 1); if (++idx == SP_SIZE) { idx = 0; node_p = grow_sp_list(node_p); } } return slen; } /* * The caller knows there are cnt STRING* in the split_block_list * buffers. This function uses them to make CELLs in cp[] * The target CELLs are virgin, they don't need to be * destroyed */ void transfer_to_array(CELL cp[], size_t cnt) { Split_Block_Node *node_p = split_block_list; unsigned idx = 0; while (cnt > 0) { cp->type = C_MBSTRN; cp->ptr = (PTR) node_p->strings[idx]; cnt--; cp++; if (++idx == SP_SIZE) { idx = 0; node_p = node_p->link; } } if (node_p != split_block_list) spb_list_shrink(); } /* * like above but transfers the saved pieces to $1, $2 ... $cnt * The target CELLs may be string type so need to be destroyed * The caller has made sure the target CELLs exist */ void transfer_to_fields(size_t cnt) { CELL *fp = &field[1]; /* start with $1 */ CELL *fp_end = &field[FBANK_SZ]; Split_Block_Node *node_p = split_block_list; unsigned idx = 0; unsigned fb_idx = 0; while (cnt > 0) { cell_destroy(fp); fp->type = C_MBSTRN; fp->ptr = (PTR) node_p->strings[idx]; cnt--; if (++idx == SP_SIZE) { idx = 0; node_p = node_p->link; } if (++fp == fp_end) { fb_idx++; fp = &fbankv[fb_idx][0]; fp_end = fp + FBANK_SZ; } } if (node_p != split_block_list) spb_list_shrink(); } /* * split(s, X, r) * split s into array X on r * * mawk state is EXECUTION sp points at top of eval_stack[] * * entry: sp[0] holds r * sp[-1] pts at X * sp[-2] holds s * * exit : sp is 2 less, sp[0] is C_DOUBLE CELL with value equal * to the number of split pieces */ CELL * bi_split(CELL *sp) { size_t cnt = 0; /* the number of pieces */ if (sp->type < C_RE) cast_for_split(sp); /* can be C_RE, C_SPACE or C_SNULL */ sp -= 2; if (sp->type < C_STRING) cast1_to_s(sp); if (string(sp)->len == 0) { /* nothing to split */ cnt = 0; } else { switch ((sp + 2)->type) { case C_RE: if (isEmpty_RE((sp + 2)->ptr)) { cnt = null_split(string(sp)->str, string(sp)->len); } else { cnt = re_split(string(sp)->str, string(sp)->len, (sp + 2)->ptr); } break; case C_SPACE: cnt = space_split(string(sp)->str, string(sp)->len); break; case C_SNULL: /* split on empty string */ cnt = null_split(string(sp)->str, string(sp)->len); break; default: bozo("bad splitting cell in bi_split"); } } free_STRING(string(sp)); sp->type = C_DOUBLE; sp->dval = (double) cnt; array_load((ARRAY) (sp + 1)->ptr, cnt); return sp; } mawk-1.3.4-20240123/makedeps.sh0000755000000000000000000000226014520304016014172 0ustar rootroot#!/bin/sh # $MawkId: makedeps.sh,v 1.3 2023/10/31 23:04:46 tom Exp $ ############################################################################### # copyright 2009-2010,2023 Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### if test ! -f config.h then echo "? config.h not found" exit 1 fi if test ! -f mawk then echo "? mawk not found" exit 1 fi cat >makedeps.awk <<'EOF' # vile:awkmode # regexp.c is a special case function AddDeps() { for (n = 1; n < NF; ++n) { name = $n; if ( name == ":" ) { ; } else { sub("[.]o$", ".c", name); deps[name] = 1; } } } BEGIN { count = 0; } EOF grep -E 'include.*\.c"' regexp.c | sed -e 's/^#[^"]*"/\/^/' \ -e 's/\.c/\\.o/' \ -e 's/"/\/ { AddDeps(); next; }/' \ >>makedeps.awk cat >>makedeps.awk <<'EOF' { print; } END { printf "regexp.o :"; for (name in deps) { printf " %s", name; } printf "\n"; } EOF WHINY_USERS=yes ./mawk -f examples/deps.awk *.c | mawk -f makedeps.awk mawk-1.3.4-20240123/rexpdb.c0000644000000000000000000000527414456075614013523 0ustar rootroot/******************************************** rexpdb.c copyright 2008-2020,2023, Thomas E. Dickey copyright 1991,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: rexpdb.c,v 1.24 2023/07/20 00:10:52 tom Exp $ */ #include "rexp.h" #include /* print a machine for debugging */ static const char xlat[][12] = { "M_STR", "M_CLASS", "M_ANY", "M_START", "M_END", "M_U", "M_1J", "M_2JA", "M_2JB", "M_SAVE_POS", "M_2JC", "M_ACCEPT" }; const char * REs_type(STATE * p) { return (xlat[((UChar) (p->s_type)) % U_ON]); } void REmprint(STATE * m, FILE *f) { STATE *base = m; STATE *p = base; const char *end_on_string; while (1) { int line = (int) (p - base); fprintf(f, "%03d ", line); fprintf(f, ".\t"); if (p->s_type >= END_ON) { p->s_type = (SType) (p->s_type - END_ON); end_on_string = "$"; } else end_on_string = ""; if (p->s_type < 0 || p->s_type >= END_ON) { fprintf(f, "unknown STATE type %d\n", (int) (p->s_type)); return; } fprintf(f, "%s", xlat[((UChar) (p->s_type)) % U_ON]); switch (p->s_type) { case M_STR: fprintf(f, "\t"); da_string2(f, p->s_data.str, (size_t) p->s_len, '"'); break; case M_1J: case M_2JA: case M_2JB: fprintf(f, "\t%03d", line + p->s_data.jump); break; case M_2JC: fprintf(f, "\t%03d", line + p->s_data.jump); #ifndef NO_INTERVAL_EXPR if (p->it_min != 1 || p->it_max != MAX__INT) { fprintf(f, " %c", L_CURL); if (p->it_min != 0) fprintf(f, INT_FMT, p->it_min); if (p->it_max != p->it_min) { fprintf(f, ","); if (p->it_max != MAX__INT) fprintf(f, INT_FMT, p->it_max); } fprintf(f, "%c", R_CURL); } #endif break; case M_CLASS: { UChar *q = (UChar *) p->s_data.bvp; UChar *r = q + sizeof(BV); unsigned bitnum = 0; fprintf(f, "\t["); while (q < r) { unsigned bits = *q++; if (bits != 0) { unsigned b; for (b = 0; b < 8; ++b) { if (bits & (unsigned) (1 << b)) { int ch = (int) (bitnum + b); if (ch < 32 || ch >= 128) { fprintf(f, "\\%03o", ch); } else { if (strchr("\\[]", ch)) fprintf(f, "\\"); fprintf(f, "%c", ch); } } } } bitnum += 8; } fprintf(f, "]"); } break; } if (end_on_string[0]) fprintf(f, "\t%s", end_on_string); fprintf(f, "\n"); if (end_on_string[0]) p->s_type = (SType) (p->s_type + END_ON); if (p->s_type == M_ACCEPT) return; p++; } } mawk-1.3.4-20240123/split.h0000644000000000000000000000140514457165637013375 0ustar rootroot/******************************************** split.h copyright 2014,2023 Thomas E. Dickey copyright 2014, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: split.h,v 1.4 2023/07/23 08:58:07 tom Exp $ */ /* split.h */ #ifndef MAWK_SPLIT_H #define MAWK_SPLIT_H extern size_t null_split(const char *s, size_t slen); extern size_t re_split(char *s, size_t slen, PTR re); extern size_t space_split(const char *s, size_t slen); extern void transfer_to_array(CELL cp[], size_t cnt); extern void transfer_to_fields(size_t cnt); #endif /* MAWK_SPLIT_H */ mawk-1.3.4-20240123/error.c0000644000000000000000000001634314462277103013361 0ustar rootroot/******************************************** error.c copyright 2008-2020,2023 Thomas E. Dickey copyright 1991-1994,1995 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: error.c,v 1.26 2023/08/01 21:50:59 tom Exp $ */ #include #include #include #ifdef DEBUG #define FLUSH() fflush(stdout) #else #define FLUSH() /* nothing */ #endif /* for run time error messages only */ unsigned rt_nr, rt_fnr; /* *INDENT-OFF* */ static const struct token_str { short token; const char str[12]; } token_str[] = { { EOF, "end of file" }, { NL, "end of line" }, { SEMI_COLON, ";" }, { LBRACE, "{" }, { RBRACE, "}" }, { SC_FAKE_SEMI_COLON, "}" }, { LPAREN, "(" }, { RPAREN, ")" }, { LBOX, "[" }, { RBOX, "]" }, { QMARK, "?" }, { COLON, ":" }, { OR, "||" }, { AND, "&&" }, { ASSIGN, "=" }, { ADD_ASG, "+=" }, { SUB_ASG, "-=" }, { MUL_ASG, "*=" }, { DIV_ASG, "/=" }, { MOD_ASG, "%=" }, { POW_ASG, "^=" }, { EQ, "==" }, { NEQ, "!=" }, { LT, "<" }, { LTE, "<=" }, { GT, ">" }, { GTE, ">=" }, { MATCH, "" }, /* string_buff */ { PLUS, "+" }, { MINUS, "-" }, { MUL, "*" }, { DIV, "/" }, { MOD, "%" }, { POW, "^" }, { NOT, "!" }, { COMMA, "," }, { INC_or_DEC, "" }, /* string_buff */ { DOUBLE, "" }, /* string_buff */ { STRING_, "" }, /* string_buff */ { ID, "" }, /* string_buff */ { FUNCT_ID, "" }, /* string_buff */ { BUILTIN, "" }, /* string_buff */ { IO_OUT, "" }, /* string_buff */ { IO_IN, "<" }, { PIPE, "|" }, { DOLLAR, "$" }, { FIELD, "$" }, { 0, "" } }; /* *INDENT-ON* */ /* if paren_cnt >0 and we see one of these, we are missing a ')' */ static const int missing_rparen[] = { EOF, NL, SEMI_COLON, SC_FAKE_SEMI_COLON, RBRACE, 0 }; /* ditto for '}' */ static const int missing_rbrace[] = { EOF, BEGIN, END, 0 }; static void missing(int c, const char *n, unsigned ln) { const char *s0, *s1; if (pfile_name) { s0 = pfile_name; s1 = ": "; } else s0 = s1 = ""; errmsg(0, "%s%sline %u: missing %c near %s", s0, s1, ln, c, n); } void yyerror(const char *s GCC_UNUSED) { const char *ss = 0; const struct token_str *p; const int *ip; for (p = token_str; p->token; p++) if (current_token == p->token) { ss = p->str[0] ? p->str : string_buff; break; } if (!ss) /* search the keywords */ ss = find_kw_str(current_token); if (ss) { if (paren_cnt) for (ip = missing_rparen; *ip; ip++) if (*ip == current_token) { missing(')', ss, token_lineno); paren_cnt = 0; goto done; } if (brace_cnt) for (ip = missing_rbrace; *ip; ip++) if (*ip == current_token) { missing('}', ss, token_lineno); brace_cnt = 0; goto done; } compile_error("syntax error at or near %s", ss); } else /* special cases */ switch (current_token) { case UNEXPECTED: unexpected_char(); goto done; case BAD_DECIMAL: compile_error( "syntax error in decimal constant %s", string_buff); break; case RE: compile_error( "syntax error at or near /%s/", string_buff); break; default: compile_error("syntax error"); break; } return; done: if (++compile_error_count == MAX_COMPILE_ERRORS) mawk_exit(2); } /* generic error message with a hook into the system error messages if errnum > 0 */ void errmsg(int errnum, const char *format, ...) { va_list args; FLUSH(); fprintf(stderr, "%s: ", progname); #if OPT_TRACE > 0 va_start(args, format); Trace("\n?? errmsg \n"); TraceVA(format, args); Trace("\n"); va_end(args); #endif va_start(args, format); vfprintf(stderr, format, args); va_end(args); if (errnum > 0) fprintf(stderr, " (%s)", strerror(errnum)); fprintf(stderr, "\n"); } void compile_error(const char *format, ...) { va_list args; const char *s0, *s1; /* with multiple program files put program name in error message */ if (pfile_name) { s0 = pfile_name; s1 = ": "; } else { s0 = s1 = ""; } FLUSH(); fprintf(stderr, "%s: %s%sline %u: ", progname, s0, s1, token_lineno); va_start(args, format); vfprintf(stderr, format, args); va_end(args); fprintf(stderr, "\n"); if (++compile_error_count >= MAX_COMPILE_ERRORS) mawk_exit(2); } void bozo(const char *s) { errmsg(0, "bozo: %s", s); mawk_exit(3); } void overflow(const char *s, unsigned size) { errmsg(0, "program limit exceeded: %s size=%u", s, size); mawk_exit(2); } /* print as much as we know about where a rt error occurred */ static void rt_where(void) { if (FILENAME->type != C_STRING) cast1_to_s(FILENAME); fprintf(stderr, "\tFILENAME=\"%s\" FNR=%u NR=%u\n", string(FILENAME)->str, rt_fnr, rt_nr); } void rt_error(const char *format, ...) { va_list args; FLUSH(); fprintf(stderr, "%s: run time error: ", progname); va_start(args, format); vfprintf(stderr, format, args); va_end(args); putc('\n', stderr); rt_where(); mawk_exit(2); } /* run time */ void rt_overflow(const char *s, unsigned size) { errmsg(0, "program limit exceeded: %s size=%u", s, size); rt_where(); mawk_exit(2); } void unexpected_char(void) { int c = yylval.ival; FLUSH(); fprintf(stderr, "%s: %u: ", progname, token_lineno); if (c > ' ' && c < 127) fprintf(stderr, "unexpected character '%c'\n", c); else fprintf(stderr, "unexpected character 0x%02x\n", c); } const char * type_to_str(int type) { const char *retval = 0; switch (type) { case ST_NONE: retval = "untyped variable"; break; case ST_VAR: retval = "variable"; break; case ST_KEYWORD: retval = "keyword"; break; case ST_BUILTIN: retval = "builtin"; break; case ST_ARRAY: retval = "array"; break; case ST_FIELD: retval = "field"; break; case ST_NR: retval = "NR"; break; case ST_ENV: retval = "ENVIRON"; break; case ST_FUNCT: retval = "function"; break; case ST_LOCAL_VAR: retval = "local variable"; break; case ST_LOCAL_NONE: retval = "local untyped variable"; break; case ST_LOCAL_ARRAY: retval = "local array"; break; default: bozo("type_to_str"); } return retval; } /* emit an error message about a type clash */ void type_error(SYMTAB * p) { compile_error("illegal reference to %s %s", type_to_str(p->type), p->name); } mawk-1.3.4-20240123/ACKNOWLEDGMENT0000644000000000000000000000276006176763171014117 0ustar rootrootVersion 1.2 =========== Thanks for help with beta test to Bill Davidsen, Tom Dickey, Ed Ferguson, Jack Fitts, Onno van der Linden, Carl Mascott, Jean-Pierre Radley, John Roll, Ian Searle, Bob Stockler. The calendar program examples/hical was written by Bob Stockler. Darrel Hankerson ported versions 1.2.x to DOS/OS2. Version 1.0 and 1.1 =================== Carl Mascott ported mawk to V7 and in the process rooted out some subtle (and not so subtle) bugs. Ian Searle ported mawk to System V and put up with my insane attempts to get fpe exception trapping off. An anonymous reviewer for comp.sources.reviewed did the MSC and Mac ports and wrote .bat files for the tests. Another or maybe the same reviewer did the Dynix port. Ports to new systems: Ed Ferguson MIPS M2000 C2.20 OS4.52 Jwahar R. Bammi Atari ST Berry Kercheval SGI IRIX 4.0.1 Andy Newman Next 2.1 Mike Carlton Next 2.1 Elliot Jaffe AIX 3.1 Jeremy Martin Convex 9.1 Scott Hunziker Coherent 4.0 Ken Poulton Hpux Onno van der Linden 386bsd 0.1 Bob Hutchinson Linux 0.98p14 The DOS version is a lot better thanks to suggestions and testing from Ed Ferguson, Jack Fitts, Nadav Horesh, Michael Golan and Conny Ohstrom. The DOS additions for 1.1.2d are all ideas of Ben Myers; much of the code is his too. Arnold Robbins kept me current on POSIX standards for AWK, and explained some of the "dark corners". Thank you to everyone who reported bugs or offered encouragement, suggestions or criticism. (At least the bugs got fixed). mawk-1.3.4-20240123/regexp.c0000644000000000000000000000224013742417067013516 0ustar rootroot/* regexp_system.c copyright 2009-2014,2020, Thomas E. Dickey copyright 2005, Aleksey Cheusov This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. */ /* $MawkId: regexp.c,v 1.10 2020/10/16 22:27:03 tom Exp $ */ #include #ifdef LOCAL_REGEXP #define REGEXP_INTERNALS # include "mawk.h" #define RE_FILL() { goto refill; } #define RE_CASE() { goto reswitch; } # include "rexp.c" # include "rexp0.c" # include "rexp1.c" # include "rexp2.c" # include "rexp3.c" # include "rexp4.c" # include "rexpdb.c" #else # include "rexp4.c" # include "regexp_system.c" #endif #ifdef NO_LEAKS void rexp_leaks(void) { TRACE(("rexp_leaks\n")); #ifdef LOCAL_REGEXP lookup_cclass(0); if (bv_base) { BV **p = bv_base; while (p != bv_next) { RE_free(*p); ++p; } RE_free(bv_base); bv_base = 0; bv_limit = 0; bv_next = 0; } if (RE_run_stack_base) { RE_free(RE_run_stack_base); RE_run_stack_base = 0; } if (RE_pos_stack_base) { RE_free(RE_pos_stack_base); RE_pos_stack_base = 0; } #endif } #endif mawk-1.3.4-20240123/field.c0000644000000000000000000003701514457210044013305 0ustar rootroot/******************************************** field.c copyright 2008-2021,2023 Thomas E. Dickey copyright 1991-1995,2014 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: field.c,v 1.41 2023/07/23 11:33:56 tom Exp $ */ /* field.c */ #include "mawk.h" #include "split.h" #include "field.h" #include "init.h" #include "memory.h" #include "scan.h" #include "bi_vars.h" #include "repl.h" #include "regexp.h" /* initial fields and pseudo fields, most programs only need these */ CELL field[FBANK_SZ + NUM_PFIELDS]; /* hold banks of more fields if needed */ CELL **fbankv; /* fbankv grows in chunks */ #define FBANKV_CHUNK_SIZE 1024 static size_t fbankv_num_chunks; /* make fbankv big enough to hold field CELL $i is called with i==0 during initialization This does not create field CELL $i, it just makes fbankv big enough to hold the fbank that will hold $i */ static void allocate_fbankv(int i) { if (i == 0) { size_t sz = FBANKV_CHUNK_SIZE * sizeof(CELL *); fbankv_num_chunks = 1; fbankv = (CELL **) zmalloc(sz); memset(fbankv, 0, sz); fbankv[0] = field; } else { size_t u = (size_t) i + 1; size_t chunks = (u / (FBANK_SZ * FBANKV_CHUNK_SIZE)) + 1; if (chunks > fbankv_num_chunks) { size_t old_size = fbankv_num_chunks * FBANKV_CHUNK_SIZE; size_t new_size = chunks * FBANKV_CHUNK_SIZE; fbankv = zrealloc(fbankv, old_size * sizeof(CELL *), new_size * sizeof(CELL *)); memset(&fbankv[old_size], 0, (new_size - old_size) * sizeof(CELL *)); fbankv_num_chunks = chunks; } } } /* max_field created i.e. $max_field exists as new fields are created max_field grows */ static int max_field = FBANK_SZ - 1; /* The fields $0, $1, ... $max_field are always valid, the value of nf (below) does not affect validity of the allocated fields. When a new $0 is read, nf is set to -1 to indicate $0 has not been split, field[1], field[2] ... field[3] (actually fbankv[i/1024][i%1024]) are unchanged. So any time a field is assigned or changed, it has to be cell_destroyed first and this is the only way a field gets cell_destroyed. */ static void build_field0(void); /* a description of how to split based on RS. If RS is changed, so is rs_shadow */ SEPARATOR rs_shadow = { SEP_CHAR, '\n', NULL }; /* a splitting CELL version of FS */ CELL fs_shadow = { C_SPACE, 0, 0, 0.0 }; int nf; /* nf holds the true value of NF. If nf < 0 , then NF has not been computed, i.e., $0 has not been split */ static void set_rs_shadow(void) { CELL c; STRING *sval; char *s; size_t len; if (posix_space_flag && mawk_state == EXECUTION) scan_code['\n'] = SC_UNEXPECTED; if (rs_shadow.type == SEP_STR) { free_STRING((STRING *) rs_shadow.ptr); } cast_for_split(cellcpy(&c, RS)); switch (c.type) { case C_RE: if ((s = is_string_split(c.ptr, &len))) { if (len == 1) { rs_shadow.type = SEP_CHAR; rs_shadow.c = s[0]; } else { rs_shadow.type = SEP_STR; rs_shadow.ptr = (PTR) new_STRING(s); } } else { rs_shadow.type = SEP_RE; rs_shadow.ptr = c.ptr; } break; case C_SPACE: rs_shadow.type = SEP_CHAR; rs_shadow.c = ' '; break; case C_SNULL: /* RS becomes one or more blank lines */ if (mawk_state == EXECUTION) scan_code['\n'] = SC_SPACE; rs_shadow.type = SEP_MLR; sval = new_STRING("\n\n+"); rs_shadow.ptr = re_compile(sval); free_STRING(sval); break; case C_STRING: /* * Check for special case where we retained the cell as a string, * bypassing regular-expression compiling. */ if (string(&c)->len == 1) { rs_shadow.type = SEP_CHAR; rs_shadow.c = string(&c)->str[0]; break; } /* FALLTHRU */ default: bozo("bad cell in set_rs_shadow"); } } static void load_pfield(const char *name, CELL *cp) { SYMTAB *stp; stp = insert(name); stp->type = ST_FIELD; stp->stval.cp = cp; } /* initialize $0 and the pseudo fields */ void field_init(void) { allocate_fbankv(0); field[0].type = C_STRING; field[0].ptr = (PTR) & null_str; null_str.ref_cnt++; load_pfield("NF", NF); NF->type = C_DOUBLE; NF->dval = 0.0; load_pfield("RS", RS); RS->type = C_STRING; RS->ptr = (PTR) new_STRING("\n"); /* rs_shadow already set */ load_pfield("FS", FS); FS->type = C_STRING; FS->ptr = (PTR) new_STRING(" "); /* fs_shadow is already set */ load_pfield("OFMT", OFMT); OFMT->type = C_STRING; OFMT->ptr = (PTR) new_STRING("%.6g"); load_pfield("CONVFMT", CONVFMT); CONVFMT->type = C_STRING; CONVFMT->ptr = OFMT->ptr; string(OFMT)->ref_cnt++; } void set_field0(const char *s, size_t len) { cell_destroy(&field[0]); nf = -1; if (len) { field[0].type = C_MBSTRN; field[0].ptr = (PTR) new_STRING0(len); memcpy(string(&field[0])->str, s, len); } else { field[0].type = C_STRING; field[0].ptr = (PTR) & null_str; null_str.ref_cnt++; } } /* split field[0] into $1, $2 ... and set NF * * Note the current values are valid CELLS and * have to be destroyed when the new values are loaded. */ void split_field0(void) { CELL *cp0; size_t cnt = 0; CELL hold0; /* copy field[0] here if not string */ if (field[0].type < C_STRING) { cast1_to_s(cellcpy(&hold0, field + 0)); cp0 = &hold0; } else { cp0 = &field[0]; } if (string(cp0)->len > 0) { switch (fs_shadow.type) { case C_SNULL: /* FS == "" */ cnt = null_split(string(cp0)->str, string(cp0)->len); break; case C_SPACE: cnt = space_split(string(cp0)->str, string(cp0)->len); break; default: cnt = re_split(string(cp0)->str, string(cp0)->len, fs_shadow.ptr); break; } } /* the above xxx_split() function put the fields in an anonyous * buffer that will be pulled into the fields with a transfer call */ /* we are done with cp0 */ if (cp0 == &hold0) free_STRING(string(cp0)); nf = (int) cnt; cell_destroy(NF); NF->type = C_DOUBLE; NF->dval = (double) nf; if (nf > max_field) slow_field_ptr(nf); /* fields 1 .. nf are created and valid */ /* retrieves the result of xxx_split() */ if (cnt > 0) { transfer_to_fields(cnt); } } static void invalid_format(CELL *fp) { const char *what = (fp == CONVFMT) ? "CONVFMT" : "OFMT"; const char *format = string(fp)->str; rt_error("illegal format assigned to %s: %s", what, format); } /* * We expect only one field, using the same format choices as in do_printf(). */ static int valid_format(CELL *fp) { int result = 1; char *format = string(fp)->str; char *q = format; int args = 0; while (*q != '\0') { if (*q++ == '%') { int l_flag = 0; int h_flag = 0; if (++args > 1) invalid_format(fp); while (*q == '-' || *q == '+' || *q == ' ' || *q == '#' || *q == '0' || *q == '\'') { q++; } if (*q == '*') { invalid_format(fp); } else { while (scan_code[*(unsigned char *) q] == SC_DIGIT) { q++; } } if (*q == '.') { /* have precision */ q++; if (*q == '*') { invalid_format(fp); } else { while (scan_code[*(unsigned char *) q] == SC_DIGIT) { q++; } } } if (*q == 'l') { q++; } else if (*q == 'h') { q++; } switch (*q++) { case 's': if (l_flag + h_flag) invalid_format(fp); break; case 'c': if (l_flag + h_flag) invalid_format(fp); break; case 'd': case 'i': break; case 'o': case 'x': case 'X': case 'u': break; case 'e': case 'g': case 'f': case 'E': case 'G': if (h_flag + l_flag) invalid_format(fp); break; default: invalid_format(fp); } } } return result; } /* assign CELL *cp to field or pseudo field and take care of all side effects */ void field_assign(CELL *fp, CELL *cp) { CELL c; int i, j; /* the most common case first */ if (fp == field) { cell_destroy(field); cellcpy(fp, cp); nf = -1; return; } /* its not important to do any of this fast */ if (nf < 0) split_field0(); switch (i = (int) (fp - field)) { case NF_field: cell_destroy(NF); cellcpy(NF, cellcpy(&c, cp)); if (c.type != C_DOUBLE) cast1_to_d(&c); if ((j = d_to_i(c.dval)) < 0) rt_error("negative value assigned to NF"); if (j > nf) for (i = nf + 1; i <= j; i++) { cp = field_ptr(i); cell_destroy(cp); cp->type = C_STRING; cp->ptr = (PTR) & null_str; null_str.ref_cnt++; } nf = j; build_field0(); break; case RS_field: cell_destroy(RS); cellcpy(RS, cp); set_rs_shadow(); break; case FS_field: cell_destroy(FS); cast_for_split(cellcpy(&fs_shadow, cellcpy(FS, cp))); break; case OFMT_field: case CONVFMT_field: /* If the user does something stupid with OFMT or CONVFMT, we could crash. We'll make an attempt to protect ourselves here. This is why OFMT and CONVFMT are pseudo fields. The ptrs of OFMT and CONVFMT always have a valid STRING, even if assigned a DOUBLE or NOINIT */ free_STRING(string(fp)); cellcpy(fp, cp); if (fp->type < C_STRING) { /* !! */ fp->ptr = (PTR) new_STRING("%.6g"); } else if (valid_format(fp)) { if (fp == CONVFMT) { /* It's a string, but if it's really goofy and CONVFMT, it could still damage us. Test it . */ char xbuff[512]; xbuff[256] = 0; sprintf(xbuff, string(fp)->str, 3.1459); if (xbuff[256]) rt_error("CONVFMT assigned unusable value"); } } break; #ifdef MSDOS lm_dos_label: #endif default: /* $1 or $2 or ... */ cell_destroy(fp); cellcpy(fp, cp); if (i < 0 || i >= FBANK_SZ) { /* field assigned to was not in field[0..FBANK_SZ-1] * or a pseudo field, so compute actual field index */ i = field_addr_to_index(fp); } if (i > nf) { for (j = nf + 1; j < i; j++) { cp = field_ptr(j); cell_destroy(cp); cp->type = C_STRING; cp->ptr = (PTR) & null_str; null_str.ref_cnt++; } nf = i; cell_destroy(NF); NF->type = C_DOUBLE; NF->dval = (double) i; } build_field0(); } } /* construct field[0] from the other fields */ static void build_field0(void) { #ifdef DEBUG if (nf < 0) bozo("nf <0 in build_field0"); #endif cell_destroy(field + 0); if (nf == 0) { field[0].type = C_STRING; field[0].ptr = (PTR) & null_str; null_str.ref_cnt++; } else if (nf == 1) { cellcpy(field, field + 1); } else { CELL c; STRING *ofs, *tail; size_t len; register CELL *cp; int cnt; register char *p; CELL **fbp, *cp_limit; cast1_to_s(cellcpy(&c, OFS)); ofs = (STRING *) c.ptr; cast1_to_s(cellcpy(&c, field_ptr(nf))); tail = (STRING *) c.ptr; cnt = nf - 1; len = ((size_t) cnt) * ofs->len + tail->len; fbp = fbankv; cp_limit = field + FBANK_SZ; cp = field + 1; while (cnt-- > 0) { if (cp->type < C_STRING) { /* use the string field temporarily */ if (cp->type == C_NOINIT) { cp->ptr = (PTR) & null_str; null_str.ref_cnt++; } else { /* its a double */ Long ival; char xbuff[260]; ival = d_to_L(cp->dval); if (ival == cp->dval) sprintf(xbuff, LONG_FMT, ival); else sprintf(xbuff, string(CONVFMT)->str, cp->dval); cp->ptr = (PTR) new_STRING(xbuff); } } len += string(cp)->len; if (++cp == cp_limit) { cp = *++fbp; cp_limit = cp + FBANK_SZ; } } field[0].type = C_STRING; field[0].ptr = (PTR) new_STRING0(len); p = string(field)->str; /* walk it again , putting things together */ cnt = nf - 1; fbp = fbankv; cp = field + 1; cp_limit = field + FBANK_SZ; while (cnt-- > 0) { register char *q; memcpy(p, string(cp)->str, string(cp)->len); p += string(cp)->len; /* if not really string, free temp use of ptr */ if (cp->type < C_STRING) { free_STRING(string(cp)); } if (++cp == cp_limit) { cp = *++fbp; cp_limit = cp + FBANK_SZ; } /* add the separator */ q = ofs->str; while (*q) *p++ = *q++; } /* tack tail on the end */ memcpy(p, tail->str, tail->len); /* cleanup */ if (tail == ofs) { free_STRING(tail); } else { free_STRING(tail); free_STRING(ofs); } } } /* We are assigning to a CELL and we aren't sure if its a field */ void slow_cell_assign(CELL *target, CELL *source) { if (field <= target && target <= LAST_PFIELD) { field_assign(target, source); } else { size_t i; for (i = 1; i < fbankv_num_chunks * FBANKV_CHUNK_SIZE; i++) { CELL *bank_start = fbankv[i]; CELL *bank_end; if (bank_start == 0) break; bank_end = bank_start + FBANK_SZ; if (bank_start <= target && target < bank_end) { /* it is a field */ field_assign(target, source); return; } } /* its not a field */ cell_destroy(target); cellcpy(target, source); } } int field_addr_to_index(CELL *cp) { CELL **p = fbankv; while (cp < *p || cp >= *p + FBANK_SZ) p++; return (int) (((p - fbankv) << FB_SHIFT) + (cp - *p)); } /*------- more than 1 fbank needed ------------*/ /* compute the address of a field $i if CELL $i doesn't exist, because it is bigger than max_field, then it gets created and max_field grows. */ CELL * slow_field_ptr(int i) { if (i > max_field) { /* need to allocate more field memory */ int j; allocate_fbankv(i); j = (max_field >> FB_SHIFT) + 1; assert(j > 0 && fbankv[j - 1] != 0 && fbankv[j] == 0); do { fbankv[j] = (CELL *) zmalloc(sizeof(CELL) * FBANK_SZ); memset(fbankv[j], 0, sizeof(CELL) * FBANK_SZ); j++; max_field += FBANK_SZ; } while (i > max_field); } return &fbankv[i >> FB_SHIFT][i & (FBANK_SZ - 1)]; } #if USE_BINMODE /* read current value of BINMODE */ int binmode(void) { CELL c; cast1_to_d(cellcpy(&c, BINMODE)); return d_to_i(c.dval); } /* set BINMODE and RS and ORS from environment or -W binmode= */ void set_binmode(long x) { CELL c; int change = ((x & 4) == 0); /* set RS */ c.type = C_STRING; c.ptr = (PTR) new_STRING((change && (x & 1)) ? "\r\n" : "\n"); field_assign(RS, &c); free_STRING(string(&c)); /* set ORS */ cell_destroy(ORS); ORS->type = C_STRING; ORS->ptr = (PTR) new_STRING((change && (x & 2)) ? "\r\n" : "\n"); cell_destroy(BINMODE); BINMODE->type = C_DOUBLE; BINMODE->dval = (double) x; } #endif /* USE_BINMODE */ #ifdef NO_LEAKS static void fbank_free(CELL *const fb) { CELL *end = fb + FBANK_SZ; CELL *cp; for (cp = fb; cp < end; cp++) { cell_destroy(cp); } zfree(fb, FBANK_SZ * sizeof(CELL)); } static void fbankv_free(void) { unsigned i = 1; const size_t cnt = FBANKV_CHUNK_SIZE * fbankv_num_chunks; while (i < cnt && fbankv[i] != 0) { fbank_free(fbankv[i]); i++; } for (; i < cnt; i++) { if (fbankv[i] != 0) { bozo("unexpected pointer in fbankv[]"); } } zfree(fbankv, cnt * sizeof(CELL *)); } void field_leaks(void) { int n; /* everything in field[] */ for (n = 0; n < FBANK_SZ + NUM_PFIELDS; n++) { cell_destroy(&field[n]); } /* fbankv[0] == field this call does all the rest of the fields */ fbankv_free(); switch (fs_shadow.type) { case C_RE: re_destroy(fs_shadow.ptr); break; case C_STRING: case C_STRNUM: case C_MBSTRN: cell_destroy(&fs_shadow); break; default: break; } switch (rs_shadow.type) { case SEP_STR: free_STRING(((STRING *) (&rs_shadow.ptr))); break; case SEP_RE: re_destroy(rs_shadow.ptr); break; } } #endif mawk-1.3.4-20240123/scancode.h0000644000000000000000000000222014457054246014006 0ustar rootroot/******************************************** scancode.h copyright 2023, Thomas E. Dickey copyright 2009, Jonathan Nieder copyright 1991, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: scancode.h,v 1.3 2023/07/22 22:31:02 tom Exp $ */ /* scancode.h */ #ifndef SCANCODE_H_INCLUDED #define SCANCODE_H_INCLUDED 1 extern char scan_code[256]; /* the scan codes to compactify the main switch */ typedef enum { SC_SPACE = 1 ,SC_NL ,SC_SEMI_COLON ,SC_FAKE_SEMI_COLON ,SC_LBRACE ,SC_RBRACE ,SC_QMARK ,SC_COLON ,SC_OR ,SC_AND ,SC_PLUS ,SC_MINUS ,SC_MUL ,SC_DIV ,SC_MOD ,SC_POW ,SC_LPAREN ,SC_RPAREN ,SC_LBOX ,SC_RBOX ,SC_IDCHAR ,SC_DIGIT ,SC_DQUOTE ,SC_ESCAPE ,SC_COMMENT ,SC_EQUAL ,SC_NOT ,SC_LT ,SC_GT ,SC_COMMA ,SC_DOT ,SC_MATCH ,SC_DOLLAR ,SC_UNEXPECTED } SCAN_CODES; #endif /* SCANCODE_H_INCLUDED */ mawk-1.3.4-20240123/print.c0000644000000000000000000005123714530761764013374 0ustar rootroot/******************************************** print.c copyright 2008-2021,2023. Thomas E. Dickey copyright 1991-1996,2014. Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: print.c,v 1.48 2023/11/27 00:33:56 tom Exp $ */ #include "mawk.h" #include "bi_vars.h" #include "bi_funct.h" #include "memory.h" #include "field.h" #include "scan.h" #include "files.h" #include "init.h" #ifdef USE_LL_FORMAT #define ELL_LIMIT 2 #define SpliceFormat(n) splice = 1 #else #define ELL_LIMIT 1 #define SpliceFormat(n) if (n) splice = 1 #endif #define CopySplice(dst,src) \ { \ size_t pp; \ for (pp = 0; (pp < sizeof(dst) - 1) && (src[pp] != 0); ++pp) \ dst[pp] = src[pp]; \ dst[pp] = 0; \ } #ifdef SHORT_INTS #define MY_FMT xbuff /* format in xbuff */ #else #define MY_FMT p /* p -> format */ #endif static void write_error(void); /* this can be moved and enlarged by -W sprintf=num */ char *sprintf_buff = string_buff; char *sprintf_limit = string_buff + sizeof(string_buff); /* Once execute() starts the sprintf code is (belatedly) the only code allowed to use string_buff */ static void print_cell(CELL *p, FILE *fp) { size_t len; switch (p->type) { case C_NOINIT: break; case C_MBSTRN: case C_STRING: case C_STRNUM: switch (len = string(p)->len) { case 0: break; case 1: putc(string(p)->str[0], fp); break; default: fwrite(string(p)->str, (size_t) 1, len, fp); } break; case C_DOUBLE: if (p->dval >= (double) Max_Long) { ULong ival = d_to_UL(p->dval); /* integers can print as "%[l]u", for additional range */ if ((double) ival == p->dval) fprintf(fp, ULONG_FMT, ival); else fprintf(fp, string(OFMT)->str, p->dval); } else { Long ival = d_to_L(p->dval); /* integers print as "%[l]d" */ if ((double) ival == p->dval) fprintf(fp, LONG_FMT, ival); else fprintf(fp, string(OFMT)->str, p->dval); } break; default: bozo("bad cell passed to print_cell"); } } /* on entry to bi_print or bi_printf the stack is: sp[0] = an integer k if ( k < 0 ) output is to a file with name in sp[-1] { so open file and sp -= 2 } sp[0] = k >= 0 is the number of print args sp[-k] holds the first argument */ CELL * bi_print(CELL *sp) /* stack ptr passed in */ { register CELL *p; register int k; FILE *fp; k = sp->type; if (k < 0) { /* k holds redirection */ if ((--sp)->type < C_STRING) cast1_to_s(sp); fp = (FILE *) file_find(string(sp), k); free_STRING(string(sp)); k = (--sp)->type; /* k now has number of arguments */ } else fp = stdout; if (k) { p = sp - k; /* clear k variables off the stack */ sp = p - 1; k--; while (k > 0) { print_cell(p, fp); print_cell(OFS, fp); cell_destroy(p); p++; k--; } print_cell(p, fp); cell_destroy(p); } else { /* print $0 */ sp--; print_cell(&field[0], fp); } print_cell(ORS, fp); if (ferror(fp)) write_error(); return sp; } /*---------- types and defs for doing printf and sprintf----*/ typedef enum { PF_C = 0, /* %c */ PF_S, /* %s */ PF_D, /* int conversion */ PF_F, /* float conversion */ PF_U, /* unsigned conversion */ PF_last } PF_enum; /* for switch on number of '*' and type */ #define AST(num,type) ((PF_last)*(num)+(type)) /*-------------------------------------------------------*/ static void bad_conversion(int cnt, const char *who, const char *format) { rt_error("improper conversion(number %d) in %s(\"%s\")", cnt, who, format); } typedef enum { sfmtSPACE = 1, sfmtMINUS = 2, sfmtZEROS = 4, sfmtWIDTH = 8, sfmtPREC = 16 } enumSFMT; /* * nawk pads leading 0's if it sees a format such as "%06s". * C's printf/sprintf do not do that. * So we decode the format and interpret it according to nawk. */ static int make_sfmt(const char *format, int *fill_in, int *width, int *prec, int *flags) { int parts = 0; int digits = 0; int value = 0; int used = 0; int success = 1; int ok_flag = 1; *width = 0; *prec = 0; *flags = 0; ++format; while (*format != '\0' && ok_flag) { switch (*format++) { case ' ': *flags |= sfmtSPACE; break; case '-': *flags |= sfmtMINUS; break; case '0': *flags |= sfmtZEROS; break; case '+': /* FALLTHRU */ case '#': /* ignore for %s */ break; default: ok_flag = 0; --format; break; } } while (*format != '\0' && success) { int ch; switch (ch = *format++) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digits < 0) { success = 0; } else if (digits++ == 0) { value = (ch - '0'); } else { value = (10 * value) + (ch - '0'); } break; case '.': if (parts) { success = 0; } else { if (digits) { *width = value; *flags |= sfmtWIDTH; digits = 0; value = 0; } parts = 1; } break; case '*': if (digits == 0) { value = fill_in[used++]; digits = -1; } else { success = 0; } break; case 'c': /* FALLTHRU */ case 's': if (digits) { if (parts) { *prec = value; *flags |= sfmtPREC; } else { *width = value; *flags |= sfmtWIDTH; } } if (*format != '\0') success = 0; break; default: success = 0; break; } } return success; } #define SprintfOverflow(bfr, need) \ if (bfr + need + 1 >= sprintf_limit) { \ rt_overflow("sprintf buffer", \ (unsigned) (sprintf_limit - sprintf_buff)); \ } static char * SprintfChar(char *buffer, int ch) { SprintfOverflow(buffer, 1); *buffer++ = (char) ch; return buffer; } static char * SprintfFill(char *buffer, int ch, int fill) { SprintfOverflow(buffer, fill); memset(buffer, ch, (size_t) fill); return buffer + fill; } static char * SprintfBlock(char *buffer, const char *source, int length) { SprintfOverflow(buffer, length); memcpy(buffer, source, (size_t) length); return buffer + length; } /* * Write the s-format text. */ static void stream_puts_sfmt(FILE *fp, const char *src_str, int src_len, int width, int prec, int flags) { if (width < 0) { width = -width; flags |= sfmtMINUS; } if (flags & sfmtSPACE) { if (src_len == 0) fputc(' ', fp); } if (flags & sfmtPREC) { if (src_len > prec) src_len = prec; } if (!(flags & sfmtWIDTH)) { width = src_len; } if (!(flags & sfmtMINUS)) { while (src_len < width) { fputc(' ', fp); --width; } } fwrite(src_str, sizeof(char), (size_t) src_len, fp); while (src_len < width) { fputc(' ', fp); --width; } } static PTR buffer_puts_sfmt(char *target, const char *src_str, int src_len, int width, int prec, int flags) { if (width < 0) { width = -width; flags |= sfmtMINUS; } if (flags & sfmtSPACE) { if (src_len == 0) { target = SprintfChar(target, ' '); } } if (flags & sfmtPREC) { if (src_len > prec) src_len = prec; } if (!(flags & sfmtWIDTH)) { width = src_len; } if (!(flags & sfmtMINUS)) { if (src_len < width) { target = SprintfFill(target, ' ', width - src_len); width = src_len; } } target = SprintfBlock(target, src_str, src_len); if (src_len < width) { target = SprintfFill(target, ' ', width - src_len); } return target; } /* * Note: caller must do CELL cleanup. * The format parameter is modified, but restored. */ static STRING * do_printf(FILE *fp, char *format, unsigned argcnt, /* number of args on eval stack */ CELL *cp) /* ptr to an array of arguments (on the eval stack) */ { char save; /* saves when temporary null ends format */ int splice; /* set to pad format with l's for Long */ char *p; register char *q = format; int l_flag, h_flag; /* seen %ld or %hd */ int ast_cnt; int ast[2]; ULong Uval = 0; Long Ival = 0; int sfmt_width, sfmt_prec, sfmt_flags; int num_conversion = 0; /* for error messages */ const char *who = "printf"; /*ditto */ int pf_type = 0; /* conversion type */ STRING onechr; char xbuff[256]; /* splice in l qualifier here */ while (1) { while (*q != '%') { if (*q == 0) { if (ferror(fp)) write_error(); /* return is ignored */ return (STRING *) 0; } else { putc(*q, fp); q++; } } /* *q == '%' */ num_conversion++; if (*++q == '%') { /* %% */ putc(*q, fp); q++; continue; } /* mark the '%' with p */ p = q - 1; /* eat the flags */ while (*q == '-' || *q == '+' || *q == ' ' || *q == '#' || *q == '0' || *q == '\'') q++; ast_cnt = 0; ast[0] = 0; if (*q == '*') { if (cp->type != C_DOUBLE) cast1_to_d(cp); ast[ast_cnt++] = d_to_i(cp++->dval); argcnt--; q++; } else while (scan_code[*(unsigned char *) q] == SC_DIGIT) q++; /* width is done */ if (*q == '.') { /* have precision */ q++; if (*q == '*') { if (cp->type != C_DOUBLE) cast1_to_d(cp); ast[ast_cnt++] = d_to_i(cp++->dval); argcnt--; q++; } else { while (scan_code[*(unsigned char *) q] == SC_DIGIT) q++; } } if ((int) argcnt <= 0) rt_error("not enough arguments passed to %s(\"%s\")", who, format); l_flag = h_flag = 0; for (;;) { if (*q == 'l') { ++q; ++l_flag; } else if (*q == 'h') { ++q; ++h_flag; } else { break; } } splice = 0; switch (*q++) { case 's': if (l_flag + h_flag) bad_conversion(num_conversion, who, format); if (cp->type < C_STRING) cast1_to_s(cp); pf_type = PF_S; break; case 'c': if (l_flag + h_flag) bad_conversion(num_conversion, who, format); switch (cp->type) { case C_NOINIT: Ival = 0; break; case C_STRNUM: case C_DOUBLE: Ival = d_to_L(cp->dval); break; case C_STRING: Ival = string(cp)->str[0]; break; case C_MBSTRN: check_strnum(cp); Ival = ((cp->type == C_STRING) ? string(cp)->str[0] : d_to_I(cp->dval)); break; default: bozo("printf %c"); } onechr.len = 1; onechr.str[0] = (char) Ival; pf_type = PF_C; break; case 'd': if (cp->type != C_DOUBLE) cast1_to_d(cp); if (cp->dval >= (double) Max_Long) { Uval = d_to_UL(cp->dval); pf_type = PF_U; } else { Ival = d_to_L(cp->dval); pf_type = PF_D; } SpliceFormat(!l_flag || h_flag); break; case 'i': if (cp->type != C_DOUBLE) cast1_to_d(cp); Ival = d_to_L(cp->dval); pf_type = PF_D; SpliceFormat(!l_flag || h_flag); break; case 'o': case 'x': case 'X': case 'u': if (cp->type != C_DOUBLE) cast1_to_d(cp); Uval = d_to_UL(cp->dval); pf_type = PF_U; SpliceFormat(!l_flag); break; case 'e': case 'g': case 'f': case 'E': case 'G': if (h_flag + l_flag) bad_conversion(num_conversion, who, format); if (cp->type != C_DOUBLE) cast1_to_d(cp); pf_type = PF_F; break; default: bad_conversion(num_conversion, who, format); } #ifdef SHORT_INTS if (pf_type == PF_D) p = xbuff; #endif save = *q; *q = 0; if (splice) { /* need to splice in long modifier */ CopySplice(xbuff, p); if (l_flag < ELL_LIMIT) { int k = (int) (q - p); switch (h_flag) { case 2: Ival = (char) Ival; if (pf_type == PF_D) Ival &= 0xff; break; case 1: Ival = (short) Ival; if (pf_type == PF_D) Ival &= 0xffff; break; default: do { xbuff[k] = xbuff[k - 1]; xbuff[k - 1] = 'l'; xbuff[++k] = 0; } while (++l_flag < ELL_LIMIT); if ((pf_type == PF_U) && (xbuff[k - 1] == 'd')) xbuff[k - 1] = 'u'; break; } } p = xbuff; } #define PUTS_C_ARGS fp, onechr.str, 1, sfmt_width, sfmt_prec, sfmt_flags #define PUTS_S_ARGS fp, string(cp)->str, (int) string(cp)->len, sfmt_width, sfmt_prec, sfmt_flags /* ready to call printf() */ switch (AST(ast_cnt, pf_type)) { case AST(0, PF_C): /* FALLTHRU */ case AST(1, PF_C): /* FALLTHRU */ case AST(2, PF_C): make_sfmt(p, ast, &sfmt_width, &sfmt_prec, &sfmt_flags); stream_puts_sfmt(PUTS_C_ARGS); break; case AST(0, PF_S): /* FALLTHRU */ case AST(1, PF_S): /* FALLTHRU */ case AST(2, PF_S): make_sfmt(p, ast, &sfmt_width, &sfmt_prec, &sfmt_flags); stream_puts_sfmt(PUTS_S_ARGS); break; #undef PUTS_C_ARGS #undef PUTS_S_ARGS case AST(0, PF_D): fprintf(fp, MY_FMT, Ival); break; case AST(1, PF_D): fprintf(fp, MY_FMT, ast[0], Ival); break; case AST(2, PF_D): fprintf(fp, MY_FMT, ast[0], ast[1], Ival); break; case AST(0, PF_U): fprintf(fp, MY_FMT, Uval); break; case AST(1, PF_U): fprintf(fp, MY_FMT, ast[0], Uval); break; case AST(2, PF_U): fprintf(fp, MY_FMT, ast[0], ast[1], Uval); break; case AST(0, PF_F): fprintf(fp, p, cp->dval); break; case AST(1, PF_F): fprintf(fp, p, ast[0], cp->dval); break; case AST(2, PF_F): fprintf(fp, p, ast[0], ast[1], cp->dval); break; } *q = save; argcnt--; cp++; } } CELL * bi_printf(CELL *sp) { register int k; register CELL *p; FILE *fp; TRACE_FUNC("bi_printf", sp); k = sp->type; if (k < 0) { /* k has redirection */ if ((--sp)->type < C_STRING) cast1_to_s(sp); fp = (FILE *) file_find(string(sp), k); free_STRING(string(sp)); k = (--sp)->type; /* k is now number of args including format */ } else fp = stdout; sp -= k; /* sp points at the format string */ k--; if (sp->type < C_STRING) cast1_to_s(sp); do_printf(fp, string(sp)->str, (unsigned) k, sp + 1); free_STRING(string(sp)); /* cleanup arguments on eval stack */ for (p = sp + 1; k; k--, p++) cell_destroy(p); return --sp; } /* * Note: caller must do CELL cleanup. * The format parameter is modified, but restored. */ static STRING * do_sprintf( char *format, unsigned argcnt, /* number of args on eval stack */ CELL *cp) /* ptr to an array of arguments (on the eval stack) */ { char save; /* saves when temporary null ends format */ int splice; char *p; register char *q = format; register char *target = sprintf_buff; int l_flag, h_flag; /* seen %ld or %hd */ int ast_cnt; int ast[2]; ULong Uval = 0; Long Ival = 0; int sfmt_width, sfmt_prec, sfmt_flags, s_format; int num_conversion = 0; /* for error messages */ const char *who = "sprintf"; /*ditto */ int pf_type = 0; /* conversion type */ STRING onechr; char xbuff[256]; /* splice in l qualifier here */ while (1) { while (*q != '%') { if (*q == 0) { if (target > sprintf_limit) /* damaged */ { /* hope this works */ rt_overflow("sprintf buffer", (unsigned) (sprintf_limit - sprintf_buff)); } else { /* really done */ return new_STRING1(sprintf_buff, (size_t) (target - sprintf_buff)); } } else { *target++ = *q++; } } /* *q == '%' */ num_conversion++; if (*++q == '%') { /* %% */ *target++ = *q; q++; continue; } /* mark the '%' with p */ p = q - 1; /* eat the flags */ while (*q == '-' || *q == '+' || *q == ' ' || *q == '#' || *q == '0' || *q == '\'') q++; ast_cnt = 0; ast[0] = 0; if (*q == '*') { if (cp->type != C_DOUBLE) cast1_to_d(cp); ast[ast_cnt++] = d_to_i(cp++->dval); argcnt--; q++; } else while (scan_code[*(unsigned char *) q] == SC_DIGIT) q++; /* width is done */ if (*q == '.') { /* have precision */ q++; if (*q == '*') { if (cp->type != C_DOUBLE) cast1_to_d(cp); ast[ast_cnt++] = d_to_i(cp++->dval); argcnt--; q++; } else { while (scan_code[*(unsigned char *) q] == SC_DIGIT) q++; } } if ((int) argcnt <= 0) rt_error("not enough arguments passed to %s(\"%s\")", who, format); l_flag = h_flag = 0; for (;;) { if (*q == 'l') { ++q; ++l_flag; } else if (*q == 'h') { ++q; ++h_flag; } else { break; } } splice = 0; switch (*q++) { case 's': if (l_flag + h_flag) bad_conversion(num_conversion, who, format); if (cp->type < C_STRING) cast1_to_s(cp); pf_type = PF_S; break; case 'c': if (l_flag + h_flag) bad_conversion(num_conversion, who, format); switch (cp->type) { case C_NOINIT: Ival = 0; break; case C_STRNUM: case C_DOUBLE: Ival = d_to_L(cp->dval); break; case C_STRING: #ifndef NO_INTERVAL_EXPR /* fall thru to check for bad number formats */ /* fall thru */ #else Ival = string(cp)->str[0]; break; #endif case C_MBSTRN: check_strnum(cp); Ival = ((cp->type == C_STRING) ? string(cp)->str[0] : d_to_I(cp->dval)); break; default: bozo("printf %c"); } onechr.len = 1; onechr.str[0] = (char) Ival; pf_type = PF_C; break; case 'd': if (cp->type != C_DOUBLE) cast1_to_d(cp); if (cp->dval >= (double) Max_Long) { Uval = d_to_UL(cp->dval); pf_type = PF_U; } else { Ival = d_to_L(cp->dval); pf_type = PF_D; } SpliceFormat(!l_flag || h_flag); break; case 'i': if (cp->type != C_DOUBLE) cast1_to_d(cp); Ival = d_to_L(cp->dval); pf_type = PF_D; SpliceFormat(!l_flag || h_flag); break; case 'o': case 'x': case 'X': case 'u': if (cp->type != C_DOUBLE) cast1_to_d(cp); Uval = d_to_UL(cp->dval); pf_type = PF_U; SpliceFormat(!l_flag); break; case 'e': case 'g': case 'f': case 'E': case 'G': if (h_flag + l_flag) bad_conversion(num_conversion, who, format); if (cp->type != C_DOUBLE) cast1_to_d(cp); pf_type = PF_F; break; default: bad_conversion(num_conversion, who, format); } #ifdef SHORT_INTS if (pf_type == PF_D) p = xbuff; #endif save = *q; *q = 0; if (splice) { /* need to splice in long modifier */ CopySplice(xbuff, p); if (l_flag < ELL_LIMIT) { int k = (int) (q - p); switch (h_flag) { case 2: Ival = (char) Ival; if (pf_type == PF_D) Ival &= 0xff; break; case 1: Ival = (short) Ival; if (pf_type == PF_D) Ival &= 0xffff; break; default: do { xbuff[k] = xbuff[k - 1]; xbuff[k - 1] = 'l'; xbuff[++k] = 0; } while (++l_flag < ELL_LIMIT); if ((pf_type == PF_U) && (xbuff[k - 1] == 'd')) xbuff[k - 1] = 'u'; break; } } p = xbuff; } #define PUTS_C_ARGS target, onechr.str, 1, sfmt_width, sfmt_prec, sfmt_flags #define PUTS_S_ARGS target, string(cp)->str, (int) string(cp)->len, sfmt_width, sfmt_prec, sfmt_flags /* ready to call printf() */ s_format = 0; switch (AST(ast_cnt, pf_type)) { case AST(0, PF_C): /* FALLTHRU */ case AST(1, PF_C): /* FALLTHRU */ case AST(2, PF_C): s_format = 1; make_sfmt(p, ast, &sfmt_width, &sfmt_prec, &sfmt_flags); target = buffer_puts_sfmt(PUTS_C_ARGS); break; case AST(0, PF_S): /* FALLTHRU */ case AST(1, PF_S): /* FALLTHRU */ case AST(2, PF_S): s_format = 1; make_sfmt(p, ast, &sfmt_width, &sfmt_prec, &sfmt_flags); target = buffer_puts_sfmt(PUTS_S_ARGS); break; #undef PUTS_C_ARGS #undef PUTS_S_ARGS case AST(0, PF_D): sprintf(target, MY_FMT, Ival); break; case AST(1, PF_D): sprintf(target, MY_FMT, ast[0], Ival); break; case AST(2, PF_D): sprintf(target, MY_FMT, ast[0], ast[1], Ival); break; case AST(0, PF_U): sprintf(target, MY_FMT, Uval); break; case AST(1, PF_U): sprintf(target, MY_FMT, ast[0], Uval); break; case AST(2, PF_U): sprintf(target, MY_FMT, ast[0], ast[1], Uval); break; case AST(0, PF_F): sprintf(target, p, cp->dval); break; case AST(1, PF_F): sprintf(target, p, ast[0], cp->dval); break; case AST(2, PF_F): sprintf(target, p, ast[0], ast[1], cp->dval); break; } if (!s_format) { while (*target) target++; } *q = save; argcnt--; cp++; } } CELL * bi_sprintf(CELL *sp) { CELL *p; int argcnt = sp->type; STRING *sval; TRACE_FUNC("bi_sprintf", sp); sp -= argcnt; /* sp points at the format string */ argcnt--; if (sp->type != C_STRING) cast1_to_s(sp); sval = do_sprintf(string(sp)->str, (unsigned) argcnt, sp + 1); free_STRING(string(sp)); sp->ptr = (PTR) sval; /* cleanup */ for (p = sp + 1; argcnt; argcnt--, p++) cell_destroy(p); return sp; } static void write_error(void) { errmsg(errno, "write failure"); mawk_exit(2); } mawk-1.3.4-20240123/rexp.h0000644000000000000000000001511414460604756013214 0ustar rootroot/******************************************** rexp.h copyright 2008-2021,2023, Thomas E. Dickey copyright 2010, Jonathan Nieder copyright 1991,2014, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: rexp.h,v 1.41 2023/07/28 00:21:02 tom Exp $ */ #ifndef REXP_H #define REXP_H #include "nstd.h" #include "types.h" #include #include extern PTR RE_malloc(size_t); extern PTR RE_realloc(void *, size_t); #ifdef NO_LEAKS extern void RE_free(void *); #else #define RE_free(p) free(p) #endif /* finite machine state types */ typedef enum { M_STR /* matching a literal string */ ,M_CLASS /* character class */ ,M_ANY /* arbitrary character (.) */ ,M_START /* start of string (^) */ ,M_END /* end of string ($) */ ,M_U /* arbitrary string (.*) */ ,M_1J /* mandatory jump */ ,M_2JA /* optional (undesirable) jump */ ,M_2JB /* optional (desirable) jump */ ,M_SAVE_POS /* push position onto stack */ ,M_2JC /* pop pos'n, optional jump if advanced */ ,M_ACCEPT /* end of match */ ,U_ON /* ...distinct from the preceding */ } MAWK_REGEX; #define U_OFF 0 #define END_OFF 0 #define END_ON (2*U_ON) /* ...distinct from the preceding */ #define L_CURL '{' #define R_CURL '}' typedef UChar BV[32]; /* bit vector */ typedef struct { SType s_type; size_t s_len; /* used for M_STR */ union { char *str; /* string */ BV *bvp; /* class */ int jump; } s_data; #ifndef NO_INTERVAL_EXPR Int it_min; /* used for s_type == M_2JC */ Int it_max; /* used for s_type == M_2JC */ Int it_cnt; #endif } STATE; #define STATESZ (sizeof(STATE)) typedef struct { STATE *start, *stop; } MACHINE; /* tokens */ typedef enum { T_NONE = 0 /* no token */ ,T_OR /* | */ ,T_CAT /* binary operator */ ,T_STAR /* * */ ,T_PLUS /* + */ ,T_Q /* ? */ ,T_LP /* ( */ ,T_RP /* ) */ #ifdef NO_INTERVAL_EXPR #define T_LB T_CHAR /* { */ #define T_RB T_CHAR /* } */ #else ,T_LB /* { */ ,T_RB /* } */ #endif ,T_START /* ^ */ ,T_END /* $ */ ,T_ANY /* . */ ,T_CLASS /* starts with [ */ ,T_SLASH /* \ */ ,T_CHAR /* all the rest */ ,T_STR /* string built of other tokens */ ,T_U } MAWK_TOKEN; /* precedences and error codes */ #define OP_L 0 #define OP_EQ 1 #define OP_G 2 #define ERR_1 (-1) #define ERR_2 (-2) #define ERR_3 (-3) #define ERR_4 (-4) #define ERR_5 (-5) #define ERR_6 (-6) #define ERR_7 (-7) #define MEMORY_FAILURE 5 #define ison(b,x) ((b)[((UChar)(x)) >> 3] & (1 << ((x) & 7))) /* struct for the run time stack */ typedef struct { STATE *m; /* save the machine ptr */ int u; /* save the u_flag */ char *s; /* save the active string ptr */ int sp; /* size of position stack */ int tp; /* offset to top entry of position stack */ char *ss; /* save the match start -- only used by REmatch */ } RT_STATE; /* run time state */ /* entry for the position stack */ typedef struct { /* if we have not advanced beyond this character, * do not bother trying another round. */ const char *pos; /* run time stack frame responsible for removing this node */ int owner; /* previous node is this - this->prev_offset. See RE_pos_pop() */ int prev_offset; } RT_POS_ENTRY; /* error trap */ extern int REerrno; void RE_error_trap(int); #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif extern MACHINE RE_u(void); extern MACHINE RE_start(void); extern MACHINE RE_end(void); extern MACHINE RE_any(void); extern MACHINE RE_str(char *, size_t); extern MACHINE RE_class(BV *); extern void RE_cat(MACHINE *, MACHINE *); extern void RE_or(MACHINE *, MACHINE *); extern STATE *RE_close(MACHINE *); extern STATE *RE_poscl(MACHINE *); extern void RE_01(MACHINE *); extern GCC_NORETURN void RE_panic(const char *, ...) GCC_PRINTFLIKE(1,2); #ifndef NO_INTERVAL_EXPR extern void RE_close_limit(MACHINE *, Int, Int); extern void RE_poscl_limit(MACHINE *, Int, Int); extern void duplicate_m(MACHINE *, MACHINE *); #endif #ifndef MAWK_H extern char *str_str(char *, size_t, char *, size_t); #endif extern void RE_lex_init(char *, size_t); extern int RE_lex(MACHINE *); extern void RE_run_stack_init(void); extern void RE_pos_stack_init(void); extern RT_STATE *RE_new_run_stack(void); extern RT_POS_ENTRY *RE_new_pos_stack(void); extern RT_STATE *RE_run_stack_base; extern RT_STATE *RE_run_stack_limit; extern RT_STATE *RE_run_stack_empty; extern RT_POS_ENTRY *RE_pos_stack_base; extern RT_POS_ENTRY *RE_pos_stack_limit; extern RT_POS_ENTRY *RE_pos_stack_empty; extern Int intrvalmin; extern Int intrvalmax; extern char *re_exp; #if defined(LOCAL_REGEXP) && defined(REGEXP_INTERNALS) static /* inline */ RT_POS_ENTRY * RE_pos_push(RT_POS_ENTRY * head, const RT_STATE * owner, const char *s) { head->pos = s; head->owner = (int) (owner - RE_run_stack_base); if (++head == RE_pos_stack_limit) { head = RE_new_pos_stack(); } head->prev_offset = 1; return head; } static /* inline */ const char * RE_pos_pop(RT_POS_ENTRY ** head, const RT_STATE * current) { RT_POS_ENTRY *prev = *head - (*head)->prev_offset; if (prev->owner == current - RE_run_stack_base) { /* likely */ /* no need to preserve intervening nodes */ *head = prev; } else if (*head == prev) { RE_panic("unbalanced M_SAVE_POS and M_2JC"); } else { (*head)->prev_offset += prev->prev_offset; } return prev->pos; } #ifndef NO_INTERVAL_EXPR /* reset it_cnt to zero for the M_2JC state * which is where loop count is checked */ static void RE_init_it_cnt(STATE * s) { STATE *p = s; while (p->s_type < M_ACCEPT) { if (p->s_type == M_2JC) p->it_cnt = 0; p++; } } #else #define RE_init_it_cnt(s) /* nothing */ #endif #ifndef NO_INTERVAL_EXPR #undef NO_RI_LOOP_UNROLL /* experimental 2020/10/22 -TD */ #ifdef NO_RI_LOOP_UNROLL #else static void RE_set_limit(STATE * s, Int minlimit, Int maxlimit) { STATE *p = s; while (p->s_type < M_ACCEPT) { if (p->s_type == M_2JC) { p->it_min = minlimit; p->it_max = maxlimit; } p++; } } #endif /* ! NO_RI_LOOP_UNROLL */ #endif /* ! NO_INTERVAL_EXPR */ #ifdef NO_LEAKS extern void RE_copy_states(STATE *, const STATE *, size_t); #else #define RE_copy_states(d, s, n) memcpy((d), (s), (n) * STATESZ) #endif #endif /* LOCAL_REGEXP */ #endif /* REXP_H */ mawk-1.3.4-20240123/config.sub0000755000000000000000000010722314501160441014033 0ustar rootroot#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2023 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale timestamp='2023-09-15' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. # The "shellcheck disable" line above the timestamp inhibits complaints # about features and limitations of the classic Bourne shell that were # superseded or lifted in POSIX. However, this script identifies a wide # variety of pre-POSIX systems that do not have POSIX shells at all, and # even some reasonably current systems (Solaris 10 as case-in-point) still # have a pre-POSIX /bin/sh. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Split fields of configuration type # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read field1 field2 field3 field4 <&2 exit 1 ;; *-*-*-*) basic_machine=$field1-$field2 basic_os=$field3-$field4 ;; *-*-*) # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two # parts maybe_os=$field2-$field3 case $maybe_os in nto-qnx* | linux-* | uclinux-uclibc* \ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \ | windows-* ) basic_machine=$field1 basic_os=$maybe_os ;; android-linux) basic_machine=$field1-unknown basic_os=linux-android ;; *) basic_machine=$field1-$field2 basic_os=$field3 ;; esac ;; *-*) # A lone config we happen to match not fitting any pattern case $field1-$field2 in decstation-3100) basic_machine=mips-dec basic_os= ;; *-*) # Second component is usually, but not always the OS case $field2 in # Prevent following clause from handling this valid os sun*os*) basic_machine=$field1 basic_os=$field2 ;; zephyr*) basic_machine=$field1-unknown basic_os=$field2 ;; # Manufacturers dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ | unicom* | ibm* | next | hp | isi* | apollo | altos* \ | convergent* | ncr* | news | 32* | 3600* | 3100* \ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ | ultra | tti* | harris | dolphin | highlevel | gould \ | cbm | ns | masscomp | apple | axis | knuth | cray \ | microblaze* | sim | cisco \ | oki | wec | wrs | winbond) basic_machine=$field1-$field2 basic_os= ;; *) basic_machine=$field1 basic_os=$field2 ;; esac ;; esac ;; *) # Convert single-component short-hands not valid as part of # multi-component configurations. case $field1 in 386bsd) basic_machine=i386-pc basic_os=bsd ;; a29khif) basic_machine=a29k-amd basic_os=udi ;; adobe68k) basic_machine=m68010-adobe basic_os=scout ;; alliant) basic_machine=fx80-alliant basic_os= ;; altos | altos3068) basic_machine=m68k-altos basic_os= ;; am29k) basic_machine=a29k-none basic_os=bsd ;; amdahl) basic_machine=580-amdahl basic_os=sysv ;; amiga) basic_machine=m68k-unknown basic_os= ;; amigaos | amigados) basic_machine=m68k-unknown basic_os=amigaos ;; amigaunix | amix) basic_machine=m68k-unknown basic_os=sysv4 ;; apollo68) basic_machine=m68k-apollo basic_os=sysv ;; apollo68bsd) basic_machine=m68k-apollo basic_os=bsd ;; aros) basic_machine=i386-pc basic_os=aros ;; aux) basic_machine=m68k-apple basic_os=aux ;; balance) basic_machine=ns32k-sequent basic_os=dynix ;; blackfin) basic_machine=bfin-unknown basic_os=linux ;; cegcc) basic_machine=arm-unknown basic_os=cegcc ;; convex-c1) basic_machine=c1-convex basic_os=bsd ;; convex-c2) basic_machine=c2-convex basic_os=bsd ;; convex-c32) basic_machine=c32-convex basic_os=bsd ;; convex-c34) basic_machine=c34-convex basic_os=bsd ;; convex-c38) basic_machine=c38-convex basic_os=bsd ;; cray) basic_machine=j90-cray basic_os=unicos ;; crds | unos) basic_machine=m68k-crds basic_os= ;; da30) basic_machine=m68k-da30 basic_os= ;; decstation | pmax | pmin | dec3100 | decstatn) basic_machine=mips-dec basic_os= ;; delta88) basic_machine=m88k-motorola basic_os=sysv3 ;; dicos) basic_machine=i686-pc basic_os=dicos ;; djgpp) basic_machine=i586-pc basic_os=msdosdjgpp ;; ebmon29k) basic_machine=a29k-amd basic_os=ebmon ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson basic_os=ose ;; gmicro) basic_machine=tron-gmicro basic_os=sysv ;; go32) basic_machine=i386-pc basic_os=go32 ;; h8300hms) basic_machine=h8300-hitachi basic_os=hms ;; h8300xray) basic_machine=h8300-hitachi basic_os=xray ;; h8500hms) basic_machine=h8500-hitachi basic_os=hms ;; harris) basic_machine=m88k-harris basic_os=sysv3 ;; hp300 | hp300hpux) basic_machine=m68k-hp basic_os=hpux ;; hp300bsd) basic_machine=m68k-hp basic_os=bsd ;; hppaosf) basic_machine=hppa1.1-hp basic_os=osf ;; hppro) basic_machine=hppa1.1-hp basic_os=proelf ;; i386mach) basic_machine=i386-mach basic_os=mach ;; isi68 | isi) basic_machine=m68k-isi basic_os=sysv ;; m68knommu) basic_machine=m68k-unknown basic_os=linux ;; magnum | m3230) basic_machine=mips-mips basic_os=sysv ;; merlin) basic_machine=ns32k-utek basic_os=sysv ;; mingw64) basic_machine=x86_64-pc basic_os=mingw64 ;; mingw32) basic_machine=i686-pc basic_os=mingw32 ;; mingw32ce) basic_machine=arm-unknown basic_os=mingw32ce ;; monitor) basic_machine=m68k-rom68k basic_os=coff ;; morphos) basic_machine=powerpc-unknown basic_os=morphos ;; moxiebox) basic_machine=moxie-unknown basic_os=moxiebox ;; msdos) basic_machine=i386-pc basic_os=msdos ;; msys) basic_machine=i686-pc basic_os=msys ;; mvs) basic_machine=i370-ibm basic_os=mvs ;; nacl) basic_machine=le32-unknown basic_os=nacl ;; ncr3000) basic_machine=i486-ncr basic_os=sysv4 ;; netbsd386) basic_machine=i386-pc basic_os=netbsd ;; netwinder) basic_machine=armv4l-rebel basic_os=linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony basic_os=newsos ;; news1000) basic_machine=m68030-sony basic_os=newsos ;; necv70) basic_machine=v70-nec basic_os=sysv ;; nh3000) basic_machine=m68k-harris basic_os=cxux ;; nh[45]000) basic_machine=m88k-harris basic_os=cxux ;; nindy960) basic_machine=i960-intel basic_os=nindy ;; mon960) basic_machine=i960-intel basic_os=mon960 ;; nonstopux) basic_machine=mips-compaq basic_os=nonstopux ;; os400) basic_machine=powerpc-ibm basic_os=os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson basic_os=ose ;; os68k) basic_machine=m68k-none basic_os=os68k ;; paragon) basic_machine=i860-intel basic_os=osf ;; parisc) basic_machine=hppa-unknown basic_os=linux ;; psp) basic_machine=mipsallegrexel-sony basic_os=psp ;; pw32) basic_machine=i586-unknown basic_os=pw32 ;; rdos | rdos64) basic_machine=x86_64-pc basic_os=rdos ;; rdos32) basic_machine=i386-pc basic_os=rdos ;; rom68k) basic_machine=m68k-rom68k basic_os=coff ;; sa29200) basic_machine=a29k-amd basic_os=udi ;; sei) basic_machine=mips-sei basic_os=seiux ;; sequent) basic_machine=i386-sequent basic_os= ;; sps7) basic_machine=m68k-bull basic_os=sysv2 ;; st2000) basic_machine=m68k-tandem basic_os= ;; stratus) basic_machine=i860-stratus basic_os=sysv4 ;; sun2) basic_machine=m68000-sun basic_os= ;; sun2os3) basic_machine=m68000-sun basic_os=sunos3 ;; sun2os4) basic_machine=m68000-sun basic_os=sunos4 ;; sun3) basic_machine=m68k-sun basic_os= ;; sun3os3) basic_machine=m68k-sun basic_os=sunos3 ;; sun3os4) basic_machine=m68k-sun basic_os=sunos4 ;; sun4) basic_machine=sparc-sun basic_os= ;; sun4os3) basic_machine=sparc-sun basic_os=sunos3 ;; sun4os4) basic_machine=sparc-sun basic_os=sunos4 ;; sun4sol2) basic_machine=sparc-sun basic_os=solaris2 ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun basic_os= ;; sv1) basic_machine=sv1-cray basic_os=unicos ;; symmetry) basic_machine=i386-sequent basic_os=dynix ;; t3e) basic_machine=alphaev5-cray basic_os=unicos ;; t90) basic_machine=t90-cray basic_os=unicos ;; toad1) basic_machine=pdp10-xkl basic_os=tops20 ;; tpf) basic_machine=s390x-ibm basic_os=tpf ;; udi29k) basic_machine=a29k-amd basic_os=udi ;; ultra3) basic_machine=a29k-nyu basic_os=sym1 ;; v810 | necv810) basic_machine=v810-nec basic_os=none ;; vaxv) basic_machine=vax-dec basic_os=sysv ;; vms) basic_machine=vax-dec basic_os=vms ;; vsta) basic_machine=i386-pc basic_os=vsta ;; vxworks960) basic_machine=i960-wrs basic_os=vxworks ;; vxworks68) basic_machine=m68k-wrs basic_os=vxworks ;; vxworks29k) basic_machine=a29k-wrs basic_os=vxworks ;; xbox) basic_machine=i686-pc basic_os=mingw32 ;; ymp) basic_machine=ymp-cray basic_os=unicos ;; *) basic_machine=$1 basic_os= ;; esac ;; esac # Decode 1-component or ad-hoc basic machines case $basic_machine in # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) cpu=hppa1.1 vendor=winbond ;; op50n) cpu=hppa1.1 vendor=oki ;; op60c) cpu=hppa1.1 vendor=oki ;; ibm*) cpu=i370 vendor=ibm ;; orion105) cpu=clipper vendor=highlevel ;; mac | mpw | mac-mpw) cpu=m68k vendor=apple ;; pmac | pmac-mpw) cpu=powerpc vendor=apple ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) cpu=m68000 vendor=att ;; 3b*) cpu=we32k vendor=att ;; bluegene*) cpu=powerpc vendor=ibm basic_os=cnk ;; decsystem10* | dec10*) cpu=pdp10 vendor=dec basic_os=tops10 ;; decsystem20* | dec20*) cpu=pdp10 vendor=dec basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) cpu=m68k vendor=motorola ;; dpx2*) cpu=m68k vendor=bull basic_os=sysv3 ;; encore | umax | mmax) cpu=ns32k vendor=encore ;; elxsi) cpu=elxsi vendor=elxsi basic_os=${basic_os:-bsd} ;; fx2800) cpu=i860 vendor=alliant ;; genix) cpu=ns32k vendor=ns ;; h3050r* | hiux*) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) cpu=m68000 vendor=hp ;; hp9k3[2-9][0-9]) cpu=m68k vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) cpu=hppa1.1 vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp cpu=hppa1.1 vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp cpu=hppa1.1 vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) cpu=hppa1.1 vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) cpu=hppa1.0 vendor=hp ;; i*86v32) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv32 ;; i*86v4*) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv4 ;; i*86v) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=sysv ;; i*86sol2) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc basic_os=solaris2 ;; j90 | j90-cray) cpu=j90 vendor=cray basic_os=${basic_os:-unicos} ;; iris | iris4d) cpu=mips vendor=sgi case $basic_os in irix*) ;; *) basic_os=irix4 ;; esac ;; miniframe) cpu=m68000 vendor=convergent ;; *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) cpu=m68k vendor=atari basic_os=mint ;; news-3600 | risc-news) cpu=mips vendor=sony basic_os=newsos ;; next | m*-next) cpu=m68k vendor=next case $basic_os in openstep*) ;; nextstep*) ;; ns2*) basic_os=nextstep2 ;; *) basic_os=nextstep3 ;; esac ;; np1) cpu=np1 vendor=gould ;; op50n-* | op60c-*) cpu=hppa1.1 vendor=oki basic_os=proelf ;; pa-hitachi) cpu=hppa1.1 vendor=hitachi basic_os=hiuxwe2 ;; pbd) cpu=sparc vendor=tti ;; pbb) cpu=m68k vendor=tti ;; pc532) cpu=ns32k vendor=pc532 ;; pn) cpu=pn vendor=gould ;; power) cpu=power vendor=ibm ;; ps2) cpu=i386 vendor=ibm ;; rm[46]00) cpu=mips vendor=siemens ;; rtpc | rtpc-*) cpu=romp vendor=ibm ;; sde) cpu=mipsisa32 vendor=sde basic_os=${basic_os:-elf} ;; simso-wrs) cpu=sparclite vendor=wrs basic_os=vxworks ;; tower | tower-32) cpu=m68k vendor=ncr ;; vpp*|vx|vx-*) cpu=f301 vendor=fujitsu ;; w65) cpu=w65 vendor=wdc ;; w89k-*) cpu=hppa1.1 vendor=winbond basic_os=proelf ;; none) cpu=none vendor=none ;; leon|leon[3-9]) cpu=sparc vendor=$basic_machine ;; leon-*|leon[3-9]-*) cpu=sparc vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; *-*) # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read cpu vendor <&2 exit 1 ;; esac ;; esac # Here we canonicalize certain aliases for manufacturers. case $vendor in digital*) vendor=dec ;; commodore*) vendor=cbm ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if test x"$basic_os" != x then # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just # set os. obj= case $basic_os in gnu/linux*) kernel=linux os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` ;; os2-emx) kernel=os2 os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` ;; nto-qnx*) kernel=nto os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` ;; *-*) # shellcheck disable=SC2162 saved_IFS=$IFS IFS="-" read kernel os <&2 fi ;; *) echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 exit 1 ;; esac case $obj in aout* | coff* | elf* | pe*) ;; '') # empty is fine ;; *) echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 exit 1 ;; esac # Here we handle the constraint that a (synthetic) cpu and os are # valid only in combination with each other and nowhere else. case $cpu-$os in # The "javascript-unknown-ghcjs" triple is used by GHC; we # accept it here in order to tolerate that, but reject any # variations. javascript-ghcjs) ;; javascript-* | *-ghcjs) echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 exit 1 ;; esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. case $kernel-$os-$obj in linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \ | linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- ) ;; uclinux-uclibc*- ) ;; managarm-mlibc*- | managarm-kernel*- ) ;; windows*-gnu*- | windows*-msvc*-) ;; -dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- ) # These are just libc implementations, not actual OSes, and thus # require a kernel. echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 exit 1 ;; -kernel*- ) echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 exit 1 ;; *-kernel*- ) echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 exit 1 ;; *-msvc*- ) echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 exit 1 ;; kfreebsd*-gnu*- | kopensolaris*-gnu*-) ;; vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) ;; nto-qnx*-) ;; os2-emx-) ;; *-eabi*- | *-gnueabi*-) ;; none--*) # None (no kernel, i.e. freestanding / bare metal), # can be paired with an machine code file format ;; -*-) # Blank kernel with real OS is always fine. ;; --*) # Blank kernel and OS with real machine code file format is always fine. ;; *-*-*) echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 exit 1 ;; esac # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. case $vendor in unknown) case $cpu-$os in *-riscix*) vendor=acorn ;; *-sunos*) vendor=sun ;; *-cnk* | *-aix*) vendor=ibm ;; *-beos*) vendor=be ;; *-hpux*) vendor=hp ;; *-mpeix*) vendor=hp ;; *-hiux*) vendor=hitachi ;; *-unos*) vendor=crds ;; *-dgux*) vendor=dg ;; *-luna*) vendor=omron ;; *-genix*) vendor=ns ;; *-clix*) vendor=intergraph ;; *-mvs* | *-opened*) vendor=ibm ;; *-os400*) vendor=ibm ;; s390-* | s390x-*) vendor=ibm ;; *-ptx*) vendor=sequent ;; *-tpf*) vendor=ibm ;; *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; *-aux*) vendor=apple ;; *-hms*) vendor=hitachi ;; *-mpw* | *-macos*) vendor=apple ;; *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; *-vos*) vendor=stratus ;; esac ;; esac echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" exit # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: mawk-1.3.4-20240123/install-sh0000755000000000000000000003577613761220263014077 0ustar rootroot#!/bin/sh # install - install a program, script, or datafile scriptversion=2020-11-14.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 # Create dirs (including intermediate dirs) using mode 755. # This is like GNU 'install' as of coreutils 8.32 (2020). mkdir_umask=22 backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -p pass -p to $cpprog. -s $stripprog installed files. -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG By default, rm is invoked with -f; when overridden with RMPROG, it's up to you to specify -f if you want it. If -S is not specified, no backups are attempted. Email bug reports to bug-automake@gnu.org. Automake home page: https://www.gnu.org/software/automake/ " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -p) cpprog="$cpprog -p";; -s) stripcmd=$stripprog;; -S) backupsuffix="$2" shift;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? # Don't chown directories that already exist. if test $dstdir_status = 0; then chowncmd="" fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false # The $RANDOM variable is not portable (e.g., dash). Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap ' ret=$? rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null exit $ret ' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p'. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && { test -z "$stripcmd" || { # Create $dsttmp read-write so that cp doesn't create it read-only, # which would cause strip to fail. if test -z "$doit"; then : >"$dsttmp" # No need to fork-exec 'touch'. else $doit touch "$dsttmp" fi } } && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # If $backupsuffix is set, and the file being installed # already exists, attempt a backup. Don't worry if it fails, # e.g., if mv doesn't support -f. if test -n "$backupsuffix" && test -f "$dst"; then $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null fi # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: mawk-1.3.4-20240123/bi_funct.c0000644000000000000000000006422114554027021014011 0ustar rootroot/******************************************** bi_funct.c copyright 2008-2023,2024, Thomas E. Dickey copyright 1991-1995,1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: bi_funct.c,v 1.127 2024/01/23 21:22:25 tom Exp $ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(mawk_srand) || defined(mawk_rand) #define USE_SYSTEM_SRAND #endif #if defined(HAVE_BSD_STDLIB_H) && defined(USE_SYSTEM_SRAND) #include /* prototype arc4random */ #endif #if defined(WINVER) && (WINVER >= 0x501) #include #endif #if OPT_TRACE > 0 #define return_CELL(func, cell) TRACE(("..." func " ->")); \ TRACE_CELL(cell); \ return cell #else #define return_CELL(func, cell) return cell #endif /* global for the disassembler */ /* *INDENT-OFF* */ const BI_REC bi_funct[] = { /* info to load builtins */ { "index", bi_index, 2, 2 }, { "substr", bi_substr, 2, 3 }, { "sprintf", bi_sprintf, 1, 255 }, { "sin", bi_sin, 1, 1 }, { "cos", bi_cos, 1, 1 }, { "atan2", bi_atan2, 2, 2 }, { "exp", bi_exp, 1, 1 }, { "log", bi_log, 1, 1 }, { "int", bi_int, 1, 1 }, { "sqrt", bi_sqrt, 1, 1 }, { "rand", bi_rand, 0, 0 }, { "srand", bi_srand, 0, 1 }, { "close", bi_close, 1, 1 }, { "system", bi_system, 1, 1 }, { "toupper", bi_toupper, 1, 1 }, { "tolower", bi_tolower, 1, 1 }, { "fflush", bi_fflush, 0, 1 }, /* useful gawk extension (time functions) */ { "systime", bi_systime, 0, 0 }, #ifdef HAVE_MKTIME { "mktime", bi_mktime, 1, 1 }, #endif #ifdef HAVE_STRFTIME { "strftime", bi_strftime, 0, 3 }, #endif { (char *) 0, (PF_CP) 0, 0, 0 } }; /* *INDENT-ON* */ /* load built-in functions in symbol table */ void bi_funct_init(void) { register const BI_REC *p; register SYMTAB *stp; for (p = bi_funct; p->name; p++) { stp = insert(p->name); stp->type = ST_BUILTIN; stp->stval.bip = p; } #ifndef NO_INIT_SRAND /* seed rand() off the clock */ { CELL c[2]; memset(c, 0, sizeof(c)); c[1].type = C_NOINIT; bi_srand(c + 1); } #endif } /************************************************** string builtins (except split (in split.c) and [g]sub (at end)) **************************************************/ CELL * bi_length(CELL *sp) { size_t len; TRACE_FUNC("bi_length", sp); if (sp->type < C_STRING) cast1_to_s(sp); len = string(sp)->len; free_STRING(string(sp)); sp->type = C_DOUBLE; sp->dval = (double) len; return_CELL("bi_length", sp); } /* length (size) of an array */ CELL * bi_alength(CELL *sp) { TRACE_FUNC("bi_alength", sp); sp->type = C_DOUBLE; sp->dval = (double) ((ARRAY) sp->ptr)->size; return_CELL("bi_alength", sp); } char * str_str(char *target, size_t target_len, const char *key, size_t key_len) { register int k = key[0]; int k1; const char *prior; char *result = 0; switch (key_len) { case 0: break; case 1: if (target_len != 0) { result = memchr(target, k, target_len); } break; case 2: k1 = key[1]; prior = target; while (target_len >= key_len && (target = memchr(target, k, target_len))) { target_len = target_len - (size_t) (target - prior) - 1; prior = ++target; if (target_len > 0 && target[0] == k1) { result = target - 1; break; } } break; default: key_len--; prior = target; while (target_len > key_len && (target = memchr(target, k, target_len))) { target_len = target_len - (size_t) (target - prior) - 1; prior = ++target; if (target_len >= key_len && memcmp(target, key + 1, key_len) == 0) { result = target - 1; break; } } break; } return result; } CELL * bi_index(CELL *sp) { size_t idx; size_t len; TRACE_FUNC("bi_index", sp); sp--; if (TEST2(sp) != TWO_STRINGS) cast2_to_s(sp); if ((len = string(sp + 1)->len)) { const char *p; idx = (size_t) ((p = str_str(string(sp)->str, string(sp)->len, string(sp + 1)->str, len)) ? p - string(sp)->str + 1 : 0); } else { /* index of the empty string */ idx = 1; } free_STRING(string(sp)); free_STRING(string(sp + 1)); sp->type = C_DOUBLE; sp->dval = (double) idx; return_CELL("bi_index", sp); } /* substr(s, i, n) if l = length(s) then get the characters from max(1,i) to min(l,n-i-1) inclusive */ CELL * bi_substr(CELL *sp) { int n_args, len; register int i, n; STRING *sval; /* substr(sval->str, i, n) */ TRACE_FUNC("bi_substr", sp); n_args = sp->type; sp -= n_args; if (sp->type != C_STRING) cast1_to_s(sp); /* don't use < C_STRING shortcut */ sval = string(sp); if ((len = (int) sval->len) == 0) /* substr on null string */ { if (n_args == 3) { cell_destroy(sp + 2); } cell_destroy(sp + 1); return_CELL("bi_substr", sp); } if (n_args == 2) { n = len; if (sp[1].type != C_DOUBLE) { cast1_to_d(sp + 1); } } else { if (TEST2(sp + 1) != TWO_DOUBLES) cast2_to_d(sp + 1); n = d_to_i(sp[2].dval); } i = d_to_i(sp[1].dval) - 1; /* i now indexes into string */ /* * If the starting index is past the end of the string, there is nothing * to extract other than an empty string. */ if (i > len) { n = 0; } /* * Workaround in case someone's written a script that does substr(0,last-1) * by transforming it into substr(1,last). */ if (i < 0) { n -= i + 1; i = 0; } /* * Keep 'n' from extending past the end of the string. */ if (n > len - i) { n = len - i; } if (n <= 0) /* the null string */ { sp->ptr = (PTR) & null_str; null_str.ref_cnt++; } else { /* got something */ sp->ptr = (PTR) new_STRING0((size_t) n); memcpy(string(sp)->str, sval->str + i, (size_t) n); } free_STRING(sval); return_CELL("bi_substr", sp); } /* match(s,r) sp[0] holds r, sp[-1] holds s */ CELL * bi_match(CELL *sp) { char *p; size_t length; TRACE_FUNC("bi_match", sp); if (sp->type != C_RE) cast_to_RE(sp); if ((--sp)->type < C_STRING) cast1_to_s(sp); cell_destroy(RSTART); cell_destroy(RLENGTH); RSTART->type = C_DOUBLE; RLENGTH->type = C_DOUBLE; p = REmatch(string(sp)->str, string(sp)->len, cast_to_re((sp + 1)->ptr), &length, 0); if (p) { sp->dval = (double) (p - string(sp)->str + 1); RLENGTH->dval = (double) length; } else { sp->dval = 0.0; RLENGTH->dval = -1.0; /* posix */ } free_STRING(string(sp)); sp->type = C_DOUBLE; RSTART->dval = sp->dval; return_CELL("bi_match", sp); } #define BI_TOCASE(case) \ CELL * \ bi_to##case(CELL *sp) \ { \ STRING *old; \ size_t len; \ register char *p, *q; \ \ TRACE_FUNC("bi_to" #case, sp); \ \ if (sp->type != C_STRING) \ cast1_to_s(sp); \ old = string(sp); \ len = old->len; \ sp->ptr = (PTR) new_STRING0(len); \ \ q = string(sp)->str; \ p = old->str; \ while (len--) \ *q++ = (char) to##case((UChar) *p++); \ free_STRING(old); \ return_CELL("bi_to" #case, sp); \ } /* *INDENT-OFF* */ BI_TOCASE(upper) BI_TOCASE(lower) #undef BI_TOCASE /* *INDENT-ON* */ /* * Like gawk... */ CELL * bi_systime(CELL *sp) { time_t result; time(&result); TRACE_FUNC("bi_systime", sp); sp++; sp->type = C_DOUBLE; sp->dval = (double) result; return_CELL("bi_systime", sp); } #ifdef HAVE_MKTIME /* mktime(datespec) Turns datespec into a time stamp of the same form as returned by systime(). The datespec is a string of the form YYYY MM DD HH MM SS [DST]. */ CELL * bi_mktime(CELL *sp) { time_t result; struct tm my_tm; STRING *sval = string(sp); TRACE_FUNC("bi_mktime", sp); if (!sval) goto error; memset(&my_tm, 0, sizeof(my_tm)); switch (sscanf(sval->str, "%d %d %d %d %d %d %d", &my_tm.tm_year, &my_tm.tm_mon, &my_tm.tm_mday, &my_tm.tm_hour, &my_tm.tm_min, &my_tm.tm_sec, &my_tm.tm_isdst)) { case 7: break; case 6: my_tm.tm_isdst = -1; /* ask mktime to get timezone */ break; default: goto error; /* not enough data */ } if (0) { error: result = -1; } else { my_tm.tm_year -= 1900; my_tm.tm_mon -= 1; result = mktime(&my_tm); } TRACE(("...bi_mktime(%s) ->%s", sval ? sval->str : "?", ctime(&result))); cell_destroy(sp); sp->type = C_DOUBLE; sp->dval = (double) result; return_CELL("bi_mktime", sp); } #endif /* strftime(format, timestamp, utc) should be equal to gawk strftime. all parameters are optional: format: ansi c strftime format descriptor. default is "%c" timestamp: seconds since unix epoch. default is now utc: when set and != 0 date is utc otherwise local. default is 0 */ #ifdef HAVE_STRFTIME CELL * bi_strftime(CELL *sp) { const char *format = "%c"; time_t rawtime; struct tm *ptm; int n_args; int utc; STRING *sval = 0; /* strftime(sval->str, timestamp, utc) */ size_t result; TRACE_FUNC("bi_strftime", sp); n_args = sp->type; sp -= n_args; if (n_args > 0) { if (sp->type != C_STRING) cast1_to_s(sp); /* don't use < C_STRING shortcut */ sval = string(sp); if ((int) sval->len != 0) /* strftime on valid format */ format = sval->str; } else { sp->type = C_STRING; } if (n_args > 1) { if (sp[1].type != C_DOUBLE) cast1_to_d(sp + 1); rawtime = d_to_l(sp[1].dval); } else { time(&rawtime); } if (n_args > 2) { if (sp[2].type != C_DOUBLE) cast1_to_d(sp + 2); utc = d_to_i(sp[2].dval); } else { utc = 0; } if (utc != 0) ptm = gmtime(&rawtime); else ptm = localtime(&rawtime); result = strftime(sprintf_buff, (size_t) (sprintf_limit - sprintf_buff), format, ptm); TRACE(("...bi_strftime (%s, \"%d.%d.%d %d.%d.%d %d\", %d) ->%s\n", format, ptm->tm_year, ptm->tm_mon, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, ptm->tm_isdst, utc, sprintf_buff)); if (sval) free_STRING(sval); sp->ptr = (PTR) new_STRING1(sprintf_buff, result); while (n_args > 1) { n_args--; cell_destroy(sp + n_args); } return_CELL("bi_strftime", sp); } #endif /* HAVE_STRFTIME */ /************************************************ arithmetic builtins ************************************************/ #if STDC_MATHERR static void fplib_err( char *fname, double val, char *error) { rt_error("%s(%g) : %s", fname, val, error); } #endif CELL * bi_sin(CELL *sp) { TRACE_FUNC("bi_sin", sp); #if ! STDC_MATHERR if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = sin(sp->dval); #else { double x; errno = 0; if (sp->type != C_DOUBLE) cast1_to_d(sp); x = sp->dval; sp->dval = sin(sp->dval); if (errno) fplib_err("sin", x, "loss of precision"); } #endif return_CELL("bi_sin", sp); } CELL * bi_cos(CELL *sp) { TRACE_FUNC("bi_cos", sp); #if ! STDC_MATHERR if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = cos(sp->dval); #else { double x; errno = 0; if (sp->type != C_DOUBLE) cast1_to_d(sp); x = sp->dval; sp->dval = cos(sp->dval); if (errno) fplib_err("cos", x, "loss of precision"); } #endif return_CELL("bi_cos", sp); } CELL * bi_atan2(CELL *sp) { TRACE_FUNC("bi_atan2", sp); #if ! STDC_MATHERR sp--; if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); sp->dval = atan2(sp->dval, (sp + 1)->dval); #else { errno = 0; sp--; if (TEST2(sp) != TWO_DOUBLES) cast2_to_d(sp); sp->dval = atan2(sp->dval, (sp + 1)->dval); if (errno) rt_error("atan2(0,0) : domain error"); } #endif return_CELL("bi_atan2", sp); } CELL * bi_log(CELL *sp) { TRACE_FUNC("bi_log", sp); #if ! STDC_MATHERR if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = log(sp->dval); #else { double x; errno = 0; if (sp->type != C_DOUBLE) cast1_to_d(sp); x = sp->dval; sp->dval = log(sp->dval); if (errno) fplib_err("log", x, "domain error"); } #endif return_CELL("bi_log", sp); } CELL * bi_exp(CELL *sp) { TRACE_FUNC("bi_exp", sp); #if ! STDC_MATHERR if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = exp(sp->dval); #else { double x; errno = 0; if (sp->type != C_DOUBLE) cast1_to_d(sp); x = sp->dval; sp->dval = exp(sp->dval); if (errno && sp->dval) fplib_err("exp", x, "overflow"); /* on underflow sp->dval==0, ignore */ } #endif return_CELL("bi_exp", sp); } CELL * bi_int(CELL *sp) { TRACE_FUNC("bi_int", sp); if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = sp->dval >= 0.0 ? floor(sp->dval) : ceil(sp->dval); return_CELL("bi_int", sp); } CELL * bi_sqrt(CELL *sp) { TRACE_FUNC("bi_sqrt", sp); #if ! STDC_MATHERR if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = sqrt(sp->dval); #else { double x; errno = 0; if (sp->type != C_DOUBLE) cast1_to_d(sp); x = sp->dval; sp->dval = sqrt(sp->dval); if (errno) fplib_err("sqrt", x, "domain error"); } #endif return_CELL("bi_sqrt", sp); } #if !(defined(mawk_srand) || defined(mawk_rand)) /* For portability, we'll use our own random number generator , taken from: Park, SK and Miller KW, "Random Number Generators: Good Ones are Hard to Find", CACM, 31, 1192-1201, 1988. */ static long seed; /* must be >=1 and < 2^31-1 */ static CELL cseed; /* argument of last call to srand() */ #define M 0x7fffffff /* 2^31-1 */ #define MX 0xffffffff #define A 16807 #define Q 127773 /* M/A */ #define R 2836 /* M%A */ #if M == MAX__LONG #define crank(s) s = A * (s % Q) - R * (s / Q) ;\ if ( s <= 0 ) s += M #else /* 64 bit longs */ #define crank(s) { unsigned long t = (unsigned long) s ;\ t = (A * (t % Q) - R * (t / Q)) & MX ;\ if ( t >= M ) t = (t+M)&M ;\ s = (long) t ;\ } #endif /* M == MAX__LONG */ #endif /* defined(mawk_srand) || defined(mawk_rand) */ static double initial_seed(void) { double result; #if defined(HAVE_CLOCK_GETTIME) struct timespec data; if (clock_gettime(CLOCK_REALTIME, &data) == 0) result = (data.tv_sec * 1000000000L) + data.tv_nsec; else result = 0.0; #elif defined(HAVE_GETTIMEOFDAY) struct timeval data; if (gettimeofday(&data, (struct timezone *) 0) == 0) result = (data.tv_sec * 1000000) + data.tv_usec; else result = 0.0; #elif defined(WINVER) && (WINVER >= 0x501) union { FILETIME ft; long long since1601; /* time since 1 Jan 1601 in 100ns units */ } data; GetSystemTimeAsFileTime(&data.ft); result = (double) (data.since1601 / 10LL); #else time_t now; (void) time(&now); result = (double) now; #endif return result; } CELL * bi_srand(CELL *sp) { #ifdef USE_SYSTEM_SRAND static CELL cseed = { C_DOUBLE, 0, 0, 1.0 }; double seed32; #endif CELL c; TRACE_FUNC("bi_srand", sp); if (sp->type == C_NOINIT) /* seed off clock */ { cellcpy(sp, &cseed); cell_destroy(&cseed); cseed.type = C_DOUBLE; cseed.dval = initial_seed(); } else { /* user seed */ sp--; /* swap cseed and *sp ; don't need to adjust ref_cnts */ c = *sp; *sp = cseed; cseed = c; if (cseed.type != C_DOUBLE) cast1_to_d(&cseed); } #ifdef USE_SYSTEM_SRAND seed32 = fmod(cseed.dval, (double) Max_UInt); mawk_srand((unsigned) seed32); #else /* The old seed is now in *sp ; move the value in cseed to seed in range [1,M) */ cellcpy(&c, &cseed); if (c.type == C_NOINIT) cast1_to_d(&c); seed = ((c.type == C_DOUBLE) ? (long) (d_to_l(c.dval) & M) % M + 1 : (long) hash(string(&c)->str) % M + 1); if (seed == M) seed = M - 1; cell_destroy(&c); /* crank it once so close seeds don't give a close first result */ crank(seed); #endif return_CELL("bi_srand", sp); } CELL * bi_rand(CELL *sp) { TRACE_FUNC("bi_rand", sp); #ifdef USE_SYSTEM_SRAND { long value = (long) mawk_rand(); sp++; sp->type = C_DOUBLE; sp->dval = ((double) value) / ((unsigned long) MAWK_RAND_MAX); } #else crank(seed); sp++; sp->type = C_DOUBLE; sp->dval = (double) seed / (double) M; #endif return_CELL("bi_rand", sp); } #undef A #undef M #undef MX #undef Q #undef R #undef crank /************************************************* miscellaneous builtins close, system and getline fflush *************************************************/ CELL * bi_close(CELL *sp) { int x; TRACE_FUNC("bi_close", sp); if (sp->type < C_STRING) cast1_to_s(sp); x = file_close((STRING *) sp->ptr); free_STRING(string(sp)); sp->type = C_DOUBLE; sp->dval = (double) x; return_CELL("bi_close", sp); } CELL * bi_fflush(CELL *sp) { int ret = 0; TRACE_FUNC("bi_fflush", sp); if (sp->type == 0) fflush(stdout); else { sp--; if (sp->type < C_STRING) cast1_to_s(sp); ret = file_flush(string(sp)); free_STRING(string(sp)); } sp->type = C_DOUBLE; sp->dval = (double) ret; return_CELL("bi_fflush", sp); } CELL * bi_system(CELL *sp GCC_UNUSED) { int ret_val; TRACE_FUNC("bi_system", sp); if (sp->type < C_STRING) cast1_to_s(sp); #ifdef HAVE_REAL_PIPES flush_all_output(); ret_val = wait_status(system(string(sp)->str)); #elif defined(__MINGW32__) flush_all_output(); ret_val = system(string(sp)->str); #elif defined(MSDOS) ret_val = DOSexec(string(sp)->str); #else ret_val = -1; #endif cell_destroy(sp); sp->type = C_DOUBLE; sp->dval = (double) ret_val; return_CELL("bi_system", sp); } /* getline() */ /* if type == 0 : stack is 0 , target address if type == F_IN : stack is F_IN, expr(filename), target address if type == PIPE_IN : stack is PIPE_IN, target address, expr(pipename) */ CELL * bi_getline(CELL *sp) { CELL tc; CELL *cp = 0; char *p = 0; size_t len = 0; FIN *fin_p; TRACE_FUNC("bi_getline", sp); switch (sp->type) { case 0: sp--; if (!main_fin) open_main(); if (!(p = FINgets(main_fin, &len))) goto eof; cp = (CELL *) sp->ptr; if (TEST2(NR) != TWO_DOUBLES) cast2_to_d(NR); NR->dval += 1.0; rt_nr++; FNR->dval += 1.0; rt_fnr++; break; case F_IN: sp--; if (sp->type < C_STRING) cast1_to_s(sp); fin_p = (FIN *) file_find(string(sp), F_IN); free_STRING(string(sp)); sp--; if (!fin_p) goto open_failure; if (!(p = FINgets(fin_p, &len))) { FINsemi_close(fin_p); goto eof; } cp = (CELL *) sp->ptr; break; case PIPE_IN: sp -= 2; if (sp->type < C_STRING) cast1_to_s(sp); fin_p = (FIN *) file_find(string(sp), PIPE_IN); free_STRING(string(sp)); if (!fin_p) goto open_failure; if (!(p = FINgets(fin_p, &len))) { FINsemi_close(fin_p); #ifdef HAVE_REAL_PIPES /* reclaim process slot */ wait_for(0); #endif goto eof; } cp = (CELL *) (sp + 1)->ptr; break; default: bozo("type in bi_getline"); } /* we've read a line , store it */ if (len == 0) { tc.type = C_STRING; tc.ptr = (PTR) & null_str; null_str.ref_cnt++; } else { tc.type = C_MBSTRN; tc.ptr = (PTR) new_STRING0(len); memcpy(string(&tc)->str, p, len); } slow_cell_assign(cp, &tc); cell_destroy(&tc); sp->dval = 1.0; goto done; open_failure: sp->dval = -1.0; goto done; eof: sp->dval = 0.0; /* fall thru to done */ done: sp->type = C_DOUBLE; return_CELL("bi_getline", sp); } /********************************************** sub() and gsub() **********************************************/ /* entry: sp[0] = address of CELL to sub on sp[-1] = substitution CELL sp[-2] = regular expression to match */ CELL * bi_sub(CELL *sp) { CELL *cp; /* pointer to the replacement target */ CELL tc; /* build the new string here */ CELL sc; /* copy of the target CELL */ char *front, *middle; /* pieces */ size_t middle_len; TRACE_FUNC("bi_sub", sp); sp -= 2; if (sp->type != C_RE) cast_to_RE(sp); if (sp[1].type != C_REPL && sp[1].type != C_REPLV) cast_to_REPL(sp + 1); cp = (CELL *) (sp + 2)->ptr; /* make a copy of the target, because we won't change anything including type unless the match works */ cellcpy(&sc, cp); if (sc.type < C_STRING) cast1_to_s(&sc); front = string(&sc)->str; middle = REmatch(front, string(&sc)->len, cast_to_re(sp->ptr), &middle_len, 0); if (middle != 0) { size_t front_len = (size_t) (middle - front); char *back = middle + middle_len; size_t back_len = string(&sc)->len - front_len - middle_len; if ((sp + 1)->type == C_REPLV) { STRING *sval = new_STRING0(middle_len); memcpy(sval->str, middle, middle_len); replv_to_repl(sp + 1, sval); free_STRING(sval); } tc.type = C_STRING; tc.ptr = (PTR) new_STRING0(front_len + string(sp + 1)->len + back_len); { char *p = string(&tc)->str; if (front_len) { memcpy(p, front, front_len); p += front_len; } if (string(sp + 1)->len) { memcpy(p, string(sp + 1)->str, string(sp + 1)->len); p += string(sp + 1)->len; } if (back_len) memcpy(p, back, back_len); } slow_cell_assign(cp, &tc); free_STRING(string(&tc)); } free_STRING(string(&sc)); repl_destroy(sp + 1); sp->type = C_DOUBLE; sp->dval = middle != (char *) 0 ? 1.0 : 0.0; return_CELL("bi_sub", sp); } static unsigned repl_cnt; /* number of global replacements */ static STRING * gsub3(PTR re, CELL *repl, CELL *target) { int j; CELL xrepl; STRING *input = string(target); STRING *output; STRING *buffer; STRING *sval; size_t have; size_t used = 0; size_t guess = input->len; size_t limit = guess; int skip0 = -1; size_t howmuch; TRACE(("called gsub3\n")); /* * If the replacement is constant, do it only once. */ if (repl->type != C_REPLV) { cellcpy(&xrepl, repl); } else { memset(&xrepl, 0, sizeof(xrepl)); } repl_cnt = 0; output = new_STRING0(limit); for (j = 0; j <= (int) input->len; ++j) { char *where = REmatch(input->str + j, input->len - (size_t) j, cast_to_re(re), &howmuch, (j != 0)); /* * REmatch returns a non-null pointer if it found a match. But * that can be an empty string, e.g., for "*" or "?". The length * is in 'howmuch'. */ if (where != 0) { have = (size_t) (where - (input->str + j)); if (have) { skip0 = -1; TRACE(("..before match:%d:", (int) have)); TRACE_STRING2(input->str + j, have); TRACE(("\n")); memcpy(output->str + used, input->str + j, have); used += have; } TRACE(("REmatch %d vs %d len=%d:", (int) j, skip0, (int) howmuch)); TRACE_STRING2(where, howmuch); TRACE(("\n")); if (repl->type == C_REPLV) { if (xrepl.ptr == 0 || string(&xrepl)->len != howmuch || (howmuch != 0 && memcmp(string(&xrepl)->str, where, howmuch))) { if (xrepl.ptr != 0) repl_destroy(&xrepl); sval = new_STRING1(where, howmuch); cellcpy(&xrepl, repl); replv_to_repl(&xrepl, sval); free_STRING(sval); } } have = string(&xrepl)->len; TRACE(("..replace:")); TRACE_STRING2(string(&xrepl)->str, have); TRACE(("\n")); if (howmuch || (j != skip0)) { ++repl_cnt; /* * If this new chunk is longer than its replacement, add that * to the estimate of the length. Then, if the estimate goes * past the allocated length, reallocate and copy the existing * data. */ if (have > howmuch) { /* growing */ guess += (have - howmuch); if (guess >= limit) { buffer = output; limit = (++guess) * 2; /* FIXME - too coarse? */ output = new_STRING0(limit); memcpy(output->str, buffer->str, used); free_STRING(buffer); } } else if (howmuch > have) { /* shrinking */ guess -= (howmuch - have); } /* * Finally, copy the new chunk. */ memcpy(output->str + used, string(&xrepl)->str, have); used += have; } if (howmuch) { j = (int) ((size_t) (where - input->str) + howmuch) - 1; } else { j = (int) (where - input->str); if (j < (int) input->len) { TRACE(("..emptied:")); TRACE_STRING2(input->str + j, 1); TRACE(("\n")); output->str[used++] = input->str[j]; } } skip0 = (howmuch != 0) ? (j + 1) : -1; } else { have = (input->len - (size_t) j); TRACE(("..after match:%d:", (int) have)); TRACE_STRING2(input->str + j, have); TRACE(("\n")); memcpy(output->str + used, input->str + j, have); used += have; break; } } TRACE(("..input %d ->output %d\n", (int) input->len, (int) output->len)); repl_destroy(&xrepl); if (output->len > used) { buffer = output; output = new_STRING1(output->str, used); free_STRING(buffer); } TRACE(("..done gsub3\n")); return output; } /* set up for call to gsub() */ CELL * bi_gsub(CELL *sp) { CELL *cp; /* pts at the replacement target */ CELL sc; /* copy of replacement target */ CELL tc; /* build the result here */ STRING *result; TRACE_FUNC("bi_gsub", sp); sp -= 2; if (sp->type != C_RE) cast_to_RE(sp); if ((sp + 1)->type != C_REPL && (sp + 1)->type != C_REPLV) cast_to_REPL(sp + 1); cellcpy(&sc, cp = (CELL *) (sp + 2)->ptr); if (sc.type < C_STRING) cast1_to_s(&sc); TRACE(("..actual gsub args:\n")); TRACE(("arg0: ")); TRACE_CELL(sp); TRACE(("arg1: ")); TRACE_CELL(sp + 1); TRACE(("arg2: ")); TRACE_CELL(&sc); result = gsub3(sp->ptr, sp + 1, &sc); tc.ptr = (PTR) result; if (repl_cnt) { tc.type = C_STRING; slow_cell_assign(cp, &tc); } sp->type = C_DOUBLE; sp->dval = (double) repl_cnt; TRACE(("Result: ")); TRACE_CELL(sp); TRACE(("String: ")); TRACE_STRING(result); TRACE(("\n")); /* cleanup */ free_STRING(string(&sc)); free_STRING(string(&tc)); repl_destroy(sp + 1); return_CELL("bi_gsub", sp); } mawk-1.3.4-20240123/rexp4.c0000644000000000000000000000116514457207704013272 0ustar rootroot/* regexp_system.c copyright 2009-2014,2023 Thomas E. Dickey copyright 2005, Aleksey Cheusov This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. */ /* * $MawkId: rexp4.c,v 1.9 2023/07/23 11:32:20 tom Exp $ */ #include "mawk.h" #include "rexp.h" #include "field.h" char * is_string_split(PTR q, size_t * lenp) { STATE *p = (STATE *) q; if (p != 0 && (p[0].s_type == M_STR && p[1].s_type == M_ACCEPT)) { *lenp = p->s_len; return p->s_data.str; } else return (char *) 0; } mawk-1.3.4-20240123/rexp3.c0000644000000000000000000002621314461322167013266 0ustar rootroot/******************************************** rexp3.c copyright 2008-2020,2023, Thomas E. Dickey copyright 2010, Jonathan Nieder copyright 1991-1992,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: rexp3.c,v 1.51 2023/07/29 23:44:55 tom Exp $ */ /* match a string against a machine */ #include "rexp.h" #define push(mx,sx,px,ssx,ux) do { \ if (++stackp == RE_run_stack_limit) \ stackp = RE_new_run_stack() ;\ TRACE2(("@%d, pushing %d:%03d\n", __LINE__, (int)(stackp - RE_run_stack_base), (int)(m - machine))); \ stackp->m = (mx); \ stackp->s = (sx); \ stackp->sp = (int) ((px) - RE_pos_stack_base); \ stackp->tp = (px)->prev_offset; \ stackp->ss = (ssx); \ stackp->u = (ux); \ } while(0) #ifdef NO_RI_LOOP_UNROLL #define restart_count(old,new) \ if (old != new) { \ TRACE2(("RESET %p ->%p\n", old, new)); \ m->it_cnt = 1; \ } #else #define restart_count(old,new) /* nothing */ #endif #define CASE_UANY(x) case (x)+U_OFF: /* FALLTHRU */ case (x)+U_ON #define TR_STR(s) TRACE((" str:%i len:%lu\n", ((s) ? (int) ((s) - str) : -99), (unsigned long) *lenp)) #define RE_TURN() \ if (cb_ss) { \ *lenp = (size_t) (cb_e - cb_ss); \ } \ TR_STR(s); \ TRACE2(("returning @%d: %d\n", __LINE__, cb_ss ? (int)(cb_ss - str) : -1)); \ return cb_ss #if OPT_TRACE static const char * RE_u_end(int flag) { static const char *utable[] = { "U_OFF + END_OFF", "U_ON + END_OFF", "U_OFF + END_ON", "U_ON + END_ON", }; flag /= U_ON; return utable[flag % 4]; } #endif /* returns start of first longest match and the length by reference. If no match returns NULL and length zero */ char * REmatch(char *str, /* string to test */ size_t str_len, /* ...its length */ STATE * machine, /* compiled regular expression */ size_t *lenp, /* where to return matched-length */ int no_bol) /* disallow match at beginning of line */ { register STATE *m = machine; char *s = str; char *ss; register RT_STATE *stackp; int u_flag, t; char *str_end = s + str_len; RT_POS_ENTRY *sp; char *ts; /* state of current best match stored here */ char *cb_ss; /* the start */ char *cb_e = 0; /* the end , pts at first char not matched */ *lenp = 0; TRACE(("REmatch: %s \"%s\" ~ /pattern/\n", no_bol ? "any" : "1st", str)); /* check for the easy case */ if (m->s_type == M_STR && (m + 1)->s_type == M_ACCEPT) { TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); if ((ts = str_str(s, str_len, m->s_data.str, (size_t) m->s_len))) { *lenp = m->s_len; } TR_STR(ts); return ts; } u_flag = U_ON; cb_ss = ss = (char *) 0; stackp = RE_run_stack_empty; sp = RE_pos_stack_empty; RE_init_it_cnt(m); RE_CASE(); refill: TRACE2(("@%d, refill machine %03d\n", __LINE__, (int) (m - machine))); if (stackp == RE_run_stack_empty) { RE_TURN(); } ss = stackp->ss; s = (stackp--)->s; if (cb_ss) { /* does new state start too late ? */ if (ss) { if (cb_ss < ss || (cb_ss == ss && cb_e == str_end)) { RE_FILL(); } } else if (cb_ss < s || (cb_ss == s && cb_e == str_end)) { RE_FILL(); } } m = (stackp + 1)->m; TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); sp = RE_pos_stack_base + (stackp + 1)->sp; sp->prev_offset = (stackp + 1)->tp; u_flag = (stackp + 1)->u; reswitch: TRACE(("[%s@%d] %d:%03d %-8s %-15s: %s\n", __FILE__, __LINE__, (int) (stackp - RE_run_stack_base), (int) (m - machine), REs_type(m), RE_u_end(u_flag), cb_ss ? cb_ss : s)); switch (m->s_type + u_flag) { case M_STR + U_OFF + END_OFF: TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); if (strncmp(s, m->s_data.str, (size_t) m->s_len)) { TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); RE_FILL(); } if (!ss) { if (cb_ss && s > cb_ss) { TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); RE_FILL(); } else { ss = s; } } s += m->s_len; m++; TRACE2(("@%d, next %03d\n", __LINE__, (int) (m - machine))); RE_CASE(); case M_STR + U_OFF + END_ON: TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); if (strcmp(s, m->s_data.str)) { RE_FILL(); } if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } s += m->s_len; m++; TRACE2(("@%d, next %03d\n", __LINE__, (int) (m - machine))); RE_CASE(); case M_STR + U_ON + END_OFF: TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); if (s >= str_end) { RE_FILL(); } if (!(s = str_str(s, (size_t) (str_end - s), m->s_data.str, (size_t) m->s_len))) { RE_FILL(); } if (s >= str_end) { RE_FILL(); } push(m, s + 1, sp, ss, U_ON); if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } s += m->s_len; m++; u_flag = U_OFF; TRACE2(("@%d, next %03d\n", __LINE__, (int) (m - machine))); RE_CASE(); case M_STR + U_ON + END_ON: TRACE2(("@%d, now %03d\n", __LINE__, (int) (m - machine))); t = (int) ((size_t) (str_end - s) - m->s_len); if (t < 0 || memcmp(ts = s + t, m->s_data.str, (size_t) m->s_len)) { RE_FILL(); } if (!ss) { if (cb_ss && ts > cb_ss) { RE_FILL(); } else { ss = ts; } } s = str_end; m++; u_flag = U_OFF; TRACE2(("@%d, next %03d\n", __LINE__, (int) (m - machine))); RE_CASE(); case M_CLASS + U_OFF + END_OFF: if (s >= str_end) { RE_FILL(); } if (!ison(*m->s_data.bvp, s[0])) { RE_FILL(); } if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } s++; m++; RE_CASE(); case M_CLASS + U_OFF + END_ON: if (s >= str_end) { RE_FILL(); } if (s[1] || !ison(*m->s_data.bvp, s[0])) { RE_FILL(); } if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } s++; m++; RE_CASE(); case M_CLASS + U_ON + END_OFF: if (s >= str_end) { RE_FILL(); } while (!ison(*m->s_data.bvp, s[0])) { if (s >= str_end) { RE_FILL(); } else { s++; } } if (s >= str_end) { RE_FILL(); } s++; push(m, s, sp, ss, U_ON); if (!ss) { if (cb_ss && s - 1 > cb_ss) { RE_FILL(); } else { ss = s - 1; } } m++; u_flag = U_OFF; RE_CASE(); case M_CLASS + U_ON + END_ON: if ((s >= str_end) || !ison(*m->s_data.bvp, str_end[-1])) { RE_FILL(); } if (!ss) { if (cb_ss && str_end - 1 > cb_ss) { RE_FILL(); } else { ss = str_end - 1; } } s = str_end; m++; u_flag = U_OFF; RE_CASE(); case M_ANY + U_OFF + END_OFF: if (s >= str_end) { RE_FILL(); } if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } s++; m++; RE_CASE(); case M_ANY + U_OFF + END_ON: if ((s >= str_end) || ((s + 1) < str_end)) { RE_FILL(); } if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } s++; m++; RE_CASE(); case M_ANY + U_ON + END_OFF: if (s >= str_end) { RE_FILL(); } s++; push(m, s, sp, ss, U_ON); if (!ss) { if (cb_ss && s - 1 > cb_ss) { RE_FILL(); } else { ss = s - 1; } } m++; u_flag = U_OFF; RE_CASE(); case M_ANY + U_ON + END_ON: if (s >= str_end) { RE_FILL(); } if (!ss) { if (cb_ss && str_end - 1 > cb_ss) { RE_FILL(); } else { ss = str_end - 1; } } s = str_end; m++; u_flag = U_OFF; RE_CASE(); case M_START + U_OFF + END_OFF: case M_START + U_ON + END_OFF: if (s != str || no_bol) { RE_FILL(); } ss = s; m++; u_flag = U_OFF; RE_CASE(); case M_START + U_OFF + END_ON: case M_START + U_ON + END_ON: if (s != str || no_bol || (s < str_end)) { RE_FILL(); } ss = s; m++; u_flag = U_OFF; RE_CASE(); case M_END + U_OFF: if (s < str_end) { RE_FILL(); } if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } m++; RE_CASE(); case M_END + U_ON: s = str_end; if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } m++; u_flag = U_OFF; RE_CASE(); CASE_UANY(M_U): if (!ss) { if (cb_ss && s > cb_ss) { RE_FILL(); } else { ss = s; } } u_flag = U_ON; m++; RE_CASE(); CASE_UANY(M_1J): m += m->s_data.jump; RE_CASE(); CASE_UANY(M_SAVE_POS): /* save position for a later M_2JC */ /* see also REtest */ sp = RE_pos_push(sp, stackp, s); m++; RE_CASE(); CASE_UANY(M_2JA): /* take the non jump branch */ push(m + m->s_data.jump, s, sp, ss, u_flag); m++; RE_CASE(); case (M_2JC) + U_OFF: /* take the jump branch if position changed */ case (M_2JC) + U_ON: /* see REtest */ #ifndef NO_INTERVAL_EXPR #ifdef NO_RI_LOOP_UNROLL m->it_cnt++; TRACE(("checking loop " INT_FMT " [" INT_FMT ".." INT_FMT "]\n", m->it_cnt, m->it_min, m->it_max)); TR_STR(s); if (m->it_cnt < m->it_min) { /* keep looping until minimum is met */ RE_pos_pop(&sp, stackp); push(m + 1, s, sp, ss, u_flag); m += m->s_data.jump; TRACE2(("TEST @%d: %03d\n", __LINE__, (int) (m - machine))); } else if ((m->it_cnt >= m->it_min) && (m->it_max == MAX__INT || (m->it_max < MAX__INT && m->it_cnt >= m->it_max))) { /* quit looping once maximum is met */ RE_pos_pop(&sp, stackp); m++; TRACE2(("TEST @%d: %03d\n", __LINE__, (int) (m - machine))); } else #else /* !NO_RI_LOOP_UNROLL */ if (m->it_max < MAX__INT && ++(m->it_cnt) >= m->it_max) { ++m; RE_CASE(); /* test the next thing */ } else #endif /* NO_RI_LOOP_UNROLL */ if (RE_pos_pop(&sp, stackp) == s) { /* fall out of loop, to next instruction */ m++; TRACE2(("TEST @%d: %03d\n", __LINE__, (int) (m - machine))); } else { /* continue looping as long as matching */ push(m + 1, s, sp, ss, u_flag); m += m->s_data.jump; TRACE2(("TEST @%d: %03d\n", __LINE__, (int) (m - machine))); } RE_CASE(); #else if (RE_pos_pop(&sp, stackp) == s) { m++; RE_CASE(); } /* FALLTHRU */ #endif /* ! NO_INTERVAL_EXPR */ case (M_2JB) + U_OFF: /* take the jump branch */ /* FALLTHRU */ case (M_2JB) + U_ON: push(m + 1, s, sp, ss, u_flag); m += m->s_data.jump; RE_CASE(); case M_ACCEPT + U_OFF: if (!ss) ss = s; if (!cb_ss || ss < cb_ss || (ss == cb_ss && s > cb_e)) { /* we have a new current best */ restart_count(cb_ss, ss); cb_ss = ss; cb_e = s; TRACE2(("@%d, new best [%d..%d]'%.*s'\n", __LINE__, (int) (cb_ss - str), (int) (cb_e - str), (int) (cb_e - cb_ss), cb_ss)); } else if (ss == cb_ss && s == cb_e) { RE_TURN(); } RE_FILL(); case M_ACCEPT + U_ON: if (!ss) { ss = s; } else { s = str_end; } if (!cb_ss || ss < cb_ss || (ss == cb_ss && s > cb_e)) { /* we have a new current best */ restart_count(cb_ss, ss); cb_ss = ss; cb_e = s; TRACE2(("@%d, new best [%d..%d]'%.*s'\n", __LINE__, (int) (cb_ss - str), (int) (cb_e - str), (int) (cb_e - cb_ss), cb_ss)); } else if (ss == cb_ss && s == cb_e) { RE_TURN(); } RE_FILL(); default: RE_panic("unexpected case in REmatch"); } } #undef push mawk-1.3.4-20240123/parse.h0000644000000000000000000000375014453360336013346 0ustar rootroot#ifndef _yy_defines_h_ #define _yy_defines_h_ #define UNEXPECTED 257 #define BAD_DECIMAL 258 #define NL 259 #define SEMI_COLON 260 #define LBRACE 261 #define RBRACE 262 #define LBOX 263 #define RBOX 264 #define COMMA 265 #define IO_OUT 266 #define ASSIGN 267 #define ADD_ASG 268 #define SUB_ASG 269 #define MUL_ASG 270 #define DIV_ASG 271 #define MOD_ASG 272 #define POW_ASG 273 #define QMARK 274 #define COLON 275 #define OR 276 #define AND 277 #define IN 278 #define MATCH 279 #define EQ 280 #define NEQ 281 #define LT 282 #define LTE 283 #define GT 284 #define GTE 285 #define CAT 286 #define GETLINE 287 #define PLUS 288 #define MINUS 289 #define MUL 290 #define DIV 291 #define MOD 292 #define NOT 293 #define UMINUS 294 #define IO_IN 295 #define PIPE 296 #define POW 297 #define INC_or_DEC 298 #define DOLLAR 299 #define FIELD 300 #define LPAREN 301 #define RPAREN 302 #define DOUBLE 303 #define STRING_ 304 #define RE 305 #define ID 306 #define D_ID 307 #define FUNCT_ID 308 #define BUILTIN 309 #define LENGTH 310 #define PRINT 311 #define PRINTF 312 #define SPLIT 313 #define MATCH_FUNC 314 #define SUB 315 #define GSUB 316 #define DO 317 #define WHILE 318 #define FOR 319 #define BREAK 320 #define CONTINUE 321 #define IF 322 #define ELSE 323 #define DELETE 324 #define BEGIN 325 #define END 326 #define EXIT 327 #define NEXT 328 #define NEXTFILE 329 #define RETURN 330 #define FUNCTION 331 #ifdef YYSTYPE #undef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 #endif #ifndef YYSTYPE_IS_DECLARED #define YYSTYPE_IS_DECLARED 1 typedef union YYSTYPE{ CELL *cp ; SYMTAB *stp ; int start ; /* code starting address as offset from code_base */ PF_CP fp ; /* ptr to a (print/printf) or (sub/gsub) function */ const BI_REC *bip ; /* ptr to info about a builtin */ FBLOCK *fbp ; /* ptr to a function block */ ARG2_REC *arg2p ; CA_REC *ca_p ; int ival ; PTR ptr ; } YYSTYPE; #endif /* !YYSTYPE_IS_DECLARED */ extern YYSTYPE yylval; #endif /* _yy_defines_h_ */ mawk-1.3.4-20240123/vs6.mak0000644000000000000000000001264512042736676013304 0ustar rootroot# $MawkId: vs6.mak,v 1.3 2012/10/27 10:55:58 tom Exp $ # Microsoft C makefile for mawk, # # Tested with Microsoft Visual Studio 6 using nmake. ############################################################################### # copyright 2010,2012 Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### !include #======================================================================== CFLAGS = -I. -DLOCAL_REGEXP $(cflags) .c.obj: $(CC) $(CFLAGS) -c $< OBJ1 = parse.obj array.obj bi_funct.obj bi_vars.obj cast.obj code.obj \ da.obj error.obj execute.obj fcall.obj OBJ2 = field.obj files.obj fin.obj hash.obj jmp.obj init.obj \ kw.obj main.obj matherr.obj OBJ3 = memory.obj print.obj re_cmpl.obj scan.obj scancode.obj split.obj \ zmalloc.obj version.obj regexp.obj dosexec.obj MAWK_OBJ = $(OBJ1) $(OBJ2) $(OBJ3) mawk.exe : $(MAWK_OBJ) $(link) $(LDFLAGS) $(MAWK_OBJ) $(LIBS) -out:mawk.exe -map:mawk.map config.h : msdos/vs6.h copy msdos\vs6.h config.h dosexec.c : msdos/dosexec.c copy msdos\dosexec.c dosexec.c mawk_test : mawk.exe # test that we have a sane mawk @echo you may have to run the test manually cd test && mawktest.bat fpe_test : mawk.exe # test FPEs are handled OK @echo testing floating point exception handling @echo you may have to run the test manually cd test && fpe_test.bat check : mawk_test fpe_test ################################################### # FIXME # parse.c is provided # so you don't need to make it. # # But if you do: here's how: # To make it with byacc # YACC=byacc # parse.c : parse.y # $(YACC) -d parse.y # rename y_tab.h parse.h # rename y_tab.c parse.c ######################################## scancode.c : makescan.c scan.h $(CC) -o makescan.exe makescan.c makescan.exe > scancode.c del makescan.exe clean : -del *.bak -del *.exe -del *.ilk -del *.map -del *.pdb -del *.obj distclean : clean -del dosexec.c -del scancode.c -del config.h # dependencies of .objs on .h array.obj : array.h bi_vars.h config.h field.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h bi_funct.obj : array.h bi_funct.h bi_vars.h config.h field.h files.h fin.h init.h mawk.h memory.h nstd.h regexp.h repl.h sizes.h symtype.h types.h zmalloc.h bi_vars.obj : array.h bi_vars.h config.h field.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h cast.obj : array.h config.h field.h mawk.h memory.h nstd.h parse.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h code.obj : array.h code.h config.h field.h init.h jmp.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h da.obj : array.h bi_funct.h code.h config.h field.h mawk.h memory.h nstd.h repl.h sizes.h symtype.h types.h zmalloc.h error.obj : array.h bi_vars.h config.h mawk.h nstd.h parse.h scan.h scancode.h sizes.h symtype.h types.h execute.obj : array.h bi_funct.h bi_vars.h code.h config.h field.h fin.h mawk.h memory.h nstd.h regexp.h repl.h sizes.h symtype.h types.h zmalloc.h fcall.obj : array.h code.h config.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h field.obj : array.h bi_vars.h config.h field.h init.h mawk.h memory.h nstd.h parse.h regexp.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h files.obj : array.h config.h files.h fin.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h fin.obj : array.h bi_vars.h config.h field.h fin.h mawk.h memory.h nstd.h parse.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h hash.obj : array.h config.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h init.obj : array.h bi_vars.h code.h config.h field.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h jmp.obj : array.h code.h config.h init.h jmp.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h kw.obj : array.h config.h init.h mawk.h nstd.h parse.h sizes.h symtype.h types.h main.obj : array.h code.h config.h files.h init.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h makescan.obj : config.h nstd.h scancode.h matherr.obj : array.h config.h init.h mawk.h nstd.h sizes.h symtype.h types.h memory.obj : config.h mawk.h memory.h nstd.h sizes.h types.h zmalloc.h parse.obj : array.h bi_funct.h bi_vars.h code.h config.h field.h files.h jmp.h mawk.h memory.h nstd.h sizes.h symtype.h types.h zmalloc.h print.obj : array.h bi_funct.h bi_vars.h config.h field.h files.h mawk.h memory.h nstd.h parse.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h re_cmpl.obj : array.h config.h mawk.h memory.h nstd.h parse.h regexp.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h scan.obj : array.h code.h config.h field.h files.h fin.h init.h mawk.h memory.h nstd.h parse.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h split.obj : array.h bi_funct.h bi_vars.h config.h field.h mawk.h memory.h nstd.h parse.h regexp.h repl.h scan.h scancode.h sizes.h symtype.h types.h zmalloc.h version.obj : array.h config.h init.h mawk.h nstd.h patchlev.h sizes.h symtype.h types.h zmalloc.obj : config.h mawk.h nstd.h sizes.h types.h zmalloc.h regexp.obj : rexpdb.c rexp4.c rexp2.c regexp_system.c sizes.h mawk.h rexp0.c rexp1.c config.h rexp.h regexp.h nstd.h rexp3.c rexp.c field.h mawk-1.3.4-20240123/man/0000755000000000000000000000000014554061433012627 5ustar rootrootmawk-1.3.4-20240123/man/TODO0000644000000000000000000000362013705060156013316 0ustar rootroot-- $MawkId: TODO,v 1.8 2020/07/19 15:02:06 tom Exp $ mawk was implemented to conform with POSIX 1003.2-1992 According to http://www.opengroup.org/austin/papers/posix_faq.html that was merged into POSIX-1003.1, and the latest relevant text of that is documented here: http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html The extended regular expressions are documented here: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html Sections below refer to the awk.html sections. OPTIONS mawk complies here. OPERANDS mawk complies here. STDIN mawk complies here. INPUT FILES mawk complies here. ENVIRONMENT VARIABLES mawk ignores LC_COLLATE, LC_MESSAGES, LC_NUMERIC and NLSPATH mawk implements extensions MAWKBINMODE which gawk does as BINMODE MAWK_LONG_OPTIONS to ignore long options such as gawk's. Values are: error, warn, ignore (only the first character is checked). WHINY_USERS feature from gawk which makes iteration over array in sorted order. EXTENDED DESCRIPTION strings are converted to double using strtod(), which could be implemented using atof(). ENVIRON and CONVFMT are in the standard now, not extensions. >Expressions in awk mawk complies >Variables and Special Variables mawk complies >Regular Expressions mawk's built-in regular expressions supports brace expressions (used to denote minimum/maximum number of matches). mawk can be built with an external regular-expression library. However, POSIX regular expressions do not support matches of NUL-bytes. mawk's internal regular expressions support NULs. >Expression Patterns ok >Pattern Ranges ok >Actions delete is now part of POSIX-1003.1 >Output Statements mawk does not use popen/pclose for opening/closing a pipe. >Arithmetic Functions ok >String Functions toupper and tolower are now part of POSIX-1003.1 >Input/Output and General Functions ok >User-Defined Functions ok mawk-1.3.4-20240123/man/mawk.txt0000644000000000000000000014135714554045066014346 0ustar rootrootMAWK(1) User commands MAWK(1) NAME mawk - pattern scanning and text processing language SYNOPSIS mawk [-W option] [-F value] [-v var=value] [--] 'program text' [file ...] mawk [-W option] [-F value] [-v var=value] [-f program-file] [--] [file ...] DESCRIPTION mawk is an interpreter for the AWK Programming Language. The AWK lan- guage is useful for manipulation of data files, text retrieval and pro- cessing, and for prototyping and experimenting with algorithms. mawk is a new awk meaning it implements the AWK language as defined in Aho, Kernighan and Weinberger, The AWK Programming Language, Addison-Wesley Publishing, 1988 (hereafter referred to as the AWK book.) mawk con- forms to the POSIX 1003.2 (draft 11.3) definition of the AWK language which contains a few features not described in the AWK book, and mawk provides a small number of extensions. An AWK program is a sequence of pattern {action} pairs and function definitions. Short programs are entered on the command line usually enclosed in ' ' to avoid shell interpretation. Longer programs can be read in from a file with the -f option. Data input is read from the list of files on the command line or from standard input when the list is empty. The input is broken into records as determined by the record separator variable, RS. Initially, RS = "\n" and records are synony- mous with lines. Each record is compared against each pattern and if it matches, the program text for {action} is executed. OPTIONS -F value sets the field separator, FS, to value. -f file Program text is read from file instead of from the com- mand line. Multiple -f options are allowed. -v var=value assigns value to program variable var. -- indicates the unambiguous end of options. The above options will be available with any POSIX compatible implemen- tation of AWK. Implementation specific options are prefaced with -W. mawk provides these: -W dump writes an assembler like listing of the internal representation of the program to stdout and exits 0 (on successful compila- tion). -W exec file Program text is read from file and this is the last option. This is a useful alternative to -f on systems that support the #! "magic number" convention for executable scripts. Those im- plicitly pass the pathname of the script itself as the final pa- rameter, and expect no more than one "-" option on the #! line. Because mawk can combine multiple -W options separated by com- mas, you can use this option when an additional -W option is needed. -W help prints a usage message to stderr and exits (same as "-W usage"). -W interactive sets unbuffered writes to stdout and line buffered reads from stdin. Records from stdin are lines regardless of the value of RS. -W posix modifies mawk's behavior to be more POSIX-compliant: o forces mawk not to consider '\n' to be space. The original "posix_space" is recognized, but deprecated. -W random=num calls srand with the given parameter (and overrides the auto- seeding behavior). -W sprintf=num adjusts the size of mawk's internal sprintf buffer to num bytes. More than rare use of this option indicates mawk should be re- compiled. -W traditional Omit features such as interval expressions which were not sup- ported by traditional awk. -W usage prints a usage message to stderr and exits (same as "-W help"). -W version mawk writes its version and copyright to stdout and compiled limits to stderr and exits 0. mawk accepts abbreviations for any of these options, e.g., "-W v" and "-Wv" both tell mawk to show its version. mawk allows multiple -W options to be combined by separating the op- tions with commas, e.g., -Wsprint=2000,posix. This is useful for exe- cutable #! "magic number" invocations in which only one argument is supported, e.g., -Winteractive,exec. THE AWK LANGUAGE 1. Program structure An AWK program is a sequence of pattern {action} pairs and user func- tion definitions. A pattern can be: BEGIN END expression expression , expression One, but not both, of pattern {action} can be omitted. If {action} is omitted it is implicitly { print }. If pattern is omitted, then it is implicitly matched. BEGIN and END patterns require an action. Statements are terminated by newlines, semi-colons or both. Groups of statements such as actions or loop bodies are blocked via { ... } as in C. The last statement in a block doesn't need a terminator. Blank lines have no meaning; an empty statement is terminated with a semi- colon. Long statements can be continued with a backslash, \. A state- ment can be broken without a backslash after a comma, left brace, &&, ||, do, else, the right parenthesis of an if, while or for statement, and the right parenthesis of a function definition. A comment starts with # and extends to, but does not include the end of line. The following statements control program flow inside blocks. if ( expr ) statement if ( expr ) statement else statement while ( expr ) statement do statement while ( expr ) for ( opt_expr ; opt_expr ; opt_expr ) statement for ( var in array ) statement continue break 2. Data types, conversion and comparison There are two basic data types, numeric and string. Numeric constants can be integer like -2, decimal like 1.08, or in scientific notation like -1.1e4 or .28E-3. All numbers are represented internally and all computations are done in floating point arithmetic. So for example, the expression 0.2e2 == 20 is true and true is represented as 1.0. String constants are enclosed in double quotes. "This is a string with a newline at the end.\n" Strings can be continued across a line by escaping (\) the newline. The following escape sequences are recognized. \\ \ \" " \a alert, ascii 7 \b backspace, ascii 8 \t tab, ascii 9 \n newline, ascii 10 \v vertical tab, ascii 11 \f formfeed, ascii 12 \r carriage return, ascii 13 \ddd 1, 2 or 3 octal digits for ascii ddd \xhh 1 or 2 hex digits for ascii hh If you escape any other character \c, you get \c, i.e., mawk ignores the escape. There are really three basic data types; the third is number and string which has both a numeric value and a string value at the same time. User defined variables come into existence when first referenced and are initialized to null, a number and string value which has numeric value 0 and string value "". Non-trivial number and string typed data come from input and are typically stored in fields. (See section 4). The type of an expression is determined by its context and automatic type conversion occurs if needed. For example, to evaluate the state- ments y = x + 2 ; z = x "hello" The value stored in variable y will be typed numeric. If x is not nu- meric, the value read from x is converted to numeric before it is added to 2 and stored in y. The value stored in variable z will be typed string, and the value of x will be converted to string if necessary and concatenated with "hello". (Of course, the value and type stored in x is not changed by any conversions.) A string expression is converted to numeric using its longest numeric prefix as with atof(3). A numeric expression is converted to string by replacing expr with sprintf(CON- VFMT, expr), unless expr can be represented on the host machine as an exact integer then it is converted to sprintf("%d", expr). Sprintf() is an AWK built-in that duplicates the functionality of sprintf(3), and CONVFMT is a built-in variable used for internal conversion from number to string and initialized to "%.6g". Explicit type conversions can be forced, expr "" is string and expr+0 is numeric. To evaluate, expr1 rel-op expr2, if both operands are numeric or number and string then the comparison is numeric; if both operands are string the comparison is string; if one operand is string, the non-string op- erand is converted and the comparison is string. The result is nu- meric, 1 or 0. In boolean contexts such as, if ( expr ) statement, a string expression evaluates true if and only if it is not the empty string ""; numeric values if and only if not numerically zero. 3. Regular expressions In the AWK language, records, fields and strings are often tested for matching a regular expression. Regular expressions are enclosed in slashes, and expr ~ /r/ is an AWK expression that evaluates to 1 if expr "matches" r, which means a substring of expr is in the set of strings defined by r. With no match the expression evaluates to 0; replacing ~ with the "not match" operator, !~ , reverses the meaning. As pattern-action pairs, /r/ { action } and $0 ~ /r/ { action } are the same, and for each input record that matches r, action is exe- cuted. In fact, /r/ is an AWK expression that is equivalent to ($0 ~ /r/) anywhere except when on the right side of a match operator or passed as an argument to a built-in function that expects a regular ex- pression argument. AWK uses extended regular expressions as with the -E option of grep(1). The regular expression metacharacters, i.e., those with special meaning in regular expressions are \ ^ $ . [ ] | ( ) * + ? { } If the command line option -W traditional is used, these are omitted: { } are also regular expression metacharacters, and in this mode, require escaping to be a literal character. Regular expressions are built up from characters as follows: c matches any non-metacharacter c. \c matches a character defined by the same escape se- quences used in string constants or the literal char- acter c if \c is not an escape sequence. . matches any character (including newline). ^ matches the front of a string. $ matches the back of a string. [c1c2c3...] matches any character in the class c1c2c3... . An interval of characters is denoted c1-c2 inside a class [...]. [^c1c2c3...] matches any character not in the class c1c2c3... Regular expressions are built up from other regular expressions as fol- lows: r1r2 matches r1 followed immediately by r2 (concatena- tion). r1 | r2 matches r1 or r2 (alternation). r* matches r repeated zero or more times. r+ matches r repeated one or more times. r? matches r zero or once. (repetition). (r) matches r (grouping). r{n} matches r exactly n times. r{n,} matches r repeated n or more times. r{n,m} matches r repeated n to m (inclusive) times. r{,m} matches r repeated 0 to m times (a non-standard op- tion). The increasing precedence of operators is: alternation concatenation repetition grouping For example, /^[_a-zA-Z][_a-zA-Z0-9]*$/ and /^[-+]?([0-9]+\.?|\.[0-9])[0-9]*([eE][-+]?[0-9]+)?$/ are matched by AWK identifiers and AWK numeric constants respectively. Note that "." has to be escaped to be recognized as a decimal point, and that metacharacters are not special inside character classes. Any expression can be used on the right hand side of the ~ or !~ opera- tors or passed to a built-in that expects a regular expression. If needed, it is converted to string, and then interpreted as a regular expression. For example, BEGIN { identifier = "[_a-zA-Z][_a-zA-Z0-9]*" } $0 ~ "^" identifier prints all lines that start with an AWK identifier. mawk recognizes the empty regular expression, //, which matches the empty string and hence is matched by any string at the front, back and between every character. For example, echo abc | mawk '{ gsub(//, "X")' ; print } XaXbXcX 4. Records and fields Records are read in one at a time, and stored in the field variable $0. The record is split into fields which are stored in $1, $2, ..., $NF. The built-in variable NF is set to the number of fields, and NR and FNR are incremented by 1. Fields above $NF are set to "". Assignment to $0 causes the fields and NF to be recomputed. Assignment to NF or to a field causes $0 to be reconstructed by concatenating the $i's separated by OFS. Assignment to a field with index greater than NF, increases NF and causes $0 to be reconstructed. Data input stored in fields is string, unless the entire field has nu- meric form and then the type is number and string. For example, echo 24 24E | mawk '{ print($1>100, $1>"100", $2>100, $2>"100") }' 0 1 1 1 $0 and $2 are string and $1 is number and string. The first comparison is numeric, the second is string, the third is string (100 is converted to "100"), and the last is string. 5. Expressions and operators The expression syntax is similar to C. Primary expressions are numeric constants, string constants, variables, fields, arrays and function calls. The identifier for a variable, array or function can be a se- quence of letters, digits and underscores, that does not start with a digit. Variables are not declared; they exist when first referenced and are initialized to null. New expressions are composed with the following operators in order of increasing precedence. assignment = += -= *= /= %= ^= conditional ? : logical or || logical and && array membership in matching ~ !~ relational < > <= >= == != concatenation (no explicit operator) add ops + - mul ops * / % unary + - logical not ! exponentiation ^ inc and dec ++ -- (both post and pre) field $ Assignment, conditional and exponentiation associate right to left; the other operators associate left to right. Any expression can be paren- thesized. 6. Arrays Awk provides one-dimensional arrays. Array elements are expressed as array[expr]. Expr is internally converted to string type, so, for ex- ample, A[1] and A["1"] are the same element and the actual index is "1". Arrays indexed by strings are called associative arrays. Ini- tially an array is empty; elements exist when first accessed. An ex- pression, expr in array evaluates to 1 if array[expr] exists, else to 0. There is a form of the for statement that loops over each index of an array. for ( var in array ) statement sets var to each index of array and executes statement. The order that var transverses the indices of array is not defined. The statement, delete array[expr], causes array[expr] not to exist. mawk supports the delete array feature, which deletes all elements of array. Multidimensional arrays are synthesized with concatenation using the built-in variable SUBSEP. array[expr1,expr2] is equivalent to ar- ray[expr1 SUBSEP expr2]. Testing for a multidimensional element uses a parenthesized index, such as if ( (i, j) in A ) print A[i, j] 7. Builtin-variables The following variables are built-in and initialized before program ex- ecution. ARGC number of command line arguments. ARGV array of command line arguments, 0..ARGC-1. CONVFMT format for internal conversion of numbers to string, ini- tially = "%.6g". ENVIRON array indexed by environment variables. An environment string, var=value is stored as ENVIRON[var] = value. FILENAME name of the current input file. FNR current record number in FILENAME. FS splits records into fields as a regular expression. NF number of fields in the current record. NR current record number in the total input stream. OFMT format for printing numbers; initially = "%.6g". OFS inserted between fields on output, initially = " ". ORS terminates each record on output, initially = "\n". RLENGTH length set by the last call to the built-in function, match(). RS input record separator, initially = "\n". RSTART index set by the last call to match(). SUBSEP used to build multiple array subscripts, initially = "\034". 8. Built-in functions String functions gsub(r,s,t) gsub(r,s) Global substitution, every match of regular expression r in variable t is replaced by string s. The number of replace- ments is returned. If t is omitted, $0 is used. An & in the replacement string s is replaced by the matched sub- string of t. \& and \\ put literal & and \, respectively, in the replacement string. index(s,t) If t is a substring of s, then the position where t starts is returned, else 0 is returned. The first character of s is in position 1. length(s) Returns the length of string or array s. match(s,r) Returns the index of the first longest match of regular ex- pression r in string s. Returns 0 if no match. As a side effect, RSTART is set to the return value. RLENGTH is set to the length of the match or -1 if no match. If the empty string is matched, RLENGTH is set to 0, and 1 is returned if the match is at the front, and length(s)+1 is returned if the match is at the back. split(s,A,r) split(s,A) String s is split into fields by regular expression r and the fields are loaded into array A. The number of fields is returned. See section 11 below for more detail. If r is omitted, FS is used. sprintf(format,expr-list) Returns a string constructed from expr-list according to format. See the description of printf() below. sub(r,s,t) sub(r,s) Single substitution, same as gsub() except at most one sub- stitution. substr(s,i,n) substr(s,i) Returns the substring of string s, starting at index i, of length n. If n is omitted, the suffix of s, starting at i is returned. tolower(s) Returns a copy of s with all upper case characters con- verted to lower case. toupper(s) Returns a copy of s with all lower case characters con- verted to upper case. Time functions These are available on systems which support the corresponding C mktime and strftime functions: mktime(specification) converts a date specification to a timestamp with the same units as systime. The date specification is a string con- taining the components of the date as decimal integers: YYYY the year, e.g., 2012 MM the month of the year starting at 1 DD the day of the month starting at 1 HH hour (0-23) MM minute (0-59) SS seconds (0-59) DST tells how to treat timezone versus daylight savings time: positive DST is in effect zero (default) DST is not in effect negative mktime() should (use timezone information and sys- tem databases to) attempt to determine whether DST is in effect at the specified time. strftime([format [, timestamp [, utc ]]]) formats the given timestamp using the format (passed to the C strftime function): o If the format parameter is missing, "%c" is used. o If the timestamp parameter is missing, the current value from systime is used. o If the utc parameter is present and nonzero, the result is in UTC. Otherwise local time is used. systime() returns the current time of day as the number of seconds since the Epoch (1970-01-01 00:00:00 UTC on POSIX systems). Arithmetic functions atan2(y,x) Arctan of y/x between -pi and pi. cos(x) Cosine function, x in radians. exp(x) Exponential function. int(x) Returns x truncated towards zero. log(x) Natural logarithm. rand() Returns a random number between zero and one. sin(x) Sine function, x in radians. sqrt(x) Returns square root of x. srand(expr) srand() Seeds the random number generator, using the clock if expr is omitted, and returns the value of the previous seed. Srand(expr) is useful for repeating pseudo random se- quences. Note: mawk is normally configured to seed the random number generator from the clock at startup, making it unnecessary to call srand(). This feature can be suppressed via condi- tional compile, or overridden using the -Wrandom option. 9. Input and output There are two output statements, print and printf. print writes $0 ORS to standard output. print expr1, expr2, ..., exprn writes expr1 OFS expr2 OFS ... exprn ORS to standard out- put. Numeric expressions are converted to string with OFMT. printf format, expr-list duplicates the printf C library function writing to stan- dard output. The complete ANSI C format specifications are recognized with conversions %c, %d, %e, %E, %f, %g, %G, %i, %o, %s, %u, %x, %X and %%, and conversion qualifiers h and l. The argument list to print or printf can optionally be enclosed in parentheses. Print formats numbers using OFMT or "%d" for exact inte- gers. "%c" with a numeric argument prints the corresponding 8 bit character, with a string argument it prints the first character of the string. The output of print and printf can be redirected to a file or command by appending > file, >> file or | command to the end of the print statement. Redirection opens file or command only once, subse- quent redirections append to the already open stream. By convention, mawk associates the filename o "/dev/stderr" with stderr, o "/dev/stdout" with stdout, o "-" and "/dev/stdin" with stdin. The association with stderr is especially useful because it allows print and printf to be redirected to stderr. These names can also be passed to functions. The input function getline has the following variations. getline reads into $0, updates the fields, NF, NR and FNR. getline < file reads into $0 from file, updates the fields and NF. getline var reads the next record into var, updates NR and FNR. getline var < file reads the next record of file into var. command | getline pipes a record from command into $0 and updates the fields and NF. command | getline var pipes a record from command into var. Getline returns 0 on end-of-file, -1 on error, otherwise 1. Commands on the end of pipes are executed by /bin/sh. The function close(expr) closes the file or pipe associated with expr. Close returns 0 if expr is an open file, the exit status if expr is a piped command, and -1 otherwise. Close is used to reread a file or command, make sure the other end of an output pipe is finished or con- serve file resources. The function fflush(expr) flushes the output file or pipe associated with expr. Fflush returns 0 if expr is an open output stream else -1. Fflush without an argument flushes stdout. Fflush with an empty argu- ment ("") flushes all open output. The function system(expr) uses the C runtime system call to execute expr and returns the corresponding wait status of the command as fol- lows: o if the system call failed, setting the status to -1, mawk returns that value. o if the command exited normally, mawk returns its exit-status. o if the command exited due to a signal such as SIGHUP, mawk returns the signal number plus 256. Changes made to the ENVIRON array are not passed to commands executed with system or pipes. 10. User defined functions The syntax for a user defined function is function name( args ) { statements } The function body can contain a return statement return opt_expr A return statement is not required. Function calls may be nested or recursive. Functions are passed expressions by value and arrays by reference. Extra arguments serve as local variables and are initial- ized to null. For example, csplit(s,A) puts each character of s into array A and returns the length of s. function csplit(s, A, n, i) { n = length(s) for( i = 1 ; i <= n ; i++ ) A[i] = substr(s, i, 1) return n } Putting extra space between passed arguments and local variables is conventional. Functions can be referenced before they are defined, but the function name and the '(' of the arguments must touch to avoid con- fusion with concatenation. A function parameter is normally a scalar value (number or string). If there is a forward reference to a function using an array as a parame- ter, the function's corresponding parameter will be treated as an ar- ray. 11. Splitting strings, records and files Awk programs use the same algorithm to split strings into arrays with split(), and records into fields on FS. mawk uses essentially the same algorithm to split files into records on RS. Split(expr,A,sep) works as follows: (1) If sep is omitted, it is replaced by FS. Sep can be an expres- sion or regular expression. If it is an expression of non- string type, it is converted to string. (2) If sep = " " (a single space), then is trimmed from the front and back of expr, and sep becomes . mawk defines as the regular expression /[ \t\n]+/. Otherwise sep is treated as a regular expression, except that meta-characters are ignored for a string of length 1, e.g., split(x, A, "*") and split(x, A, /\*/) are the same. (3) If expr is not string, it is converted to string. If expr is then the empty string "", split() returns 0 and A is set empty. Otherwise, all non-overlapping, non-null and longest matches of sep in expr, separate expr into fields which are loaded into A. The fields are placed in A[1], A[2], ..., A[n] and split() re- turns n, the number of fields which is the number of matches plus one. Data placed in A that looks numeric is typed number and string. Splitting records into fields works the same except the pieces are loaded into $1, $2,..., $NF. If $0 is empty, NF is set to 0 and all $i to "". mawk splits files into records by the same algorithm, but with the slight difference that RS is really a terminator instead of a separa- tor. (ORS is really a terminator too). E.g., if FS = ":+" and $0 = "a::b:" , then NF = 3 and $1 = "a", $2 = "b" and $3 = "", but if "a::b:" is the contents of an input file and RS = ":+", then there are two records "a" and "b". RS = " " is not special. If FS = "", then mawk breaks the record into individual characters, and, similarly, split(s,A,"") places the individual characters of s into A. 12. Multi-line records Since mawk interprets RS as a regular expression, multi-line records are easy. Setting RS = "\n\n+", makes one or more blank lines separate records. If FS = " " (the default), then single newlines, by the rules for above, become space and single newlines are field separa- tors. For example, if o a file is "a b\nc\n\n", o RS = "\n\n+" and o FS = " ", then there is one record "a b\nc" with three fields "a", "b" and "c": o using FS = "\n", gives two fields "a b" and "c"; o using FS = "", gives one field identical to the record. If you want lines with spaces or tabs to be considered blank, set RS = "\n([ \t]*\n)+". For compatibility with other awks, setting RS = "" has the same effect as if blank lines are stripped from the front and back of files and then records are determined as if RS = "\n\n+". POSIX requires that "\n" always separates records when RS = "" regard- less of the value of FS. mawk does not support this convention, be- cause defining "\n" as makes it unnecessary. Most of the time when you change RS for multi-line records, you will also want to change ORS to "\n\n" so the record spacing is preserved on output. 13. Program execution This section describes the order of program execution. First ARGC is set to the total number of command line arguments passed to the execu- tion phase of the program. o ARGV[0] is set to the name of the AWK interpreter and o ARGV[1] ... ARGV[ARGC-1] holds the remaining command line argu- ments exclusive of options and program source. For example, with mawk -f prog v=1 A t=hello B ARGC = 5 with ARGV[0] = "mawk", ARGV[1] = "v=1", ARGV[2] = "A", ARGV[3] = "t=hello" and ARGV[4] = "B". Next, each BEGIN block is executed in order. If the program consists entirely of BEGIN blocks, then execution terminates, else an input stream is opened and execution continues. If ARGC equals 1, the input stream is set to stdin, else the command line arguments ARGV[1] ... ARGV[ARGC-1] are examined for a file argument. The command line arguments divide into three sets: file arguments, as- signment arguments and empty strings "". An assignment has the form var=string. When an ARGV[i] is examined as a possible file argument, if it is empty it is skipped; if it is an assignment argument, the as- signment to var takes place and i skips to the next argument; else ARGV[i] is opened for input. If it fails to open, execution terminates with exit code 2. If no command line argument is a file argument, then input comes from stdin. Getline in a BEGIN action opens input. "-" as a file argument denotes stdin. Once an input stream is open, each input record is tested against each pattern, and if it matches, the associated action is executed. An ex- pression pattern matches if it is boolean true (see the end of section 2). A BEGIN pattern matches before any input has been read, and an END pattern matches after all input has been read. A range pattern, expr1,expr2 , matches every record between the match of expr1 and the match expr2 inclusively. When end of file occurs on the input stream, the remaining command line arguments are examined for a file argument, and if there is one it is opened, else the END pattern is considered matched and all END actions are executed. In the example, the assignment v=1 takes place after the BEGIN actions are executed, and the data placed in v is typed number and string. In- put is then read from file A. On end of file A, t is set to the string "hello", and B is opened for input. On end of file B, the END actions are executed. Program flow at the pattern {action} level can be changed with the next nextfile exit opt_expr statements: o A next statement causes the next input record to be read and pat- tern testing to restart with the first pattern {action} pair in the program. o A nextfile statement tells mawk to stop processing the current in- put file. It then updates FILENAME to the next file listed on the command line, and resets FNR to 1. o An exit statement causes immediate execution of the END actions or program termination if there are none or if the exit occurs in an END action. The opt_expr sets the exit value of the program unless overridden by a later exit or subsequent error. ENVIRONMENT Mawk recognizes these variables: MAWKBINMODE (see COMPATIBILITY) MAWK_LONG_OPTIONS If this is set, mawk uses its value to decide what to do with GNU-style long options: allow Mawk allows the option to be checked against the (small) set of long options it recognizes. The long names from the -W option are recognized, e.g., --version is derived from -Wversion. error Mawk prints an error message and exits. This is the de- fault. ignore Mawk ignores the option, unless it happens to be one of the one it recognizes. warn Print an warning message and otherwise ignore the op- tion. If the variable is unset, mawk prints an error message and exits. WHINY_USERS This is a gawk 3.1.0 feature, removed in the 4.0.0 release. It tells mawk to sort array indices before it starts to iterate over the elements of an array. COMPATIBILITY MAWK 1.3.3 versus POSIX 1003.2 Draft 11.3 The POSIX 1003.2(draft 11.3) definition of the AWK language is AWK as described in the AWK book with a few extensions that appeared in Sys- temVR4 nawk. The extensions are: o New functions: toupper() and tolower(). o New variables: ENVIRON[] and CONVFMT. o ANSI C conversion specifications for printf() and sprintf(). o New command options: -v var=value, multiple -f options and im- plementation options as arguments to -W. o For systems (MS-DOS or Windows) which provide a setmode func- tion, an environment variable MAWKBINMODE and a built-in vari- able BINMODE. The bits of the BINMODE value tell mawk how to modify the RS and ORS variables: 0 set standard input to binary mode, and if BIT-2 is unset, set RS to "\r\n" (CR/LF) rather than "\n" (LF). 1 set standard output to binary mode, and if BIT-2 is unset, set ORS to "\r\n" (CR/LF) rather than "\n" (LF). 2 suppress the assignment to RS and ORS of CR/LF, making it possible to run scripts and generate output compatible with Unix line-endings. POSIX AWK is oriented to operate on files a line at a time. RS can be changed from "\n" to another single character, but it is hard to find any use for this -- there are no examples in the AWK book. By conven- tion, RS = "", makes one or more blank lines separate records, allowing multi-line records. When RS = "", "\n" is always a field separator re- gardless of the value in FS. mawk, on the other hand, allows RS to be a regular expression. When "\n" appears in records, it is treated as space, and FS always deter- mines fields. Removing the line at a time paradigm can make some programs simpler and can often improve performance. For example, redoing example 3 from above, BEGIN { RS = "[^A-Za-z]+" } { word[ $0 ] = "" } END { delete word[ "" ] for( i in word ) cnt++ print cnt } counts the number of unique words by making each word a record. On moderate size files, mawk executes twice as fast, because of the sim- plified inner loop. The following program replaces each comment by a single space in a C program file, BEGIN { RS = "/\*([^*]|\*+[^/*])*\*+/" # comment is record separator ORS = " " getline hold } { print hold ; hold = $0 } END { printf "%s" , hold } Buffering one record is needed to avoid terminating the last record with a space. With mawk, the following are all equivalent, x ~ /a\+b/ x ~ "a\+b" x ~ "a\\+b" The strings get scanned twice, once as string and once as regular ex- pression. On the string scan, mawk ignores the escape on non-escape characters while the AWK book advocates \c be recognized as c which ne- cessitates the double escaping of meta-characters in strings. POSIX explicitly declines to define the behavior which passively forces pro- grams that must run under a variety of awks to use the more portable but less readable, double escape. POSIX AWK does not recognize "/dev/std{in,out,err}". Some systems pro- vide an actual device for this, allowing AWKs which do not implement the feature directly to support it. POSIX AWK does not recognize \x hex escape sequences in strings. Un- like ANSI C, mawk limits the number of digits that follows \x to two as the current implementation only supports 8 bit characters. POSIX explicitly leaves the behavior of FS = "" undefined, and mentions splitting the record into characters as a possible interpretation, but currently this use is not portable across implementations. Some features were not part of the POSIX standard until long after their introduction in mawk and other implementations. These have been approved, though still (as of July 2020), are not part of a published standard: o The built-in fflush first appeared in a 1993 AT&T awk released to netlib. It was approved for the POSIX standard in 2012. o Aggregate deletion with delete array was approved in 2018. Random numbers POSIX does not prescribe a method for initializing random numbers at startup. In practice, most implementations do nothing special, which makes srand and rand follow the C runtime library, making the initial seed value 1. Some implementations (Solaris XPG4 and Tru64) return 0 from the first call to srand, although the results from rand behave as if the initial seed is 1. Other implementations return 1. While mawk can call srand at startup with no parameter (initializing random numbers from the clock), this feature may be suppressed using conditional compilation. Extensions added for compatibility for GAWK and BWK Nextfile is a gawk extension (also implemented by BWK awk). It was ap- proved for the POSIX standard in September 2012, and is expected to be part of the next revision of the standard. Mktime, strftime and systime are gawk extensions. The "/dev/stdin" feature was added to mawk after 1.3.4, for compatibil- ity with gawk and BWK awk. The corresponding "-" (alias for /dev/stdin) was present in mawk 1.3.3. Interval expressions, e.g., a range {m,n} in Extended Regular Expres- sions (EREs), were not supported in awk (or even the original "nawk"): o Gawk provided this feature in 1991 (and later, in 1998, options for turning it off, for compatibility with "traditional awk"). o Interval expressions, were introduced into awk regular expressions in IEEE 1003.1-2001 (also known as Unix 03), along with some inter- nationalization features. o Apple modified its copy of the original awk in April 2006, making this version of awk support interval expressions. The updated source provides for compatibility with older "legacy" versions using an environment variable, making this "Unix 2003" feature (perhaps meant as Unix 03) the default. o NetBSD developers copied this change in January 2018, omitting the compatibility option, and then applied it to BWK awk. o The interval expression implementation in mawk is based on changes proposed by James Parkinson in April 2016. Mawk also recognizes a few gawk-specific command line options for script compatibility: --help, --posix, -r, --re-interval, --traditional, --version Subtle Differences not in POSIX or the AWK Book Finally, here is how mawk handles exceptional cases not discussed in the AWK book or the POSIX draft. It is unsafe to assume consistency across awks and safe to skip to the next section. o substr(s, i, n) returns the characters of s in the intersection of the closed interval [1, length(s)] and the half-open interval [i, i+n). When this intersection is empty, the empty string is returned; so substr("ABC", 1, 0) = "" and substr("ABC", -4, 6) = "A". o Every string, including the empty string, matches the empty string at the front so, s ~ // and s ~ "", are always 1 as is match(s, //) and match(s, ""). The last two set RLENGTH to 0. o index(s, t) is always the same as match(s, t1) where t1 is the same as t with metacharacters escaped. Hence consistency with match requires that index(s, "") always returns 1. Also the condition, index(s,t) != 0 if and only t is a substring of s, requires index("","") = 1. o If getline encounters end of file, getline var, leaves var un- changed. Similarly, on entry to the END actions, $0, the fields and NF have their value unaltered from the last record. BUGS mawk implements printf() and sprintf() using the C library functions, printf and sprintf, so full ANSI compatibility requires an ANSI C li- brary. In practice this means the h conversion qualifier may not be available. Also mawk inherits any bugs or limitations of the library functions. Implementors of the AWK language have shown a consistent lack of imagi- nation when naming their programs. EXAMPLES 1. emulate cat. { print } 2. emulate wc. { chars += length($0) + 1 # add one for the \n words += NF } END{ print NR, words, chars } 3. count the number of unique "real words". BEGIN { FS = "[^A-Za-z]+" } { for(i = 1 ; i <= NF ; i++) word[$i] = "" } END { delete word[""] for ( i in word ) cnt++ print cnt } 4. sum the second field of every record based on the first field. $1 ~ /credit|gain/ { sum += $2 } $1 ~ /debit|loss/ { sum -= $2 } END { print sum } 5. sort a file, comparing as string { line[NR] = $0 "" } # make sure of comparison type # in case some lines look numeric END { isort(line, NR) for(i = 1 ; i <= NR ; i++) print line[i] } #insertion sort of A[1..n] function isort( A, n, i, j, hold) { for( i = 2 ; i <= n ; i++) { hold = A[j = i] while ( A[j-1] > hold ) { j-- ; A[j+1] = A[j] } A[j] = hold } # sentinel A[0] = "" will be created if needed } AUTHORS Mike Brennan (brennan@whidbey.com). Thomas E. Dickey . SEE ALSO grep(1) Aho, Kernighan and Weinberger, The AWK Programming Language, Addison- Wesley Publishing, 1988, (the AWK book), defines the language, opening with a tutorial and advancing to many interesting programs that delve into issues of software design and analysis relevant to programming in any language. The GAWK Manual, The Free Software Foundation, 1991, is a tutorial and language reference that does not attempt the depth of the AWK book and assumes the reader may be a novice programmer. The section on AWK ar- rays is excellent. It also discusses POSIX requirements for AWK. mawk-arrays(7) discusses mawk's implementation of arrays. mawk-code(7) gives more information on the -W dump option. Version 1.3.4 2024-01-23 MAWK(1) mawk-1.3.4-20240123/man/mawk.doc0000644000000000000000000015647714554045065014304 0ustar rootrootMAWK(1) User commands MAWK(1) NNAAMMEE mawk - pattern scanning and text processing language SSYYNNOOPPSSIISS mmaawwkk [-WW _o_p_t_i_o_n] [-FF _v_a_l_u_e] [-vv _v_a_r_=_v_a_l_u_e] [--] 'program text' [file ...] mmaawwkk [-WW _o_p_t_i_o_n] [-FF _v_a_l_u_e] [-vv _v_a_r_=_v_a_l_u_e] [-ff _p_r_o_g_r_a_m_-_f_i_l_e] [--] [file ...] DDEESSCCRRIIPPTTIIOONN mmaawwkk is an interpreter for the AWK Programming Language. The AWK lan- guage is useful for manipulation of data files, text retrieval and pro- cessing, and for prototyping and experimenting with algorithms. mmaawwkk is a _n_e_w _a_w_k meaning it implements the AWK language as defined in Aho, Kernighan and Weinberger, _T_h_e _A_W_K _P_r_o_g_r_a_m_m_i_n_g _L_a_n_g_u_a_g_e_, Addison-Wesley Publishing, 1988 (hereafter referred to as the AWK book.) mmaawwkk con- forms to the POSIX 1003.2 (draft 11.3) definition of the AWK language which contains a few features not described in the AWK book, and mmaawwkk provides a small number of extensions. An AWK program is a sequence of _p_a_t_t_e_r_n _{_a_c_t_i_o_n_} pairs and function definitions. Short programs are entered on the command line usually enclosed in ' ' to avoid shell interpretation. Longer programs can be read in from a file with the -f option. Data input is read from the list of files on the command line or from standard input when the list is empty. The input is broken into records as determined by the record separator variable, RRSS. Initially, RRSS = "\n" and records are synony- mous with lines. Each record is compared against each _p_a_t_t_e_r_n and if it matches, the program text for _{_a_c_t_i_o_n_} is executed. OOPPTTIIOONNSS -FF _v_a_l_u_e sets the field separator, FFSS, to _v_a_l_u_e. -ff _f_i_l_e Program text is read from _f_i_l_e instead of from the com- mand line. Multiple --ff options are allowed. -vv _v_a_r_=_v_a_l_u_e assigns _v_a_l_u_e to program variable _v_a_r. -- indicates the unambiguous end of options. The above options will be available with any POSIX compatible implemen- tation of AWK. Implementation specific options are prefaced with --WW. mmaawwkk provides these: -WW dump writes an assembler like listing of the internal representation of the program to stdout and exits 0 (on successful compila- tion). -WW exec _f_i_l_e Program text is read from _f_i_l_e and this is the last option. This is a useful alternative to -ff on systems that support the ##!! "magic number" convention for executable scripts. Those im- plicitly pass the pathname of the script itself as the final pa- rameter, and expect no more than one "-" option on the ##!! line. Because mmaawwkk can combine multiple -WW options separated by com- mas, you can use this option when an additional -WW option is needed. -WW help prints a usage message to stderr and exits (same as "-WW usage"). -WW interactive sets unbuffered writes to stdout and line buffered reads from stdin. Records from stdin are lines regardless of the value of RRSS. -WW posix modifies mmaawwkk's behavior to be more POSIX-compliant: +o forces mmaawwkk not to consider '\n' to be space. The original "posix_space" is recognized, but deprecated. -WW random=_n_u_m calls ssrraanndd with the given parameter (and overrides the auto- seeding behavior). -WW sprintf=_n_u_m adjusts the size of mmaawwkk's internal sprintf buffer to _n_u_m bytes. More than rare use of this option indicates mmaawwkk should be re- compiled. -WW traditional Omit features such as interval expressions which were not sup- ported by traditional _a_w_k. -WW usage prints a usage message to stderr and exits (same as "-WW help"). -WW version mmaawwkk writes its version and copyright to stdout and compiled limits to stderr and exits 0. mmaawwkk accepts abbreviations for any of these options, e.g., "-WW v" and "-WWv" both tell mmaawwkk to show its version. mmaawwkk allows multiple --WW options to be combined by separating the op- tions with commas, e.g., -Wsprint=2000,posix. This is useful for exe- cutable ##!! "magic number" invocations in which only one argument is supported, e.g., -WWiinntteerraaccttiivvee,,eexxeecc. TTHHEE AAWWKK LLAANNGGUUAAGGEE 11.. PPrrooggrraamm ssttrruuccttuurree An AWK program is a sequence of _p_a_t_t_e_r_n _{_a_c_t_i_o_n_} pairs and user func- tion definitions. A pattern can be: BBEEGGIINN EENNDD expression expression , expression One, but not both, of _p_a_t_t_e_r_n _{_a_c_t_i_o_n_} can be omitted. If _{_a_c_t_i_o_n_} is omitted it is implicitly { print }. If _p_a_t_t_e_r_n is omitted, then it is implicitly matched. BBEEGGIINN and EENNDD patterns require an action. Statements are terminated by newlines, semi-colons or both. Groups of statements such as actions or loop bodies are blocked via { ... } as in C. The last statement in a block doesn't need a terminator. Blank lines have no meaning; an empty statement is terminated with a semi- colon. Long statements can be continued with a backslash, \. A state- ment can be broken without a backslash after a comma, left brace, &&, ||, ddoo, eellssee, the right parenthesis of an iiff, wwhhiillee or ffoorr statement, and the right parenthesis of a function definition. A comment starts with # and extends to, but does not include the end of line. The following statements control program flow inside blocks. iiff ( _e_x_p_r ) _s_t_a_t_e_m_e_n_t iiff ( _e_x_p_r ) _s_t_a_t_e_m_e_n_t eellssee _s_t_a_t_e_m_e_n_t wwhhiillee ( _e_x_p_r ) _s_t_a_t_e_m_e_n_t ddoo _s_t_a_t_e_m_e_n_t wwhhiillee ( _e_x_p_r ) ffoorr ( _o_p_t___e_x_p_r ; _o_p_t___e_x_p_r ; _o_p_t___e_x_p_r ) _s_t_a_t_e_m_e_n_t ffoorr ( _v_a_r iinn _a_r_r_a_y ) _s_t_a_t_e_m_e_n_t ccoonnttiinnuuee bbrreeaakk 22.. DDaattaa ttyyppeess,, ccoonnvveerrssiioonn aanndd ccoommppaarriissoonn There are two basic data types, numeric and string. Numeric constants can be integer like -2, decimal like 1.08, or in scientific notation like -1.1e4 or .28E-3. All numbers are represented internally and all computations are done in floating point arithmetic. So for example, the expression 0.2e2 == 20 is true and true is represented as 1.0. String constants are enclosed in double quotes. "This is a string with a newline at the end.\n" Strings can be continued across a line by escaping (\) the newline. The following escape sequences are recognized. \\ \ \" " \a alert, ascii 7 \b backspace, ascii 8 \t tab, ascii 9 \n newline, ascii 10 \v vertical tab, ascii 11 \f formfeed, ascii 12 \r carriage return, ascii 13 \ddd 1, 2 or 3 octal digits for ascii ddd \xhh 1 or 2 hex digits for ascii hh If you escape any other character \c, you get \c, i.e., mmaawwkk ignores the escape. There are really three basic data types; the third is _n_u_m_b_e_r _a_n_d _s_t_r_i_n_g which has both a numeric value and a string value at the same time. User defined variables come into existence when first referenced and are initialized to _n_u_l_l, a number and string value which has numeric value 0 and string value "". Non-trivial number and string typed data come from input and are typically stored in fields. (See section 4). The type of an expression is determined by its context and automatic type conversion occurs if needed. For example, to evaluate the state- ments y = x + 2 ; z = x "hello" The value stored in variable y will be typed numeric. If x is not nu- meric, the value read from x is converted to numeric before it is added to 2 and stored in y. The value stored in variable z will be typed string, and the value of x will be converted to string if necessary and concatenated with "hello". (Of course, the value and type stored in x is not changed by any conversions.) A string expression is converted to numeric using its longest numeric prefix as with aattooff(3). A numeric expression is converted to string by replacing _e_x_p_r with sspprriinnttff((CCOONN-- VVFFMMTT, _e_x_p_r), unless _e_x_p_r can be represented on the host machine as an exact integer then it is converted to sspprriinnttff("%d", _e_x_p_r). SSpprriinnttff(()) is an AWK built-in that duplicates the functionality of sspprriinnttff(3), and CCOONNVVFFMMTT is a built-in variable used for internal conversion from number to string and initialized to "%.6g". Explicit type conversions can be forced, _e_x_p_r "" is string and _e_x_p_r+0 is numeric. To evaluate, _e_x_p_r1 rreell--oopp _e_x_p_r2, if both operands are numeric or number and string then the comparison is numeric; if both operands are string the comparison is string; if one operand is string, the non-string op- erand is converted and the comparison is string. The result is nu- meric, 1 or 0. In boolean contexts such as, iiff ( _e_x_p_r ) _s_t_a_t_e_m_e_n_t, a string expression evaluates true if and only if it is not the empty string ""; numeric values if and only if not numerically zero. 33.. RReegguullaarr eexxpprreessssiioonnss In the AWK language, records, fields and strings are often tested for matching a _r_e_g_u_l_a_r _e_x_p_r_e_s_s_i_o_n. Regular expressions are enclosed in slashes, and _e_x_p_r ~ /_r/ is an AWK expression that evaluates to 1 if _e_x_p_r "matches" _r, which means a substring of _e_x_p_r is in the set of strings defined by _r. With no match the expression evaluates to 0; replacing ~ with the "not match" operator, !~ , reverses the meaning. As pattern-action pairs, /_r/ { _a_c_t_i_o_n } and $$00 ~ /_r/ { _a_c_t_i_o_n } are the same, and for each input record that matches _r, _a_c_t_i_o_n is exe- cuted. In fact, /_r/ is an AWK expression that is equivalent to ($$00 ~ /_r/) anywhere except when on the right side of a match operator or passed as an argument to a built-in function that expects a regular ex- pression argument. AWK uses extended regular expressions as with the --EE option of ggrreepp(1). The regular expression metacharacters, i.e., those with special meaning in regular expressions are \ ^ $ . [ ] | ( ) * + ? { } If the command line option _-_W _t_r_a_d_i_t_i_o_n_a_l is used, these are omitted: { } are also regular expression metacharacters, and in this mode, require escaping to be a literal character. Regular expressions are built up from characters as follows: _c matches any non-metacharacter _c. \_c matches a character defined by the same escape se- quences used in string constants or the literal char- acter _c if \_c is not an escape sequence. . matches any character (including newline). ^ matches the front of a string. $ matches the back of a string. [c1c2c3...] matches any character in the class c1c2c3... . An interval of characters is denoted c1-c2 inside a class [...]. [^c1c2c3...] matches any character not in the class c1c2c3... Regular expressions are built up from other regular expressions as fol- lows: _r1_r2 matches _r1 followed immediately by _r2 (_c_o_n_c_a_t_e_n_a_- _t_i_o_n). _r1 | _r2 matches _r1 or _r2 (_a_l_t_e_r_n_a_t_i_o_n). _r* matches _r repeated zero or more times. _r+ matches _r repeated one or more times. _r? matches _r zero or once. (_r_e_p_e_t_i_t_i_o_n). (_r) matches _r (_g_r_o_u_p_i_n_g). _r{n} matches _r exactly n times. _r{n,} matches _r repeated n or more times. _r{n,m} matches _r repeated n to m (inclusive) times. _r{,m} matches _r repeated 0 to m times (a non-standard op- tion). The increasing pprreecceeddeennccee ooff ooppeerraattoorrss is: alternation concatenation repetition grouping For example, /^[_a-zA-Z][_a-zA-Z0-9]*$/ and /^[-+]?([0-9]+\.?|\.[0-9])[0-9]*([eE][-+]?[0-9]+)?$/ are matched by AWK identifiers and AWK numeric constants respectively. Note that "." has to be escaped to be recognized as a decimal point, and that metacharacters are not special inside character classes. Any expression can be used on the right hand side of the ~ or !~ opera- tors or passed to a built-in that expects a regular expression. If needed, it is converted to string, and then interpreted as a regular expression. For example, BEGIN { identifier = "[_a-zA-Z][_a-zA-Z0-9]*" } $0 ~ "^" identifier prints all lines that start with an AWK identifier. mmaawwkk recognizes the empty regular expression, //, which matches the empty string and hence is matched by any string at the front, back and between every character. For example, echo abc | mawk '{ gsub(//, "X")' ; print } XaXbXcX 44.. RReeccoorrddss aanndd ffiieellddss Records are read in one at a time, and stored in the _f_i_e_l_d variable $$00. The record is split into _f_i_e_l_d_s which are stored in $$11, $$22, ..., $$NNFF. The built-in variable NNFF is set to the number of fields, and NNRR and FFNNRR are incremented by 1. Fields above $$NNFF are set to "". Assignment to $$00 causes the fields and NNFF to be recomputed. Assignment to NNFF or to a field causes $$00 to be reconstructed by concatenating the $$ii''ss separated by OOFFSS. Assignment to a field with index greater than NNFF, increases NNFF and causes $$00 to be reconstructed. Data input stored in fields is string, unless the entire field has nu- meric form and then the type is number and string. For example, echo 24 24E | mawk '{ print($1>100, $1>"100", $2>100, $2>"100") }' 0 1 1 1 $$00 and $$22 are string and $$11 is number and string. The first comparison is numeric, the second is string, the third is string (100 is converted to "100"), and the last is string. 55.. EExxpprreessssiioonnss aanndd ooppeerraattoorrss The expression syntax is similar to C. Primary expressions are numeric constants, string constants, variables, fields, arrays and function calls. The identifier for a variable, array or function can be a se- quence of letters, digits and underscores, that does not start with a digit. Variables are not declared; they exist when first referenced and are initialized to _n_u_l_l. New expressions are composed with the following operators in order of increasing precedence. _a_s_s_i_g_n_m_e_n_t = += -= *= /= %= ^= _c_o_n_d_i_t_i_o_n_a_l ? : _l_o_g_i_c_a_l _o_r || _l_o_g_i_c_a_l _a_n_d && _a_r_r_a_y _m_e_m_b_e_r_s_h_i_p iinn _m_a_t_c_h_i_n_g ~ !~ _r_e_l_a_t_i_o_n_a_l < > <= >= == != _c_o_n_c_a_t_e_n_a_t_i_o_n (no explicit operator) _a_d_d _o_p_s + - _m_u_l _o_p_s * / % _u_n_a_r_y + - _l_o_g_i_c_a_l _n_o_t ! _e_x_p_o_n_e_n_t_i_a_t_i_o_n ^ _i_n_c _a_n_d _d_e_c ++ -- (both post and pre) _f_i_e_l_d $ Assignment, conditional and exponentiation associate right to left; the other operators associate left to right. Any expression can be paren- thesized. 66.. AArrrraayyss Awk provides one-dimensional arrays. Array elements are expressed as _a_r_r_a_y[_e_x_p_r]. _E_x_p_r is internally converted to string type, so, for ex- ample, A[1] and A["1"] are the same element and the actual index is "1". Arrays indexed by strings are called associative arrays. Ini- tially an array is empty; elements exist when first accessed. An ex- pression, _e_x_p_r iinn _a_r_r_a_y evaluates to 1 if _a_r_r_a_y[_e_x_p_r] exists, else to 0. There is a form of the ffoorr statement that loops over each index of an array. ffoorr ( _v_a_r iinn _a_r_r_a_y ) _s_t_a_t_e_m_e_n_t sets _v_a_r to each index of _a_r_r_a_y and executes _s_t_a_t_e_m_e_n_t. The order that _v_a_r transverses the indices of _a_r_r_a_y is not defined. The statement, ddeelleettee _a_r_r_a_y[_e_x_p_r], causes _a_r_r_a_y[_e_x_p_r] not to exist. mmaawwkk supports the ddeelleettee _a_r_r_a_y feature, which deletes all elements of _a_r_r_a_y. Multidimensional arrays are synthesized with concatenation using the built-in variable SSUUBBSSEEPP. _a_r_r_a_y[_e_x_p_r1,_e_x_p_r2] is equivalent to _a_r_- _r_a_y[_e_x_p_r1 SSUUBBSSEEPP _e_x_p_r2]. Testing for a multidimensional element uses a parenthesized index, such as if ( (i, j) in A ) print A[i, j] 77.. BBuuiillttiinn--vvaarriiaabblleess The following variables are built-in and initialized before program ex- ecution. AARRGGCC number of command line arguments. AARRGGVV array of command line arguments, 0..ARGC-1. CCOONNVVFFMMTT format for internal conversion of numbers to string, ini- tially = "%.6g". EENNVVIIRROONN array indexed by environment variables. An environment string, _v_a_r_=_v_a_l_u_e is stored as EENNVVIIRROONN[_v_a_r] = _v_a_l_u_e. FFIILLEENNAAMMEE name of the current input file. FFNNRR current record number in FFIILLEENNAAMMEE. FFSS splits records into fields as a regular expression. NNFF number of fields in the current record. NNRR current record number in the total input stream. OOFFMMTT format for printing numbers; initially = "%.6g". OOFFSS inserted between fields on output, initially = " ". OORRSS terminates each record on output, initially = "\n". RRLLEENNGGTTHH length set by the last call to the built-in function, mmaattcchh(()). RRSS input record separator, initially = "\n". RRSSTTAARRTT index set by the last call to mmaattcchh(()). SSUUBBSSEEPP used to build multiple array subscripts, initially = "\034". 88.. BBuuiilltt--iinn ffuunnccttiioonnss SSttrriinngg ffuunnccttiioonnss gsub(_r_,_s_,_t) gsub(_r_,_s) Global substitution, every match of regular expression _r in variable _t is replaced by string _s. The number of replace- ments is returned. If _t is omitted, $$00 is used. An _& in the replacement string _s is replaced by the matched sub- string of _t. \& and \\ put literal & and \, respectively, in the replacement string. index(_s_,_t) If _t is a substring of _s, then the position where _t starts is returned, else 0 is returned. The first character of _s is in position 1. length(_s) Returns the length of string or array _s. match(_s_,_r) Returns the index of the first longest match of regular ex- pression _r in string _s. Returns 0 if no match. As a side effect, RRSSTTAARRTT is set to the return value. RRLLEENNGGTTHH is set to the length of the match or -1 if no match. If the empty string is matched, RRLLEENNGGTTHH is set to 0, and 1 is returned if the match is at the front, and length(_s)+1 is returned if the match is at the back. split(_s_,_A_,_r) split(_s_,_A) String _s is split into fields by regular expression _r and the fields are loaded into array _A. The number of fields is returned. See section 11 below for more detail. If _r is omitted, FFSS is used. sprintf(_f_o_r_m_a_t_,_e_x_p_r_-_l_i_s_t) Returns a string constructed from _e_x_p_r_-_l_i_s_t according to _f_o_r_m_a_t. See the description of printf() below. sub(_r_,_s_,_t) sub(_r_,_s) Single substitution, same as gsub() except at most one sub- stitution. substr(_s_,_i_,_n) substr(_s_,_i) Returns the substring of string _s, starting at index _i, of length _n. If _n is omitted, the suffix of _s, starting at _i is returned. tolower(_s) Returns a copy of _s with all upper case characters con- verted to lower case. toupper(_s) Returns a copy of _s with all lower case characters con- verted to upper case. TTiimmee ffuunnccttiioonnss These are available on systems which support the corresponding C mmkkttiimmee and ssttrrffttiimmee functions: mktime(_s_p_e_c_i_f_i_c_a_t_i_o_n) converts a date specification to a timestamp with the same units as ssyyssttiimmee. The date specification is a string con- taining the components of the date as decimal integers: YYYYYYYY the year, e.g., 2012 MMMM the month of the year starting at 1 DDDD the day of the month starting at 1 HHHH hour (0-23) MMMM minute (0-59) SSSS seconds (0-59) DDSSTT tells how to treat timezone versus daylight savings time: positive DST is in effect zero (default) DST is not in effect negative mktime() should (use timezone information and sys- tem databases to) attempt to determine whether DST is in effect at the specified time. strftime([_f_o_r_m_a_t [, _t_i_m_e_s_t_a_m_p [, _u_t_c ]]]) formats the given timestamp using the format (passed to the C ssttrrffttiimmee function): +o If the _f_o_r_m_a_t parameter is missing, "%c" is used. +o If the _t_i_m_e_s_t_a_m_p parameter is missing, the current value from ssyyssttiimmee is used. +o If the _u_t_c parameter is present and nonzero, the result is in UTC. Otherwise local time is used. systime() returns the current time of day as the number of seconds since the Epoch (1970-01-01 00:00:00 UTC on POSIX systems). AArriitthhmmeettiicc ffuunnccttiioonnss atan2(_y_,_x) Arctan of _y/_x between -pi and pi. cos(_x) Cosine function, _x in radians. exp(_x) Exponential function. int(_x) Returns _x truncated towards zero. log(_x) Natural logarithm. rand() Returns a random number between zero and one. sin(_x) Sine function, _x in radians. sqrt(_x) Returns square root of _x. srand(_e_x_p_r) srand() Seeds the random number generator, using the clock if _e_x_p_r is omitted, and returns the value of the previous seed. Srand(_e_x_p_r) is useful for repeating pseudo random se- quences. Note: mmaawwkk is normally configured to seed the random number generator from the clock at startup, making it unnecessary to call srand(). This feature can be suppressed via condi- tional compile, or overridden using the --WWrraannddoomm option. 99.. IInnppuutt aanndd oouuttppuutt There are two output statements, pprriinntt and pprriinnttff. print writes $$00 OORRSS to standard output. print _e_x_p_r1, _e_x_p_r2, ..., _e_x_p_rn writes _e_x_p_r1 OOFFSS _e_x_p_r2 OOFFSS ... _e_x_p_rn OORRSS to standard out- put. Numeric expressions are converted to string with OOFFMMTT. printf _f_o_r_m_a_t_, _e_x_p_r_-_l_i_s_t duplicates the printf C library function writing to stan- dard output. The complete ANSI C format specifications are recognized with conversions %c, %d, %e, %E, %f, %g, %G, %i, %o, %s, %u, %x, %X and %%, and conversion qualifiers h and l. The argument list to print or printf can optionally be enclosed in parentheses. Print formats numbers using OOFFMMTT or "%d" for exact inte- gers. "%c" with a numeric argument prints the corresponding 8 bit character, with a string argument it prints the first character of the string. The output of print and printf can be redirected to a file or command by appending > _f_i_l_e, >> _f_i_l_e or | _c_o_m_m_a_n_d to the end of the print statement. Redirection opens _f_i_l_e or _c_o_m_m_a_n_d only once, subse- quent redirections append to the already open stream. By convention, mmaawwkk associates the filename +o "/dev/stderr" with stderr, +o "/dev/stdout" with stdout, +o "-" and "/dev/stdin" with stdin. The association with stderr is especially useful because it allows print and printf to be redirected to stderr. These names can also be passed to functions. The input function ggeettlliinnee has the following variations. getline reads into $$00, updates the fields, NNFF, NNRR and FFNNRR. getline < _f_i_l_e reads into $$00 from _f_i_l_e, updates the fields and NNFF. getline _v_a_r reads the next record into _v_a_r, updates NNRR and FFNNRR. getline _v_a_r < _f_i_l_e reads the next record of _f_i_l_e into _v_a_r. _c_o_m_m_a_n_d | getline pipes a record from _c_o_m_m_a_n_d into $$00 and updates the fields and NNFF. _c_o_m_m_a_n_d | getline _v_a_r pipes a record from _c_o_m_m_a_n_d into _v_a_r. Getline returns 0 on end-of-file, -1 on error, otherwise 1. Commands on the end of pipes are executed by /bin/sh. The function cclloossee(_e_x_p_r) closes the file or pipe associated with _e_x_p_r. Close returns 0 if _e_x_p_r is an open file, the exit status if _e_x_p_r is a piped command, and -1 otherwise. Close is used to reread a file or command, make sure the other end of an output pipe is finished or con- serve file resources. The function fffflluusshh(_e_x_p_r) flushes the output file or pipe associated with _e_x_p_r. Fflush returns 0 if _e_x_p_r is an open output stream else -1. Fflush without an argument flushes stdout. Fflush with an empty argu- ment ("") flushes all open output. The function ssyysstteemm(_e_x_p_r) uses the C runtime ssyysstteemm call to execute _e_x_p_r and returns the corresponding wait status of the command as fol- lows: +o if the ssyysstteemm call failed, setting the status to -1, mmaawwkk returns that value. +o if the command exited normally, mmaawwkk returns its exit-status. +o if the command exited due to a signal such as SSIIGGHHUUPP, mmaawwkk returns the signal number plus 256. Changes made to the EENNVVIIRROONN array are not passed to commands executed with ssyysstteemm or pipes. 1100.. UUsseerr ddeeffiinneedd ffuunnccttiioonnss The syntax for a user defined function is ffuunnccttiioonn name( _a_r_g_s ) { _s_t_a_t_e_m_e_n_t_s } The function body can contain a return statement rreettuurrnn _o_p_t___e_x_p_r A return statement is not required. Function calls may be nested or recursive. Functions are passed expressions by value and arrays by reference. Extra arguments serve as local variables and are initial- ized to _n_u_l_l. For example, csplit(_s_,_A) puts each character of _s into array _A and returns the length of _s. function csplit(s, A, n, i) { n = length(s) for( i = 1 ; i <= n ; i++ ) A[i] = substr(s, i, 1) return n } Putting extra space between passed arguments and local variables is conventional. Functions can be referenced before they are defined, but the function name and the '(' of the arguments must touch to avoid con- fusion with concatenation. A function parameter is normally a scalar value (number or string). If there is a forward reference to a function using an array as a parame- ter, the function's corresponding parameter will be treated as an ar- ray. 1111.. SSpplliittttiinngg ssttrriinnggss,, rreeccoorrddss aanndd ffiilleess Awk programs use the same algorithm to split strings into arrays with split(), and records into fields on FFSS. mmaawwkk uses essentially the same algorithm to split files into records on RRSS. Split(_e_x_p_r_,_A_,_s_e_p) works as follows: (1) If _s_e_p is omitted, it is replaced by FFSS. _S_e_p can be an expres- sion or regular expression. If it is an expression of non- string type, it is converted to string. (2) If _s_e_p = " " (a single space), then is trimmed from the front and back of _e_x_p_r, and _s_e_p becomes . mmaawwkk defines as the regular expression /[ \t\n]+/. Otherwise _s_e_p is treated as a regular expression, except that meta-characters are ignored for a string of length 1, e.g., split(x, A, "*") and split(x, A, /\*/) are the same. (3) If _e_x_p_r is not string, it is converted to string. If _e_x_p_r is then the empty string "", split() returns 0 and _A is set empty. Otherwise, all non-overlapping, non-null and longest matches of _s_e_p in _e_x_p_r, separate _e_x_p_r into fields which are loaded into _A. The fields are placed in A[1], A[2], ..., A[n] and split() re- turns n, the number of fields which is the number of matches plus one. Data placed in _A that looks numeric is typed number and string. Splitting records into fields works the same except the pieces are loaded into $$11, $$22,..., $$NNFF. If $$00 is empty, NNFF is set to 0 and all $$ii to "". mmaawwkk splits files into records by the same algorithm, but with the slight difference that RRSS is really a terminator instead of a separa- tor. (OORRSS is really a terminator too). E.g., if FFSS = ":+" and $$00 = "a::b:" , then NNFF = 3 and $$11 = "a", $$22 = "b" and $$33 = "", but if "a::b:" is the contents of an input file and RRSS = ":+", then there are two records "a" and "b". RRSS = " " is not special. If FFSS = "", then mmaawwkk breaks the record into individual characters, and, similarly, split(_s_,_A_,"") places the individual characters of _s into _A. 1122.. MMuullttii--lliinnee rreeccoorrddss Since mmaawwkk interprets RRSS as a regular expression, multi-line records are easy. Setting RRSS = "\n\n+", makes one or more blank lines separate records. If FFSS = " " (the default), then single newlines, by the rules for above, become space and single newlines are field separa- tors. For example, if +o a file is "a b\nc\n\n", +o RRSS = "\n\n+" and +o FFSS = " ", then there is one record "a b\nc" with three fields "a", "b" and "c": +o using FFSS = "\n", gives two fields "a b" and "c"; +o using FFSS = "", gives one field identical to the record. If you want lines with spaces or tabs to be considered blank, set RRSS = "\n([ \t]*\n)+". For compatibility with other awks, setting RRSS = "" has the same effect as if blank lines are stripped from the front and back of files and then records are determined as if RRSS = "\n\n+". POSIX requires that "\n" always separates records when RRSS = "" regard- less of the value of FFSS. mmaawwkk does not support this convention, be- cause defining "\n" as makes it unnecessary. Most of the time when you change RRSS for multi-line records, you will also want to change OORRSS to "\n\n" so the record spacing is preserved on output. 1133.. PPrrooggrraamm eexxeeccuuttiioonn This section describes the order of program execution. First AARRGGCC is set to the total number of command line arguments passed to the execu- tion phase of the program. +o AARRGGVV[[00]] is set to the name of the AWK interpreter and +o AARRGGVV[[11]] ... AARRGGVV[[AARRGGCC--11]] holds the remaining command line argu- ments exclusive of options and program source. For example, with mawk -f prog v=1 A t=hello B AARRGGCC = 5 with AARRGGVV[[00]] = "mawk", AARRGGVV[[11]] = "v=1", AARRGGVV[[22]] = "A", AARRGGVV[[33]] = "t=hello" and AARRGGVV[[44]] = "B". Next, each BBEEGGIINN block is executed in order. If the program consists entirely of BBEEGGIINN blocks, then execution terminates, else an input stream is opened and execution continues. If AARRGGCC equals 1, the input stream is set to stdin, else the command line arguments AARRGGVV[[11]] ... AARRGGVV[[AARRGGCC--11]] are examined for a file argument. The command line arguments divide into three sets: file arguments, as- signment arguments and empty strings "". An assignment has the form _v_a_r=_s_t_r_i_n_g. When an AARRGGVV[[ii]] is examined as a possible file argument, if it is empty it is skipped; if it is an assignment argument, the as- signment to _v_a_r takes place and ii skips to the next argument; else AARRGGVV[[ii]] is opened for input. If it fails to open, execution terminates with exit code 2. If no command line argument is a file argument, then input comes from stdin. Getline in a BBEEGGIINN action opens input. "-" as a file argument denotes stdin. Once an input stream is open, each input record is tested against each _p_a_t_t_e_r_n, and if it matches, the associated _a_c_t_i_o_n is executed. An ex- pression pattern matches if it is boolean true (see the end of section 2). A BBEEGGIINN pattern matches before any input has been read, and an EENNDD pattern matches after all input has been read. A range pattern, _e_x_p_r1,_e_x_p_r2 , matches every record between the match of _e_x_p_r1 and the match _e_x_p_r2 inclusively. When end of file occurs on the input stream, the remaining command line arguments are examined for a file argument, and if there is one it is opened, else the EENNDD _p_a_t_t_e_r_n is considered matched and all EENNDD _a_c_t_i_o_n_s are executed. In the example, the assignment v=1 takes place after the BBEEGGIINN _a_c_t_i_o_n_s are executed, and the data placed in v is typed number and string. In- put is then read from file A. On end of file A, t is set to the string "hello", and B is opened for input. On end of file B, the EENNDD _a_c_t_i_o_n_s are executed. Program flow at the _p_a_t_t_e_r_n _{_a_c_t_i_o_n_} level can be changed with the nneexxtt nneexxttffiillee eexxiitt _o_p_t___e_x_p_r statements: +o A nneexxtt statement causes the next input record to be read and pat- tern testing to restart with the first _p_a_t_t_e_r_n _{_a_c_t_i_o_n_} pair in the program. +o A nneexxttffiillee statement tells mmaawwkk to stop processing the current in- put file. It then updates FILENAME to the next file listed on the command line, and resets FNR to 1. +o An eexxiitt statement causes immediate execution of the EENNDD actions or program termination if there are none or if the eexxiitt occurs in an EENNDD action. The _o_p_t___e_x_p_r sets the exit value of the program unless overridden by a later eexxiitt or subsequent error. EENNVVIIRROONNMMEENNTT MMaawwkk recognizes these variables: MAWKBINMODE (see CCOOMMPPAATTIIBBIILLIITTYY) MAWK_LONG_OPTIONS If this is set, mmaawwkk uses its value to decide what to do with GNU-style long options: allow MMaawwkk allows the option to be checked against the (small) set of long options it recognizes. The long names from the --WW option are recognized, e.g., ----vveerrssiioonn is derived from --WWvveerrssiioonn. error MMaawwkk prints an error message and exits. This is the de- fault. ignore MMaawwkk ignores the option, unless it happens to be one of the one it recognizes. warn Print an warning message and otherwise ignore the op- tion. If the variable is unset, mmaawwkk prints an error message and exits. WHINY_USERS This is a ggaawwkk 3.1.0 feature, removed in the 4.0.0 release. It tells mmaawwkk to sort array indices before it starts to iterate over the elements of an array. CCOOMMPPAATTIIBBIILLIITTYY MMAAWWKK 11..33..33 vveerrssuuss PPOOSSIIXX 11000033..22 DDrraafftt 1111..33 The POSIX 1003.2(draft 11.3) definition of the AWK language is AWK as described in the AWK book with a few extensions that appeared in Sys- temVR4 nawk. The extensions are: +o New functions: toupper() and tolower(). +o New variables: ENVIRON[] and CONVFMT. +o ANSI C conversion specifications for printf() and sprintf(). +o New command options: -v var=value, multiple -f options and im- plementation options as arguments to -W. +o For systems (MS-DOS or Windows) which provide a _s_e_t_m_o_d_e func- tion, an environment variable MAWKBINMODE and a built-in vari- able BINMODE. The bits of the BINMODE value tell mmaawwkk how to modify the RRSS and OORRSS variables: 0 set standard input to binary mode, and if BIT-2 is unset, set RRSS to "\r\n" (CR/LF) rather than "\n" (LF). 1 set standard output to binary mode, and if BIT-2 is unset, set OORRSS to "\r\n" (CR/LF) rather than "\n" (LF). 2 suppress the assignment to RRSS and OORRSS of CR/LF, making it possible to run scripts and generate output compatible with Unix line-endings. POSIX AWK is oriented to operate on files a line at a time. RRSS can be changed from "\n" to another single character, but it is hard to find any use for this -- there are no examples in the AWK book. By conven- tion, RRSS = "", makes one or more blank lines separate records, allowing multi-line records. When RRSS = "", "\n" is always a field separator re- gardless of the value in FFSS. mmaawwkk, on the other hand, allows RRSS to be a regular expression. When "\n" appears in records, it is treated as space, and FFSS always deter- mines fields. Removing the line at a time paradigm can make some programs simpler and can often improve performance. For example, redoing example 3 from above, BEGIN { RS = "[^A-Za-z]+" } { word[ $0 ] = "" } END { delete word[ "" ] for( i in word ) cnt++ print cnt } counts the number of unique words by making each word a record. On moderate size files, mmaawwkk executes twice as fast, because of the sim- plified inner loop. The following program replaces each comment by a single space in a C program file, BEGIN { RS = "/\*([^*]|\*+[^/*])*\*+/" # comment is record separator ORS = " " getline hold } { print hold ; hold = $0 } END { printf "%s" , hold } Buffering one record is needed to avoid terminating the last record with a space. With mmaawwkk, the following are all equivalent, x ~ /a\+b/ x ~ "a\+b" x ~ "a\\+b" The strings get scanned twice, once as string and once as regular ex- pression. On the string scan, mmaawwkk ignores the escape on non-escape characters while the AWK book advocates _\_c be recognized as _c which ne- cessitates the double escaping of meta-characters in strings. POSIX explicitly declines to define the behavior which passively forces pro- grams that must run under a variety of awks to use the more portable but less readable, double escape. POSIX AWK does not recognize "/dev/std{in,out,err}". Some systems pro- vide an actual device for this, allowing AWKs which do not implement the feature directly to support it. POSIX AWK does not recognize \x hex escape sequences in strings. Un- like ANSI C, mmaawwkk limits the number of digits that follows \x to two as the current implementation only supports 8 bit characters. POSIX explicitly leaves the behavior of FFSS = "" undefined, and mentions splitting the record into characters as a possible interpretation, but currently this use is not portable across implementations. Some features were not part of the POSIX standard until long after their introduction in mmaawwkk and other implementations. These have been approved, though still (as of July 2020), are not part of a published standard: +o The built-in fffflluusshh first appeared in a 1993 AT&T awk released to netlib. It was approved for the POSIX standard in 2012. +o Aggregate deletion with ddeelleettee _a_r_r_a_y was approved in 2018. RRaannddoomm nnuummbbeerrss POSIX does not prescribe a method for initializing random numbers at startup. In practice, most implementations do nothing special, which makes ssrraanndd and rraanndd follow the C runtime library, making the initial seed value 1. Some implementations (Solaris XPG4 and Tru64) return 0 from the first call to ssrraanndd, although the results from rraanndd behave as if the initial seed is 1. Other implementations return 1. While mmaawwkk can call ssrraanndd at startup with no parameter (initializing random numbers from the clock), this feature may be suppressed using conditional compilation. EExxtteennssiioonnss aaddddeedd ffoorr ccoommppaattiibbiilliittyy ffoorr GGAAWWKK aanndd BBWWKK NNeexxttffiillee is a ggaawwkk extension (also implemented by BWK awk). It was ap- proved for the POSIX standard in September 2012, and is expected to be part of the next revision of the standard. MMkkttiimmee, ssttrrffttiimmee and ssyyssttiimmee are ggaawwkk extensions. The "/dev/stdin" feature was added to mmaawwkk after 1.3.4, for compatibil- ity with ggaawwkk and BWK awk. The corresponding "-" (alias for /dev/stdin) was present in mmaawwkk 1.3.3. Interval expressions, e.g., a range _{_m_,_n_} in Extended Regular Expres- sions (EREs), were not supported in awk (or even the original "nawk"): +o Gawk provided this feature in 1991 (and later, in 1998, options for turning it off, for compatibility with "traditional awk"). +o Interval expressions, were introduced into _a_w_k regular expressions in IEEE 1003.1-2001 (also known as Unix 03), along with some inter- nationalization features. +o Apple modified its copy of the original awk in April 2006, making this version of awk support interval expressions. The updated source provides for compatibility with older "legacy" versions using an environment variable, making this "Unix 2003" feature (perhaps meant as Unix 03) the default. +o NetBSD developers copied this change in January 2018, omitting the compatibility option, and then applied it to BWK awk. +o The interval expression implementation in mmaawwkk is based on changes proposed by James Parkinson in April 2016. MMaawwkk also recognizes a few gawk-specific command line options for script compatibility: ----hheellpp, ----ppoossiixx, --rr, ----rree--iinntteerrvvaall, ----ttrraaddiittiioonnaall, ----vveerrssiioonn SSuubbttllee DDiiffffeerreenncceess nnoott iinn PPOOSSIIXX oorr tthhee AAWWKK BBooookk Finally, here is how mmaawwkk handles exceptional cases not discussed in the AWK book or the POSIX draft. It is unsafe to assume consistency across awks and safe to skip to the next section. +o substr(s, i, n) returns the characters of s in the intersection of the closed interval [1, length(s)] and the half-open interval [i, i+n). When this intersection is empty, the empty string is returned; so substr("ABC", 1, 0) = "" and substr("ABC", -4, 6) = "A". +o Every string, including the empty string, matches the empty string at the front so, s ~ // and s ~ "", are always 1 as is match(s, //) and match(s, ""). The last two set RRLLEENNGGTTHH to 0. +o index(s, t) is always the same as match(s, t1) where t1 is the same as t with metacharacters escaped. Hence consistency with match requires that index(s, "") always returns 1. Also the condition, index(s,t) != 0 if and only t is a substring of s, requires index("","") = 1. +o If getline encounters end of file, getline var, leaves var un- changed. Similarly, on entry to the EENNDD actions, $$00, the fields and NNFF have their value unaltered from the last record. BBUUGGSS mmaawwkk implements pprriinnttff(()) and sspprriinnttff(()) using the C library functions, printf and sprintf, so full ANSI compatibility requires an ANSI C li- brary. In practice this means the h conversion qualifier may not be available. Also mmaawwkk inherits any bugs or limitations of the library functions. Implementors of the AWK language have shown a consistent lack of imagi- nation when naming their programs. EEXXAAMMPPLLEESS 1. emulate cat. { print } 2. emulate wc. { chars += length($0) + 1 # add one for the \n words += NF } END{ print NR, words, chars } 3. count the number of unique "real words". BEGIN { FS = "[^A-Za-z]+" } { for(i = 1 ; i <= NF ; i++) word[$i] = "" } END { delete word[""] for ( i in word ) cnt++ print cnt } 4. sum the second field of every record based on the first field. $1 ~ /credit|gain/ { sum += $2 } $1 ~ /debit|loss/ { sum -= $2 } END { print sum } 5. sort a file, comparing as string { line[NR] = $0 "" } # make sure of comparison type # in case some lines look numeric END { isort(line, NR) for(i = 1 ; i <= NR ; i++) print line[i] } #insertion sort of A[1..n] function isort( A, n, i, j, hold) { for( i = 2 ; i <= n ; i++) { hold = A[j = i] while ( A[j-1] > hold ) { j-- ; A[j+1] = A[j] } A[j] = hold } # sentinel A[0] = "" will be created if needed } AAUUTTHHOORRSS Mike Brennan (brennan@whidbey.com). Thomas E. Dickey . SSEEEE AALLSSOO ggrreepp(1) Aho, Kernighan and Weinberger, _T_h_e _A_W_K _P_r_o_g_r_a_m_m_i_n_g _L_a_n_g_u_a_g_e, Addison- Wesley Publishing, 1988, (the AWK book), defines the language, opening with a tutorial and advancing to many interesting programs that delve into issues of software design and analysis relevant to programming in any language. _T_h_e _G_A_W_K _M_a_n_u_a_l, The Free Software Foundation, 1991, is a tutorial and language reference that does not attempt the depth of the AWK book and assumes the reader may be a novice programmer. The section on AWK ar- rays is excellent. It also discusses POSIX requirements for AWK. mmaawwkk--aarrrraayyss(7) discusses mmaawwkk's implementation of arrays. mmaawwkk--ccooddee(7) gives more information on the --WW dduummpp option. Version 1.3.4 2024-01-23 MAWK(1) mawk-1.3.4-20240123/man/mawk-externs.dat0000644000000000000000000000023513712064452015745 0ustar rootroot# $MawkId: mawk-externs.dat,v 1.1 2020/08/03 19:44:42 tom Exp $ # manpages to exclude from man2html linking, for post-processing. atof(3) grep(1) sprintf(3) mawk-1.3.4-20240123/man/mawk-code.70000644000000000000000000006676114554034057014610 0ustar rootroot.\" $MawkId: mawk-code.7,v 1.43 2024/01/23 22:05:35 tom Exp $ .\" ########################################################################### .\" # copyright 2020,2024 Thomas E. Dickey .\" # .\" # This is a source file for mawk, an implementation of .\" # the AWK programming language. .\" # .\" # Mawk is distributed without warranty under the terms of .\" # the GNU General Public License, version 2, 1991. .\" ########################################################################### .ds N Mawk .ds n mawk .TH MAWK-CODE 7 2024-01-23 "Version 1.3.4" Miscellaneous .\" Bulleted paragraph .de bP .ie n .IP \(bu 4 .el .IP \(bu 2 .. .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g \{\ .ds `` \(lq .ds '' \(rq .ds ' \(aq .\} .el \{\ .ie t .ds `` `` .el .ds `` "" .ie t .ds '' '' .el .ds '' "" .ie t .ds ' \(aq .el .ds ' ' .\} .\" superscript .de SU .ie n \\$1**(\\$2)\\$3 .el \\$1\u\s-1\\$2\s+1\d\\$3 .. .\" ************************************************************************** .SH NAME mawk-code \- dumping \*n's byte-code .\" ************************************************************************** .SH SYNOPSIS At startup, \fB\*n\fP compiles the script into byte-code. After that, it interprets the compiled byte-code. Use the \fB\-Wdump\fP option to show the byte-code. .SH "PROGRAM CODES" As \fB\*n\fP executes the program, it maintains a reference to the command to execute in \fBcdp\fP. After that there may be data and/or references in \fBcdp\fP[0], \fBcdp\fP[1], etc. .PP When an operation requires operands, \fB\*n\fP pushes the values (or array/string references) onto the stack, which updates the stack pointer \fBsp\fP. When the operation completes, \fB\*n\fP consumes those entries on the stack, pushing the result (if any) onto the stack. .PP While executing user-defined functions, \fB\*n\fP maintains a \fIframe pointer\fP \fBfp\fP to address the function's local variables. .SS a_cat \fIConcatenate array-indices\fP. .PP Usage: .RS 5 Forms a multiple array index by concatenating the elements of \fBsp\fP[1-\fIcnt\fP..0], with each element separated by \fISUBSEP\fP. .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br \fIcnt\fP, the number of elements to concatenate follows the command. .TP 5 sp[0]..sp[1-\fIcnt\fP] hold reference to the elements to concatenate. .RE Returns the index in sp[0]. .SS a_del \fIDelete an array item\fP. .PP Usage: .RS 5 delete array[expr] .RE .PP Parameters: .RS 5 .TP 5 sp[0] points to \fIarray\fP .TP 5 sp[-1] is an \fIexpr\fP .RE .SS a_length \fIFind the length of an array\fP. .PP Usage: .RS 5 length(array) .RE .PP Parameters: .RS 5 .TP 5 sp[0] points to \fIarray\fP. .RE .PP Returns the length of the array in sp[0]. .SS a_pusha \fIPush array address onto stack\fP. .PP Usage: .RS 5 This is used to set up a calling argument for a function. .RE .PP Parameters: .RS 5 .TP 5 cdp[0] array reference follows the command. .RE .PP Returns the array in sp[0]. .SS a_test \fITest if an expression is present in an array\fP. .PP Usage: .RS 5 (expression in array) .RE .PP Parameters: .RS 5 .TP 5 sp[0] points to \fIan array\fP. .TP 5 sp[-1] is an \fIexpression\fP. .RE .PP Returns 1 in sp[0] if the expression is found, 0 otherwise. .SS add \fIAdd two numbers\fP. .PP Usage: .RS 5 \fIfirst\fP + \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value. .TP 5 sp[-1] holds the \fIfirst\fP value. .RE .PP Returns the sum in sp[0]. .SS add_asg \fICombined addition/assignment\fP. .PP Usage: .RS 5 \fItarget\fP += \fIsource\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsource\fP expression .TP 5 sp[-1] points to the \fItarget\fP .RE .PP Stores the sum in the \fItarget\fP, leaving sp[0] pointing to the \fItarget\fP. .SS ae_pusha \fIPush reference to array cell, given expression for its index\fP. .PP Usage: .RS 5 \fIarrayname\fP[\fIexpression\fP] .RE .PP Parameters: .RS 5 .TP 5 cdp[0] an array reference follows the command. .TP 5 sp[0] has an expression, used for the index of a cell in the array. .RE .PP Returns a reference to the addressed cell in sp[0]. .SS ae_pushi \fIPush contents of array cell, given expression for its index\fP. .PP Usage: .RS 5 \fIarrayname\fP[\fIexpression\fP] .RE .PP Parameters: .RS 5 .TP 5 sp[0] has an expression, used for the index of a cell in the array. .RE .PP Returns contents of the addressed cell in sp[0]. .SS aloop \fIUpdate reference to next cell for array loop\fP. .PP Usage: .RS 5 for ( \fIi\fP in \fIarrayname\fP ) \fIstatement\fP .RE .PP Parameters: .RS 5 .TP 5 none .RE .PP \fB\*N\fP maintains a stack of array-loop state. It updates the array/cell references in the current loop's state. .SS assign \fIAssigns a value\fP. .PP Usage: .RS 5 \fItarget\fP = \fIsource\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsource\fP expression .TP 5 sp[-1] points to the \fItarget\fP .PP Stores the sum in the \fItarget\fP, leaving sp[0] pointing to the \fItarget\fP. .RE .SS atan2 \fICompute arc-tangent of two values\fP. .PP Usage: .RS 5 atan2( \fIfirst\fP, \fIsecond\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value .TP 5 sp[-1] holds the \fIfirst\fP value .RE .PP Returns the result in sp[0]. .SS call \fICall a function\fP. .PP Usage: .RS 5 \fIfunction\fP() .RE .PP Parameters: .RS 5 .TP 5 cdp[0] is a reference to the function block .TP 5 cdp[1] holds number of input arguments .RE .PP Returns function value in sp[0]. .SS cat \fIConcatenate two strings\fP. .PP Usage: .RS 5 \fIfirst\fP \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsecond\fP string. .TP 5 sp[-1] is the \fIfirst\fP string. .RE .PP Returns the result in sp[0]. .SS close \fIClose the file or pipe associated with an expression\fP. .PP Usage: .RS 5 close( \fIexpression\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIexpression\fP identifying the file to close .RE .PP Returns the status from closing the file, 0 on success or \-1 on failure. .SS cos \fICompute the cosine of a value in radians\fP. .PP Usage: .RS 5 cos( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIvalue\fP. .RE .PP Returns the result in sp[0]. .SS del_a \fIDelete an array\fP. .PP Usage: .RS 5 delete(array) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIarray\fP to delete. .RE .SS div \fIDivide one number by another\fP. .PP Usage: .RS 5 \fIfirst\fP / \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsecond\fP value. .TP 5 sp[-1] is the \fIfirst\fP value. .RE .PP Returns the quotient in sp[0]. .SS div_asg \fICombined division/assignment\fP. .PP Usage: .RS 5 \fItarget\fP /= \fIsource\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsource\fP .TP 5 sp[-1] points to the \fItarget\fP .RE .PP Stores the quotient in the \fItarget\fP, leaving sp[0] pointing to the target. .SS eq \fICompare two values\fP. .PP Usage: .RS 5 \fIfirst\fP == \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsecond\fP value .TP 5 sp[-1] is the \fIfirst\fP value .RE .PP Returns 1 in sp[0] if the values are equal, otherwise 0. .SS exit \fIExits \*n with a specific exit-code\fP. .PP Usage: .RS 5 exit(\fIexit_code\fP) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIexit_code\fP .RE .SS exit0 \fIExits \*n with success\fP .PP Usage: .RS 5 exit .RE .PP Parameters: .RS 5 none .RE .SS exp \fICompute base-e exponential function of a value\fP. .PP Usage: .RS 5 exp( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIvalue\fP .RE .PP Returns the result in sp[0]. .SS f_add_asg \fICombination addition/assignment to NF\fP. .PP Usage: .RS 5 NF += \fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIexpression\fP to add .RE .SS f_assign \fIAssign an expression to NF\fP. .PP Usage: .RS 5 NF = \fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIexpression\fP .RE .SS f_div_asg \fICombination division/assignment to NF\fP. .PP Usage: .RS 5 NF /= \fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIexpression\fP .RE .SS f_mod_asg \fICombination modulus/assignment to NF\fP. .PP Usage: .RS 5 NF %= \fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIexpression\fP .RE .SS f_mul_asg \fICombination multiplication/assignment to NF\fP. .PP Usage: .RS 5 NF *= \fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIexpression\fP .RE .SS f_post_dec \fIPost-decrement using NF\fP. .PP Usage: .RS 5 NF-- .RE .PP Parameters: .RS 5 holds a reference to the field to use .RE .SS f_post_inc \fIPost-increment using NF\fP. .PP Usage: .RS 5 NF++ .RE .PP Parameters: .RS 5 holds a reference to the field to use .RE .SS f_pow_asg \fIExponentiation using NF\fP. .PP Usage: .RS 5 NF ^= \fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the expression to use .RE .SS f_pre_dec \fIPredecrement using NF\fP. .PP Usage: .RS 5 \-\-NF .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds a reference to the field to use .RE .SS f_pre_inc \fIPreincrement using NF\fP. .PP Usage: .RS 5 ++NF .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds a reference to the field to use .RE .SS f_pusha \fIPush array reference to data split-up as fields.\fP. .PP Usage: .RS 5 $0 = \fIexpression\fP .br getline .RE .PP Parameters: .RS 5 .TP 5 cdp[0] is a reference to the data to be split/assigned. .RE .PP Returns the resulting array reference in sp[0]. .SS f_pushi \fIPush contents of numbered field\fP. .PP Usage: .RS 5 $\fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 cdp[0] holds a reference to $\fIexpression\fP .TP 5 cdp[1] holds \fIexpression\fP .RE .PP Returns the field's value in sp[0]. .SS f_sub_asg \fICombination subtraction/assignment to NF\fP. .PP Usage: .RS 5 NF -= \fIexpression\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds a reference to the field to use .RE .SS fe_pusha \fIPush reference to numbered field\fP. .PP Usage: .RS 5 $\fInumber\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the field \fInumber\fP .RE .PP Returns a reference to the field in sp[0]. .SS fe_pushi \fIPush content of numbered field\fP. .PP Usage: .RS 5 $\fInumber\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the field \fInumber\fP .RE .PP Returns the field's content in sp[0]. .SS fflush \fIFlush the output file or pipe associated with an expression\fP. .PP Usage: .RS 5 fflush( \fIexpression\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIexpression\fP value .RE .PP Returns the result in sp[0]. .SS gt \fITest if first value is greater than the second\fP. .PP Usage: .RS 5 \fIfirst\fP > \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value. .TP 5 sp[-1] holds the \fIfirst\fP value. .RE .PP Returns 1 in sp[0] if the \fIfirst\fP value is greater than, otherwise 0. .SS gte \fITest if first value is greater than or equal to the second\fP. .PP Usage: .RS 5 \fIfirst\fP >= \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value. .TP 5 sp[-1] holds the \fIfirst\fP value. .RE .PP Returns 1 in sp[0] if the \fIfirst\fP value is greater than or equal, otherwise 0. .SS index \fIFind the position of the second string in the first\fP. .PP Usage: .RS 5 index( \fIfirst\fP, \fIsecond\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsecond\fP string .TP 5 sp[0] is the \fIfirst\fP string .RE .PP Returns the position in sp[0] starting at 1 if found, 0 if not found. .SS int \fIReturns a value truncated towards zero.\fP. .PP Usage: .RS 5 int( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the value .RE .PP Returns the result in sp[0]. .SS jmain \fIGo from BEGIN code to MAIN code\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS jmp \fIJump to a new byte-code position, by a given number of bytes\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] holds the (signed) number of bytes by which to jump. .RE .SS jnz \fIJump to a new byte-code position if sp[0] is nonzero,\fP \fIby a given number of bytes\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP cdp[0] .br holds the (signed) number of bytes by which to jump. .TP 5 sp[0] .br holds a value to compare against 0. .RE .SS jz \fIJump to a new byte-code position if sp[0] is zero, by a given number of bytes\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP cdp[0] .br holds the (signed) number of bytes by which to jump. .TP 5 sp[0] .br holds a value to compare against 0. .RE .SS l_pusha \fIPush a local address onto the evaluation stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds the offset from the \fIframe pointer\fP \fBfp\fP. .RE .PP Returns the address in sp[0]. .SS l_pushi \fIPush contents of a local variable onto the evaluation stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds the offset from the \fIframe pointer\fP \fBfp\fP. .RE .PP Returns the contents of the local variable in sp[0]. .SS la_pusha \fIPushes a reference to an array onto the evaluation stack\fP. .PP Usage: .RS 5 \fIarrayname\fP .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds the offset from the \fIframe pointer\fP \fBfp\fP of a reference to an array. .RE .PP Returns a reference to the array in sp[0]. .SS lae_pusha \fIPushes a reference to a given array cell onto the evaluation stack\fP. .PP Usage: .RS 5 \fIarrayname\fP[\fIexpression\fP] .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds the offset from the \fIframe pointer\fP \fBfp\fP of a reference to an array. .TP 5 sp[0] .br holds an \fIexpression\fP .RE .PP Returns a reference to the specified array cell in sp[0]. .SS lae_pushi \fIPushes the contents of a given array cell onto the evaluation stack\fP. .PP Usage: .RS 5 \fIarrayname\fP[\fIexpression\fP] .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds the offset from the \fIframe pointer\fP \fBfp\fP of a reference to an array. .TP 5 sp[0] .br holds an \fIexpression\fP .RE .PP Returns the contents of the specified array cell in sp[0]. .SS length \fIReturns the length of a string or array value\fP. .PP Usage: .RS 5 length( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the string or array reference .RE .PP Returns the length in sp[0]. .SS ljnz \fISpecial jump for logical-OR, always preceded by \fBtest\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds the (signed) number of bytes by which to jump if the value is nonzero. .TP 5 sp[0] .br holds a value to compare against 0. .RE .SS ljz \fISpecial jump for logical-OR, always preceded by \fBtest\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds the (signed) number of bytes by which to jump if the value is zero. .TP 5 sp[0] .br holds a value to compare against 0. .RE .SS log \fICompute the natural logarithm of a value\fP. .PP Usage: .RS 5 log( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the value .RE .PP Returns the result in sp[0]. .SS lt \fITest if first value is less than the second\fP. .PP Usage: .RS 5 \fIfirst\fP < \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value. .TP 5 sp[-1] holds the \fIfirst\fP value. .RE .PP Returns 1 in sp[0] if the \fIfirst\fP value is less than, otherwise 0. .SS lte \fITest if first value is less than or equal to the second\fP. .PP Usage: .RS 5 \fIfirst\fP <= \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value. .TP 5 sp[-1] holds the \fIfirst\fP value. .RE .PP Returns 1 in sp[0] if the \fIfirst\fP value is less than or equal, otherwise 0. .SS match0 \fITest if $0 matches a given regular expression\fP. .PP Usage: .RS 5 $0 ~ \fIregex\fP .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds a reference to a regular expression. .RE .PP Returns 1 in sp[0] if \fB$0\fP matches the regular expression, 0 otherwise. .SS match1 \fITest if a given expression matches a given regular expression\fP. .PP Usage: .RS 5 \fIexpression\fP ~ \fIregex\fP .RE .PP Parameters: .RS 5 .TP 5 cdp[0] .br holds a reference to a regular expression. .TP 5 sp[0] .br holds an expression to test. .RE .PP Returns 1 in sp[0] if the expression matches the regular expression, 0 otherwise. .SS match2 \fITest if an expression in sp[-1] matches the regular expression in sp[0]\fP. .PP Usage: .RS 5 \fIexpression\fP ~ \fIregex\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] .br holds a reference to a regular expression. .TP 5 sp[-1] .br holds an expression to test. .RE .PP Returns 1 in sp[0] if the expression matches the regular expression, 0 otherwise. .SS mktime \fIConverts a date specification in systime format to a timestamp\fP. .PP Usage: .RS 5 mktime( \fIstring\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the date-specification string .RE .PP Returns the result in sp[0]. .SS mod \fICompute modulus/remainder with two operands\fP. .PP Usage: .RS 5 \fIfirst\fP % \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP operand .TP 5 sp[-1] holds the \fIfirst\fP operand .RE .PP Returns the remainder in sp[0]. .SS mod_asg \fIAssign modulus/remainder with two operands\fP. .PP Usage: .RS 5 \fIfirst\fP %= \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP operand .TP 5 cdp[0] holds the \fIfirst\fP operand .RE .PP Returns the remainder in sp[0] as well as replacing the \fIfirst\fP value. .SS mul \fICompute product with two operands\fP. .PP Usage: .RS 5 \fIfirst\fP * \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value .TP 5 sp[-1] holds the \fIfirst\fP value .RE .PP Returns the product in sp[0]. .SS mul_asg \fIAssign product with two operands\fP. .PP Usage: .RS 5 \fIfirst\fP *= \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value .TP 5 sp[-1] holds the \fIfirst\fP value .RE .PP Returns the product in sp[0] as well as replacing the \fIfirst\fP value. .SS neq \fICompare two values\fP. .PP Usage: .RS 5 \fIfirst\fP != \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the \fIsecond\fP value .TP 5 sp[-1] is the \fIfirst\fP value .RE .PP Returns 1 in sp[0] if the values are not equal, otherwise 0. .SS next \fIRead the next record, restart pattern testing\fP. .PP Usage: .RS 5 next .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS nextfile \fIBegin processing the next file listed on the command line\fP. .PP Usage: .RS 5 nextfile .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS nf_pushi \fIPush the number of fields (NF) onto the evaluation stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS not \fICompute a logical negation\fP. .PP Usage: .RS 5 ! \fIvalue\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds a value to negate. .RE .PP Returns the result on the evaluation stack, i.e., 0 if the value is nonzero and 1 otherwise. .SS ol_gl \fIRead into $0 using getline\fP. .PP Usage: .RS 5 getline .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS ol_gl_nr \fIRead into $0 using getline, updating NR and FNR\fP. .PP Usage: .RS 5 getline < \fIfile\fP .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS omain \fIStart executing the main section of the script (between BEGIN and END)\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS pop \fIPop the evaluation stack, discarding the value\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS pop_al \fIFinish an array \*(``in\*('' loop, deallocating the state information\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS post_dec \fIPost-decrement a value\fP. .PP Usage: .RS 5 \fIvalue\fP \-\- .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the value to decrement .RE .PP Returns the updated value in sp[0]. .SS post_inc \fIPost-increment a value\fP. .PP Usage: .RS 5 \fIvalue\fP ++ .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the value to increment .RE .PP Returns the updated value in sp[0]. .SS pow \fICompute the first value raised to the power of the second value\fP. .PP Usage: .RS 5 \fIfirst\fP ^ \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value .TP 5 sp[-1] holds the \fIfirst\fP value .RE .PP Returns the result in sp[0]. .SS pow_asg \fIAssign the first value raised to the power of the second value\fP. .PP Usage: .RS 5 \fIvariable\fP = \fIfirst\fP ^ \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 cdp[0] is a reference to the variable which will be assigned the result .TP 5 sp[0] holds the \fIsecond\fP value .TP 5 sp[-1] holds the \fIfirst\fP value .RE .SS pre_dec \fIPre-decrement a value\fP. .PP Usage: .RS 5 \-\- \fIvalue\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIvalue\fP to decrement. .RE .PP Returns the updated value in sp[0];. .SS pre_inc \fIPre-increment a value\fP. .PP Usage: .RS 5 ++ \fIvalue\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIvalue\fP to decrement. .RE .PP Returns the updated value in sp[0];. .SS pusha \fIPush array address onto stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] array reference follows the command. .RE .PP Returns the array in sp[0]. .SS pushc \fIPush a data cell onto the evaluation stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] is a reference to the data to push .RE .PP Returns a reference to the result in sp[0]. .SS pushd \fIPush a double floating value onto the evaluation stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] is a reference to the data to push .RE .PP Returns a reference to the result in sp[0]. .SS pushi \fIPush contents of next referenced variable onto the evaluation stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] is a reference to the data cell to copy. .RE .PP Returns a reference to the result in sp[0]. .SS pushint \fIReserve the next slot on the evaluation stack, setting its type\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] holds the type to set in the new slot, e.g., for data via I/O redirection .RE .PP Returns a reference to the result in sp[0]. .SS pushs \fIPush a reference to a string value onto the evaluation stack\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0] holds a reference to the string value .RE .PP Returns a reference to the result in sp[0]. .SS rand \fIReturns a random number between zero and one.\fP. .PP Usage: .RS 5 rand() .RE .PP Parameters: .RS 5 .TP 5 none .RE .PP Returns the result in sp[0]. .SS range \fITest a range pattern: pat1, pat2 { action }\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 cdp[0].op a flag, test \fIpat1\fP if on else \fIpat2\fP .TP 5 cdp[1].op offset of \fIpat2\fP code from cdp .TP 5 cdp[2].op offset of action code from cdp .TP 5 cdp[3].op offset of code after the action from cdp .TP 5 cdp[4] start of \fIpat1\fP code .TP 5 sp[0] holds arguments for the action. .RE .SS ret \fIReturn a function value\fP. .PP Usage: .RS 5 return \fIvalue\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the return value .RE .PP When calling a function, \fB\*n\fP saves the current stack, creating a new one. On return, \fB\*n\fP restores the previous stack and returns the function value in sp[0]. .SS ret0 \fIReturn from a function without providing a return-value\fP. .PP Usage: .RS 5 return .RE .PP Parameters: .RS 5 .TP 5 sp[0] is modified to make the value uninitialized. .RE .PP As in the \fBret\fP operation, \fB\*n\fP restores the previous stack. After the return, sp[0] is an uninitialized value. .SS set_al \fIBegin an array \*(``in\*('' loop\fP. .PP Usage: .RS 5 for ( \fIiterator\fP in \fIarrayname\fP ) \fIstatement\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds a reference to the array .TP 5 sp[-1] holds a reference to the iteration variable .RE .PP \fB\*N\fP pushes a new entry onto the array loop stack, and updates cdp to point to the statement to execute. .SS sin \fICompute the sine of a value in radians\fP. .PP Usage: .RS 5 sin( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the value .RE .PP Returns the result in sp[0]. .SS sprintf \fIReturns a string constructed from expression-list according to format\fP. .PP Usage: .RS 5 sprintf( \fIformat\fP [, value1 [,... ] ] ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the last parameter value; there can be up to 255. .RE Returns the resulting string in sp[0]. .SS sqrt \fIReturns the square root of a value\fP. .PP Usage: .RS 5 sqrt( \fIvalue\fP 0 .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the value .RE .PP Returns the result in sp[0]. .SS srand \fISeeds the random number generator\fP. .PP Usage: .RS 5 srand( \fIvalue\fP ) .br srand( ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the seed value, which may be uninitialized .RE .PP Returns the previous seed value in sp[0]. .SS stop \fIFinish a range pattern\fP. .PP Usage: .RS 5 (internal state) .RE .PP Parameters: .RS 5 .TP 5 none .RE .SS strftime \fIFormats the given timestamp using the given format\fP. .PP Usage: .RS 5 strftime( \fIformat\fP , \fItimestamp\fP , \fIutc\fP ) .br strftime( \fIformat\fP , \fItimestamp\fP ) .br strftime( \fIformat\fP ) .br strftime( ) .RE .PP Parameters: .RS 5 .PP Zero to three parameters may be on the stack. If all three are used, they are as follows: .TP 5 sp[0] is the \fIutc\fP flag .TP 5 sp[-1] is the \fItimestamp\fP value .TP 5 sp[-2] is the \fIformat\fP .RE .PP Returns the result in sp[0]. .SS sub \fISubtract the second value from the first\fP. .PP Usage: .RS 5 \fIfirst\fP \- \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds the \fIsecond\fP value .TP 5 sp[-1] holds the \fIfirst\fP value .PP Returns the result in sp[0]. .RE .SS sub_asg \fIAssign the difference of two values to a variable\fP. .PP Usage: .RS 5 \fItarget\fP = \fIfirst\fP \- \fIsecond\fP .RE .PP Parameters: .RS 5 .TP 5 cdp[0] holds a reference to the variable to which to assign the result .TP 5 sp[0] holds the \fIsecond\fP value .TP 5 sp[-1] holds the \fIfirst\fP value .RE .PP Stores the difference in the \fItarget\fP, leaving sp[0] pointing to the \fItarget\fP. .SS substr \fIeturns the substring of string s, starting at index i, of length n\fP. .PP Usage: .RS 5 substr(s,i,n) .br substr(s,i) .RE .PP Parameters: .RS 5 .PP Two or three parameters may be on the stack. If all three are used, they are as follows: .TP 5 sp[0] holds the length \fIn\fP. .TP 5 sp[0] holds the index \fIi\fP. .TP 5 sp[0] holds the string \fIs\fP. .RE .SS system \fIExecutes a command, returning the wait-status\fP. .PP Usage: .RS 5 status = system( \fIcommand\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the command to execute .RE .PP Returns the wait-status in sp[0]. .SS systime \fIReturns the current time of day as the number of seconds since the Epoch\fP. .PP Usage: .RS 5 systime( ) .RE .PP Parameters: .RS 5 .TP 5 none .RE .PP Returns the result in sp[0]. .SS test \fITest a logical expression\fP. .PP Usage: .RS 5 \fIvalue\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] holds a value to test. .RE .PP Returns the result on the evaluation stack, i.e., 1 if the value is nonzero and 0 otherwise. .SS tolower \fICopy a string, converting to lowercase\fP. .PP Usage: .RS 5 tolower( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the value to convert .RE .PP Returns the result in sp[0]. .SS toupper \fICopy a string, converting to uppercase\fP. .PP Usage: .RS 5 toupper( \fIvalue\fP ) .RE .PP Parameters: .RS 5 .TP 5 sp[0] is the value to convert .RE .PP Returns the result in sp[0]. .SS uminus \fIUnitary minus\fP. .PP Usage: .RS 5 \- \fIvalue\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] contains a value to negate. As a side-effect, if the value is a string, it is cast to double floating point. .RE .PP Returns the result in sp[0]. .SS uplus \fIUnitary plus\fP. .PP Usage: .RS 5 + \fIvalue\fP .RE .PP Parameters: .RS 5 .TP 5 sp[0] contains a value to use. As a side-effect, if the value is a string, it is cast to double floating point. .PP Returns the result in sp[0]. .RE .SH "REGULAR EXPRESSIONS" .SS M_1J mandatory jump .SS M_2JA optional (undesirable) jump .SS M_2JB optional (desirable) jump .SS M_2JC pop pos'n, optional jump if advanced .SS M_ACCEPT end of match .SS M_ANY arbitrary character (.) .SS M_CLASS character class .SS M_END end of string ($) .SS M_SAVE_POS push position onto stack .SS M_START start of string (^) .SS M_STR matching a literal string .SS M_U arbitrary string (.*) mawk-1.3.4-20240123/man/Makefile.in0000644000000000000000000000376514554061433014707 0ustar rootroot# $MawkId: Makefile.in,v 1.7 2024/01/24 01:08:43 tom Exp $ ############################################################################### # copyright 2010-2023,2024 Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### # produce alternate forms from mawk's documentation. SHELL=/bin/sh srcdir = @srcdir@ VPATH = @srcdir@ prefix = @prefix@ datarootdir = @datarootdir@ mandir = @mandir@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ # these are overridden by top-level makefile PROGRAM = mawk TOPIC = SECTION = 1 # what/where to put the man pages (do not override) MANDIR = $(DESTDIR)$(mandir) TARGET_DIR = $(MANDIR)/man$(SECTION) SOURCE_ROOT = mawk$(TOPIC) TARGET_ROOT = $(PROGRAM)$(TOPIC) SOURCE_FILE = $(SOURCE_ROOT).$(SECTION) TARGET_FILE = $(TARGET_ROOT).$(SECTION) .SUFFIXES : .html .$(SECTION) .man .ps .pdf .doc .txt .$(SECTION).html : ../man2html.tmp $* $(SECTION) man >$@ .$(SECTION).ps : $(SHELL) -c "tbl $*.$(SECTION) | groff -man" >$@ .$(SECTION).doc : GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(SECTION) | nroff -Tascii -man" >$@ .$(SECTION).txt : GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(SECTION) | nroff -Tascii -man | col -bx" >$@ .ps.pdf : ps2pdf $*.ps ALL = \ $(SOURCE_ROOT).html \ $(SOURCE_ROOT).pdf \ $(SOURCE_ROOT).ps all: $(SOURCE_ROOT).txt $(SOURCE_ROOT).doc $(ALL) install: $(TARGET_DIR) @echo "$@ing $(TARGET_DIR)/$(TARGET_FILE) manpage" @$(INSTALL_DATA) $(SOURCE_FILE) $(TARGET_DIR)/$(TARGET_FILE) uninstall: @echo "$@ing $(TARGET_DIR)/$(TARGET_FILE) manpage" @-rm -f $(TARGET_DIR)/$(TARGET_FILE) clean: -rm -f $(ALL) distclean: clean rm -f Makefile maintainer-clean: clean rm -f $(SOURCE_ROOT).txt $(SOURCE_ROOT).doc $(SOURCE_ROOT).pdf : $(SOURCE_ROOT).ps $(TARGET_DIR) : mkdir -p "$@" mawk-1.3.4-20240123/man/mawk.10000644000000000000000000013261414554034101013647 0ustar rootroot.\" $MawkId: mawk.1,v 1.64 2024/01/23 22:05:53 tom Exp $ .\" ########################################################################### .\" # copyright 2008-2023,2024, Thomas E. Dickey .\" # copyright 1996, Michael D. Brennan .\" # .\" # This is a source file for mawk, an implementation of .\" # the AWK programming language. .\" # .\" # Mawk is distributed without warranty under the terms of .\" # the GNU General Public License, version 2, 1991. .\" ########################################################################### .ds N Mawk .ds n mawk .TH MAWK 1 2024-01-23 "Version 1.3.4" "User commands" .\" strings .ds ex \fIexpr\fR .\" Bulleted paragraph .de bP .ie n .IP \(bu 4 .el .IP \(bu 2 .. .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g \{\ .ds `` \(lq .ds '' \(rq .ds ' \(aq .\} .el \{\ .ie t .ds `` `` .el .ds `` "" .ie t .ds '' '' .el .ds '' "" .ie t .ds ' \(aq .el .ds ' ' .\} .\" ************************************************************************** .SH NAME mawk \- pattern scanning and text processing language .\" ************************************************************************** .SH SYNOPSIS \fB\*n\fP [\-\fBW .IR option ] [\-\fBF .IR value ] [\-\fBv .IR var=value ] [\-\|\-] 'program text' [file ...] .br \fB\*n\fP [\-\fBW .IR option ] [\-\fBF .IR value ] [\-\fBv .IR var=value ] [\-\fBf .IR program-file ] [\-\|\-] [file ...] .\" ************************************************************************** .SH DESCRIPTION \fB\*n\fP is an interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms. \fB\*n\fP is a \fInew awk\fR meaning it implements the AWK language as defined in Aho, Kernighan and Weinberger, .I "The AWK Programming Language," Addison-Wesley Publishing, 1988 (hereafter referred to as the AWK book.) \fB\*n\fP conforms to the POSIX 1003.2 (draft 11.3) definition of the AWK language which contains a few features not described in the AWK book, and \fB\*n\fP provides a small number of extensions. .PP An AWK program is a sequence of \fIpattern {action}\fR pairs and function definitions. Short programs are entered on the command line usually enclosed in ' ' to avoid shell interpretation. Longer programs can be read in from a file with the \-f option. Data input is read from the list of files on the command line or from standard input when the list is empty. The input is broken into records as determined by the record separator variable, \fBRS\fR. Initially, .B RS = \*(``\en\*('' and records are synonymous with lines. Each record is compared against each .I pattern and if it matches, the program text for .I "{action}" is executed. .\" ************************************************************************** .SH OPTIONS .TP \w'\-\fBW'u+\w'\fRsprintf=\fInum\fR'u+2n \-\fBF \fIvalue\fP sets the field separator, \fBFS\fR, to .IR value . .TP \-\fBf \fIfile\fR Program text is read from \fIfile\fR instead of from the command line. Multiple .B \-f options are allowed. .TP \-\fBv \fIvar=value\fR assigns .I value to program variable .IR var . .TP \-\|\- indicates the unambiguous end of options. .PP The above options will be available with any POSIX compatible implementation of AWK. Implementation specific options are prefaced with .BR \-W . \fB\*n\fP provides these: .TP \-\fBW \fRdump writes an assembler like listing of the internal representation of the program to stdout and exits 0 (on successful compilation). .TP \-\fBW \fRexec \fIfile\fR Program text is read from .I file and this is the last option. .IP This is a useful alternative to \-\fBf\fP on systems that support the .B #! \*(``magic number\*('' convention for executable scripts. Those implicitly pass the pathname of the script itself as the final parameter, and expect no more than one \*(``\-\*('' option on the \fB#!\fP line. Because \fB\*n\fP can combine multiple \-\fBW\fP options separated by commas, you can use this option when an additional \-\fBW\fP option is needed. .TP \-\fBW \fRhelp prints a usage message to stderr and exits (same as \*(``\-\fBW\ \fRusage\*(''). .TP \-\fBW \fRinteractive sets unbuffered writes to stdout and line buffered reads from stdin. Records from stdin are lines regardless of the value of .BR RS . .TP \-\fBW \fRposix modifies \fB\*n\fP's behavior to be more POSIX-compliant: .RS .bP forces \fB\*n\fP not to consider '\en' to be space. .RE .IP The original \*(``posix_space\*('' is recognized, but deprecated. .TP \-\fBW \fRrandom=\fInum\fR calls \fBsrand\fP with the given parameter (and overrides the auto-seeding behavior). .TP \-\fBW \fRsprintf=\fInum\fR adjusts the size of \fB\*n\fP's internal sprintf buffer to .I num bytes. More than rare use of this option indicates \fB\*n\fP should be recompiled. .TP \-\fBW \fRtraditional Omit features such as interval expressions which were not supported by traditional \fIawk\fP. .TP \-\fBW \fRusage prints a usage message to stderr and exits (same as \*(``\-\fBW\ \fRhelp\*(''). .TP \-\fBW \fRversion \fB\*n\fP writes its version and copyright to stdout and compiled limits to stderr and exits 0. .PP \fB\*n\fP accepts abbreviations for any of these options, e.g., \*(``\-\fBW\ \fRv\*('' and \*(``\-\fBW\fRv\*('' both tell \fB\*n\fP to show its version. .PP \fB\*n\fP allows multiple \fB\-W\fP options to be combined by separating the options with commas, e.g., \-Wsprint=2000,posix. This is useful for executable .B #! \*(``magic number\*('' invocations in which only one argument is supported, e.g., \-\fBWinteractive,exec\fP. .\" ************************************************************************** .SH "THE AWK LANGUAGE" .SS "\fB1. Program structure" An AWK program is a sequence of .I "pattern {action}" pairs and user function definitions. .PP A pattern can be: .nf .RS 5 \fBBEGIN\fR \fBEND\fR expression expression , expression .sp .RE .fi One, but not both, of \fIpattern {action}\fR can be omitted. If .I {action} is omitted it is implicitly { print }. If .I pattern is omitted, then it is implicitly matched. .B BEGIN and .B END patterns require an action. .PP Statements are terminated by newlines, semi-colons or both. Groups of statements such as actions or loop bodies are blocked via {\ ...\ } as in C. The last statement in a block doesn't need a terminator. Blank lines have no meaning; an empty statement is terminated with a semi-colon. Long statements can be continued with a backslash, \e\|. A statement can be broken without a backslash after a comma, left brace, &&, ||, .BR do , .BR else , the right parenthesis of an .BR if , .B while or .B for statement, and the right parenthesis of a function definition. A comment starts with # and extends to, but does not include the end of line. .PP The following statements control program flow inside blocks. .RS 5 .PP .B if ( \*(ex ) .I statement .PP .B if ( \*(ex ) .I statement .B else .I statement .PP .B while ( \*(ex ) .I statement .PP .B do .I statement .B while ( \*(ex ) .PP .B for ( \fIopt_expr\fR ; \fIopt_expr\fR ; \fIopt_expr\fR ) .I statement .PP .B for ( \fIvar \fBin \fIarray\fR ) .I statement .PP .B continue .PP .B break .RE .\" .SS "\fB2. Data types, conversion and comparison" There are two basic data types, numeric and string. Numeric constants can be integer like \-2, decimal like 1.08, or in scientific notation like \-1.1e4 or .28E\-3. All numbers are represented internally and all computations are done in floating point arithmetic. So for example, the expression 0.2e2 == 20 is true and true is represented as 1.0. .PP String constants are enclosed in double quotes. .sp .ce "This is a string with a newline at the end.\en" .sp Strings can be continued across a line by escaping (\e) the newline. The following escape sequences are recognized. .nf .sp \e\e \e \e" " \ea alert, ascii 7 \eb backspace, ascii 8 \et tab, ascii 9 \en newline, ascii 10 \ev vertical tab, ascii 11 \ef formfeed, ascii 12 \er carriage return, ascii 13 \eddd 1, 2 or 3 octal digits for ascii ddd \exhh 1 or 2 hex digits for ascii hh .sp .fi If you escape any other character \ec, you get \ec, i.e., \fB\*n\fP ignores the escape. .PP There are really three basic data types; the third is .I "number and string" which has both a numeric value and a string value at the same time. User defined variables come into existence when first referenced and are initialized to .IR null , a number and string value which has numeric value 0 and string value "". Non-trivial number and string typed data come from input and are typically stored in fields. (See section 4). .PP The type of an expression is determined by its context and automatic type conversion occurs if needed. For example, to evaluate the statements .nf .sp y = x + 2 ; z = x "hello" .sp .fi The value stored in variable y will be typed numeric. If x is not numeric, the value read from x is converted to numeric before it is added to 2 and stored in y. The value stored in variable z will be typed string, and the value of x will be converted to string if necessary and concatenated with "hello". (Of course, the value and type stored in x is not changed by any conversions.) A string expression is converted to numeric using its longest numeric prefix as with \fBatof\fP(3). A numeric expression is converted to string by replacing .I expr with .BR sprintf(CONVFMT , .IR expr ), unless .I expr can be represented on the host machine as an exact integer then it is converted to \fBsprintf\fR("%d", \*(ex). .B Sprintf() is an AWK built-in that duplicates the functionality of \fBsprintf\fP(3), and \fBCONVFMT\fP is a built-in variable used for internal conversion from number to string and initialized to "%.6g". Explicit type conversions can be forced, \*(ex "" is string and .IR expr +0 is numeric. .PP To evaluate, \*(ex\d1\u \fBrel-op\fR \*(ex\d2\u, if both operands are numeric or number and string then the comparison is numeric; if both operands are string the comparison is string; if one operand is string, the non-string operand is converted and the comparison is string. The result is numeric, 1 or 0. .PP In boolean contexts such as, \fBif\fR ( \*(ex ) \fIstatement\fR, a string expression evaluates true if and only if it is not the empty string ""; numeric values if and only if not numerically zero. .\" .SS "\fB3. Regular expressions" In the AWK language, records, fields and strings are often tested for matching a .IR "regular expression" . Regular expressions are enclosed in slashes, and .nf .sp \*(ex ~ /\fIr\fR/ .sp .fi is an AWK expression that evaluates to 1 if \*(ex \*(``matches\*('' .IR r , which means a substring of \*(ex is in the set of strings defined by .IR r . With no match the expression evaluates to 0; replacing ~ with the \*(``not match\*('' operator, !~ , reverses the meaning. As pattern-action pairs, .nf .sp /\fIr\fR/ { \fIaction\fR } and\ \fB$0\fR ~ /\fIr\fR/ { \fIaction\fR } .sp .fi are the same, and for each input record that matches .IR r , .I action is executed. In fact, /\fIr\fR/ is an AWK expression that is equivalent to (\fB$0\fR ~ /\fIr\fR/) anywhere except when on the right side of a match operator or passed as an argument to a built-in function that expects a regular expression argument. .PP AWK uses extended regular expressions as with the \fB\-E\fP option of \fBgrep\fP(1). The regular expression metacharacters, i.e., those with special meaning in regular expressions are .nf .sp \\ ^ $ . [ ] | ( ) * + ? { } .sp .fi If the command line option \fI-W traditional\fP is used, these are omitted: .nf .sp { } .sp .fi are also regular expression metacharacters, and in this mode, require escaping to be a literal character. Regular expressions are built up from characters as follows: .RS 5 .TP \w'[^c\d1\uc\d2\uc\d3\u...]'u+1n \fIc\fR matches any non-metacharacter .IR c . .TP \e\fIc\fR matches a character defined by the same escape sequences used in string constants or the literal character \fIc\fR if \e\fIc\fR is not an escape sequence. .TP \&\. matches any character (including newline). .TP ^ matches the front of a string. .TP $ matches the back of a string. .TP [c\d1\uc\d2\uc\d3\u...] matches any character in the class c\d1\uc\d2\uc\d3\u...\ . An interval of characters is denoted c\d1\u\-c\d2\u inside a class [...]. .TP [^c\d1\uc\d2\uc\d3\u...] matches any character not in the class c\d1\uc\d2\uc\d3\u... .RE .sp Regular expressions are built up from other regular expressions as follows: .RS 5 .TP \w'[^c\d1\uc\d2\uc\d3\u...]'u+1n \fIr\fR\d1\u\fIr\fR\d2\u matches \fIr\fR\d1\u followed immediately by \fIr\fR\d2\u (\fIconcatenation\fR). .sp .TP \fIr\fR\d1\u | \fIr\fR\d2\u matches \fIr\fR\d1\u or \fIr\fR\d2\u (\fIalternation\fR). .sp .TP \fIr\fR* matches \fIr\fR repeated zero or more times. .TP \fIr\fR+ matches \fIr\fR repeated one or more times. .TP \fIr\fR? matches \fIr\fR zero or once. (\fIrepetition\fR). .TP (\fIr\fR) matches \fIr\fR (\fIgrouping\fR). .sp .TP \fIr\fR{n} matches \fIr\fR exactly n times. .TP \fIr\fR{n,} matches \fIr\fR repeated n or more times. .TP \fIr\fR{n,m} matches \fIr\fR repeated n to m (inclusive) times. .TP \fIr\fR{,m} matches \fIr\fR repeated 0 to m times (a non-standard option). .RE .PP The increasing \fBprecedence of operators\fR is: .nf .sp alternation concatenation repetition grouping .sp .fi .PP For example, .nf .sp /^[_a\-zA\-Z][_a\-zA\-Z0\-9]*$/ and /^[\-+]?([0\-9]+\e\|.?|\e\|.[0\-9])[0\-9]*([eE][\-+]?[0\-9]+)?$/ .sp .fi are matched by AWK identifiers and AWK numeric constants respectively. Note that \*(``.\*('' has to be escaped to be recognized as a decimal point, and that metacharacters are not special inside character classes. .PP Any expression can be used on the right hand side of the ~ or !~ operators or passed to a built-in that expects a regular expression. If needed, it is converted to string, and then interpreted as a regular expression. For example, .nf .sp BEGIN { identifier = "[_a\-zA\-Z][_a\-zA\-Z0\-9]*" } $0 ~ "^" identifier .sp .fi prints all lines that start with an AWK identifier. .PP \fB\*n\fP recognizes the empty regular expression, //\|, which matches the empty string and hence is matched by any string at the front, back and between every character. For example, .nf .sp echo abc | \*n '{ gsub(//, "X")' ; print } XaXbXcX .sp .fi .\" .SS "\fB4. Records and fields" Records are read in one at a time, and stored in the .I field variable .BR $0 . The record is split into .I fields which are stored in .BR $1 , .BR $2 ", ...," .BR $NF . The built-in variable .B NF is set to the number of fields, and .B NR and .B FNR are incremented by 1. Fields above .B $NF are set to "". .PP Assignment to .B $0 causes the fields and .B NF to be recomputed. Assignment to .B NF or to a field causes .B $0 to be reconstructed by concatenating the .B $i's separated by .BR OFS . Assignment to a field with index greater than .BR NF , increases .B NF and causes .B $0 to be reconstructed. .PP Data input stored in fields is string, unless the entire field has numeric form and then the type is number and string. For example, .sp .nf echo 24 24E | \*n '{ print($1>100, $1>"100", $2>100, $2>"100") }' 0 1 1 1 .fi .sp .B $0 and .B $2 are string and .B $1 is number and string. The first comparison is numeric, the second is string, the third is string (100 is converted to "100"), and the last is string. .\" .SS "\fB5. Expressions and operators" The expression syntax is similar to C. Primary expressions are numeric constants, string constants, variables, fields, arrays and function calls. The identifier for a variable, array or function can be a sequence of letters, digits and underscores, that does not start with a digit. Variables are not declared; they exist when first referenced and are initialized to .IR null . .PP New expressions are composed with the following operators in order of increasing precedence. .PP .RS 5 .nf .vs +2p \" open up a little \fIassignment\fR = += \-= *= /= %= ^= \fIconditional\fR ? : \fIlogical or\fR || \fIlogical and\fR && \fIarray membership\fR \fBin \fImatching\fR ~ !~ \fIrelational\fR < > <= >= == != \fIconcatenation\fR (no explicit operator) \fIadd ops\fR + \- \fImul ops\fR * / % \fIunary\fR + \- \fIlogical not\fR ! \fIexponentiation\fR ^ \fIinc and dec\fR ++ \-\|\- (both post and pre) \fIfield\fR $ .vs .RE .PP .fi Assignment, conditional and exponentiation associate right to left; the other operators associate left to right. Any expression can be parenthesized. .\" .SS "\fB6. Arrays" .ds ae \fIarray\fR[\fIexpr\fR] Awk provides one-dimensional arrays. Array elements are expressed as \*(ae. .I Expr is internally converted to string type, so, for example, A[1] and A["1"] are the same element and the actual index is "1". Arrays indexed by strings are called associative arrays. Initially an array is empty; elements exist when first accessed. An expression, \fIexpr\fB in\fI array\fR evaluates to 1 if \*(ae exists, else to 0. .PP There is a form of the .B for statement that loops over each index of an array. .nf .sp \fBfor\fR ( \fIvar\fB in \fIarray \fR) \fIstatement\fR .sp .fi sets .I var to each index of .I array and executes .IR statement . The order that .I var transverses the indices of .I array is not defined. .PP The statement, .B delete \*(ae, causes \*(ae not to exist. \fB\*n\fP supports the .B delete .I array feature, which deletes all elements of .IR array . .PP Multidimensional arrays are synthesized with concatenation using the built-in variable .BR SUBSEP . \fIarray\fR[\fIexpr\fR\d1\u,\|\fIexpr\fR\d2\u] is equivalent to \fIarray\fR[\fIexpr\fR\d1\u \fBSUBSEP \fIexpr\fR\d2\u]. Testing for a multidimensional element uses a parenthesized index, such as .sp .nf if ( (i, j) in A ) print A[i, j] .fi .sp .\" .SS "\fB7. Builtin-variables\fR" The following variables are built-in and initialized before program execution. .RS 5 .TP .B ARGC number of command line arguments. .TP .B ARGV array of command line arguments, 0..ARGC\-1. .TP .B CONVFMT format for internal conversion of numbers to string, initially = "%.6g". .TP .B ENVIRON array indexed by environment variables. An environment string, \fIvar=value\fR is stored as \fBENVIRON\fR[\fIvar\fR] = .IR value . .TP .B FILENAME name of the current input file. .TP .B FNR current record number in .BR FILENAME . .TP .B FS splits records into fields as a regular expression. .TP .B NF number of fields in the current record. .TP .B NR current record number in the total input stream. .TP .B OFMT format for printing numbers; initially = "%.6g". .TP .B OFS inserted between fields on output, initially = " ". .TP .B ORS terminates each record on output, initially = "\en". .TP .B RLENGTH length set by the last call to the built-in function, .BR match() . .TP .B RS input record separator, initially = "\en". .TP .B RSTART index set by the last call to .BR match() . .TP .B SUBSEP used to build multiple array subscripts, initially = "\e034". .RE .\" .SS "\fB8. Built-in functions" .B String functions .RS 5 .TP gsub(\fIr,s,t\fR) gsub(\fIr,s\fR) Global substitution, every match of regular expression .I r in variable .I t is replaced by string .IR s . The number of replacements is returned. If .I t is omitted, .B $0 is used. An .I & in the replacement string .I s is replaced by the matched substring of .IR t . \e& and \e\e put literal & and \e, respectively, in the replacement string. .TP index(\fIs,t\fR) If .I t is a substring of .IR s , then the position where .I t starts is returned, else 0 is returned. The first character of .I s is in position 1. .TP length(\fIs\fR) Returns the length of string or array .IR s . .TP match(\fIs,r\fR) Returns the index of the first longest match of regular expression .I r in string .IR s . Returns 0 if no match. As a side effect, .B RSTART is set to the return value. .B RLENGTH is set to the length of the match or \-1 if no match. If the empty string is matched, .B RLENGTH is set to 0, and 1 is returned if the match is at the front, and length(\fIs\fR)+1 is returned if the match is at the back. .TP split(\fIs,A,r\fR) split(\fIs,A\fR) String .I s is split into fields by regular expression .I r and the fields are loaded into array .IR A . The number of fields is returned. See section 11 below for more detail. If .I r is omitted, .B FS is used. .TP sprintf(\fIformat,expr-list\fR) Returns a string constructed from .I expr-list according to .IR format . See the description of printf() below. .TP sub(\fIr,s,t\fR) sub(\fIr,s\fR) Single substitution, same as gsub() except at most one substitution. .TP substr(\fIs,i,n\fR) substr(\fIs,i\fR) Returns the substring of string .IR s , starting at index .IR i , of length .IR n . If .I n is omitted, the suffix of .IR s , starting at .I i is returned. .TP tolower(\fIs\fR) Returns a copy of .I s with all upper case characters converted to lower case. .TP toupper(\fIs\fR) Returns a copy of .I s with all lower case characters converted to upper case. .RE .PP .B Time functions .PP These are available on systems which support the corresponding C \fBmktime\fP and \fBstrftime\fP functions: .RS 5 .TP mktime(\fIspecification\fR) converts a date specification to a timestamp with the same units as \fBsystime\fP. The date specification is a string containing the components of the date as decimal integers: .RS .TP 3 .B YYYY the year, e.g., 2012 .TP 3 .B MM the month of the year starting at 1 .TP 3 .B DD the day of the month starting at 1 .TP 3 .B HH hour (0-23) .TP 3 .B MM minute (0-59) .TP 3 .B SS seconds (0-59) .TP 3 .B DST tells how to treat timezone versus daylight savings time: .RS 5 .TP 3 positive DST is in effect .TP 3 zero (default) DST is not in effect .TP 3 negative mktime() should (use timezone information and system databases to) attempt to determine whether DST is in effect at the specified time. .RE .RE .TP strftime([\fIformat\fR [, \fItimestamp\fP [, \fIutc\fP ]]]) formats the given timestamp using the format (passed to the C \fBstrftime\fP function): .RS .bP If the \fIformat\fP parameter is missing, "%c" is used. .bP If the \fItimestamp\fP parameter is missing, the current value from \fBsystime\fP is used. .bP If the \fIutc\fP parameter is present and nonzero, the result is in UTC. Otherwise local time is used. .RE .TP systime() returns the current time of day as the number of seconds since the Epoch (1970-01-01 00:00:00 UTC on POSIX systems). .RE .PP .B Arithmetic functions .RS 5 .ie n .ds Pi pi .el .ds Pi \\(*p .TP atan2(\fIy,x\fR) Arctan of \fIy\fR/\fIx\fR between \-\*(Pi and \*(Pi. .TP cos(\fIx\fR) Cosine function, \fIx\fR in radians. .TP exp(\fIx\fR) Exponential function. .TP int(\fIx\fR) Returns \fIx\fR truncated towards zero. .TP log(\fIx\fR) Natural logarithm. .TP rand() Returns a random number between zero and one. .TP sin(\fIx\fR) Sine function, \fIx\fR in radians. .TP sqrt(\fIx\fR) Returns square root of \fIx\fR. .TP srand(\fIexpr\fR) .TP srand() Seeds the random number generator, using the clock if \fIexpr\fP is omitted, and returns the value of the previous seed. Srand(\fIexpr\fR) is useful for repeating pseudo random sequences. .IP Note: \fB\*n\fP is normally configured to seed the random number generator from the clock at startup, making it unnecessary to call srand(). This feature can be suppressed via conditional compile, or overridden using the \fB\-Wrandom\fP option. .RE .\" .SS "\fB9. Input and output" There are two output statements, .B print and .BR printf . .RS 5 .TP print writes .B "$0 ORS" to standard output. .TP print \*(ex\d1\u, \*(ex\d2\u, ..., \*(ex\dn\u writes \*(ex\d1\u \fBOFS \*(ex\d2\u \fBOFS\fR ... \*(ex\dn\u .B ORS to standard output. Numeric expressions are converted to string with .BR OFMT . .TP printf \fIformat, expr-list\fR duplicates the printf C library function writing to standard output. The complete ANSI C format specifications are recognized with conversions %c, %d, %e, %E, %f, %g, %G, %i, %o, %s, %u, %x, %X and %%, and conversion qualifiers h and l. .RE .PP The argument list to print or printf can optionally be enclosed in parentheses. Print formats numbers using .B OFMT or "%d" for exact integers. "%c" with a numeric argument prints the corresponding 8 bit character, with a string argument it prints the first character of the string. The output of print and printf can be redirected to a file or command by appending > .IR file , >> .I file or | .I command to the end of the print statement. Redirection opens .I file or .I command only once, subsequent redirections append to the already open stream. By convention, \fB\*n\fP associates the filename .RS 3 .bP "/dev/stderr" with stderr, .bP "/dev/stdout" with stdout, .bP "\-" and "/dev/stdin" with stdin. .RE .PP The association with stderr is especially useful because it allows print and printf to be redirected to stderr. These names can also be passed to functions. .PP The input function .B getline has the following variations. .RS 5 .TP getline reads into .BR $0 , updates the fields, .BR NF , .B NR and .BR FNR . .TP getline < \fIfile\fR reads into .B $0 from \fIfile\fR, updates the fields and .BR NF . .TP getline \fIvar\fR reads the next record into .IR var , updates .B NR and .BR FNR . .TP getline \fIvar\fR < \fIfile\fR reads the next record of .I file into .IR var . .TP \fIcommand\fR | getline pipes a record from .I command into .B $0 and updates the fields and .BR NF . .TP \fIcommand\fR | getline \fIvar\fR pipes a record from .I command into .IR var . .RE .PP Getline returns 0 on end-of-file, \-1 on error, otherwise 1. .PP Commands on the end of pipes are executed by /bin/sh. .PP The function \fBclose\fR(\*(ex) closes the file or pipe associated with .IR expr . Close returns 0 if .I expr is an open file, the exit status if .I expr is a piped command, and \-1 otherwise. Close is used to reread a file or command, make sure the other end of an output pipe is finished or conserve file resources. .PP The function \fBfflush\fR(\*(ex) flushes the output file or pipe associated with .IR expr . Fflush returns 0 if .I expr is an open output stream else \-1. Fflush without an argument flushes stdout. Fflush with an empty argument ("") flushes all open output. .PP The function \fBsystem\fR(\fIexpr\fR) uses the C runtime \fBsystem\fP call to execute .I expr and returns the corresponding wait status of the command as follows: .bP if the \fBsystem\fP call failed, setting the status to -1, \fB\*n\fP returns that value. .bP if the command exited normally, \fB\*n\fP returns its exit-status. .bP if the command exited due to a signal such as \fBSIGHUP\fP, \fB\*n\fP returns the signal number plus 256. .PP Changes made to the .B ENVIRON array are not passed to commands executed with .B system or pipes. .SS "\fB10. User defined functions" The syntax for a user defined function is .nf .sp \fBfunction\fR name( \fIargs\fR ) { \fIstatements\fR } .sp .fi The function body can contain a return statement .nf .sp \fBreturn\fI opt_expr\fR .sp .fi A return statement is not required. Function calls may be nested or recursive. Functions are passed expressions by value and arrays by reference. Extra arguments serve as local variables and are initialized to .IR null . For example, csplit(\fIs,\|A\fR) puts each character of .I s into array .I A and returns the length of .IR s . .nf .sp function csplit(s, A, n, i) { n = length(s) for( i = 1 ; i <= n ; i++ ) A[i] = substr(s, i, 1) return n } .sp .fi Putting extra space between passed arguments and local variables is conventional. Functions can be referenced before they are defined, but the function name and the '(' of the arguments must touch to avoid confusion with concatenation. .sp A function parameter is normally a scalar value (number or string). If there is a forward reference to a function using an array as a parameter, the function's corresponding parameter will be treated as an array. .\" .SS "\fB11. Splitting strings, records and files" Awk programs use the same algorithm to split strings into arrays with split(), and records into fields on .BR FS . \fB\*n\fP uses essentially the same algorithm to split files into records on .BR RS . .PP Split(\fIexpr,\|A,\|sep\fR) works as follows: .RS 3 .TP 5 (1) If .I sep is omitted, it is replaced by .BR FS . .I Sep can be an expression or regular expression. If it is an expression of non-string type, it is converted to string. .TP (2) If .I sep = " " (a single space), then is trimmed from the front and back of .IR expr , and .I sep becomes . \fB\*n\fP defines as the regular expression /[\ \et\en]+/. Otherwise .I sep is treated as a regular expression, except that meta-characters are ignored for a string of length 1, e.g., split(x, A, "*") and split(x, A, /\e*/) are the same. .TP (3) If \*(ex is not string, it is converted to string. If \*(ex is then the empty string "", split() returns 0 and .I A is set empty. Otherwise, all non-overlapping, non-null and longest matches of .I sep in .IR expr , separate .I expr into fields which are loaded into .IR A . The fields are placed in A[1], A[2], ..., A[n] and split() returns n, the number of fields which is the number of matches plus one. Data placed in .I A that looks numeric is typed number and string. .RE .PP Splitting records into fields works the same except the pieces are loaded into .BR $1 , \fB$2\fR,..., .BR $NF . If .B $0 is empty, .B NF is set to 0 and all .B $i to "". .PP \fB\*n\fP splits files into records by the same algorithm, but with the slight difference that .B RS is really a terminator instead of a separator. (\fBORS\fR is really a terminator too). .RS 5 .PP E.g., if .B FS = \*(``:+\*('' and .B $0 = \*(``a::b:\*('' , then .B NF = 3 and .B $1 = \*(``a\*('', .B $2 = \*(``b\*('' and .B $3 = "", but if \*(``a::b:\*('' is the contents of an input file and .B RS = \*(``:+\*('', then there are two records \*(``a\*('' and \*(``b\*(''. .RE .PP .B RS = " " is not special. .PP If .B FS = "", then \fB\*n\fP breaks the record into individual characters, and, similarly, split(\fIs,A,\fR"") places the individual characters of .I s into .IR A . .\" .SS "\fB12. Multi-line records" Since \fB\*n\fP interprets .B RS as a regular expression, multi-line records are easy. Setting .B RS = "\en\en+", makes one or more blank lines separate records. If .B FS = " " (the default), then single newlines, by the rules for above, become space and single newlines are field separators. .RS 5 .PP For example, if .bP a file is "a\ b\enc\en\en", .bP \fBRS\fP = "\en\en+" and .bP \fBFS\fP = "\ ", .PP then there is one record \*(``a\ b\enc\*('' with three fields \*(``a\*('', \*(``b\*('' and \*(``c\*('': .bP using .B FS = \*(``\en\*('', gives two fields \*(``a b\*('' and \*(``c\*(''; .bP using .B FS = \*(``\*('', gives one field identical to the record. .RE .PP If you want lines with spaces or tabs to be considered blank, set .B RS = \*(``\en([\ \et]*\en)+\*(''. For compatibility with other awks, setting .B RS = "" has the same effect as if blank lines are stripped from the front and back of files and then records are determined as if .B RS = \*(``\en\en+\*(''. POSIX requires that \*(``\en\*('' always separates records when .B RS = "" regardless of the value of .BR FS . \fB\*n\fP does not support this convention, because defining \*(``\en\*('' as makes it unnecessary. .\" .PP Most of the time when you change .B RS for multi-line records, you will also want to change .B ORS to \*(``\en\en\*('' so the record spacing is preserved on output. .\" .SS "\fB13. Program execution" This section describes the order of program execution. First .B ARGC is set to the total number of command line arguments passed to the execution phase of the program. .bP .B ARGV[0] is set to the name of the AWK interpreter and .bP \fBARGV[1]\fR ... .B ARGV[ARGC\-1] holds the remaining command line arguments exclusive of options and program source. .PP For example, with .nf .sp \*n \-f prog v=1 A t=hello B .sp .fi .B ARGC = 5 with .RS .B ARGV[0] = "\*n", .br .B ARGV[1] = "v=1", .br .B ARGV[2] = "A", .br .B ARGV[3] = "t=hello" and .br .B ARGV[4] = "B". .RE .PP Next, each .B BEGIN block is executed in order. If the program consists entirely of .B BEGIN blocks, then execution terminates, else an input stream is opened and execution continues. If .B ARGC equals 1, the input stream is set to stdin, else the command line arguments .BR ARGV[1] " ..." .B ARGV[ARGC\-1] are examined for a file argument. .PP The command line arguments divide into three sets: file arguments, assignment arguments and empty strings "". An assignment has the form \fIvar\fR=\fIstring\fR. When an .B ARGV[i] is examined as a possible file argument, if it is empty it is skipped; if it is an assignment argument, the assignment to .I var takes place and .B i skips to the next argument; else .B ARGV[i] is opened for input. If it fails to open, execution terminates with exit code 2. If no command line argument is a file argument, then input comes from stdin. Getline in a .B BEGIN action opens input. \*(``\-\*('' as a file argument denotes stdin. .PP Once an input stream is open, each input record is tested against each .IR pattern , and if it matches, the associated .I action is executed. An expression pattern matches if it is boolean true (see the end of section 2). A .B BEGIN pattern matches before any input has been read, and an .B END pattern matches after all input has been read. A range pattern, \fIexpr\fR1,\|\fIexpr\fR2 , matches every record between the match of .IR expr 1 and the match .IR expr 2 inclusively. .PP When end of file occurs on the input stream, the remaining command line arguments are examined for a file argument, and if there is one it is opened, else the .B END .I pattern is considered matched and all .B END .I actions are executed. .PP In the example, the assignment v=1 takes place after the .B BEGIN .I actions are executed, and the data placed in v is typed number and string. Input is then read from file A. On end of file A, t is set to the string "hello", and B is opened for input. On end of file B, the .B END .I actions are executed. .PP Program flow at the .I pattern .I {action} level can be changed with the .nf .sp \fBnext \fBnextfile \fBexit \fIopt_expr\fR .sp .fi statements: .bP A .B next statement causes the next input record to be read and pattern testing to restart with the first .I "pattern {action}" pair in the program. .bP A .B nextfile statement tells \fB\*n\fP to stop processing the current input file. It then updates FILENAME to the next file listed on the command line, and resets FNR to 1. .bP An .B exit statement causes immediate execution of the .B END actions or program termination if there are none or if the .B exit occurs in an .B END action. The .I opt_expr sets the exit value of the program unless overridden by a later .B exit or subsequent error. .\" ************************************************************************** .SH ENVIRONMENT \fB\*N\fP recognizes these variables: .RS 3 .TP 3 MAWKBINMODE (see \fBCOMPATIBILITY\fP) .TP MAWK_LONG_OPTIONS If this is set, \fB\*n\fP uses its value to decide what to do with GNU-style long options: .RS 5 .TP allow \fB\*N\fP allows the option to be checked against the (small) set of long options it recognizes. .IP The long names from the \fB\-W\fP option are recognized, e.g., \fB\-\-version\fP is derived from \fB\-Wversion\fP. .TP error \fB\*N\fP prints an error message and exits. This is the default. .TP ignore \fB\*N\fP ignores the option, unless it happens to be one of the one it recognizes. .TP warn Print an warning message and otherwise ignore the option. .RE .IP If the variable is unset, \fB\*n\fP prints an error message and exits. .TP WHINY_USERS This is a \fBgawk\fP 3.1.0 feature, removed in the 4.0.0 release. It tells \fB\*n\fP to sort array indices before it starts to iterate over the elements of an array. .RE .\" ************************************************************************** .SH "COMPATIBILITY" .SS "MAWK 1.3.3 versus POSIX 1003.2 Draft 11.3" The POSIX 1003.2(draft 11.3) definition of the AWK language is AWK as described in the AWK book with a few extensions that appeared in SystemVR4 nawk. The extensions are: .RS 3 .bP New functions: toupper() and tolower(). .bP New variables: ENVIRON[\|] and CONVFMT. .bP ANSI C conversion specifications for printf() and sprintf(). .bP New command options: \-v var=value, multiple \-f options and implementation options as arguments to \-W. .bP For systems (MS-DOS or Windows) which provide a \fIsetmode\fP function, an environment variable MAWKBINMODE and a built-in variable BINMODE. The bits of the BINMODE value tell \fB\*n\fP how to modify the \fBRS\fP and \fBORS\fP variables: .RS .TP 3 0 set standard input to binary mode, and if BIT-2 is unset, set \fBRS\fP to "\\r\\n" (CR/LF) rather than "\\n" (LF). .TP 3 1 set standard output to binary mode, and if BIT-2 is unset, set \fBORS\fP to "\\r\\n" (CR/LF) rather than "\\n" (LF). .TP 3 2 suppress the assignment to \fBRS\fP and \fBORS\fP of CR/LF, making it possible to run scripts and generate output compatible with Unix line-endings. .RE .RE .sp POSIX AWK is oriented to operate on files a line at a time. .B RS can be changed from "\en" to another single character, but it is hard to find any use for this \(em there are no examples in the AWK book. By convention, \fBRS\fR = "", makes one or more blank lines separate records, allowing multi-line records. When \fBRS\fR = "", "\en" is always a field separator regardless of the value in .BR FS . .PP .BR \*n , on the other hand, allows .B RS to be a regular expression. When "\en" appears in records, it is treated as space, and .B FS always determines fields. .PP Removing the line at a time paradigm can make some programs simpler and can often improve performance. For example, redoing example 3 from above, .nf .sp BEGIN { RS = "[^A\-Za\-z]+" } { word[ $0 ] = "" } END { delete word[ "" ] for( i in word ) cnt++ print cnt } .sp .fi counts the number of unique words by making each word a record. On moderate size files, \fB\*n\fP executes twice as fast, because of the simplified inner loop. .PP The following program replaces each comment by a single space in a C program file, .nf .sp BEGIN { RS = "/\|\e*([^*]\||\|\e*+[^/*])*\e*+/" # comment is record separator ORS = " " getline hold } { print hold ; hold = $0 } END { printf "%s" , hold } .sp .fi Buffering one record is needed to avoid terminating the last record with a space. .PP With .BR \*n , the following are all equivalent, .nf .sp x ~ /a\e+b/ x ~ "a\e+b" x ~ "a\e\e+b" .sp .fi The strings get scanned twice, once as string and once as regular expression. On the string scan, \fB\*n\fP ignores the escape on non-escape characters while the AWK book advocates .I \ec be recognized as .I c which necessitates the double escaping of meta-characters in strings. POSIX explicitly declines to define the behavior which passively forces programs that must run under a variety of awks to use the more portable but less readable, double escape. .PP POSIX AWK does not recognize "/dev/std{in,out,err}". Some systems provide an actual device for this, allowing AWKs which do not implement the feature directly to support it. .PP POSIX AWK does not recognize \ex hex escape sequences in strings. Unlike ANSI C, \fB\*n\fP limits the number of digits that follows \ex to two as the current implementation only supports 8 bit characters. .PP POSIX explicitly leaves the behavior of .B FS = "" undefined, and mentions splitting the record into characters as a possible interpretation, but currently this use is not portable across implementations. .PP Some features were not part of the POSIX standard until long after their introduction in \fB\*n\fP and other implementations. These have been approved, though still (as of July 2020), are not part of a published standard: .bP The built-in .B fflush first appeared in a 1993 AT&T awk released to netlib. It was approved for the POSIX standard in 2012. .bP Aggregate deletion with .B delete .I array was approved in 2018. .SS "Random numbers" POSIX does not prescribe a method for initializing random numbers at startup. .PP In practice, most implementations do nothing special, which makes \fBsrand\fP and \fBrand\fP follow the C runtime library, making the initial seed value 1. Some implementations (Solaris XPG4 and Tru64) return 0 from the first call to \fBsrand\fP, although the results from \fBrand\fP behave as if the initial seed is 1. Other implementations return 1. .PP While \fB\*n\fP can call \fBsrand\fP at startup with no parameter (initializing random numbers from the clock), this feature may be suppressed using conditional compilation. . .SS "Extensions added for compatibility for GAWK and BWK" .B Nextfile is a \fBgawk\fP extension (also implemented by BWK awk). It was approved for the POSIX standard in September 2012, and is expected to be part of the next revision of the standard. .PP .BR Mktime , .BR strftime \ and .B systime are \fBgawk\fP extensions. .PP The "/dev/stdin" feature was added to \fB\*n\fP after 1.3.4, for compatibility with \fBgawk\fP and BWK awk. The corresponding "-" (alias for /dev/stdin) was present in \fB\*n\fR 1.3.3. .PP Interval expressions, e.g., a range \fI{m,n}\fP in Extended Regular Expressions (EREs), were not supported in awk (or even the original \*(``nawk\*(''): .bP Gawk provided this feature in 1991 (and later, in 1998, options for turning it off, for compatibility with \*(``traditional awk\*(''). .bP Interval expressions, were introduced into \fIawk\fP regular expressions in IEEE 1003.1-2001 (also known as Unix 03), along with some internationalization features. .bP Apple modified its copy of the original awk in April 2006, making this version of awk support interval expressions. .IP The updated source provides for compatibility with older \*(``legacy\*('' versions using an environment variable, making this \*(``Unix 2003\*('' feature (perhaps meant as Unix 03) the default. .bP NetBSD developers copied this change in January 2018, omitting the compatibility option, and then applied it to BWK awk. .bP The interval expression implementation in \fB\*n\fP is based on changes proposed by James Parkinson in April 2016. .PP \fB\*N\fP also recognizes a few gawk-specific command line options for script compatibility: .RS 5 .sp .hy 0 .na \fB\-\-help\fP, \fB\-\-posix\fP, \fB\-r\fP, \fB\-\-re\-interval\fP, \fB\-\-traditional\fP, \fB\-\-version\fP .ad .hy .RE . .SS "Subtle Differences not in POSIX or the AWK Book" Finally, here is how \fB\*n\fP handles exceptional cases not discussed in the AWK book or the POSIX draft. It is unsafe to assume consistency across awks and safe to skip to the next section. .PP .RS 3 .bP substr(s, i, n) returns the characters of s in the intersection of the closed interval [1, length(s)] and the half-open interval [i, i+n). When this intersection is empty, the empty string is returned; so substr("ABC", 1, 0) = "" and substr("ABC", \-4, 6) = "A". .bP Every string, including the empty string, matches the empty string at the front so, s ~ // and s ~ "", are always 1 as is match(s, //) and match(s, ""). The last two set .B RLENGTH to 0. .bP index(s, t) is always the same as match(s, t1) where t1 is the same as t with metacharacters escaped. Hence consistency with match requires that index(s, "") always returns 1. Also the condition, index(s,t) != 0 if and only t is a substring of s, requires index("","") = 1. .bP If getline encounters end of file, getline var, leaves var unchanged. Similarly, on entry to the .B END actions, .BR $0 , the fields and .B NF have their value unaltered from the last record. .RE .\" ************************************************************************** .SH BUGS \fB\*n\fP implements \fBprintf()\fR and \fBsprintf()\fR using the C library functions, printf and sprintf, so full ANSI compatibility requires an ANSI C library. In practice this means the h conversion qualifier may not be available. .sp Also \fB\*n\fP inherits any bugs or limitations of the library functions. .PP Implementors of the AWK language have shown a consistent lack of imagination when naming their programs. .\" ************************************************************************** .SH EXAMPLES .nf 1. emulate cat. { print } 2. emulate wc. { chars += length($0) + 1 # add one for the \en words += NF } END{ print NR, words, chars } 3. count the number of unique \*(``real words\*(''. BEGIN { FS = "[^A\-Za\-z]+" } { for(i = 1 ; i <= NF ; i++) word[$i] = "" } END { delete word[""] for ( i in word ) cnt++ print cnt } .fi 4. sum the second field of every record based on the first field. .nf $1 ~ /credit\||\|gain/ { sum += $2 } $1 ~ /debit\||\|loss/ { sum \-= $2 } END { print sum } 5. sort a file, comparing as string { line[NR] = $0 "" } # make sure of comparison type # in case some lines look numeric END { isort(line, NR) for(i = 1 ; i <= NR ; i++) print line[i] } #insertion sort of A[1..n] function isort( A, n, i, j, hold) { for( i = 2 ; i <= n ; i++) { hold = A[j = i] while ( A[j\-1] > hold ) { j\-\|\- ; A[j+1] = A[j] } A[j] = hold } # sentinel A[0] = "" will be created if needed } .fi .\" ************************************************************************** .SH AUTHORS Mike Brennan (brennan@whidbey.com). .br Thomas E. Dickey . .\" ************************************************************************** .SH SEE ALSO \fBgrep\fP(1) .PP Aho, Kernighan and Weinberger, .IR "The AWK Programming Language" , Addison-Wesley Publishing, 1988, (the AWK book), defines the language, opening with a tutorial and advancing to many interesting programs that delve into issues of software design and analysis relevant to programming in any language. .PP .IR "The GAWK Manual" , The Free Software Foundation, 1991, is a tutorial and language reference that does not attempt the depth of the AWK book and assumes the reader may be a novice programmer. The section on AWK arrays is excellent. It also discusses POSIX requirements for AWK. .PP \fBmawk-arrays\fP(7) discusses \fB\*n\fP's implementation of arrays. .PP \fBmawk-code\fP(7) gives more information on the \fB\-W\ dump\fP option. mawk-1.3.4-20240123/man/mawk-arrays.70000644000000000000000000003724014554052751015166 0ustar rootroot.\" $MawkId: mawk-arrays.7,v 1.14 2024/01/24 00:12:25 tom Exp $ .\" ########################################################################### .\" # copyright 2008-2020,2024, Thomas E. Dickey .\" # copyright 1996, Michael D. Brennan .\" # .\" # This is a source file for mawk, an implementation of .\" # the AWK programming language. .\" # .\" # Mawk is distributed without warranty under the terms of .\" # the GNU General Public License, version 2, 1991. .\" ########################################################################### .ds N Mawk .ds n mawk .TH MAWK-ARRAYS 7 2024-01-23 "Version 1.3.4" Miscellaneous .\" Bulleted paragraph .de bP .ie n .IP \(bu 4 .el .IP \(bu 2 .. .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g \{\ .ds `` \(lq .ds '' \(rq .ds ' \(aq .\} .el \{\ .ie t .ds `` `` .el .ds `` "" .ie t .ds '' '' .el .ds '' "" .ie t .ds ' \(aq .el .ds ' ' .\} .\" superscript .de SU .ie n \\$1**(\\$2)\\$3 .el \\$1\u\s-1\\$2\s+1\d\\$3 .. .\" ************************************************************************** .SH NAME mawk-arrays \- design notes for mawk's array implementation .\" ************************************************************************** .SH SYNOPSIS This is the documentation for the \fB\*n\fP implementation of awk arrays. Arrays in awk are associations of strings to awk scalar values. The \fB\*n\fP implementation stores the associations in hash tables. The hash table scheme was influenced by and is similar to the design presented in Griswold and Townsend, .IR "The Design and Implementation of Dynamic Hashing Sets and Tables in Icon" , .BR "Software Practice and Experience" , 23, 351-367, 1993. .SH "DATA STRUCTURES" .SS "Array Structure" The type \fBARRAY\fP is a pointer to a \fBstruct array\fP. The \fIsize\fP field is the number of elements in the table. The meaning of the other fields depends on the \fItype\fP field. .PP There are three types of arrays and these are distinguished by the \fItype\fP field in the structure. The types are: .TP 5 \fBAY_NULL\fP The array is empty and the \fIsize\fP field is always zero. The other fields have no meaning. .TP 5 \fBAY_SPLIT\fP The array was created by the \fIAWK\fP built-in \fIsplit\fP. The return value from \fIsplit\fP is stored in the \fIsize\fP field. The \fIptr\fP field points at a vector of \fBCELL\fPs. The number of \fBCELL\fPs is the \fIlimit\fP field. It is always true that \fIsize\fP\ \[<=]\ \fIlimit\fP. The address of \fIA[i\fP] is \fI(CELL*)A->ptr+i-1\fP for 1\[<=]\ \fIi\fP\ \[<=] \fIsize\fP. The \fIhmask\fP field has no meaning. .TP 5 \fIHash Table\fP The array is a hash table. If the \fBAY_STR\fP bit in the \fItype\fP field is set, then the table is keyed on strings. If the \fBAY_INT\fP bit in the \fItype\fP field is set, then the table is keyed on integers. Both bits can be set, and then the two keys are consistent, i.e., look up of \fIA[-14\fP] and \fIA["-14"\fP] will return identical \fICELL\fP pointers although the look up methods will be different. In this case, the \fIsize\fP field is the number of hash nodes in the table. When insertion of a new element would cause \fIsize\fP to exceed \fIlimit\fP, the table grows by doubling the number of hash chains. The invariant, (\fIhmask\fP+1)\fImax\_ave\_list\_length\fP=\fIlimit\fP is always true. \fIMax\_ave\_list\_length\fP is a tunable constant. .SS "Hash Tables" The hash tables are linked lists of nodes, called \fBANODE\fPs. The number of lists is \fIhmask+1\fP which is always a power of two. The \fIptr\fP field points at a vector of list heads. Since there are potentially two types of lists, integer lists and strings lists, each list head is a structure, \fIDUAL_LINK\fP. .PP The string lists are chains connected by \fIslinks\fP and the integer lists are chains connected by \fIilinks\fP. We sometimes refer to these lists as slists and ilists, respectively. The elements on the lists are \fBANODE\fPs. The fields of an \fBANODE\fP are: .PP \fIslink\fP The link field for slists. \fIilink\fP The link field for ilists. \fIsval\fP If non-null, then \fIsval\fP is a pointer to a string key. For a given table, if the \fBAY_STR\fP bit is set then every \fBANODE\fP has a non-null \fIsval\fP field and conversely, if \fBAY_STR\fP is not set, then every \fIsval\fP field is null. .PP \fIhval\fP The hash value of \fIsval\fP. This field has no meaning if \fIsval\fP is null. .PP \fIival\fP The integer key. The field has no meaning if set to the constant, \fINOT_AN_IVALUE\fP. If the \fBAY_STR\fP bit is off, then every \fBANODE\fP will have a valid \fIival\fP field. If the \fBAY_STR\fP bit is on, then the \fIival\fP field may or may not be valid. .PP \fIcell\fP The data field in the hash table. \endhitems .PP So the value of \fIA\fP[\fIexpr\fP is stored in the \fIcell\fP field, and if \fIexpr\fP is an integer, then \fIexpr\fP is stored in \fIival\fP, else it is stored in \fIsval\fP. .SH "ARRAY OPERATIONS" The functions that operate on arrays are, .TP 5 \fICELL* array_find(ARRAY A, CELL *cp, int create_flag)\fP returns a pointer to \fIA\fP[\fIexpr\fP] where \fIcp\fP is a pointer to the \fICELL\fP holding \fIexpr\fP. If the \fIcreate_flag\fP is on and \fIexpr\fP is not an element of \fIA\fP, then the element is created with value \fInull\fP. .TP 5 \fIvoid array_delete(ARRAY A, CELL *cp)\fP removes an element \fIA\fP[\fIexpr\fP from the array \fIA\fP. \fIcp\fP points at the \fICELL\fP holding \fIexpr\fP. .TP 5 \fIvoid array_load(ARRAY A, size_t cnt)\fP builds a split array. The values \fIA[1..cnt\fP] are moved into \fIA\fP from an anonymous buffer with \fItransfer_to_array()\fP which is declared in \fIsplit.h\fP. .TP 5 \fIvoid array_clear(ARRAY A)\fP removes all elements of \fIA\fP. The type of \fIA\fP is then \fBAY_NULL\fP. .TP 5 \fISTRING** array_loop_vector(ARRAY A, size_t *sizep)\fP returns a pointer to a linear vector that holds all the strings that are indices of \fIA\fP. The size of the the vector is returned indirectly in \fI*sizep\fP. If \fIA->size\fP\[==]\fB0\fP, a \fInull\fP pointer is returned. .TP 5 \fICELL* array_cat(CELL *sp, int cnt)\fP concatenates the elements of \fIsp[1-cnt..0]\fP, with each element separated by \fISUBSEP\fP, to compute an array index. For example, on a reference to \fIA\fP[i,j], \fIarray_cat\fP computes \fIi\fP \[ci] \fISUBSEP \[ci] \fIj\fP where \[ci] denotes concatenation. .SS "Array Find" Any reference to A[\fIexpr\fP] creates a call to \fIarray_find(A,cp,CREATE)\fP where \fIcp\fP points at the cell holding \fIexpr\fP. The test, \fIexpr\fP \fBin\fP \fIA\fP, creates a call to \fIarray_find(A,cp,NO_CREATE)\fP. \fIArray_find\fP is a hash-table lookup function that handles two cases: .TP 5 1. If \fI*cp\fP is numeric and integer valued, then lookup by integer value using \fIfind_by_ival\fP. If \fI*cp\fP is numeric, but not integer valued, then convert to string with \fIsprintf(CONVFMT,...)\fP and go to case~2. .TP 5 2. If \fI*cp\fP is string valued, then lookup by string value using \fIfind_by_sval\fP. \endlist .PP To test whether \fIcp->dval\fP is integer, we convert to the nearest integer by rounding towards zero (done by \fIdo_to_I\fP) and then cast back to double. If we get the same number we started with, then \fIcp->dval\fP is integer valued. .PP When we get to the function \fIfind_by_ival\fP, the search has been reduced to lookup in a hash table by integer value. .PP When a search by integer value fails, we have to check by string value to correctly handle the case insertion by \fIA["123"\fP] and later search as \fIA[123\fP]. This string search is necessary if and only if the \fBAY_STR\fP bit is set. An important point is that all \fBANODE\fPs get created with a valid \fIsval\fP if \fBAY_STR\fP is set, because then creation of new nodes always occurs in a call to \fIfind_by_sval\fP. .PP Searching by string value is easier because \fIAWK\fP arrays are really string associations. If the array does not have the \fBAY_STR\fP bit set, then we have to convert the array to a dual hash table with strings which is done by the function \fIadd_string_associations\fP. .PP One \fIInt\fP value is reserved to show that the \fIival\fP field is invalid. This works because \fId_to_I\fP returns a value in \fI[-Max_Int, Max_Int\fP]. .PP On entry to \fIadd_string_associations\fP, we know that the \fBAY_STR\fP bit is not set. We convert to a dual hash table, then walk all the integer lists and put each \fBANODE\fP on a string list. .SS "Array Delete" The execution of the statement, \fBdelete\fP \fIA\fP[\fIexpr\fP], creates a call to \fIarray_delete(ARRAY A, CELL *cp)\fP. Depending on the type of \fI*cp\fP, the call is routed to \fIfind_by_sval\fP or \fIfind_by_ival\fP. Each of these functions leaves its return value on the front of an \fIslist\fP or \fIilist\fP, respectively, and then it is deleted from the front of the list. The case where \fIA\fP[\fIexpr\fP is on two lists, e.g., \fIA[12\fP] and \fIA["12"\fP] is checked by examining the \fIsval\fP and \fIival\fP fields of the returned \fBANODE*\fP. .PP Even though we found a node by searching an \fIilist\fP it might also be on an \fIslist\fP and vice-versa. .PP When the size of a hash table drops below a certain value, it might be profitable to shrink the hash table. Currently we don't do this, because our guess is that it would be a waste of time for most \fIAWK\fP applications. However, we do convert an array to \fBAY_NULL\fP when the size goes to zero which would resize a large hash table that had been completely cleared by successive deletions. .SS "Building an Array with Split" A simple operation is to create an array with the \fIAWK\fP primitive \fIsplit\fP. The code that performs \fIsplit\fP puts the pieces in an anonymous buffer. \fIarray_load(A, cnt)\fP moves the \fIcnt\fP elements from the anonymous buffer into \fIA\fP. This is the only way an array of type \fBAY_SPLIT\fP is created. .PP If the array \fIA\fP is a split array and big enough then we reuse it, otherwise we need to allocate a new split array. When we allocate a block of \fBCELL\fPs for a split array, we round up to a multiple of 4. .SS "Array Clear" The function \fIarray_clear(ARRAY A)\fP converts \fIA\fP to type \fBAY_NULL\fP and frees all storage used by \fIA\fP except for the \fIstruct array\fP itself. This function gets called in three contexts: .TP 5 (1) when an array local to a user function goes out of scope, .TP 5 (2) execution of the \fIAWK\fP statement, \fIdelete A\fP and .TP 5 (3) when an existing changes type or size from \fIsplit()\fP. .SS "Constructor and Conversions" Arrays are always created as empty arrays of type \fBAY_NULL\fP. Global arrays are never destroyed although they can go empty or have their type change by conversion. The only constructor function is a macro. .PP Hash tables only get constructed by conversion. This happens in two ways. The function \fImake_empty_table\fP converts an empty array of type \fBAY_NULL\fP to an empty hash table. The number of lists in the table is a power of 2 determined by the constant \fISTARTING_HMASK\fP. The limit size of the table is determined by the constant \fIMAX_AVE_LIST_LENGTH\fP which is the largest average size of the hash lists that we are willing to tolerate before enlarging the table. When \fIA->size\fP exceeds \fIA->limit\fP, the hash table grows in size by doubling the number of lists. \fIA->limit\fP is then reset to \fIMAX_AVE_LIST_LENGTH\fP times \fIA->hmask+1\fP. .PP The other way a hash table gets constructed is when a split array is converted to a hash table of type \fBAY_INT\fP. .PP To determine the size of the table, we set the initial size to \fISTARTING_HMASK+1\fP and then double the size until \fIA->size\fP\ \[<=]\ \fIA->limit\fP. .SS "Doubling the Size of a Hash Table" The whole point of making the table size a power of two is to facilitate resizing the table. If the table size is .SU 2 n and \fIh\fP is the hash key, then \fIh\fP\ \fBmod\fP .SU 2 n is the hash chain index which can be calculated with bit-wise and, \fIh\fP & .SU (2 n-1 ). When the table size doubles, the new bit-mask has one more bit turned on. Elements of an old hash chain whose hash value have this bit turned on get moved to a new chain. Elements with this bit turned off stay on the same chain. On average only half the old chain moves to the new chain. If the old chain is at \fItable\fP[i],\ 0\ \[<=]\ \fIi\fP < .SU 2 n , then the elements that move, all move to the new chain at \fItable\fP[i + .SU 2 n ]. .PP As we walk an old string list with pointer \fIp\fP, the expression \fIp->hval & new_hmask\fP takes one of two values. If it is equal to \fIp->hval & old_hmask\fP (which equals \fIi\fP), then the node stays otherwise it gets moved to a new string list at \fIj\fP. The new string list preserves order so that the positions of the move-to-the-front heuristic are preserved. Nodes moving to the new list are appended at pointer \fItail\fP. The \fBANODE\fPs, \fIdummy0\fP~and \fIdummy1\fP, are sentinels that remove special handling of boundary conditions. .PP The doubling of the integer lists is exactly the same except that \fIslink\fP is replaced by \fIilink\fP and \fIhval\fP is replaced by \fIival\fP. .SS "Array Loops" Our mechanism for dealing with execution of the statement, .RS .PP \fBfor \fP(\fIi\fP in \fIA\fP) { \fIstatements\fP } .RE .PP is simple. We allocate a vector of \fISTRING*\fP of size, \fIA->size\fP. Each element of the vector is a string key for~\fIA\fP. Note that if the \fBAY_STR\fP bit of \fIA\fP is not set, then \fIA\fP has to be converted to a string hash table, because the index \fIi\fP walks string indices. .PP To execute the loop, the only state that needs to be saved is the address of \fIi\fP and an index into the vector of string keys. Since nothing about \fIA\fP is saved as state, the user program can do anything to \fIA\fP inside the body of the loop, even \fIdelete A\fP, and the loop still works. Essentially, we have traded data space (the string vector) in exchange for implementation simplicity. On a 32-bit system, each \fBANODE\fP is 36 bytes, so the extra memory needed for the array loop is 11\% more than the memory consumed by the \fBANODE\fPs of the array. Note that the large size of the \fBANODE\fPs is indicative of our whole design which pays data space for integer lookup speed and algorithm simplicity. The only aspect of array loops that occurs in \fIarray.c\fP is construction of the string vector. The rest of the implementation is in the file \fIexecute.c\fP. .PP As we walk over the hash table \fBANODE\fPs, putting each \fIsval\fP in \fIret\fP, we need to increment each reference count. The user of the return value is responsible for these new reference counts. .SS "Concatenating Array Indices" In \fIAWK\fP, an array expression \fIA[i,j\fP] is equivalent to the expression \fIA[i SUBSEP j\fP], i.e., the index is the concatenation of the three elements \fIi\fP, \fISUBSEP\fP and \fIj\fP. This is performed by the function \fIarray_cat\fP. On entry, \fIsp\fP points at the top of a stack of \fBCELL\fPs. \fICnt\fP cells are popped off the stack and concatenated together separated by \fISUBSEP\fP and the result is pushed back on the stack. On entry, the first multi-index is in \fIsp[1-cnt\fP] and the last is in \fIsp[0\fP]. The return value is the new stack top. (The stack is the run-time evaluation stack. This operation really has nothing to do with array structure, so logically this code belongs in \fIexecute.c\fP, but remains here for historical reasons.) .PP We make a copy of \fISUBSEP\fP which we can cast to string in the unlikely event the user has assigned a number to \fISUBSEP\fP. .PP Set \fIsp\fP and \fItop\fP so the cells to concatenate are inclusively between \fIsp\fP and \fItop\fP. .PP The \fItotal_len\fP is the sum of the lengths of the \fIcnt\fP strings and the \fIcnt-1\fP copies of \fIsubsep\fP. .PP The return value is \fIsp\fP and it is already set correctly. We just need to free the strings and set the contents of \fIsp\fP. mawk-1.3.4-20240123/main.c0000644000000000000000000000366313171250714013150 0ustar rootroot/******************************************** main.c copyright 2009-2014,2017 Thomas E. Dickey copyright 1991-1995,2014, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: main.c,v 1.31 2017/10/17 00:41:48 tom Exp $ */ /* main.c */ #include "mawk.h" #include "bi_vars.h" #include "init.h" #include "code.h" #include "files.h" #ifdef LOCALE #include #endif short mawk_state; /* 0 is compiling */ int exit_code; #if defined(__GNUC__) && defined(_FORTIFY_SOURCE) int ignore_unused; #endif #ifdef LOCALE char decimal_dot; #endif int main(int argc, char **argv) { #ifdef LOCALE setlocale(LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); #endif initialize(argc, argv); #ifdef LOCALE { struct lconv *data; decimal_dot = '\0'; /* only set to nonzero if not POSIX '.' */ setlocale(LC_NUMERIC, ""); data = localeconv(); if (data != 0 && data->decimal_point != 0 && strlen(data->decimal_point) == 1) { decimal_dot = data->decimal_point[0]; } else { /* back out of this if we cannot handle it */ setlocale(LC_NUMERIC, "C"); } if (decimal_dot == '.') decimal_dot = 0; } #endif parse(); mawk_state = EXECUTION; execute(execution_start, eval_stack - 1, 0); /* never returns */ return 0; } void mawk_exit(int x) { #ifdef HAVE_REAL_PIPES close_out_pipes(); /* actually closes all output */ #else #ifdef HAVE_FAKE_PIPES close_fake_pipes(); #endif #endif #ifdef NO_LEAKS code_leaks(); scan_leaks(); cell_leaks(); re_leaks(); rexp_leaks(); bi_vars_leaks(); hash_leaks(); array_leaks(); files_leaks(); fin_leaks(); field_leaks(); zmalloc_leaks(); #if OPT_TRACE > 0 trace_leaks(); #endif #endif exit(x); } mawk-1.3.4-20240123/test/0000755000000000000000000000000014521027316013027 5ustar rootrootmawk-1.3.4-20240123/test/mawktest.dat0000644000000000000000000000523305415353337015372 0ustar rootroot #include extern unsigned hash() ; /* An array A is a pointer to an array of struct array, which is two hash tables in one. One for strings and one for doubles. each array is of size A_HASH_PRIME. When an index is deleted via delete A[i], the ANODE is not removed from the hash chain. A[i].cp and A[i].sval are both freed and sval is set NULL. This method of deletion simplifies for( i in A ) loops. On the D_ANODE list, we use real deletion and move to the front on access. Separate nodes (as opposed to one type of node on two lists) to (1) d1 != d2, but sprintf(A_FMT,d1) == sprintf(A_FMT,d1) so two dnodes can point at the same anode. (2) Save a little data space(64K PC mentality). the cost is an extra level of indirection. Some care is needed so that things like A[1] = 2 ; delete A["1"] work . */ #define _dhash(d) (((int)(d)&0x7fff)%A_HASH_PRIME) #define DHASH(d) (last_dhash=_dhash(d)) static unsigned last_dhash ; /* switch =======;;;;;;hhhh */ static ANODE *find_by_sval(A, sval, cflag) ARRAY A ; STRING *sval ; int cflag ; /* create if on */ { char *s = sval->str ; unsigned h = hash(s) % A_HASH_PRIME ; register ANODE *p = A[h].link ; ANODE *q = 0 ; /* holds first deleted ANODE */ while ( p ) { if ( p->sval ) { if ( strcmp(s,p->sval->str) == 0 ) return p ; } else /* its deleted, mark with q */ if ( ! q ) q = p ; p = p->link ; } /* not there */ if ( cflag ) { if ( q ) p = q ; /* reuse the deleted node q */ else { p = (ANODE *)zmalloc(sizeof(ANODE)) ; p->link = A[h].link ; A[h].link = p ; } p->sval = sval ; sval->ref_cnt++ ; p->cp = (CELL *) zmalloc(sizeof(CELL)) ; p->cp->type = C_NOINIT ; } return p ; } /* on the D_ANODE list, when we find a node we move it to the front of the hash chain */ static D_ANODE *find_by_dval(A, d, cflag) ARRAY A ; double d ; int cflag ; { unsigned h = DHASH(d) ; register D_ANODE *p = A[h].dlink ; D_ANODE *q = 0 ; /* trails p for move to front */ ANODE *ap ; while ( p ) if ( p->dval == d ) { /* found */ if ( ! p->ap->sval ) /* but it was deleted by string */ { if ( q ) q->dlink = p->dlink ; else A[h].dlink = p->dlink ; zfree(p, sizeof(D_ANODE)) ; break ; } /* found */ if ( !q ) return p ; /* already at front */ else /* delete to put at front */ { q->dlink = p->dlink ; goto found ; } } else { q = p ; p = p->dlink ; } void (*signal())() ; mawk-1.3.4-20240123/test/reg6.awk0000644000000000000000000000137311500456220014374 0ustar rootroot# $MawkId: reg6.awk,v 1.3 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2010, Jonathan Nieder # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### BEGIN { patterns = "(a?)+bles /(^)+e/a(a?)*b/(a?)+*bles\\." n = split(patterns, pattern, "/") } { for (i = 1; i <= n; i++) { if ($0 ~ pattern[i]) { match($0, pattern[i]) printf "%d..%d:%s\n", RSTART, RLENGTH, $0 printf "reg6.%d<<%s>>\n", i, substr($0,RSTART,RLENGTH) } } } mawk-1.3.4-20240123/test/wfrq0.awk0000644000000000000000000000417213611312146014573 0ustar rootroot# $MawkId: wfrq0.awk,v 1.3 2020/01/20 11:52:06 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### # this program finds the twenty most frequent # words in document using a heap sort at the end # # function down_heap(i, k,hold) { while ( 1 ) { if ( compare(heap[2*i], heap[2*i+1]) <= 0 ) k = 2*i else k = 2*i + 1 if ( compare(heap[i],heap[k]) <= 0 ) return hold = heap[k] ; heap[k] = heap[i] ; heap[i] = hold i = k } } # compares two values of form "number word" # by number and breaks ties by word (reversed) function compare(s1, s2, t, X) { t = (s1+0) - (s2+0) # forces types to number if ( t == 0 ) { split(s1, X); s1 = X[2] split(s2, X); s2 = X[2] if ( s2 < s1 ) return -1 return s1 < s2 } return t } BEGIN { RS = "[^a-zA-Z]+" ; BIG = "999999:" } { cnt[$0]++ } END { delete cnt[ "" ] # load twenty values j = 1 for( i in cnt ) { heap[j] = num_word( cnt[i] , i ) delete cnt[i] ; if ( ++j == 21 ) break ; } # make some sentinels for( i = j ; i < 43 ; i++ ) heap[i] = BIG h_empty = j # save the first empty slot # make a heap with the smallest in slot 1 for( i = h_empty - 1 ; i > 0 ; i-- ) down_heap(i) # examine the rest of the values for ( i in cnt ) { j = num_word(cnt[i], i) if ( compare(j, heap[1]) > 0 ) { # its bigger # take the smallest out of the heap and readjust heap[1] = j down_heap(1) } } h_empty-- ; # what's left are the twenty largest # smallest at the top # i = 20 while ( h_empty > 1 ) { buffer[i--] = heap[1] heap[1] = heap[h_empty] heap[h_empty] = BIG down_heap(1) h_empty-- } buffer[i--] = heap[1] for(j = 1 ; j <= 20 ; j++ ) print buffer[j] } function num_word(num, word) { return sprintf("%3d %s", num, word) } mawk-1.3.4-20240123/test/decl-awk.out0000644000000000000000000000034605415353342015255 0ustar rootroothash: function returning unsigned (extern) last_dhash: unsigned (static) A: ARRAY sval: pointer to STRING cflag: int A: ARRAY d: double cflag: int ap: pointer to ANODE signal: function returning pointer to function returning void mawk-1.3.4-20240123/test/reg2.awk0000644000000000000000000000103211500456220014360 0ustar rootroot# $MawkId: reg2.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### /[A-Za-z_][A-Za-z0-9_]*\[.*\][ \t]*=/ {cnt++} END{print cnt} mawk-1.3.4-20240123/test/full-awk.dat0000644000000000000000000000024011061560657015245 0ustar rootrootThis has to be a small file to check if mawk handles write errors correctly even on a full disk. It has to be smaller than the write buffer of the C library. mawk-1.3.4-20240123/test/null-rs.awk0000644000000000000000000000115111500456220015117 0ustar rootroot# $MawkId: null-rs.awk,v 1.3 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2009, Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### # the test-data was generated on Linux using bash: #for ((i = 1; i <= 10; ++i)) ;do echo -ne "$i\0"; done BEGIN {RS = "\0"}; END {print NR} mawk-1.3.4-20240123/test/mawktest.bat0000644000000000000000000001054113705070213015354 0ustar rootroot@echo off rem $MawkId: mawktest.bat,v 1.15 2020/07/19 16:10:51 tom Exp $ rem vile:rs=lf rem rem ########################################################################## rem copyright 2010-2014,2020 Thomas E. Dickey rem copyright 1996, Michael D. Brennan rem rem This is a source file for mawk, an implementation of rem the AWK programming language. rem rem Mawk is distributed without warranty under the terms of rem the GNU General Public License, version 2, 1991. rem ########################################################################## rem rem This is a simple test that a new-made mawk seems to rem be working OK. rem It's certainly not exhaustive, but the last two tests in rem particular use most features. rem rem It needs to be run from mawk/test. rem You also need a binary-compare utility, e.g., "cmp". setlocal set dat=mawktest.dat if %CMP%.==. set CMP=cmp set PROG=..\mawk set MAWKBINMODE=7 set STDOUT=temp$$ rem find out which mawk we're testing %PROG% -Wv rem ################################ call :begin testing input and field splitting %PROG% -f null-rs.awk null-rs.dat > %STDOUT% call :compare "null-rs.awk" %STDOUT% null-rs.out %PROG% -f wc.awk %dat% > %STDOUT% call :compare "wc.awk" %STDOUT% wc-awk.out call :cmpsp2 "(a?)*b" "a*b" call :cmpsp2 "(a?)+b" "a*b" call :cmpsp2 "[^^]" "(.)" rem call :cmpsp2 "[^]]" "[[#a-zA-Z0-9/*!=<>+,;.&_%(){}" -]" call :cmpsp2 "[a[]" "[[a]" rem call :cmpsp2 "(])" "[]]" call :chkone "[\" rem call :cmpsp2 "(^)?)" ")" call :cmpsp3 "a*+" "a*" %PROG% -F "\000" -f nulls0.awk mawknull.dat > %STDOUT% %PROG% -F "[\000 ]" -f nulls0.awk mawknull.dat >> %STDOUT% call :compare "nulls" %STDOUT% nulls.out rem #################################### call :begin testing regular expression matching %PROG% -f reg0.awk %dat% > %STDOUT% %PROG% -f reg1.awk %dat% >> %STDOUT% %PROG% -f reg2.awk %dat% >> %STDOUT% %PROG% -f reg3.awk %dat% >> %STDOUT% %PROG% -f reg4.awk %dat% >> %STDOUT% %PROG% -f reg5.awk %dat% >> %STDOUT% %PROG% -f reg6.awk %dat% >> %STDOUT% %PROG% -f reg7.awk %dat% >> %STDOUT% call :compare "reg0-reg7" %STDOUT% reg-awk.out echo ''Italics with an apostrophe' embedded'' | %PROG% -f noloop.awk echo ''Italics with an apostrophe'' embedded'' | %PROG% -f noloop.awk %PROG% "/^[^^]*$/" %dat% > %STDOUT% call :compare "case 1" %STDOUT% %dat% rem call :cmpsp0 "!/^[^]]*$/" "/]/" rem call :cmpsp0 "/[a[]/" "/[[a]/" rem call :cmpsp0 "/]/" "/[]]/" rem ###################################### call :begin testing arrays and flow of control %PROG% -f wfrq0.awk %dat% > %STDOUT% call :compare "array-test" %STDOUT% wfrq-awk.out rem ###################################### call :begin testing nextfile %PROG% -f nextfile.awk full-awk.dat %dat% > %STDOUT% call :compare "nextfile-test" %STDOUT% nextfile.out rem ###################################### call :begin testing interval-expressions %PROG% -f repetitions.awk repetitions.dat > %STDOUT% call :compare "repetitions-test" %STDOUT% repetitions.out %PROG% -f interval0.awk repetitions.dat > %STDOUT% call :compare "empty-intervals-test" %STDOUT% interval0.out rem ################################ call :begin testing function calls and general stress test %PROG% -f ../examples/decl.awk %dat% > %STDOUT% call :compare "general" %STDOUT% decl-awk.out echo. echo if %CMP% always encountered "no differences", then the tested mawk seems OK del %STDOUT% endlocal goto :eof :cmpsp0 echo ...checking %1 vs %2 %PROG% -F "%1" %dat% > %STDOUT% %PROG% -F "%2" %dat% | cmp -s - %STDOUT% if errorlevel 1 goto :errsp0 echo ...ok goto :eof :errsp0 echo ...fail goto :eof :chkone echo ...checking %1 %PROG% -F "%1" 2> %STDOUT% if errorlevel 1 goto :errsp1 echo ...ok goto :eof :errsp1 echo ...fail goto :eof :cmpsp2 echo ...checking %1 vs %2 %PROG% -F "%1" -f wc.awk %dat% > %STDOUT% %PROG% -F "%2" -f wc.awk %dat% | cmp -s - %STDOUT% if errorlevel 1 goto :errsp2 echo ...ok goto :eof :errsp2 echo ...fail goto :eof :cmpsp3 echo ...checking %1 vs %2 %PROG% -F "%1" "{print NF}" > %STDOUT% %PROG% -F "%2" "{print NF}" | cmp -s - %STDOUT% if errorlevel 1 goto :errsp3 echo ...ok goto :eof :errsp3 echo ...fail goto :eof :begin echo. echo %* goto :eof :compare set TESTNAME=%1 echo ...checking %2 %3 %CMP% %2 %3 if errorlevel 1 goto :failed echo ...ok goto :eof :failed echo ...fail goto :eof mawk-1.3.4-20240123/test/repetitions.dat0000644000000000000000000000257213702556541016103 0ustar rootrootabc ac abbc bbbbbbc bbcab cabac cababac cababc cabc xyz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz qwertyqwertyqwertyqwerty mawk-1.3.4-20240123/test/interval0.awk0000644000000000000000000000111313705032640015432 0ustar rootroot# Test-script for MAWK ############################################################################### # copyright 2016, jlp765 # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### /b{0,0}/ /b{0}/ /b{,0}/ /ab{0,0}c/ /ab{0}c/ /^ab{0,1}c/ /ab{0,1}c/ /ab{0,3}c/ /ab{0,}c/ /b{0,1}c/ /b{0,2}c/ /b{0,3}c/ /b{0,3}/ /b{0}c/ /b{0,}/ /b{0}/ /(bbb){0,}/ mawk-1.3.4-20240123/test/null-rs.out0000644000000000000000000000000311233077705015151 0ustar rootroot10 mawk-1.3.4-20240123/test/fpe_test.bat0000644000000000000000000000552311500456220015327 0ustar rootrootecho off rem $MawkId: fpe_test.bat,v 1.2 2010/12/10 17:00:00 tom Exp $ rem vile:rs=lf rem rem ########################################################################## rem copyright 1996, Michael D. Brennan rem rem This is a source file for mawk, an implementation of rem the AWK programming language. rem rem Mawk is distributed without warranty under the terms of rem the GNU General Public License, version 2, 1991. rem ########################################################################## rem rem tests if mawk has been compiled to correctly handle rem floating point exceptions echo testing division by zero type fpetest1.awk ..\mawk -f fpetest1.awk if errorlevel 128 goto :test1_128 if errorlevel 3 goto :test1_3 if errorlevel 2 goto :test1_2 if errorlevel 1 goto :test1_1 set ret1=0 goto :test2 :test1_128 set ret1=128 goto :test2 :test1_3 set ret1=3 goto :test2 :test1_2 set ret1=2 goto :test2 :test1_1 set ret1=1 :test2 echo testing overflow type fpetest2.awk ..\mawk -f fpetest2.awk if errorlevel 128 goto :test2_128 if errorlevel 3 goto :test2_3 if errorlevel 2 goto :test2_2 if errorlevel 1 goto :test2_1 set ret2=0 goto :test3 :test2_128 set ret2=128 goto :test3 :test2_3 set ret2=3 goto :test3 :test2_2 set ret2=2 goto :test3 :test2_1 set ret2=1 :test3 echo testing domain error type fpetest3.awk ..\mawk -f fpetest3.awk > temp$$ if errorlevel 128 goto :test3_128 if errorlevel 3 goto :test3_3 if errorlevel 2 goto :test3_2 if errorlevel 1 goto :test3_1 set ret3=0 goto :type3 :test3_128 set ret3=128 goto :type3 :test3_3 set ret3=3 goto :type3 :test3_2 set ret3=2 goto :type3 :test3_1 set ret3=1 :type3 type temp$$ rem the returns should all be zero or all 2 echo ************************************* echo return1 = %ret1% echo return2 = %ret2% echo return3 = %ret3% set exception=0 if %ret1% == 2 goto :okay1 if %ret1% == 0 goto :okay1 echo test1 failed set exception=1 :okay1 if %ret2% == 2 goto :okay2 if %ret2% == 0 goto :okay2 echo test2 failed set exception=1 :okay2 if %ret3% == 2 goto :okay3 if %ret3% == 0 goto :okay3 echo test3 failed set exception=1 :okay3 if %exception% == 1 goto :done set same=1 if %ret1% == %ret2% goto :same12 set same=0 :same12 if %ret2% == %ret3% goto :same23 set same=0 :same23 if %same% == 1 goto :same123 echo results are not consistent echo return values should all be 0 if ignoring FPEs (e.g. with IEEE754) echo or all 2 if trapping FPEs goto :cleanup :same123 if %ret1% == 0 goto :allzero echo results consistent: trapping floating exceptions goto :cleanup :allzero echo results consistent: ignoring floating exceptions grep -i nan temp$$ >NUL if not errorlevel 1 goto :cleanup echo but the library is not IEEE754 compatible echo test 3 failed :cleanup del temp$$ :done set ret1= set ret2= set ret3= set same= if %exception% == 1 goto :done1 set exception= exit 0 :done1 set exception= exit 1 exit %exception% mawk-1.3.4-20240123/test/fpe_test0000755000000000000000000000502714521027277014600 0ustar rootroot#!/bin/sh # $MawkId: fpe_test,v 1.10 2023/11/02 23:20:31 tom Exp $ ############################################################################### # copyright 2009-2022,2023, Thomas E. Dickey # copyright 2010, Guido Berhoerster # copyright 1994,1995, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### # tests if mawk has been compiled to correctly handle # floating point exceptions PROG="${MAWK:-../mawk}" : "${EGREP:=grep -E}" : "${FGREP:=grep -F}" echo "testing floating point exception handling" STDOUT=${TMPDIR-/tmp}/mawktest$$ test1='BEGIN{ print 4/0 }' test2='BEGIN { x = 100 do { y = x ; x *= 1000 } while ( y != x ) print "loop terminated" }' # this used to test log(-8), but that was too challenging for cygwin hackers test3='BEGIN{ print sqrt(-8) }' echo "testing division by zero" echo "$PROG" "$test1" $PROG "$test1" ret1=$? echo echo "testing overflow" echo "$PROG" "$test2" $PROG "$test2" ret2=$? echo echo "testing domain error" echo "$PROG" "$test3" $PROG "$test3" > "$STDOUT" ret3=$? cat "$STDOUT" echo # the returns should all be zero or all 2 # core dumps not allowed trap ' echo compilation defines for floating point are incorrect rm -f $STDOUT exit 1' 0 echo echo ============================== echo return1 = $ret1 echo return2 = $ret2 echo return3 = $ret3 [ $ret1 -gt 128 ] && { echo test1 failed ; exception=1 ; } [ $ret2 -gt 128 ] && { echo test2 failed ; exception=1 ; } [ $ret3 -gt 128 ] && { echo test3 failed ; exception=1 ; } [ "$exception" = 1 ] && { rm -f ./*core* "$STDOUT" ; exit 1 ; } same=0 [ $ret1 = $ret2 ] && [ $ret2 = $ret3 ] && same=1 if [ $same = 1 ] then if [ $ret1 = 0 ] then echo "results consistent: ignoring floating exceptions" # some versions of hpux print NAN as ? if $EGREP '[nN][aA][nN]|\?' "$STDOUT" > /dev/null then : # MSYS / MinGW uses a different string... elif $FGREP '#IND' "$STDOUT" > /dev/null then echo "found MinGW hack for NaN..." else echo "but the library is not IEEE754 compatible" echo "test 3 failed" exit 1 fi else echo "results consistent: trapping floating exceptions" fi trap 0 rm -f "$STDOUT" exit 0 else cat <<-EOF results are not consistent return values should all be 0 if ignoring FPEs (e.g. with IEEE754) or all 2 if trapping FPEs EOF exit 1 fi # vile: ts=4 sw=4 mawk-1.3.4-20240123/test/reg5.awk0000644000000000000000000000217111500456220014370 0ustar rootroot# $MawkId: reg5.awk,v 1.3 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2009, Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### BEGIN { pat1="([[:upper:][:digit:]])+(_[[:upper:][:digit:]]+)+" pat2="0x[[:xdigit:]]+" } { if ($0 ~ /[^[:alnum:]]([[:upper:][:digit:]])+(_[[:upper:][:digit:]]+)+[^[:alnum:]]/) { match($0,pat1) printf "%d..%d:%s\n", RSTART, RLENGTH, $0 printf ("reg5.1<<%s>>\n",substr($0,RSTART,RLENGTH)) } if ($0 ~ pat1 ) { match($0,pat1) printf "%d..%d:%s\n", RSTART, RLENGTH, $0 printf ("reg5.2<<%s>>\n",substr($0,RSTART,RLENGTH)) } if ($0 ~ pat2 ) { match($0,pat2) printf "%d..%d:%s\n", RSTART, RLENGTH, $0 printf ("reg5.3<<%s>>\n",substr($0,RSTART,RLENGTH)) } # add patterns like those in reg4.awk which exercise [, ] at beginning } mawk-1.3.4-20240123/test/wc-awk.out0000644000000000000000000000001005415353343014744 0ustar rootroot107 479 mawk-1.3.4-20240123/test/fpetest3.awk0000644000000000000000000000076711500456220015274 0ustar rootroot# $MawkId: fpetest3.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### BEGIN{ print log(-8) } mawk-1.3.4-20240123/test/nextfile.out0000644000000000000000000000106511772610237015405 0ustar rootrootfull-awk.dat(1):This has to be a small file to check if mawk handles write errors correctly full-awk.dat(2):even on a full disk. It has to be smaller than the write buffer of the mawktest.dat(1): mawktest.dat(2):#include mawktest.dat(3): mawktest.dat(4):extern unsigned hash() ; mawktest.dat(5): mawktest.dat(6):/* An array A is a pointer to an array of struct array, mawktest.dat(7): which is two hash tables in one. One for strings mawktest.dat(8): and one for doubles. mawktest.dat(9): mawktest.dat(10): each array is of size A_HASH_PRIME. mawk-1.3.4-20240123/test/mawknull.dat0000644000000000000000000000111711255541046015355 0ustar rootroot-r--r--r--1tomusers191993-07-0314:58fpetest1.awk -r--r--r--1tomusers911993-07-0314:58fpetest2.awk -r--r--r--1tomusers231993-07-0314:58fpetest3.awk -r--r--r--1tomusers1402009-07-2612:16null-rs.awk -r--r--r--1tomusers331993-07-0314:58reg0.awk -r--r--r--1tomusers411993-07-0314:58reg1.awk -r--r--r--1tomusers621993-07-0314:58reg2.awk -r--r--r--1tomusers4102009-09-1719:29reg4.awk -r--r--r--1tomusers7272009-09-1620:51reg5.awk -r--r--r--1tomusers331993-07-0314:58wc.awk -r--r--r--1tomusers16891993-07-0314:58wfrq0.awk mawk-1.3.4-20240123/test/reg4.awk0000644000000000000000000000150512763323033014376 0ustar rootroot# $MawkId: reg4.awk,v 1.9 2016/09/05 17:06:35 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2009,2016 Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### { if ($0 ~/^[-+()0-9.,$%\/'"]*$/) { print ("reg4.1<<:",$0,">>") } if ($0 ~/^[]+()0-9.,$%\/'"-]*$/) { print ("reg4.2<<:",$0,">>") } if ($0 ~/^[^]+()0-9.,$%\/'"-]*$/) { print ("reg4.3<<:",$0,">>") } if ($0 ~/^[[+(){}0-9.,$%\/'"-]*$/) { print ("reg4.4<<:",$0,">>") } if ($0 ~/^[^[+(){}0-9.,$%\/'"-]*$/) { print ("reg4.5<<:",$0,">>") } } mawk-1.3.4-20240123/test/null-rs.dat0000644000000000000000000000002511233077547015122 0ustar rootroot12345678910mawk-1.3.4-20240123/test/nextfile.awk0000644000000000000000000000103511772610151015350 0ustar rootroot# $MawkId: nextfile.awk,v 1.1 2012/06/27 13:53:45 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2012, Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### {printf "%s(%d):", FILENAME, FNR; print $0; } /I/ {nextfile;} mawk-1.3.4-20240123/test/mawktest0000755000000000000000000001625214521027316014622 0ustar rootroot#!/bin/sh # $MawkId: mawktest,v 1.46 2023/11/02 23:20:46 tom Exp $ ############################################################################### # copyright 2008-2022,2023, Thomas E. Dickey # copyright 2010, Guido Berhoerster # copyright 2010, Jonathan Nieder # copyright 2005, Aleksey Cheusov # copyright 1996, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### # This is a simple test that a new made mawk seems to # be working OK. # It's certainly not exhaustive, but the last two tests in # particular use most features. # # It needs to be run from mawk/test # and mawk needs to be in mawk/test or in PATH : "${FGREP:=grep -F}" # POSIX shells have functions... Fail() { echo "?? fail $*" FAIL=`expr "$FAIL" + 1` ERRS=`expr "$ERRS" + 1` } Begin() { echo echo "$*" FAIL=0 } Finish() { if test $FAIL = 1 then echo "$* had one failure" elif test $FAIL != 0 then echo "$* had $FAIL failures" else echo "$* OK" fi } ERRS=0 Summary() { if test $ERRS = 1 then echo "$* had one failure" elif test $ERRS != 0 then echo "$* had $ERRS failures" else echo "$* OK" fi } if [ -f ../mawk ] then PROG="${AWK:-../mawk}" else PROG="${AWK:-mawk}" fi MAWKBINMODE=7 export MAWKBINMODE if test $# != 0 ; then SRC=$1 else SRC=.. fi dat=mawktest.dat nulldat=mawknull.dat STDOUT=${TMPDIR-/tmp}/mawk-out$$ STDERR=${TMPDIR-/tmp}/mawk-err$$ # The ulimit command interferes with valgrind (uncomment for ad hoc testing). #ulimit -v 25000 trap 'echo mawk_test failed ; rm -f "$STDOUT" "$STDERR"; exit 1' 0 # find out which mawk we're testing MAWKS=no if $PROG -W version &1 |head -n 1 |grep mawk >/dev/null ) && MAWKS=yes NULLS=`$PROG -W version 2>&1 /dev/null` else NULLS= fi ################################# Begin "testing input and field splitting" LC_ALL=C $PROG -f wc.awk $dat | cmp -s - wc-awk.out || Fail "wc.awk" LC_ALL=C $PROG -f null-rs.awk null-rs.dat | cmp -s - null-rs.out || Fail "null-rs.awk" LC_ALL=C $PROG -F '(a?)*b' -f wc.awk $dat > "$STDOUT" LC_ALL=C $PROG -F 'a*b' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 2" LC_ALL=C $PROG -F '(a?)+b' -f wc.awk $dat > "$STDOUT" LC_ALL=C $PROG -F 'a*b' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 3" LC_ALL=C $PROG -F 'a{0,}b' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 3b" LC_ALL=C $PROG -F '[^^]' -f wc.awk $dat > "$STDOUT" LC_ALL=C $PROG -F '(.)' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 4" LC_ALL=C $PROG -F '[^]]' -f wc.awk $dat > "$STDOUT" LC_ALL=C $PROG -F '[[#a-zA-Z0-9/*!=<>+,;.&_%(){}" -]' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 5" LC_ALL=C $PROG -F '[a[]' -f wc.awk $dat > "$STDOUT" LC_ALL=C $PROG -F '[[a]' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 6" if test "$MAWKS" = "yes" ; then LC_ALL=C $PROG -F 'a|\[' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 6b" else echo "...skipping case 6b: escaped-bracket test" fi LC_ALL=C $PROG -F '(])' -f wc.awk $dat > "$STDOUT" LC_ALL=C $PROG -F '[]]' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 7" LC_ALL=C $PROG -F '\]' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 7b" # check that the regexp [\ does not make mawk segfault if test "$MAWKS" = "yes" ; then LC_ALL=C $PROG -F "[\\" 2> "$STDERR" || Fail "case 8" fi LC_ALL=C $PROG -F '(^)?)' -f wc.awk $dat > "$STDOUT" LC_ALL=C $PROG -F ')' -f wc.awk $dat | cmp -s - "$STDOUT" || Fail "case 9" echo baaab | LC_ALL=C $PROG -F 'a*+' '{print NF}' > "$STDOUT" echo baaab | LC_ALL=C $PROG -F 'a*' '{print NF}' | cmp -s - "$STDOUT" || Fail "case 10" #LC_ALL=C $PROG -F '[\\\\]' -f wc.awk $dat > "$STDOUT" #LC_ALL=C $PROG -F '(\\\\)' -f wc.awk | cmp -s - "$STDOUT" || Fail "case 11" #LC_ALL=C $PROG -F '\\\\' -f wc.awk | cmp -s - "$STDOUT" || Fail "case 11b" if test -n "$NULLS" ; then LC_ALL=C $PROG -F '\000' -f nulls0.awk $nulldat > "$STDOUT" LC_ALL=C $PROG -F '[\000 ]' -f nulls0.awk $nulldat >> "$STDOUT" if ( cmp -s nulls.out "$STDOUT" ) then echo "... $PROG supports matches with NUL bytes" else echo "... $PROG does NOT supports matches with NUL bytes" fi fi Finish "input and field splitting" ##################################### Begin "testing regular expression matching" { LC_ALL=C $PROG -f reg0.awk $dat LC_ALL=C $PROG -f reg1.awk $dat LC_ALL=C $PROG -f reg2.awk $dat LC_ALL=C $PROG -f reg3.awk $dat LC_ALL=C $PROG -f reg4.awk $dat LC_ALL=C $PROG -f reg5.awk $dat LC_ALL=C $PROG -f reg6.awk $dat LC_ALL=C $PROG -f reg7.awk $dat } > "$STDOUT" cmp -s reg-awk.out "$STDOUT" || Fail "reg0-reg7 case" echo "''Italics with an apostrophe' embedded''" | LC_ALL=C $PROG -f noloop.awk || Fail "noloop2 test" echo "''Italics with an apostrophe'' embedded''" | LC_ALL=C $PROG -f noloop.awk || Fail "noloop1 test" LC_ALL=C $PROG '/^[^^]*$/' $dat > "$STDOUT" cmp -s $dat "$STDOUT" || Fail "case 1" LC_ALL=C $PROG '!/^[^]]*$/' $dat > "$STDOUT" LC_ALL=C $PROG '/]/' $dat | cmp -s - "$STDOUT" || Fail "case 2" LC_ALL=C $PROG '/[a[]/' $dat > "$STDOUT" LC_ALL=C $PROG '/[[a]/' $dat | cmp -s - "$STDOUT" || Fail "case 3" LC_ALL=C $PROG '/]/' $dat > "$STDOUT" LC_ALL=C $PROG '/[]]/' $dat | cmp -s - "$STDOUT" || Fail "case 4" echo aaa | LC_ALL=C $PROG '/a*+/' > "$STDOUT" echo aaa | LC_ALL=C $PROG '/a*/' | cmp -s - "$STDOUT" || Fail "case 5" echo aaa | cmp -s - "$STDOUT" || Fail "case 6" Finish "regular expression matching" ####################################### if [ -c /dev/full ]; then Begin "testing checking for write errors" # Check for write errors noticed when closing the file LC_ALL=C $PROG '{print}' /dev/full 2>/dev/null && Fail "case 1" # Check for write errors noticed on writing # The file has to be bigger than the buffer size of the libc LC_ALL=C $PROG '{print}' <$SRC/scan.c >/dev/full 2>/dev/null && Fail "case 2" Finish "checking for write errors" else echo echo "No /dev/full - check for write errors skipped" fi ####################################### Begin "testing arrays and flow of control" LC_ALL=C $PROG -f wfrq0.awk $dat | cmp -s - wfrq-awk.out || Fail "wfrq-awk" Finish "array test" ####################################### Begin "testing nextfile" LC_ALL=C $PROG -f nextfile.awk full-awk.dat $dat | cmp -s - nextfile.out || Fail "nextfile.awk" Finish "nextfile test" ################################# Begin "testing function calls and general stress test" LC_ALL=C $PROG -f $SRC/examples/decl.awk $dat | cmp -s - decl-awk.out || Fail "examples/decl.awk" Finish "general stress test" ################################# Begin "testing r{n,m} repetitions" LC_ALL=C $PROG -f repetitions.awk repetitions.dat | cmp -s - repetitions.out || Fail "repetitions.awk" LC_ALL=C $PROG -f interval0.awk repetitions.dat | cmp -s - interval0.out || Fail "interval0.awk" Finish "repetitions test" ################################# echo "##################################################" Summary "tested $PROG" echo "##################################################" trap 0 rm -f "$STDOUT" exit $ERRS # vile: ts=4 sw=4 mawk-1.3.4-20240123/test/repetitions.out0000644000000000000000000001040513705034677016140 0ustar rootrootabc abc abc abc abc abc ac abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbcab bbcab bbcab bbcab bbcab bbcab bbcab cabac cabac cababac cababac cababc cababc cababc cababc cababc cababc cabc cabc cabc cabc cabc xyz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz qwertyqwertyqwertyqwerty qwertyqwertyqwertyqwerty mawk-1.3.4-20240123/test/noloop.awk0000644000000000000000000000133411336752457015056 0ustar rootroot# From jhart@avcnet.bates.edu Sun Oct 6 16:05:21 2002 # Date: Sun, 6 Oct 2002 08:36:54 -0400 # Subject: Infinite loop in sub/gsub # From: jhart@avcnet.bates.edu # To: bug-gawk@gnu.org # Message-Id: <4BC4A4F0-D928-11D6-8E78-00039384A9CC@mail.avcnet.org> # # This command line: # # echo "''Italics with an apostrophe'' embedded''"|gawk -f test.awk # # where test.awk contains this instruction: # /''/ { sub(/''(.?[^']+)*''/, "&"); } # # puts gawk 3.11 into an infinite loop. Whereas, this command works: # # echo "''Italics with an apostrophe' embedded''"|gawk -f test.awk # # # # Platform: Mac OS X 10.1.5/Darwin Kernel Version 5.5: Thu May 30 14:51:26 # PDT 2002; root:xnu/xnu-201.42.3.obj~1/RELEASE_PPC # # mawk-1.3.4-20240123/test/reg0.awk0000644000000000000000000000077511500456220014373 0ustar rootroot# $MawkId: reg0.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### /return/ {cnt++} END{print cnt} mawk-1.3.4-20240123/test/wfrq-awk.out0000644000000000000000000000024005415353344015320 0ustar rootroot 29 p 21 A 14 ANODE 13 q 12 d 12 sval 10 if 10 the 8 dlink 8 h 8 is 7 to 6 D 6 of 5 cflag 5 deleted 5 else 5 front 5 hash 5 link mawk-1.3.4-20240123/test/fpetest1.awk0000644000000000000000000000076311500456220015266 0ustar rootroot# $MawkId: fpetest1.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### BEGIN{ print 4/0 } mawk-1.3.4-20240123/test/nulls0.awk0000644000000000000000000000101611500456220014740 0ustar rootroot# $MawkId: nulls0.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2009, Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### { printf "%3d: %2d - %s %s\n", NR, NF, $6, $8; } mawk-1.3.4-20240123/test/reg7.awk0000644000000000000000000000263212375177117014414 0ustar rootroot# $MawkId: reg7.awk,v 1.1 2014/08/20 20:00:15 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2014, Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### BEGIN { str = "abc"; print gsub("b+", "FOO", str), str str = "abc"; print gsub("x*", "X", str), str str = "abc"; print gsub("b*", "X", str), str str = "abc"; print gsub("c", "X", str), str str = "abc"; print gsub("c+", "X", str), str str = "abc"; print gsub("x*$", "X", str), str str = "abc"; print gsub("b|$", "X", str), str str = "abc"; print gsub("b+", "FOO", str), str str = "abc"; print gsub("x*", "X", str), str str = "abc"; print gsub("b*", "X", str), str str = "abc"; print gsub("c", "X", str), str str = "abc"; print gsub("c+", "X", str), str str = "abc"; print gsub("x*$", "X", str), str str = "abc"; print gsub("b+", "(&)", str), str str = "abc"; print gsub("x*", "{&}", str), str str = "abc"; print gsub("b*", "{&}", str), str str = "abbcb"; print gsub("b*", "{&}", str), str str = "abbcb"; print gsub("b+", "(&)", str), str str = "a b c"; print gsub(/^[ ]*/, "", str), str str = " a b c"; print gsub(/^[ ]*/, "", str), str } mawk-1.3.4-20240123/test/reg-awk.out0000644000000000000000000001102212375177400015116 0ustar rootroot3 4 1 0 -1 reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: to >> reg4.5<<: to >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: Some care is needed so that things like >> reg4.5<<: Some care is needed so that things like >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: static unsigned last_dhash ; >> reg4.5<<: static unsigned last_dhash ; >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: ARRAY A ; >> reg4.5<<: ARRAY A ; >> reg4.3<<: STRING *sval ; >> reg4.5<<: STRING *sval ; >> reg4.3<<: { >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: { >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: } >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: { >> reg4.3<<: else >> reg4.5<<: else >> reg4.3<<: } >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: } >> reg4.3<<: return p ; >> reg4.5<<: return p ; >> reg4.3<<: } >> reg4.4<<: } >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: ARRAY A ; >> reg4.5<<: ARRAY A ; >> reg4.3<<: double d ; >> reg4.5<<: double d ; >> reg4.3<<: int cflag ; >> reg4.5<<: int cflag ; >> reg4.3<<: { >> reg4.4<<: { >> reg4.3<<: ANODE *ap ; >> reg4.5<<: ANODE *ap ; >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.3<<: break ; >> reg4.5<<: break ; >> reg4.3<<: } >> reg4.3<<: } >> reg4.3<<: else >> reg4.5<<: else >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> reg4.1<<: >> reg4.2<<: >> reg4.3<<: >> reg4.4<<: >> reg4.5<<: >> 26..12: each array is of size A_HASH_PRIME. reg5.1<> 26..12: each array is of size A_HASH_PRIME. reg5.2<> 11..7: On the D_ANODE list, we use real deletion and move to the reg5.1<> 11..7: On the D_ANODE list, we use real deletion and move to the reg5.2<> 32..5: (1) d1 != d2, but sprintf(A_FMT,d1) == sprintf(A_FMT,d1) reg5.1<> 32..5: (1) d1 != d2, but sprintf(A_FMT,d1) == sprintf(A_FMT,d1) reg5.2<> 42..12:#define _dhash(d) (((int)(d)&0x7fff)%A_HASH_PRIME) reg5.1<> 42..12:#define _dhash(d) (((int)(d)&0x7fff)%A_HASH_PRIME) reg5.2<> 34..6:#define _dhash(d) (((int)(d)&0x7fff)%A_HASH_PRIME) reg5.3<<0x7fff>> 27..12: unsigned h = hash(s) % A_HASH_PRIME ; reg5.1<> 27..12: unsigned h = hash(s) % A_HASH_PRIME ; reg5.2<> 22..8: p->cp->type = C_NOINIT ; reg5.1<> 22..8: p->cp->type = C_NOINIT ; reg5.2<> 11..7:/* on the D_ANODE list, when we find a node we move it reg5.1<> 11..7:/* on the D_ANODE list, when we find a node we move it reg5.2<> 8..7:static D_ANODE *find_by_dval(A, d, cflag) reg5.1<> 8..7:static D_ANODE *find_by_dval(A, d, cflag) reg5.2<> 12..7: register D_ANODE *p = A[h].dlink ; reg5.1<> 12..7: register D_ANODE *p = A[h].dlink ; reg5.2<> 3..7: D_ANODE *q = 0 ; /* trails p for move to front */ reg5.1<> 3..7: D_ANODE *q = 0 ; /* trails p for move to front */ reg5.2<> 28..7: zfree(p, sizeof(D_ANODE)) ; reg5.1<> 28..7: zfree(p, sizeof(D_ANODE)) ; reg5.2<> 1..1:extern unsigned hash() ; reg6.2<> 23..6: which is two hash tables in one. One for strings reg6.1<> 23..2: which is two hash tables in one. One for strings reg6.3<> 19..5: and one for doubles. reg6.4<> 1 aFOOc 4 XaXbXcX 3 XaXcX 1 abX 1 abX 1 abcX 2 aXcX 1 aFOOc 4 XaXbXcX 3 XaXcX 1 abX 1 abX 1 abcX 1 a(b)c 4 {}a{}b{}c{} 3 {}a{b}c{} 3 {}a{bb}c{b} 2 a(bb)c(b) 1 a b c 1 a b c mawk-1.3.4-20240123/test/interval0.out0000644000000000000000000003614013705034737015500 0ustar rootrootabc abc abc abc abc abc abc abc abc abc abc abc abc abc abc ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac ac abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc abbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbbbbbc bbcab bbcab bbcab bbcab bbcab bbcab bbcab bbcab bbcab bbcab bbcab cabac cabac cabac cabac cabac cabac cabac cabac cabac cabac cabac cabac cabac cabac cabac cabac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababac cababc cababc cababc cababc cababc cababc cababc cababc cababc cababc cababc cababc cababc cababc cabc cabc cabc cabc cabc cabc cabc cabc cabc cabc cabc cabc cabc cabc xyz xyz xyz xyz xyz xyz xyz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz wabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxczwabxcz qwertyqwertyqwertyqwerty qwertyqwertyqwertyqwerty qwertyqwertyqwertyqwerty qwertyqwertyqwertyqwerty qwertyqwertyqwertyqwerty qwertyqwertyqwertyqwerty qwertyqwertyqwertyqwerty mawk-1.3.4-20240123/test/repetitions.awk0000644000000000000000000000153313707043740016106 0ustar rootroot# $MawkId: repetitions.awk,v 1.3 2020/07/25 14:55:28 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2016, jlp765 # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### /b{,1}/ /ab{1,3}c/ /^ab{1,}c/ /ab{1,}c/ /ab{1}c/ /ab{2,3}c/ /a(b){2}c/ /a(b{2})c/ /ab{2}c/ /(ab){2,}c/ /ab{2,}c/ /ab{3}c/ /ab{3,5}c/ /(abb){1,}/ /b{1,}/ /b{2,}c/ /(b){2,}c/ /b{6,}c/ /b{7,}c/ /(bb){1,}c/ /(bb){1}c/ /bb{1}c/ /(bb){2,}c/ /(bb){2}c/ /bb{2}c/ /(bbb){1,}/ /(qwerty){4}/ /(qwerty){5}/ /(wabxcz){220}w/ /(wabxcz){220}/ /(wabxcz){221}/ /wabxcz{219}w/ mawk-1.3.4-20240123/test/reg1.awk0000644000000000000000000000100511500456220014357 0ustar rootroot# $MawkId: reg1.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### /return|switch/ {cnt++} END{print cnt} mawk-1.3.4-20240123/test/reg3.awk0000644000000000000000000000104611500456220014366 0ustar rootroot# $MawkId: reg3.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 2010, Thomas E. Dickey # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### BEGIN { test = "MFG" match(test, "[^0-9A-Za-z]") print RSTART, RLENGTH } mawk-1.3.4-20240123/test/nulls.out0000644000000000000000000000126011255542516014721 0ustar rootroot 1: 8 - 1993-07-03 fpetest1.awk 2: 8 - 1993-07-03 fpetest2.awk 3: 8 - 1993-07-03 fpetest3.awk 4: 8 - 2009-07-26 null-rs.awk 5: 8 - 1993-07-03 reg0.awk 6: 8 - 1993-07-03 reg1.awk 7: 8 - 1993-07-03 reg2.awk 8: 8 - 2009-09-17 reg4.awk 9: 8 - 2009-09-16 reg5.awk 10: 8 - 1993-07-03 wc.awk 11: 8 - 1993-07-03 wfrq0.awk 1: 8 - 1993-07-03 fpetest1.awk 2: 8 - 1993-07-03 fpetest2.awk 3: 8 - 1993-07-03 fpetest3.awk 4: 8 - 2009-07-26 null-rs.awk 5: 8 - 1993-07-03 reg0.awk 6: 8 - 1993-07-03 reg1.awk 7: 8 - 1993-07-03 reg2.awk 8: 8 - 2009-09-17 reg4.awk 9: 8 - 2009-09-16 reg5.awk 10: 8 - 1993-07-03 wc.awk 11: 8 - 1993-07-03 wfrq0.awk mawk-1.3.4-20240123/test/fpetest2.awk0000644000000000000000000000107311500456220015262 0ustar rootroot# $MawkId: fpetest2.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### BEGIN { x = 100 do { y = x ; x *= 1000 } while ( y != x ) print "loop terminated" } mawk-1.3.4-20240123/test/wc.awk0000644000000000000000000000077311500456220014145 0ustar rootroot# $MawkId: wc.awk,v 1.2 2010/12/10 17:00:00 tom Exp $ # Test-script for MAWK ############################################################################### # copyright 1993, Michael D. Brennan # # This is a source file for mawk, an implementation of # the AWK programming language. # # Mawk is distributed without warranty under the terms of # the GNU General Public License, version 2, 1991. ############################################################################### {sum += NF} END{ print NR, sum} mawk-1.3.4-20240123/cast.c0000644000000000000000000002141014054300200013127 0ustar rootroot/******************************************** cast.c copyright 2009-2020,2021, Thomas E. Dickey copyright 1991-1995,1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: cast.c,v 1.29 2021/05/28 23:45:04 tom Exp $ */ /* cast.c */ #include "mawk.h" #include "field.h" #include "memory.h" #include "scan.h" #include "repl.h" const int mpow2[NUM_CELL_TYPES] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512}; void cast1_to_d(CELL *cp) { switch (cp->type) { case C_NOINIT: cp->dval = 0.0; break; case C_DOUBLE: return; case C_MBSTRN: case C_STRING: { register STRING *s = (STRING *) cp->ptr; errno = 0; #ifdef FPE_TRAPS_ON /* look for overflow error */ cp->dval = strtod(s->str, (char **) 0); if (errno && cp->dval != 0.0) /* ignore underflow */ rt_error("overflow converting %s to double", s->str); #else cp->dval = strtod(s->str, (char **) 0); #endif free_STRING(s); } break; case C_STRNUM: /* don't need to convert, but do need to free the STRING part */ free_STRING(string(cp)); break; default: bozo("cast on bad type"); } cp->type = C_DOUBLE; } void cast2_to_d(CELL *cp) { register STRING *s; switch (cp->type) { case C_NOINIT: cp->dval = 0.0; break; case C_DOUBLE: goto two; case C_STRNUM: free_STRING(string(cp)); break; case C_MBSTRN: case C_STRING: s = (STRING *) cp->ptr; errno = 0; #ifdef FPE_TRAPS_ON /* look for overflow error */ cp->dval = strtod(s->str, (char **) 0); if (errno && cp->dval != 0.0) /* ignore underflow */ rt_error("overflow converting %s to double", s->str); #else cp->dval = strtod(s->str, (char **) 0); #endif free_STRING(s); break; default: bozo("cast on bad type"); } cp->type = C_DOUBLE; two: cp++; switch (cp->type) { case C_NOINIT: cp->dval = 0.0; break; case C_DOUBLE: return; case C_STRNUM: free_STRING(string(cp)); break; case C_MBSTRN: case C_STRING: s = (STRING *) cp->ptr; errno = 0; #ifdef FPE_TRAPS_ON /* look for overflow error */ cp->dval = strtod(s->str, (char **) 0); if (errno && cp->dval != 0.0) /* ignore underflow */ rt_error("overflow converting %s to double", s->str); #else cp->dval = strtod(s->str, (char **) 0); #endif free_STRING(s); break; default: bozo("cast on bad type"); } cp->type = C_DOUBLE; } #define DoubleToString(target,source) \ if (source->dval >= (double) Max_Long) { \ ULong lval = d_to_UL(source->dval); \ if (lval == source->dval) { \ sprintf(target, ULONG_FMT, lval); \ } else { \ sprintf(target, string(CONVFMT)->str, source->dval); \ } \ } else { \ Long lval = d_to_L(source->dval); \ if (lval == source->dval) { \ sprintf(target, LONG_FMT, lval); \ } else { \ sprintf(target, string(CONVFMT)->str, source->dval); \ } \ } void cast1_to_s(CELL *cp) { char xbuff[260]; switch (cp->type) { case C_NOINIT: null_str.ref_cnt++; cp->ptr = (PTR) & null_str; break; case C_DOUBLE: DoubleToString(xbuff, cp); cp->ptr = (PTR) new_STRING(xbuff); break; case C_STRING: return; case C_MBSTRN: case C_STRNUM: break; default: bozo("bad type on cast"); } cp->type = C_STRING; } void cast2_to_s(CELL *cp) { char xbuff[260]; switch (cp->type) { case C_NOINIT: null_str.ref_cnt++; cp->ptr = (PTR) & null_str; break; case C_DOUBLE: DoubleToString(xbuff, cp); cp->ptr = (PTR) new_STRING(xbuff); break; case C_STRING: goto two; case C_MBSTRN: case C_STRNUM: break; default: bozo("bad type on cast"); } cp->type = C_STRING; two: cp++; switch (cp->type) { case C_NOINIT: null_str.ref_cnt++; cp->ptr = (PTR) & null_str; break; case C_DOUBLE: DoubleToString(xbuff, cp); cp->ptr = (PTR) new_STRING(xbuff); break; case C_STRING: return; case C_MBSTRN: case C_STRNUM: break; default: bozo("bad type on cast"); } cp->type = C_STRING; } void cast_to_RE(CELL *cp) { register PTR p; if (cp->type < C_STRING) cast1_to_s(cp); p = re_compile(string(cp)); no_leaks_re_ptr(p); free_STRING(string(cp)); cp->type = C_RE; cp->ptr = p; } void cast_for_split(CELL *cp) { #ifndef NO_INTERVAL_EXPR static const char meta[] = "^$.*+?|[](){}"; #else static const char meta[] = "^$.*+?|[]()"; #endif size_t len; if (cp->type < C_STRING) cast1_to_s(cp); if ((len = string(cp)->len) == 1) { int c; if ((c = string(cp)->str[0]) == ' ') { free_STRING(string(cp)); cp->type = C_SPACE; return; } else if (c == 0) { #ifdef LOCAL_REGEXP char temp[1]; temp[0] = (char) c; free_STRING(string(cp)); cp->ptr = (PTR) new_STRING1(temp, (size_t) 1); #else /* * A null is not a meta character, but strchr will match it anyway. * For now, there's no reason to compile a null as a regular * expression - just return a string containing the single * character. That is used in a special case in set_rs_shadow(). */ char temp[2]; temp[0] = (char) c; free_STRING(string(cp)); cp->ptr = (PTR) new_STRING1(temp, (size_t) 1); return; #endif } else if ((strchr) (meta, c)) { static char xbuff[] = "\\X"; xbuff[1] = (char) c; free_STRING(string(cp)); cp->ptr = (PTR) new_STRING(xbuff); } } else if (len == 0) { free_STRING(string(cp)); cp->type = C_SNULL; return; } cast_to_RE(cp); } /* input: cp-> a CELL of type C_MBSTRN (maybe strnum) test it -- casting it to the appropriate type which is C_STRING or C_STRNUM */ void check_strnum(CELL *cp) { char *temp; register unsigned char *s, *q; cp->type = C_STRING; /* assume not C_STRNUM */ s = (unsigned char *) string(cp)->str; q = s + string(cp)->len; while (scan_code[*s] == SC_SPACE) s++; if (s == q) return; while (scan_code[q[-1]] == SC_SPACE) q--; if (scan_code[q[-1]] != SC_DIGIT && q[-1] != '.') return; switch (scan_code[*s]) { case SC_DIGIT: case SC_PLUS: case SC_MINUS: case SC_DOT: errno = 0; #ifdef FPE_TRAPS_ON cp->dval = strtod((char *) s, &temp); /* make overflow pure string */ if (errno && cp->dval != 0.0) break; #else cp->dval = strtod((char *) s, &temp); #endif #ifdef ERANGE if (errno == ERANGE) break; #endif if ((char *) q <= temp) { cp->type = C_STRNUM; /* <= instead of == , for some buggy strtod e.g. Apple Unix */ } break; } } /* cast a CELL to a replacement cell */ void cast_to_REPL(CELL *cp) { register STRING *sval; if (cp->type < C_STRING) cast1_to_s(cp); sval = (STRING *) cp->ptr; cellcpy(cp, repl_compile(sval)); free_STRING(sval); } /* convert a double to Int (this is not as simple as a cast because the results are undefined if it won't fit). Truncate large values to +Max_Int or -Max_Int Send nans to -Max_Int */ Int d_to_I(double d) { Int result; if (d >= (double) Max_Int) { result = Max_Int; } else if (d < 0) { if (-d <= (double) Max_Int) { result = (Int) d; } else { result = -Max_Int; } } else { result = (Int) d; } return result; } Long d_to_L(double d) { Long result; if (d >= (double) Max_Long) { result = Max_Long; } else if (d < 0) { if (-d <= (double) Max_Long) { result = (Long) d; } else { result = -Max_Long; } } else { result = (Long) d; } return result; } ULong d_to_UL(double d) { ULong result; if (d >= (double) Max_ULong) { result = Max_ULong; } else if (d < 0) { if (-d < (double) Max_ULong) { result = ((Max_ULong + (ULong) d) + 1); } else { result = -Max_ULong; } } else { result = (ULong) d; } return result; } #ifdef NO_LEAKS typedef struct _all_cells { struct _all_cells *next; char ptr; CELL *cp; } ALL_CELLS; static ALL_CELLS *all_cells; /* * Some regular expressions are parsed, and the pointer stored in the byte-code * where we cannot distinguish it from other constants. Keep a list here, to * free on exit for auditing. */ void no_leaks_cell(CELL *cp) { ALL_CELLS *p = calloc(1, sizeof(ALL_CELLS)); p->next = all_cells; p->cp = cp; p->ptr = 0; all_cells = p; } void no_leaks_cell_ptr(CELL *cp) { ALL_CELLS *p = calloc(1, sizeof(ALL_CELLS)); p->next = all_cells; p->cp = cp; p->ptr = 1; all_cells = p; } void cell_leaks(void) { while (all_cells != 0) { ALL_CELLS *next = all_cells->next; if (all_cells->ptr) { zfree(all_cells->cp, sizeof(CELL)); } else { free_cell_data(all_cells->cp); } free(all_cells); all_cells = next; } } #endif mawk-1.3.4-20240123/bi_vars.c0000644000000000000000000000361014457053760013653 0ustar rootroot/******************************************** bi_vars.c copyright 2009-2010,2023 Thomas E. Dickey copyright 1991-1992,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: bi_vars.c,v 1.11 2023/07/22 22:28:00 tom Exp $ */ /* bi_vars.c */ #include "mawk.h" #include "symtype.h" #include "bi_vars.h" #include "field.h" #include "init.h" #include "memory.h" /* the builtin variables */ CELL bi_vars[NUM_BI_VAR]; /* the order here must match the order in bi_vars.h */ static const char *bi_var_names[NUM_BI_VAR] = { "NR", "FNR", "ARGC", "FILENAME", "OFS", "ORS", "RLENGTH", "RSTART", "SUBSEP" #if USE_BINMODE ,"BINMODE" #endif }; /* insert the builtin vars in the hash table */ void bi_vars_init(void) { register int i; register SYMTAB *s; for (i = 0; i < NUM_BI_VAR; i++) { s = insert(bi_var_names[i]); s->type = (char) ((i <= 1) ? ST_NR : ST_VAR); s->stval.cp = bi_vars + i; /* bi_vars[i].type = 0 which is C_NOINIT */ } s = insert("ENVIRON"); s->type = ST_ENV; /* set defaults */ FILENAME->type = C_STRING; FILENAME->ptr = (PTR) new_STRING(""); OFS->type = C_STRING; OFS->ptr = (PTR) new_STRING(" "); ORS->type = C_STRING; ORS->ptr = (PTR) new_STRING("\n"); SUBSEP->type = C_STRING; SUBSEP->ptr = (PTR) new_STRING("\034"); NR->type = FNR->type = C_DOUBLE; /* dval is already 0.0 */ #if USE_BINMODE BINMODE->type = C_DOUBLE; #endif } #ifdef NO_LEAKS void bi_vars_leaks(void) { int n; for (n = 0; n < NUM_BI_VAR; ++n) { switch (bi_vars[n].type) { case C_STRING: case C_STRNUM: case C_MBSTRN: free_STRING(string(&bi_vars[n])); break; } } } #endif mawk-1.3.4-20240123/version.c0000644000000000000000000000326214553336325013714 0ustar rootroot/******************************************** version.c copyright 2008-2023,2024 Thomas E. Dickey copyright 1991-1996,2014 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: version.c,v 1.36 2024/01/22 00:54:45 tom Exp $ */ #include "mawk.h" #include "init.h" #include "patchlev.h" #define VERSION_STRING \ "mawk %d.%d%s %s\n\ Copyright 2008-2023,2024, Thomas E. Dickey\n\ Copyright 1991-1996,2014, Michael D. Brennan\n\n" #define FMT_N "%-20s%.0f\n" #define FMT_S "%-20s%s\n" /* print VERSION and exit */ void print_version(FILE *fp) { fprintf(fp, VERSION_STRING, PATCH_BASE, PATCH_LEVEL, PATCH_STRING, DATE_STRING); fflush(fp); #define SHOW_RANDOM "random-funcs:" #if defined(NAME_RANDOM) fprintf(fp, FMT_S, SHOW_RANDOM, NAME_RANDOM); #else fprintf(fp, FMT_S, SHOW_RANDOM, "internal"); #endif #define SHOW_REGEXP "regex-funcs:" #ifdef LOCAL_REGEXP fprintf(fp, FMT_S, SHOW_REGEXP, "internal"); #else fprintf(fp, FMT_S, SHOW_REGEXP, "external"); #endif fprintf(fp, "\ncompiled limits:\n"); fprintf(fp, FMT_N, "sprintf buffer", (double) SPRINTF_LIMIT); fprintf(fp, FMT_N, "maximum-integer", (double) MAX__INT); #if 0 /* we could show these, but for less benefit: */ fprintf(fp, FMT_N, "maximum-unsigned", (double) MAX__UINT); fprintf(fp, FMT_N, "maximum-long", (double) MAX__LONG); fprintf(fp, "\nactual limits:\n"); fprintf(fp, FMT_N, "sprintf buffer", (double) (sprintf_limit - sprintf_buff)); #endif mawk_exit(0); } mawk-1.3.4-20240123/memory.h0000644000000000000000000000167314457054040013542 0ustar rootroot/******************************************** memory.h copyright 2009-2010,2023 Thomas E. Dickey copyright 1991,1993, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: memory.h,v 1.10 2023/07/22 22:28:48 tom Exp $ */ /* memory.h */ #ifndef MAWK_MEMORY_H #define MAWK_MEMORY_H #include "types.h" #include "zmalloc.h" STRING *new_STRING(const char *); STRING *new_STRING0(size_t); STRING *new_STRING1(const char *, size_t); #ifdef DEBUG void DB_free_STRING(STRING *); #define free_STRING(s) DB_free_STRING(s) #else #define free_STRING(sval) \ do { \ if ( -- (sval)->ref_cnt == 0 && \ sval != &null_str ) \ zfree(sval, (sval)->len + STRING_OH) ; \ } while (0) #endif #endif /* MAWK_MEMORY_H */ mawk-1.3.4-20240123/COPYING0000644000000000000000000004325412664177716013133 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. mawk-1.3.4-20240123/rexp.c0000644000000000000000000002335314535352225013205 0ustar rootroot/******************************************** rexp.c copyright 2008-2020,2023, Thomas E. Dickey copyright 1991-1993,1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: rexp.c,v 1.39 2023/12/10 15:09:09 Paul.Eggert Exp $ */ /* op precedence parser for regular expressions */ #include "rexp.h" #include "regexp.h" /* DATA */ int REerrno; const char *const REerrlist[] = {(char *) 0, /* 1 */ "missing '('", /* 2 */ "missing ')'", /* 3 */ "bad class -- [], [^] or [", /* 4 */ "missing operand", /* 5 */ "resource exhaustion -- regular expression too large", /* 6 */ "syntax error ^* or ^+", /* 7 */ "bad interval expression", /* 8 */ "" }; /* ERR_5 is very unlikely to occur */ /* This table drives the operator precedence parser */ /* *INDENT-OFF* */ #ifdef NO_INTERVAL_EXPR static short table[8][8] = { /* 0 | CAT * + ? ( ) */ /* 0 */ {0, OP_L, OP_L, OP_L, OP_L, OP_L, OP_L, ERR_1}, /* | */ {OP_G, OP_G, OP_L, OP_L, OP_L, OP_L, OP_L, OP_G}, /* CAT*/ {OP_G, OP_G, OP_G, OP_L, OP_L, OP_L, OP_L, OP_G}, /* * */ {OP_G, OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G}, /* + */ {OP_G, OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G}, /* ? */ {OP_G, OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G}, /* ( */ {ERR_2, OP_L, OP_L, OP_L, OP_L, OP_L, OP_L, OP_EQ}, /* ) */ {OP_G , OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G}}; #else static short table[10][10] = { /* 0 | CAT * + ? ( ) { } */ /* 0 */ {0, OP_L, OP_L, OP_L, OP_L, OP_L, OP_L, ERR_1, ERR_7, OP_L}, /* | */ {OP_G, OP_G, OP_L, OP_L, OP_L, OP_L, OP_L, OP_G, OP_G, OP_G}, /* CAT*/ {OP_G, OP_G, OP_G, OP_L, OP_L, OP_L, OP_L, OP_G, OP_L, OP_G}, /* * */ {OP_G, OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G, OP_G, OP_G}, /* + */ {OP_G, OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G, OP_G, OP_G}, /* ? */ {OP_G, OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G, OP_G, OP_G}, /* ( */ {ERR_2, OP_L, OP_L, OP_L, OP_L, OP_L, OP_L, OP_EQ, OP_G, OP_G}, /* ) */ {OP_G , OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G, ERR_7, OP_G}, /* { */ {OP_G, OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G, OP_G, OP_EQ}, /* } */ {OP_G , OP_G, OP_G, OP_G, OP_G, OP_G, ERR_7, OP_G, ERR_7, OP_G} }; #endif /* *INDENT-ON* */ #define STACKSZ 64 static jmp_buf err_buf; /* used to trap on error */ #if OPT_TRACE > 0 static const char * token_name(int token) { const char *result; #define CASE(name) case name: result = #name; break switch (token) { CASE(T_NONE); CASE(T_OR); CASE(T_CAT); CASE(T_STAR); CASE(T_PLUS); CASE(T_Q); CASE(T_LP); CASE(T_RP); CASE(T_START); CASE(T_END); CASE(T_ANY); CASE(T_CLASS); CASE(T_SLASH); CASE(T_CHAR); CASE(T_STR); #ifndef NO_INTERVAL_EXPR CASE(T_LB); CASE(T_RB); #endif CASE(T_U); default: result = "?"; break; } #undef CASE return result; } #endif void RE_error_trap(int x) { REerrno = x; longjmp(err_buf, 1); } typedef struct { int token; int prec; } OPS; /* duplicate_m() relies upon copying machines whose size is 1, i.e., atoms */ #define BigMachine(mp) (((mp)->stop - (mp)->start) > 1) STATE * REcompile(char *re, size_t len) { MACHINE m_stack[STACKSZ]; OPS op_stack[STACKSZ]; register MACHINE *m_ptr; register OPS *op_ptr; register int t; /* do this first because it also checks if we have a run time stack */ RE_lex_init(re, len); if (len == 0) { STATE *p = (STATE *) RE_malloc(sizeof(STATE)); p->s_type = M_ACCEPT; return p; } if (setjmp(err_buf)) return NULL; /* we used to try to recover memory left on machine stack ; but now m_ptr is in a register so it won't be right unless we force it out of a register which isn't worth the trouble */ /* initialize the stacks */ m_ptr = m_stack - 1; op_ptr = op_stack; op_ptr->token = 0; t = RE_lex(m_stack); while (1) { TRACE(("RE_lex token %s\n", token_name(t))); switch (t) { case T_STR: case T_ANY: case T_U: case T_START: case T_END: case T_CLASS: m_ptr++; break; #ifndef NO_INTERVAL_EXPR case T_RB: if (!repetitions_flag) { goto default_case; } /* interval expression {n,m} * eg, * convert m{3} to mmm * convert m{3,} to mmm* (with a limit of MAX_INT) * convert m{3,10} to mmm* with a limit of 10 */ if (intrvalmin == 0) { /* zero or more */ switch (intrvalmax) { case 0: /* user stupidity: m{0} or m{0,0} * don't add this re token */ if (op_ptr != op_stack) { /* no previous re */ RE_free(m_ptr->start); m_ptr--; switch (op_ptr->token) { case T_RP: while (op_ptr != op_stack) { --op_ptr; if (op_ptr->token == T_LP) { if (op_ptr == op_stack) { op_ptr->token = T_NONE; } else { --op_ptr; } break; } } op_ptr = op_stack + 1; break; case T_LP: break; default: op_ptr--; break; } } else if (*re_exp == '\0') { /* this was the only re expr so leave one M_ACCEPT as the machine */ m_ptr->start->s_type = M_ACCEPT; } else { RE_free(m_ptr->start); m_ptr--; } TRACE(("RE_lex token %s\n", "of zero interval is ignored!")); break; case 1: RE_01(m_ptr); /* m{0,1} which is m? */ TRACE(("RE_lex token %s\n", token_name(T_Q))); break; default: RE_close_limit(m_ptr, intrvalmin, intrvalmax); TRACE(("RE_lex token %s\n", token_name(T_Q))); } } else if (BigMachine(m_ptr)) { RE_poscl_limit(m_ptr, intrvalmin, intrvalmax); #ifdef NO_RI_LOOP_UNROLL } else if (intrvalmin >= 1) { /* one or more */ RE_poscl_limit(m_ptr, intrvalmin, intrvalmax); TRACE(("RE_lex token %s\n", token_name(T_PLUS))); #else } else if (intrvalmin == 1) { /* one or more */ RE_poscl_limit(m_ptr, intrvalmin, intrvalmax); TRACE(("RE_lex token %s\n", token_name(T_PLUS))); #endif } else { /* n or more */ register Int i; /* copy 2 copies of m_ptr, use 2nd copy to replace the first copy that gets swallowed by concat */ MACHINE *result_mp = m_ptr; MACHINE *concat_mp = (m_ptr + 1); MACHINE *new_mp = (m_ptr + 2); duplicate_m(concat_mp, result_mp); duplicate_m(new_mp, result_mp); for (i = 2; i <= intrvalmin; i++) { RE_cat(result_mp, concat_mp); duplicate_m(concat_mp, new_mp); } /* don't need 2nd copy in new_mp */ RE_free(new_mp->start); } break; #endif /* ! NO_INTERVAL_EXPR */ case 0: /* end of reg expr */ if (op_ptr->token == 0) { /* done */ if (m_ptr == m_stack) { return m_ptr->start; } else { /* machines still on the stack */ RE_panic("values still on machine stack for %s", re); } } /* FALLTHRU */ /* otherwise, default is operator case */ default: #ifndef NO_INTERVAL_EXPR default_case: #endif if ((op_ptr->prec = table[op_ptr->token][t]) == OP_G) { do { /* op_pop */ if (op_ptr->token <= T_CAT) { /*binary op */ if (m_ptr == m_stack && op_ptr->token == T_CAT) { TRACE(("...ignoring empty T_CAT\n")); op_ptr--; continue; } m_ptr--; } /* if not enough values on machine stack then we have a missing operand */ if (m_ptr < m_stack) RE_error_trap(-ERR_4); switch (op_ptr->token) { case T_CAT: RE_cat(m_ptr, m_ptr + 1); break; case T_OR: RE_or(m_ptr, m_ptr + 1); break; case T_STAR: RE_close(m_ptr); break; case T_PLUS: RE_poscl(m_ptr); break; case T_Q: RE_01(m_ptr); break; default: /*nothing on ( or ) */ break; } op_ptr--; } while (op_ptr->prec != OP_L); continue; /* back thru switch at top */ } if (op_ptr->prec < 0) { if (op_ptr->prec == ERR_7) RE_panic("parser returns ERR_7"); else RE_error_trap(-op_ptr->prec); } if (++op_ptr == op_stack + STACKSZ) { /* stack overflow */ RE_error_trap(-ERR_5); } op_ptr->token = t; } /* end of switch */ if (m_ptr == m_stack + (STACKSZ - 1)) { /*overflow */ RE_error_trap(-ERR_5); } t = RE_lex(m_ptr + 1); } } void REdestroy(STATE * ptr) { int done = 0; int n = 0; STATE *q = ptr; TRACE(("REdestroy %p\n", (void *) ptr)); while (!done) { TRACE(("...destroy[%d] %p type %s\n", n, q, REs_type(q))); switch (q->s_type) { case M_ACCEPT: done = 1; break; case M_STR: RE_free(q->s_data.str); break; default: if (q->s_type < 0 || q->s_type > END_ON) done = -1; break; } ++q; ++n; } RE_free(ptr); } /* getting here means a logic flaw or unforeseen case */ void RE_panic(const char *format, ...) { const char *where = "REcompile() - panic: "; va_list args; fflush(stdout); #if OPT_TRACE > 0 va_start(args, format); Trace("?? %s", where); TraceVA(format, args); Trace("\n"); va_end(args); #endif fputs(where, stderr); va_start(args, format); vfprintf(stderr, format, args); va_end(args); fprintf(stderr, "\n"); mawk_exit(100); } /* getting regexp error message */ const char * REerror(void) { return REerrlist[REerrno]; } #ifndef NO_INTERVAL_EXPR /* duplicate a machine, oldmp into newmp */ void duplicate_m(MACHINE * newmp, MACHINE * oldmp) { register STATE *p; p = (STATE *) RE_malloc(2 * STATESZ); RE_copy_states(p, oldmp->start, 2); newmp->start = (STATE *) p; newmp->stop = (STATE *) (p + 1); } #endif /* NO_INTERVAL_EXPR */ mawk-1.3.4-20240123/INSTALL0000644000000000000000000002231010771537705013112 0ustar rootrootInstallation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. mawk-1.3.4-20240123/array.c0000644000000000000000000003421714453357513013352 0ustar rootroot/* array.c */ /* $MawkId: array.c,v 1.27 2023/07/11 23:01:31 tom Exp $ copyright 2009-2021,2023 Thomas E. Dickey copyright 1991-1996,2014 Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. array.c and array.h were originally generated with the commands notangle -R'"array.c"' array.w > array.c notangle -R'"array.h"' array.w > array.h Notangle is part of Norman Ramsey's noweb literate programming package available from CTAN(ftp.shsu.edu). */ #include "mawk.h" #include "symtype.h" #include "memory.h" #include "split.h" #include "field.h" #include "bi_vars.h" struct anode; typedef struct { struct anode *slink, *ilink; } DUAL_LINK; typedef struct anode { struct anode *slink; struct anode *ilink; STRING *sval; unsigned hval; Int ival; CELL cell; } ANODE; static ANODE *find_by_ival(ARRAY, Int, int, int *); static ANODE *find_by_sval(ARRAY, STRING *, int, int *); #define NOT_AN_IVALUE (-Max_Int-1) /* usually 0x80000000 */ static void add_string_associations(ARRAY); #define STARTING_HMASK 63 /* 2^6-1, must have form 2^n-1 */ #define MAX_AVE_LIST_LENGTH 12 #define hmask_to_limit(x) (((x)+1)*MAX_AVE_LIST_LENGTH) #define ahash(sval) hash2((sval)->str, (sval)->len) static void make_empty_table(ARRAY, int); static void convert_split_array_to_table(ARRAY); static void double_the_hash_table(ARRAY); CELL * array_find( ARRAY A, CELL *cp, int create_flag) { ANODE *ap; int redid; if (A->size == 0 && !create_flag) /* eliminating this trivial case early avoids unnecessary conversions later */ return (CELL *) 0; switch (cp->type) { case C_DOUBLE: { double d = cp->dval; Int ival = d_to_I(d); if ((double) ival == d) { if (A->type == AY_SPLIT) { if (ival >= 1 && ival <= (int) A->size) return (CELL *) A->ptr + (ival - 1); if (!create_flag) return (CELL *) 0; convert_split_array_to_table(A); } else if (A->type == AY_NULL) make_empty_table(A, AY_INT); ap = find_by_ival(A, ival, create_flag, &redid); } else { /* convert to string */ char buff[260]; STRING *sval; sprintf(buff, string(CONVFMT)->str, d); sval = new_STRING(buff); ap = find_by_sval(A, sval, create_flag, &redid); free_STRING(sval); } } break; case C_NOINIT: ap = find_by_sval(A, &null_str, create_flag, &redid); break; default: ap = find_by_sval(A, string(cp), create_flag, &redid); break; } return ap ? &ap->cell : (CELL *) 0; } void array_delete( ARRAY A, CELL *cp) { ANODE *ap; int redid; if (A->size == 0) return; switch (cp->type) { case C_DOUBLE: { double d = cp->dval; Int ival = d_to_I(d); if ((double) ival == d) { if (A->type == AY_SPLIT) { if (ival >= 1 && ival <= (int) A->size) convert_split_array_to_table(A); else return; /* ival not in range */ } ap = find_by_ival(A, ival, NO_CREATE, &redid); if (ap) { /* remove from the front of the ilist */ DUAL_LINK *table = (DUAL_LINK *) A->ptr; table[(unsigned) ap->ival & A->hmask].ilink = ap->ilink; if (ap->sval) { ANODE *p, *q = 0; unsigned indx = (unsigned) ap->hval & A->hmask; p = table[indx].slink; while (p != ap) { q = p; p = q->slink; } if (q) q->slink = p->slink; else table[indx].slink = p->slink; free_STRING(ap->sval); } cell_destroy(&ap->cell); ZFREE(ap); if (--A->size == 0) array_clear(A); } return; } else { /* get the string value */ char buff[260]; STRING *sval; sprintf(buff, string(CONVFMT)->str, d); sval = new_STRING(buff); ap = find_by_sval(A, sval, NO_CREATE, &redid); free_STRING(sval); } } break; case C_NOINIT: ap = find_by_sval(A, &null_str, NO_CREATE, &redid); break; default: ap = find_by_sval(A, string(cp), NO_CREATE, &redid); break; } if (ap) { /* remove from the front of the slist */ DUAL_LINK *table = (DUAL_LINK *) A->ptr; table[ap->hval & A->hmask].slink = ap->slink; if (ap->ival != NOT_AN_IVALUE) { ANODE *p, *q = 0; unsigned indx = (unsigned) ap->ival & A->hmask; p = table[indx].ilink; while (p != ap) { q = p; p = q->ilink; } if (q) q->ilink = p->ilink; else table[indx].ilink = p->ilink; } free_STRING(ap->sval); cell_destroy(&ap->cell); ZFREE(ap); if (--A->size == 0) array_clear(A); } } void array_load( ARRAY A, size_t cnt) { if (A->type != AY_SPLIT || A->limit < cnt) { array_clear(A); A->limit = (cnt & (size_t) ~3) + 4; A->ptr = zmalloc(A->limit * sizeof(CELL)); A->type = AY_SPLIT; } else { /* reusing an existing AY_SPLIT array */ size_t i; for (i = 0; i < A->size; i++) { cell_destroy((CELL *) A->ptr + i); } } A->size = cnt; transfer_to_array((CELL *) A->ptr, cnt); } void array_clear(ARRAY A) { unsigned i; ANODE *p, *q; if (A->type == AY_SPLIT) { for (i = 0; i < A->size; i++) cell_destroy((CELL *) A->ptr + i); zfree(A->ptr, A->limit * sizeof(CELL)); } else if (A->type & AY_STR) { DUAL_LINK *table = (DUAL_LINK *) A->ptr; for (i = 0; (unsigned) i <= A->hmask; i++) { p = table[i].slink; while (p) { q = p; p = q->slink; free_STRING(q->sval); cell_destroy(&q->cell); ZFREE(q); } } zfree(A->ptr, (A->hmask + 1) * sizeof(DUAL_LINK)); } else if (A->type & AY_INT) { DUAL_LINK *table = (DUAL_LINK *) A->ptr; for (i = 0; (unsigned) i <= A->hmask; i++) { p = table[i].ilink; while (p) { q = p; p = q->ilink; cell_destroy(&q->cell); ZFREE(q); } } zfree(A->ptr, (A->hmask + 1) * sizeof(DUAL_LINK)); } memset(A, 0, sizeof(*A)); } static int string_compare( const void *l, const void *r) { STRING *const *a = (STRING * const *) l; STRING *const *b = (STRING * const *) r; return strcmp((*a)->str, (*b)->str); } STRING ** array_loop_vector( ARRAY A, size_t *sizep) { *sizep = A->size; if (A->size > 0) { STRING **ret; if (!(A->type & AY_STR)) add_string_associations(A); ret = (STRING **) zmalloc(A->size * sizeof(STRING *)); { int r = 0; /* indexes ret */ DUAL_LINK *table = (DUAL_LINK *) A->ptr; int i; /* indexes table */ ANODE *p; /* walks slists */ for (i = 0; (unsigned) i <= A->hmask; i++) { for (p = table[i].slink; p; p = p->slink) { ret[r++] = p->sval; p->sval->ref_cnt++; } } } if (getenv("WHINY_USERS") != NULL) /* gawk compatibility */ qsort(ret, A->size, sizeof(STRING *), string_compare); return ret; } return (STRING **) 0; } CELL * array_cat( CELL *sp, int cnt) { CELL *p; /* walks the eval stack */ CELL subsep; /* local copy of SUBSEP */ size_t subsep_len; /* string length of subsep_str */ char *subsep_str; size_t total_len; /* length of cat'ed expression */ CELL *top; /* value of sp at entry */ char *target; /* build cat'ed char* here */ STRING *sval; /* build cat'ed STRING here */ cellcpy(&subsep, SUBSEP); if (subsep.type < C_STRING) cast1_to_s(&subsep); subsep_len = string(&subsep)->len; subsep_str = string(&subsep)->str; assert(cnt > 0); top = sp; sp -= (cnt - 1); total_len = ((size_t) (cnt - 1)) * subsep_len; for (p = sp; p <= top; p++) { if (p->type < C_STRING) cast1_to_s(p); total_len += string(p)->len; } sval = new_STRING0(total_len); target = sval->str; for (p = sp; p < top; p++) { memcpy(target, string(p)->str, string(p)->len); target += string(p)->len; memcpy(target, subsep_str, subsep_len); target += subsep_len; } /* now p == top */ memcpy(target, string(p)->str, string(p)->len); for (p = sp; p <= top; p++) free_STRING(string(p)); free_STRING(string(&subsep)); /* set contents of sp , sp->type > C_STRING is possible so reset */ sp->type = C_STRING; sp->ptr = (PTR) sval; return sp; } static ANODE * find_by_ival( ARRAY A, Int ival, int create_flag, int *redo) { DUAL_LINK *table = (DUAL_LINK *) A->ptr; unsigned indx = (unsigned) ival & A->hmask; ANODE *p = table[indx].ilink; /* walks ilist */ ANODE *q = (ANODE *) 0; /* trails p */ while (1) { if (!p) { /* search failed */ if (A->type & AY_STR) { /* need to search by string */ char buff[256]; STRING *sval; sprintf(buff, LONG_FMT, (Long) ival); sval = new_STRING(buff); p = find_by_sval(A, sval, create_flag, redo); if (*redo) { table = (DUAL_LINK *) A->ptr; } free_STRING(sval); if (!p) return (ANODE *) 0; } else if (create_flag) { p = ZMALLOC(ANODE); p->sval = (STRING *) 0; p->cell.type = C_NOINIT; if (++A->size > A->limit) { double_the_hash_table(A); /* changes table, may change index */ table = (DUAL_LINK *) A->ptr; indx = A->hmask & (unsigned) ival; } } else return (ANODE *) 0; p->ival = ival; A->type |= AY_INT; break; } else if (p->ival == ival) { /* found it, now move to the front */ if (!q) /* already at the front */ return p; /* delete for insertion at the front */ q->ilink = p->ilink; break; } q = p; p = q->ilink; } /* insert at the front */ p->ilink = table[indx].ilink; table[indx].ilink = p; return p; } static ANODE * find_by_sval( ARRAY A, STRING * sval, int create_flag, int *redo) { unsigned hval = ahash(sval); char *str = sval->str; DUAL_LINK *table; unsigned indx; ANODE *p; /* walks list */ ANODE *q = (ANODE *) 0; /* trails p */ if (!(A->type & AY_STR)) add_string_associations(A); table = (DUAL_LINK *) A->ptr; indx = hval & A->hmask; p = table[indx].slink; *redo = 0; while (1) { if (!p) { if (create_flag) { { p = ZMALLOC(ANODE); p->sval = sval; sval->ref_cnt++; p->ival = NOT_AN_IVALUE; p->hval = hval; p->cell.type = C_NOINIT; if (++A->size > A->limit) { double_the_hash_table(A); /* changes table, may change index */ table = (DUAL_LINK *) A->ptr; indx = hval & A->hmask; *redo = 1; } } break; } return (ANODE *) 0; } else if (p->hval == hval) { if (strcmp(p->sval->str, str) == 0) { /* found */ if (!q) /* already at the front */ return p; else { /* delete for move to the front */ q->slink = p->slink; break; } } } q = p; p = q->slink; } p->slink = table[indx].slink; table[indx].slink = p; return p; } static void add_string_associations(ARRAY A) { if (A->type == AY_NULL) make_empty_table(A, AY_STR); else { DUAL_LINK *table; int i; /* walks table */ ANODE *p; /* walks ilist */ char buff[256]; if (A->type == AY_SPLIT) convert_split_array_to_table(A); table = (DUAL_LINK *) A->ptr; for (i = 0; (unsigned) i <= A->hmask; i++) { p = table[i].ilink; while (p) { sprintf(buff, LONG_FMT, (Long) p->ival); p->sval = new_STRING(buff); p->hval = ahash(p->sval); p->slink = table[A->hmask & p->hval].slink; table[A->hmask & p->hval].slink = p; p = p->ilink; } } A->type |= AY_STR; } } static void make_empty_table( ARRAY A, int type) /* AY_INT or AY_STR */ { size_t sz = (STARTING_HMASK + 1) * sizeof(DUAL_LINK); A->type = (short) type; A->hmask = STARTING_HMASK; A->limit = hmask_to_limit(STARTING_HMASK); A->ptr = memset(zmalloc(sz), 0, sz); } static void convert_split_array_to_table(ARRAY A) { CELL *cells = (CELL *) A->ptr; unsigned i; /* walks cells */ DUAL_LINK *table; unsigned j; /* walks table */ size_t entry_limit = A->limit; A->hmask = STARTING_HMASK; A->limit = hmask_to_limit(STARTING_HMASK); while (A->size > A->limit) { A->hmask = (A->hmask << 1) + 1; /* double the size */ A->limit = hmask_to_limit(A->hmask); } { size_t sz = (A->hmask + 1) * sizeof(DUAL_LINK); A->ptr = memset(zmalloc(sz), 0, sz); table = (DUAL_LINK *) A->ptr; } /* insert each cells[i] in the new hash table on an ilist */ for (i = 0, j = 1; i < A->size; i++) { ANODE *p = ZMALLOC(ANODE); p->sval = (STRING *) 0; p->ival = (Int) (i + 1); p->cell = cells[i]; p->ilink = table[j].ilink; table[j].ilink = p; j++; j &= A->hmask; } A->type = AY_INT; zfree(cells, entry_limit * sizeof(CELL)); } static void double_the_hash_table(ARRAY A) { unsigned old_hmask = A->hmask; unsigned new_hmask = (old_hmask << 1) + 1; DUAL_LINK *table; A->ptr = zrealloc(A->ptr, (old_hmask + 1) * sizeof(DUAL_LINK), (new_hmask + 1) * sizeof(DUAL_LINK)); table = (DUAL_LINK *) A->ptr; /* zero out the new part which is the back half */ memset(&table[old_hmask + 1], 0, (old_hmask + 1) * sizeof(DUAL_LINK)); if (A->type & AY_STR) { unsigned i; /* index to old lists */ unsigned j; /* index to new lists */ ANODE *p; /* walks an old list */ ANODE *q; /* trails p for deletion */ ANODE *tail; /* builds new list from the back */ ANODE dummy0, dummy1; for (i = 0, j = old_hmask + 1; i <= old_hmask; i++, j++) { q = &dummy0; q->slink = p = table[i].slink; tail = &dummy1; while (p) { if ((p->hval & new_hmask) != (unsigned) i) { /* move it */ q->slink = p->slink; tail = tail->slink = p; } else q = p; p = q->slink; } table[i].slink = dummy0.slink; tail->slink = (ANODE *) 0; table[j].slink = dummy1.slink; } } if (A->type & AY_INT) { unsigned i; /* index to old lists */ unsigned j; /* index to new lists */ ANODE *p; /* walks an old list */ ANODE *q; /* trails p for deletion */ ANODE *tail; /* builds new list from the back */ ANODE dummy0, dummy1; for (i = 0, j = old_hmask + 1; i <= old_hmask; i++, j++) { q = &dummy0; q->ilink = p = table[i].ilink; tail = &dummy1; while (p) { if (((unsigned) p->ival & new_hmask) != i) { /* move it */ q->ilink = p->ilink; tail = tail->ilink = p; } else q = p; p = q->ilink; } table[i].ilink = dummy0.ilink; tail->ilink = (ANODE *) 0; table[j].ilink = dummy1.ilink; } } A->hmask = new_hmask; A->limit = hmask_to_limit(new_hmask); } mawk-1.3.4-20240123/jmp.c0000644000000000000000000001154514054304013013001 0ustar rootroot/******************************************** jmp.c copyright 2009-2010,2021, Thomas E. Dickey copyright 1991-1993,1995, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: jmp.c,v 1.7 2021/05/29 00:17:15 tom Exp $ */ /* this module deals with back patching jumps, breaks and continues, and with save and restoring code when we move code. There are three stacks. If we encounter a compile error, the stacks are frozen, i.e., we do not attempt error recovery on the stacks */ #include "mawk.h" #include "symtype.h" #include "jmp.h" #include "code.h" #include "sizes.h" #include "init.h" #include "memory.h" #define error_state (compile_error_count>0) /*---------- back patching jumps ---------------*/ typedef struct jmp { struct jmp *link; int source_offset; } JMP; static JMP *jmp_top; void code_jmp(int jtype, INST * target) { if (error_state) return; /* WARNING: Don't emit any code before using target or relocation might make it invalid */ if (target) code2op(jtype, (int) (target - (code_ptr + 1))); else { register JMP *p = ZMALLOC(JMP); /* stack for back patch */ code2op(jtype, 0); p->source_offset = code_offset - 1; p->link = jmp_top; jmp_top = p; } } /* patch a jump on the jmp_stack */ void patch_jmp(INST * target) { if (!error_state) { register JMP *p; register INST *source; /* jmp starts here */ #ifdef DEBUG if (!jmp_top) bozo("jmp stack underflow"); #endif p = jmp_top; jmp_top = p->link; source = p->source_offset + code_base; source->op = (int) (target - source); ZFREE(p); } } /*-- break and continue -------*/ typedef struct bc { struct bc *link; /* stack as linked list */ int type; /* 'B' or 'C' or mark start with 0 */ int source_offset; /* position of _JMP */ } BC; static BC *bc_top; void BC_new(void) /* mark the start of a loop */ { BC_insert(0, (INST *) 0); } void BC_insert(int type, INST * address) { register BC *p; if (error_state) return; if (type && !bc_top) { compile_error("%s statement outside of loop", type == 'B' ? "break" : "continue"); return; } else { p = ZMALLOC(BC); p->type = type; p->source_offset = (int) (address - code_base); p->link = bc_top; bc_top = p; } } /* patch all break and continues for one loop */ void BC_clear(INST * B_address, INST * C_address) { register BC *p; if (error_state) return; p = bc_top; /* pop down to the mark node */ while (p->type) { INST *source; register BC *q; source = code_base + p->source_offset; source->op = (int) ((p->type == 'B' ? B_address : C_address) - source); q = p; p = p->link; ZFREE(q); } /* remove the mark node */ bc_top = p->link; ZFREE(p); } /*----- moving code --------------------------*/ /* a stack to hold some pieces of code while reorganizing loops . */ typedef struct mc { /* mc -- move code */ struct mc *link; INST *code; /* the save code */ unsigned len; /* its length */ int scope; /* its scope */ int move_level; /* size of this stack when coded */ FBLOCK *fbp; /* if scope FUNCT */ int offset; /* distance from its code base */ } MC; static MC *mc_top; int code_move_level = 0; /* see comment in jmp.h */ #define NO_SCOPE -1 /* means relocation of resolve list not needed */ void code_push(INST * code, unsigned len, int scope, FBLOCK * fbp) { register MC *p; if (!error_state) { p = ZMALLOC(MC); p->len = len; p->link = mc_top; mc_top = p; if (len) { p->code = (INST *) zmalloc(sizeof(INST) * len); memcpy(p->code, code, sizeof(INST) * len); } if (!resolve_list) p->scope = NO_SCOPE; else { p->scope = scope; p->move_level = code_move_level; p->fbp = fbp; if (code) p->offset = (int) (code - code_base); else p->offset = 0; } } code_move_level++; } /* copy the code at the top of the mc stack to target. return the number of INSTs moved */ unsigned code_pop(INST * target) { register MC *p; unsigned len; int target_offset; if (error_state) return 0; #ifdef DEBUG if (!mc_top) bozo("mc underflow"); #endif p = mc_top; mc_top = p->link; len = p->len; while (target + len >= code_warn) { target_offset = (int) (target - code_base); code_grow(); target = code_base + target_offset; } if (len) { memcpy(target, p->code, len * sizeof(INST)); zfree(p->code, len * sizeof(INST)); } if (p->scope != NO_SCOPE) { target_offset = (int) (target - code_base); relocate_resolve_list(p->scope, p->move_level, p->fbp, p->offset, len, target_offset - p->offset); } ZFREE(p); code_move_level--; return len; } mawk-1.3.4-20240123/aclocal.m40000644000000000000000000025663314553604443013736 0ustar rootrootdnl $MawkId: aclocal.m4,v 1.113 2024/01/23 00:32:35 tom Exp $ dnl custom mawk macros for autoconf dnl dnl The symbols beginning "CF_MAWK_" were originally written by Mike Brennan, dnl renamed for consistency by Thomas E Dickey. dnl dnl --------------------------------------------------------------------------- dnl Copyright: 2008-2023,2024 by Thomas E. Dickey dnl dnl Permission is hereby granted, free of charge, to any person obtaining a dnl copy of this software and associated documentation files (the dnl "Software"), to deal in the Software without restriction, including dnl without limitation the rights to use, copy, modify, merge, publish, dnl distribute, distribute with modifications, sublicense, and/or sell dnl copies of the Software, and to permit persons to whom the Software is dnl furnished to do so, subject to the following conditions: dnl dnl The above copyright notice and this permission notice shall be included dnl in all copies or portions of the Software. dnl dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. dnl dnl Except as contained in this notice, the name(s) of the above copyright dnl holders shall not be used in advertising or otherwise to promote the dnl sale, use or other dealings in this Software without prior written dnl authorization. dnl dnl --------------------------------------------------------------------------- dnl See dnl https://invisible-island.net/autoconf/autoconf.html dnl https://invisible-island.net/autoconf/my-autoconf.html dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49 dnl ------------------ dnl Conditionally generate script according to whether we're using a given autoconf. dnl dnl $1 = version to compare against dnl $2 = code to use if AC_ACVERSION is at least as high as $1. dnl $3 = code to use if AC_ACVERSION is older than $1. define([CF_ACVERSION_CHECK], [ ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl ifdef([m4_version_compare], [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])], [CF_ACVERSION_COMPARE( AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl dnl --------------------------------------------------------------------------- dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53 dnl -------------------- dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1, dnl MAJOR2, MINOR2, TERNARY2, dnl PRINTABLE2, not FOUND, FOUND) define([CF_ACVERSION_COMPARE], [ifelse(builtin([eval], [$2 < $5]), 1, [ifelse([$8], , ,[$8])], [ifelse([$9], , ,[$9])])])dnl dnl --------------------------------------------------------------------------- dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15 dnl ------------- dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS dnl $1 = flags to add dnl $2 = if given makes this macro verbose. dnl dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS, dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily dnl confused by the quotes (which require backslashes to keep them usable). AC_DEFUN([CF_ADD_CFLAGS], [ cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $1 do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) continue elif test "${cf_tst_cflags}" = "\"'" ; then CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags) ;; esac CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags) ;; esac ;; (*) CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags) ;; esac ;; (yes) CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)]) CF_APPEND_TEXT(CFLAGS,$cf_new_cflags) fi if test -n "$cf_new_cppflags" ; then ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)]) CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags) fi if test -n "$cf_new_extra_cppflags" ; then ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)]) CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags) fi AC_SUBST(EXTRA_CPPFLAGS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05 dnl ---------- dnl Add a library, used to enforce consistency. dnl dnl $1 = library to add, without the "-l" dnl $2 = variable to update (default $LIBS) AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl dnl --------------------------------------------------------------------------- dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33 dnl ----------- dnl Add one or more libraries, used to enforce consistency. Libraries are dnl prepended to an existing list, since their dependencies are assumed to dnl already exist in the list. dnl dnl $1 = libraries to add, with the "-l", etc. dnl $2 = variable to update (default $LIBS) AC_DEFUN([CF_ADD_LIBS],[ cf_add_libs="[$]ifelse($2,,LIBS,[$2])" # reverse order cf_add_0lib= for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done ifelse($2,,LIBS,[$2])="$cf_add_libs" ])dnl dnl --------------------------------------------------------------------------- dnl CF_APPEND_CFLAGS version: 3 updated: 2021/09/05 17:25:40 dnl ---------------- dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions. dnl $1 = flags to add dnl $2 = if given makes this macro verbose. define([CF_APPEND_CFLAGS], [ for cf_add_cflags in $1 do case "x$cf_add_cflags" in (x-[[DU]]*) CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2]) CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2]) ;; esac CF_ADD_CFLAGS([$cf_add_cflags],[$2]) done ])dnl dnl --------------------------------------------------------------------------- dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55 dnl -------------- dnl use this macro for appending text without introducing an extra blank at dnl the beginning define([CF_APPEND_TEXT], [ test -n "[$]$1" && $1="[$]$1 " $1="[$]{$1}$2" ])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31 dnl -------------- dnl Allow user to disable a normally-on option. AC_DEFUN([CF_ARG_DISABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31 dnl ------------- dnl Allow user to enable a normally-off option. AC_DEFUN([CF_ARG_ENABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl dnl --------------------------------------------------------------------------- dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14 dnl ------------- dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus dnl values. dnl dnl Parameters: dnl $1 = option name dnl $2 = help-string dnl $3 = action to perform if option is not default dnl $4 = action if perform if option is default dnl $5 = default option value (either 'yes' or 'no') AC_DEFUN([CF_ARG_OPTION], [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes) if test "$enableval" != "$5" ; then ifelse([$3],,[ :]dnl ,[ $3]) ifelse([$4],,,[ else $4]) fi],[enableval=$5 ifelse([$4],,,[ $4 ])dnl ])])dnl dnl --------------------------------------------------------------------------- dnl CF_BUILD_CC version: 11 updated: 2022/12/04 15:40:08 dnl ----------- dnl If we're cross-compiling, allow the user to override the tools and their dnl options. The configure script is oriented toward identifying the host dnl compiler, etc., but we need a build compiler to generate parts of the dnl source. dnl dnl $1 = default for $CPPFLAGS dnl $2 = default for $LIBS AC_DEFUN([CF_BUILD_CC],[ CF_ACVERSION_CHECK(2.52,, [AC_REQUIRE([CF_PROG_EXT])]) if test "$cross_compiling" = yes ; then # defaults that we might want to override : ${BUILD_CFLAGS:=''} : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'} : ${BUILD_LDFLAGS:=''} : ${BUILD_LIBS:='ifelse([$2],,,[$2])'} : ${BUILD_EXEEXT:='$x'} : ${BUILD_OBJEXT:='o'} AC_ARG_WITH(build-cc, [ --with-build-cc=XXX the build C compiler ($BUILD_CC)], [BUILD_CC="$withval"], [AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none)]) AC_MSG_CHECKING(for native build C compiler) AC_MSG_RESULT($BUILD_CC) AC_MSG_CHECKING(for native build C preprocessor) AC_ARG_WITH(build-cpp, [ --with-build-cpp=XXX the build C preprocessor ($BUILD_CPP)], [BUILD_CPP="$withval"], [BUILD_CPP='${BUILD_CC} -E']) AC_MSG_RESULT($BUILD_CPP) AC_MSG_CHECKING(for native build C flags) AC_ARG_WITH(build-cflags, [ --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)], [BUILD_CFLAGS="$withval"]) AC_MSG_RESULT($BUILD_CFLAGS) AC_MSG_CHECKING(for native build C preprocessor-flags) AC_ARG_WITH(build-cppflags, [ --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)], [BUILD_CPPFLAGS="$withval"]) AC_MSG_RESULT($BUILD_CPPFLAGS) AC_MSG_CHECKING(for native build linker-flags) AC_ARG_WITH(build-ldflags, [ --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)], [BUILD_LDFLAGS="$withval"]) AC_MSG_RESULT($BUILD_LDFLAGS) AC_MSG_CHECKING(for native build linker-libraries) AC_ARG_WITH(build-libs, [ --with-build-libs=XXX the build libraries (${BUILD_LIBS})], [BUILD_LIBS="$withval"]) AC_MSG_RESULT($BUILD_LIBS) # this assumes we're on Unix. BUILD_EXEEXT= BUILD_OBJEXT=o : ${BUILD_CC:='${CC}'} AC_MSG_CHECKING(if the build-compiler "$BUILD_CC" works) cf_save_crossed=$cross_compiling cf_save_ac_link=$ac_link cross_compiling=no cf_build_cppflags=$BUILD_CPPFLAGS test "$cf_build_cppflags" = "#" && cf_build_cppflags= ac_link='$BUILD_CC -o "conftest$ac_exeext" $BUILD_CFLAGS $cf_build_cppflags $BUILD_LDFLAGS "conftest.$ac_ext" $BUILD_LIBS >&AS_MESSAGE_LOG_FD' AC_TRY_RUN([#include int main(int argc, char *argv[]) { ${cf_cv_main_return:-return}(argc < 0 || argv == 0 || argv[0] == 0); } ], cf_ok_build_cc=yes, cf_ok_build_cc=no, cf_ok_build_cc=unknown) cross_compiling=$cf_save_crossed ac_link=$cf_save_ac_link AC_MSG_RESULT($cf_ok_build_cc) if test "$cf_ok_build_cc" != yes then AC_MSG_ERROR([Cross-build requires two compilers. Use --with-build-cc to specify the native compiler.]) fi else : ${BUILD_CC:='${CC}'} : ${BUILD_CPP:='${CPP}'} : ${BUILD_CFLAGS:='${CFLAGS}'} : ${BUILD_CPPFLAGS:='${CPPFLAGS}'} : ${BUILD_LDFLAGS:='${LDFLAGS}'} : ${BUILD_LIBS:='${LIBS}'} : ${BUILD_EXEEXT:='$x'} : ${BUILD_OBJEXT:='o'} fi AC_SUBST(BUILD_CC) AC_SUBST(BUILD_CPP) AC_SUBST(BUILD_CFLAGS) AC_SUBST(BUILD_CPPFLAGS) AC_SUBST(BUILD_LDFLAGS) AC_SUBST(BUILD_LIBS) AC_SUBST(BUILD_EXEEXT) AC_SUBST(BUILD_OBJEXT) ])dnl dnl --------------------------------------------------------------------------- dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25 dnl --------------- AC_DEFUN([CF_C11_NORETURN], [ AC_MSG_CHECKING(if you want to use C11 _Noreturn feature) CF_ARG_ENABLE(stdnoreturn, [ --enable-stdnoreturn enable C11 _Noreturn feature for diagnostics], [enable_stdnoreturn=yes], [enable_stdnoreturn=no]) AC_MSG_RESULT($enable_stdnoreturn) if test $enable_stdnoreturn = yes; then AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn, [AC_TRY_COMPILE([ $ac_includes_default #include static _Noreturn void giveup(void) { exit(0); } ], [if (feof(stdin)) giveup()], cf_cv_c11_noreturn=yes, cf_cv_c11_noreturn=no) ]) else cf_cv_c11_noreturn=no, fi if test "$cf_cv_c11_noreturn" = yes; then AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if header is available and working]) AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported]) HAVE_STDNORETURN_H=1 else HAVE_STDNORETURN_H=0 fi AC_SUBST(HAVE_STDNORETURN_H) AC_SUBST(STDC_NORETURN) ])dnl dnl --------------------------------------------------------------------------- dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46 dnl --------------- dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content dnl into CC. This will not help with broken scripts that wrap the compiler dnl with options, but eliminates a more common category of user confusion. dnl dnl In particular, it addresses the problem of being able to run the C dnl preprocessor in a consistent manner. dnl dnl Caveat: this also disallows blanks in the pathname for the compiler, but dnl the nuisance of having inconsistent settings for compiler and preprocessor dnl outweighs that limitation. AC_DEFUN([CF_CC_ENV_FLAGS], [ # This should have been defined by AC_PROG_CC : "${CC:=cc}" AC_MSG_CHECKING(\$CFLAGS variable) case "x$CFLAGS" in (*-[[IUD]]*) AC_MSG_RESULT(broken) AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options) cf_flags="$CFLAGS" CFLAGS= for cf_arg in $cf_flags do CF_ADD_CFLAGS($cf_arg) done ;; (*) AC_MSG_RESULT(ok) ;; esac AC_MSG_CHECKING(\$CC variable) case "$CC" in (*[[\ \ ]]-*) AC_MSG_RESULT(broken) AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options) # humor him... cf_prog=`echo "$CC" | sed -e 's/ / /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'` cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"` CC="$cf_prog" for cf_arg in $cf_flags do case "x$cf_arg" in (x-[[IUDfgOW]]*) CF_ADD_CFLAGS($cf_arg) ;; (*) CC="$CC $cf_arg" ;; esac done CF_VERBOSE(resulting CC: '$CC') CF_VERBOSE(resulting CFLAGS: '$CFLAGS') CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS') ;; (*) AC_MSG_RESULT(ok) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15 dnl -------------- dnl Check if we're accidentally using a cache from a different machine. dnl Derive the system name, as a check for reusing the autoconf cache. dnl dnl If we've packaged config.guess and config.sub, run that (since it does a dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM dnl which is useful in cross-compiles. dnl dnl Note: we would use $ac_config_sub, but that is one of the places where dnl autoconf 2.5x broke compatibility with autoconf 2.13 AC_DEFUN([CF_CHECK_CACHE], [ if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then ifelse([$1],,[AC_CANONICAL_HOST],[$1]) system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.]) AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name) if test ".$system_name" != ".$cf_cv_system_name" ; then AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)) AC_MSG_ERROR("Please remove config.cache and try again.") fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_CHECK_ENVIRON version: 5 updated: 2023/02/18 17:41:25 dnl ---------------- dnl Check for data that is usually declared in , e.g., the 'environ' dnl variable. Define a DECL_xxx symbol if we must declare it ourselves. dnl dnl $1 = the name to check dnl $2 = the assumed type AC_DEFUN([CF_CHECK_ENVIRON], [ AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[ AC_TRY_COMPILE([ $ac_includes_default], ifelse([$2],,void*,[$2]) x = (ifelse([$2],,void*,[$2])) $1; (void)x, [cf_cv_dcl_$1=yes], [cf_cv_dcl_$1=no]) ]) if test "$cf_cv_dcl_$1" = no ; then CF_UPPER(cf_result,decl_$1) AC_DEFINE_UNQUOTED($cf_result) fi # It's possible (for near-UNIX clones) that the data doesn't exist CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2])) ])dnl dnl --------------------------------------------------------------------------- dnl CF_CHECK_EXTERN_DATA version: 5 updated: 2021/09/04 06:35:04 dnl -------------------- dnl Check for existence of external data in the current set of libraries. If dnl we can modify it, it is real enough. dnl $1 = the name to check dnl $2 = its type AC_DEFUN([CF_CHECK_EXTERN_DATA], [ AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[ AC_TRY_LINK([ #undef $1 extern $2 $1; ], [$1 = 2], [cf_cv_have_$1=yes], [cf_cv_have_$1=no]) ]) if test "$cf_cv_have_$1" = yes ; then CF_UPPER(cf_result,have_$1) AC_DEFINE_UNQUOTED($cf_result) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25 dnl ----------------- dnl Check if the given compiler is really clang. clang's C driver defines dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does dnl not ignore some gcc options. dnl dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from dnl the wrappers for gcc and g++ warnings. dnl dnl $1 = GCC (default) or GXX dnl $2 = CLANG_COMPILER (default) dnl $3 = CFLAGS (default) or CXXFLAGS AC_DEFUN([CF_CLANG_COMPILER],[ ifelse([$2],,CLANG_COMPILER,[$2])=no if test "$ifelse([$1],,[$1],GCC)" = yes ; then AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler) cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])" AC_TRY_COMPILE([],[ #ifdef __clang__ #else #error __clang__ is not defined #endif ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes ],[]) ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2])) fi CLANG_VERSION=none if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then case "$CC" in (c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]]) AC_MSG_WARN(replacing broken compiler alias $CC) CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" CC=clang ;; esac AC_MSG_CHECKING(version of $CC) CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" test -z "$CLANG_VERSION" && CLANG_VERSION=unknown AC_MSG_RESULT($CLANG_VERSION) for cf_clang_opt in \ -Qunused-arguments \ -Wno-error=implicit-function-declaration do AC_MSG_CHECKING(if option $cf_clang_opt works) cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cf_clang_opt" AC_TRY_LINK([ #include ],[ printf("hello!\\n");],[ cf_clang_optok=yes],[ cf_clang_optok=no]) AC_MSG_RESULT($cf_clang_optok) CFLAGS="$cf_save_CFLAGS" if test "$cf_clang_optok" = yes; then CF_VERBOSE(adding option $cf_clang_opt) CF_APPEND_TEXT(CFLAGS,$cf_clang_opt) fi done fi ]) dnl --------------------------------------------------------------------------- dnl CF_CONST_X_STRING version: 8 updated: 2023/12/01 17:22:50 dnl ----------------- dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most dnl character-strings. dnl dnl It is ambiguous because the specification accommodated the pre-ANSI dnl compilers bundled by more than one vendor in lieu of providing a standard C dnl compiler other than by costly add-ons. Because of this, the specification dnl did not take into account the use of const for telling the compiler that dnl string literals would be in readonly memory. dnl dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to dnl let the compiler decide how to represent Xt's strings which were #define'd. dnl That does not solve the problem of using the block of Xt's strings which dnl are compiled into the library (and is less efficient than one might want). dnl dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both dnl when compiling the library and compiling using the library, to tell the dnl compiler that String is const. AC_DEFUN([CF_CONST_X_STRING], [ AC_REQUIRE([AC_PATH_XTRA]) CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING]) AC_TRY_COMPILE( [ #include #include ], [String foo = malloc(1); free((void*)foo)],[ AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[ AC_TRY_COMPILE( [ #undef _CONST_X_STRING #define _CONST_X_STRING /* X11R7.8 (perhaps) */ #undef XTSTRINGDEFINES /* X11R5 and later */ #include #include ],[String foo = malloc(1); *foo = 0],[ cf_cv_const_x_string=no ],[ cf_cv_const_x_string=yes ]) ]) CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING]) case "$cf_cv_const_x_string" in (no) CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES) ;; (*) CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING) ;; esac ]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04 dnl --------------- dnl You can always use "make -n" to see the actual options, but it is hard to dnl pick out/analyze warning messages when the compile-line is long. dnl dnl Sets: dnl ECHO_LT - symbol to control if libtool is verbose dnl ECHO_LD - symbol to prefix "cc -o" lines dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o) dnl SHOW_CC - symbol to put before explicit "cc -c" lines dnl ECHO_CC - symbol to put before any "cc" line dnl AC_DEFUN([CF_DISABLE_ECHO],[ AC_MSG_CHECKING(if you want to see long compiling messages) CF_ARG_DISABLE(echo, [ --disable-echo do not display "compiling" commands], [ ECHO_LT='--silent' ECHO_LD='@echo linking [$]@;' RULE_CC='@echo compiling [$]<' SHOW_CC='@echo compiling [$]@' ECHO_CC='@' ],[ ECHO_LT='' ECHO_LD='' RULE_CC='' SHOW_CC='' ECHO_CC='' ]) AC_MSG_RESULT($enableval) AC_SUBST(ECHO_LT) AC_SUBST(ECHO_LD) AC_SUBST(RULE_CC) AC_SUBST(SHOW_CC) AC_SUBST(ECHO_CC) ])dnl dnl --------------------------------------------------------------------------- dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50 dnl ---------------- dnl Combine no-leak checks with the libraries or tools that are used for the dnl checks. AC_DEFUN([CF_DISABLE_LEAKS],[ AC_REQUIRE([CF_WITH_DMALLOC]) AC_REQUIRE([CF_WITH_DBMALLOC]) AC_REQUIRE([CF_WITH_VALGRIND]) AC_MSG_CHECKING(if you want to perform memory-leak testing) AC_ARG_ENABLE(leaks, [ --disable-leaks test: free permanent memory, analyze leaks], [enable_leaks=$enableval], [enable_leaks=yes]) dnl with_no_leaks is more readable... if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi AC_MSG_RESULT($with_no_leaks) if test "$enable_leaks" = no ; then AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.]) AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_ENABLE_TRACE version: 3 updated: 2012/10/04 05:24:07 dnl --------------- AC_DEFUN([CF_ENABLE_TRACE],[ AC_MSG_CHECKING(if you want to enable debugging trace) CF_ARG_ENABLE(trace, [ --enable-trace test: turn on debug-tracing], [with_trace=yes], [with_trace=no]) AC_MSG_RESULT($with_trace) if test "$with_trace" = "yes" then AC_DEFINE(OPT_TRACE,1,[Define to 1 if you want to enable debugging trace]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50 dnl ------------------ dnl Configure-option to enable gcc warnings dnl dnl $1 = extra options to add, if supported dnl $2 = option for checking attributes. By default, this is done when dnl warnings are enabled. For other values: dnl yes: always do this, e.g., to use in generated library-headers dnl no: never do this AC_DEFUN([CF_ENABLE_WARNINGS],[ if test "$GCC" = yes || test "$GXX" = yes then CF_FIX_WARNINGS(CFLAGS) CF_FIX_WARNINGS(CPPFLAGS) CF_FIX_WARNINGS(LDFLAGS) AC_MSG_CHECKING(if you want to turn on gcc warnings) CF_ARG_ENABLE(warnings, [ --enable-warnings test: turn on gcc compiler warnings], [enable_warnings=yes], [enable_warnings=no]) AC_MSG_RESULT($enable_warnings) if test "$enable_warnings" = "yes" then ifelse($2,,[CF_GCC_ATTRIBUTES]) CF_GCC_WARNINGS($1) fi ifelse($2,yes,[CF_GCC_ATTRIBUTES]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31 dnl --------------- dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc. Any of gcc's dnl "-Werror" flags can interfere with configure-checks. Those go into dnl EXTRA_CFLAGS. dnl dnl $1 = variable name to repair define([CF_FIX_WARNINGS],[ if test "$GCC" = yes || test "$GXX" = yes then case [$]$1 in (*-Werror=*) cf_temp_flags= for cf_temp_scan in [$]$1 do case "x$cf_temp_scan" in (x-Werror=format*) CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan) ;; (x-Werror=*) CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan) ;; (*) CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan) ;; esac done if test "x[$]$1" != "x$cf_temp_flags" then CF_VERBOSE(repairing $1: [$]$1) $1="$cf_temp_flags" CF_VERBOSE(... fixed [$]$1) CF_VERBOSE(... extra $EXTRA_CFLAGS) fi ;; esac fi AC_SUBST(EXTRA_CFLAGS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_FUNC_GETTIME version: 2 updated: 2023/02/25 08:45:56 dnl --------------- dnl Check for gettimeofday or clock_gettime. In 2023, the former is still more dnl widely supported, but "deprecated" (2008), so we will use the latter if it dnl is available, to reduce compiler warnings. AC_DEFUN([CF_FUNC_GETTIME],[ AC_CACHE_CHECK(for clock_gettime,cf_cv_func_clock_gettime,[ AC_TRY_LINK([#include ], [struct timespec ts; int rc = clock_gettime(CLOCK_REALTIME, &ts); (void) rc; (void)ts], [cf_cv_func_clock_gettime=yes], [cf_cv_func_clock_gettime=no]) ]) if test "$cf_cv_func_clock_gettime" = yes then AC_DEFINE(HAVE_CLOCK_GETTIME,1,[Define to 1 if we have clock_gettime function]) else AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function]),[ AC_CHECK_LIB(bsd, gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function]) CF_ADD_LIB(bsd))])dnl CLIX: bzero, select, gettimeofday fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25 dnl ----------------- dnl Test for availability of useful gcc __attribute__ directives to quiet dnl compiler warnings. Though useful, not all are supported -- and contrary dnl to documentation, unrecognized directives cause older compilers to barf. AC_DEFUN([CF_GCC_ATTRIBUTES], [AC_REQUIRE([AC_PROG_FGREP])dnl AC_REQUIRE([CF_C11_NORETURN])dnl if test "$GCC" = yes || test "$GXX" = yes then cat > conftest.i < "conftest.$ac_ext" < #include "confdefs.h" #include "conftest.h" #include "conftest.i" #if GCC_PRINTF #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif #if GCC_SCANF #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif extern void wow(char *,...) GCC_SCANFLIKE(1,2); extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2); extern GCC_NORETURN void foo(void); int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; } EOF cf_printf_attribute=no cf_scanf_attribute=no for cf_attribute in scanf printf unused noreturn do CF_UPPER(cf_ATTRIBUTE,$cf_attribute) cf_directive="__attribute__(($cf_attribute))" echo "checking for $CC $cf_directive" 1>&AC_FD_CC case "$cf_attribute" in (printf) cf_printf_attribute=yes cat >conftest.h <conftest.h <conftest.h <>confdefs.h case "$cf_attribute" in (noreturn) AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc]) ;; (printf) cf_value='/* nothing */' if test "$cf_printf_attribute" != no ; then cf_value='__attribute__((format(printf,fmt,var)))' AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.]) fi AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc]) ;; (scanf) cf_value='/* nothing */' if test "$cf_scanf_attribute" != no ; then cf_value='__attribute__((format(scanf,fmt,var)))' AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.]) fi AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc]) ;; (unused) AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc]) ;; esac fi done else ${FGREP-fgrep} define conftest.i >>confdefs.h fi rm -rf ./conftest* fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13 dnl -------------- dnl Find version of gcc, and (because icc/clang pretend to be gcc without being dnl compatible), attempt to determine if icc/clang is actually used. AC_DEFUN([CF_GCC_VERSION],[ AC_REQUIRE([AC_PROG_CC]) GCC_VERSION=none if test "$GCC" = yes ; then AC_MSG_CHECKING(version of $CC) GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown AC_MSG_RESULT($GCC_VERSION) fi CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS) CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59 dnl --------------- dnl Check if the compiler supports useful warning options. There's a few that dnl we don't use, simply because they're too noisy: dnl dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x) dnl -Winline (usually not worthwhile) dnl -Wredundant-decls (system headers make this too noisy) dnl -Wtraditional (combines too many unrelated messages, only a few useful) dnl -Wwrite-strings (too noisy, but should review occasionally). This dnl is enabled for ncurses using "--enable-const". dnl -pedantic dnl dnl Parameter: dnl $1 is an optional list of gcc warning flags that a particular dnl application might want to use, e.g., "no-unused" for dnl -Wno-unused dnl Special: dnl If $with_ext_const is "yes", add a check for -Wwrite-strings dnl AC_DEFUN([CF_GCC_WARNINGS], [ AC_REQUIRE([CF_GCC_VERSION]) if test "x$have_x" = xyes; then CF_CONST_X_STRING fi cat > "conftest.$ac_ext" <],[ #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0 return 0; #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0 return 0; #else # error not GNU C library #endif], [cf_cv_gnu_library=yes], [cf_cv_gnu_library=no]) ]) if test x$cf_cv_gnu_library = xyes; then # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE # was changed to help a little. newlib incorporated the change about 4 # years later. AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[ cf_save="$CPPFLAGS" CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE) AC_TRY_COMPILE([#include ],[ #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2) return 0; #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3) return 0; #else # error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old #endif], [cf_cv_gnu_library_219=yes], [cf_cv_gnu_library_219=no]) CPPFLAGS="$cf_save" ]) if test "x$cf_cv_gnu_library_219" = xyes; then cf_save="$CPPFLAGS" AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[ CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source) AC_TRY_COMPILE([ #include #include ],[ #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1) return 0; #else # error GNU C library is too old #endif], [cf_cv_gnu_dftsrc_219=yes], [cf_cv_gnu_dftsrc_219=no]) ]) test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save" else cf_cv_gnu_dftsrc_219=maybe fi if test "x$cf_cv_gnu_dftsrc_219" != xyes; then AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[ AC_TRY_COMPILE([#include ],[ #ifndef _XOPEN_SOURCE #error expected _XOPEN_SOURCE to be defined #endif], [cf_cv_gnu_source=no], [cf_save="$CPPFLAGS" CF_ADD_CFLAGS(-D_GNU_SOURCE) AC_TRY_COMPILE([#include ],[ #ifdef _XOPEN_SOURCE #error expected _XOPEN_SOURCE to be undefined #endif], [cf_cv_gnu_source=no], [cf_cv_gnu_source=yes]) CPPFLAGS="$cf_save" ]) ]) if test "$cf_cv_gnu_source" = yes then AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[ CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE) AC_TRY_COMPILE([#include ],[ #ifdef _DEFAULT_SOURCE #error expected _DEFAULT_SOURCE to be undefined #endif], [cf_cv_default_source=no], [cf_cv_default_source=yes]) ]) if test "$cf_cv_default_source" = yes then CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE) fi fi fi fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_HELP_MESSAGE version: 4 updated: 2019/12/31 08:53:54 dnl --------------- dnl Insert text into the help-message, for readability, from AC_ARG_WITH. AC_DEFUN([CF_HELP_MESSAGE], [CF_ACVERSION_CHECK(2.53,[],[ AC_DIVERT_HELP($1)])dnl ])dnl dnl --------------------------------------------------------------------------- dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25 dnl ----------------- dnl Check if the given compiler is really the Intel compiler for Linux. It dnl tries to imitate gcc, but does not return an error when it finds a mismatch dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK. dnl dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from dnl the wrappers for gcc and g++ warnings. dnl dnl $1 = GCC (default) or GXX dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS dnl $3 = CFLAGS (default) or CXXFLAGS AC_DEFUN([CF_INTEL_COMPILER],[ AC_REQUIRE([AC_CANONICAL_HOST]) ifelse([$2],,INTEL_COMPILER,[$2])=no if test "$ifelse([$1],,[$1],GCC)" = yes ; then case "$host_os" in (linux*|gnu*) AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler) cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])" ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc" AC_TRY_COMPILE([],[ #ifdef __INTEL_COMPILER #else #error __INTEL_COMPILER is not defined #endif ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147" ],[]) ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2])) ;; esac fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_LARGEFILE version: 13 updated: 2023/12/03 19:09:59 dnl ------------ dnl Add checks for large file support. AC_DEFUN([CF_LARGEFILE],[ ifdef([AC_FUNC_FSEEKO],[ AC_SYS_LARGEFILE if test "$enable_largefile" != no ; then AC_FUNC_FSEEKO # Normally we would collect these definitions in the config.h, # but (like _XOPEN_SOURCE), some environments rely on having these # defined before any of the system headers are included. Another # case comes up with C++, e.g., on AIX the compiler compiles the # header files by themselves before looking at the body files it is # told to compile. For ncurses, those header files do not include # the config.h if test "$ac_cv_sys_large_files" != no then CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES) fi if test "$ac_cv_sys_largefile_source" != no then CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE) fi if test "$ac_cv_sys_file_offset_bits" != no then CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits) fi AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[ AC_TRY_COMPILE([ #pragma GCC diagnostic error "-Wincompatible-pointer-types" #include #include #ifndef __REDIRECT /* if transitional largefile support is setup, this is true */ extern struct dirent64 * readdir(DIR *); #endif ],[ DIR *dp = opendir("."); struct dirent64 *x = readdir(dp); struct dirent *y = readdir(dp); int z = x - y; (void)z; ], [cf_cv_struct_dirent64=yes], [cf_cv_struct_dirent64=no]) ]) test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64]) fi ]) ]) dnl --------------------------------------------------------------------------- dnl CF_LOCALE version: 7 updated: 2023/01/11 04:05:23 dnl --------- dnl Check if we have setlocale() and its header, dnl The optional parameter $1 tells what to do if we do have locale support. AC_DEFUN([CF_LOCALE], [ AC_MSG_CHECKING(for setlocale()) AC_CACHE_VAL(cf_cv_locale,[ AC_TRY_LINK([ $ac_includes_default #include ], [setlocale(LC_ALL, "")], [cf_cv_locale=yes], [cf_cv_locale=no]) ]) AC_MSG_RESULT($cf_cv_locale) test "$cf_cv_locale" = yes && { ifelse($1,,AC_DEFINE(LOCALE,1,[Define to 1 if we have locale support]),[$1]) } ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAKEFLAGS version: 21 updated: 2021/09/04 06:47:34 dnl ------------ dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make' dnl options to lower-levels. It is very useful for "make -n" -- if we have it. dnl (GNU 'make' does both, something POSIX 'make', which happens to make the dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-) AC_DEFUN([CF_MAKEFLAGS], [AC_REQUIRE([AC_PROG_FGREP])dnl AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[ cf_cv_makeflags='' for cf_option in '-${MAKEFLAGS}' '${MFLAGS}' do cat >cf_makeflags.tmp </dev/null | ${FGREP-fgrep} -v "ing directory" | sed -e 's,[[ ]]*$,,'` case "$cf_result" in (.*k|.*kw) cf_result="`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`" case "$cf_result" in (.*CC=*) cf_cv_makeflags= ;; (*) cf_cv_makeflags=$cf_option ;; esac break ;; (.-) ;; (*) CF_MSG_LOG(given option \"$cf_option\", no match \"$cf_result\") ;; esac done rm -f cf_makeflags.tmp ]) AC_SUBST(cf_cv_makeflags) ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAKE_PHONY version: 3 updated: 2021/01/08 16:08:21 dnl ------------- dnl Check if the make-program handles a ".PHONY" target, e.g,. a target which dnl acts as a placeholder. dnl dnl The ".PHONY" feature was proposed in 2011 here dnl https://www.austingroupbugs.net/view.php?id=523 dnl and is scheduled for release in P1003.1 Issue 8 (late 2022). dnl dnl This is not supported by SVr4 make (or SunOS 4, 4.3SD, etc), but works with dnl a few others (i.e., GNU make and the non-POSIX "BSD" make): dnl dnl + This is a GNU make feature (since April 1988, but in turn from binutils, dnl date unspecified). dnl dnl + It was adopted in NetBSD make in June 1995. dnl dnl + The other BSD make programs are derived from the NetBSD make (and for dnl that reason are not actually different "implementations"). dnl dnl + Some features of NetBSD make were actually adapted from pmake, which dnl began as a modified GNU make starting in 1993. dnl dnl + Version 3.8 of the dmake program in January 1992 also implemented this dnl GNU make extension, but is less well known than the BSD make. AC_DEFUN([CF_MAKE_PHONY],[ AC_CACHE_CHECK(for \".PHONY\" make-support, cf_cv_make_PHONY,[ rm -rf conftest* ( mkdir conftest || exit 1 cd conftest cat >makefile <<'CF_EOF' .PHONY: always DATA=0 always: always.out @echo "** making [$]@ [$](DATA)" once: once.out @echo "** making [$]@ [$](DATA)" always.out: @echo "** making [$]@ [$](DATA)" echo [$](DATA) > [$]@ once.out: @echo "** making [$]@ [$](DATA)" echo [$](DATA) > [$]@ CF_EOF for cf_data in 1 2 3 do ${MAKE:-make} always DATA=$cf_data ${MAKE:-make} once DATA=$cf_data ${MAKE:-make} -t always once if test -f always ; then echo "no (case 1)" > ../conftest.tmp elif test ! -f always.out ; then echo "no (case 2)" > ../conftest.tmp elif test ! -f once.out ; then echo "no (case 3)" > ../conftest.tmp elif ! cmp -s always.out once.out ; then echo "no (case 4)" > ../conftest.tmp diff always.out once.out else cf_check="`cat always.out`" if test "x$cf_check" != "x$cf_data" ; then echo "no (case 5)" > ../conftest.tmp else echo yes > ../conftest.tmp rm -f ./*.out continue fi fi break done ) >&AC_FD_CC 2>&1 cf_cv_make_PHONY="`cat conftest.tmp`" rm -rf conftest* ]) MAKE_NO_PHONY="#" MAKE_PHONY="#" test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY= test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY= AC_SUBST(MAKE_NO_PHONY) AC_SUBST(MAKE_PHONY) ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32 dnl ------------ dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have dnl a monocase filesystem. AC_DEFUN([CF_MAKE_TAGS],[ AC_REQUIRE([CF_MIXEDCASE_FILENAMES]) AC_CHECK_PROGS(CTAGS, exctags ctags) AC_CHECK_PROGS(ETAGS, exetags etags) AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no) if test "$cf_cv_mixedcase" = yes ; then AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no) else MAKE_UPPER_TAGS=no fi if test "$MAKE_UPPER_TAGS" = yes ; then MAKE_UPPER_TAGS= else MAKE_UPPER_TAGS="#" fi if test "$MAKE_LOWER_TAGS" = yes ; then MAKE_LOWER_TAGS= else MAKE_LOWER_TAGS="#" fi AC_SUBST(CTAGS) AC_SUBST(ETAGS) AC_SUBST(MAKE_UPPER_TAGS) AC_SUBST(MAKE_LOWER_TAGS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAWK_CHECK_LIMITS_MSG version: 1 updated: 2008/09/09 19:18:22 dnl ------------------------ dnl Write error-message if CF_MAWK_FIND_MAX_INT fails. AC_DEFUN([CF_MAWK_CHECK_LIMITS_MSG], [AC_MSG_ERROR(C program to compute maxint and maxlong failed. Please send bug report to CF_MAWK_MAINTAINER.)])dnl dnl --------------------------------------------------------------------------- dnl CF_MAWK_CHECK_SIZE_T version: 3 updated: 2012/10/25 20:41:47 dnl -------------------- dnl Check if size_t is found in the given header file, unless we have already dnl found it. dnl $1 = header to check dnl $2 = symbol to define if size_t is found there. dnl Find size_t. AC_DEFUN([CF_MAWK_CHECK_SIZE_T],[ if test "x$cf_mawk_check_size_t" != xyes ; then AC_CACHE_VAL(cf_cv_size_t_$2,[ AC_CHECK_HEADER($1,cf_mawk_check_size=ok) if test "x$cf_mawk_check_size" = xok ; then AC_CACHE_CHECK(if size_t is declared in $1,cf_cv_size_t_$2,[ AC_TRY_COMPILE([#include <$1>],[size_t *n], [cf_cv_size_t_$2=yes], [cf_cv_size_t_$2=no])]) fi ]) if test "x$cf_cv_size_t_$2" = xyes ; then AC_DEFINE_UNQUOTED($2,1,[Define to 1 if we have $1 header]) cf_mawk_check_size_t=yes fi fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAWK_FIND_MAX_INT version: 8 updated: 2023/01/05 17:52:18 dnl -------------------- dnl Try to find a definition of MAX__INT from limits.h else compute. AC_DEFUN([CF_MAWK_FIND_MAX_INT], [AC_CHECK_HEADER(limits.h,cf_limits_h=yes) if test "x$cf_limits_h" = xyes ; then : else AC_CHECK_HEADER(values.h,cf_values_h=yes) if test "x$cf_values_h" = xyes ; then AC_TRY_RUN( [$ac_includes_default #include int main(void) { FILE *out = fopen("conftest.out", "w") ; unsigned max_uint = 0; unsigned long max_ulong = 0; if ( ! out ) exit(1) ; fprintf(out, "MAX__INT 0x%x\n", MAXINT) ; fprintf(out, "MAX__LONG 0x%lx\n", MAXLONG) ; #ifdef MAXUINT max_uint = MAXUINT; /* not likely (SunOS/Solaris lacks it) */ #else max_uint = MAXINT; max_uint <<= 1; max_uint |= 1; #endif fprintf(out, "MAX__UINT 0x%lx\n", max_uint) ; #ifdef MAXULONG max_ulong = MAXULONG; #else max_ulong = MAXLONG; max_ulong <<= 1; max_ulong |= 1; #endif fprintf(out, "MAX__ULONG 0x%lx\n", max_ulong) ; ${cf_cv_main_return:-return}(0); } ], cf_maxint_set=yes,[CF_MAWK_CHECK_LIMITS_MSG]) fi if test "x$cf_maxint_set" != xyes ; then # compute it -- assumes two's complement AC_TRY_RUN(CF_MAWK_MAX__INT_PROGRAM,:,[CF_MAWK_CHECK_LIMITS_MSG]) fi cat conftest.out | while true do read name value test -z "$name" && break AC_DEFINE_UNQUOTED($name,$value) done rm -f conftest.out fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_MAWK_FIND_SIZE_T version: 1 updated: 2008/09/09 19:18:22 dnl ------------------- AC_DEFUN([CF_MAWK_FIND_SIZE_T], [CF_MAWK_CHECK_SIZE_T(stddef.h,SIZE_T_STDDEF_H) CF_MAWK_CHECK_SIZE_T(sys/types.h,SIZE_T_TYPES_H)])dnl dnl --------------------------------------------------------------------------- dnl CF_MAWK_FPE_SIGINFO version: 8 updated: 2012/10/25 20:41:47 dnl ------------------- dnl SYSv and Solaris FPE checks AC_DEFUN([CF_MAWK_FPE_SIGINFO], [ if test "x$cf_cv_use_sv_siginfo" = "xno" then AC_CHECK_FUNC(sigvec,cf_have_sigvec=1) echo "FPE_CHECK 2:get_fpe_codes" >&AC_FD_CC if test "$cf_have_sigvec" = 1 && ./fpe_check$ac_exeext phoney_arg >> defines.out ; then : else dnl FIXME - look for sigprocmask if we have sigaction AC_DEFINE(NOINFO_SIGFPE,1,[Define to 1 if we cannot use SYSv siginfo]) fi fi]) dnl --------------------------------------------------------------------------- dnl CF_MAWK_MAINTAINER version: 2 updated: 2009/07/12 09:10:33 dnl ------------------ AC_DEFUN([CF_MAWK_MAINTAINER], [dickey@invisible-island.net]) dnl --------------------------------------------------------------------------- dnl CF_MAWK_MATHLIB version: 3 updated: 2009/12/19 13:18:53 dnl --------------- dnl Look for math library. AC_DEFUN([CF_MAWK_MATHLIB],[ if test "${MATHLIB+set}" != set ; then AC_CHECK_LIB(m,log,[MATHLIB=-lm ; LIBS="-lm $LIBS"], [# maybe don't need separate math library AC_CHECK_FUNC(log, log=yes) if test "$log" = yes then MATHLIB='' # evidently don't need one else AC_MSG_ERROR( Cannot find a math library. You need to set MATHLIB in config.user) fi])dnl fi AC_SUBST(MATHLIB)])dnl dnl --------------------------------------------------------------------------- dnl CF_MAWK_MAX__INT_PROGRAM version: 5 updated: 2020/07/30 17:24:25 dnl ------------------------ dnl C program to compute MAX__INT, MAX__LONG, MAX__UINT and MAX_ULONG if dnl looking at headers fails. AC_DEFUN([CF_MAWK_MAX__INT_PROGRAM], [[#include #include int main(void) { static int y ; static unsigned yu; static long yy ; static unsigned long yyu ; FILE *out ; if ( !(out = fopen("conftest.out","w")) ) exit(1) ; /* find max int and max long */ y = 0x1000 ; while ( y > 0 ) { yu = y; y *= 2 ; } fprintf(out,"MAX__INT 0x%x\n", y-1) ; yu = yu - 1; yu <<= 1; yu |= 1; yu <<= 1; yu |= 1; fprintf(out,"MAX__UINT 0x%xU\n", yu) ; yy = 0x1000 ; while ( yy > 0 ) { yyu = yy; yy *= 2 ; } fprintf(out,"MAX__LONG 0x%lxL\n", yy-1) ; yyu = yyu - 1; yyu <<= 1; yyu |= 1; yyu <<= 1; yyu |= 1; fprintf(out,"MAX__ULONG 0x%lxUL\n", yyu) ; ${cf_cv_main_return:-return}(0); }]])dnl dnl --------------------------------------------------------------------------- dnl CF_MAWK_RUN_FPE_TESTS version: 16 updated: 2023/12/10 06:52:47 dnl --------------------- dnl These are mawk's dreaded FPE tests. AC_DEFUN([CF_MAWK_RUN_FPE_TESTS], [ AC_CHECK_FUNCS(isnan sigaction) test "$ac_cv_func_sigaction" = yes && sigaction=1 AC_CHECK_HEADERS(siginfo.h) test "$ac_cv_header_siginfo_h" = yes && siginfo_h=1 AC_CACHE_CHECK(if we should use siginfo,cf_cv_use_sv_siginfo,[ if test "$sigaction" = 1 && test "$siginfo_h" = 1 ; then cf_cv_use_sv_siginfo=yes else cf_cv_use_sv_siginfo=no fi ]) AC_TYPE_SIGNAL AC_CACHE_CHECK(if we should use sigaction.sa_sigaction,cf_cv_use_sa_sigaction, [ cf_cv_use_sa_sigaction=no if test "$ac_cv_func_sigaction" = yes then AC_TRY_COMPILE([#include ],[ struct sigaction foo; foo.sa_sigaction = 0; (void) foo; ],[cf_cv_use_sa_sigaction=yes]) fi ]) test "$cf_cv_use_sa_sigaction" = yes && AC_DEFINE(HAVE_SIGACTION_SA_SIGACTION,1,[Define to 1 if we should use sigaction.sa_sigaction,cf_cv_use_sa_sigaction]) cf_FPE_DEFS="$CPPFLAGS" cf_FPE_LIBS="$LIBS" cf_FPE_SRCS="$srcdir/fpe_check.c" CPPFLAGS="$CPPFLAGS -I. -DRETSIGTYPE=$ac_cv_type_signal" test "$ac_cv_func_isnan" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_ISNAN" test "$ac_cv_func_nanf" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_NANF" test "$ac_cv_func_sigaction" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_SIGACTION" test "$ac_cv_header_siginfo_h" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_SIGINFO_H" test "$cf_cv_use_sa_sigaction" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_SIGACTION_SA_SIGACTION" LIBS="$MATHLIB $LIBS" echo checking handling of floating point exceptions cat >conftest.$ac_ext < CF_EOF rm -f conftest$ac_exeext if AC_TRY_EVAL(ac_link); then echo "FPE_CHECK 1:check_fpe_traps" >&AC_FD_CC ./conftest 2>/dev/null cf_status=$? else echo "$cf_FPE_SRCS failed to compile" 1>&2 cf_status=100 fi echo "FPE_CHECK status=$cf_status" >&AC_FD_CC case $cf_status in (0) ;; # good news do nothing (3) # reasonably good news AC_DEFINE(FPE_TRAPS_ON,1,[Define to 1 if floating-point exception traps are enabled]) CF_MAWK_FPE_SIGINFO ;; (1|2|4) # bad news have to turn off traps # only know how to do this on systemV and solaris AC_CHECK_HEADER(ieeefp.h, cf_have_ieeefp_h=1) AC_CHECK_FUNC(fpsetmask, cf_have_fpsetmask=1) if test "$cf_have_ieeefp_h" = 1 && test "$cf_have_fpsetmask" = 1 ; then AC_DEFINE(FPE_TRAPS_ON) AC_DEFINE(USE_IEEEFP_H,1,[Define to 1 we should include ieeefp.h]) AC_DEFINE_UNQUOTED([TURN_ON_FPE_TRAPS], [fpsetmask(fpgetmask() | (FP_X_DZ|FP_X_OFL))], [Define to expression for turning on FPE traps]) AC_DEFINE_UNQUOTED([TURN_OFF_FPE_TRAPS], [fpsetmask(fpgetmask() & ~(FP_X_DZ|FP_X_OFL))], [Define to expression for turning off FPE traps]) CF_MAWK_FPE_SIGINFO # look for strtod overflow bug AC_MSG_CHECKING([strtod bug on overflow]) rm -f conftest$ac_exeext CPPFLAGS="$CPPFLAGS -DUSE_IEEEFP_H" cat >conftest.$ac_ext < CF_EOF if AC_TRY_EVAL(ac_link); then echo "FPE_CHECK 3:check_strtod_ovf" >&AC_FD_CC if ./conftest phoney_arg phoney_arg 2>/dev/null then AC_MSG_RESULT([no bug]) else AC_MSG_RESULT([buggy -- will use work around]) AC_DEFINE_UNQUOTED(HAVE_STRTOD_OVF_BUG,1,[Define to 1 if strtod has overflow bug]) fi else AC_MSG_RESULT([$cf_FPE_SRCS failed to compile]) fi else if test $cf_status != 4 ; then AC_DEFINE(FPE_TRAPS_ON) CF_MAWK_FPE_SIGINFO fi [case $cf_status in (1) cat 1>&2 <<-'EOF' Warning: Your system defaults generate floating point exception on divide by zero but not on overflow. You need to #define TURN_ON_FPE_TRAPS to handle overflow. EOF ;; (2) cat 1>&2 <<-'EOF' Warning: Your system defaults generate floating point exception on overflow but not on divide by zero. You need to #define TURN_ON_FPE_TRAPS to handle divide by zero. EOF ;; (4) cat 1>&2 <<-'EOF' Warning: Your system defaults do not generate floating point exceptions, but your math library does not support this behavior. You need to #define TURN_ON_FPE_TRAPS to use fp exceptions for consistency. EOF ;; esac] cat 1>&2 <<-'EOF' Please report this so I can fix this script to do it automatically. CF_MAWK_MAINTAINER You can continue with the build and the resulting mawk will be usable, but getting FPE_TRAPS_ON correct eventually is best. EOF fi ;; (*) # some sort of disaster if test "x$cross_compiling" = xno then cat 1>&2 <<-EOF The program \`fpe_check' compiled from $cf_FPE_SRCS seems to have unexpectly blown up. Please report this to CF_MAWK_MAINTAINER EOF # quit or not ??? else cat 1>&2 <<-EOF The program \`fpe_check' will not work for cross-compiling. You can continue with the build and the resulting mawk will be usable, but getting FPE_TRAPS_ON correct eventually is best. EOF fi ;; esac CPPFLAGS="$cf_FPE_DEFS" LIBS="$cf_FPE_LIBS" rm -f conftest.$ac_ext fpe_check$ac_exeext # whew!! ]) dnl --------------------------------------------------------------------------- dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59 dnl ---------------------- dnl Check if the file-system supports mixed-case filenames. If we're able to dnl create a lowercase name and see it as uppercase, it doesn't support that. AC_DEFUN([CF_MIXEDCASE_FILENAMES], [ AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[ if test "$cross_compiling" = yes ; then case "$target_alias" in (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*) cf_cv_mixedcase=no ;; (*) cf_cv_mixedcase=yes ;; esac else rm -f conftest CONFTEST echo test >conftest if test -f CONFTEST ; then cf_cv_mixedcase=no else cf_cv_mixedcase=yes fi rm -f conftest CONFTEST fi ]) test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32 dnl ---------- dnl Write a debug message to config.log, along with the line number in the dnl configure script. AC_DEFUN([CF_MSG_LOG],[ echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC ])dnl dnl --------------------------------------------------------------------------- dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41 dnl ------------------ dnl see CF_WITH_NO_LEAKS dnl dnl $1 = option/name dnl $2 = help-text dnl $3 = symbol to define if the option is set dnl $4 = additional actions to take if the option is set AC_DEFUN([CF_NO_LEAKS_OPTION],[ AC_MSG_CHECKING(if you want to use $1 for testing) AC_ARG_WITH($1, [$2], [case "x$withval" in (x|xno) ;; (*) : "${with_cflags:=-g}" : "${enable_leaks:=no}" with_$1=yes AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[ $4 ]) ;; esac], [with_$1=]) AC_MSG_RESULT(${with_$1:-no}) case ".$with_cflags" in (.*-g*) case .$CFLAGS in (.*-g*) ;; (*) CF_ADD_CFLAGS([-g]) ;; esac ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20 dnl -------------- dnl Check the argument to see that it looks like a pathname. Rewrite it if it dnl begins with one of the prefix/exec_prefix variables, and then again if the dnl result begins with 'NONE'. This is necessary to work around autoconf's dnl delayed evaluation of those symbols. AC_DEFUN([CF_PATH_SYNTAX],[ if test "x$prefix" != xNONE; then cf_path_syntax="$prefix" else cf_path_syntax="$ac_default_prefix" fi case ".[$]$1" in (.\[$]\(*\)*|.\'*\'*) ;; (..|./*|.\\*) ;; (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX ;; (.\[$]\{*prefix\}*|.\[$]\{*dir\}*) eval $1="[$]$1" case ".[$]$1" in (.NONE/*) $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%` ;; esac ;; (.no|.NONE/*) $1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%` ;; (*) ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25 dnl ----------------- dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed. dnl dnl POSIX.1-1990 _POSIX_SOURCE dnl POSIX.1-1990 and _POSIX_SOURCE and dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2 dnl Bindings Option dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L dnl X/Open 2000 _POSIX_C_SOURCE=200112L dnl dnl Parameters: dnl $1 is the nominal value for _POSIX_C_SOURCE AC_DEFUN([CF_POSIX_C_SOURCE], [AC_REQUIRE([CF_POSIX_VISIBLE])dnl if test "$cf_cv_posix_visible" = no; then cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1]) cf_save_CFLAGS="$CFLAGS" cf_save_CPPFLAGS="$CPPFLAGS" CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE) CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE) AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[ CF_MSG_LOG(if the symbol is already defined go no further) AC_TRY_COMPILE([#include ],[ #ifndef _POSIX_C_SOURCE #error _POSIX_C_SOURCE is not defined #endif], [cf_cv_posix_c_source=no], [cf_want_posix_source=no case .$cf_POSIX_C_SOURCE in (.[[12]]??*) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" ;; (.2) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" cf_want_posix_source=yes ;; (.*) cf_want_posix_source=yes ;; esac if test "$cf_want_posix_source" = yes ; then AC_TRY_COMPILE([#include ],[ #ifdef _POSIX_SOURCE #error _POSIX_SOURCE is defined #endif],[], cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE") fi CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE) CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source) CF_MSG_LOG(if the second compile does not leave our definition intact error) AC_TRY_COMPILE([#include ],[ #ifndef _POSIX_C_SOURCE #error _POSIX_C_SOURCE is not defined #endif],, [cf_cv_posix_c_source=no]) CFLAGS="$cf_save_CFLAGS" CPPFLAGS="$cf_save_CPPFLAGS" ]) ]) if test "$cf_cv_posix_c_source" != no ; then CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" CF_ADD_CFLAGS($cf_cv_posix_c_source) fi fi # cf_cv_posix_visible ])dnl dnl --------------------------------------------------------------------------- dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17 dnl ---------------- dnl POSIX documents test-macros which an application may set before any system dnl headers are included to make features available. dnl dnl Some BSD platforms (originally FreeBSD, but copied by a few others) dnl diverged from POSIX in 2002 by setting symbols which make all of the most dnl recent features visible in the system header files unless the application dnl overrides the corresponding test-macros. Doing that introduces portability dnl problems. dnl dnl This macro makes a special check for the symbols used for this, to avoid a dnl conflicting definition. AC_DEFUN([CF_POSIX_VISIBLE], [ AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[ AC_TRY_COMPILE([#include ],[ #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \ && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \ && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \ && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0) #error conflicting symbols found #endif ],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes]) ]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54 dnl ---------- dnl standard check for CC, plus followup sanity checks dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name AC_DEFUN([CF_PROG_CC],[ CF_ACVERSION_CHECK(2.53, [AC_MSG_WARN(this will incorrectly handle gnatgcc choice) AC_REQUIRE([AC_PROG_CC])], []) ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)]) CF_GCC_VERSION CF_ACVERSION_CHECK(2.52, [AC_PROG_CC_STDC], [CF_ANSI_CC_REQD]) CF_CC_ENV_FLAGS ])dnl dnl --------------------------------------------------------------------------- dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19 dnl ------------- dnl Check if groff is available, for cases (such as html output) where nroff dnl is not enough. AC_DEFUN([CF_PROG_GROFF],[ AC_PATH_PROG(GROFF_PATH,groff,no) AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no) AC_PATH_PROG(TBL_PATH,tbl,cat) if test "x$GROFF_PATH" = xno then NROFF_NOTE= GROFF_NOTE="#" else NROFF_NOTE="#" GROFF_NOTE= fi AC_SUBST(GROFF_NOTE) AC_SUBST(NROFF_NOTE) ])dnl dnl --------------------------------------------------------------------------- dnl CF_PROG_LINT version: 5 updated: 2022/08/20 15:44:13 dnl ------------ AC_DEFUN([CF_PROG_LINT], [ AC_CHECK_PROGS(LINT, lint cppcheck splint) case "x$LINT" in (xcppcheck|x*/cppcheck) test -z "$LINT_OPTS" && LINT_OPTS="--enable=all" ;; esac AC_SUBST(LINT_OPTS) AC_SUBST(LINT_LIBS) ])dnl dnl --------------------------------------------------------------------------- dnl CF_REGEX version: 18 updated: 2021/01/01 16:53:59 dnl -------- dnl Attempt to determine if we've got one of the flavors of regular-expression dnl code that we can support. AC_DEFUN([CF_REGEX], [ cf_regex_func=no cf_regex_libs= case "$host_os" in (mingw*) # -lsystre -ltre -lintl -liconv AC_CHECK_LIB(systre,regcomp,[ AC_CHECK_LIB(iconv,libiconv_open,[CF_ADD_LIB(iconv)]) AC_CHECK_LIB(intl,libintl_gettext,[CF_ADD_LIB(intl)]) AC_CHECK_LIB(tre,tre_regcomp,[CF_ADD_LIB(tre)]) CF_ADD_LIB(systre) cf_regex_func=regcomp ],[ AC_CHECK_LIB(gnurx,regcomp,[ CF_ADD_LIB(gnurx) cf_regex_func=regcomp]) ]) ;; (*) cf_regex_libs="regex re" AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[ for cf_regex_lib in $cf_regex_libs do AC_CHECK_LIB($cf_regex_lib,regcomp,[ CF_ADD_LIB($cf_regex_lib) cf_regex_func=regcomp break]) done ]) ;; esac if test "$cf_regex_func" = no ; then AC_CHECK_FUNC(compile,[cf_regex_func=compile],[ AC_CHECK_LIB(gen,compile,[ CF_ADD_LIB(gen) cf_regex_func=compile])]) fi if test "$cf_regex_func" = no ; then AC_MSG_WARN(cannot find regular expression library) fi AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[ cf_cv_regex_hdrs=no case "$cf_regex_func" in (compile) for cf_regex_hdr in regexp.h regexpr.h do AC_TRY_LINK([#include <$cf_regex_hdr>],[ char *p = compile("", "", "", 0); int x = step("", ""); (void)p; (void)x; ],[ cf_cv_regex_hdrs=$cf_regex_hdr break ]) done ;; (*) for cf_regex_hdr in regex.h do AC_TRY_LINK([#include #include <$cf_regex_hdr>],[ regex_t *p = 0; int x = regcomp(p, "", 0); int y = regexec(p, "", 0, 0, 0); (void)x; (void)y; regfree(p); ],[ cf_cv_regex_hdrs=$cf_regex_hdr break ]) done ;; esac ]) case "$cf_cv_regex_hdrs" in (no) AC_MSG_WARN(no regular expression header found) ;; (regex.h) AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;; (regexp.h) AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;; (regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40 dnl ---------------- dnl Remove a given option from CFLAGS/CPPFLAGS dnl $1 = option to remove dnl $2 = variable to update dnl $3 = nonempty to allow verbose message define([CF_REMOVE_CFLAGS], [ cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'` while true do cf_old_cflag=`echo "x[$]$2" | sed -e 's/^.//' -e 's/[[ ]][[ ]]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[[^ ]][[^ ]]*\\)\?%%" -e 's/^[[ ]]*//' -e 's%[[ ]][[ ]]*-D% -D%g' -e 's%[[ ]][[ ]]*-I% -I%g'` test "[$]$2" != "$cf_old_cflag" || break ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)]) $2="$cf_old_cflag" done ])dnl dnl --------------------------------------------------------------------------- dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50 dnl ---------------- dnl Remove all -U and -D options that refer to the given symbol from a list dnl of C compiler options. This works around the problem that not all dnl compilers process -U and -D options from left-to-right, so a -U option dnl cannot be used to cancel the effect of a preceding -D option. dnl dnl $1 = target (which could be the same as the source variable) dnl $2 = source (including '$') dnl $3 = symbol to remove define([CF_REMOVE_DEFINE], [ $1=`echo "$2" | \ sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \ -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'` ])dnl dnl --------------------------------------------------------------------------- dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45 dnl --------------------- dnl Restore flags saved in CF_SAVE_XTRA_FLAGS dnl $1 = name of current macro define([CF_RESTORE_XTRA_FLAGS], [ LIBS="$cf_save_LIBS_$1" CFLAGS="$cf_save_CFLAGS_$1" CPPFLAGS="$cf_save_CPPFLAGS_$1" ])dnl dnl --------------------------------------------------------------------------- dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44 dnl ------------------ dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers dnl and libraries which do not update those variables. dnl dnl $1 = name of current macro define([CF_SAVE_XTRA_FLAGS], [ cf_save_LIBS_$1="$LIBS" cf_save_CFLAGS_$1="$CFLAGS" cf_save_CPPFLAGS_$1="$CPPFLAGS" LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}" for cf_X_CFLAGS in $X_CFLAGS do case "x$cf_X_CFLAGS" in x-[[IUD]]*) CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS" ;; *) CFLAGS="$CFLAGS $cf_X_CFLAGS" ;; esac done ])dnl dnl --------------------------------------------------------------------------- dnl CF_SET_MATH_LIB_VERSION version: 1 updated: 2013/12/26 20:21:00 dnl ----------------------- dnl Check if math.h declares _LIB_VERSION, and if so, whether we can modify it dnl at runtime. Cygwin is known to be broken in this regard (late 2013). AC_DEFUN([CF_SET_MATH_LIB_VERSION],[ AC_CACHE_CHECK(if math.h declares _LIB_VERSION,cf_cv_get_math_lib_version,[ AC_TRY_LINK([ #include ], [int foo = _LIB_VERSION], [cf_cv_get_math_lib_version=yes], [cf_cv_get_math_lib_version=no]) ]) if test "x$cf_cv_get_math_lib_version" = xyes then AC_CACHE_CHECK(if we can update _LIB_VERSION,cf_cv_set_math_lib_version,[ AC_TRY_LINK([ #include ], [_LIB_VERSION = _IEEE_], [cf_cv_set_math_lib_version=yes], [cf_cv_set_math_lib_version=no]) ]) if test "x$cf_cv_set_math_lib_version" = xyes then AC_DEFINE(HAVE_MATH__LIB_VERSION,1,[Define to 1 if we can set math.h variable _LIB_VERSION]) else AC_MSG_WARN(this is probably due to a defect in your system headers) fi fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_SRAND version: 22 updated: 2024/01/22 19:30:53 dnl -------- dnl Check for functions similar to srand() and rand(). lrand48() and random() dnl return a 31-bit value, while rand() returns a value less than RAND_MAX dnl which usually is only 16-bits. dnl dnl $1 = optional prefix for resulting shell variables. The default "my_" dnl gives $my_srand and $my_rand to the caller, as well as MY_RAND_MAX. dnl These are all AC_SUBST'd and AC_DEFINE'd. AC_DEFUN([CF_SRAND],[ AC_CHECK_HEADERS(limits.h) AC_CHECK_FUNC(arc4random,,[AC_CHECK_LIB(bsd,arc4random,CF_ADD_LIB(bsd))]) AC_CACHE_CHECK(for random-integer functions, cf_cv_srand_func,[ cf_cv_srand_func=unknown for cf_func in arc4random_stir/arc4random srandom/random srand48/lrand48 srand/rand do CF_SRAND_PARSE($cf_func,cf_srand_func,cf_rand_func) AC_TRY_LINK([ $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif ],[long seed = 1; $cf_srand_func(seed); seed = $cf_rand_func(); (void)seed], [cf_cv_srand_func=$cf_func break]) done ]) if test "$cf_cv_srand_func" != unknown ; then AC_CACHE_CHECK(for range of random-integers, cf_cv_rand_max,[ case "$cf_cv_srand_func" in (srand/rand) cf_cv_rand_max=RAND_MAX cf_rand_max=16 ;; (*/arc4random) cf_cv_rand_max=0xFFFFFFFFUL cf_rand_max=32 ;; (*) cf_cv_rand_max=INT_MAX cf_rand_max=31 ;; esac AC_TRY_COMPILE([ $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif ],[long x = $cf_cv_rand_max; (void)x],, [cf_cv_rand_max="(1UL<<$cf_rand_max)-1"]) ]) case "$cf_cv_srand_func" in (*/arc4random) AC_MSG_CHECKING(if should be included) AC_TRY_COMPILE([ $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif #include ], [void *arc4random(int); void *x = arc4random(1); (void)x], [cf_bsd_stdlib_h=no], [AC_TRY_COMPILE([ $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif #include ], [unsigned long x = arc4random(); (void)x], [cf_bsd_stdlib_h=yes], [cf_bsd_stdlib_h=no])]) AC_MSG_RESULT($cf_bsd_stdlib_h) if test "$cf_bsd_stdlib_h" = yes then AC_DEFINE(HAVE_BSD_STDLIB_H,1,[Define to 1 if bsd/stdlib.h header should be used]) else AC_MSG_CHECKING(if should be included) AC_TRY_COMPILE([ $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif #include ], [void *arc4random(int); void *x = arc4random(1); (void)x], [cf_bsd_random_h=no], [AC_TRY_COMPILE([#include ], [unsigned long x = arc4random(); (void)x], [cf_bsd_random_h=yes], [cf_bsd_random_h=no])]) AC_MSG_RESULT($cf_bsd_random_h) if test "$cf_bsd_random_h" = yes then AC_DEFINE(HAVE_BSD_RANDOM_H,1,[Define to 1 if bsd/random.h header should be used]) else AC_MSG_WARN(no header file found for arc4random) fi fi ;; esac CF_SRAND_PARSE($cf_func,cf_srand_func,cf_rand_func) CF_UPPER(cf_rand_max,ifelse($1,,my_,$1)rand_max) AC_DEFINE_UNQUOTED(ifelse($1,,my_,$1)srand,$cf_srand_func,[Define to the name for the srand function]) AC_DEFINE_UNQUOTED(ifelse($1,,my_,$1)rand, $cf_rand_func,[Define to the name for the rand function]) AC_DEFINE_UNQUOTED([$]cf_rand_max, $cf_cv_rand_max,[Define to the name for the RAND_MAX constant]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_SRAND_PARSE version: 2 updated: 2015/04/15 19:08:48 dnl -------------- dnl Parse the loop variable for CF_SRAND, with a workaround for asymmetric dnl variations. define([CF_SRAND_PARSE],[ $2=`echo $1 | sed -e 's%/.*%%'` $3=`echo $1 | sed -e 's%.*/%%'` case [$]$2 in (arc4random_stir) $2='(void)' ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl CF_TRY_XOPEN_SOURCE version: 4 updated: 2022/09/10 15:16:16 dnl ------------------- dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we dnl can define it successfully. AC_DEFUN([CF_TRY_XOPEN_SOURCE],[ AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[ AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY, [cf_cv_xopen_source=no], [cf_save="$CPPFLAGS" CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE) AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY, [cf_cv_xopen_source=no], [cf_cv_xopen_source=$cf_XOPEN_SOURCE]) CPPFLAGS="$cf_save" ]) ]) if test "$cf_cv_xopen_source" != no ; then CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE) CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE) cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source" CF_APPEND_CFLAGS($cf_temp_xopen_source) fi ]) dnl --------------------------------------------------------------------------- dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59 dnl -------- dnl Make an uppercase version of a variable dnl $1=uppercase($2) AC_DEFUN([CF_UPPER], [ $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` ])dnl dnl --------------------------------------------------------------------------- dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12 dnl ---------- dnl Use AC_VERBOSE w/o the warnings AC_DEFUN([CF_VERBOSE], [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG CF_MSG_LOG([$1]) ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47 dnl ---------------- dnl Configure-option for dbmalloc. The optional parameter is used to override dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests. AC_DEFUN([CF_WITH_DBMALLOC],[ CF_NO_LEAKS_OPTION(dbmalloc, [ --with-dbmalloc test: use Conor Cahill's dbmalloc library], [USE_DBMALLOC]) if test "$with_dbmalloc" = yes ; then AC_CHECK_HEADER(dbmalloc.h, [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47 dnl --------------- dnl Configure-option for dmalloc. The optional parameter is used to override dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests. AC_DEFUN([CF_WITH_DMALLOC],[ CF_NO_LEAKS_OPTION(dmalloc, [ --with-dmalloc test: use Gray Watson's dmalloc library], [USE_DMALLOC]) if test "$with_dmalloc" = yes ; then AC_CHECK_HEADER(dmalloc.h, [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))]) fi ])dnl dnl --------------------------------------------------------------------------- dnl CF_WITH_MAN2HTML version: 13 updated: 2023/11/23 06:40:35 dnl ---------------- dnl Check for man2html and groff. Prefer man2html over groff, but use groff dnl as a fallback. See dnl dnl http://invisible-island.net/scripts/man2html.html dnl dnl Generate a shell script which hides the differences between the two. dnl dnl We name that "man2html.tmp". dnl dnl The shell script can be removed later, e.g., using "make distclean". AC_DEFUN([CF_WITH_MAN2HTML],[ AC_REQUIRE([CF_PROG_GROFF])dnl AC_REQUIRE([AC_PROG_FGREP])dnl case "x${with_man2html}" in (xno) cf_man2html=no ;; (x|xyes) AC_PATH_PROG(cf_man2html,man2html,no) case "x$cf_man2html" in (x/*) AC_MSG_CHECKING(for the modified Earl Hood script) if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null ) then cf_man2html_ok=yes else cf_man2html=no cf_man2html_ok=no fi AC_MSG_RESULT($cf_man2html_ok) ;; (*) cf_man2html=no ;; esac esac AC_MSG_CHECKING(for program to convert manpage to html) AC_ARG_WITH(man2html, [[ --with-man2html[=XXX] use XXX rather than groff]], [cf_man2html=$withval], [cf_man2html=$cf_man2html]) cf_with_groff=no case $cf_man2html in (yes) AC_MSG_RESULT(man2html) AC_PATH_PROG(cf_man2html,man2html,no) ;; (no|groff|*/groff*) cf_with_groff=yes cf_man2html=$GROFF_PATH AC_MSG_RESULT($cf_man2html) ;; (*) AC_MSG_RESULT($cf_man2html) ;; esac MAN2HTML_TEMP="man2html.tmp" cat >$MAN2HTML_TEMP <>$MAN2HTML_TEMP <conftest.in <conftest.out cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`" cf_man2html_top=`expr "$cf_man2html_1st" - 2` cf_man2html_bot="`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`" cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"` cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot" AC_MSG_RESULT($cf_man2html_top_bot) AC_MSG_CHECKING(for pagesize to use) for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do cat >>conftest.in <conftest.out cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`" test -z "$cf_man2html_page" && cf_man2html_page=99999 test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999 rm -rf conftest* AC_MSG_RESULT($cf_man2html_page) cat >>$MAN2HTML_TEMP < and other headers which use u_int / u_short types cf_XOPEN_SOURCE= CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) ;; (netbsd*) cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw ;; (openbsd[[6-9]]*) # OpenBSD 6.x has broken locale support, both compile-time and runtime. # see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html # Abusing the conformance level is a workaround. AC_MSG_WARN(this system does not provide usable locale support) cf_xopen_source="-D_BSD_SOURCE" cf_XOPEN_SOURCE=700 ;; (openbsd[[4-5]]*) # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw cf_xopen_source="-D_BSD_SOURCE" cf_XOPEN_SOURCE=600 ;; (openbsd*) # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw ;; (osf[[45]]*) cf_xopen_source="-D_OSF_SOURCE" ;; (nto-qnx*) cf_xopen_source="-D_QNX_SOURCE" ;; (sco*) # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer ;; (solaris2.*) cf_xopen_source="-D__EXTENSIONS__" cf_cv_xopen_source=broken ;; (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2) cf_XOPEN_SOURCE= cf_POSIX_C_SOURCE= ;; (*) CF_TRY_XOPEN_SOURCE cf_save_xopen_cppflags="$CPPFLAGS" CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) # Some of these niche implementations use copy/paste, double-check... if test "$cf_cv_xopen_source" = no ; then CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE) AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[ AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable) CPPFLAGS="$cf_save_xopen_cppflags"]) fi ;; esac if test -n "$cf_xopen_source" ; then CF_APPEND_CFLAGS($cf_xopen_source,true) fi dnl In anything but the default case, we may have system-specific setting dnl which is still not guaranteed to provide all of the entrypoints that dnl _XOPEN_SOURCE would yield. if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then AC_MSG_CHECKING(if _XOPEN_SOURCE really is set) AC_TRY_COMPILE([#include ],[ #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif], [cf_XOPEN_SOURCE_set=yes], [cf_XOPEN_SOURCE_set=no]) AC_MSG_RESULT($cf_XOPEN_SOURCE_set) if test "$cf_XOPEN_SOURCE_set" = yes then AC_TRY_COMPILE([#include ],[ #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE #error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE #endif], [cf_XOPEN_SOURCE_set_ok=yes], [cf_XOPEN_SOURCE_set_ok=no]) if test "$cf_XOPEN_SOURCE_set_ok" = no then AC_MSG_WARN(_XOPEN_SOURCE is lower than requested) fi else CF_TRY_XOPEN_SOURCE fi fi fi # cf_cv_posix_visible ]) dnl --------------------------------------------------------------------------- dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25 dnl --------------------- dnl body of test when test-compiling for _XOPEN_SOURCE check define([CF__XOPEN_SOURCE_BODY], [ #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif ]) dnl --------------------------------------------------------------------------- dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25 dnl --------------------- dnl headers to include when test-compiling for _XOPEN_SOURCE check define([CF__XOPEN_SOURCE_HEAD], [ $ac_includes_default ]) mawk-1.3.4-20240123/configure0000755000000000000000000125177414553604614014007 0ustar rootroot#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by Autoconf 2.52.20231210. # # Copyright 2003-2022,2023 Thomas E. Dickey # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Sed expression to map a string onto a valid variable name. as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Name of the executable. as_me=`echo "$0" |sed 's,.*[\\/],,'` if expr a : '\(a\)' >/dev/null 2>&1; then as_expr="expr" else as_expr="false" fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln' else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset="unset" else as_unset="false" fi # NLS nuisances. $as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } $as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } $as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } $as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : "${ac_max_here_lines=38}" ac_unique_file="mawk.h" # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif" # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${datarootdir}/info' mandir='${datarootdir}/man' # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo "$ac_feature" | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo "$ac_feature" | sed 's/-/_/g'` case "$ac_option" in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst \ | --runs | --run | --ru) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* \ | --runs=* | --run=* | --ru=*) runstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo "$ac_package" | sed 's/-/_/g'` case "$ac_option" in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo "$ac_package" | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export "$ac_envvar" ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option}" "${host_alias=$ac_option}" "${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo "$ac_prev" | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo "$ac_var"` case "$ac_val" in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo "$ac_var"` case "$ac_val" in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. build=$build_alias host=$host_alias target=$target_alias # FIXME: should be removed in autoconf 3.0. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat < if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. EOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue cd "$ac_subdir" # A "../" for each directory in /$ac_subdir. ac_dots=`echo "$ac_subdir" | sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'` case "$srcdir" in .) # No --srcdir option. We are building in place. ac_sub_srcdir="$srcdir" ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_sub_srcdir="$srcdir/$ac_subdir" ;; *) # Relative path. ac_sub_srcdir="$ac_dots$srcdir/$ac_subdir" ;; esac # Check for guested configure; otherwise get Cygnus style configure. if test -f "$ac_sub_srcdir/configure.gnu"; then echo $SHELL "$ac_sub_srcdir/configure.gnu" --help=recursive elif test -f "$ac_sub_srcdir/configure"; then echo $SHELL "$ac_sub_srcdir/configure" --help=recursive elif test -f "$ac_sub_srcdir/configure.ac" || test -f "$ac_sub_srcdir/configure.in"; then echo "$ac_configure" --help else echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2 fi cd "$ac_popdir" done fi test -n "$ac_init_help" && exit 0 if "$ac_init_version"; then cat <<\EOF Copyright 2003-2022,2023 Thomas E. Dickey Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. EOF exit 0 fi exec 5>config.log cat >&5 </dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` PATH = $PATH _ASUNAME } >&5 cat >&5 <\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" ac_sep=" " ;; *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg" ac_sep=" " ;; esac # Get rid of the leading space. done # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. trap 'exit_status=$? # Save into config.log some information that might help in debugging. echo >&5 echo "## ----------------- ##" >&5 echo "## Cache variables. ##" >&5 echo "## ----------------- ##" >&5 echo >&5 # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } >&5 sed "/^$/d" confdefs.h >conftest.log if test -s conftest.log; then echo >&5 echo "## ------------ ##" >&5 echo "## confdefs.h. ##" >&5 echo "## ------------ ##" >&5 echo >&5 cat conftest.log >&5 fi (echo; echo) >&5 test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" >&5 echo "$as_me: exit $exit_status" >&5 rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' "$ac_signal" done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:919: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} cat "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:930: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:938: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case "$ac_old_set,$ac_new_set" in set,) { echo "$as_me:954: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:958: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:964: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:966: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:968: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. It doesn't matter if # we pass some twice (in addition to the command line arguments). if test "$ac_new_set" = set; then case "$ac_new_val" in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val" ;; esac fi done if "$ac_cache_corrupted"; then { echo "$as_me:987: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:989: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" case `echo "testing\c" 2>/dev/null; echo 1,2,3`,`echo -n testing 2>/dev/null; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C= # newlines do not sed ;-) only broken shells would use this case anyway ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac echo "#! $SHELL" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh if { (echo "$as_me:1018: PATH=\".;.\"; conftest.sh") >&5 (PATH=".;."; conftest.sh) 2>&5 ac_status=$? echo "$as_me:1021: \$? = $ac_status" >&5 (exit "$ac_status"); }; then ac_path_separator=';' else ac_path_separator=: fi PATH_SEPARATOR="$ac_path_separator" rm -f conftest.sh ac_config_headers="$ac_config_headers config.h:config_h.in" ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:1049: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || { { echo "$as_me:1059: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } echo "$as_me:1063: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_build_alias=$build_alias test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && { { echo "$as_me:1072: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub "$ac_cv_build_alias"` || { { echo "$as_me:1076: error: $ac_config_sub $ac_cv_build_alias failed." >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:1081: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo "$ac_cv_build" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then echo "$as_me:1089: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_host_alias=$host_alias test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub "$ac_cv_host_alias"` || { { echo "$as_me:1098: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:1103: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo "$ac_cv_host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && cat >>confdefs.h <&6 else cf_cv_system_name="$system_name" fi test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && echo "$as_me:1129: result: Configuring for $cf_cv_system_name" >&5 echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6 if test ".$system_name" != ".$cf_cv_system_name" ; then echo "$as_me:1133: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5 echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6 { { echo "$as_me:1135: error: \"Please remove config.cache and try again.\"" >&5 echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;} { (exit 1); exit 1; }; } fi test "$program_prefix" != NONE && program_transform_name="s,^,$program_prefix,;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s,\$,$program_suffix,;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm conftest.sed ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:1162: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:1177: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1185: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1188: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:1197: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:1212: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:1220: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:1223: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:1236: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:1251: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1259: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1262: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:1271: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="cc" echo "$as_me:1286: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:1294: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:1297: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:1310: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:1330: found $ac_dir/$ac_word" >&5 break done if test "$ac_prog_rejected" = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" ${1+"$@"} shift ac_cv_prog_CC="$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1352: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1355: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:1366: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:1381: found $ac_dir/$ac_word" >&5 break done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:1389: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:1392: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:1405: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:1420: found $ac_dir/$ac_word" >&5 break done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:1428: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:1431: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:1443: error: no acceptable cc found in \$PATH" >&5 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:1448:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo "$2"` { (eval echo "$as_me:1451: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:1454: \$? = $ac_status" >&5 (exit "$ac_status"); } { (eval echo "$as_me:1456: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:1459: \$? = $ac_status" >&5 (exit "$ac_status"); } { (eval echo "$as_me:1461: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:1464: \$? = $ac_status" >&5 (exit "$ac_status"); } cat >"conftest.$ac_ext" <<_ACEOF #line 1468 "configure" #include "confdefs.h" int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:1484: checking for C compiler default output" >&5 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *"conftest[^"]*"//'` if { (eval echo "$as_me:1487: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:1490: \$? = $ac_status" >&5 (exit "$ac_status"); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. for ac_file in `ls a.exe conftest.exe 2>/dev/null; ls a.out conftest 2>/dev/null; ls a.* conftest.* 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; a.out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 { { echo "$as_me:1513: error: C compiler cannot create executables" >&5 echo "$as_me: error: C compiler cannot create executables" >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:1519: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:1524: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:1530: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1533: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:1540: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:1548: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe "conftest$ac_cv_exeext" ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:1555: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:1557: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:1560: checking for executable suffix" >&5 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 if { (eval echo "$as_me:1562: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:1565: \$? = $ac_status" >&5 (exit "$ac_status"); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:1581: error: cannot compute EXEEXT: cannot compile and link" >&5 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} { (exit 1); exit 1; }; } fi rm -f "conftest$ac_cv_exeext" echo "$as_me:1587: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f "conftest.$ac_ext" EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:1593: checking for object suffix" >&5 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 1599 "configure" #include "confdefs.h" int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:1611: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1614: \$? = $ac_status" >&5 (exit "$ac_status"); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 { { echo "$as_me:1626: error: cannot compute OBJEXT: cannot compile" >&5 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} { (exit 1); exit 1; }; } fi rm -f "conftest.$ac_cv_objext" "conftest.$ac_ext" fi echo "$as_me:1633: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:1637: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 1643 "configure" #include "confdefs.h" int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1658: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1661: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1664: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1667: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_compiler_gnu=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:1679: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:1685: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 1691 "configure" #include "confdefs.h" int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1703: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1706: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1709: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1712: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_prog_cc_g=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:1722: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >"conftest.$ac_ext" <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1749: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1752: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1755: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1758: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then for ac_declaration in \ ''\ '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >"conftest.$ac_ext" <<_ACEOF #line 1770 "configure" #include "confdefs.h" #include $ac_declaration int main (void) { exit (42); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1783: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1786: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1789: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1792: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 continue fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" cat >"conftest.$ac_ext" <<_ACEOF #line 1802 "configure" #include "confdefs.h" $ac_declaration int main (void) { exit (42); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1814: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1817: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1820: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1823: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done rm -rf conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo "$ac_declaration" >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" GCC_VERSION=none if test "$GCC" = yes ; then echo "$as_me:1853: checking version of $CC" >&5 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[^(]*([^)][^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$GCC_VERSION" && GCC_VERSION=unknown echo "$as_me:1857: result: $GCC_VERSION" >&5 echo "${ECHO_T}$GCC_VERSION" >&6 fi INTEL_COMPILER=no if test "$GCC" = yes ; then case "$host_os" in (linux*|gnu*) echo "$as_me:1866: checking if this is really Intel C compiler" >&5 echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -no-gcc" cat >"conftest.$ac_ext" <<_ACEOF #line 1871 "configure" #include "confdefs.h" int main (void) { #ifdef __INTEL_COMPILER #else #error __INTEL_COMPILER is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1888: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1891: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1894: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1897: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then INTEL_COMPILER=yes cf_save_CFLAGS="$cf_save_CFLAGS -we147" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CFLAGS="$cf_save_CFLAGS" echo "$as_me:1908: result: $INTEL_COMPILER" >&5 echo "${ECHO_T}$INTEL_COMPILER" >&6 ;; esac fi CLANG_COMPILER=no if test "$GCC" = yes ; then echo "$as_me:1917: checking if this is really Clang C compiler" >&5 echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" cat >"conftest.$ac_ext" <<_ACEOF #line 1921 "configure" #include "confdefs.h" int main (void) { #ifdef __clang__ #else #error __clang__ is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:1938: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:1941: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:1944: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:1947: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then CLANG_COMPILER=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CFLAGS="$cf_save_CFLAGS" echo "$as_me:1957: result: $CLANG_COMPILER" >&5 echo "${ECHO_T}$CLANG_COMPILER" >&6 fi CLANG_VERSION=none if test "x$CLANG_COMPILER" = "xyes" ; then case "$CC" in (c[1-9][0-9]|*/c[1-9][0-9]) { echo "$as_me:1966: WARNING: replacing broken compiler alias $CC" >&5 echo "$as_me: WARNING: replacing broken compiler alias $CC" >&2;} CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`" CC=clang ;; esac echo "$as_me:1973: checking version of $CC" >&5 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6 CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`" test -z "$CLANG_VERSION" && CLANG_VERSION=unknown echo "$as_me:1977: result: $CLANG_VERSION" >&5 echo "${ECHO_T}$CLANG_VERSION" >&6 for cf_clang_opt in \ -Qunused-arguments \ -Wno-error=implicit-function-declaration do echo "$as_me:1984: checking if option $cf_clang_opt works" >&5 echo $ECHO_N "checking if option $cf_clang_opt works... $ECHO_C" >&6 cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cf_clang_opt" cat >"conftest.$ac_ext" <<_ACEOF #line 1989 "configure" #include "confdefs.h" #include int main (void) { printf("hello!\\n"); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:2003: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:2006: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:2009: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2012: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_clang_optok=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_clang_optok=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" echo "$as_me:2023: result: $cf_clang_optok" >&5 echo "${ECHO_T}$cf_clang_optok" >&6 CFLAGS="$cf_save_CFLAGS" if test "$cf_clang_optok" = yes; then test -n "$verbose" && echo " adding option $cf_clang_opt" 1>&6 echo "${as_me:-configure}:2029: testing adding option $cf_clang_opt ..." 1>&5 test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_clang_opt" fi done fi echo "$as_me:2038: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >"conftest.$ac_ext" <<_ACEOF #line 2046 "configure" #include "confdefs.h" #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (char **p, int i) { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main (void) { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f "conftest.$ac_objext" if { (eval echo "$as_me:2093: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:2096: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:2099: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:2102: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" done rm -f "conftest.$ac_ext" "conftest.$ac_objext" CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:2119: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:2122: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac # This should have been defined by AC_PROG_CC : "${CC:=cc}" echo "$as_me:2130: checking \$CFLAGS variable" >&5 echo $ECHO_N "checking \$CFLAGS variable... $ECHO_C" >&6 case "x$CFLAGS" in (*-[IUD]*) echo "$as_me:2134: result: broken" >&5 echo "${ECHO_T}broken" >&6 { echo "$as_me:2136: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&5 echo "$as_me: WARNING: your environment uses the CFLAGS variable to hold CPPFLAGS options" >&2;} cf_flags="$CFLAGS" CFLAGS= for cf_arg in $cf_flags do cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_arg do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi done ;; (*) echo "$as_me:2244: result: ok" >&5 echo "${ECHO_T}ok" >&6 ;; esac echo "$as_me:2249: checking \$CC variable" >&5 echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6 case "$CC" in (*[\ \ ]-*) echo "$as_me:2253: result: broken" >&5 echo "${ECHO_T}broken" >&6 { echo "$as_me:2255: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&5 echo "$as_me: WARNING: your environment uses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;} # humor him... cf_prog=`echo "$CC" | sed -e 's/ / /g' -e 's/[ ]* / /g' -e 's/[ ]*[ ]-[^ ].*//'` cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"` CC="$cf_prog" for cf_arg in $cf_flags do case "x$cf_arg" in (x-[IUDfgOW]*) cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_arg do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi ;; (*) CC="$CC $cf_arg" ;; esac done test -n "$verbose" && echo " resulting CC: '$CC'" 1>&6 echo "${as_me:-configure}:2372: testing resulting CC: '$CC' ..." 1>&5 test -n "$verbose" && echo " resulting CFLAGS: '$CFLAGS'" 1>&6 echo "${as_me:-configure}:2376: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5 test -n "$verbose" && echo " resulting CPPFLAGS: '$CPPFLAGS'" 1>&6 echo "${as_me:-configure}:2380: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5 ;; (*) echo "$as_me:2384: result: ok" >&5 echo "${ECHO_T}ok" >&6 ;; esac echo "$as_me:2389: checking whether ${MAKE-make} sets \${MAKE}" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$as_me:2409: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else echo "$as_me:2413: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi for ac_prog in ggrep grep do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:2422: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$GREP"; then ac_cv_prog_GREP="$GREP" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_GREP="$ac_prog" echo "$as_me:2437: found $ac_dir/$ac_word" >&5 break done fi fi GREP=$ac_cv_prog_GREP if test -n "$GREP"; then echo "$as_me:2445: result: $GREP" >&5 echo "${ECHO_T}$GREP" >&6 else echo "$as_me:2448: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$GREP" && break done test -n "$GREP" || GREP=": " echo "$as_me:2456: checking for fgrep" >&5 echo $ECHO_N "checking for fgrep... $ECHO_C" >&6 if test "${ac_cv_path_FGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else for ac_prog in gfgrep fgrep do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:2468: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_FGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $FGREP in [\\/]* | ?:[\\/]*) ac_cv_path_FGREP="$FGREP" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_FGREP="$ac_dir/$ac_word" echo "$as_me:2485: found $ac_dir/$ac_word" >&5 break fi done ;; esac fi FGREP=$ac_cv_path_FGREP if test -n "$FGREP"; then echo "$as_me:2496: result: $FGREP" >&5 echo "${ECHO_T}$FGREP" >&6 else echo "$as_me:2499: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$FGREP" && break done test -n "$FGREP" || FGREP=": " test "x$ac_cv_path_FGREP" = "x:" && { { echo "$as_me:2507: error: cannot find workable fgrep" >&5 echo "$as_me: error: cannot find workable fgrep" >&2;} { (exit 1); exit 1; }; } fi fi echo "$as_me:2512: result: $ac_cv_path_FGREP" >&5 echo "${ECHO_T}$ac_cv_path_FGREP" >&6 FGREP="$ac_cv_path_FGREP" echo "$as_me:2516: checking for makeflags variable" >&5 echo $ECHO_N "checking for makeflags variable... $ECHO_C" >&6 if test "${cf_cv_makeflags+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cf_cv_makeflags='' for cf_option in '-${MAKEFLAGS}' '${MFLAGS}' do cat >cf_makeflags.tmp </dev/null | ${FGREP-fgrep} -v "ing directory" | sed -e 's,[ ]*$,,'` case "$cf_result" in (.*k|.*kw) cf_result="`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`" case "$cf_result" in (.*CC=*) cf_cv_makeflags= ;; (*) cf_cv_makeflags=$cf_option ;; esac break ;; (.-) ;; (*) echo "${as_me:-configure}:2546: testing given option \"$cf_option\",no match \"$cf_result\" ..." 1>&5 ;; esac done rm -f cf_makeflags.tmp fi echo "$as_me:2554: result: $cf_cv_makeflags" >&5 echo "${ECHO_T}$cf_cv_makeflags" >&6 echo "$as_me:2557: checking for \".PHONY\" make-support" >&5 echo $ECHO_N "checking for \".PHONY\" make-support... $ECHO_C" >&6 if test "${cf_cv_make_PHONY+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -rf conftest* ( mkdir conftest || exit 1 cd conftest cat >makefile <<'CF_EOF' .PHONY: always DATA=0 always: always.out @echo "** making $@ $(DATA)" once: once.out @echo "** making $@ $(DATA)" always.out: @echo "** making $@ $(DATA)" echo $(DATA) > $@ once.out: @echo "** making $@ $(DATA)" echo $(DATA) > $@ CF_EOF for cf_data in 1 2 3 do ${MAKE:-make} always DATA=$cf_data ${MAKE:-make} once DATA=$cf_data ${MAKE:-make} -t always once if test -f always ; then echo "no (case 1)" > ../conftest.tmp elif test ! -f always.out ; then echo "no (case 2)" > ../conftest.tmp elif test ! -f once.out ; then echo "no (case 3)" > ../conftest.tmp elif ! cmp -s always.out once.out ; then echo "no (case 4)" > ../conftest.tmp diff always.out once.out else cf_check="`cat always.out`" if test "x$cf_check" != "x$cf_data" ; then echo "no (case 5)" > ../conftest.tmp else echo yes > ../conftest.tmp rm -f ./*.out continue fi fi break done ) >&5 2>&1 cf_cv_make_PHONY="`cat conftest.tmp`" rm -rf conftest* fi echo "$as_me:2612: result: $cf_cv_make_PHONY" >&5 echo "${ECHO_T}$cf_cv_make_PHONY" >&6 MAKE_NO_PHONY="#" MAKE_PHONY="#" test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY= test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY= echo "$as_me:2619: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else for ac_prog in gegrep egrep do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:2631: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_EGREP="$EGREP" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_EGREP="$ac_dir/$ac_word" echo "$as_me:2648: found $ac_dir/$ac_word" >&5 break fi done ;; esac fi EGREP=$ac_cv_path_EGREP if test -n "$EGREP"; then echo "$as_me:2659: result: $EGREP" >&5 echo "${ECHO_T}$EGREP" >&6 else echo "$as_me:2662: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$EGREP" && break done test -n "$EGREP" || EGREP=": " test "x$ac_cv_path_EGREP" = "x:" && { { echo "$as_me:2670: error: cannot find workable egrep" >&5 echo "$as_me: error: cannot find workable egrep" >&2;} { (exit 1); exit 1; }; } fi fi echo "$as_me:2675: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6 EGREP="$ac_cv_path_EGREP" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" echo "$as_me:2685: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >"conftest.$ac_ext" <<_ACEOF #line 2706 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:2711: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2717: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Broken: fails on valid input. continue fi rm -f conftest.err "conftest.$ac_ext" # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >"conftest.$ac_ext" <<_ACEOF #line 2740 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:2744: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2750: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err "conftest.$ac_ext" done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err "conftest.$ac_ext" if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:2787: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >"conftest.$ac_ext" <<_ACEOF #line 2797 "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:2802: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2808: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Broken: fails on valid input. continue fi rm -f conftest.err "conftest.$ac_ext" # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >"conftest.$ac_ext" <<_ACEOF #line 2831 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:2835: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:2841: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err "conftest.$ac_ext" done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err "conftest.$ac_ext" if $ac_preproc_ok; then : else { { echo "$as_me:2869: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS "conftest.$ac_ext" >&5' ac_link='$CC -o "conftest$ac_exeext" $CFLAGS $CPPFLAGS $LDFLAGS "conftest.$ac_ext" $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_main_return="return" # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:2893: checking for a BSD compatible install" >&5 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_IFS=$IFS; IFS=$ac_path_separator for ac_dir in $PATH; do IFS=$ac_save_IFS # Account for people who put trailing slashes in PATH elements. case $ac_dir/ in / | ./ | .// | /cC/* \ | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \ | /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if $as_executable_p "$ac_dir/$ac_prog"; then if test $ac_prog = install && grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:2942: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' for ac_prog in byacc 'bison -y' do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:2957: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_YACC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_YACC="$ac_prog" echo "$as_me:2972: found $ac_dir/$ac_word" >&5 break done fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then echo "$as_me:2980: result: $YACC" >&5 echo "${ECHO_T}$YACC" >&6 else echo "$as_me:2983: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$YACC" && break done test -n "$YACC" || YACC="yacc" for ac_prog in lint cppcheck splint do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:2995: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_LINT+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$LINT"; then ac_cv_prog_LINT="$LINT" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_LINT="$ac_prog" echo "$as_me:3010: found $ac_dir/$ac_word" >&5 break done fi fi LINT=$ac_cv_prog_LINT if test -n "$LINT"; then echo "$as_me:3018: result: $LINT" >&5 echo "${ECHO_T}$LINT" >&6 else echo "$as_me:3021: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$LINT" && break done case "x$LINT" in (xcppcheck|x*/cppcheck) test -z "$LINT_OPTS" && LINT_OPTS="--enable=all" ;; esac echo "$as_me:3034: checking if filesystem supports mixed-case filenames" >&5 echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6 if test "${cf_cv_mixedcase+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes ; then case "$target_alias" in (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*) cf_cv_mixedcase=no ;; (*) cf_cv_mixedcase=yes ;; esac else rm -f conftest CONFTEST echo test >conftest if test -f CONFTEST ; then cf_cv_mixedcase=no else cf_cv_mixedcase=yes fi rm -f conftest CONFTEST fi fi echo "$as_me:3061: result: $cf_cv_mixedcase" >&5 echo "${ECHO_T}$cf_cv_mixedcase" >&6 test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF #define MIXEDCASE_FILENAMES 1 EOF for ac_prog in exctags ctags do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:3072: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CTAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CTAGS"; then ac_cv_prog_CTAGS="$CTAGS" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CTAGS="$ac_prog" echo "$as_me:3087: found $ac_dir/$ac_word" >&5 break done fi fi CTAGS=$ac_cv_prog_CTAGS if test -n "$CTAGS"; then echo "$as_me:3095: result: $CTAGS" >&5 echo "${ECHO_T}$CTAGS" >&6 else echo "$as_me:3098: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CTAGS" && break done for ac_prog in exetags etags do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:3109: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ETAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ETAGS"; then ac_cv_prog_ETAGS="$ETAGS" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ETAGS="$ac_prog" echo "$as_me:3124: found $ac_dir/$ac_word" >&5 break done fi fi ETAGS=$ac_cv_prog_ETAGS if test -n "$ETAGS"; then echo "$as_me:3132: result: $ETAGS" >&5 echo "${ECHO_T}$ETAGS" >&6 else echo "$as_me:3135: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ETAGS" && break done # Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args. set dummy ${CTAGS:-ctags}; ac_word=$2 echo "$as_me:3144: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$MAKE_LOWER_TAGS"; then ac_cv_prog_MAKE_LOWER_TAGS="$MAKE_LOWER_TAGS" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_MAKE_LOWER_TAGS="yes" echo "$as_me:3159: found $ac_dir/$ac_word" >&5 break done test -z "$ac_cv_prog_MAKE_LOWER_TAGS" && ac_cv_prog_MAKE_LOWER_TAGS="no" fi fi MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS if test -n "$MAKE_LOWER_TAGS"; then echo "$as_me:3168: result: $MAKE_LOWER_TAGS" >&5 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6 else echo "$as_me:3171: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "$cf_cv_mixedcase" = yes ; then # Extract the first word of "${ETAGS:-etags}", so it can be a program name with args. set dummy ${ETAGS:-etags}; ac_word=$2 echo "$as_me:3178: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$MAKE_UPPER_TAGS"; then ac_cv_prog_MAKE_UPPER_TAGS="$MAKE_UPPER_TAGS" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_MAKE_UPPER_TAGS="yes" echo "$as_me:3193: found $ac_dir/$ac_word" >&5 break done test -z "$ac_cv_prog_MAKE_UPPER_TAGS" && ac_cv_prog_MAKE_UPPER_TAGS="no" fi fi MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS if test -n "$MAKE_UPPER_TAGS"; then echo "$as_me:3202: result: $MAKE_UPPER_TAGS" >&5 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6 else echo "$as_me:3205: result: no" >&5 echo "${ECHO_T}no" >&6 fi else MAKE_UPPER_TAGS=no fi if test "$MAKE_UPPER_TAGS" = yes ; then MAKE_UPPER_TAGS= else MAKE_UPPER_TAGS="#" fi if test "$MAKE_LOWER_TAGS" = yes ; then MAKE_LOWER_TAGS= else MAKE_LOWER_TAGS="#" fi echo "$as_me:3225: checking if the POSIX test-macros are already defined" >&5 echo $ECHO_N "checking if the POSIX test-macros are already defined... $ECHO_C" >&6 if test "${cf_cv_posix_visible+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 3232 "configure" #include "confdefs.h" #include int main (void) { #if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \ && defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \ && defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \ && defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0) #error conflicting symbols found #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3251: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3254: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3257: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3260: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_posix_visible=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_posix_visible=yes fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:3271: result: $cf_cv_posix_visible" >&5 echo "${ECHO_T}$cf_cv_posix_visible" >&6 if test "$cf_cv_posix_visible" = no; then cf_XOPEN_SOURCE=500 cf_POSIX_C_SOURCE=199506L cf_xopen_source= case "$host_os" in (aix[4-7]*) cf_xopen_source="-D_ALL_SOURCE" ;; (darwin[0-8].*) cf_xopen_source="-D_APPLE_C_SOURCE" ;; (darwin*) cf_xopen_source="-D_DARWIN_C_SOURCE" cf_XOPEN_SOURCE= ;; (freebsd*|dragonfly*|midnightbsd*) # 5.x headers associate # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L cf_POSIX_C_SOURCE=200112L cf_XOPEN_SOURCE=600 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" ;; (hpux11*) cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500" ;; (hpux*) cf_xopen_source="-D_HPUX_SOURCE" ;; (irix[56].*) cf_xopen_source="-D_SGI_SOURCE" cf_XOPEN_SOURCE= ;; (linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc) cf_gnu_xopen_source=$cf_XOPEN_SOURCE echo "$as_me:3313: checking if this is the GNU C library" >&5 echo $ECHO_N "checking if this is the GNU C library... $ECHO_C" >&6 if test "${cf_cv_gnu_library+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 3320 "configure" #include "confdefs.h" #include int main (void) { #if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0 return 0; #elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0 return 0; #else # error not GNU C library #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3339: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3342: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3345: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3348: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_gnu_library=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_gnu_library=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:3359: result: $cf_cv_gnu_library" >&5 echo "${ECHO_T}$cf_cv_gnu_library" >&6 if test x$cf_cv_gnu_library = xyes; then # With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE # was changed to help a little. newlib incorporated the change about 4 # years later. echo "$as_me:3367: checking if _DEFAULT_SOURCE can be used as a basis" >&5 echo $ECHO_N "checking if _DEFAULT_SOURCE can be used as a basis... $ECHO_C" >&6 if test "${cf_cv_gnu_library_219+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cf_save="$CPPFLAGS" test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE" cat >"conftest.$ac_ext" <<_ACEOF #line 3379 "configure" #include "confdefs.h" #include int main (void) { #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2) return 0; #elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3) return 0; #else # error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3398: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3401: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3404: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3407: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_gnu_library_219=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_gnu_library_219=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CPPFLAGS="$cf_save" fi echo "$as_me:3419: result: $cf_cv_gnu_library_219" >&5 echo "${ECHO_T}$cf_cv_gnu_library_219" >&6 if test "x$cf_cv_gnu_library_219" = xyes; then cf_save="$CPPFLAGS" echo "$as_me:3424: checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE" >&5 echo $ECHO_N "checking if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE... $ECHO_C" >&6 if test "${cf_cv_gnu_dftsrc_219+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi cat >"conftest.$ac_ext" <<_ACEOF #line 3529 "configure" #include "confdefs.h" #include #include int main (void) { #if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1) return 0; #else # error GNU C library is too old #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3549: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3552: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3555: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3558: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_gnu_dftsrc_219=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_gnu_dftsrc_219=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:3569: result: $cf_cv_gnu_dftsrc_219" >&5 echo "${ECHO_T}$cf_cv_gnu_dftsrc_219" >&6 test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save" else cf_cv_gnu_dftsrc_219=maybe fi if test "x$cf_cv_gnu_dftsrc_219" != xyes; then echo "$as_me:3578: checking if we must define _GNU_SOURCE" >&5 echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6 if test "${cf_cv_gnu_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 3585 "configure" #include "confdefs.h" #include int main (void) { #ifndef _XOPEN_SOURCE #error expected _XOPEN_SOURCE to be defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3600: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3603: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3606: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3609: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_gnu_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_save="$CPPFLAGS" cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in -D_GNU_SOURCE do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi cat >"conftest.$ac_ext" <<_ACEOF #line 3716 "configure" #include "confdefs.h" #include int main (void) { #ifdef _XOPEN_SOURCE #error expected _XOPEN_SOURCE to be undefined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3731: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3734: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3737: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3740: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_gnu_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_gnu_source=yes fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CPPFLAGS="$cf_save" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:3755: result: $cf_cv_gnu_source" >&5 echo "${ECHO_T}$cf_cv_gnu_source" >&6 if test "$cf_cv_gnu_source" = yes then echo "$as_me:3760: checking if we should also define _DEFAULT_SOURCE" >&5 echo $ECHO_N "checking if we should also define _DEFAULT_SOURCE... $ECHO_C" >&6 if test "${cf_cv_default_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_GNU_SOURCE" cat >"conftest.$ac_ext" <<_ACEOF #line 3770 "configure" #include "confdefs.h" #include int main (void) { #ifdef _DEFAULT_SOURCE #error expected _DEFAULT_SOURCE to be undefined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3785: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3788: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3791: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3794: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_default_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_default_source=yes fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:3805: result: $cf_cv_default_source" >&5 echo "${ECHO_T}$cf_cv_default_source" >&6 if test "$cf_cv_default_source" = yes then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_DEFAULT_SOURCE" fi fi fi fi ;; (minix*) cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this... ;; (mirbsd*) # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks and other headers which use u_int / u_short types cf_XOPEN_SOURCE= if test "$cf_cv_posix_visible" = no; then cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE cf_save_CFLAGS="$CFLAGS" cf_save_CPPFLAGS="$CPPFLAGS" cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` echo "$as_me:3842: checking if we should define _POSIX_C_SOURCE" >&5 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6 if test "${cf_cv_posix_c_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else echo "${as_me:-configure}:3848: testing if the symbol is already defined go no further ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF #line 3851 "configure" #include "confdefs.h" #include int main (void) { #ifndef _POSIX_C_SOURCE #error _POSIX_C_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3866: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3869: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3872: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3875: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_posix_c_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_want_posix_source=no case .$cf_POSIX_C_SOURCE in (.[12]??*) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" ;; (.2) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" cf_want_posix_source=yes ;; (.*) cf_want_posix_source=yes ;; esac if test "$cf_want_posix_source" = yes ; then cat >"conftest.$ac_ext" <<_ACEOF #line 3896 "configure" #include "confdefs.h" #include int main (void) { #ifdef _POSIX_SOURCE #error _POSIX_SOURCE is defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3911: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3914: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3917: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3920: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "${as_me:-configure}:3931: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source" echo "${as_me:-configure}:3939: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF #line 3942 "configure" #include "confdefs.h" #include int main (void) { #ifndef _POSIX_C_SOURCE #error _POSIX_C_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:3957: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:3960: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:3963: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:3966: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_posix_c_source=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CFLAGS="$cf_save_CFLAGS" CPPFLAGS="$cf_save_CPPFLAGS" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:3982: result: $cf_cv_posix_c_source" >&5 echo "${ECHO_T}$cf_cv_posix_c_source" >&6 if test "$cf_cv_posix_c_source" != no ; then CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_cv_posix_c_source do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi fi fi # cf_cv_posix_visible ;; (netbsd*) cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw ;; (openbsd[6-9]*) # OpenBSD 6.x has broken locale support, both compile-time and runtime. # see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html # Abusing the conformance level is a workaround. { echo "$as_me:4099: WARNING: this system does not provide usable locale support" >&5 echo "$as_me: WARNING: this system does not provide usable locale support" >&2;} cf_xopen_source="-D_BSD_SOURCE" cf_XOPEN_SOURCE=700 ;; (openbsd[4-5]*) # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw cf_xopen_source="-D_BSD_SOURCE" cf_XOPEN_SOURCE=600 ;; (openbsd*) # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw ;; (osf[45]*) cf_xopen_source="-D_OSF_SOURCE" ;; (nto-qnx*) cf_xopen_source="-D_QNX_SOURCE" ;; (sco*) # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer ;; (solaris2.*) cf_xopen_source="-D__EXTENSIONS__" cf_cv_xopen_source=broken ;; (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2) cf_XOPEN_SOURCE= cf_POSIX_C_SOURCE= ;; (*) echo "$as_me:4131: checking if we should define _XOPEN_SOURCE" >&5 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6 if test "${cf_cv_xopen_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 4138 "configure" #include "confdefs.h" $ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4156: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4159: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4162: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4165: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_save="$CPPFLAGS" test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >"conftest.$ac_ext" <<_ACEOF #line 4177 "configure" #include "confdefs.h" $ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4195: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4198: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4201: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4204: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_xopen_source=$cf_XOPEN_SOURCE fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CPPFLAGS="$cf_save" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:4219: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then CFLAGS=`echo "$CFLAGS" | \ sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'` cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source" for cf_add_cflags in $cf_temp_xopen_source do case "x$cf_add_cflags" in (x-[DU]*) cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'` while true do cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ ][ ]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ ][^ ]*\\)\?%%" -e 's/^[ ]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'` test "$CFLAGS" != "$cf_old_cflag" || break CFLAGS="$cf_old_cflag" done cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'` while true do cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ ][ ]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ ][^ ]*\\)\?%%" -e 's/^[ ]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'` test "$CPPFLAGS" != "$cf_old_cflag" || break CPPFLAGS="$cf_old_cflag" done ;; esac cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_add_cflags do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi done fi cf_save_xopen_cppflags="$CPPFLAGS" if test "$cf_cv_posix_visible" = no; then cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE cf_save_CFLAGS="$CFLAGS" cf_save_CPPFLAGS="$CPPFLAGS" cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \ sed -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ ]*\)\?$//g'` echo "$as_me:4379: checking if we should define _POSIX_C_SOURCE" >&5 echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6 if test "${cf_cv_posix_c_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else echo "${as_me:-configure}:4385: testing if the symbol is already defined go no further ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF #line 4388 "configure" #include "confdefs.h" #include int main (void) { #ifndef _POSIX_C_SOURCE #error _POSIX_C_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4403: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4406: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4409: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4412: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_posix_c_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_want_posix_source=no case .$cf_POSIX_C_SOURCE in (.[12]??*) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" ;; (.2) cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" cf_want_posix_source=yes ;; (.*) cf_want_posix_source=yes ;; esac if test "$cf_want_posix_source" = yes ; then cat >"conftest.$ac_ext" <<_ACEOF #line 4433 "configure" #include "confdefs.h" #include int main (void) { #ifdef _POSIX_SOURCE #error _POSIX_SOURCE is defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4448: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4451: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4454: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4457: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "${as_me:-configure}:4468: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_cv_posix_c_source" echo "${as_me:-configure}:4476: testing if the second compile does not leave our definition intact error ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF #line 4479 "configure" #include "confdefs.h" #include int main (void) { #ifndef _POSIX_C_SOURCE #error _POSIX_C_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4494: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4497: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4500: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4503: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_posix_c_source=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CFLAGS="$cf_save_CFLAGS" CPPFLAGS="$cf_save_CPPFLAGS" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:4519: result: $cf_cv_posix_c_source" >&5 echo "${ECHO_T}$cf_cv_posix_c_source" >&6 if test "$cf_cv_posix_c_source" != no ; then CFLAGS="$cf_trim_CFLAGS" CPPFLAGS="$cf_trim_CPPFLAGS" cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_cv_posix_c_source do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi fi fi # cf_cv_posix_visible # Some of these niche implementations use copy/paste, double-check... if test "$cf_cv_xopen_source" = no ; then test -n "$verbose" && echo " checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE" 1>&6 echo "${as_me:-configure}:4632: testing checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE ..." 1>&5 cat >"conftest.$ac_ext" <<_ACEOF #line 4635 "configure" #include "confdefs.h" $ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4653: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4656: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4659: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4662: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 { echo "$as_me:4669: WARNING: _POSIX_C_SOURCE definition is not usable" >&5 echo "$as_me: WARNING: _POSIX_C_SOURCE definition is not usable" >&2;} CPPFLAGS="$cf_save_xopen_cppflags" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi ;; esac if test -n "$cf_xopen_source" ; then for cf_add_cflags in $cf_xopen_source do case "x$cf_add_cflags" in (x-[DU]*) cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'` while true do cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ ][ ]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ ][^ ]*\\)\?%%" -e 's/^[ ]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'` test "$CFLAGS" != "$cf_old_cflag" || break test -n "$verbose" && echo " removing old option $cf_add_cflags from CFLAGS" 1>&6 echo "${as_me:-configure}:4692: testing removing old option $cf_add_cflags from CFLAGS ..." 1>&5 CFLAGS="$cf_old_cflag" done cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'` while true do cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ ][ ]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ ][^ ]*\\)\?%%" -e 's/^[ ]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'` test "$CPPFLAGS" != "$cf_old_cflag" || break test -n "$verbose" && echo " removing old option $cf_add_cflags from CPPFLAGS" 1>&6 echo "${as_me:-configure}:4704: testing removing old option $cf_add_cflags from CPPFLAGS ..." 1>&5 CPPFLAGS="$cf_old_cflag" done ;; esac cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_add_cflags do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$verbose" && echo " add to \$CFLAGS $cf_new_cflags" 1>&6 echo "${as_me:-configure}:4792: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5 test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$verbose" && echo " add to \$CPPFLAGS $cf_new_cppflags" 1>&6 echo "${as_me:-configure}:4802: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5 test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6 echo "${as_me:-configure}:4812: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5 test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi done fi if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then echo "$as_me:4824: checking if _XOPEN_SOURCE really is set" >&5 echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6 cat >"conftest.$ac_ext" <<_ACEOF #line 4827 "configure" #include "confdefs.h" #include int main (void) { #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4842: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4845: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4848: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4851: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_XOPEN_SOURCE_set=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_XOPEN_SOURCE_set=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" echo "$as_me:4860: result: $cf_XOPEN_SOURCE_set" >&5 echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6 if test "$cf_XOPEN_SOURCE_set" = yes then cat >"conftest.$ac_ext" <<_ACEOF #line 4865 "configure" #include "confdefs.h" #include int main (void) { #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE #error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4880: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4883: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4886: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4889: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_XOPEN_SOURCE_set_ok=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_XOPEN_SOURCE_set_ok=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" if test "$cf_XOPEN_SOURCE_set_ok" = no then { echo "$as_me:4900: WARNING: _XOPEN_SOURCE is lower than requested" >&5 echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;} fi else echo "$as_me:4905: checking if we should define _XOPEN_SOURCE" >&5 echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6 if test "${cf_cv_xopen_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 4912 "configure" #include "confdefs.h" $ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4930: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4933: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4936: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4939: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_save="$CPPFLAGS" test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" cat >"conftest.$ac_ext" <<_ACEOF #line 4951 "configure" #include "confdefs.h" $ac_includes_default int main (void) { #ifndef _XOPEN_SOURCE #error _XOPEN_SOURCE is not defined #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:4969: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:4972: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:4975: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:4978: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_xopen_source=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_xopen_source=$cf_XOPEN_SOURCE fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" CPPFLAGS="$cf_save" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:4993: result: $cf_cv_xopen_source" >&5 echo "${ECHO_T}$cf_cv_xopen_source" >&6 if test "$cf_cv_xopen_source" != no ; then CFLAGS=`echo "$CFLAGS" | \ sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ ]*\)\?$//g'` cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source" for cf_add_cflags in $cf_temp_xopen_source do case "x$cf_add_cflags" in (x-[DU]*) cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'` while true do cf_old_cflag=`echo "x$CFLAGS" | sed -e 's/^.//' -e 's/[ ][ ]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ ][^ ]*\\)\?%%" -e 's/^[ ]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'` test "$CFLAGS" != "$cf_old_cflag" || break CFLAGS="$cf_old_cflag" done cf_tmp_cflag=`echo "x$cf_add_cflags" | sed -e 's/^.//' -e 's/=.*//'` while true do cf_old_cflag=`echo "x$CPPFLAGS" | sed -e 's/^.//' -e 's/[ ][ ]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[^ ][^ ]*\\)\?%%" -e 's/^[ ]*//' -e 's%[ ][ ]*-D% -D%g' -e 's%[ ][ ]*-I% -I%g'` test "$CPPFLAGS" != "$cf_old_cflag" || break CPPFLAGS="$cf_old_cflag" done ;; esac cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in $cf_add_cflags do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi done fi fi fi fi # cf_cv_posix_visible # Check whether --enable-largefile or --disable-largefile was given. if test "${enable_largefile+set}" = set; then enableval="$enable_largefile" fi; if test "$enable_largefile" != no; then echo "$as_me:5147: checking for special C compiler options needed for large files" >&5 echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6 if test "${ac_cv_sys_largefile_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat >"conftest.$ac_ext" <<_ACEOF #line 5159 "configure" #include "confdefs.h" #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5179: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5182: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5185: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5188: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" CC="$CC -n32" rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5198: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5201: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5204: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5207: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_sys_largefile_CC=' -n32'; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" break done CC=$ac_save_CC rm -f "conftest.$ac_ext" fi fi echo "$as_me:5221: result: $ac_cv_sys_largefile_CC" >&5 echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6 if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi echo "$as_me:5227: checking for _FILE_OFFSET_BITS value needed for large files" >&5 echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6 if test "${ac_cv_sys_file_offset_bits+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do ac_cv_sys_file_offset_bits=no cat >"conftest.$ac_ext" <<_ACEOF #line 5235 "configure" #include "confdefs.h" #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5255: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5258: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5261: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5264: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" cat >"conftest.$ac_ext" <<_ACEOF #line 5273 "configure" #include "confdefs.h" #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5294: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5297: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5300: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5303: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_sys_file_offset_bits=64; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" break done fi echo "$as_me:5314: result: $ac_cv_sys_file_offset_bits" >&5 echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6 if test "$ac_cv_sys_file_offset_bits" != no; then cat >>confdefs.h <&5 echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6 if test "${ac_cv_sys_large_files+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do ac_cv_sys_large_files=no cat >"conftest.$ac_ext" <<_ACEOF #line 5332 "configure" #include "confdefs.h" #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5352: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5355: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5358: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5361: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" cat >"conftest.$ac_ext" <<_ACEOF #line 5370 "configure" #include "confdefs.h" #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main (void) { ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5391: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5394: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5397: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5400: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_sys_large_files=1; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" break done fi echo "$as_me:5411: result: $ac_cv_sys_large_files" >&5 echo "${ECHO_T}$ac_cv_sys_large_files" >&6 if test "$ac_cv_sys_large_files" != no; then cat >>confdefs.h <&5 echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6 if test "${ac_cv_sys_largefile_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do ac_cv_sys_largefile_source=no cat >"conftest.$ac_ext" <<_ACEOF #line 5432 "configure" #include "confdefs.h" #include #include int main (void) { int (*my_fseeko)(FILE *, off_t, int) = fseeko; return my_fseeko(stdin, 0, 0); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5447: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5450: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5453: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5456: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" cat >"conftest.$ac_ext" <<_ACEOF #line 5465 "configure" #include "confdefs.h" #define _LARGEFILE_SOURCE 1 #include #include int main (void) { int (*my_fseeko)(FILE *, off_t, int) = fseeko; return my_fseeko(stdin, 0, 0); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5481: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5484: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5487: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5490: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_sys_largefile_source=1; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" break done fi echo "$as_me:5501: result: $ac_cv_sys_largefile_source" >&5 echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6 if test "$ac_cv_sys_largefile_source" != no; then cat >>confdefs.h <&5 echo $ECHO_N "checking for fseeko... $ECHO_C" >&6 if test "${ac_cv_func_fseeko+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 5521 "configure" #include "confdefs.h" #include #include int main (void) { int (*my_fseeko)(FILE *, off_t, int) = fseeko; return my_fseeko && my_fseeko (stdin, 0, 0); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:5535: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:5538: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:5541: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5544: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_fseeko=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_fseeko=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:5554: result: $ac_cv_func_fseeko" >&5 echo "${ECHO_T}$ac_cv_func_fseeko" >&6 if test $ac_cv_func_fseeko = yes; then cat >>confdefs.h <<\EOF #define HAVE_FSEEKO 1 EOF fi # Normally we would collect these definitions in the config.h, # but (like _XOPEN_SOURCE), some environments rely on having these # defined before any of the system headers are included. Another # case comes up with C++, e.g., on AIX the compiler compiles the # header files by themselves before looking at the body files it is # told to compile. For ncurses, those header files do not include # the config.h if test "$ac_cv_sys_large_files" != no then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_LARGE_FILES" fi if test "$ac_cv_sys_largefile_source" != no then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_LARGEFILE_SOURCE" fi if test "$ac_cv_sys_file_offset_bits" != no then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" fi echo "$as_me:5593: checking whether to use struct dirent64" >&5 echo $ECHO_N "checking whether to use struct dirent64... $ECHO_C" >&6 if test "${cf_cv_struct_dirent64+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 5600 "configure" #include "confdefs.h" #pragma GCC diagnostic error "-Wincompatible-pointer-types" #include #include #ifndef __REDIRECT /* if transitional largefile support is setup, this is true */ extern struct dirent64 * readdir(DIR *); #endif int main (void) { DIR *dp = opendir("."); struct dirent64 *x = readdir(dp); struct dirent *y = readdir(dp); int z = x - y; (void)z; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5627: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5630: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5633: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5636: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_struct_dirent64=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_struct_dirent64=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:5647: result: $cf_cv_struct_dirent64" >&5 echo "${ECHO_T}$cf_cv_struct_dirent64" >&6 test "$cf_cv_struct_dirent64" = yes && cat >>confdefs.h <<\EOF #define HAVE_STRUCT_DIRENT64 1 EOF fi echo "$as_me:5656: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 5662 "configure" #include "confdefs.h" #include #include #include #include _ACEOF if { (eval echo "$as_me:5670: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:5676: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_stdc=no fi rm -f conftest.err "conftest.$ac_ext" if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >"conftest.$ac_ext" <<_ACEOF #line 5698 "configure" #include "confdefs.h" #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -rf conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >"conftest.$ac_ext" <<_ACEOF #line 5716 "configure" #include "confdefs.h" #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -rf conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >"conftest.$ac_ext" <<_ACEOF #line 5737 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main (void) { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) $ac_main_return(2); $ac_main_return (0); } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:5763: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:5766: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:5768: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5771: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_stdc=no fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi fi fi echo "$as_me:5784: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:5800: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 5806 "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5812: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5815: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5818: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5821: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_Header=no" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:5831: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking whether exit is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_exit+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 5847 "configure" #include "confdefs.h" $ac_includes_default int main (void) { #ifndef exit (void) exit; #endif ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:5862: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:5865: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:5868: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:5871: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_have_decl_exit=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_have_decl_exit=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:5881: result: $ac_cv_have_decl_exit" >&5 echo "${ECHO_T}$ac_cv_have_decl_exit" >&6 if test "$cross_compiling" = yes ; then # defaults that we might want to override : ${BUILD_CFLAGS:=''} : ${BUILD_CPPFLAGS:=''} : ${BUILD_LDFLAGS:=''} : ${BUILD_LIBS:=''} : ${BUILD_EXEEXT:='$x'} : ${BUILD_OBJEXT:='o'} # Check whether --with-build-cc or --without-build-cc was given. if test "${with_build_cc+set}" = set; then withval="$with_build_cc" BUILD_CC="$withval" else for ac_prog in gcc clang c99 c89 cc cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:5903: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_BUILD_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$BUILD_CC"; then ac_cv_prog_BUILD_CC="$BUILD_CC" # Let the user override the test. else ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_BUILD_CC="$ac_prog" echo "$as_me:5918: found $ac_dir/$ac_word" >&5 break done fi fi BUILD_CC=$ac_cv_prog_BUILD_CC if test -n "$BUILD_CC"; then echo "$as_me:5926: result: $BUILD_CC" >&5 echo "${ECHO_T}$BUILD_CC" >&6 else echo "$as_me:5929: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$BUILD_CC" && break done test -n "$BUILD_CC" || BUILD_CC="none" fi; echo "$as_me:5938: checking for native build C compiler" >&5 echo $ECHO_N "checking for native build C compiler... $ECHO_C" >&6 echo "$as_me:5940: result: $BUILD_CC" >&5 echo "${ECHO_T}$BUILD_CC" >&6 echo "$as_me:5943: checking for native build C preprocessor" >&5 echo $ECHO_N "checking for native build C preprocessor... $ECHO_C" >&6 # Check whether --with-build-cpp or --without-build-cpp was given. if test "${with_build_cpp+set}" = set; then withval="$with_build_cpp" BUILD_CPP="$withval" else BUILD_CPP='${BUILD_CC} -E' fi; echo "$as_me:5953: result: $BUILD_CPP" >&5 echo "${ECHO_T}$BUILD_CPP" >&6 echo "$as_me:5956: checking for native build C flags" >&5 echo $ECHO_N "checking for native build C flags... $ECHO_C" >&6 # Check whether --with-build-cflags or --without-build-cflags was given. if test "${with_build_cflags+set}" = set; then withval="$with_build_cflags" BUILD_CFLAGS="$withval" fi; echo "$as_me:5964: result: $BUILD_CFLAGS" >&5 echo "${ECHO_T}$BUILD_CFLAGS" >&6 echo "$as_me:5967: checking for native build C preprocessor-flags" >&5 echo $ECHO_N "checking for native build C preprocessor-flags... $ECHO_C" >&6 # Check whether --with-build-cppflags or --without-build-cppflags was given. if test "${with_build_cppflags+set}" = set; then withval="$with_build_cppflags" BUILD_CPPFLAGS="$withval" fi; echo "$as_me:5975: result: $BUILD_CPPFLAGS" >&5 echo "${ECHO_T}$BUILD_CPPFLAGS" >&6 echo "$as_me:5978: checking for native build linker-flags" >&5 echo $ECHO_N "checking for native build linker-flags... $ECHO_C" >&6 # Check whether --with-build-ldflags or --without-build-ldflags was given. if test "${with_build_ldflags+set}" = set; then withval="$with_build_ldflags" BUILD_LDFLAGS="$withval" fi; echo "$as_me:5986: result: $BUILD_LDFLAGS" >&5 echo "${ECHO_T}$BUILD_LDFLAGS" >&6 echo "$as_me:5989: checking for native build linker-libraries" >&5 echo $ECHO_N "checking for native build linker-libraries... $ECHO_C" >&6 # Check whether --with-build-libs or --without-build-libs was given. if test "${with_build_libs+set}" = set; then withval="$with_build_libs" BUILD_LIBS="$withval" fi; echo "$as_me:5997: result: $BUILD_LIBS" >&5 echo "${ECHO_T}$BUILD_LIBS" >&6 # this assumes we're on Unix. BUILD_EXEEXT= BUILD_OBJEXT=o : ${BUILD_CC:='${CC}'} echo "$as_me:6006: checking if the build-compiler \"$BUILD_CC\" works" >&5 echo $ECHO_N "checking if the build-compiler \"$BUILD_CC\" works... $ECHO_C" >&6 cf_save_crossed=$cross_compiling cf_save_ac_link=$ac_link cross_compiling=no cf_build_cppflags=$BUILD_CPPFLAGS test "$cf_build_cppflags" = "#" && cf_build_cppflags= ac_link='$BUILD_CC -o "conftest$ac_exeext" $BUILD_CFLAGS $cf_build_cppflags $BUILD_LDFLAGS "conftest.$ac_ext" $BUILD_LIBS >&5' if test "$cross_compiling" = yes; then cf_ok_build_cc=unknown else cat >"conftest.$ac_ext" <<_ACEOF #line 6020 "configure" #include "confdefs.h" #include int main(int argc, char *argv[]) { ${cf_cv_main_return:-return}(argc < 0 || argv == 0 || argv[0] == 0); } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:6030: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:6033: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:6035: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:6038: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_ok_build_cc=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_ok_build_cc=no fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi cross_compiling=$cf_save_crossed ac_link=$cf_save_ac_link echo "$as_me:6053: result: $cf_ok_build_cc" >&5 echo "${ECHO_T}$cf_ok_build_cc" >&6 if test "$cf_ok_build_cc" != yes then { { echo "$as_me:6058: error: Cross-build requires two compilers. Use --with-build-cc to specify the native compiler." >&5 echo "$as_me: error: Cross-build requires two compilers. Use --with-build-cc to specify the native compiler." >&2;} { (exit 1); exit 1; }; } fi else : ${BUILD_CC:='${CC}'} : ${BUILD_CPP:='${CPP}'} : ${BUILD_CFLAGS:='${CFLAGS}'} : ${BUILD_CPPFLAGS:='${CPPFLAGS}'} : ${BUILD_LDFLAGS:='${LDFLAGS}'} : ${BUILD_LIBS:='${LIBS}'} : ${BUILD_EXEEXT:='$x'} : ${BUILD_OBJEXT:='o'} fi if test "${MATHLIB+set}" != set ; then echo "$as_me:6077: checking for log in -lm" >&5 echo $ECHO_N "checking for log in -lm... $ECHO_C" >&6 if test "${ac_cv_lib_m_log+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 6085 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char log (void); int main (void) { log (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:6104: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:6107: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:6110: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:6113: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_m_log=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_m_log=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:6124: result: $ac_cv_lib_m_log" >&5 echo "${ECHO_T}$ac_cv_lib_m_log" >&6 if test "$ac_cv_lib_m_log" = yes; then MATHLIB=-lm ; LIBS="-lm $LIBS" else # maybe don't need separate math library echo "$as_me:6130: checking for log" >&5 echo $ECHO_N "checking for log... $ECHO_C" >&6 if test "${ac_cv_func_log+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 6136 "configure" #include "confdefs.h" #define log autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef log #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char log (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_log) || defined (__stub___log) #error found stub for log #endif return log (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:6167: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:6170: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:6173: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:6176: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_log=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_log=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:6186: result: $ac_cv_func_log" >&5 echo "${ECHO_T}$ac_cv_func_log" >&6 if test "$ac_cv_func_log" = yes; then log=yes fi if test "$log" = yes then MATHLIB='' # evidently don't need one else { { echo "$as_me:6196: error: Cannot find a math library. You need to set MATHLIB in config.user" >&5 echo "$as_me: error: Cannot find a math library. You need to set MATHLIB in config.user" >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:6203: checking if you want to see long compiling messages" >&5 echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6 # Check whether --enable-echo or --disable-echo was given. if test "${enable_echo+set}" = set; then enableval="$enable_echo" test "$enableval" != no && enableval=yes if test "$enableval" != "yes" ; then ECHO_LT='--silent' ECHO_LD='@echo linking $@;' RULE_CC='@echo compiling $<' SHOW_CC='@echo compiling $@' ECHO_CC='@' else ECHO_LT='' ECHO_LD='' RULE_CC='' SHOW_CC='' ECHO_CC='' fi else enableval=yes ECHO_LT='' ECHO_LD='' RULE_CC='' SHOW_CC='' ECHO_CC='' fi; echo "$as_me:6237: result: $enableval" >&5 echo "${ECHO_T}$enableval" >&6 echo "$as_me:6240: checking if you want to use C11 _Noreturn feature" >&5 echo $ECHO_N "checking if you want to use C11 _Noreturn feature... $ECHO_C" >&6 # Check whether --enable-stdnoreturn or --disable-stdnoreturn was given. if test "${enable_stdnoreturn+set}" = set; then enableval="$enable_stdnoreturn" test "$enableval" != yes && enableval=no if test "$enableval" != "no" ; then enable_stdnoreturn=yes else enable_stdnoreturn=no fi else enableval=no enable_stdnoreturn=no fi; echo "$as_me:6257: result: $enable_stdnoreturn" >&5 echo "${ECHO_T}$enable_stdnoreturn" >&6 if test $enable_stdnoreturn = yes; then echo "$as_me:6261: checking for C11 _Noreturn feature" >&5 echo $ECHO_N "checking for C11 _Noreturn feature... $ECHO_C" >&6 if test "${cf_cv_c11_noreturn+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 6267 "configure" #include "confdefs.h" $ac_includes_default #include static _Noreturn void giveup(void) { exit(0); } int main (void) { if (feof(stdin)) giveup() ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:6283: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:6286: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:6289: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:6292: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_c11_noreturn=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_c11_noreturn=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:6303: result: $cf_cv_c11_noreturn" >&5 echo "${ECHO_T}$cf_cv_c11_noreturn" >&6 else cf_cv_c11_noreturn=no, fi if test "$cf_cv_c11_noreturn" = yes; then cat >>confdefs.h <<\EOF #define HAVE_STDNORETURN_H 1 EOF cat >>confdefs.h <&6 echo "${as_me:-configure}:6359: testing repairing CFLAGS: $CFLAGS ..." 1>&5 CFLAGS="$cf_temp_flags" test -n "$verbose" && echo " ... fixed $CFLAGS" 1>&6 echo "${as_me:-configure}:6364: testing ... fixed $CFLAGS ..." 1>&5 test -n "$verbose" && echo " ... extra $EXTRA_CFLAGS" 1>&6 echo "${as_me:-configure}:6368: testing ... extra $EXTRA_CFLAGS ..." 1>&5 fi ;; esac fi if test "$GCC" = yes || test "$GXX" = yes then case $CPPFLAGS in (*-Werror=*) cf_temp_flags= for cf_temp_scan in $CPPFLAGS do case "x$cf_temp_scan" in (x-Werror=format*) test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags " cf_temp_flags="${cf_temp_flags}$cf_temp_scan" ;; (x-Werror=*) test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS " EXTRA_CFLAGS="${EXTRA_CFLAGS}$cf_temp_scan" ;; (*) test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags " cf_temp_flags="${cf_temp_flags}$cf_temp_scan" ;; esac done if test "x$CPPFLAGS" != "x$cf_temp_flags" then test -n "$verbose" && echo " repairing CPPFLAGS: $CPPFLAGS" 1>&6 echo "${as_me:-configure}:6407: testing repairing CPPFLAGS: $CPPFLAGS ..." 1>&5 CPPFLAGS="$cf_temp_flags" test -n "$verbose" && echo " ... fixed $CPPFLAGS" 1>&6 echo "${as_me:-configure}:6412: testing ... fixed $CPPFLAGS ..." 1>&5 test -n "$verbose" && echo " ... extra $EXTRA_CFLAGS" 1>&6 echo "${as_me:-configure}:6416: testing ... extra $EXTRA_CFLAGS ..." 1>&5 fi ;; esac fi if test "$GCC" = yes || test "$GXX" = yes then case $LDFLAGS in (*-Werror=*) cf_temp_flags= for cf_temp_scan in $LDFLAGS do case "x$cf_temp_scan" in (x-Werror=format*) test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags " cf_temp_flags="${cf_temp_flags}$cf_temp_scan" ;; (x-Werror=*) test -n "$EXTRA_CFLAGS" && EXTRA_CFLAGS="$EXTRA_CFLAGS " EXTRA_CFLAGS="${EXTRA_CFLAGS}$cf_temp_scan" ;; (*) test -n "$cf_temp_flags" && cf_temp_flags="$cf_temp_flags " cf_temp_flags="${cf_temp_flags}$cf_temp_scan" ;; esac done if test "x$LDFLAGS" != "x$cf_temp_flags" then test -n "$verbose" && echo " repairing LDFLAGS: $LDFLAGS" 1>&6 echo "${as_me:-configure}:6455: testing repairing LDFLAGS: $LDFLAGS ..." 1>&5 LDFLAGS="$cf_temp_flags" test -n "$verbose" && echo " ... fixed $LDFLAGS" 1>&6 echo "${as_me:-configure}:6460: testing ... fixed $LDFLAGS ..." 1>&5 test -n "$verbose" && echo " ... extra $EXTRA_CFLAGS" 1>&6 echo "${as_me:-configure}:6464: testing ... extra $EXTRA_CFLAGS ..." 1>&5 fi ;; esac fi echo "$as_me:6471: checking if you want to turn on gcc warnings" >&5 echo $ECHO_N "checking if you want to turn on gcc warnings... $ECHO_C" >&6 # Check whether --enable-warnings or --disable-warnings was given. if test "${enable_warnings+set}" = set; then enableval="$enable_warnings" test "$enableval" != yes && enableval=no if test "$enableval" != "no" ; then enable_warnings=yes else enable_warnings=no fi else enableval=no enable_warnings=no fi; echo "$as_me:6488: result: $enable_warnings" >&5 echo "${ECHO_T}$enable_warnings" >&6 if test "$enable_warnings" = "yes" then if test "$GCC" = yes || test "$GXX" = yes then cat > conftest.i <&5 echo "$as_me: checking for $CC __attribute__ directives..." >&6;} cat > "conftest.$ac_ext" < #include "confdefs.h" #include "conftest.h" #include "conftest.i" #if GCC_PRINTF #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif #if GCC_SCANF #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif extern void wow(char *,...) GCC_SCANFLIKE(1,2); extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2); extern GCC_NORETURN void foo(void); int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { (void)argc; (void)argv; return 0; } EOF cf_printf_attribute=no cf_scanf_attribute=no for cf_attribute in scanf printf unused noreturn do cf_ATTRIBUTE=`echo "$cf_attribute" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` cf_directive="__attribute__(($cf_attribute))" echo "checking for $CC $cf_directive" 1>&5 case "$cf_attribute" in (printf) cf_printf_attribute=yes cat >conftest.h <conftest.h <conftest.h <&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:6567: \$? = $ac_status" >&5 (exit "$ac_status"); }; then test -n "$verbose" && echo "$as_me:6569: result: ... $cf_attribute" >&5 echo "${ECHO_T}... $cf_attribute" >&6 cat conftest.h >>confdefs.h case "$cf_attribute" in (noreturn) cat >>confdefs.h <>confdefs.h <<\EOF #define GCC_PRINTF 1 EOF fi cat >>confdefs.h <>confdefs.h <<\EOF #define GCC_SCANF 1 EOF fi cat >>confdefs.h <>confdefs.h <>confdefs.h fi rm -rf ./conftest* fi if test "x$have_x" = xyes; then cf_save_LIBS_CF_CONST_X_STRING="$LIBS" cf_save_CFLAGS_CF_CONST_X_STRING="$CFLAGS" cf_save_CPPFLAGS_CF_CONST_X_STRING="$CPPFLAGS" LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}" for cf_X_CFLAGS in $X_CFLAGS do case "x$cf_X_CFLAGS" in x-[IUD]*) CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS" ;; *) CFLAGS="$CFLAGS $cf_X_CFLAGS" ;; esac done cat >"conftest.$ac_ext" <<_ACEOF #line 6647 "configure" #include "confdefs.h" #include #include int main (void) { String foo = malloc(1); free((void*)foo) ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:6662: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:6665: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:6668: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:6671: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then echo "$as_me:6674: checking for X11/Xt const-feature" >&5 echo $ECHO_N "checking for X11/Xt const-feature... $ECHO_C" >&6 if test "${cf_cv_const_x_string+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 6681 "configure" #include "confdefs.h" #undef _CONST_X_STRING #define _CONST_X_STRING /* X11R7.8 (perhaps) */ #undef XTSTRINGDEFINES /* X11R5 and later */ #include #include int main (void) { String foo = malloc(1); *foo = 0 ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:6699: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:6702: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:6705: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:6708: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_const_x_string=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_const_x_string=yes fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:6723: result: $cf_cv_const_x_string" >&5 echo "${ECHO_T}$cf_cv_const_x_string" >&6 LIBS="$cf_save_LIBS_CF_CONST_X_STRING" CFLAGS="$cf_save_CFLAGS_CF_CONST_X_STRING" CPPFLAGS="$cf_save_CPPFLAGS_CF_CONST_X_STRING" case "$cf_cv_const_x_string" in (no) test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-DXTSTRINGDEFINES" ;; (*) test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}-D_CONST_X_STRING" ;; esac else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi cat > "conftest.$ac_ext" <&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall" for cf_opt in \ wd1419 \ wd1683 \ wd1684 \ wd193 \ wd593 \ wd279 \ wd810 \ wd869 \ wd981 do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" if { (eval echo "$as_me:6784: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:6787: \$? = $ac_status" >&5 (exit "$ac_status"); }; then test -n "$verbose" && echo "$as_me:6789: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi done CFLAGS="$cf_save_CFLAGS" elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown" then { echo "$as_me:6797: checking for $CC warning options..." >&5 echo "$as_me: checking for $CC warning options..." >&6;} cf_save_CFLAGS="$CFLAGS" cf_warn_CONST="" test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings" cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs" test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings= for cf_opt in W Wall \ Wbad-function-cast \ Wcast-align \ Wcast-qual \ Wdeclaration-after-statement \ Wextra \ Winline \ Wmissing-declarations \ Wmissing-prototypes \ Wnested-externs \ Wpointer-arith \ Wshadow \ Wstrict-prototypes \ Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST do CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" if { (eval echo "$as_me:6820: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:6823: \$? = $ac_status" >&5 (exit "$ac_status"); }; then test -n "$verbose" && echo "$as_me:6825: result: ... -$cf_opt" >&5 echo "${ECHO_T}... -$cf_opt" >&6 case "$cf_opt" in (Winline) case "$GCC_VERSION" in ([34].*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 echo "${as_me:-configure}:6833: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac ;; (Wpointer-arith) case "$GCC_VERSION" in ([12].*) test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 echo "${as_me:-configure}:6843: testing feature is broken in gcc $GCC_VERSION ..." 1>&5 continue;; esac ;; esac EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" fi done CFLAGS="$cf_save_CFLAGS" fi rm -rf ./conftest* fi fi # Extract the first word of "groff", so it can be a program name with args. set dummy groff; ac_word=$2 echo "$as_me:6862: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_GROFF_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $GROFF_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_GROFF_PATH="$GROFF_PATH" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_GROFF_PATH="$ac_dir/$ac_word" echo "$as_me:6879: found $ac_dir/$ac_word" >&5 break fi done test -z "$ac_cv_path_GROFF_PATH" && ac_cv_path_GROFF_PATH="no" ;; esac fi GROFF_PATH=$ac_cv_path_GROFF_PATH if test -n "$GROFF_PATH"; then echo "$as_me:6891: result: $GROFF_PATH" >&5 echo "${ECHO_T}$GROFF_PATH" >&6 else echo "$as_me:6894: result: no" >&5 echo "${ECHO_T}no" >&6 fi for ac_prog in nroff mandoc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:6902: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_NROFF_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $NROFF_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_NROFF_PATH="$NROFF_PATH" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_NROFF_PATH="$ac_dir/$ac_word" echo "$as_me:6919: found $ac_dir/$ac_word" >&5 break fi done ;; esac fi NROFF_PATH=$ac_cv_path_NROFF_PATH if test -n "$NROFF_PATH"; then echo "$as_me:6930: result: $NROFF_PATH" >&5 echo "${ECHO_T}$NROFF_PATH" >&6 else echo "$as_me:6933: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$NROFF_PATH" && break done test -n "$NROFF_PATH" || NROFF_PATH="no" # Extract the first word of "tbl", so it can be a program name with args. set dummy tbl; ac_word=$2 echo "$as_me:6943: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_TBL_PATH+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $TBL_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_TBL_PATH="$TBL_PATH" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_TBL_PATH="$ac_dir/$ac_word" echo "$as_me:6960: found $ac_dir/$ac_word" >&5 break fi done test -z "$ac_cv_path_TBL_PATH" && ac_cv_path_TBL_PATH="cat" ;; esac fi TBL_PATH=$ac_cv_path_TBL_PATH if test -n "$TBL_PATH"; then echo "$as_me:6972: result: $TBL_PATH" >&5 echo "${ECHO_T}$TBL_PATH" >&6 else echo "$as_me:6975: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "x$GROFF_PATH" = xno then NROFF_NOTE= GROFF_NOTE="#" else NROFF_NOTE="#" GROFF_NOTE= fi case "x${with_man2html}" in (xno) cf_man2html=no ;; (x|xyes) # Extract the first word of "man2html", so it can be a program name with args. set dummy man2html; ac_word=$2 echo "$as_me:6995: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_cf_man2html+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $cf_man2html in [\\/]* | ?:[\\/]*) ac_cv_path_cf_man2html="$cf_man2html" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_cf_man2html="$ac_dir/$ac_word" echo "$as_me:7012: found $ac_dir/$ac_word" >&5 break fi done test -z "$ac_cv_path_cf_man2html" && ac_cv_path_cf_man2html="no" ;; esac fi cf_man2html=$ac_cv_path_cf_man2html if test -n "$cf_man2html"; then echo "$as_me:7024: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 else echo "$as_me:7027: result: no" >&5 echo "${ECHO_T}no" >&6 fi case "x$cf_man2html" in (x/*) echo "$as_me:7033: checking for the modified Earl Hood script" >&5 echo $ECHO_N "checking for the modified Earl Hood script... $ECHO_C" >&6 if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null ) then cf_man2html_ok=yes else cf_man2html=no cf_man2html_ok=no fi echo "$as_me:7042: result: $cf_man2html_ok" >&5 echo "${ECHO_T}$cf_man2html_ok" >&6 ;; (*) cf_man2html=no ;; esac esac echo "$as_me:7051: checking for program to convert manpage to html" >&5 echo $ECHO_N "checking for program to convert manpage to html... $ECHO_C" >&6 # Check whether --with-man2html or --without-man2html was given. if test "${with_man2html+set}" = set; then withval="$with_man2html" cf_man2html=$withval else cf_man2html=$cf_man2html fi; cf_with_groff=no case $cf_man2html in (yes) echo "$as_me:7066: result: man2html" >&5 echo "${ECHO_T}man2html" >&6 # Extract the first word of "man2html", so it can be a program name with args. set dummy man2html; ac_word=$2 echo "$as_me:7070: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_path_cf_man2html+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $cf_man2html in [\\/]* | ?:[\\/]*) ac_cv_path_cf_man2html="$cf_man2html" # Let the user override the test with a path. ;; *) ac_save_IFS=$IFS; IFS=$ac_path_separator ac_dummy="$PATH" for ac_dir in $ac_dummy; do IFS=$ac_save_IFS test -z "$ac_dir" && ac_dir=. if $as_executable_p "$ac_dir/$ac_word"; then ac_cv_path_cf_man2html="$ac_dir/$ac_word" echo "$as_me:7087: found $ac_dir/$ac_word" >&5 break fi done test -z "$ac_cv_path_cf_man2html" && ac_cv_path_cf_man2html="no" ;; esac fi cf_man2html=$ac_cv_path_cf_man2html if test -n "$cf_man2html"; then echo "$as_me:7099: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 else echo "$as_me:7102: result: no" >&5 echo "${ECHO_T}no" >&6 fi ;; (no|groff|*/groff*) cf_with_groff=yes cf_man2html=$GROFF_PATH echo "$as_me:7110: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; (*) echo "$as_me:7114: result: $cf_man2html" >&5 echo "${ECHO_T}$cf_man2html" >&6 ;; esac MAN2HTML_TEMP="man2html.tmp" cat >$MAN2HTML_TEMP <>$MAN2HTML_TEMP <&5 echo $ECHO_N "checking if nroff is really groff... $ECHO_C" >&6 cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`" test -n "$cf_check_groff" && cf_check_groff=yes test -n "$cf_check_groff" || cf_check_groff=no echo "$as_me:7160: result: $cf_check_groff" >&5 echo "${ECHO_T}$cf_check_groff" >&6 test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0" fi MAN2HTML_NOTE="" if test "x$prefix" != xNONE; then cf_path_syntax="$prefix" else cf_path_syntax="$ac_default_prefix" fi case ".$cf_man2html" in (.\$\(*\)*|.\'*\'*) ;; (..|./*|.\\*) ;; (.[a-zA-Z]:[\\/]*) # OS/2 EMX ;; (.\$\{*prefix\}*|.\$\{*dir\}*) eval cf_man2html="$cf_man2html" case ".$cf_man2html" in (.NONE/*) cf_man2html=`echo "$cf_man2html" | sed -e s%NONE%$cf_path_syntax%` ;; esac ;; (.no|.NONE/*) cf_man2html=`echo "$cf_man2html" | sed -e s%NONE%$cf_path_syntax%` ;; (*) { { echo "$as_me:7191: error: expected a pathname, not \"$cf_man2html\"" >&5 echo "$as_me: error: expected a pathname, not \"$cf_man2html\"" >&2;} { (exit 1); exit 1; }; } ;; esac MAN2HTML_PATH="$cf_man2html" echo "$as_me:7198: checking for $cf_man2html top/bottom margins" >&5 echo $ECHO_N "checking for $cf_man2html top/bottom margins... $ECHO_C" >&6 # for this example, expect 3 lines of content, the remainder is head/foot cat >conftest.in <conftest.out cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[^0-9]*://' -e 's/:.*//'`" cf_man2html_top=`expr "$cf_man2html_1st" - 2` cf_man2html_bot="`wc -l conftest.out |sed -e 's/[^0-9]//g'`" cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"` cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot" echo "$as_me:7216: result: $cf_man2html_top_bot" >&5 echo "${ECHO_T}$cf_man2html_top_bot" >&6 echo "$as_me:7219: checking for pagesize to use" >&5 echo $ECHO_N "checking for pagesize to use... $ECHO_C" >&6 for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do cat >>conftest.in <conftest.out cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[^0-9]*://' -e 's/:.*//'`" test -z "$cf_man2html_page" && cf_man2html_page=99999 test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999 rm -rf conftest* echo "$as_me:7244: result: $cf_man2html_page" >&5 echo "${ECHO_T}$cf_man2html_page" >&6 cat >>$MAN2HTML_TEMP <&5 echo $ECHO_N "checking if you want to use mawk's own regular-expressions engine... $ECHO_C" >&6 # Check whether --with-builtin-regex or --without-builtin-regex was given. if test "${with_builtin_regex+set}" = set; then withval="$with_builtin_regex" with_builtin_regex=$withval fi; if test "x${with_builtin_regex}" != xno; then with_builtin_regex=yes cat >>confdefs.h <<\EOF #define LOCAL_REGEXP 1 EOF fi echo "$as_me:7282: result: $with_builtin_regex" >&5 echo "${ECHO_T}$with_builtin_regex" >&6 if test "x${with_builtin_regex}" = xno; then cf_regex_func=no cf_regex_libs= case "$host_os" in (mingw*) # -lsystre -ltre -lintl -liconv echo "$as_me:7292: checking for regcomp in -lsystre" >&5 echo $ECHO_N "checking for regcomp in -lsystre... $ECHO_C" >&6 if test "${ac_cv_lib_systre_regcomp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsystre $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 7300 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char regcomp (void); int main (void) { regcomp (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7319: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7322: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7325: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7328: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_systre_regcomp=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_systre_regcomp=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:7339: result: $ac_cv_lib_systre_regcomp" >&5 echo "${ECHO_T}$ac_cv_lib_systre_regcomp" >&6 if test "$ac_cv_lib_systre_regcomp" = yes; then echo "$as_me:7343: checking for libiconv_open in -liconv" >&5 echo $ECHO_N "checking for libiconv_open in -liconv... $ECHO_C" >&6 if test "${ac_cv_lib_iconv_libiconv_open+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-liconv $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 7351 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char libiconv_open (void); int main (void) { libiconv_open (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7370: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7373: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7376: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7379: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_iconv_libiconv_open=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_iconv_libiconv_open=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:7390: result: $ac_cv_lib_iconv_libiconv_open" >&5 echo "${ECHO_T}$ac_cv_lib_iconv_libiconv_open" >&6 if test "$ac_cv_lib_iconv_libiconv_open" = yes; then cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -liconv; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" fi echo "$as_me:7412: checking for libintl_gettext in -lintl" >&5 echo $ECHO_N "checking for libintl_gettext in -lintl... $ECHO_C" >&6 if test "${ac_cv_lib_intl_libintl_gettext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 7420 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char libintl_gettext (void); int main (void) { libintl_gettext (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7439: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7442: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7445: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7448: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_intl_libintl_gettext=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_intl_libintl_gettext=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:7459: result: $ac_cv_lib_intl_libintl_gettext" >&5 echo "${ECHO_T}$ac_cv_lib_intl_libintl_gettext" >&6 if test "$ac_cv_lib_intl_libintl_gettext" = yes; then cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -lintl; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" fi echo "$as_me:7481: checking for tre_regcomp in -ltre" >&5 echo $ECHO_N "checking for tre_regcomp in -ltre... $ECHO_C" >&6 if test "${ac_cv_lib_tre_tre_regcomp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltre $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 7489 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char tre_regcomp (void); int main (void) { tre_regcomp (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7508: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7511: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7514: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7517: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_tre_tre_regcomp=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_tre_tre_regcomp=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:7528: result: $ac_cv_lib_tre_tre_regcomp" >&5 echo "${ECHO_T}$ac_cv_lib_tre_tre_regcomp" >&6 if test "$ac_cv_lib_tre_tre_regcomp" = yes; then cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -ltre; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" fi cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -lsystre; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" cf_regex_func=regcomp else echo "$as_me:7570: checking for regcomp in -lgnurx" >&5 echo $ECHO_N "checking for regcomp in -lgnurx... $ECHO_C" >&6 if test "${ac_cv_lib_gnurx_regcomp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgnurx $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 7578 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char regcomp (void); int main (void) { regcomp (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7597: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7600: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7603: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7606: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_gnurx_regcomp=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_gnurx_regcomp=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:7617: result: $ac_cv_lib_gnurx_regcomp" >&5 echo "${ECHO_T}$ac_cv_lib_gnurx_regcomp" >&6 if test "$ac_cv_lib_gnurx_regcomp" = yes; then cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -lgnurx; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" cf_regex_func=regcomp fi fi ;; (*) cf_regex_libs="regex re" echo "$as_me:7645: checking for regcomp" >&5 echo $ECHO_N "checking for regcomp... $ECHO_C" >&6 if test "${ac_cv_func_regcomp+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 7651 "configure" #include "confdefs.h" #define regcomp autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef regcomp #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char regcomp (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_regcomp) || defined (__stub___regcomp) #error found stub for regcomp #endif return regcomp (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7682: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7685: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7688: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7691: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_regcomp=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_regcomp=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:7701: result: $ac_cv_func_regcomp" >&5 echo "${ECHO_T}$ac_cv_func_regcomp" >&6 if test "$ac_cv_func_regcomp" = yes; then cf_regex_func=regcomp else for cf_regex_lib in $cf_regex_libs do as_ac_Lib=`echo "ac_cv_lib_$cf_regex_lib''_regcomp" | $as_tr_sh` echo "$as_me:7710: checking for regcomp in -l$cf_regex_lib" >&5 echo $ECHO_N "checking for regcomp in -l$cf_regex_lib... $ECHO_C" >&6 if eval "test \"\${$as_ac_Lib+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$cf_regex_lib $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 7718 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char regcomp (void); int main (void) { regcomp (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7737: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7740: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7743: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7746: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then eval "$as_ac_Lib=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_Lib=no" fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:7757: result: `eval echo '${'"$as_ac_Lib"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_Lib"'}'`" >&6 if test "`eval echo '${'"$as_ac_Lib"'}'`" = yes; then cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -l$cf_regex_lib; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" cf_regex_func=regcomp break fi done fi ;; esac if test "$cf_regex_func" = no ; then echo "$as_me:7789: checking for compile" >&5 echo $ECHO_N "checking for compile... $ECHO_C" >&6 if test "${ac_cv_func_compile+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 7795 "configure" #include "confdefs.h" #define compile autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef compile #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char compile (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_compile) || defined (__stub___compile) #error found stub for compile #endif return compile (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7826: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7829: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7832: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7835: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_compile=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_compile=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:7845: result: $ac_cv_func_compile" >&5 echo "${ECHO_T}$ac_cv_func_compile" >&6 if test "$ac_cv_func_compile" = yes; then cf_regex_func=compile else echo "$as_me:7851: checking for compile in -lgen" >&5 echo $ECHO_N "checking for compile in -lgen... $ECHO_C" >&6 if test "${ac_cv_lib_gen_compile+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgen $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 7859 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char compile (void); int main (void) { compile (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7878: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7881: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7884: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7887: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_gen_compile=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_gen_compile=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:7898: result: $ac_cv_lib_gen_compile" >&5 echo "${ECHO_T}$ac_cv_lib_gen_compile" >&6 if test "$ac_cv_lib_gen_compile" = yes; then cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -lgen; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" cf_regex_func=compile fi fi fi if test "$cf_regex_func" = no ; then { echo "$as_me:7926: WARNING: cannot find regular expression library" >&5 echo "$as_me: WARNING: cannot find regular expression library" >&2;} fi echo "$as_me:7930: checking for regular-expression headers" >&5 echo $ECHO_N "checking for regular-expression headers... $ECHO_C" >&6 if test "${cf_cv_regex_hdrs+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cf_cv_regex_hdrs=no case "$cf_regex_func" in (compile) for cf_regex_hdr in regexp.h regexpr.h do cat >"conftest.$ac_ext" <<_ACEOF #line 7942 "configure" #include "confdefs.h" #include <$cf_regex_hdr> int main (void) { char *p = compile("", "", "", 0); int x = step("", ""); (void)p; (void)x; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:7959: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:7962: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:7965: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:7968: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_regex_hdrs=$cf_regex_hdr break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" done ;; (*) for cf_regex_hdr in regex.h do cat >"conftest.$ac_ext" <<_ACEOF #line 7985 "configure" #include "confdefs.h" #include #include <$cf_regex_hdr> int main (void) { regex_t *p = 0; int x = regcomp(p, "", 0); int y = regexec(p, "", 0, 0, 0); (void)x; (void)y; regfree(p); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:8005: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:8008: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:8011: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8014: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_regex_hdrs=$cf_regex_hdr break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" done ;; esac fi echo "$as_me:8030: result: $cf_cv_regex_hdrs" >&5 echo "${ECHO_T}$cf_cv_regex_hdrs" >&6 case "$cf_cv_regex_hdrs" in (no) { echo "$as_me:8034: WARNING: no regular expression header found" >&5 echo "$as_me: WARNING: no regular expression header found" >&2;} ;; (regex.h) cat >>confdefs.h <<\EOF #define HAVE_REGEX_H_FUNCS 1 EOF ;; (regexp.h) cat >>confdefs.h <<\EOF #define HAVE_REGEXP_H_FUNCS 1 EOF ;; (regexpr.h) cat >>confdefs.h <<\EOF #define HAVE_REGEXPR_H_FUNCS 1 EOF ;; esac fi ############################################################################### echo "$as_me:8056: checking if you want to use mawk's own srand/rand functions" >&5 echo $ECHO_N "checking if you want to use mawk's own srand/rand functions... $ECHO_C" >&6 # Check whether --enable-builtin-srand or --disable-builtin-srand was given. if test "${enable_builtin_srand+set}" = set; then enableval="$enable_builtin_srand" test "$enableval" != yes && enableval=no if test "$enableval" != "no" ; then with_builtin_srand=yes else with_builtin_srand=no fi else enableval=no with_builtin_srand=no fi; if test "x${with_builtin_srand}" != xno; then with_builtin_srand=yes fi echo "$as_me:8076: result: $with_builtin_srand" >&5 echo "${ECHO_T}$with_builtin_srand" >&6 if test "x${with_builtin_srand}" = xno; then for ac_header in limits.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:8084: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 8090 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:8094: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:8100: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_Header=no" fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:8119: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for arc4random... $ECHO_C" >&6 if test "${ac_cv_func_arc4random+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 8135 "configure" #include "confdefs.h" #define arc4random autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef arc4random #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char arc4random (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_arc4random) || defined (__stub___arc4random) #error found stub for arc4random #endif return arc4random (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:8166: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:8169: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:8172: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8175: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_arc4random=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_arc4random=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:8185: result: $ac_cv_func_arc4random" >&5 echo "${ECHO_T}$ac_cv_func_arc4random" >&6 if test "$ac_cv_func_arc4random" = yes; then : else echo "$as_me:8190: checking for arc4random in -lbsd" >&5 echo $ECHO_N "checking for arc4random in -lbsd... $ECHO_C" >&6 if test "${ac_cv_lib_bsd_arc4random+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 8198 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char arc4random (void); int main (void) { arc4random (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:8217: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:8220: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:8223: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8226: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_bsd_arc4random=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_bsd_arc4random=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:8237: result: $ac_cv_lib_bsd_arc4random" >&5 echo "${ECHO_T}$ac_cv_lib_bsd_arc4random" >&6 if test "$ac_cv_lib_bsd_arc4random" = yes; then cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -lbsd; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" fi fi echo "$as_me:8261: checking for random-integer functions" >&5 echo $ECHO_N "checking for random-integer functions... $ECHO_C" >&6 if test "${cf_cv_srand_func+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cf_cv_srand_func=unknown for cf_func in arc4random_stir/arc4random srandom/random srand48/lrand48 srand/rand do cf_srand_func=`echo $cf_func | sed -e 's%/.*%%'` cf_rand_func=`echo $cf_func | sed -e 's%.*/%%'` case $cf_srand_func in (arc4random_stir) cf_srand_func='(void)' ;; esac cat >"conftest.$ac_ext" <<_ACEOF #line 8281 "configure" #include "confdefs.h" $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif int main (void) { long seed = 1; $cf_srand_func(seed); seed = $cf_rand_func(); (void)seed ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:8298: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:8301: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:8304: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8307: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_srand_func=$cf_func break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" done fi echo "$as_me:8319: result: $cf_cv_srand_func" >&5 echo "${ECHO_T}$cf_cv_srand_func" >&6 if test "$cf_cv_srand_func" != unknown ; then echo "$as_me:8322: checking for range of random-integers" >&5 echo $ECHO_N "checking for range of random-integers... $ECHO_C" >&6 if test "${cf_cv_rand_max+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case "$cf_cv_srand_func" in (srand/rand) cf_cv_rand_max=RAND_MAX cf_rand_max=16 ;; (*/arc4random) cf_cv_rand_max=0xFFFFFFFFUL cf_rand_max=32 ;; (*) cf_cv_rand_max=INT_MAX cf_rand_max=31 ;; esac cat >"conftest.$ac_ext" <<_ACEOF #line 8343 "configure" #include "confdefs.h" $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif int main (void) { long x = $cf_cv_rand_max; (void)x ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:8360: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:8363: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:8366: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8369: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_rand_max="(1UL<<$cf_rand_max)-1" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:8380: result: $cf_cv_rand_max" >&5 echo "${ECHO_T}$cf_cv_rand_max" >&6 case "$cf_cv_srand_func" in (*/arc4random) echo "$as_me:8385: checking if should be included" >&5 echo $ECHO_N "checking if should be included... $ECHO_C" >&6 cat >"conftest.$ac_ext" <<_ACEOF #line 8388 "configure" #include "confdefs.h" $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif #include int main (void) { void *arc4random(int); void *x = arc4random(1); (void)x ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:8406: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:8409: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:8412: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8415: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_bsd_stdlib_h=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cat >"conftest.$ac_ext" <<_ACEOF #line 8422 "configure" #include "confdefs.h" $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif #include int main (void) { unsigned long x = arc4random(); (void)x ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:8439: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:8442: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:8445: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8448: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_bsd_stdlib_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_bsd_stdlib_h=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" echo "$as_me:8459: result: $cf_bsd_stdlib_h" >&5 echo "${ECHO_T}$cf_bsd_stdlib_h" >&6 if test "$cf_bsd_stdlib_h" = yes then cat >>confdefs.h <<\EOF #define HAVE_BSD_STDLIB_H 1 EOF else echo "$as_me:8469: checking if should be included" >&5 echo $ECHO_N "checking if should be included... $ECHO_C" >&6 cat >"conftest.$ac_ext" <<_ACEOF #line 8472 "configure" #include "confdefs.h" $ac_includes_default #ifdef HAVE_LIMITS_H #include #endif #include int main (void) { void *arc4random(int); void *x = arc4random(1); (void)x ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:8490: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:8493: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:8496: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8499: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_bsd_random_h=no else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cat >"conftest.$ac_ext" <<_ACEOF #line 8506 "configure" #include "confdefs.h" #include int main (void) { unsigned long x = arc4random(); (void)x ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:8518: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:8521: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:8524: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8527: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_bsd_random_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_bsd_random_h=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" echo "$as_me:8538: result: $cf_bsd_random_h" >&5 echo "${ECHO_T}$cf_bsd_random_h" >&6 if test "$cf_bsd_random_h" = yes then cat >>confdefs.h <<\EOF #define HAVE_BSD_RANDOM_H 1 EOF else { echo "$as_me:8548: WARNING: no header file found for arc4random" >&5 echo "$as_me: WARNING: no header file found for arc4random" >&2;} fi fi ;; esac cf_srand_func=`echo $cf_func | sed -e 's%/.*%%'` cf_rand_func=`echo $cf_func | sed -e 's%.*/%%'` case $cf_srand_func in (arc4random_stir) cf_srand_func='(void)' ;; esac cf_rand_max=`echo "mawk_rand_max" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` cat >>confdefs.h <>confdefs.h <>confdefs.h <>confdefs.h <&5 echo $ECHO_N "checking if you want mawk to initialize random numbers at startup... $ECHO_C" >&6 # Check whether --enable-init-srand or --disable-init-srand was given. if test "${enable_init_srand+set}" = set; then enableval="$enable_init_srand" test "$enableval" != no && enableval=yes if test "$enableval" != "yes" ; then with_init_srand=no else with_init_srand=yes fi else enableval=yes with_init_srand=yes fi; if test "x${with_init_srand}" != xno; then with_init_srand=yes else cat >>confdefs.h <<\EOF #define NO_INIT_SRAND 1 EOF fi echo "$as_me:8613: result: $with_init_srand" >&5 echo "${ECHO_T}$with_init_srand" >&6 ############################################################################### echo "$as_me:8617: checking if you want mawk to support regex interval expressions {m,n}" >&5 echo $ECHO_N "checking if you want mawk to support regex interval expressions {m,n}... $ECHO_C" >&6 # Check whether --enable-interval-expr or --disable-interval-expr was given. if test "${enable_interval_expr+set}" = set; then enableval="$enable_interval_expr" test "$enableval" != no && enableval=yes if test "$enableval" != "yes" ; then with_interval_expr=no else with_interval_expr=yes fi else enableval=yes with_interval_expr=yes fi; if test "x${with_interval_expr}" != xno; then with_interval_expr=yes else cat >>confdefs.h <<\EOF #define NO_INTERVAL_EXPR 1 EOF fi echo "$as_me:8643: result: $with_interval_expr" >&5 echo "${ECHO_T}$with_interval_expr" >&6 ############################################################################### echo "$as_me:8648: checking if you want to use dmalloc for testing" >&5 echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6 # Check whether --with-dmalloc or --without-dmalloc was given. if test "${with_dmalloc+set}" = set; then withval="$with_dmalloc" case "x$withval" in (x|xno) ;; (*) : "${with_cflags:=-g}" : "${enable_leaks:=no}" with_dmalloc=yes cat >>confdefs.h <&5 echo "${ECHO_T}${with_dmalloc:-no}" >&6 case ".$with_cflags" in (.*-g*) case .$CFLAGS in (.*-g*) ;; (*) cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in -g do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi ;; esac ;; esac if test "$with_dmalloc" = yes ; then echo "$as_me:8784: checking for dmalloc.h" >&5 echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 8790 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:8794: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:8800: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_dmalloc_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_dmalloc_h=no fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:8819: result: $ac_cv_header_dmalloc_h" >&5 echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6 if test "$ac_cv_header_dmalloc_h" = yes; then echo "$as_me:8823: checking for dmalloc_debug in -ldmalloc" >&5 echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6 if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldmalloc $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 8831 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dmalloc_debug (void); int main (void) { dmalloc_debug (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:8850: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:8853: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:8856: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:8859: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_dmalloc_dmalloc_debug=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_dmalloc_dmalloc_debug=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:8870: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6 if test "$ac_cv_lib_dmalloc_dmalloc_debug" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6 # Check whether --with-dbmalloc or --without-dbmalloc was given. if test "${with_dbmalloc+set}" = set; then withval="$with_dbmalloc" case "x$withval" in (x|xno) ;; (*) : "${with_cflags:=-g}" : "${enable_leaks:=no}" with_dbmalloc=yes cat >>confdefs.h <&5 echo "${ECHO_T}${with_dbmalloc:-no}" >&6 case ".$with_cflags" in (.*-g*) case .$CFLAGS in (.*-g*) ;; (*) cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in -g do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi ;; esac ;; esac if test "$with_dbmalloc" = yes ; then echo "$as_me:9021: checking for dbmalloc.h" >&5 echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6 if test "${ac_cv_header_dbmalloc_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9027 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:9031: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:9037: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_dbmalloc_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_dbmalloc_h=no fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:9056: result: $ac_cv_header_dbmalloc_h" >&5 echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6 if test "$ac_cv_header_dbmalloc_h" = yes; then echo "$as_me:9060: checking for debug_malloc in -ldbmalloc" >&5 echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6 if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldbmalloc $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 9068 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char debug_malloc (void); int main (void) { debug_malloc (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:9087: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:9090: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:9093: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9096: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_dbmalloc_debug_malloc=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_dbmalloc_debug_malloc=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:9107: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5 echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6 if test "$ac_cv_lib_dbmalloc_debug_malloc" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6 # Check whether --with-valgrind or --without-valgrind was given. if test "${with_valgrind+set}" = set; then withval="$with_valgrind" case "x$withval" in (x|xno) ;; (*) : "${with_cflags:=-g}" : "${enable_leaks:=no}" with_valgrind=yes cat >>confdefs.h <&5 echo "${ECHO_T}${with_valgrind:-no}" >&6 case ".$with_cflags" in (.*-g*) case .$CFLAGS in (.*-g*) ;; (*) cf_fix_cppflags=no cf_new_cflags= cf_new_cppflags= cf_new_extra_cppflags= for cf_add_cflags in -g do case "$cf_fix_cppflags" in (no) case "$cf_add_cflags" in (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) case "$cf_add_cflags" in (-D*) cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[^=]*='\''\"[^"]*//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=yes if test "$cf_fix_cppflags" = yes ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue elif test "${cf_tst_cflags}" = "\"'" ; then test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" continue fi ;; esac case "$CPPFLAGS" in (*$cf_add_cflags) ;; (*) case "$cf_add_cflags" in (-D*) cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` CPPFLAGS=`echo "$CPPFLAGS" | \ sed -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?[ ]/ /g' \ -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ ]*\)\?$//g'` ;; esac test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags " cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags" ;; esac ;; (*) test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags " cf_new_cflags="${cf_new_cflags}$cf_add_cflags" ;; esac ;; (yes) test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags " cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags" cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[^"]*"'\''//'` test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \ && test -z "${cf_tst_cflags}" \ && cf_fix_cppflags=no ;; esac done if test -n "$cf_new_cflags" ; then test -n "$CFLAGS" && CFLAGS="$CFLAGS " CFLAGS="${CFLAGS}$cf_new_cflags" fi if test -n "$cf_new_cppflags" ; then test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS " CPPFLAGS="${CPPFLAGS}$cf_new_cppflags" fi if test -n "$cf_new_extra_cppflags" ; then test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS " EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags" fi ;; esac ;; esac echo "$as_me:9257: checking if you want to perform memory-leak testing" >&5 echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6 # Check whether --enable-leaks or --disable-leaks was given. if test "${enable_leaks+set}" = set; then enableval="$enable_leaks" enable_leaks=$enableval else enable_leaks=yes fi; if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi echo "$as_me:9268: result: $with_no_leaks" >&5 echo "${ECHO_T}$with_no_leaks" >&6 if test "$enable_leaks" = no ; then cat >>confdefs.h <<\EOF #define NO_LEAKS 1 EOF cat >>confdefs.h <<\EOF #define YY_NO_LEAKS 1 EOF fi echo "$as_me:9283: checking if you want to enable debugging trace" >&5 echo $ECHO_N "checking if you want to enable debugging trace... $ECHO_C" >&6 # Check whether --enable-trace or --disable-trace was given. if test "${enable_trace+set}" = set; then enableval="$enable_trace" test "$enableval" != yes && enableval=no if test "$enableval" != "no" ; then with_trace=yes else with_trace=no fi else enableval=no with_trace=no fi; echo "$as_me:9300: result: $with_trace" >&5 echo "${ECHO_T}$with_trace" >&6 if test "$with_trace" = "yes" then cat >>confdefs.h <<\EOF #define OPT_TRACE 1 EOF fi if test "x$with_trace" = xyes then EXTRAOBJS="$EXTRAOBJS trace\$o" fi for ac_header in errno.h fcntl.h sys/wait.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:9319: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9325 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:9329: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:9335: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_Header=no" fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:9354: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for int64_t... $ECHO_C" >&6 if test "${ac_cv_type_int64_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9370 "configure" #include "confdefs.h" $ac_includes_default int main (void) { if ((int64_t *) 0) return 0; if (sizeof (int64_t)) return 0; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9385: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9388: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9391: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9394: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_int64_t=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_type_int64_t=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:9404: result: $ac_cv_type_int64_t" >&5 echo "${ECHO_T}$ac_cv_type_int64_t" >&6 if test "$ac_cv_type_int64_t" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6 if test "${ac_cv_type_uint64_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9419 "configure" #include "confdefs.h" $ac_includes_default int main (void) { if ((uint64_t *) 0) return 0; if (sizeof (uint64_t)) return 0; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9434: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9437: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9440: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9443: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_uint64_t=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_type_uint64_t=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:9453: result: $ac_cv_type_uint64_t" >&5 echo "${ECHO_T}$ac_cv_type_uint64_t" >&6 if test "$ac_cv_type_uint64_t" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for long long... $ECHO_C" >&6 if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9468 "configure" #include "confdefs.h" $ac_includes_default int main (void) { if ((long long *) 0) return 0; if (sizeof (long long)) return 0; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9483: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9486: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9489: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9492: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_long_long=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_type_long_long=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:9502: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6 if test "$ac_cv_type_long_long" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for long... $ECHO_C" >&6 if test "${ac_cv_type_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9518 "configure" #include "confdefs.h" $ac_includes_default int main (void) { if ((long *) 0) return 0; if (sizeof (long)) return 0; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9533: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9536: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9539: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9542: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_long=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_type_long=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:9552: result: $ac_cv_type_long" >&5 echo "${ECHO_T}$ac_cv_type_long" >&6 echo "$as_me:9555: checking size of long" >&5 echo $ECHO_N "checking size of long... $ECHO_C" >&6 if test "${ac_cv_sizeof_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_type_long" = yes; then if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >"conftest.$ac_ext" <<_ACEOF #line 9564 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long)) >= 0)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9576: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9579: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9582: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9585: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_lo=0 ac_mid=0 while :; do cat >"conftest.$ac_ext" <<_ACEOF #line 9590 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long)) <= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9602: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9605: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9608: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9611: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_lo=`expr "$ac_mid" + 1`; ac_mid=`expr 2 '*' "$ac_mid" + 1` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_hi=-1 ac_mid=-1 while :; do cat >"conftest.$ac_ext" <<_ACEOF #line 9627 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long)) >= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9639: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9642: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9645: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9648: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_hi=`expr "$ac_mid" - 1`; ac_mid=`expr 2 '*' "$ac_mid"` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' "$ac_hi" - "$ac_lo" ')' / 2 + "$ac_lo"` cat >"conftest.$ac_ext" <<_ACEOF #line 9664 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long)) <= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9676: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9679: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9682: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9685: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_lo=`expr "$ac_mid" + 1` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done ac_cv_sizeof_long=$ac_lo else if test "$cross_compiling" = yes; then { { echo "$as_me:9698: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >"conftest.$ac_ext" <<_ACEOF #line 9703 "configure" #include "confdefs.h" $ac_includes_default int main (void) { FILE *f = fopen ("conftest.val", "w"); if (!f) $ac_main_return (1); fprintf (f, "%ld", (long)(sizeof (long))); fclose (f); ; return 0; } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:9719: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:9722: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:9724: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9727: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_sizeof_long=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi fi rm -f conftest.val else ac_cv_sizeof_long=0 fi fi echo "$as_me:9743: result: $ac_cv_sizeof_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long" >&6 cat >>confdefs.h <&5 echo $ECHO_N "checking for int64_t... $ECHO_C" >&6 if test "${ac_cv_type_int64_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9755 "configure" #include "confdefs.h" $ac_includes_default int main (void) { if ((int64_t *) 0) return 0; if (sizeof (int64_t)) return 0; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9770: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9773: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9776: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9779: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_int64_t=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_type_int64_t=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:9789: result: $ac_cv_type_int64_t" >&5 echo "${ECHO_T}$ac_cv_type_int64_t" >&6 echo "$as_me:9792: checking size of int64_t" >&5 echo $ECHO_N "checking size of int64_t... $ECHO_C" >&6 if test "${ac_cv_sizeof_int64_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_type_int64_t" = yes; then if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >"conftest.$ac_ext" <<_ACEOF #line 9801 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (int64_t)) >= 0)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9813: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9816: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9819: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9822: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_lo=0 ac_mid=0 while :; do cat >"conftest.$ac_ext" <<_ACEOF #line 9827 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (int64_t)) <= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9839: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9842: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9845: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9848: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_lo=`expr "$ac_mid" + 1`; ac_mid=`expr 2 '*' "$ac_mid" + 1` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_hi=-1 ac_mid=-1 while :; do cat >"conftest.$ac_ext" <<_ACEOF #line 9864 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (int64_t)) >= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9876: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9879: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9882: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9885: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_hi=`expr "$ac_mid" - 1`; ac_mid=`expr 2 '*' "$ac_mid"` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' "$ac_hi" - "$ac_lo" ')' / 2 + "$ac_lo"` cat >"conftest.$ac_ext" <<_ACEOF #line 9901 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (int64_t)) <= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:9913: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:9916: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:9919: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9922: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_lo=`expr "$ac_mid" + 1` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done ac_cv_sizeof_int64_t=$ac_lo else if test "$cross_compiling" = yes; then { { echo "$as_me:9935: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >"conftest.$ac_ext" <<_ACEOF #line 9940 "configure" #include "confdefs.h" $ac_includes_default int main (void) { FILE *f = fopen ("conftest.val", "w"); if (!f) $ac_main_return (1); fprintf (f, "%ld", (long)(sizeof (int64_t))); fclose (f); ; return 0; } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:9956: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:9959: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:9961: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:9964: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_sizeof_int64_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi fi rm -f conftest.val else ac_cv_sizeof_int64_t=0 fi fi echo "$as_me:9980: result: $ac_cv_sizeof_int64_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_int64_t" >&6 cat >>confdefs.h <&5 echo $ECHO_N "checking for long long... $ECHO_C" >&6 if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 9992 "configure" #include "confdefs.h" $ac_includes_default int main (void) { if ((long long *) 0) return 0; if (sizeof (long long)) return 0; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10007: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10010: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10013: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10016: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_long_long=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_type_long_long=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:10026: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6 echo "$as_me:10029: checking size of long long" >&5 echo $ECHO_N "checking size of long long... $ECHO_C" >&6 if test "${ac_cv_sizeof_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_type_long_long" = yes; then if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >"conftest.$ac_ext" <<_ACEOF #line 10038 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long long)) >= 0)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10050: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10053: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10056: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10059: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_lo=0 ac_mid=0 while :; do cat >"conftest.$ac_ext" <<_ACEOF #line 10064 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long long)) <= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10076: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10079: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10082: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10085: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_lo=`expr "$ac_mid" + 1`; ac_mid=`expr 2 '*' "$ac_mid" + 1` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_hi=-1 ac_mid=-1 while :; do cat >"conftest.$ac_ext" <<_ACEOF #line 10101 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long long)) >= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10113: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10116: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10119: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10122: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_hi=`expr "$ac_mid" - 1`; ac_mid=`expr 2 '*' "$ac_mid"` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' "$ac_hi" - "$ac_lo" ')' / 2 + "$ac_lo"` cat >"conftest.$ac_ext" <<_ACEOF #line 10138 "configure" #include "confdefs.h" $ac_includes_default int main (void) { int _array_ [1 - 2 * !((sizeof (long long)) <= $ac_mid)] ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10150: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10153: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10156: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10159: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_lo=`expr "$ac_mid" + 1` fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" done ac_cv_sizeof_long_long=$ac_lo else if test "$cross_compiling" = yes; then { { echo "$as_me:10172: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >"conftest.$ac_ext" <<_ACEOF #line 10177 "configure" #include "confdefs.h" $ac_includes_default int main (void) { FILE *f = fopen ("conftest.val", "w"); if (!f) $ac_main_return (1); fprintf (f, "%ld", (long)(sizeof (long long))); fclose (f); ; return 0; } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:10193: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10196: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:10198: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10201: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_sizeof_long_long=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi fi rm -f conftest.val else ac_cv_sizeof_long_long=0 fi fi echo "$as_me:10217: result: $ac_cv_sizeof_long_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 cat >>confdefs.h <&6 else echo "$as_me:10229: checking for stddef.h" >&5 echo $ECHO_N "checking for stddef.h... $ECHO_C" >&6 if test "${ac_cv_header_stddef_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10235 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:10239: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:10245: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_stddef_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_stddef_h=no fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:10264: result: $ac_cv_header_stddef_h" >&5 echo "${ECHO_T}$ac_cv_header_stddef_h" >&6 if test "$ac_cv_header_stddef_h" = yes; then cf_mawk_check_size=ok fi if test "x$cf_mawk_check_size" = xok ; then echo "$as_me:10271: checking if size_t is declared in stddef.h" >&5 echo $ECHO_N "checking if size_t is declared in stddef.h... $ECHO_C" >&6 if test "${cf_cv_size_t_SIZE_T_STDDEF_H+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10278 "configure" #include "confdefs.h" #include int main (void) { size_t *n ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10290: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10293: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10296: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10299: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_size_t_SIZE_T_STDDEF_H=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_size_t_SIZE_T_STDDEF_H=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:10309: result: $cf_cv_size_t_SIZE_T_STDDEF_H" >&5 echo "${ECHO_T}$cf_cv_size_t_SIZE_T_STDDEF_H" >&6 fi fi if test "x$cf_cv_size_t_SIZE_T_STDDEF_H" = xyes ; then cat >>confdefs.h <&6 else echo "$as_me:10331: checking for sys/types.h" >&5 echo $ECHO_N "checking for sys/types.h... $ECHO_C" >&6 if test "${ac_cv_header_sys_types_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10337 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:10341: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:10347: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_sys_types_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_sys_types_h=no fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:10366: result: $ac_cv_header_sys_types_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_types_h" >&6 if test "$ac_cv_header_sys_types_h" = yes; then cf_mawk_check_size=ok fi if test "x$cf_mawk_check_size" = xok ; then echo "$as_me:10373: checking if size_t is declared in sys/types.h" >&5 echo $ECHO_N "checking if size_t is declared in sys/types.h... $ECHO_C" >&6 if test "${cf_cv_size_t_SIZE_T_TYPES_H+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10380 "configure" #include "confdefs.h" #include int main (void) { size_t *n ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10392: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10395: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10398: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10401: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_size_t_SIZE_T_TYPES_H=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_size_t_SIZE_T_TYPES_H=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:10411: result: $cf_cv_size_t_SIZE_T_TYPES_H" >&5 echo "${ECHO_T}$cf_cv_size_t_SIZE_T_TYPES_H" >&6 fi fi if test "x$cf_cv_size_t_SIZE_T_TYPES_H" = xyes ; then cat >>confdefs.h <&5 echo $ECHO_N "checking for setlocale()... $ECHO_C" >&6 if test "${cf_cv_locale+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10434 "configure" #include "confdefs.h" $ac_includes_default #include int main (void) { setlocale(LC_ALL, "") ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10448: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10451: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10454: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10457: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_locale=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_locale=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:10469: result: $cf_cv_locale" >&5 echo "${ECHO_T}$cf_cv_locale" >&6 test "$cf_cv_locale" = yes && { cat >>confdefs.h <<\EOF #define LOCALE 1 EOF } echo "$as_me:10477: checking if external environ is declared" >&5 echo $ECHO_N "checking if external environ is declared... $ECHO_C" >&6 if test "${cf_cv_dcl_environ+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10484 "configure" #include "confdefs.h" $ac_includes_default int main (void) { void* x = (void*) environ; (void)x ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:10497: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:10500: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:10503: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10506: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_dcl_environ=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_dcl_environ=no fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:10517: result: $cf_cv_dcl_environ" >&5 echo "${ECHO_T}$cf_cv_dcl_environ" >&6 if test "$cf_cv_dcl_environ" = no ; then cf_result=`echo "decl_environ" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` cat >>confdefs.h <&5 echo $ECHO_N "checking if external environ exists... $ECHO_C" >&6 if test "${cf_cv_have_environ+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10539 "configure" #include "confdefs.h" #undef environ extern int environ; int main (void) { environ = 2 ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10554: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10557: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10560: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10563: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_have_environ=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_have_environ=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:10574: result: $cf_cv_have_environ" >&5 echo "${ECHO_T}$cf_cv_have_environ" >&6 if test "$cf_cv_have_environ" = yes ; then cf_result=`echo "have_environ" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` cat >>confdefs.h <&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10596 "configure" #include "confdefs.h" #define $ac_func autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef $ac_func #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) #error found stub for $ac_func #endif return $ac_func (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10627: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10630: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10633: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10636: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_var=no" fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:10646: result: `eval echo '${'"$as_ac_var"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for clock_gettime... $ECHO_C" >&6 if test "${cf_cv_func_clock_gettime+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10663 "configure" #include "confdefs.h" #include int main (void) { struct timespec ts; int rc = clock_gettime(CLOCK_REALTIME, &ts); (void) rc; (void)ts ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10676: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10679: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10682: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10685: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_func_clock_gettime=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_func_clock_gettime=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:10696: result: $cf_cv_func_clock_gettime" >&5 echo "${ECHO_T}$cf_cv_func_clock_gettime" >&6 if test "$cf_cv_func_clock_gettime" = yes then cat >>confdefs.h <<\EOF #define HAVE_CLOCK_GETTIME 1 EOF else echo "$as_me:10707: checking for gettimeofday" >&5 echo $ECHO_N "checking for gettimeofday... $ECHO_C" >&6 if test "${ac_cv_func_gettimeofday+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10713 "configure" #include "confdefs.h" #define gettimeofday autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef gettimeofday #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gettimeofday (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gettimeofday) || defined (__stub___gettimeofday) #error found stub for gettimeofday #endif return gettimeofday (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10744: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10747: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10750: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10753: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_gettimeofday=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_gettimeofday=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:10763: result: $ac_cv_func_gettimeofday" >&5 echo "${ECHO_T}$ac_cv_func_gettimeofday" >&6 if test "$ac_cv_func_gettimeofday" = yes; then cat >>confdefs.h <<\EOF #define HAVE_GETTIMEOFDAY 1 EOF else echo "$as_me:10773: checking for gettimeofday in -lbsd" >&5 echo $ECHO_N "checking for gettimeofday in -lbsd... $ECHO_C" >&6 if test "${ac_cv_lib_bsd_gettimeofday+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" cat >"conftest.$ac_ext" <<_ACEOF #line 10781 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gettimeofday (void); int main (void) { gettimeofday (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10800: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10803: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10806: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10809: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_lib_bsd_gettimeofday=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_lib_bsd_gettimeofday=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:10820: result: $ac_cv_lib_bsd_gettimeofday" >&5 echo "${ECHO_T}$ac_cv_lib_bsd_gettimeofday" >&6 if test "$ac_cv_lib_bsd_gettimeofday" = yes; then cat >>confdefs.h <<\EOF #define HAVE_GETTIMEOFDAY 1 EOF cf_add_libs="$LIBS" # reverse order cf_add_0lib= for cf_add_1lib in -lbsd; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done # filter duplicates for cf_add_1lib in $cf_add_0lib; do for cf_add_2lib in $cf_add_libs; do if test "x$cf_add_1lib" = "x$cf_add_2lib"; then cf_add_1lib= break fi done test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs" done LIBS="$cf_add_libs" fi fi fi ### Checks for libraries. case $cf_cv_system_name in (*mingw32*) CPPFLAGS="$CPPFLAGS -DWINVER=0x0501" # LIBS=" -lpsapi $LIBS" ;; esac test "$ac_cv_func_fork" = yes && \ test "$ac_cv_func_pipe" = yes && \ test "$ac_cv_func_wait" = yes && \ cat >>confdefs.h <<\EOF #define HAVE_REAL_PIPES 1 EOF echo "$as_me:10865: checking if math.h declares _LIB_VERSION" >&5 echo $ECHO_N "checking if math.h declares _LIB_VERSION... $ECHO_C" >&6 if test "${cf_cv_get_math_lib_version+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10872 "configure" #include "confdefs.h" #include int main (void) { int foo = _LIB_VERSION ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10885: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10888: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10891: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10894: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_get_math_lib_version=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_get_math_lib_version=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:10905: result: $cf_cv_get_math_lib_version" >&5 echo "${ECHO_T}$cf_cv_get_math_lib_version" >&6 if test "x$cf_cv_get_math_lib_version" = xyes then echo "$as_me:10910: checking if we can update _LIB_VERSION" >&5 echo $ECHO_N "checking if we can update _LIB_VERSION... $ECHO_C" >&6 if test "${cf_cv_set_math_lib_version+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10917 "configure" #include "confdefs.h" #include int main (void) { _LIB_VERSION = _IEEE_ ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:10930: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:10933: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:10936: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:10939: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_set_math_lib_version=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 cf_cv_set_math_lib_version=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:10950: result: $cf_cv_set_math_lib_version" >&5 echo "${ECHO_T}$cf_cv_set_math_lib_version" >&6 if test "x$cf_cv_set_math_lib_version" = xyes then cat >>confdefs.h <<\EOF #define HAVE_MATH__LIB_VERSION 1 EOF else { echo "$as_me:10960: WARNING: this is probably due to a defect in your system headers" >&5 echo "$as_me: WARNING: this is probably due to a defect in your system headers" >&2;} fi fi echo "$as_me:10965: checking for limits.h" >&5 echo $ECHO_N "checking for limits.h... $ECHO_C" >&6 if test "${ac_cv_header_limits_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 10971 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:10975: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:10981: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_limits_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_limits_h=no fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:11000: result: $ac_cv_header_limits_h" >&5 echo "${ECHO_T}$ac_cv_header_limits_h" >&6 if test "$ac_cv_header_limits_h" = yes; then cf_limits_h=yes fi if test "x$cf_limits_h" = xyes ; then : else echo "$as_me:11008: checking for values.h" >&5 echo $ECHO_N "checking for values.h... $ECHO_C" >&6 if test "${ac_cv_header_values_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11014 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:11018: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:11024: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_values_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_values_h=no fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:11043: result: $ac_cv_header_values_h" >&5 echo "${ECHO_T}$ac_cv_header_values_h" >&6 if test "$ac_cv_header_values_h" = yes; then cf_values_h=yes fi if test "x$cf_values_h" = xyes ; then if test "$cross_compiling" = yes; then { { echo "$as_me:11051: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >"conftest.$ac_ext" <<_ACEOF #line 11056 "configure" #include "confdefs.h" $ac_includes_default #include int main(void) { FILE *out = fopen("conftest.out", "w") ; unsigned max_uint = 0; unsigned long max_ulong = 0; if ( ! out ) exit(1) ; fprintf(out, "MAX__INT 0x%x\n", MAXINT) ; fprintf(out, "MAX__LONG 0x%lx\n", MAXLONG) ; #ifdef MAXUINT max_uint = MAXUINT; /* not likely (SunOS/Solaris lacks it) */ #else max_uint = MAXINT; max_uint <<= 1; max_uint |= 1; #endif fprintf(out, "MAX__UINT 0x%lx\n", max_uint) ; #ifdef MAXULONG max_ulong = MAXULONG; #else max_ulong = MAXLONG; max_ulong <<= 1; max_ulong |= 1; #endif fprintf(out, "MAX__ULONG 0x%lx\n", max_ulong) ; ${cf_cv_main_return:-return}(0); } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:11090: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11093: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:11095: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11098: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_maxint_set=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 { { echo "$as_me:11105: error: C program to compute maxint and maxlong failed. Please send bug report to dickey@invisible-island.net." >&5 echo "$as_me: error: C program to compute maxint and maxlong failed. Please send bug report to dickey@invisible-island.net." >&2;} { (exit 1); exit 1; }; } fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi fi if test "x$cf_maxint_set" != xyes ; then # compute it -- assumes two's complement if test "$cross_compiling" = yes; then { { echo "$as_me:11117: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >"conftest.$ac_ext" <<_ACEOF #line 11122 "configure" #include "confdefs.h" #include #include int main(void) { static int y ; static unsigned yu; static long yy ; static unsigned long yyu ; FILE *out ; if ( !(out = fopen("conftest.out","w")) ) exit(1) ; /* find max int and max long */ y = 0x1000 ; while ( y > 0 ) { yu = y; y *= 2 ; } fprintf(out,"MAX__INT 0x%x\n", y-1) ; yu = yu - 1; yu <<= 1; yu |= 1; yu <<= 1; yu |= 1; fprintf(out,"MAX__UINT 0x%xU\n", yu) ; yy = 0x1000 ; while ( yy > 0 ) { yyu = yy; yy *= 2 ; } fprintf(out,"MAX__LONG 0x%lxL\n", yy-1) ; yyu = yyu - 1; yyu <<= 1; yyu |= 1; yyu <<= 1; yyu |= 1; fprintf(out,"MAX__ULONG 0x%lxUL\n", yyu) ; ${cf_cv_main_return:-return}(0); } _ACEOF rm -f "conftest$ac_exeext" if { (eval echo "$as_me:11162: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11165: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='"./conftest$ac_exeext"' { (eval echo "$as_me:11167: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11170: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 { { echo "$as_me:11177: error: C program to compute maxint and maxlong failed. Please send bug report to dickey@invisible-island.net." >&5 echo "$as_me: error: C program to compute maxint and maxlong failed. Please send bug report to dickey@invisible-island.net." >&2;} { (exit 1); exit 1; }; } fi rm -f core ./core.* ./*.core "conftest$ac_exeext" "conftest.$ac_objext" "conftest.$ac_ext" fi fi cat conftest.out | while true do read name value test -z "$name" && break cat >>confdefs.h <&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11207 "configure" #include "confdefs.h" #define $ac_func autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef $ac_func #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) #error found stub for $ac_func #endif return $ac_func (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:11238: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11241: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:11244: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11247: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_var=no" fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:11257: result: `eval echo '${'"$as_ac_var"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_var"'}'`" >&6 if test "`eval echo '${'"$as_ac_var"'}'`" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11278 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:11282: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:11288: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 eval "$as_ac_Header=no" fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:11307: result: `eval echo '${'"$as_ac_Header"'}'`" >&5 echo "${ECHO_T}`eval echo '${'"$as_ac_Header"'}'`" >&6 if test "`eval echo '${'"$as_ac_Header"'}'`" = yes; then cat >>confdefs.h <&5 echo $ECHO_N "checking if we should use siginfo... $ECHO_C" >&6 if test "${cf_cv_use_sv_siginfo+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$sigaction" = 1 && test "$siginfo_h" = 1 ; then cf_cv_use_sv_siginfo=yes else cf_cv_use_sv_siginfo=no fi fi echo "$as_me:11332: result: $cf_cv_use_sv_siginfo" >&5 echo "${ECHO_T}$cf_cv_use_sv_siginfo" >&6 echo "$as_me:11335: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11341 "configure" #include "confdefs.h" #include #include #ifdef signal # undef signal #endif extern void (*signal (int, void (*)(int)))(int); int main (void) { int i; (void) i ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:11359: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:11362: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:11365: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11368: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_type_signal=void else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_type_signal=int fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi echo "$as_me:11378: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6 cat >>confdefs.h <&5 echo $ECHO_N "checking if we should use sigaction.sa_sigaction... $ECHO_C" >&6 if test "${cf_cv_use_sa_sigaction+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cf_cv_use_sa_sigaction=no if test "$ac_cv_func_sigaction" = yes then cat >"conftest.$ac_ext" <<_ACEOF #line 11395 "configure" #include "confdefs.h" #include int main (void) { struct sigaction foo; foo.sa_sigaction = 0; (void) foo; ; return 0; } _ACEOF rm -f "conftest.$ac_objext" if { (eval echo "$as_me:11411: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:11414: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest.$ac_objext"' { (eval echo "$as_me:11417: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11420: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then cf_cv_use_sa_sigaction=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 fi rm -f "conftest.$ac_objext" "conftest.$ac_ext" fi fi echo "$as_me:11431: result: $cf_cv_use_sa_sigaction" >&5 echo "${ECHO_T}$cf_cv_use_sa_sigaction" >&6 test "$cf_cv_use_sa_sigaction" = yes && cat >>confdefs.h <<\EOF #define HAVE_SIGACTION_SA_SIGACTION 1 EOF cf_FPE_DEFS="$CPPFLAGS" cf_FPE_LIBS="$LIBS" cf_FPE_SRCS="$srcdir/fpe_check.c" CPPFLAGS="$CPPFLAGS -I. -DRETSIGTYPE=$ac_cv_type_signal" test "$ac_cv_func_isnan" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_ISNAN" test "$ac_cv_func_nanf" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_NANF" test "$ac_cv_func_sigaction" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_SIGACTION" test "$ac_cv_header_siginfo_h" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_SIGINFO_H" test "$cf_cv_use_sa_sigaction" = yes && CPPFLAGS="$CPPFLAGS -DHAVE_SIGACTION_SA_SIGACTION" LIBS="$MATHLIB $LIBS" echo checking handling of floating point exceptions cat >conftest.$ac_ext < CF_EOF rm -f conftest$ac_exeext if { (eval echo "$as_me:11460: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11463: \$? = $ac_status" >&5 (exit "$ac_status"); }; then echo "FPE_CHECK 1:check_fpe_traps" >&5 ./conftest 2>/dev/null cf_status=$? else echo "$cf_FPE_SRCS failed to compile" 1>&2 cf_status=100 fi echo "FPE_CHECK status=$cf_status" >&5 case $cf_status in (0) ;; # good news do nothing (3) # reasonably good news cat >>confdefs.h <<\EOF #define FPE_TRAPS_ON 1 EOF if test "x$cf_cv_use_sv_siginfo" = "xno" then echo "$as_me:11484: checking for sigvec" >&5 echo $ECHO_N "checking for sigvec... $ECHO_C" >&6 if test "${ac_cv_func_sigvec+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11490 "configure" #include "confdefs.h" #define sigvec autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef sigvec #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sigvec (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_sigvec) || defined (__stub___sigvec) #error found stub for sigvec #endif return sigvec (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:11521: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11524: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:11527: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11530: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_sigvec=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_sigvec=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:11540: result: $ac_cv_func_sigvec" >&5 echo "${ECHO_T}$ac_cv_func_sigvec" >&6 if test "$ac_cv_func_sigvec" = yes; then cf_have_sigvec=1 fi echo "FPE_CHECK 2:get_fpe_codes" >&5 if test "$cf_have_sigvec" = 1 && ./fpe_check$ac_exeext phoney_arg >> defines.out ; then : else cat >>confdefs.h <<\EOF #define NOINFO_SIGFPE 1 EOF fi fi ;; (1|2|4) # bad news have to turn off traps # only know how to do this on systemV and solaris echo "$as_me:11560: checking for ieeefp.h" >&5 echo $ECHO_N "checking for ieeefp.h... $ECHO_C" >&6 if test "${ac_cv_header_ieeefp_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11566 "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:11570: \"$ac_cpp "conftest.$ac_ext"\"") >&5 (eval $ac_cpp "conftest.$ac_ext") 2>conftest.er1 ac_status=$? $EGREP -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:11576: \$? = $ac_status" >&5 (exit "$ac_status"); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_ieeefp_h=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_header_ieeefp_h=no fi rm -f conftest.err "conftest.$ac_ext" fi echo "$as_me:11595: result: $ac_cv_header_ieeefp_h" >&5 echo "${ECHO_T}$ac_cv_header_ieeefp_h" >&6 if test "$ac_cv_header_ieeefp_h" = yes; then cf_have_ieeefp_h=1 fi echo "$as_me:11601: checking for fpsetmask" >&5 echo $ECHO_N "checking for fpsetmask... $ECHO_C" >&6 if test "${ac_cv_func_fpsetmask+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11607 "configure" #include "confdefs.h" #define fpsetmask autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef fpsetmask #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char fpsetmask (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_fpsetmask) || defined (__stub___fpsetmask) #error found stub for fpsetmask #endif return fpsetmask (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:11638: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11641: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:11644: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11647: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_fpsetmask=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_fpsetmask=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:11657: result: $ac_cv_func_fpsetmask" >&5 echo "${ECHO_T}$ac_cv_func_fpsetmask" >&6 if test "$ac_cv_func_fpsetmask" = yes; then cf_have_fpsetmask=1 fi if test "$cf_have_ieeefp_h" = 1 && test "$cf_have_fpsetmask" = 1 ; then cat >>confdefs.h <<\EOF #define FPE_TRAPS_ON 1 EOF cat >>confdefs.h <<\EOF #define USE_IEEEFP_H 1 EOF cat >>confdefs.h <>confdefs.h <&5 echo $ECHO_N "checking for sigvec... $ECHO_C" >&6 if test "${ac_cv_func_sigvec+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11688 "configure" #include "confdefs.h" #define sigvec autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef sigvec #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sigvec (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_sigvec) || defined (__stub___sigvec) #error found stub for sigvec #endif return sigvec (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:11719: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11722: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:11725: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11728: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_sigvec=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_sigvec=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:11738: result: $ac_cv_func_sigvec" >&5 echo "${ECHO_T}$ac_cv_func_sigvec" >&6 if test "$ac_cv_func_sigvec" = yes; then cf_have_sigvec=1 fi echo "FPE_CHECK 2:get_fpe_codes" >&5 if test "$cf_have_sigvec" = 1 && ./fpe_check$ac_exeext phoney_arg >> defines.out ; then : else cat >>confdefs.h <<\EOF #define NOINFO_SIGFPE 1 EOF fi fi # look for strtod overflow bug echo "$as_me:11757: checking strtod bug on overflow" >&5 echo $ECHO_N "checking strtod bug on overflow... $ECHO_C" >&6 rm -f conftest$ac_exeext CPPFLAGS="$CPPFLAGS -DUSE_IEEEFP_H" cat >conftest.$ac_ext < CF_EOF if { (eval echo "$as_me:11767: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11770: \$? = $ac_status" >&5 (exit "$ac_status"); }; then echo "FPE_CHECK 3:check_strtod_ovf" >&5 if ./conftest phoney_arg phoney_arg 2>/dev/null then echo "$as_me:11775: result: no bug" >&5 echo "${ECHO_T}no bug" >&6 else echo "$as_me:11778: result: buggy -- will use work around" >&5 echo "${ECHO_T}buggy -- will use work around" >&6 cat >>confdefs.h <&5 echo "${ECHO_T}$cf_FPE_SRCS failed to compile" >&6 fi else if test $cf_status != 4 ; then cat >>confdefs.h <<\EOF #define FPE_TRAPS_ON 1 EOF if test "x$cf_cv_use_sv_siginfo" = "xno" then echo "$as_me:11798: checking for sigvec" >&5 echo $ECHO_N "checking for sigvec... $ECHO_C" >&6 if test "${ac_cv_func_sigvec+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >"conftest.$ac_ext" <<_ACEOF #line 11804 "configure" #include "confdefs.h" #define sigvec autoconf_temporary #include /* least-intrusive standard header which defines gcc2 __stub macros */ #undef sigvec #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sigvec (void); int main (void) { /* The GNU C library defines stubs for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_sigvec) || defined (__stub___sigvec) #error found stub for sigvec #endif return sigvec (); ; return 0; } _ACEOF rm -f "conftest.$ac_objext" "conftest$ac_exeext" if { (eval echo "$as_me:11835: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:11838: \$? = $ac_status" >&5 (exit "$ac_status"); } && { ac_try='test -s "conftest$ac_exeext"' { (eval echo "$as_me:11841: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:11844: \$? = $ac_status" >&5 (exit "$ac_status"); }; }; then ac_cv_func_sigvec=yes else echo "$as_me: failed program was:" >&5 cat "conftest.$ac_ext" >&5 ac_cv_func_sigvec=no fi rm -f "conftest.$ac_objext" "conftest$ac_exeext" "conftest.$ac_ext" fi echo "$as_me:11854: result: $ac_cv_func_sigvec" >&5 echo "${ECHO_T}$ac_cv_func_sigvec" >&6 if test "$ac_cv_func_sigvec" = yes; then cf_have_sigvec=1 fi echo "FPE_CHECK 2:get_fpe_codes" >&5 if test "$cf_have_sigvec" = 1 && ./fpe_check$ac_exeext phoney_arg >> defines.out ; then : else cat >>confdefs.h <<\EOF #define NOINFO_SIGFPE 1 EOF fi fi fi case $cf_status in (1) cat 1>&2 <<-'EOF' Warning: Your system defaults generate floating point exception on divide by zero but not on overflow. You need to #define TURN_ON_FPE_TRAPS to handle overflow. EOF ;; (2) cat 1>&2 <<-'EOF' Warning: Your system defaults generate floating point exception on overflow but not on divide by zero. You need to #define TURN_ON_FPE_TRAPS to handle divide by zero. EOF ;; (4) cat 1>&2 <<-'EOF' Warning: Your system defaults do not generate floating point exceptions, but your math library does not support this behavior. You need to #define TURN_ON_FPE_TRAPS to use fp exceptions for consistency. EOF ;; esac cat 1>&2 <<-'EOF' Please report this so I can fix this script to do it automatically. dickey@invisible-island.net You can continue with the build and the resulting mawk will be usable, but getting FPE_TRAPS_ON correct eventually is best. EOF fi ;; (*) # some sort of disaster if test "x$cross_compiling" = xno then cat 1>&2 <<-EOF The program \`fpe_check' compiled from $cf_FPE_SRCS seems to have unexpectly blown up. Please report this to dickey@invisible-island.net EOF # quit or not ??? else cat 1>&2 <<-EOF The program \`fpe_check' will not work for cross-compiling. You can continue with the build and the resulting mawk will be usable, but getting FPE_TRAPS_ON correct eventually is best. EOF fi ;; esac CPPFLAGS="$cf_FPE_DEFS" LIBS="$cf_FPE_LIBS" rm -f conftest.$ac_ext fpe_check$ac_exeext # whew!! ac_config_files="$ac_config_files Makefile man/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if cmp -s $cache_file confcache; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H : "${CONFIG_STATUS=./config.status}" ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:12010: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >"$CONFIG_STATUS" <<_ACEOF #! $SHELL # Generated automatically by configure. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. me=\`echo "\$0" | sed -e 's,.*\\/,,'\` debug=false SHELL=\${CONFIG_SHELL-$SHELL} ac_cs_invocation="\$0 \$@" CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS _ACEOF cat >>"$CONFIG_STATUS" <<\_ACEOF # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # Name of the executable. as_me=`echo "$0" |sed 's,.*[\\/],,'` if expr a : '\(a\)' >/dev/null 2>&1; then as_expr="expr" else as_expr="false" fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln' else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset="unset" else as_unset="false" fi # NLS nuisances. $as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } $as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } $as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } $as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } exec 6>&1 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>"$CONFIG_STATUS" fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>"$CONFIG_STATUS" fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>"$CONFIG_STATUS" fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>"$CONFIG_STATUS" fi cat >>"$CONFIG_STATUS" <<\EOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." EOF cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` shift set dummy "$ac_option" "$ac_optarg" ${1+"$@"} shift ;; -*);; *) # This is not an option, so the user has probably given explicit # arguments. ac_need_defaults=false;; esac case $1 in # Handling of the options. EOF cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:12188: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) shift CONFIG_FILES="$CONFIG_FILES $1" ac_need_defaults=false;; --header | --heade | --head | --hea ) shift CONFIG_HEADERS="$CONFIG_HEADERS $1" ac_need_defaults=false;; # This is an error. -*) { { echo "$as_me:12207: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done exec 5>>config.log cat >&5 << _ACEOF ## ----------------------- ## ## Running config.status. ## ## ----------------------- ## This file was extended by $as_me 2.52.20231210, executed with CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS > "$ac_cs_invocation" on `(hostname || uname -n) 2>/dev/null | sed 1q` _ACEOF EOF cat >>"$CONFIG_STATUS" <<\EOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "man/Makefile" ) CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config_h.in" ;; *) { { echo "$as_me:12245: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if "$ac_need_defaults"; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. : "${TMPDIR=/tmp}" { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=$TMPDIR/cs$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 { (exit 1); exit 1; } } EOF cat >>"$CONFIG_STATUS" <"\$tmp"/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datarootdir@,$datarootdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@runstatedir@,$runstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@DEFS@,$DEFS,;t t s,@LIBS@,$LIBS,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t s,@build_vendor@,$build_vendor,;t t s,@build_os@,$build_os,;t t s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t s,@SET_MAKE@,$SET_MAKE,;t t s,@GREP@,$GREP,;t t s,@FGREP@,$FGREP,;t t s,@cf_cv_makeflags@,$cf_cv_makeflags,;t t s,@MAKE_NO_PHONY@,$MAKE_NO_PHONY,;t t s,@MAKE_PHONY@,$MAKE_PHONY,;t t s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@YACC@,$YACC,;t t s,@LINT@,$LINT,;t t s,@LINT_OPTS@,$LINT_OPTS,;t t s,@LINT_LIBS@,$LINT_LIBS,;t t s,@CTAGS@,$CTAGS,;t t s,@ETAGS@,$ETAGS,;t t s,@MAKE_LOWER_TAGS@,$MAKE_LOWER_TAGS,;t t s,@MAKE_UPPER_TAGS@,$MAKE_UPPER_TAGS,;t t s,@BUILD_CC@,$BUILD_CC,;t t s,@BUILD_CPP@,$BUILD_CPP,;t t s,@BUILD_CFLAGS@,$BUILD_CFLAGS,;t t s,@BUILD_CPPFLAGS@,$BUILD_CPPFLAGS,;t t s,@BUILD_LDFLAGS@,$BUILD_LDFLAGS,;t t s,@BUILD_LIBS@,$BUILD_LIBS,;t t s,@BUILD_EXEEXT@,$BUILD_EXEEXT,;t t s,@BUILD_OBJEXT@,$BUILD_OBJEXT,;t t s,@MATHLIB@,$MATHLIB,;t t s,@ECHO_LT@,$ECHO_LT,;t t s,@ECHO_LD@,$ECHO_LD,;t t s,@RULE_CC@,$RULE_CC,;t t s,@SHOW_CC@,$SHOW_CC,;t t s,@ECHO_CC@,$ECHO_CC,;t t s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t s,@HAVE_STDNORETURN_H@,$HAVE_STDNORETURN_H,;t t s,@STDC_NORETURN@,$STDC_NORETURN,;t t s,@GROFF_PATH@,$GROFF_PATH,;t t s,@NROFF_PATH@,$NROFF_PATH,;t t s,@TBL_PATH@,$TBL_PATH,;t t s,@GROFF_NOTE@,$GROFF_NOTE,;t t s,@NROFF_NOTE@,$NROFF_NOTE,;t t s,@cf_man2html@,$cf_man2html,;t t s,@MAN2HTML_NOTE@,$MAN2HTML_NOTE,;t t s,@MAN2HTML_PATH@,$MAN2HTML_PATH,;t t s,@MAN2HTML_TEMP@,$MAN2HTML_TEMP,;t t s,@EXTRAOBJS@,$EXTRAOBJS,;t t CEOF EOF cat >>"$CONFIG_STATUS" <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while "$ac_more_lines"; do if test "$ac_beg" -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" "$tmp"/subs.sed >"$tmp"/subs.frag else sed "${ac_end}q" "$tmp"/subs.sed >"$tmp"/subs.frag fi if test ! -s "$tmp"/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat "$tmp"/subs.frag) >"$tmp"/subs-$ac_sed_frag.sed # It is possible to make a multiline substitution using escaped newlines. # Ensure that we do not split the substitution between script fragments. ac_BEG=$ac_end ac_END=`expr "$ac_end" + "$ac_max_sed_lines"` sed "1,${ac_BEG}d; ${ac_END}p; q" "$tmp"/subs.sed >"$tmp"/subs.next if test -s "$tmp"/subs.next; then grep '^s,@[^@,][^@,]*@,.*\\$' "$tmp"/subs.next >"$tmp"/subs.edit if test ! -s "$tmp"/subs.edit; then grep "^s,@[^@,][^@,]*@,.*,;t t$" "$tmp"/subs.next >"$tmp"/subs.edit if test ! -s "$tmp"/subs.edit; then if test "$ac_beg" -gt 1; then ac_end=`expr "$ac_end" - 1` continue fi fi fi fi if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f \"$tmp\"/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f \"$tmp\"/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr "$ac_sed_frag" + 1` ac_beg=$ac_end ac_end=`expr "$ac_end" + "$ac_max_sed_lines"` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds="cat" fi fi # test -n "$CONFIG_FILES" EOF cat >>"$CONFIG_STATUS" <<\EOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in - | *:- | *:-:* ) # input from stdin cat >"$tmp"/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" ;; esac done; } ac_dir_suffix="/`echo "$ac_dir"|sed 's,^\./,,'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'` else ac_dir_suffix= ac_dots= fi case "$srcdir" in .) ac_srcdir=. if test -z "$ac_dots"; then ac_top_srcdir=. else ac_top_srcdir=`echo "$ac_dots" | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) ac_srcdir="$srcdir$ac_dir_suffix"; ac_top_srcdir="$srcdir" ;; *) # Relative path. ac_srcdir="$ac_dots$srcdir$ac_dir_suffix" ac_top_srcdir="$ac_dots$srcdir" ;; esac case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_dots$INSTALL ;; esac if test x"$ac_file" != x-; then { echo "$as_me:12522: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated automatically by config.status. */ configure_input="Generated automatically from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo "$tmp"/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:12540: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:12553: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } EOF cat >>"$CONFIG_STATUS" <<\EOF ac_warn_datarootdir=no if test x"$ac_file" != x-; then for ac_item in $ac_file_inputs do ac_seen=`grep '@\(datadir\|mandir\|infodir\)@' "$ac_item"` if test -n "$ac_seen"; then ac_used=`grep '@datarootdir@' "$ac_item"` if test -z "$ac_used"; then { echo "$as_me:12569: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used implicitly but not set: $ac_seen" >&2;} ac_warn_datarootdir=yes fi fi ac_seen=`grep '${datarootdir}' "$ac_item"` if test -n "$ac_seen"; then { echo "$as_me:12578: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&5 echo "$as_me: WARNING: datarootdir was used explicitly but not set: $ac_seen" >&2;} ac_warn_datarootdir=yes fi done fi if test "x$ac_warn_datarootdir" = xyes; then ac_sed_cmds="$ac_sed_cmds | sed -e 's,@datarootdir@,\${prefix}/share,g' -e 's,\${datarootdir},\${prefix}/share,g'" fi EOF cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >"$tmp"/out rm -f "$tmp"/stdin EOF test -n "${FGREP}" || FGREP="grep -F" test -n "${EGREP}" || EGREP="grep -E" cat >>"$CONFIG_STATUS" <>"$CONFIG_STATUS" <<\EOF if test x"$ac_file" != x-; then cp "$tmp/out" "$ac_file" for ac_name in prefix exec_prefix datarootdir do ac_seen=`$FGREP -n '${'$ac_name'[:=].*}' "$ac_file"` if test -n "$ac_seen"; then ac_init=`$EGREP '[ ]*'$ac_name'[ ]*=' "$ac_file"` if test -z "$ac_init"; then ac_seen=`echo "$ac_seen" |sed -e 's,^,'"$ac_file"':,'` { echo "$as_me:12623: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&5 echo "$as_me: WARNING: Variable $ac_name is used but was not set: $ac_seen" >&2;} fi fi done $EGREP -n '@[a-z_][a-z_0-9]+@' "$ac_file" >"$tmp"/out $EGREP -n '@[A-Z_][A-Z_0-9]+@' "$ac_file" >>"$tmp"/out if test -s "$tmp"/out; then ac_seen=`sed -e 's,^,'"$ac_file"':,' < "$tmp"/out` { echo "$as_me:12634: WARNING: Some variables may not be substituted: $ac_seen" >&5 echo "$as_me: WARNING: Some variables may not be substituted: $ac_seen" >&2;} fi else cat "$tmp"/out fi rm -f "$tmp"/out done EOF cat >>"$CONFIG_STATUS" <<\EOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_i turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_iA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_iB='\([ ]\),\1#\2define\3' ac_iC=' ' ac_iD='\4,;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in - | *:- | *:-:* ) # input from stdin cat >"$tmp"/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:12683: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo "$tmp"/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:12694: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:12707: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >"$tmp"/in EOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\EOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\(\([^ (][^ (]*\)([^)]*)\)[ ]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end EOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs sed 's/ac_d/ac_i/g' conftest.defines >>conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\EOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, EOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>"$CONFIG_STATUS" echo ' test -n "${EGREP}" || EGREP="grep -E"' >>"$CONFIG_STATUS" echo ' if ${EGREP} "^[ ]*#[ ]*define" "$tmp"/in >/dev/null; then' >>"$CONFIG_STATUS" echo ' # If there are no defines, we may have an empty if/fi' >>"$CONFIG_STATUS" echo ' :' >>"$CONFIG_STATUS" rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to "$tmp"/defines.sed. echo ' cat >"$tmp"/defines.sed <>"$CONFIG_STATUS" # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>"$CONFIG_STATUS" # Work around the forget-to-reset-the-flag bug. echo 't clr' >>"$CONFIG_STATUS" echo ': clr' >>"$CONFIG_STATUS" sed "${ac_max_here_lines}q" conftest.defines >>"$CONFIG_STATUS" echo 'CEOF sed -f "$tmp"/defines.sed "$tmp"/in >"$tmp"/out rm -f "$tmp"/in mv "$tmp"/out "$tmp"/in ' >>"$CONFIG_STATUS" sed "1,${ac_max_here_lines}d" conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # grep' >>"$CONFIG_STATUS" echo >>"$CONFIG_STATUS" # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>"$CONFIG_STATUS" rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to "$tmp"/undefs.sed. echo ' cat >"$tmp"/undefs.sed <>"$CONFIG_STATUS" # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>"$CONFIG_STATUS" # Work around the forget-to-reset-the-flag bug. echo 't clr' >>"$CONFIG_STATUS" echo ': clr' >>"$CONFIG_STATUS" sed "${ac_max_here_lines}q" conftest.undefs >>"$CONFIG_STATUS" echo 'CEOF sed -f "$tmp"/undefs.sed "$tmp"/in >"$tmp"/out rm -f "$tmp"/in mv "$tmp"/out "$tmp"/in ' >>"$CONFIG_STATUS" sed "1,${ac_max_here_lines}d" conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>"$CONFIG_STATUS" <<\EOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated automatically by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated automatically by configure. */" >"$tmp"/config.h else echo "/* $ac_file. Generated automatically by configure. */" >"$tmp"/config.h fi cat "$tmp"/in >>"$tmp"/config.h rm -f "$tmp"/in if test x"$ac_file" != x-; then if cmp -s "$ac_file" "$tmp/config.h" 2>/dev/null; then { echo "$as_me:12826: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" ;; esac done; } fi rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" fi else cat "$tmp"/config.h rm -f "$tmp"/config.h fi done EOF cat >>"$CONFIG_STATUS" <<\EOF { (exit 0); exit 0; } EOF chmod +x "$CONFIG_STATUS" ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: exec 5>/dev/null $SHELL "$CONFIG_STATUS" || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. "$ac_cs_success" || { (exit 1); exit 1; } fi mawk-1.3.4-20240123/files.h0000644000000000000000000000266013725423213013330 0ustar rootroot/******************************************** files.h copyright 2009-2016,2020, Thomas E. Dickey copyright 1991-1994,1996, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: files.h,v 1.15 2020/09/07 12:24:43 tom Exp $ */ #ifndef MAWK_FILES_H #define MAWK_FILES_H #include "nstd.h" #include "types.h" /* IO redirection types */ #define F_IN (-5) #define PIPE_IN (-4) #define PIPE_OUT (-3) #define F_APPEND (-2) #define F_TRUNC (-1) #define IS_OUTPUT(type) ((type)>=PIPE_OUT) extern const char *shell; /* for pipes and system() */ extern PTR file_find(STRING *, int); extern int file_close(STRING *); extern int file_flush(STRING *); extern int flush_all_output(void); extern PTR get_pipe(char *, int, int *); extern int wait_for(int); extern int wait_status(int); extern void close_out_pipes(void); #ifdef HAVE_FAKE_PIPES extern void close_fake_pipes(void); extern int close_fake_outpipe(char *, int); extern char *tmp_file_name(int, char *); #endif #ifdef MSDOS extern int DOSexec(char *); extern void enlarge_output_buffer(FILE *); #endif #if USE_BINMODE extern int binmode(void); extern void set_binmode(long); extern void stdout_init(void); #endif #endif /* MAWK_FILES_H */ mawk-1.3.4-20240123/matherr.c0000644000000000000000000001141413727006345013665 0ustar rootroot/******************************************** matherr.c copyright 2009-2013,2020 Thomas E. Dickey copyright 1991, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: matherr.c,v 1.28 2020/09/11 23:48:53 tom Exp $ */ #include "mawk.h" #include "init.h" #include #ifdef HAVE_SIGACTION_SA_SIGACTION #define FPE_ARGS int sig, siginfo_t *sip, void *data #define FPE_DECL int why = sip->si_code #else #define FPE_ARGS int sig, int why #define FPE_DECL /* nothing */ #endif #ifdef USE_IEEEFP_H #include #ifdef HAVE_STRTOD_OVF_BUG static fp_except entry_mask; static fp_except working_mask; #endif #endif #ifndef TURN_OFF_FPE_TRAPS #define TURN_OFF_FPE_TRAPS /* nothing */ #endif #ifndef TURN_ON_FPE_TRAPS #define TURN_ON_FPE_TRAPS /* nothing */ #endif #ifdef HAVE_SIGINFO_H #include #define FPE_UNDERFLOW FPE_FLTUND #endif #ifdef FPE_TRAPS_ON #include #ifndef FPE_FLTDIV #ifdef WIN32 #include #define FPE_FLTDIV FPE_ZERODIVIDE #define FPE_FLTOVF FPE_OVERFLOW #define FPE_FLTUND FPE_UNDERFLOW #endif #endif /* machine dependent changes might be needed here */ static void fpe_catch(FPE_ARGS) { FPE_DECL; #if defined(NOINFO_SIGFPE) rt_error("floating point exception, probably overflow"); /* does not return */ #else switch (why) { #ifdef FPE_FLTDIV case FPE_FLTDIV: rt_error("floating point division by zero"); #endif #ifdef FPE_FLTOVF case FPE_FLTOVF: rt_error("floating point overflow"); #endif #ifdef FPE_FLTUND case FPE_FLTUND: rt_error("floating point underflow"); #endif default: rt_error("floating point exception"); } #endif /* noinfo_sigfpe */ } void fpe_init(void) { #ifdef HAVE_MATH__LIB_VERSION _LIB_VERSION = _IEEE_; #endif TURN_ON_FPE_TRAPS; #ifdef HAVE_SIGACTION_SA_SIGACTION { struct sigaction x; memset(&x, 0, sizeof(x)); x.sa_sigaction = fpe_catch; x.sa_flags = SA_SIGINFO; sigaction(SIGFPE, &x, (struct sigaction *) 0); } #else signal(SIGFPE, fpe_catch); #endif #ifdef HAVE_STRTOD_OVF_BUG /* we've already turned the traps on */ working_mask = fpgetmask(); entry_mask = working_mask & ~FP_X_DZ & ~FP_X_OFL; #endif } #else /* FPE_TRAPS not defined */ void fpe_init(void) { TURN_OFF_FPE_TRAPS; } #endif #ifdef HAVE_MATHERR #ifndef FPE_TRAPS_ON /* If we are not trapping math errors, we will shutup the library calls */ struct exception; extern int matherr(struct exception *e); int matherr(struct exception *e) { (void) e; return 1; } #else /* print error message and exit */ int matherr(struct exception *e) { char *error = "?"; switch (e->type) { case DOMAIN: case SING: error = "domain error"; break; case OVERFLOW: error = "overflow"; break; case TLOSS: case PLOSS: error = "loss of significance"; break; case UNDERFLOW: e->retval = 0.0; return 1; /* ignore it */ } if (strcmp(e->name, "atan2") == 0) rt_error("atan2(%g,%g) : %s", e->arg1, e->arg2, error); else rt_error("%s(%g) : %s", e->name, e->arg1, error); /* won't get here */ return 0; } #endif /* FPE_TRAPS_ON */ #endif /* ! no matherr */ /* this is how one gets the libm calls to do the right thing on bsd43_vax */ #if defined(BSD43_VAX) || defined(__vax__) #include double infnan(int arg) { switch (arg) { case ERANGE: errno = ERANGE; return HUGE; case -ERANGE: errno = EDOM; return -HUGE; default: errno = EDOM; } return 0.0; } #endif /* BSD43_VAX */ /* This routine is for XENIX-68K 2.3A. Error check routine to be called after fp arithmetic. */ #ifdef SW_FP_CHECK /* Definitions of bit values in iserr() return value */ #define OVFLOW 2 #define UFLOW 4 #define ZERODIV 8 #define OVFLFIX 32 #define INFNAN 64 void fpcheck(void) { register int fperrval; char *errdesc; if ((fperrval = iserr()) == 0) return; /* no error */ errdesc = (char *) 0; if (fperrval & INFNAN) errdesc = "arg is infinity or NAN"; else if (fperrval & ZERODIV) errdesc = "division by zero"; else if (fperrval & OVFLOW) errdesc = "overflow"; else if (fperrval & UFLOW) { ; /* ignored */ } if (errdesc) rt_error("%s", errdesc); } #endif #ifdef HAVE_STRTOD_OVF_BUG /* buggy strtod in solaris, probably any sysv with ieee754 strtod can generate an fpe */ double strtod_with_ovf_bug(const char *s, char **ep) { double ret; fpsetmask(entry_mask); /* traps off */ #undef strtod /* make real strtod visible */ ret = strtod(s, ep); fpsetmask(working_mask); /* traps on */ return ret; } #endif mawk-1.3.4-20240123/scan.c0000644000000000000000000005675114467256465013200 0ustar rootroot/******************************************** scan.c copyright 2008-2020,2023, Thomas E. Dickey copyright 2010, Jonathan Nieder copyright 1991-1996,2014, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. ********************************************/ /* * $MawkId: scan.c,v 1.55 2023/08/16 23:35:17 tom Exp $ */ #include #include #include #include #include #include #include #include #ifdef HAVE_FCNTL_H #include #endif #include #define CHR_LPAREN '(' #define CHR_RPAREN ')' #define STR_LBRACE "{" #define STR_RBRACE "}" #define ct_ret(x) return scan_scope(current_token = (x)) #define next() (*buffp ? *buffp++ : slow_next()) #define un_next() buffp-- #define test1_ret(c,x,d) if ( next() == (c) ) ct_ret(x) ;\ else { un_next() ; ct_ret(d) ; } #define test2_ret(c1,x1,c2,x2,d) switch( next() )\ { case c1: ct_ret(x1) ;\ case c2: ct_ret(x2) ;\ default: un_next() ;\ ct_ret(d) ; } double double_zero = 0.0; double double_one = 1.0; /* static functions */ static void scan_fillbuff(void); static void scan_open(void); static int slow_next(void); static void eat_comment(void); static double collect_decimal(int, int *); static int collect_string(void); static int collect_RE(void); /*----------------------------- program file management *----------------------------*/ char *pfile_name; PFILE *pfile_list; static STRING *program_string; static UChar *buffer; static UChar *buffp; /* unsigned so it works with 8 bit chars */ static int program_fd; static int eof_flag; /* * Data for scan_scope() */ #define MAX_REPAIR 10 static SYMTAB *current_symbol; static SYMTAB *current_funct; typedef enum { ssDEFAULT = 0 ,ssHEADER ,ssFUNCTN ,ssLPAREN ,ssRPAREN ,ssLBRACE ,ssRBRACE } SCAN_SCOPE; static SCAN_SCOPE current_scope; static int braces_level; static int max_repair; static struct { SYMTAB *stp; SYM_TYPE type; } repair_syms[MAX_REPAIR]; /* use unsigned chars for index into scan_code[] */ #define NextUChar(c) (UChar)(c = (char) next()) /* overused tmp buffer */ char string_buff[SPRINTF_LIMIT]; static void string_too_long(void) { compile_error("string too long \"%.10s ...", string_buff); mawk_exit(2); } #define CheckStringSize(ptr) \ if ((size_t)((ptr) - string_buff) >= sizeof(string_buff)) \ string_too_long() void scan_init(const char *cmdline_program) { if (cmdline_program) { program_fd = -1; /* command line program */ program_string = new_STRING0(strlen(cmdline_program) + 1); strcpy(program_string->str, cmdline_program); /* simulate file termination */ program_string->str[program_string->len - 1] = '\n'; buffp = (UChar *) program_string->str; eof_flag = 1; } else { /* program from file[s] */ scan_open(); buffp = buffer = (UChar *) zmalloc((size_t) (BUFFSZ + 1)); scan_fillbuff(); } #ifdef OS2 /* OS/2 "extproc" is similar to #! */ if (strnicmp(buffp, "extproc ", 8) == 0) eat_comment(); #endif eat_nl(); /* scan to first token */ if (next() == 0) { /* no program */ mawk_exit(0); } un_next(); } static void scan_open(void) /* open pfile_name */ { if (pfile_name[0] == '-' && pfile_name[1] == 0) { program_fd = 0; } else if ((program_fd = open(pfile_name, O_RDONLY, 0)) == -1) { errmsg(errno, "cannot open \"%s\"", pfile_name); mawk_exit(2); } } void scan_cleanup(void) { if (program_fd >= 0) zfree(buffer, (size_t) (BUFFSZ + 1)); if (program_string) free_STRING(program_string); if (program_fd > 0) close(program_fd); /* redefine SPACE as [ \t\n] */ scan_code['\n'] = (char) ((posix_space_flag && rs_shadow.type != SEP_MLR) ? SC_UNEXPECTED : SC_SPACE); scan_code['\f'] = SC_UNEXPECTED; /*value doesn't matter */ scan_code['\013'] = SC_UNEXPECTED; /* \v not space */ scan_code['\r'] = SC_UNEXPECTED; } /*-------------------------------- global variables shared by yyparse() and yylex() and used for error messages too *-------------------------------*/ int current_token = -1; unsigned token_lineno; unsigned compile_error_count; int NR_flag; /* are we tracking NR */ int paren_cnt; int brace_cnt; int print_flag; /* changes meaning of '>' */ int getline_flag; /* changes meaning of '<' */ /*---------------------------------------- file reading functions next() and un_next(c) are macros in scan.h *---------------------*/ static unsigned lineno = 1; static void scan_fillbuff(void) { size_t r; r = fillbuff(program_fd, (char *) buffer, (size_t) BUFFSZ); if (r < BUFFSZ) { eof_flag = 1; /* make sure eof is terminated */ buffer[r] = '\n'; buffer[r + 1] = 0; } } /* read one character -- slowly */ static int slow_next(void) { while (*buffp == 0) { if (!eof_flag) { buffp = buffer; scan_fillbuff(); } else if (pfile_list /* open another program file */ ) { PFILE *q; if (program_fd > 0) close(program_fd); eof_flag = 0; pfile_name = pfile_list->fname; q = pfile_list; pfile_list = pfile_list->link; ZFREE(q); scan_open(); token_lineno = lineno = 1; } else { break; /* real eof */ } } return *buffp++; /* note can un_next() , eof which is zero */ } static void eat_comment(void) { register int c; while (scan_code[NextUChar(c)] && (c != '\n')) { ; /* empty */ } un_next(); } /* this is how we handle extra semi-colons that are now allowed to separate pattern-action blocks A proof that they are useless clutter to the language: we throw them away */ static void eat_semi_colon(void) /* eat one semi-colon on the current line */ { register int c; while (scan_code[NextUChar(c)] == SC_SPACE) { ; /* empty */ } if (c != ';') un_next(); } void eat_nl(void) /* eat all space including newlines */ { while (1) { switch (scan_code[(UChar) next()]) { case SC_COMMENT: eat_comment(); break; case SC_NL: lineno++; /* FALLTHRU */ case SC_SPACE: break; case SC_ESCAPE: /* bug fix - surprised anyone did this, a csh user with backslash dyslexia.(Not a joke) */ { int c; while (scan_code[NextUChar(c)] == SC_SPACE) { ; /* empty */ } if (c == '\n') token_lineno = ++lineno; else if (c == 0) { un_next(); return; } else { /* error */ un_next(); /* can't un_next() twice so deal with it */ yylval.ival = '\\'; unexpected_char(); if (++compile_error_count == MAX_COMPILE_ERRORS) mawk_exit(2); return; } } break; default: un_next(); return; } } } /* * Function parameters are local to a function, but because mawk uses a single * hash table, it may have conflicts with global symbols (function names). * Work around this by saving the conflicting symbol, overriding it an ordinary * symbol and restoring at the end of the function. */ static int scan_scope(int state) { switch (state) { case FUNCTION: if (braces_level == 0) current_scope = ssHEADER; break; case LPAREN: if (current_scope == ssFUNCTN) current_scope = ssLPAREN; break; case FUNCT_ID: if (current_scope == ssHEADER) { current_scope = ssFUNCTN; current_funct = current_symbol; } else if (current_scope == ssLPAREN) { if (current_symbol == current_funct) { compile_error("function parameter cannot be the function"); } else if (max_repair < MAX_REPAIR) { repair_syms[max_repair].stp = current_symbol; repair_syms[max_repair].type = current_symbol->type; ++max_repair; state = ID; } else { compile_error("too many local/global symbol conflicts"); } } break; case RPAREN: if (current_scope == ssLPAREN) current_scope = ssRPAREN; break; case LBRACE: ++braces_level; if (current_scope == ssRPAREN) current_scope = ssLBRACE; break; case RBRACE: if (braces_level > 0 && current_scope == ssLBRACE) { if (--braces_level == 0) { current_scope = ssDEFAULT; while (max_repair > 0) { --max_repair; (repair_syms[max_repair].stp)->type = repair_syms[max_repair].type; } } } else { current_scope = ssDEFAULT; } break; } return state; } int yylex(void) { register int c; token_lineno = lineno; #ifdef NO_LEAKS memset(&yylval, 0, sizeof(yylval)); #endif reswitch: switch (scan_code[NextUChar(c)]) { case 0: ct_ret(EOF); case SC_SPACE: goto reswitch; case SC_COMMENT: eat_comment(); goto reswitch; case SC_NL: lineno++; eat_nl(); ct_ret(NL); case SC_ESCAPE: while (scan_code[NextUChar(c)] == SC_SPACE) { ; /* empty */ } if (c == '\n') { token_lineno = ++lineno; goto reswitch; } if (c == 0) ct_ret(EOF); un_next(); yylval.ival = '\\'; ct_ret(UNEXPECTED); case SC_SEMI_COLON: eat_nl(); ct_ret(SEMI_COLON); case SC_LBRACE: eat_nl(); brace_cnt++; ct_ret(LBRACE); case SC_PLUS: switch (next()) { case '+': yylval.ival = '+'; string_buff[0] = string_buff[1] = '+'; string_buff[2] = 0; ct_ret(INC_or_DEC); case '=': ct_ret(ADD_ASG); default: un_next(); ct_ret(PLUS); } case SC_MINUS: switch (next()) { case '-': yylval.ival = '-'; string_buff[0] = string_buff[1] = '-'; string_buff[2] = 0; ct_ret(INC_or_DEC); case '=': ct_ret(SUB_ASG); default: un_next(); ct_ret(MINUS); } case SC_COMMA: eat_nl(); ct_ret(COMMA); case SC_MUL: test1_ret('=', MUL_ASG, MUL); case SC_DIV: { static const int can_precede_div[] = {DOUBLE, STRING_, RPAREN, ID, D_ID, RE, RBOX, FIELD, GETLINE, INC_or_DEC, -1}; const int *p = can_precede_div; do { if (*p == current_token) { if (*p != INC_or_DEC) { test1_ret('=', DIV_ASG, DIV); } if (next() == '=') { un_next(); ct_ret(collect_RE()); } } } while (*++p != -1); ct_ret(collect_RE()); } case SC_MOD: test1_ret('=', MOD_ASG, MOD); case SC_POW: test1_ret('=', POW_ASG, POW); case SC_LPAREN: paren_cnt++; ct_ret(LPAREN); case SC_RPAREN: if (--paren_cnt < 0) { compile_error("extra ')'"); paren_cnt = 0; goto reswitch; } ct_ret(RPAREN); case SC_LBOX: ct_ret(LBOX); case SC_RBOX: ct_ret(RBOX); case SC_MATCH: string_buff[0] = '~'; string_buff[1] = 0; yylval.ival = 1; ct_ret(MATCH); case SC_EQUAL: test1_ret('=', EQ, ASSIGN); case SC_NOT: /* ! */ if ((c = next()) == '~') { string_buff[0] = '!'; string_buff[1] = '~'; string_buff[2] = 0; yylval.ival = 0; ct_ret(MATCH); } else if (c == '=') ct_ret(NEQ); un_next(); ct_ret(NOT); case SC_LT: /* '<' */ if (next() == '=') ct_ret(LTE); else un_next(); if (getline_flag) { getline_flag = 0; ct_ret(IO_IN); } else ct_ret(LT); case SC_GT: /* '>' */ if (print_flag && paren_cnt == 0) { print_flag = 0; /* there are 3 types of IO_OUT -- build the error string in string_buff */ string_buff[0] = '>'; if (next() == '>') { yylval.ival = F_APPEND; string_buff[1] = '>'; string_buff[2] = 0; } else { un_next(); yylval.ival = F_TRUNC; string_buff[1] = 0; } return scan_scope(current_token = IO_OUT); } test1_ret('=', GTE, GT); case SC_OR: if (next() == '|') { eat_nl(); ct_ret(OR); } else { un_next(); if (print_flag && paren_cnt == 0) { print_flag = 0; yylval.ival = PIPE_OUT; string_buff[0] = '|'; string_buff[1] = 0; ct_ret(IO_OUT); } else ct_ret(PIPE); } case SC_AND: if (next() == '&') { eat_nl(); ct_ret(AND); } else { un_next(); yylval.ival = '&'; ct_ret(UNEXPECTED); } case SC_QMARK: ct_ret(QMARK); case SC_COLON: ct_ret(COLON); case SC_RBRACE: if (--brace_cnt < 0) { compile_error("extra '" STR_RBRACE "'"); eat_semi_colon(); brace_cnt = 0; goto reswitch; } if ((c = current_token) == NL || c == SEMI_COLON || c == SC_FAKE_SEMI_COLON || c == RBRACE) { /* if the brace_cnt is zero , we've completed a pattern action block. If the user insists on adding a semi-colon on the same line we will eat it. Note what we do below: physical law -- conservation of semi-colons */ if (brace_cnt == 0) eat_semi_colon(); eat_nl(); ct_ret(RBRACE); } /* supply missing semi-colon to statement that precedes a right-brace */ brace_cnt++; un_next(); current_token = SC_FAKE_SEMI_COLON; return scan_scope(SEMI_COLON); case SC_DIGIT: case SC_DOT: { double d; int flag; if ((d = collect_decimal(c, &flag)) == 0.0) { if (flag) ct_ret(flag); else yylval.ptr = (PTR) & double_zero; } else if (d == 1.0) { yylval.ptr = (PTR) & double_one; } else { yylval.ptr = (PTR) ZMALLOC(double); *(double *) yylval.ptr = d; } ct_ret(DOUBLE); } case SC_DOLLAR: /* '$' */ { double d; int flag; while (scan_code[NextUChar(c)] == SC_SPACE) { ; /* empty */ } if (scan_code[c] != SC_DIGIT && scan_code[c] != SC_DOT) { un_next(); ct_ret(DOLLAR); } /* compute field address at compile time */ if ((d = collect_decimal(c, &flag)) <= 0.0) { if (flag) ct_ret(flag); /* an error */ else yylval.cp = &field[0]; } else { Int ival = d_to_I(d); double dval = (double) ival; if (dval != d) { compile_error("$%g is invalid field index", d); } yylval.cp = field_ptr((int) ival); } ct_ret(FIELD); } case SC_DQUOTE: return scan_scope(current_token = collect_string()); case SC_IDCHAR: /* collect an identifier */ { char *p = string_buff + 1; SYMTAB *stp; string_buff[0] = (char) c; while (1) { CheckStringSize(p); c = scan_code[NextUChar(*p++)]; if (c != SC_IDCHAR && c != SC_DIGIT) break; } un_next(); *--p = 0; current_symbol = stp = find(string_buff); switch (stp->type) { case ST_NONE: /* check for function call before defined */ if (next() == CHR_LPAREN) { stp->type = ST_FUNCT; stp->stval.fbp = ZMALLOC(FBLOCK); stp->stval.fbp->name = stp->name; stp->stval.fbp->code = (INST *) 0; stp->stval.fbp->size = 0; yylval.fbp = stp->stval.fbp; current_token = FUNCT_ID; } else { yylval.stp = stp; current_token = current_token == DOLLAR ? D_ID : ID; } un_next(); break; case ST_NR: NR_flag = 1; stp->type = ST_VAR; /* FALLTHRU */ case ST_VAR: case ST_ARRAY: case ST_LOCAL_NONE: case ST_LOCAL_VAR: case ST_LOCAL_ARRAY: yylval.stp = stp; current_token = current_token == DOLLAR ? D_ID : ID; break; case ST_ENV: stp->type = ST_ARRAY; stp->stval.array = new_ARRAY(); load_environ(stp->stval.array); yylval.stp = stp; current_token = current_token == DOLLAR ? D_ID : ID; break; case ST_FUNCT: yylval.fbp = stp->stval.fbp; current_token = FUNCT_ID; break; case ST_KEYWORD: current_token = stp->stval.kw; break; case ST_BUILTIN: yylval.bip = stp->stval.bip; current_token = BUILTIN; break; case ST_FIELD: yylval.cp = stp->stval.cp; current_token = FIELD; break; default: bozo("find returned bad st type"); } return scan_scope(current_token); } case SC_UNEXPECTED: yylval.ival = c & 0xff; ct_ret(UNEXPECTED); } return scan_scope(0); /* never get here make lint happy */ } /* collect a decimal constant in temp_buff. Return the value and error conditions by reference */ static double collect_decimal(int c, int *flag) { register char *p = string_buff + 1; char *endp; char *temp; char *last_decimal = 0; double d; *flag = 0; string_buff[0] = (char) c; if (c == '.') { last_decimal = p - 1; CheckStringSize(p); if (scan_code[NextUChar(*p++)] != SC_DIGIT) { *flag = UNEXPECTED; yylval.ival = '.'; return 0.0; } } else { while (1) { CheckStringSize(p); if (scan_code[NextUChar(*p++)] != SC_DIGIT) { break; } }; if (p[-1] == '.') { last_decimal = p - 1; } else { un_next(); p--; } } /* get rest of digits after decimal point */ while (1) { CheckStringSize(p); if (scan_code[NextUChar(*p++)] != SC_DIGIT) { break; } } /* check for exponent */ if (p[-1] != 'e' && p[-1] != 'E') { un_next(); *--p = 0; } else { /* get the exponent */ if (scan_code[NextUChar(*p)] != SC_DIGIT && *p != '-' && *p != '+') { /* if we can, undo and try again */ if (buffp - buffer >= 2) { un_next(); /* undo the last character */ un_next(); /* undo the 'e' */ *--p = 0; } else { *++p = 0; *flag = BAD_DECIMAL; return 0.0; } } else { /* get the rest of the exponent */ p++; while (1) { CheckStringSize(p); if (scan_code[NextUChar(*p++)] != SC_DIGIT) { break; } } un_next(); *--p = 0; } } #ifdef LOCALE if (last_decimal && decimal_dot) { *last_decimal = decimal_dot; } #endif errno = 0; /* check for overflow/underflow */ d = strtod(string_buff, &temp); endp = temp; #ifndef STRTOD_UNDERFLOW_ON_ZERO_BUG if (errno) compile_error("%s : decimal %sflow", string_buff, d == 0.0 ? "under" : "over"); #else /* ! sun4 bug */ if (errno && d != 0.0) compile_error("%s : decimal overflow", string_buff); #endif if (endp < p) { /* if we can, undo and try again */ if ((p - endp) < (buffp - buffer)) { while (endp < p) { un_next(); ++endp; } } else { *flag = BAD_DECIMAL; return 0.0; } } return d; } /*---------- process escape characters ---------------*/ static const char hex_val['f' - 'A' + 1] = { 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15}; #define isoctal(x) ((x)>='0'&&(x)<='7') #define hex_value(x) hex_val[(x)-'A'] #define ishex(x) (scan_code[x] == SC_DIGIT ||\ ('A' <= (x) && (x) <= 'f' && hex_value(x))) /* process one , two or three octal digits moving a pointer forward by reference */ static int octal(char **start_p) { register char *p = *start_p; register unsigned x; x = (unsigned) (*p++ - '0'); if (isoctal(*p)) { x = (x << 3) + (unsigned) (*p++ - '0'); if (isoctal(*p)) x = (x << 3) + (unsigned) (*p++ - '0'); } *start_p = p; return (int) (x & 0xff); } /* process one or two hex digits moving a pointer forward by reference */ static int hex(char **start_p) { register UChar *p = (UChar *) * start_p; register unsigned x; unsigned t; if (scan_code[*p] == SC_DIGIT) x = (unsigned) (*p++ - '0'); else x = (unsigned) hex_value(*p++); if (scan_code[*p] == SC_DIGIT) x = (x << 4) + *p++ - '0'; else if ('A' <= *p && *p <= 'f' && (t = (unsigned) hex_value(*p))) { x = (x << 4) + t; p++; } *start_p = (char *) p; return (int) x; } /* process the escape characters in a string, in place . */ char * rm_escape(char *s, size_t *lenp) { register char *p, *q; char *t; q = p = s; while (*p) { if (*p == '\\') { int ch = *++p; switch (ch) { case 'n': p++; *q++ = '\n'; break; case 't': p++; *q++ = '\t'; break; case 'f': p++; *q++ = '\f'; break; case 'b': p++; *q++ = '\b'; break; case 'r': p++; *q++ = '\r'; break; case 'a': p++; *q++ = '\07'; break; case 'v': p++; *q++ = '\013'; break; case '\\': p++; *q++ = '\\'; break; case '\"': p++; *q++ = '\"'; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': t = p; *q++ = (char) octal(&t); p = t; break; case 'x': if (ishex(*(UChar *) (p + 1))) { t = p + 1; *q++ = (char) hex(&t); p = t; break; } else { goto not_escape; } case '\0': *q++ = '\\'; break; not_escape: default: *q++ = '\\'; *q++ = *p++; break; } } else *q++ = *p++; } *q = 0; if (lenp != 0) *lenp = (unsigned) (q - s); return s; } static int collect_string(void) { register char *p = string_buff; int c; int e_flag = 0; /* on if have an escape char */ size_t len_buff; while (1) { CheckStringSize(p); switch (scan_code[NextUChar(*p++)]) { case SC_DQUOTE: /* done */ *--p = 0; goto out; case SC_NL: p[-1] = 0; /* FALLTHRU */ case 0: /* unterminated string */ compile_error( "runaway string constant \"%.10s ...", string_buff); mawk_exit(2); case SC_ESCAPE: if ((c = next()) == '\n') { p--; lineno++; } else if (c == 0) un_next(); else { *p++ = (char) c; e_flag = 1; } break; default: break; } } out: if (e_flag) rm_escape(string_buff, &len_buff); else len_buff = (unsigned) ((char *) p - string_buff); yylval.ptr = (PTR) new_STRING1(string_buff, len_buff); return STRING_; } static int collect_RE(void) { char *p = string_buff; const char *first = NULL; int limit = sizeof(string_buff) - 2; int c; int boxed = 0; STRING *sval; while (1) { if (p >= (string_buff + limit)) { compile_error( "regular expression /%.10s ..." " exceeds implementation size limit (%d)", string_buff, limit); mawk_exit(2); } CheckStringSize(p); switch (scan_code[NextUChar(c = *p++)]) { case SC_POW: /* Handle [^]] and [^^] correctly. */ if ((p - 1) == first && first != 0 && first[-1] == '[') { first = p; } break; case SC_LBOX: /* * If we're starting a bracket expression, remember where that * started, so we can make comparisons to handle things like * "[]xxxx]" and "[^]xxxx]". */ if (!boxed) { first = p; ++boxed; } else { /* XXX. Does not handle collating symbols or equivalence * class expressions. */ /* XXX. Does not match logic used in rexp0.c to check for * a character class expression, though probably the * latter should be adjusted. * POSIX and common sense give us license to complain about * expressions such as '[[:not a special character class]]'. */ if (next() == ':') { ++boxed; } un_next(); } break; case SC_RBOX: /* * A right square-bracket loses its special meaning if it occurs * first in the list (after an optional "^"). */ if (boxed && p - 1 != first) { --boxed; } break; case SC_DIV: /* done */ if (!boxed) { *--p = 0; goto out; } break; case SC_NL: p[-1] = 0; /* FALLTHRU */ case 0: /* unterminated re */ compile_error( "runaway regular expression /%.10s ...", string_buff); mawk_exit(2); case SC_ESCAPE: switch (c = next()) { case '/': p[-1] = '/'; break; case '\n': p--; break; case 0: un_next(); break; default: *p++ = (char) c; break; } break; } } out: /* now we've got the RE, so compile it */ sval = new_STRING(string_buff); yylval.ptr = re_compile(sval); free_STRING(sval); return RE; } #ifdef NO_LEAKS void scan_leaks(void) { TRACE(("scan_leaks\n")); if (yylval.ptr) { free(yylval.ptr); yylval.ptr = 0; } } #endif mawk-1.3.4-20240123/patchlev.h0000644000000000000000000000073014554027553014040 0ustar rootroot/* patchlev.h copyright 2009-2023,2024, Thomas E. Dickey copyright 1991-1996,2014, Michael D. Brennan This is a source file for mawk, an implementation of the AWK programming language. Mawk is distributed without warranty under the terms of the GNU General Public License, version 2, 1991. */ /* * $MawkId: patchlev.h,v 1.145 2024/01/23 21:28:11 tom Exp $ */ #define PATCH_BASE 1 #define PATCH_LEVEL 3 #define PATCH_STRING ".4" #define DATE_STRING "20240123"