X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=tPuy7oIixBqJFg2n5I6rpN0Rn0fGZGqglgC8cLskNAc=; b=P9YgogSq4X54+moHsWDU/Adzezqlobx1HcNzRoElzq3HHOfnQKnj6hDTLkdtFrpAan nN8DaS+VGb4jXGFHBHSCjg2ej0GVnfMZxe2uzZUz2ry1wjp6O8pueneapK6Ns+Xk8bVL kSFVkuinwV0YWGy6hXyviXx/F8m8+6Gc8nZYEBPzjDuDsDj4KSNbyMv0brpQo9ykjosR MqcJU0y8O/Jiw7f1Qko6+WtKxcMZkQyoEYD7yJuR1PEvshZCz3MmDZZEP2Kq+tXT2UST o5F0AQoa1G2drHjQfLGH5b02phz10BrGZi1gdWFxGh9Qm0pExRKwHbQPV1jNKJGJtNgO 7gMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=tPuy7oIixBqJFg2n5I6rpN0Rn0fGZGqglgC8cLskNAc=; b=d2nUgQkonU10Ddbt31sq9mrCdlmGAb6cCFIOFIBq2QKLgDuuxfJZC5zFGAuhFUePZL DpvdcF+UgQ5GPI9h4wwhDnyrWXNoX/Hori+Q6s7L6DljMSPC1QhlfChfHNuU3DgArBlG B4B3E5BKbGoRt7Ug3iwUCSxOSzvCe5M+T5Y2bfq2PEYaJJY5SqN0/oMTVTyHiRAK4kGC x/6v7IFtVRBFwkwF30+UhAa23Y5bMOAjCNNclh6xemJjz7mSM18kU2akcpzCLl43JdTl gAlGj5ve/tnnYBQwMtI7eLPFcPanxmOuXre6M+4z+49YAH2WygxIWXg5IjLbMMjrcVpY Qfyw== X-Gm-Message-State: AOAM532xPHbNZTuKrMmmVV7RV64SiZs8Fr+hXK+obA+wSNIYo/y3zs2o Nts9sy8vl+9614fr8aww5F3gExzAw4OgRkrhkeVBAiIi X-Google-Smtp-Source: ABdhPJyip32BpanIAcOd7Y5AJHjVS5hYz/BbfAfOwmWfijxMpreNoFdQ/hoeeFintEJZswlv3DOmUC6QrSJimtAU56g= X-Received: by 2002:a9d:5a8d:: with SMTP id w13mr16179515oth.145.1616854701172; Sat, 27 Mar 2021 07:18:21 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <83o8f4oftm.fsf@gnu.org> References: <83o8f4oftm DOT fsf AT gnu DOT org> From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" Date: Sat, 27 Mar 2021 17:18:20 +0300 Message-ID: Subject: Re: issue with popen and reading from stdout To: djgpp AT delorie DOT com Content-Type: text/plain; charset="UTF-8" Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 3/27/21, Eli Zaretskii (eliz AT gnu DOT org) [via djgpp AT delorie DOT com] wrote: > I don't think I understand what you mean by "extracted file has 0x0a > -> 0x0d 0x0a changes and corrupted". > > The above program's expected effect is to read what "unrar -p" emits > without any EOL conversions. Programs that run on MS-DOS/Windows > usually output CRLF end-of-line sequences (i.e. 0x0d + 0x0a), so the > program you show should: > > . read these CRLF EOLs without any conversion > . write each line to stdout OK, so it's possibly an issue with unrar itself > Whether 'fwrite' add another 0x0d to each line depends on the mode of > the stream 't'; if you open it in binary mode, I would expect to see > the same CRLF EOLs as what "unrar -p" emits. If 't' is in text mode, > you will see each line end with 0x0d 0x0d 0x0a, i.e. 2 CR characters > followed by a single newline. It's opened with "w+b" mode, like: fd = mkstemp(*filename); t = fdopen(fd, "w+b"); -- O.S.