about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2010-09-23 22:43:44 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2010-09-23 22:43:44 -0400
commit69a1a751cb798556c786e3ef66d473bf8a88abdc (patch)
tree55c14b1b4bee18bd0674173917b25f5f49f994a8
parenta9f33e9f4daa32e4f1503b40e38b3b531c34b7b0 (diff)
downloadlynx-snapshots-69a1a751cb798556c786e3ef66d473bf8a88abdc.tar.gz
snapshot of project "lynx", label v2-8-8dev_5d
-rw-r--r--WWW/Library/Implementation/HTUtils.h10
-rw-r--r--src/HTAlert.c6
-rw-r--r--src/LYGetFile.c123
-rw-r--r--src/LYLeaks.c16
-rw-r--r--src/LYReadCFG.c7
-rw-r--r--src/LYReadCFG.h4
6 files changed, 74 insertions, 92 deletions
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index ec07426a..dd562964 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTUtils.h,v 1.98 2010/04/29 09:13:44 tom Exp $
+ * $LynxId: HTUtils.h,v 1.99 2010/09/23 20:34:05 tom Exp $
  *
  * Utility macros for the W3 code library
  * MACROS FOR GENERAL USE
@@ -542,7 +542,7 @@ extern int WWW_TraceMask;
 /*
  * Printing/scanning-formats for "off_t", as well as cast needed to fit.
  */
-#if defined(HAVE_INTTYPES_H) && defined(SIZEOF_OFF_T)
+#if defined(HAVE_LONG_LONG) && defined(HAVE_INTTYPES_H) && defined(SIZEOF_OFF_T)
 #if (SIZEOF_OFF_T == 8) && defined(PRId64)
 
 #define PRI_off_t	PRId64
@@ -566,7 +566,7 @@ extern int WWW_TraceMask;
 #endif
 
 #ifndef PRI_off_t
-#if (SIZEOF_OFF_T > SIZEOF_LONG)
+#if defined(HAVE_LONG_LONG) && (SIZEOF_OFF_T > SIZEOF_LONG)
 #define PRI_off_t	"lld"
 #define SCN_off_t	"lld"
 #define CAST_off_t(n)	(long long)(n)
@@ -580,7 +580,7 @@ extern int WWW_TraceMask;
 /*
  * Printing-format for "time_t", as well as cast needed to fit.
  */
-#if defined(HAVE_INTTYPES_H) && defined(SIZEOF_TIME_T)
+#if defined(HAVE_LONG_LONG) && defined(HAVE_INTTYPES_H) && defined(SIZEOF_TIME_T)
 #if (SIZEOF_TIME_T == 8) && defined(PRId64)
 
 #define PRI_time_t	PRId64
@@ -604,7 +604,7 @@ extern int WWW_TraceMask;
 #endif
 
 #ifndef PRI_time_t
-#if (SIZEOF_TIME_T > SIZEOF_LONG)
+#if defined(HAVE_LONG_LONG) && (SIZEOF_TIME_T > SIZEOF_LONG)
 #define PRI_time_t	"lld"
 #define SCN_time_t	"lld"
 #define CAST_time_t(n)	(long long)(n)
diff --git a/src/HTAlert.c b/src/HTAlert.c
index 12416ec7..d31002b9 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAlert.c,v 1.89 2010/09/23 10:43:48 tom Exp $
+ * $LynxId: HTAlert.c,v 1.90 2010/09/23 20:43:49 tom Exp $
  *
  *	Displaying messages and getting input for Lynx Browser
  *	==========================================================
@@ -306,7 +306,9 @@ void HTReadProgress(off_t bytes, off_t total)
 		    int meter = (int) (((float) LYcolLimit * percent) - 5);
 
 		    CTRACE((tfp, "rateBAR: bytes: %" PRI_off_t ", total: "
-			    "%" PRI_off_t "\n", bytes, total));
+			    "%" PRI_off_t "\n",
+			    CAST_off_t(bytes),
+			    CAST_off_t(total)));
 		    CTRACE((tfp, "meter = %d\n", meter));
 
 		    HTSprintf0(&line, "%d%% ", (int) (percent * 100));
diff --git a/src/LYGetFile.c b/src/LYGetFile.c
index c0a35f95..453d3731 100644
--- a/src/LYGetFile.c
+++ b/src/LYGetFile.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYGetFile.c,v 1.81 2010/09/23 09:37:14 tom Exp $ */
+/* $LynxId: LYGetFile.c,v 1.82 2010/09/23 22:43:44 tom Exp $ */
 #include <HTUtils.h>
 #include <HTTP.h>
 #include <HTAnchor.h>		/* Anchor class */
