delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/09/11/07:53:01

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:to:references:subject
:content-type; q=dns; s=default; b=exqDRR8Eagim95Xe68TvAuj7JqVJE
67YOKzK4h0B87BdGMncbxBiNtwyJ1Agoi0MArYuSXY3rFRk4IlHa7cl/i+Yga5wx
C886gagNugFpMQBD7ePR5eGr5M4UHnnf/QKGapvMeT1ks6cwYaibo+VCVAEG+FZb
Mt/cfXGdxrBca0=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:to:references:subject
:content-type; s=default; bh=9i2yOR6qZ3ZTZr4i/q8x2iBEHJg=; b=LJ1
RSx8MdUy5eKEAgDYJbS+Pw7zkOwXLz4Em7DmpxMu4UMc+IwIrUlmS+pgIbR9CPcG
8K0huByeP2eYTq/evGwXJPT6k37hohVpeYeBa1pZDqKrt+NM6hAju6CWTlpE52+X
DJcw1UOE9ZOmdrlqIoVzGrVoJrTwSUGoeiJClzCU=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=Perl, H*UA:github.com, Troy, H*M:1c69fb81
X-HELO: mail-oi1-f172.google.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:to:references:subject:user-agent; bh=sIY38jtTA76nEQDi7KXyIHpWJXrDdo8zIcX2zU2wClI=; b=PI4PeMfTf38yb8Tvpd7Ibh15Sc0EJ8jl2UjUAXilwDarOp7vn2TS8quAXVOPfF5ymo ky4TRBC1GyyVOuEpiy3++30wlHWPiLC3PNNdohwAS/9r56YEHYAqTg9EdsgijjLUYj7f YFLNcDKFTN0AHH2+Cb34YSJno7RGg9H2rLfTQL0QLb8MT2veEaF5SKVFiSLi+b2U5S0y bi/9Ylp/nJnaBzET8Qh8fWCoiTtUpi59MJFHuZxY3wLOgIDdfo7SxSer1ANnHLrCFSLu mCuWbbh3BB9iKp4GY9KdHOQJ6zcXAK0+PL6ex8s3cM8SmXwjpEZjvwr3ABdntlMsVgfW /xvQ==
Message-ID: <5d78dfe7.1c69fb81.686f1.9f87@mx.google.com>
Date: Wed, 11 Sep 2019 04:52:07 -0700 (PDT)
From: Steven Penny <svnpenn AT gmail DOT com>
To: cygwin AT cygwin DOT com
References: <CAC9BAENxZs7ZwSHz1Xq0DAxP0tS6R4fUQ6Rv_tEG_qrCsOZTew AT mail DOT gmail DOT com>
Subject: Re: Where is igawk and why doesn't @include replicate this feature?
User-Agent: Suede Mail/2.8.0 (github.com/cup/suede)

On Wed, 11 Sep 2019 16:54:49, Troy Kenah wrote:
> I used to embed @include junk.awk statements to reduce repetitive code but
> this no longer works. These were files were not functions, simply code
> snippets; this is the type of error I am now seeing:
> 
> gawk: get_FY2019Q1OIC.awk:28: @include "../inc/segments.awk"
> gawk: get_FY2019Q1OIC.awk:28:  ^ syntax error
> gawk: get_FY2019Q1OIC.awk:36:         fromdate=mktime("2019 09 01 00 00 00")
> gawk: get_FY2019Q1OIC.awk:36:                         ^ syntax error
> gawk: get_FY2019Q1OIC.awk:36:         fromdate=mktime("2019 09 01 00 00 00")
> gawk: get_FY2019Q1OIC.awk:36:
>  ^ 0 is invalid as number of arguments for mktime

Works fine here:

    $ gawk --version
    GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)

    $ cat one.awk
    function f1(n1) {
       return n1 + 10
    }

    $ cat two.awk
    @include "one.awk"
    BEGIN {
       print f1(20)
    }

    $ unset POSIXLY_CORRECT
    $ gawk -f two.awk
    30

Finally, I would make a suggestion. "@include" is not POSIX, so if you find
yourself relying on something like this more and more, it might be better to
switch to a proper programming language. Something like Perl, Lua or Tcl.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019