about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2011-05-27 00:46:17 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2011-05-27 00:46:17 -0400
commit6aab9ce5aeba97b6afee05e377027c3c1544583d (patch)
treecb93a1f5c0191da0b64b553990fe5ae2c5c9fb95 /src
parent35794979cb285352b58cdf1879ca9cc246168729 (diff)
downloadlynx-snapshots-6aab9ce5aeba97b6afee05e377027c3c1544583d.tar.gz
snapshot of project "lynx", label v2-8-8dev_8g
Diffstat (limited to 'src')
-rw-r--r--src/LYKeymap.c29
-rw-r--r--src/LYMail.c43
-rw-r--r--src/LYMail.h14
-rw-r--r--src/LYUtils.c26
4 files changed, 65 insertions, 47 deletions
diff --git a/src/LYKeymap.c b/src/LYKeymap.c
index 639d9492..90cd3c44 100644
--- a/src/LYKeymap.c
+++ b/src/LYKeymap.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYKeymap.c,v 1.73 2010/11/07 21:21:04 tom Exp $ */
+/* $LynxId: LYKeymap.c,v 1.74 2011/05/26 23:24:42 tom Exp $ */
 #include <HTUtils.h>
 #include <LYUtils.h>
 #include <LYGlobalDefs.h>
@@ -1376,32 +1376,37 @@ int lkcstring_to_lkc(const char *src)
 {
     int c = -1;
 
-    if (strlen(src) == 1)
+    if (strlen(src) == 1) {
 	c = *src;
-    else if (strlen(src) == 2 && *src == '^')
+    } else if (strlen(src) == 2 && *src == '^') {
 	c = src[1] & 037;
-    else if (strlen(src) >= 2 && isdigit(UCH(*src))) {
-	if (sscanf(src, "%d", &c) != 1)
-	    return (-1);
+    } else if (strlen(src) >= 2 && isdigit(UCH(*src))) {
+	char *next = 0;
+
+	c = (int) strtol(src, &next, 0);
+	if (next != 0 && *next != '\0')
+	    c = (-1);
 #ifdef USE_KEYMAPS
     } else {
 	map_string_to_keysym(src, &c);
 #ifndef USE_SLANG
 	if (c >= 0) {
 	    if ((c & LKC_MASK) > 255 && !(c & LKC_ISLKC))
-		return (-1);	/* Don't accept untranslated curses KEY_* */
+		c = (-1);	/* Don't accept untranslated curses KEY_* */
 	    else
 		c &= ~LKC_ISLKC;
 	}
 #endif
 #endif
     }
-    if (c == CH_ESC)
+
+    if (c == CH_ESC) {
 	escape_bound = 1;
-    if (c < -1)
-	return (-1);
-    else
-	return c;
+    } else if (c < -1) {
+	c = (-1);
+    }
+
+    return c;
 }
 
 static int LYLoadKeymap(const char *arg GCC_UNUSED,
diff --git a/src/LYMail.c b/src/LYMail.c
index ba9d3b48..4a43564f 100644
--- a/src/LYMail.c
+++ b/src/LYMail.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMail.c,v 1.80 2010/12/11 14:52:59 tom Exp $
+ * $LynxId: LYMail.c,v 1.82 2011/05/26 01:00:05 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTParse.h>
@@ -327,7 +327,7 @@ static char *blat_cmd(char *mail_cmd,
 		      char *ccaddr,
 		      char *mail_addr)
 {
-    static char *b_cmd;
+    char *b_cmd = NULL;
 
 #ifdef USE_ALT_BLAT_MAILER
 
@@ -343,7 +343,7 @@ static char *blat_cmd(char *mail_cmd,
 
 #else /* !USE_ALT_BLAT_MAILER */
 
-    static char bl_cmd_file[512];
+    char bl_cmd_file[LY_MAXPATH];
     FILE *fp;
 
 #ifdef __CYGWIN__
@@ -467,31 +467,24 @@ int LYSendMailFile(char *the_address,
 		   char *message)
 {
     char *cmd = NULL;
-
-#ifdef __DJGPP__
-    char *shell;
-#endif /* __DJGPP__ */
     int code;
 
     if (!LYSystemMail())
 	return 0;
 
 #if USE_BLAT_MAILER
-    if (mail_is_blat)
-	StrAllocCopy(cmd,
-		     blat_cmd(system_mail,
-			      the_filename,
-			      the_address,
-			      the_subject,
-			      the_ccaddr,
-			      personal_mail_address
-		     )
-	    );
-    else
+    if (mail_is_blat) {
+	cmd = blat_cmd(system_mail,
+		       the_filename,
+		       the_address,
+		       the_subject,
+		       the_ccaddr,
+		       personal_mail_address);
+    } else
 #endif
 #ifdef __DJGPP__
-    if ((shell = LYGetEnv("SHELL")) != NULL) {
-	if (strstr(shell, "sh") != NULL) {
+    if (LYGetEnv("SHELL")) {
+	if (dj_is_bash) {
 	    HTSprintf0(&cmd, "%s -c %s -t \"%s\" -F %s",
 		       shell,
 		       system_mail,
@@ -504,18 +497,12 @@ int LYSendMailFile(char *the_address,
 		       the_address,
 		       the_filename);
 	}
-    } else {
-	HTSprintf0(&cmd, "%s -t \"%s\" -F %s",
-		   system_mail,
-		   the_address,
-		   the_filename);
-    }
-#else
+    } else
+#endif /* __DJGPP__ */
 	HTSprintf0(&cmd, "%s -t \"%s\" -F %s",
 		   system_mail,
 		   the_address,
 		   the_filename);
-#endif /* __DJGPP__ */
 
     stop_curses();
     SetOutputMode(O_TEXT);
diff --git a/src/LYMail.h b/src/LYMail.h
index 7e58bbf7..cf7e0552 100644
--- a/src/LYMail.h
+++ b/src/LYMail.h
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: LYMail.h,v 1.14 2011/05/26 09:23:05 tom Exp $
+ */
 #ifndef LYMAIL_H
 #define LYMAIL_H
 
@@ -8,25 +11,34 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 #ifdef SH_EX
+#undef USE_BLAT_MAILER
 #define USE_BLAT_MAILER 1
-#else
+#endif
+
+#ifndef USE_BLAT_MAILER
 #define USE_BLAT_MAILER 0
 #endif
+
 #ifdef VMS
 #define USE_VMS_MAILER 1
 #else
 #define USE_VMS_MAILER 0
 #endif
+
 /*
  * Ifdef's in case we have a working popen/pclose, useful for piping to the
  * mail program.
  */
+#ifndef CAN_PIPE_TO_MAILER
 #if !defined(HAVE_POPEN) || USE_VMS_MAILER || defined(DOSPATH) || defined(__CYGWIN__)
 #define CAN_PIPE_TO_MAILER 0
 #else
 #define CAN_PIPE_TO_MAILER 1
 #endif
+#endif
+
     extern BOOLEAN term_letter;
 
     extern BOOLEAN LYSystemMail(void);
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 0ef6f93e..1a0aa7f1 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.207 2010/12/08 09:42:15 tom Exp $
+ * $LynxId: LYUtils.c,v 1.208 2011/05/27 00:40:54 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -2754,15 +2754,21 @@ BOOLEAN LYCanDoHEAD(const char *address)
  */
 BOOLEAN LYCloseInput(FILE *fp)
 {
+    int result = FALSE;
+
     if (fp != 0) {
 	int err = ferror(fp);
+	LY_TEMP *p = FindTempfileByFP(fp);
 
 	fclose(fp);
+	if (p != 0) {
+	    p->file = 0;
+	}
 	if (!err) {
-	    return TRUE;
+	    result = TRUE;
 	}
     }
-    return FALSE;
+    return result;
 }
 
 /*
@@ -2770,16 +2776,24 @@ BOOLEAN LYCloseInput(FILE *fp)
  */
 BOOLEAN LYCloseOutput(FILE *fp)
 {
+    int result = FALSE;
+
     if (fp != 0) {
 	int err = ferror(fp);
+	LY_TEMP *p = FindTempfileByFP(fp);
 
 	fclose(fp);
+	if (p != 0) {
+	    p->file = 0;
+	}
 	if (!err) {
-	    return TRUE;
+	    result = TRUE;
 	}
     }
-    HTAlert(CANNOT_WRITE_TO_FILE);
-    return FALSE;
+    if (!result) {
+	HTAlert(CANNOT_WRITE_TO_FILE);
+    }
+    return result;
 }
 
 /*