gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, master, updated. 8eb45b02e704c9586697000


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. 8eb45b02e704c95866970005fe771e3507fb935c
Date: Sun, 24 Apr 2011 09:46:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, master has been updated
       via  8eb45b02e704c95866970005fe771e3507fb935c (commit)
       via  203dfc888be3f45d3f70c9cdb91e870ae7796257 (commit)
      from  6cf1cd84870f4405143410585cc4e3e7f719f8f5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=8eb45b02e704c95866970005fe771e3507fb935c

commit 8eb45b02e704c95866970005fe771e3507fb935c
Author: Arnold D. Robbins <address@hidden>
Date:   Sun Apr 24 12:45:47 2011 +0300

    Patch from John, update man page.

diff --git a/ChangeLog b/ChangeLog
index 5fcbb96..ed69432 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Apr 24 12:43:49 2011  John Haque      <address@hidden>
+
+       * array.c (sort_user_func): Fix return value to match the
+       documentaion.
+       (sort_selection): Make user-specified comparison function with
+       the same name override default "unsorted" specification.
+
 Fri Apr 22 16:05:27 2011  John Haque      <address@hidden>
 
        * array.c (sort_user_func): New routine to handle user-defined
diff --git a/array.c b/array.c
index 32b8506..1bf6a06 100644
--- a/array.c
+++ b/array.c
@@ -1371,8 +1371,8 @@ static int
 sort_user_func(const void *p1, const void *p2)
 {
        const NODE *t1, *t2;
-       NODE *idx1, *idx2, *val1, *val2, *r;
-       int ret;
+       NODE *idx1, *idx2, *val1, *val2;
+       AWKNUM ret;
        INSTRUCTION *code;
        extern int exiting;
 
@@ -1403,11 +1403,9 @@ sort_user_func(const void *p1, const void *p2)
                gawk_exit(exit_val);
 
        /* return value of the comparison function */
-       r = POP_SCALAR();
-       ret = (int) force_number(r);
-       DEREF(r);
+       POP_NUMBER(ret);
 
-       return ret;
+       return (ret < 0.0) ? -1 : (ret > 0.0);
 }
 
 
@@ -1522,6 +1520,14 @@ sort_selection(NODE *sort_str, SORT_CTXT sort_ctxt)
                allparts |= bval;
        }
 
+       if (allparts == Unsorted) {
+               NODE *f;
+               /* user-defined function overrides default */
+
+               if ((f = lookup(sort_str->stptr)) != NULL && f->type == 
Node_func)
+                       return -1;
+       }
+
        /* num_words <= 3 */
        return (allparts & INDEX_MASK);
 
diff --git a/doc/gawk.1 b/doc/gawk.1
index 629899b..3fdf560 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -1098,6 +1098,25 @@ Supported values are
 \fB"unsorted"\fR.
 The order specification words can be truncated, or omitted (provided
 that at least one is present), or given in any order.
+The value can also be the name of any comparison function defined
+as follows:
+.PP
+.RS
+\fBfunction cmp_func(i1, v1, i2, v2)\fR
+.RE
+.PP
+where
+.I i1
+and
+.I i2
+are the indices, and
+.I v1
+and
+.I v2
+are the
+corresponding values of the two elements being compared.
+It should return a number less than, equal to, or greater than 0,
+depending on how the elements of the array are to be ordered.
 .TP
 \fBPROCINFO["version"]\fP
 the version of
@@ -2475,6 +2494,9 @@ Valid values for
 .I how
 are "ascending string", "ascending number",
 "descending string" and "descending number".
+It can also be the name of a user-defined
+comparison function as described in
+\fBPROCINFO["sorted_in"]\fR.
 .TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n"
 \fBasorti(\fIs \fR[\fB, \fId\fR [\fB, \fIhow\fR] ]\fB)\fR
 Return the number of elements in the source

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=203dfc888be3f45d3f70c9cdb91e870ae7796257

commit 203dfc888be3f45d3f70c9cdb91e870ae7796257
Author: Arnold D. Robbins <address@hidden>
Date:   Sun Apr 24 12:39:13 2011 +0300

    Update pc/Makefile.tst.

diff --git a/pc/ChangeLog b/pc/ChangeLog
index 532ea8b..42210d1 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+Sun Apr 24 11:54:58 2011  Scott Deifik         <address@hidden>
+
+       * Makefile.tst: Sync with mainline version.
+
 Fri Apr  1 11:50:59 2011  Arnold D. Robbins  <address@hidden>
 
        * config.h (ISATTY): Remove definition.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 5b83ec0..e7fe594 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -46,7 +46,7 @@
 # or "make check extra" (with DJGPP Make) should run successfully.
 
 # The Bash shell (compiled with djgpp) works very well with the
