SEND-PR: -*- send-pr -*-
SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as
SEND-PR: will all comments (text enclosed in `<' and `>').
SEND-PR: 
SEND-PR: Choose from the following categories:
SEND-PR:
SEND-PR: contrib cvs doc pcl-cvs portability 
SEND-PR: 
SEND-PR:
To: [EMAIL PROTECTED]
Subject: cvs-1.10.8/lib/yesno.c
From: [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
X-send-pr-version: 3.2


>Submitter-Id:   net
>Originator:     [EMAIL PROTECTED]
>Organization: Stellacore Corporation
net
>Confidential:  no 
>Synopsis:      yesno() always and instantly returns 'no' (e.g. after 'cvs release' 
>command)
>Severity:      <[ non-critical | serious | critical ] (one line)> serious
>Priority:      <[ low | medium | high ] (one line)> high
>Category:      cvs <name of the product (one line)>
>Class:         <[ sw-bug | doc-bug | change-request | support ] (one line)> sw-bug
>Release:       cvs-1.10.8
>Environment:
        <machine, os, target, libraries (multiple lines)>
Pentium-III
Linux 2.2.14-15mdksmp #1 SMP Tue Jan 4 21:36:33 CET 2000 i686 unknown
(Mandrake 7.0)
gcc --version ==> 2.95.2
ldd /usr/bin/cvs
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x4001b000)
        libc.so.6 => /lib/libc.so.6 (0x40048000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)                   

System: Linux 2.2.14-15mdksmp #1 SMP Tue Jan 4 21:36:33 CET 2000 i686 unknown
Architecture: i686

>Description:
        <precise description of the problem (multiple lines)>
Symptom: First detected after issue of 'cvs release ...' command. This produced
(for test case at hand)

 cvs release -d proglib/
? myNewFile
M proglib.txt
You have [1] altered files in this repository.
Are you sure you want to release (and delete) directory `proglib/': ** `release'
 aborted by user choice.

The issues is that the 'aborted' message occurs spontaneously - withOUT the
opportunity to type anything.

This is related to the behavior of 'getchar()' within the '..../lib/yesno.c'
module as follows (Bug in getchar()?). The distributed code for yesno.c
includes:

---
  c = getchar ();
  rv = (c == 'y') || (c == 'Y');
  while (c != EOF && c != '\n')
    c = getchar ();                                                             
---

On this system, the first getchar() returns EOF - e.g. it is NON-BLOCKING.
Therefore, 'rv' is set immediately to zero (an 'answer' of NO) and the 
while loop is never executed. As a result, yes/no immediately and always
returns a 'NO' (zero) value.

On this system, I hacked around this by replacing the above lines of code
with: (note EOFs are therefore always ignored)

---
  rv = 0; /* assume 'no' */
  while (1)
  {
    c = getchar ();
 
    /* skip initial EOF (bug in getchar()?) */
    if (c == EOF)
       continue;
 
    /* terminate answer entry at new line */
    if (c == '\n')
       break;
 
    /* accept string if first character is a 'y' or 'Y' */
    if ( (nchar == 0) && ((c == 'y') || (c == 'Y')) )
      rv = 1;
 
    /* increment character count - (no longer possible to get yes condition) */
    nchar++;
  }                                                                             
---


>How-To-Repeat:
        <code/input/activities to reproduce the problem (multiple lines)>
Apparently, by running CVS (1.10.7 or 1.10.8) on a fresh Mandrake 7.0 linux
release.
>Fix:
        <how to correct or work around the problem, if known (multiple lines)>
Ref code above - or "fix" the getchar() behavior somehow.

Reply via email to