From 05af6d32e67e92f4bcc21c337acf66c7eb05a3cd Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 30 Jan 2002 15:08:48 +0000 Subject: [w3m-dev 02933] segmentation fault when w3m -dump https: * file.c (readHeader): use inputAnswer() * file.c (getAuthCookie): remove term_cbreak() * file.c (checkOverWrite): use inputAnswer() * file.c (inputAnswer): added * istream.c (ssl_get_certificate): use inputAnswer() * main.c (qquitfm): change prompt * proto.h (inputAnswer): added From: Hironori Sakamoto --- file.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index ae75b6d..4a3b089 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.50 2002/01/30 04:25:02 ukai Exp $ */ +/* $Id: file.c,v 1.51 2002/01/30 15:08:48 ukai Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -731,16 +731,14 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) ? "y" : NULL; if (fmInitialized && (err & COO_OVERRIDE_OK) && accept_bad_cookie == ACCEPT_BAD_COOKIE_ASK) { - Str msg = - Sprintf - ("Accept bad cookie from %s for %s? (y or n) ", - pu->host, - domain - && domain->ptr ? domain->ptr : ""); - if (msg->length > COLS - 4) - Strshrink(msg, msg->length - (COLS - 4)); - term_raw(); - ans = inputChar(msg->ptr); + Str msg = Sprintf("Accept bad cookie from %s for %s?", + pu->host, + ((domain && domain->ptr) + ? domain->ptr : "")); + if (msg->length > COLS - 10) + Strshrink(msg, msg->length - (COLS - 10)); + Strcat_charp(msg, " (y/n)"); + ans = inputAnswer(msg->ptr); } if (ans == NULL || tolower(*ans) != 'y' || (err = @@ -1222,7 +1220,6 @@ getAuthCookie(struct http_auth *hauth, char *auth_header, IN_PASSWORD)) == NULL) return NULL; pwd = Str_conv_to_system(Strnew_charp(pp)); - term_cbreak(); } else { int proxy = !strncasecmp("Proxy-Authorization:", auth_header, @@ -6393,22 +6390,34 @@ int checkOverWrite(char *path) { struct stat st; - char buf[2]; - char *ans = NULL; + char *ans; if (stat(path, &st) < 0) return 0; + ans = inputAnswer("File exists. Overwrite? (y/n)"); + if (ans && tolower(*ans) == 'y') + return 0; + else + return -1; +} + +char * +inputAnswer(char *prompt) +{ + char *ans; + char buf[2]; + if (fmInitialized) { - ans = inputChar("File exists. Overwrite? (y or n)"); + term_raw(); + ans = inputChar(prompt); } else { - printf("File exists. Overwrite? (y or n)"); - ans = fgets(buf, 2, stdin); + printf(prompt); + fflush(stdout); + fgets(buf, 2, stdin); + ans = allocStr(buf, 1); } - if (ans != NULL && (*ans == '\0' || tolower(*ans) == 'y')) - return 0; - else - return -1; + return ans; } static void -- cgit v1.2.3