@@ -1255,61 +1255,56 @@ struct trust {
     struct trust *next;
 };
 
-static struct trust trusted_exec_default =
-{
-    "file://localhost/", "", EXEC_PATH, NULL
-};
-static struct trust always_trusted_exec_default =
-{
-    "none", "", ALWAYS_EXEC_PATH, NULL
-};
-static struct trust trusted_cgi_default =
+static struct trust *trusted_exec = 0;
+static struct trust *always_trusted_exec;
+static struct trust *trusted_cgi = 0;
+
+static struct trust *new_trust(const char *src, const char *path, int type)
 {
-    "none", "", CGI_PATH, NULL
-};
+    struct trust *tp;
+
+    tp = typecalloc(struct trust);
+
+    if (tp == NULL)
+	outofmem(__FILE__, "new_trust");
 
-static struct trust *trusted_exec = &trusted_exec_default;
-static struct trust *always_trusted_exec = &always_trusted_exec_default;
-static struct trust *trusted_cgi = &trusted_cgi_default;
+    assert(tp != NULL);
+
+    tp->type = type;
+    StrAllocCopy(tp->src, src);
+    StrAllocCopy(tp->path, path);
+
+    return tp;
+}
+
+static struct trust *get_trust(struct trust **table, const char *src, int type)
+{
+    if (*table == 0) {
+	*table = new_trust(src, "", type);
+    }
+    return *table;
+}
 
 #ifdef LY_FIND_LEAKS
-static void LYTrusted_free(void)
+static void free_data(struct trust *cur)
 {
-    struct trust *cur;
     struct trust *next;
 
-    if (trusted_exec != &trusted_exec_default) {
-	cur = trusted_exec;
-	while (cur) {
-	    FREE(cur->src);
-	    FREE(cur->path);
-	    next = cur->next;
-	    FREE(cur);
-	    cur = next;
-	}
-    }
-
-    if (always_trusted_exec != &always_trusted_exec_default) {
-	cur = always_trusted_exec;
-	while (cur) {
-	    FREE(cur->src);
-	    FREE(cur->path);
-	    next = cur->next;
-	    FREE(cur);
-	    cur = next;
-	}
+    cur = trusted_exec;
+    while (cur) {
+	FREE(cur->src);
+	FREE(cur->path);
+	next = cur->next;
+	FREE(cur);
+	cur = next;
     }
+}
 
-    if (trusted_cgi != &trusted_cgi_default) {
-	cur = trusted_cgi;
-	while (cur) {
-	    FREE(cur->src);
-	    FREE(cur->path);
-	    next = cur->next;
-	    FREE(cur);
-	    cur = next;
-	}
-    }
+static void LYTrusted_free(void)
+{
+    free_data(trusted_exec);
+    free_data(always_trusted_exec);
+    free_data(trusted_cgi);
 
     return;
 }
@@ -1342,34 +1337,16 @@ void add_trusted(char *str,
 	after_tab = "";
     }
 
-    tp = (struct trust *) malloc(sizeof(*tp));
-    if (tp == NULL)
-	outofmem(__FILE__, "add_trusted");
+    tp = new_trust(src, after_tab, Type);
 
-    assert(tp != NULL);
-
-    tp->src = NULL;
-    tp->path = NULL;
-    tp->type = Type;
-    StrAllocCopy(tp->src, src);
-    StrAllocCopy(tp->path, after_tab);
     if (Type == EXEC_PATH) {
-	if (trusted_exec == &trusted_exec_default)
-	    tp->next = NULL;
-	else
-	    tp->next = trusted_exec;
+	tp->next = trusted_exec;
 	trusted_exec = tp;
     } else if (Type == ALWAYS_EXEC_PATH) {
-	if (always_trusted_exec == &always_trusted_exec_default)
-	    tp->next = NULL;
-	else
-	    tp->next = always_trusted_exec;
+	tp->next = always_trusted_exec;
 	always_trusted_exec = tp;
     } else if (Type == CGI_PATH) {
-	if (trusted_cgi == &trusted_cgi_default)
-	    tp->next = NULL;
-	else
-	    tp->next = trusted_cgi;
+	tp->next = trusted_cgi;
 	trusted_cgi = tp;
     }
 }
