delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/06/27/07:01:52

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:date:from:to:subject:message-id:mime-version
:content-type; q=dns; s=default; b=Wv5cY/DLT9z1OeGJ3N7KuTmPD3lAD
xMMdNm+5kaNK50cj5VpISBGBgcZMiBUHIQpqOpA+bWJlvX+hwYuDjOwNzd2SaBkz
bWFvPfXtVOSYMcHZWhTtAvUXxh8wcj2K3m+QGBHwR7xlXXA/9P+7BNzn592bgViZ
jOP0cvqzy17sDU=
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:date:from:to:subject:message-id:mime-version
:content-type; s=default; bh=6D3H0pWoGb+663rnf58TzhWz2ac=; b=TeD
MFcpv2jv9i1+EeF8ErUM2t+LYEX0obgbF6P4L9OEKM5I0/kai+fzdtAP8OK/jjtq
YY+LB8vs8sLyv8dQjkYPpR0j0ahn3ZI9HWpB3fhX897cPHCfx4x9TpRjfdVe8cBl
t7Z3fo2lzq+t4btEwqwr0utyFnXpsQCAOkfBVVos=
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.1 required=5.0 tests=BAYES_00,BODY_8BITS,GARBLED_BODY,RCVD_IN_DNSWL_NONE,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=L, HDKIM-Filter:OpenDKIM, HDKIM-Filter:Filter, HDKIM-Filter:v2.10.3
X-HELO: conssluserg-02.nifty.com
DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com w5RB1FGs013666
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1530097275; bh=jV0OG2clBmIjt1IMa9CY93NPZn1QFXHYXvFcV09/6nI=; h=Date:From:To:Subject:From; b=VPvc2c4zOkqZgvi7jFFh0k7MIX6lXBoIyxpEBEJHlZaCzht92lDrBeScNicyMzBp2 Y6oLBzN+CF9gPFa9mZ0rnyMDxNAO3+d74Q5TmUOEBmHx8AKjo1tjOhY+98D3YvKwM+ EQS18D7u4DkWuQiarS78a47wA+fwkMSNcJE9uwHGRCGCMmrBNzHj6LO5w0ilIV0nV7 9gHcS1+4PvltQMgn6LiHreXGzL8e/7CoqMhcXi8I687ometsUaj+ynYmiHMEJ+lv7m Lont1RlgfCkk8ZYDAeg+BYtzJ8teBmSwFLl8IAqsz9zuywqd6crLaXIDiF27EQqu2f 0u6uNvcBjO9dA==
Date: Wed, 27 Jun 2018 20:01:16 +0900
From: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
To: cygwin AT cygwin DOT com
Subject: perror() changes the orientation of stderr to byte-oriented mode if stderr is not oriented yet.
Message-Id: <20180627200116.ddd80f78597f8fd3f09d5d4b@nifty.ne.jp>
Mime-Version: 1.0
X-IsSubscribed: yes
Note-from-DJ: This may be spam

--Multipart=_Wed__27_Jun_2018_20_01_16_+0900_vk0gE2/gPfTfn3vO
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

POSIX states:
The perror() function shall not change the orientation of the standard
error stream.

However, cygwin perror() function changes the orientation of stderr to
byte-oriented mode if stderr is not oriented yet.

Simple test case (chkperror.c) attached checks this behavior.

Expected result:
0
äöü: Invalid argument
0
äöü
1
äöü: Invalid argument

However, cygwin result:
0
äöü: Invalid argument
-1
â–’â–’â–’
-1
äöü: Invalid argument

I have made a patch to solve this problem, attached. However, I am not
sure that calling _write_r() here is correct manner. I will appreciate
if anyone familiar with libc code comment or make suggestions.

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>

--Multipart=_Wed__27_Jun_2018_20_01_16_+0900_vk0gE2/gPfTfn3vO
Content-Type: application/octet-stream;
 name="0001-Fix-a-bug-of-perror-which-changes-the-orientation-of.patch"
