delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/07/12/10:44:35

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:reply-to:subject:to:references:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=QKAnmkERTJpdmITi
b5MrgPwOrWrDU/0ewG6BV003HivUm/h49Tmxhje64m+D9feO1H5zNpP/Q4LykLPF
PmjrHp60150lAZr0rerU2jqOBIOXewTd2rMz3goLpnjTatYK+hK9hB134BVgqub7
lg07pTJ/cf1uWv8l/zluXiltbMA=
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:reply-to:subject:to:references:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=hIT+iVlKmNclEK2mYDvPxO
Jag/M=; b=PWhMSm6zb9BW/bjFW/u+tqa0fgfZoIY3gQtQqGWScauh5EZ/Z75dNE
ZVGrh2iZwiVltI32hX0mZnTWUuZAbjVeLVacHV/PcItia3pg2YggYlJ8OsX9zbpw
+3HektggNmu78yZm3BnmRpIIofkHhu+EfeYmQB7ZTsqNrPVibPnX8=
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=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=houder, Houder, Specifying
X-HELO: smtp-out-so.shaw.ca
Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca
Subject: Re: Possible issue with gawk 5.0.1-1: Getting new warnings
To: cygwin AT cygwin DOT com
References: <CAGtwZuYLXDHFiAHGVYw8s+jqt0bNtGMpy+6fOSiqjZddazXZew AT mail DOT gmail DOT com> <efc25bf20057e107ae8fbce02dd91020 AT smtp-cloud9 DOT xs4all DOT net>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Openpgp: preference=signencrypt
Message-ID: <c2a2108b-eab3-369b-b186-bc9b9c2ea553@SystematicSw.ab.ca>
Date: Fri, 12 Jul 2019 08:43:34 -0600
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <efc25bf20057e107ae8fbce02dd91020@smtp-cloud9.xs4all.net>
X-IsSubscribed: yes

On 2019-07-12 04:47, Houder wrote:
> On Thu, 11 Jul 2019 11:51:09, Vipul P  wrote:
>> Here is a sample script to invoke awk:
>> $ cat ./gawk_error.sh
>> #!/bin/sh
>> echo "This:is:a:colon:separated:line:%%%:" | awk '{
>>   gsub("\\%", "%25", $0);
>>   gsub("\\:", "%3A", $0);
>>   print
>>   }'
> gsub(regexp, replacement[, target])
> echo "This:is:a:colon:separated:line:%%%:" | awk '{
>   gsub(/%/, "%25");
>   gsub(/:/, "%3A");
>   print
>   }'
>> If I invoke it with gawk 5.0.1-1, I see warnings as below:
>> $ uname -a
>> CYGWIN_NT-10.0 MyPC 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
>> $ awk -V
>> GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
>> Copyright (C) 1989, 1991-2019 Free Software Foundation.
>> $ ./gawk_error.sh
>> awk: cmd. line:2: (FILENAME=- FNR=1) warning: regexp escape sequence `\%'
>> is not a known regexp operator
>> awk: cmd. line:3: (FILENAME=- FNR=1) warning: regexp escape sequence `\:'
>> is not a known regexp operator
>> This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A
> I am not surprised to see these specific warnings ...
> See 3.2 (escape sequences) of GAWK: Effective AWK programming.
>> This script runs without any warnings with older versions of gawk:
>     https://cygwin.com/ml/cygwin/2019-04/msg00095.html
>     ( [ANNOUNCEMENT] gawk 5.0.0-1 )
>> The script runs without any warnings on Linux and other Unix variants.
> Using version 5 of gawk?
>> Is this a regression in gawk 5.0.1-1 on Cygwin ?
> Not very likely, as Corinna V. uses the tarball provided by Arnold R.

The first gsub argument is a regexp, so using a quoted string it must follow the
rules for a computed regexp: either "%"/":" to match characters alone or
"\\\\%"/"\\\\:" for characters preceded by backslash "\", as you wish.
Specifying only a single backslash regexp /\x/ or double backslash string "\\x",
the character must be a regexp special or it generates a warning message.

$ awk '{gsub("%", "%25", $0);gsub(":", "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A
$ awk '{gsub("\\\\%", "%25", $0);gsub("\\\\:", "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This:is:a:colon:separated:line:%%%:
$ awk '{gsub(/%/, "%25", $0);gsub(/:/, "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A
$ awk '{gsub(/\\%/, "%25", $0);gsub(/\\:/, "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This:is:a:colon:separated:line:%%%:

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
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