@@ -1396,11 +1373,11 @@ BOOLEAN exec_ok(const char *source,
      * Choose the trust structure based on the type.
      */
     if (Type == EXEC_PATH) {
-	tp = trusted_exec;
+	tp = get_trust(&trusted_exec, "file://localhost/", EXEC_PATH);
     } else if (Type == ALWAYS_EXEC_PATH) {
-	tp = always_trusted_exec;
+	tp = get_trust(&always_trusted_exec, "none", ALWAYS_EXEC_PATH);
     } else if (Type == CGI_PATH) {
-	tp = trusted_cgi;
+	tp = get_trust(&trusted_cgi, "none", CGI_PATH);
     } else {
 	HTAlert(MALFORMED_EXEC_REQUEST);
 	return FALSE;
@@ -1471,7 +1448,7 @@ BOOLEAN exec_ok(const char *source,
 	tp = tp->next;
     }
     if (Type == EXEC_PATH &&
-	always_trusted_exec != &always_trusted_exec_default) {
+	always_trusted_exec->next != 0) {
 	Type = ALWAYS_EXEC_PATH;
 	tp = always_trusted_exec;
 	goto check_tp_for_entry;
diff --git a/src/LYLeaks.c b/src/LYLeaks.c
index e7a4ee5d..0164aa0e 100644
--- a/src/LYLeaks.c
+++ b/src/LYLeaks.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYLeaks.c,v 1.32 2007/07/23 22:54:46 tom Exp $
+ * $LynxId: LYLeaks.c,v 1.33 2010/09/23 22:41:23 tom Exp $
  *
  *	Copyright (c) 1994, University of Kansas, All Rights Reserved
  *	(this file was rewritten twice - 1998/1999 and 2003/2004)
@@ -31,16 +31,16 @@ static AllocationList *ALp_RunTimeAllocations = NULL;
 
 #ifdef LEAK_SUMMARY
 
-static long now_allocated = 0;
-static long peak_alloced = 0;
+static size_t now_allocated = 0;
+static size_t peak_alloced = 0;
 
-static long total_alloced = 0;
-static long total_freed = 0;
+static size_t total_alloced = 0;
+static size_t total_freed = 0;
 
 static long count_mallocs = 0;
 static long count_frees = 0;
 
-static void CountMallocs(long size)
+static void CountMallocs(size_t size)
 {
     ++count_mallocs;
     total_alloced += size;
@@ -49,7 +49,7 @@ static void CountMallocs(long size)
 	peak_alloced = now_allocated;
 }
 
-static void CountFrees(long size)
+static void CountFrees(size_t size)
 {
     ++count_frees;
     total_freed += size;
@@ -779,7 +779,7 @@ char *LYLeakSACat(char **dest,
 		    "LYLeakSACat:  *dest equals src, contains \"%s\"\n",
 		    src));
 	} else if (*dest) {
-	    int length = strlen(*dest);
+	    size_t length = strlen(*dest);
 
 	    *dest = (char *) LYLeakRealloc(*dest,
 					   (length + strlen(src) + 1),
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 88c5215d..fd028104 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYReadCFG.c,v 1.151 2010/09/22 09:54:46 tom Exp $
+ * $LynxId: LYReadCFG.c,v 1.152 2010/09/23 20:53:32 tom Exp $
  */
 #ifndef NO_RULES
 #include <HTRules.h>
@@ -1785,13 +1785,15 @@ typedef BOOL (optidx_set_t)[NOPTS_];
  * configuration variable.
  */
 void LYSetConfigValue(const char *name,
-		      char *value)
+		      const char *param)
 {
+    char *value = NULL;
     Config_Type *tbl = lookup_config(name);
     ParseUnionPtr q = ParseUnionOf(tbl);
     char *temp_name = 0;
     char *temp_value = 0;
 
+    StrAllocCopy(value, param);
     switch (tbl->type) {
     case CONF_BOOL:
 	if (q->set_value != 0)
@@ -1886,6 +1888,7 @@ void LYSetConfigValue(const char *name,
     default:
 	break;
     }
+    FREE(value);
 }
 
 /*
diff --git a/src/LYReadCFG.h b/src/LYReadCFG.h
index 8092a8a5..2175f3fe 100644
--- a/src/LYReadCFG.h
+++ b/src/LYReadCFG.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYReadCFG.h,v 1.23 2009/11/27 12:52:34 tom Exp $
+ * $LynxId: LYReadCFG.h,v 1.24 2010/09/23 20:53:47 tom Exp $
  */
 #ifndef LYREADCFG_H
 #define LYREADCFG_H
@@ -64,7 +64,7 @@ extern "C" {
 						    list_ptr,
 						    char *number);
     extern void reload_read_cfg(void);	/* implemented in LYMain.c */
-    extern void LYSetConfigValue(const char *name, char *value);
+    extern void LYSetConfigValue(const char *name, const char *value);
 
 #ifdef __cplusplus
 }