snapshot of project "mawk", label t20140618

This commit is contained in:
Thomas E. Dickey 2014-06-18 23:38:45 -04:00
parent 2faf5e1af6
commit 7b6d64dd91
9 changed files with 113 additions and 69 deletions

View File

@ -1,8 +1,10 @@
-- $MawkId: CHANGES,v 1.178 2014/06/05 23:01:15 tom Exp $
-- $MawkId: CHANGES,v 1.179 2014/06/18 21:15:34 tom Exp $
Changes by Thomas E Dickey <dickey@invisible-island.net>
20140605
20140618
+ 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

View File

@ -1,4 +1,4 @@
MANIFEST for mawk, version t20140605
MANIFEST for mawk, version t20140618
--------------------------------------------------------------------------------
MANIFEST this file
ACKNOWLEDGMENT acknowledgements

View File

@ -1,6 +1,6 @@
/********************************************
bi_funct.c
copyright 2008-2012,2013, Thomas E. Dickey
copyright 2008-2013,2014, Thomas E. Dickey
copyright 1991-1995,1996, 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: bi_funct.c,v 1.67 2013/02/19 10:57:28 tom Exp $
* $MawkId: bi_funct.c,v 1.69 2014/06/18 23:15:40 tom Exp $
* @Log: bi_funct.c,v @
* Revision 1.9 1996/01/14 17:16:11 mike
* flush_all_output() before system()
@ -160,7 +160,7 @@ bi_funct_init(void)
**************************************************/
CELL *
bi_length(CELL * sp)
bi_length(CELL *sp)
{
size_t len;
@ -227,7 +227,7 @@ str_str(char *target, size_t target_len, char *key, size_t key_len)
}
CELL *
bi_index(CELL * sp)
bi_index(CELL *sp)
{
size_t idx;
size_t len;
@ -262,7 +262,7 @@ bi_index(CELL * sp)
from max(1,i) to min(l,n-i-1) inclusive */
CELL *
bi_substr(CELL * sp)
bi_substr(CELL *sp)
{
int n_args, len;
register int i, n;
@ -341,7 +341,7 @@ bi_substr(CELL * sp)
*/
CELL *
bi_match(CELL * sp)
bi_match(CELL *sp)
{
char *p;
size_t length;
@ -377,7 +377,7 @@ bi_match(CELL * sp)
}
CELL *
bi_toupper(CELL * sp)
bi_toupper(CELL *sp)
{
STRING *old;
register char *p, *q;
@ -401,7 +401,7 @@ bi_toupper(CELL * sp)
}
CELL *
bi_tolower(CELL * sp)
bi_tolower(CELL *sp)
{
STRING *old;
register char *p, *q;
@ -428,7 +428,7 @@ bi_tolower(CELL * sp)
* Like gawk...
*/
CELL *
bi_systime(CELL * sp)
bi_systime(CELL *sp)
{
time_t result;
time(&result);
@ -448,7 +448,7 @@ bi_systime(CELL * sp)
YYYY MM DD HH MM SS [DST].
*/
CELL *
bi_mktime(CELL * sp)
bi_mktime(CELL *sp)
{
time_t result;
struct tm my_tm;
@ -500,7 +500,7 @@ bi_mktime(CELL * sp)
*/
#ifdef HAVE_STRFTIME
CELL *
bi_strftime(CELL * sp)
bi_strftime(CELL *sp)
{
const char *format = "%c";
time_t rawtime;
@ -591,7 +591,7 @@ fplib_err(
#endif
CELL *
bi_sin(CELL * sp)
bi_sin(CELL *sp)
{
TRACE_FUNC("bi_sin", sp);
@ -616,7 +616,7 @@ bi_sin(CELL * sp)
}
CELL *
bi_cos(CELL * sp)
bi_cos(CELL *sp)
{
TRACE_FUNC("bi_cos", sp);
@ -641,7 +641,7 @@ bi_cos(CELL * sp)
}
CELL *
bi_atan2(CELL * sp)
bi_atan2(CELL *sp)
{
TRACE_FUNC("bi_atan2", sp);
@ -665,7 +665,7 @@ bi_atan2(CELL * sp)
}
CELL *
bi_log(CELL * sp)
bi_log(CELL *sp)
{
TRACE_FUNC("bi_log", sp);
@ -690,7 +690,7 @@ bi_log(CELL * sp)
}
CELL *
bi_exp(CELL * sp)
bi_exp(CELL *sp)
{
TRACE_FUNC("bi_exp", sp);
@ -716,7 +716,7 @@ bi_exp(CELL * sp)
}
CELL *
bi_int(CELL * sp)
bi_int(CELL *sp)
{
TRACE_FUNC("bi_int", sp);
@ -727,7 +727,7 @@ bi_int(CELL * sp)
}
CELL *
bi_sqrt(CELL * sp)
bi_sqrt(CELL *sp)
{
TRACE_FUNC("bi_sqrt", sp);
@ -782,7 +782,7 @@ static CELL cseed; /* argument of last call to srand() */
#endif /* defined(mawk_srand) || defined(mawk_rand) */
CELL *
bi_srand(CELL * sp)
bi_srand(CELL *sp)
{
#ifdef USE_SYSTEM_SRAND
static long seed = 1;
@ -839,7 +839,7 @@ bi_srand(CELL * sp)
}
CELL *
bi_rand(CELL * sp)
bi_rand(CELL *sp)
{
TRACE_FUNC("bi_rand", sp);
@ -874,7 +874,7 @@ bi_rand(CELL * sp)
*************************************************/
CELL *
bi_close(CELL * sp)
bi_close(CELL *sp)
{
int x;
@ -891,7 +891,7 @@ bi_close(CELL * sp)
}
CELL *
bi_fflush(CELL * sp)
bi_fflush(CELL *sp)
{
int ret = 0;
@ -914,7 +914,7 @@ bi_fflush(CELL * sp)
}
CELL *
bi_system(CELL * sp GCC_UNUSED)
bi_system(CELL *sp GCC_UNUSED)
{
#ifdef HAVE_REAL_PIPES
int pid;
@ -972,7 +972,7 @@ bi_system(CELL * sp GCC_UNUSED)
*/
CELL *
bi_getline(CELL * sp)
bi_getline(CELL *sp)
{
CELL tc;
CELL *cp = 0;
@ -1082,7 +1082,7 @@ bi_getline(CELL * sp)
*/
CELL *
bi_sub(CELL * sp)
bi_sub(CELL *sp)
{
CELL *cp; /* pointer to the replacement target */
CELL tc; /* build the new string here */
@ -1222,6 +1222,31 @@ indent(int level)
empty_ok is set if, match of empty string at front is OK
*/
static size_t
repl_length(CELL *cp)
{
size_t result = 0;
if (cp->type == C_REPL) {
result = string(cp)->len;
} else if (cp->type == C_REPLV) {
STRING **sblock = (STRING **) cp->ptr;
unsigned count = cp->vcnt;
TRACE(("repl_length C_REPLV count %d\n", count));
while (count--) {
if (*sblock) {
TRACE(("..adding "));
TRACE_STRING(*sblock);
TRACE(("\n"));
result += (*sblock)->len;
}
sblock++;
}
}
TRACE(("repl_length -> %d\n", (int) result));
return result;
}
#ifdef DEBUG_GSUB
static STRING *
old_gsub(PTR re, int level)
@ -1231,6 +1256,7 @@ old_gsub(PTR re, int level)
char *front = 0, *middle;
STRING *back;
size_t front_len, middle_len;
size_t repl_len;
assert(level >= 0);
assert(level + 1 < (int) gsub_max);
@ -1293,21 +1319,22 @@ old_gsub(PTR re, int level)
}
/* put the three pieces together */
ThisResult = new_STRING0(front_len + string(&ThisReplace)->len + back->len);
repl_len = repl_length(&ThisReplace);
ThisResult = new_STRING0(front_len + repl_len + back->len);
TRACE(("old %s front '%.*s', middle '%.*s', back '%.*s'\n",
indent(level),
front_len, front,
string(&ThisReplace)->len, string(&ThisReplace)->str,
back->len, back->str));
(int) front_len, front,
(int) repl_len, string(&ThisReplace)->str,
(int) back->len, back->str));
in_sval = ThisResult->str;
if (front_len) {
memcpy(in_sval, front, front_len);
in_sval += front_len;
}
if (string(&ThisReplace)->len) {
memcpy(in_sval, string(&ThisReplace)->str, string(&ThisReplace)->len);
in_sval += string(&ThisReplace)->len;
if (repl_len) {
memcpy(in_sval, string(&ThisReplace)->str, repl_len);
in_sval += repl_len;
}
if (back->len)
memcpy(in_sval, back->str, back->len);
@ -1330,6 +1357,7 @@ new_gsub(PTR re, int level)
char xbuff[2];
char *in_sval;
STRING *back;
size_t repl_len;
loop:
assert(level >= 0);
@ -1403,11 +1431,12 @@ new_gsub(PTR re, int level)
}
/* put the three pieces together */
ThisResult = new_STRING0(ThisFrontLen + string(&ThisReplace)->len + back->len);
repl_len = repl_length(&ThisReplace);
ThisResult = new_STRING0(ThisFrontLen + repl_len + back->len);
TRACE(("new %s front '%.*s', middle '%.*s', back '%.*s'\n",
indent(level),
(int) ThisFrontLen, ThisFront,
(int) string(&ThisReplace)->len, string(&ThisReplace)->str,
(int) repl_len, string(&ThisReplace)->str,
(int) back->len, back->str));
in_sval = ThisResult->str;
@ -1415,9 +1444,9 @@ new_gsub(PTR re, int level)
memcpy(in_sval, ThisFront, ThisFrontLen);
in_sval += ThisFrontLen;
}
if (string(&ThisReplace)->len) {
memcpy(in_sval, string(&ThisReplace)->str, string(&ThisReplace)->len);
in_sval += string(&ThisReplace)->len;
if (repl_len) {
memcpy(in_sval, string(&ThisReplace)->str, repl_len);
in_sval += repl_len;
}
if (back->len)
memcpy(in_sval, back->str, back->len);
@ -1448,7 +1477,7 @@ new_gsub(PTR re, int level)
/* set up for call to gsub() */
CELL *
bi_gsub(CELL * sp)
bi_gsub(CELL *sp)
{
CELL *cp; /* pts at the replacement target */
CELL sc; /* copy of replacement target */
@ -1463,6 +1492,14 @@ bi_gsub(CELL * sp)
TRACE_FUNC("bi_gsub", sp);
sp -= 2;
TRACE(("SP 0: "));
TRACE_CELL(sp);
TRACE(("SP 1: "));
TRACE_CELL(sp + 1);
TRACE(("SP 2: "));
TRACE_CELL(sp + 2);
if (sp->type != C_RE)
cast_to_RE(sp);
if ((sp + 1)->type != C_REPL && (sp + 1)->type != C_REPLV)
@ -1494,7 +1531,7 @@ bi_gsub(CELL * sp)
resul2 = old_gsub(sp->ptr, 0);
TRACE(("OLD ->'%.*s'\n", resul2->len, resul2->str));
TRACE(("OLD ->'%.*s'\n", (int) resul2->len, resul2->str));
free_STRING(target);
}
#endif
@ -1512,7 +1549,7 @@ bi_gsub(CELL * sp)
tc.ptr = (PTR) result;
#ifdef DEBUG_GSUB
TRACE(("NEW ->'%.*s'\n", result->len, result->str));
TRACE(("NEW ->'%.*s'\n", (int) result->len, result->str));
if (result->len != resul2->len || memcmp(result->str, resul2->str, result->len))
TRACE(("OOPS\n"));
#endif
@ -1551,7 +1588,7 @@ static unsigned repl_cnt; /* number of global replacements */
*/
static STRING *
gsub(PTR re, CELL * repl, char *target, size_t target_len, int flag)
gsub(PTR re, CELL *repl, char *target, size_t target_len, int flag)
{
char *front = 0, *middle;
STRING *back;
@ -1641,7 +1678,7 @@ gsub(PTR re, CELL * repl, char *target, size_t target_len, int flag)
/* set up for call to gsub() */
CELL *
bi_gsub(CELL * sp)
bi_gsub(CELL *sp)
{
CELL *cp; /* pts at the replacement target */
CELL sc; /* copy of replacement target */

7
mawk.h
View File

@ -1,6 +1,6 @@
/********************************************
mawk.h
copyright 2008-2012,2013 Thomas E. Dickey
copyright 2008-2013,2014 Thomas E. Dickey
copyright 1991-1995,1996 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: mawk.h,v 1.44 2013/08/03 13:04:24 tom Exp $
* $MawkId: mawk.h,v 1.46 2014/06/18 23:15:52 tom Exp $
* @Log: mawk.h,v @
* Revision 1.10 1996/08/25 19:31:04 mike
* Added work-around for solaris strtod overflow bug.
@ -231,9 +231,12 @@ extern void Trace(const char *,...) GCC_PRINTFLIKE(1,2);
#if OPT_TRACE > 0
extern void TraceCell(CELL *);
extern void TraceString(STRING *);
#define TRACE_CELL(cp) TraceCell(cp)
#define TRACE_STRING(cp) TraceString(cp)
#else
#define TRACE_CELL(cp) /* nothing */
#define TRACE_STRING(cp) /* nothing */
#endif
#if OPT_TRACE > 0

View File

@ -1,4 +1,4 @@
mawk-cur (1.3.4-20140605) unstable; urgency=low
mawk-cur (1.3.4-20140618) unstable; urgency=low
* configure-script updates

View File

@ -1,8 +1,8 @@
Summary: mawk - pattern scanning and text processing language
%define AppProgram mawk
%define AppVersion 1.3.4
%define AppRelease 20140605
# $MawkId: mawk.spec,v 1.27 2014/06/05 23:02:49 tom Exp $
%define AppRelease 20140618
# $MawkId: mawk.spec,v 1.28 2014/06/18 23:37:32 tom Exp $
Name: %{AppProgram}
Version: %{AppVersion}
Release: %{AppRelease}

View File

@ -11,9 +11,9 @@ the GNU General Public License, version 2, 1991.
*/
/*
* $MawkId: patchlev.h,v 1.50 2014/06/05 23:03:38 tom Exp $
* $MawkId: patchlev.h,v 1.51 2014/06/18 23:34:26 tom Exp $
*/
#define PATCH_BASE 1
#define PATCH_LEVEL 3
#define PATCH_STRING ".4"
#define DATE_STRING "20140605"
#define DATE_STRING "20140618"

View File

@ -1,6 +1,6 @@
/********************************************
re_cmpl.c
copyright 2008-2009,2010, Thomas E. Dickey
copyright 2008-2010,2014, Thomas E. Dickey
copyright 1991-1993,1994, 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: re_cmpl.c,v 1.22 2010/12/10 17:00:00 tom Exp $
* $MawkId: re_cmpl.c,v 1.25 2014/06/18 23:10:30 tom Exp $
* @Log: re_cmpl.c,v @
* Revision 1.6 1994/12/13 00:14:58 mike
* \\ -> \ on second replacement scan
@ -174,6 +174,7 @@ REPL_compile(STRING * sval)
char *xbuff;
CELL *cp;
TRACE(("REPL_compile(%.*s)\n", (int) sval->len, sval->str));
q = xbuff = (char *) zmalloc(sval->len + 1);
while (1) {
@ -230,12 +231,16 @@ REPL_compile(STRING * sval)
VCount j = 0;
while (j < count) {
TRACE(("SPLIT %d:", j));
TRACE_STRING(split_buff[j]);
TRACE(("\n"));
*sp++ = split_buff[j++];
USED_SPLIT_BUFF(j - 1);
}
cp->type = C_REPLV;
cp->vcnt = count;
TRACE(("... created C_REPLV count %d\n", count));
}
zfree(xbuff, sval->len + 1);
return cp;
@ -244,7 +249,7 @@ REPL_compile(STRING * sval)
/* free memory used by a replacement CELL */
void
repl_destroy(CELL * cp)
repl_destroy(CELL *cp)
{
register STRING **p;
VCount cnt;
@ -266,7 +271,7 @@ repl_destroy(CELL * cp)
/* copy a C_REPLV cell to another CELL */
CELL *
replv_cpy(CELL * target, CELL * source)
replv_cpy(CELL *target, CELL *source)
{
STRING **t, **s;
VCount cnt;
@ -336,7 +341,7 @@ repl_compile(STRING * sval)
p->cp = REPL_compile(sval);
found:
/* insert p at the front of the list */
/* insert p at the front of the list */
p->link = repl_list;
repl_list = p;
return p->cp;
@ -346,7 +351,7 @@ repl_compile(STRING * sval)
this is only used by da() */
char *
repl_uncompile(CELL * cp)
repl_uncompile(CELL *cp)
{
register REPL_NODE *p = repl_list;
@ -360,8 +365,7 @@ repl_uncompile(CELL * cp)
} else {
while (p) {
if (p->cp->type == C_REPLV &&
memcmp(cp->ptr, p->cp->ptr, cp->vcnt * sizeof(STRING *))
== 0)
memcmp(cp->ptr, p->cp->ptr, cp->vcnt * sizeof(STRING *)) == 0)
return p->sval->str;
else
p = p->link;
@ -381,7 +385,7 @@ repl_uncompile(CELL * cp)
*/
CELL *
replv_to_repl(CELL * cp, STRING * sval)
replv_to_repl(CELL *cp, STRING * sval)
{
register STRING **p;
STRING **sblock = (STRING **) cp->ptr;

14
trace.c
View File

@ -1,6 +1,6 @@
/********************************************
trace.c
copyright 2012, Thomas E. Dickey
copyright 2012,2014 Thomas E. Dickey
This is a source file for mawk, an implementation of
the AWK programming language.
@ -10,14 +10,12 @@ the GNU General Public License, version 2, 1991.
********************************************/
/*
* $MawkId: trace.c,v 1.5 2012/11/02 00:34:37 tom Exp $
* $MawkId: trace.c,v 1.7 2014/06/18 23:37:51 tom Exp $
*/
#include <stdarg.h>
#include <mawk.h>
static void TraceString(STRING *);
static FILE *trace_fp;
void
@ -37,7 +35,7 @@ Trace(const char *format,...)
}
void
TraceCell(CELL * cp)
TraceCell(CELL *cp)
{
TRACE(("cell %p ", (void *) cp));
if (cp != 0) {
@ -80,7 +78,7 @@ TraceCell(CELL * cp)
}
void
TraceFunc(const char *name, CELL * sp)
TraceFunc(const char *name, CELL *sp)
{
int nargs = sp->type;
int n;
@ -92,10 +90,10 @@ TraceFunc(const char *name, CELL * sp)
}
}
static void
void
TraceString(STRING * sp)
{
size_t limit = sp->len;
size_t limit = sp ? sp->len : 0;
size_t n;
TRACE(("\""));