Content-Disposition: attachment;
 filename="0001-Fix-a-bug-of-perror-which-changes-the-orientation-of.patch"
Content-Transfer-Encoding: base64

RnJvbSBjZjU2Y2YwZWVmOGQ0OGNhNTQzYWFjOTZkNTdmZGZlYmUzZTg3Njdh
IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBUYWthc2hpIFlhbm8g
PHRha2FzaGkueWFub0BuaWZ0eS5uZS5qcD4KRGF0ZTogV2VkLCAyNyBKdW4g
MjAxOCAxOToyNjoxNSArMDkwMApTdWJqZWN0OiBbUEFUQ0hdIEZpeCBhIGJ1
ZyBvZiBwZXJyb3IoKSB3aGljaCBjaGFuZ2VzIHRoZSBvcmllbnRhdGlvbiBv
Zgogc3RkZXJyLgoKKiBwZXJyb3IuYzogRml4IHRoZSBwcm9ibGVtIHRoYXQg
cGVycm9yKCkgY2hhbmdlcyB0aGUgb3JpZW50YXRpb24KICBvZiBzdGRlcnIg
dG8gYnl0ZS1vcmllbnRlZCBtb2RlIGlmIHN0ZGVyciBpcyBub3Qgb3JpZW50
ZWQgeWV0LgotLS0KIG5ld2xpYi9saWJjL3N0ZGlvL3BlcnJvci5jIHwgMjUg
KysrKysrKysrKysrKysrKysrKysrLS0tLQogMSBmaWxlIGNoYW5nZWQsIDIx
IGluc2VydGlvbnMoKyksIDQgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEv
bmV3bGliL2xpYmMvc3RkaW8vcGVycm9yLmMgYi9uZXdsaWIvbGliYy9z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gICAgZnB1dHMgKCI6ICIsIF9zdGRlcnJfciAocHRyKSk7CisgICAg
ICB3cml0ZV9lcnIgKHB0ciwgcyk7CisgICAgICB3cml0ZV9lcnIgKHB0ciwg
IjogIik7CiAgICAgfQogCiAgIGlmICgoZXJyb3IgPSBfc3RyZXJyb3JfciAo
cHRyLCBwdHItPl9lcnJubywgMSwgJmR1bW15KSkgIT0gTlVMTCkKLSAgICBm
cHV0cyAoZXJyb3IsIF9zdGRlcnJfciAocHRyKSk7CisgICAgd3JpdGVfZXJy
IChwdHIsIGVycm9yKTsKIAotICBmcHV0YyAoJ1xuJywgX3N0ZGVycl9yIChw
dHIpKTsKKyAgd3JpdGVfZXJyIChwdHIsICJcbiIpOwogfQogCiAjaWZuZGVm
IF9SRUVOVF9PTkxZCi0tIAoyLjE3LjAKCg==

--Multipart=_Wed__27_Jun_2018_20_01_16_+0900_vk0gE2/gPfTfn3vO
Content-Type: text/x-csrc;
 name="chkperror.c"
Content-Disposition: attachment;
 filename="chkperror.c"
Content-Transfer-Encoding: quoted-printable

#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#include <errno.h>

int main()
{
	setlocale(LC_CTYPE, "de_DE.UTF-8");
	errno =3D EINVAL;
	printf("%d\n", fwide(stderr, 0));
	perror("=C3=A4=C3=B6=C3=BC");
	printf("%d\n", fwide(stderr, 0));
	fwprintf(stderr, L"=C3=A4=C3=B6=C3=BC\n");
	printf("%d\n", fwide(stderr, 0));
	perror("=C3=A4=C3=B6=C3=BC");
	return 0;
}


--Multipart=_Wed__27_Jun_2018_20_01_16_+0900_vk0gE2/gPfTfn3vO
Content-Type: text/plain; charset=us-ascii


--
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
--Multipart=_Wed__27_Jun_2018_20_01_16_+0900_vk0gE2/gPfTfn3vO--

- Raw text -


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