From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32083 invoked from network); 16 May 2020 16:28:24 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 16 May 2020 16:28:24 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 6F6F19C98F; Sun, 17 May 2020 02:28:22 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 02D079C5E5; Sun, 17 May 2020 02:28:06 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Yu2VhMFn"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 8CFD79C5E5; Sun, 17 May 2020 02:28:04 +1000 (AEST) Received: from mail-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) by minnie.tuhs.org (Postfix) with ESMTPS id 2AB0D9C5E4 for ; Sun, 17 May 2020 02:28:04 +1000 (AEST) Received: by mail-vs1-f42.google.com with SMTP id g2so3095906vsb.4 for ; Sat, 16 May 2020 09:28:04 -0700 (PDT) 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 :content-transfer-encoding; bh=Yukt5omD2NDXdjuaZxPOuwBrwDVrCE6r8dI1SwgSsgY=; b=Yu2VhMFn59kYDow/9UaGL9erPXR7UsTsS4qfM0PfQ8cTray3efg1qmtMQzJPgLu8FU 99b11DFxZCLl5q/WdtroHeyYjVtwltTuXvBGGaFwmWqWal7V5sV5UKS5x9QZmX4L+aTR /bdZm8dWdGmQHYUduZTNBo3FFSBPqRxJv8hznC74iFPgIHAX3miH/5mvRwE8dKa4t++U 4SytA2dDgS3upbMYNUgwt1fC2aWehf51MJY6lnwZqU+35FMYw2RKpPLK2tF2tdl8pr56 MfYbYIr/svP6A7GwmNSeyyt4ZQtCSfImLhYAjNbXsF0KiNOYF8LdZb8Md7++d+US/d4V N5Sw== 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:content-transfer-encoding; bh=Yukt5omD2NDXdjuaZxPOuwBrwDVrCE6r8dI1SwgSsgY=; b=Ty08JB53qndokU6MZoidwWtt/91/uIeqqEBjOjbEw3tccV8FZsBitnAun2LuXdZ+6T qjVG1bvAUguLK3rOoy7HA9J83IOv9esTXhygTicBcGe4WgKzQGLFGEHHlD5zsxfWDHFF uI2mpQBeY7qXc+yP8VQy2RbAJX0jSyAnRDf4yaksGO+dQXNANIAn1HnHpx0h3f40qFkg BKzuqPZYEerWas8AXQnzLQqrfFGeOUopiYWsVLBvgYRYOZgj77BkfBc7idqzNrq9s6oe NMpfP7hdYr9N3mKLpyrK/qUND1we6wJP7hehdHKvf3Bd0yQ16XHUYrP+pDuq9hXuUP7+ gMoA== X-Gm-Message-State: AOAM531ZHfHK16Ixi8HNVwqnjF+lbkIcNH4ddxmC9QsdhUtKH21I3zC/ OzWSXSvcAoTfmn8tv/RDc4sWRnJfgzpONEWazCjXVQ== X-Google-Smtp-Source: ABdhPJwBM1SO2vlMoHC1tBh7qOTQ5bad0/DiNuJpRhhV4/dW/g2B64x0H5eL4e1Am71Xe9Gk+5YbekX5e8lOaXbwJIo= X-Received: by 2002:a05:6102:201b:: with SMTP id p27mr6558566vsr.101.1589646483129; Sat, 16 May 2020 09:28:03 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:4717:0:0:0:0:0 with HTTP; Sat, 16 May 2020 09:28:01 -0700 (PDT) In-Reply-To: References: <202005141841.04EIfvEZ063529@tahoe.cs.Dartmouth.EDU> <20200515150122.GF30160@mcvoy.com> <014001d62af3$9cc209b0$d6461d10$@ronnatalie.com> From: Paul Winalski Date: Sat, 16 May 2020 12:28:01 -0400 Message-ID: To: The Eunuchs Hysterical Society Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [TUHS] v7 K&R C X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" > On Fri, May 15, 2020 at 4:02 PM wrote: > >Unfortunately, if c is char on a machine with unsigned chars, or it=E2=80= =99s of >type unsigned char, the EOF will never be detected. > > - while ((c =3D getchar()) !=3D EOF) if (c =3D=3D '\n') { /* entire re= cord is now there */ The function prototype for getchar() is: int getchar(void); It returns an int, not a char. In all likelihood this is specifically *because* EOF is defined as -1. The above code works fine if c is an int. One always has to be very careful when doing a typecast of a function return value. -Paul W.