From owner-freebsd-current Tue Feb 11 07:13:22 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id HAA25152 for current-outgoing; Tue, 11 Feb 1997 07:13:22 -0800 (PST) Received: from hydrogen.nike.efn.org (resnet.uoregon.edu [128.223.170.28]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA25124 for ; Tue, 11 Feb 1997 07:13:15 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by hydrogen.nike.efn.org (8.8.4/8.8.4) with SMTP id HAA01184; Tue, 11 Feb 1997 07:12:28 -0800 (PST) Date: Tue, 11 Feb 1997 07:12:27 -0800 (PST) From: John-Mark Gurney Reply-To: John-Mark Gurney To: Giles Lean cc: freebsd-gnats-submit@freefall.freebsd.org, FreeBSD Current Subject: Re: bin/777 patch had problems with closed tty... In-Reply-To: <199702111136.WAA12347@nemeton.com.au> Message-ID: X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Tue, 11 Feb 1997, Giles Lean wrote: > > On Tue, 11 Feb 1997 00:30:02 -0800 (PST) John-Mark Gurney wrote: > > > comments? is it ok if we change the default?? > > > > I don't like changing the default. I'd rather see no fix than do > this. > > I sent in an alternative patch that is ugly but does solve the problem > without much code change. heh... I see what you mean... well... I think I have a patch that will please every one :)... basicly what this does is adds a return value to ask which you can check... ask will now return 0 if there was an "error" when reading... then you can check this return value and if it's 0 know that you should do something that will continue processesing... else it will return 1 meaning success... I've also modified the 'default' fall back case to return 0 for an error also.. that way it actually fixes the problem else it would still exist... anybody have problems with this patch? here's the patch: Index: pch.c =================================================================== RCS file: /usr/cvs/src/gnu/usr.bin/patch/pch.c,v retrieving revision 1.8 diff -c -r1.8 pch.c *** pch.c 1996/04/12 11:37:32 1.8 --- pch.c 1997/02/11 15:00:09 *************** *** 231,239 **** filearg[0] = fetchname(buf, 0, FALSE); } if (filearg[0] == Nullch) { ! ask1("No file found--skip this patch? [n] "); ! if (*buf != 'y') { ! continue; } if (verbose) say1("Skipping patch...\n"); --- 231,240 ---- filearg[0] = fetchname(buf, 0, FALSE); } if (filearg[0] == Nullch) { ! if (ask1("No file found--skip this patch? [n] ")) { ! if (*buf != 'y') { ! continue; ! } } if (verbose) say1("Skipping patch...\n"); Index: util.c =================================================================== RCS file: /usr/cvs/src/gnu/usr.bin/patch/util.c,v retrieving revision 1.2 diff -c -r1.2 util.c *** util.c 1995/05/30 05:02:37 1.2 --- util.c 1997/02/11 15:08:12 *************** *** 227,233 **** /* Get a response from the user, somehow or other. */ ! void ask(pat,arg1,arg2,arg3) char *pat; long arg1,arg2,arg3; --- 227,233 ---- /* Get a response from the user, somehow or other. */ ! int ask(pat,arg1,arg2,arg3) char *pat; long arg1,arg2,arg3; *************** *** 260,266 **** } else { /* no terminal at all--default it */ buf[0] = '\n'; ! r = 1; } if (r <= 0) buf[0] = 0; --- 260,268 ---- } else { /* no terminal at all--default it */ buf[0] = '\n'; ! buf[1] = 0; ! say1(buf); ! return 0; /* signal possible error */ } if (r <= 0) buf[0] = 0; *************** *** 268,273 **** --- 270,280 ---- buf[r] = '\0'; if (!tty2) say1(buf); + + if (r <= 0) + return 0; /* if there was an error, return it */ + else + return 1; } #endif /* lint */ Index: util.h =================================================================== RCS file: /usr/cvs/src/gnu/usr.bin/patch/util.h,v retrieving revision 1.2 diff -c -r1.2 util.h *** util.h 1995/05/30 05:02:38 1.2 --- util.h 1997/02/11 14:49:19 *************** *** 86,92 **** void say(); void fatal(); void pfatal(); ! void ask(); char *savestr(); void set_signals(); void ignore_signals(); --- 86,92 ---- void say(); void fatal(); void pfatal(); ! int ask(); char *savestr(); void set_signals(); void ignore_signals(); John-Mark gurney_j@efn.org http://resnet.uoregon.edu/~gurney_j/ Modem/FAX: (541) 683-6954 (FreeBSD Box) Live in Peace, destroy Micro$oft, support free software, run FreeBSD (unix)