-# MSC & djgpp-compiled gawks.  It is currently the recommended shell to use
+# djgpp-compiled gawk.  It is currently the recommended shell to use
 # for testing, along with DJGPP make.  See README.pc for 
 # more information on OS/2 and DOS shells.
 
@@ -126,13 +126,15 @@ BASIC_TESTS = addcomma anchgsub argarray arrayparm 
arrayprm2 arrayprm3 \
        aryprm8 arysubnm asgext awkpath back89 backgsub childin clobber \
        closebad clsflnam compare compare2 concat1 concat2 concat3 concat4 \
        convfmt datanonl defref delarpm2 delarprm delfunc dynlj eofsplit \
+       exit \
        exitval1 exitval2 fcall_exit fcall_exit2 fldchg fldchgnf fnamedat \
        fnarray fnarray2 fnaryscl fnasgnm fnmisc fordel forref forsimp \
        fsbs fsrs fsspcoln fstabplus funsemnl funsmnam funstack getline \
        getline2 getline3 getlnbuf getnr2tb getnr2tm gsubasgn gsubtest gsubtst2 
\
        gsubtst3 gsubtst4 gsubtst5 gsubtst6 hex hsprint inputred intest intprec 
iobug1 \
        leaddig leadnl litoct longsub longwrds manglprm math membug1 messages \
-       minusstr mmap8k mtchi18n nasty nasty2 negexp negrange nested nfldstr 
nfneg \
+       minusstr mmap8k mtchi18n nasty nasty2 negexp negrange nested next \
+       nfldstr nfneg \
        nfset nlfldsep nlinstr nlstrina noeffect nofile nofmtch noloop1 \
        noloop2 nonl noparms nors nulrsend numindex numsubstr octsub ofmt \
        ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf paramdup paramres \
@@ -150,11 +152,13 @@ BASIC_TESTS = addcomma anchgsub argarray arrayparm 
arrayprm2 arrayprm3 \
 UNIX_TESTS = fflush getlnhd localenl pid pipeio1 pipeio2 poundbang space 
strftlng
 GAWK_EXT_TESTS = \
        aadelete1 aadelete2 aarray1 aasort aasorti \
+       arraysort \
        argtest backw badargs beginfile1 binmode1 clos1way \
        devfd devfd1 devfd2 dumpvars \
        fieldwdth fpat1 funlen fsfwfs fwtest fwtest2 gensub gensub2 getlndir \
        gnuops2 gnuops3 gnureops \
        icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall lint \
+       lintwarn \
        lintold manyfiles match1 match2 match3 mbstr1 nondec nondec2 patsplit \
        posix profile1 profile2 profile3 printfbad1 printfbad2 \
        procinfs rebuf regx8bit reint reint2 rsstart1 rsstart2 rsstart3 \
@@ -312,7 +316,6 @@ compare::
 inftest::
        @echo $@
        @echo This test is very machine specific...
-       @echo This sometimes seems to cause problems for MSC gawk.
        @echo Expect inftest to fail with DJGPP.
        @$(AWK) -f $(srcdir)/inftest.awk | sed "s/inf/Inf/g" >_$@
        @-$(CMP) $(srcdir)/inftest.ok _$@ && rm -f _$@
@@ -733,6 +736,16 @@ profile3:
        @$(PGAWK) -f $(srcdir)/address@hidden > /dev/null
        @sed 1,2d < awkprof.out > _$@; rm awkprof.out
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+next:
+       @echo $@
+       @-AWK="$(AWKPROG)" $(srcdir)/address@hidden > _$@ 2>&1
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
+exit:
+       @echo $@
+       @-AWK="$(AWKPROG)" $(srcdir)/address@hidden > _$@ 2>&1
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 Gt-dummy:
 # file Maketests, generated from Makefile.am by the Gentests program
 addcomma:
@@ -1603,6 +1616,11 @@ aasorti:
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
 
+arraysort:
+       @echo arraysort
+       @AWKPATH=$(srcdir) $(AWK) -f address@hidden  >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
+       @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
 backw:
        @echo backw
        @AWKPATH=$(srcdir) $(AWK) -f address@hidden  < $(srcdir)/address@hidden 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog       |    7 +++++++
 array.c         |   18 ++++++++++++------
 doc/gawk.1      |   22 ++++++++++++++++++++++
 pc/ChangeLog    |    4 ++++
 pc/Makefile.tst |   24 +++++++++++++++++++++---
 5 files changed, 66 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]