char *def_val;
int phone_num; /* True if this must contain only digits */
{
- char buf[BUFSIZ];
+ static char buf[BUFSIZ];
int ok = FALSE;
char *result;
int i;
{
ok = TRUE;
printf("%s [%s]: ", question, def_val);
- (void) fgets(buf, sizeof(buf), stdin);
+ if (fgets(buf, sizeof(buf), stdin) == NULL)
+ leave(0);
buf[strlen(buf) - 1] = NULL;
if (strlen(buf) == 0)
result = def_val;
}
/* Remove dashes if necessary */
- if (dashes) {
+ if (dashes && result == buf) {
char *tmp1, *tmp2;
- result = strsave(buf);
- tmp1 = (char *)buf;
- tmp2 = result;
+ tmp1 = tmp2 = (char *)buf;
do {
if (*(tmp1) != '-')
*(tmp2++) = *(tmp1);