mirror of
https://github.com/ThomasDickey/mawk-snapshots.git
synced 2026-01-26 19:09:15 +00:00
snapshot of project "mawk", label t20121105
This commit is contained in:
parent
02f757cc13
commit
64b80cd114
5
CHANGES
5
CHANGES
@ -1,8 +1,9 @@
|
||||
-- $MawkId: CHANGES,v 1.158 2012/11/02 23:25:41 tom Exp $
|
||||
-- $MawkId: CHANGES,v 1.160 2012/11/05 10:48:32 tom Exp $
|
||||
|
||||
Changes by Thomas E Dickey <dickey@invisible-island.net>
|
||||
|
||||
20121102
|
||||
20121105
|
||||
+ support length(array), as done in gawk and BWK awk.
|
||||
+ 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
|
||||
|
||||
2
MANIFEST
2
MANIFEST
@ -1,4 +1,4 @@
|
||||
MANIFEST for mawk, version t20121102
|
||||
MANIFEST for mawk, version t20121105
|
||||
--------------------------------------------------------------------------------
|
||||
MANIFEST this file
|
||||
ACKNOWLEDGMENT acknowledgements
|
||||
|
||||
3
code.c
3
code.c
@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
|
||||
********************************************/
|
||||
|
||||
/*
|
||||
* $MawkId: code.c,v 1.34 2012/11/02 00:39:52 tom Exp $
|
||||
* $MawkId: code.c,v 1.35 2012/11/03 13:36:38 tom Exp $
|
||||
* @Log: code.c,v @
|
||||
* Revision 1.6 1995/06/18 19:42:13 mike
|
||||
* Remove some redundant declarations and add some prototypes
|
||||
@ -360,6 +360,7 @@ free_codes(const char *tag, INST * base, size_t size)
|
||||
cdp += 1 + cdp[2].op;
|
||||
break;
|
||||
case A_DEL:
|
||||
case A_LENGTH:
|
||||
case A_TEST:
|
||||
case DEL_A:
|
||||
case FE_PUSHA:
|
||||
|
||||
3
code.h
3
code.h
@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
|
||||
********************************************/
|
||||
|
||||
/*
|
||||
* $MawkId: code.h,v 1.9 2012/11/02 23:21:50 tom Exp $
|
||||
* $MawkId: code.h,v 1.10 2012/11/03 13:36:38 tom Exp $
|
||||
* @Log: code.h,v @
|
||||
* Revision 1.5 1995/06/18 19:42:15 mike
|
||||
* Remove some redundant declarations and add some prototypes
|
||||
@ -129,6 +129,7 @@ typedef enum {
|
||||
,_POW
|
||||
,_NOT
|
||||
,_TEST
|
||||
,A_LENGTH
|
||||
,A_TEST
|
||||
,A_DEL
|
||||
,ALOOP
|
||||
|
||||
4
configure
vendored
4
configure
vendored
@ -2978,7 +2978,7 @@ if test "${with_builtin_regex+set}" = set; then
|
||||
fi;
|
||||
if test "x${with_builtin_regex}" != xno; then
|
||||
with_builtin_regex=yes
|
||||
CFLAGS="$CFLAGS -DLOCAL_REGEXP"
|
||||
CPPFLAGS="$CPPFLAGS -DLOCAL_REGEXP"
|
||||
fi
|
||||
echo "$as_me:2983: result: $with_builtin_regex" >&5
|
||||
echo "${ECHO_T}$with_builtin_regex" >&6
|
||||
@ -3723,7 +3723,7 @@ fi;
|
||||
if test "x${with_init_srand}" != xno; then
|
||||
with_init_srand=yes
|
||||
else
|
||||
CFLAGS="$CFLAGS -DNO_INIT_SRAND"
|
||||
CPPFLAGS="$CPPFLAGS -DNO_INIT_SRAND"
|
||||
fi
|
||||
echo "$as_me:3728: result: $with_init_srand" >&5
|
||||
echo "${ECHO_T}$with_init_srand" >&6
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
dnl $MawkId: configure.in,v 1.47 2012/11/01 09:51:00 tom Exp $
|
||||
dnl $MawkId: configure.in,v 1.48 2012/11/03 00:22:45 tom Exp $
|
||||
dnl configure.in for mawk
|
||||
dnl ###########################################################################
|
||||
dnl configure.in
|
||||
@ -73,7 +73,7 @@ AC_ARG_WITH([builtin-regex],
|
||||
])
|
||||
if test "x${with_builtin_regex}" != xno; then
|
||||
with_builtin_regex=yes
|
||||
CFLAGS="$CFLAGS -DLOCAL_REGEXP"
|
||||
CPPFLAGS="$CPPFLAGS -DLOCAL_REGEXP"
|
||||
fi
|
||||
AC_MSG_RESULT($with_builtin_regex)
|
||||
|
||||
@ -104,7 +104,7 @@ CF_ARG_ENABLE([init-srand],
|
||||
if test "x${with_init_srand}" != xno; then
|
||||
with_init_srand=yes
|
||||
else
|
||||
CFLAGS="$CFLAGS -DNO_INIT_SRAND"
|
||||
CPPFLAGS="$CPPFLAGS -DNO_INIT_SRAND"
|
||||
fi
|
||||
AC_MSG_RESULT($with_init_srand)
|
||||
|
||||
|
||||
3
da.c
3
da.c
@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
|
||||
********************************************/
|
||||
|
||||
/*
|
||||
* $MawkId: da.c,v 1.12 2012/06/27 09:21:13 tom Exp $
|
||||
* $MawkId: da.c,v 1.13 2012/11/03 13:36:38 tom Exp $
|
||||
* @Log: da.c,v @
|
||||
* Revision 1.6 1995/06/18 19:19:59 mike
|
||||
* remove use of comma operator that broke some sysVr3 compilers
|
||||
@ -69,6 +69,7 @@ static OP_NAME simple_code[] =
|
||||
{_STOP, "stop"},
|
||||
{FE_PUSHA, "fe_pusha"},
|
||||
{FE_PUSHI, "fe_pushi"},
|
||||
{A_LENGTH, "a_length"},
|
||||
{A_TEST, "a_test"},
|
||||
{A_DEL, "a_del"},
|
||||
{DEL_A, "del_a"},
|
||||
|
||||
5
error.c
5
error.c
@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
|
||||
********************************************/
|
||||
|
||||
/*
|
||||
* $MawkId: error.c,v 1.17 2012/10/30 21:43:40 tom Exp $
|
||||
* $MawkId: error.c,v 1.18 2012/11/03 00:32:58 tom Exp $
|
||||
* @Log: error.c,v @
|
||||
* Revision 1.6 1995/06/06 00:18:22 mike
|
||||
* change mawk_exit(1) to mawk_exit(2)
|
||||
@ -236,6 +236,9 @@ compile_error(const char *format,...)
|
||||
s0 = s1 = "";
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fflush(stdout);
|
||||
#endif
|
||||
fprintf(stderr, "%s: %s%sline %u: ", progname, s0, s1, token_lineno);
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
|
||||
@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
|
||||
********************************************/
|
||||
|
||||
/*
|
||||
* $MawkId: execute.c,v 1.27 2012/10/27 00:32:33 tom Exp $
|
||||
* $MawkId: execute.c,v 1.29 2012/11/05 10:53:43 tom Exp $
|
||||
* @Log: execute.c,v @
|
||||
* Revision 1.13 1996/02/01 04:39:40 mike
|
||||
* dynamic array scheme
|
||||
@ -1088,6 +1088,12 @@ execute(INST * cdp, /* code ptr, start execution here */
|
||||
sp->dval = t ? 1.0 : 0.0;
|
||||
break;
|
||||
|
||||
case A_LENGTH:
|
||||
sp--;
|
||||
sp->type = C_DOUBLE;
|
||||
sp->dval = (double) (((ARRAY) ((sp + 0)->ptr))->size);
|
||||
break;
|
||||
|
||||
case A_TEST:
|
||||
/* entry : sp[0].ptr-> an array
|
||||
sp[-1] is an expression
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
mawk-cur (1.3.4-20121102) unstable; urgency=low
|
||||
mawk-cur (1.3.4-20121105) unstable; urgency=low
|
||||
|
||||
* make srand/rand more configurable.
|
||||
* implement length(array)
|
||||
* make srand/rand more configurable
|
||||
* add strftime and related functions
|
||||
* fix bug in "/dev/stdin" change
|
||||
* improved configure script
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
Summary: mawk - pattern scanning and text processing language
|
||||
%define AppProgram mawk
|
||||
%define AppVersion 1.3.4
|
||||
%define AppRelease 20121102
|
||||
# $MawkId: mawk.spec,v 1.16 2012/11/02 08:25:20 tom Exp $
|
||||
%define AppRelease 20121105
|
||||
# $MawkId: mawk.spec,v 1.18 2012/11/05 10:47:56 tom Exp $
|
||||
Name: %{AppProgram}
|
||||
Version: %{AppVersion}
|
||||
Release: %{AppRelease}
|
||||
|
||||
20
parse.h
20
parse.h
@ -80,16 +80,16 @@
|
||||
#ifndef YYSTYPE_IS_DECLARED
|
||||
#define YYSTYPE_IS_DECLARED 1
|
||||
typedef 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 */
|
||||
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 ;
|
||||
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 */
|
||||
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;
|
||||
|
||||
72
parse.y
72
parse.y
@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
|
||||
********************************************/
|
||||
|
||||
/*
|
||||
* $MawkId: parse.y,v 1.15 2012/06/27 09:19:17 tom Exp $
|
||||
* $MawkId: parse.y,v 1.16 2012/11/05 10:39:14 tom Exp $
|
||||
* @Log: parse.y,v @
|
||||
* Revision 1.11 1995/06/11 22:40:09 mike
|
||||
* change if(dump_code) -> if(dump_code_flag)
|
||||
@ -124,16 +124,16 @@ static FBLOCK *active_funct ;
|
||||
%}
|
||||
|
||||
%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 */
|
||||
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 ;
|
||||
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 */
|
||||
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 */
|
||||
@ -170,7 +170,7 @@ PTR ptr ;
|
||||
%token <stp> ID D_ID
|
||||
%token <fbp> FUNCT_ID
|
||||
%token <bip> BUILTIN LENGTH
|
||||
%token <cp> FIELD
|
||||
%token <cp> FIELD
|
||||
|
||||
%token PRINT PRINTF SPLIT MATCH_FUNC SUB GSUB
|
||||
/* keywords */
|
||||
@ -351,7 +351,7 @@ expr : cat_expr
|
||||
cp->type = C_STRING ;
|
||||
cp->ptr = p3[1].ptr ;
|
||||
cast_to_RE(cp) ;
|
||||
no_leaks_re_ptr(cp->ptr) ;
|
||||
no_leaks_re_ptr(cp->ptr) ;
|
||||
code_ptr -= 2 ;
|
||||
code2(_MATCH1, cp->ptr) ;
|
||||
ZFREE(cp) ;
|
||||
@ -395,10 +395,10 @@ p_expr : DOUBLE
|
||||
{ $$ = 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) ;
|
||||
$$ = code_offset ;
|
||||
if ( is_local($1) )
|
||||
{ code2op(L_PUSHI, $1->offset) ; }
|
||||
else code2(_PUSHI, $1->stval.cp) ;
|
||||
}
|
||||
|
||||
| LPAREN expr RPAREN
|
||||
@ -407,9 +407,9 @@ p_expr : DOUBLE
|
||||
|
||||
p_expr : RE
|
||||
{ $$ = code_offset ;
|
||||
code2(_MATCH0, $1) ;
|
||||
no_leaks_re_ptr($1);
|
||||
}
|
||||
code2(_MATCH0, $1) ;
|
||||
no_leaks_re_ptr($1);
|
||||
}
|
||||
;
|
||||
|
||||
p_expr : p_expr PLUS p_expr { code1(_ADD) ; }
|
||||
@ -473,7 +473,29 @@ args : expr %prec LPAREN
|
||||
;
|
||||
|
||||
builtin :
|
||||
BUILTIN mark LPAREN arglist RPAREN
|
||||
BUILTIN mark LPAREN ID RPAREN
|
||||
{ BI_REC *p = $1 ;
|
||||
$$ = $2 ;
|
||||
if ( (int)p->min_args > 1 || (int)p->max_args < 1 )
|
||||
compile_error(
|
||||
"wrong number of arguments in call to %s" ,
|
||||
p->name ) ;
|
||||
/* if we have length(array), emit a different code */
|
||||
if ( p->fp == bi_length && is_array($4) ) {
|
||||
code_array($4) ;
|
||||
{ code1(_PUSHINT) ; code1(1) ; }
|
||||
code1(A_LENGTH) ;
|
||||
} else {
|
||||
check_var($4);
|
||||
if ( is_local($4) )
|
||||
{ code1(L_PUSHI); code1($4->offset) ; }
|
||||
else { code2(_PUSHI, $4->stval.cp) ; }
|
||||
if ( p->min_args != p->max_args ) /* variable args */
|
||||
{ code1(_PUSHINT) ; code1(1) ; }
|
||||
code2(_BUILTIN, p->fp) ;
|
||||
}
|
||||
}
|
||||
| BUILTIN mark LPAREN arglist RPAREN
|
||||
{ BI_REC *p = $1 ;
|
||||
$$ = $2 ;
|
||||
if ( (int)p->min_args > $4 || (int)p->max_args < $4 )
|
||||
@ -863,7 +885,7 @@ split_back : RPAREN
|
||||
cast_for_split(cp) ;
|
||||
code_ptr[-2].op = _PUSHC ;
|
||||
code_ptr[-1].ptr = (PTR) cp ;
|
||||
no_leaks_cell(cp);
|
||||
no_leaks_cell(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -896,7 +918,7 @@ re_arg : expr
|
||||
cast_to_RE(cp) ;
|
||||
p1->op = _PUSHC ;
|
||||
p1[1].ptr = (PTR) cp ;
|
||||
no_leaks_cell(cp);
|
||||
no_leaks_cell(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -979,7 +1001,7 @@ p_expr : sub_or_gsub LPAREN re_arg COMMA expr sub_back
|
||||
cast_to_REPL(cp) ;
|
||||
p5->op = _PUSHC ;
|
||||
p5[1].ptr = (PTR) cp ;
|
||||
no_leaks_cell(cp);
|
||||
no_leaks_cell(cp);
|
||||
}
|
||||
code2(_BUILTIN, $1) ;
|
||||
$$ = $3 ;
|
||||
@ -1175,7 +1197,7 @@ resize_fblock(FBLOCK *fbp)
|
||||
/* code_shrink() zfrees p */
|
||||
|
||||
if ( dump_code_flag )
|
||||
add_to_fdump_list(fbp) ;
|
||||
add_to_fdump_list(fbp) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -11,9 +11,9 @@ the GNU General Public License, version 2, 1991.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $MawkId: patchlev.h,v 1.40 2012/11/02 08:25:13 tom Exp $
|
||||
* $MawkId: patchlev.h,v 1.42 2012/11/05 10:47:56 tom Exp $
|
||||
*/
|
||||
#define PATCH_BASE 1
|
||||
#define PATCH_LEVEL 3
|
||||
#define PATCH_STRING ".4"
|
||||
#define DATE_STRING "20121102"
|
||||
#define DATE_STRING "20121105"
|
||||
|
||||
52
symtype.h
52
symtype.h
@ -1,6 +1,6 @@
|
||||
/********************************************
|
||||
symtype.h
|
||||
copyright 2009,2010, Thomas E. Dickey
|
||||
copyright 2009-2010,2012, Thomas E. Dickey
|
||||
copyright 1991, Michael D. Brennan
|
||||
|
||||
This is a source file for mawk, an implementation of
|
||||
@ -11,7 +11,7 @@ the GNU General Public License, version 2, 1991.
|
||||
********************************************/
|
||||
|
||||
/*
|
||||
* $MawkId: symtype.h,v 1.13 2010/12/10 17:00:00 tom Exp $
|
||||
* $MawkId: symtype.h,v 1.14 2012/11/03 13:08:35 tom Exp $
|
||||
* @Log: symtype.h,v @
|
||||
* Revision 1.6 1996/02/01 04:39:43 mike
|
||||
* dynamic array scheme
|
||||
@ -53,7 +53,7 @@ the GNU General Public License, version 2, 1991.
|
||||
#ifndef SYMTYPE_H
|
||||
#define SYMTYPE_H
|
||||
|
||||
#include "types.h"
|
||||
#include <types.h>
|
||||
|
||||
/* struct to hold info about builtins */
|
||||
typedef struct {
|
||||
@ -67,23 +67,10 @@ typedef struct {
|
||||
structures and types for arrays
|
||||
*--------------------------*/
|
||||
|
||||
#include "array.h"
|
||||
#include <array.h>
|
||||
|
||||
extern ARRAY Argv;
|
||||
|
||||
#if 0
|
||||
/* struct to hold the state of an array loop */
|
||||
typedef struct al_state {
|
||||
struct al_state *link;
|
||||
CELL *var;
|
||||
ARRAY A;
|
||||
int index; /* A[index] */
|
||||
ANODE *ptr;
|
||||
} ALOOP_STATE;
|
||||
|
||||
extern int inc_aloop_state(ALOOP_STATE *);
|
||||
#endif
|
||||
|
||||
/* for parsing (i,j) in A */
|
||||
typedef struct {
|
||||
int start; /* offset to code_base */
|
||||
@ -109,21 +96,24 @@ extern void fdump(void);
|
||||
elements of the symbol table
|
||||
-----------------------*/
|
||||
|
||||
#define ST_NONE 0
|
||||
#define ST_VAR 1
|
||||
#define ST_KEYWORD 2
|
||||
#define ST_BUILTIN 3 /* a pointer to a builtin record */
|
||||
#define ST_ARRAY 4 /* a void * ptr to a hash table */
|
||||
#define ST_FIELD 5 /* a cell ptr to a field */
|
||||
#define ST_FUNCT 6
|
||||
#define ST_NR 7 /* NR is special */
|
||||
#define ST_ENV 8 /* and so is ENVIRON */
|
||||
#define ST_LENGTH 9 /* ditto and bozo */
|
||||
#define ST_LOCAL_NONE 10
|
||||
#define ST_LOCAL_VAR 11
|
||||
#define ST_LOCAL_ARRAY 12
|
||||
typedef enum {
|
||||
ST_NONE
|
||||
,ST_VAR
|
||||
,ST_KEYWORD
|
||||
,ST_BUILTIN /* a pointer to a builtin record */
|
||||
,ST_ARRAY /* a void * ptr to a hash table */
|
||||
,ST_FIELD /* a cell ptr to a field */
|
||||
,ST_FUNCT
|
||||
,ST_NR /* NR is special */
|
||||
,ST_ENV /* and so is ENVIRON */
|
||||
,ST_LENGTH /* ditto and bozo */
|
||||
,ST_LOCAL_NONE
|
||||
,ST_LOCAL_VAR
|
||||
,ST_LOCAL_ARRAY
|
||||
} SYMTAB_TYPES;
|
||||
|
||||
#define is_local(stp) ((stp)->type>=ST_LOCAL_NONE)
|
||||
#define is_array(stp) ((stp)->type == ST_ARRAY || (stp)->type == ST_LOCAL_ARRAY)
|
||||
#define is_local(stp) ((stp)->type >= ST_LOCAL_NONE)
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user