about summary refs log tree commit diff stats
path: root/src/LYLocal.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2013-05-01 01:00:38 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2013-05-01 01:00:38 -0400
commit81905f18dc0594e372cf38cfb0e0b71b69849a43 (patch)
tree8eb23ef6f907e1a4f53bd7c2247522b077037e63 /src/LYLocal.c
parent7827f0bdba0c75376e59443975f3638df4cce044 (diff)
downloadlynx-snapshots-81905f18dc0594e372cf38cfb0e0b71b69849a43.tar.gz
snapshot of project "lynx", label v2-8-8dev-15b
Diffstat (limited to 'src/LYLocal.c')
-rw-r--r--src/LYLocal.c95
1 files changed, 54 insertions, 41 deletions
diff --git a/src/LYLocal.c b/src/LYLocal.c
index 54d43c85..3cfd5d0c 100644
--- a/src/LYLocal.c
+++ b/src/LYLocal.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYLocal.c,v 1.119 2012/11/18 22:25:54 tom Exp $
+ * $LynxId: LYLocal.c,v 1.123 2013/04/30 08:51:14 tom Exp $
  *
  *  Routines to manipulate the local filesystem.
  *  Written by: Rick Mallett, Carleton University
@@ -2045,7 +2045,7 @@ int dired_options(DocInfo *doc, char **newfile)
 {
     static char tempfile[LY_MAXPATH];
     const char *my_suffix;
-    char *path;
+    char *path = NULL;
     char *dir;
     lynx_list_item_type *nxt;
     struct stat dir_info;
@@ -2497,6 +2497,7 @@ void add_menu_item(char *str)
 {
     struct dired_menu *tmp, *mp;
     char *cp;
+    BOOL used = FALSE;
 
     /*
      * First custom menu definition causes entire default menu to be discarded.
@@ -2514,48 +2515,60 @@ void add_menu_item(char *str)
     /*
      * Conditional on tagged != NULL ?
      */
-    cp = strchr(str, ':');
-    *cp++ = '\0';
-    if (strcasecomp(str, "tag") == 0) {
-	tmp->cond = DE_TAG;
-    } else if (strcasecomp(str, "dir") == 0) {
-	tmp->cond = DE_DIR;
-    } else if (strcasecomp(str, "file") == 0) {
-	tmp->cond = DE_FILE;
+    if ((cp = strchr(str, ':')) != 0) {
+	*cp++ = '\0';
+	if (strcasecomp(str, "tag") == 0) {
+	    tmp->cond = DE_TAG;
+	} else if (strcasecomp(str, "dir") == 0) {
+	    tmp->cond = DE_DIR;
+	} else if (strcasecomp(str, "file") == 0) {
+	    tmp->cond = DE_FILE;
 #ifdef S_IFLNK
-    } else if (strcasecomp(str, "link") == 0) {
-	tmp->cond = DE_SYMLINK;
+	} else if (strcasecomp(str, "link") == 0) {
+	    tmp->cond = DE_SYMLINK;
 #endif /* S_IFLNK */
-    }
+	}
 
-    /*
-     * Conditional on matching suffix.
-     */
-    str = cp;
-    cp = strchr(str, ':');
-    *cp++ = '\0';
-    StrAllocCopy(tmp->sfx, str);
-
-    str = cp;
-    cp = strchr(str, ':');
-    *cp++ = '\0';
-    StrAllocCopy(tmp->link, str);
-
-    str = cp;
-    cp = strchr(str, ':');
-    *cp++ = '\0';
-    StrAllocCopy(tmp->rest, str);
-
-    StrAllocCopy(tmp->href, cp);
-
-    if (menu_head) {
-	for (mp = menu_head; mp && mp->next != NULL; mp = mp->next) {
-	    ;
-	}
-	if (mp != NULL)
-	    mp->next = tmp;
-    } else
-	menu_head = tmp;
+	/*
+	 * Conditional on matching suffix.
+	 */
+	str = cp;
+	if ((cp = strchr(str, ':')) != 0) {
+	    *cp++ = '\0';
+	    StrAllocCopy(tmp->sfx, str);
+
+	    str = cp;
+	    if ((cp = strchr(str, ':')) != 0) {
+		*cp++ = '\0';
+		StrAllocCopy(tmp->link, str);
+
+		str = cp;
+		if ((cp = strchr(str, ':')) != 0) {
+		    *cp++ = '\0';
+		    StrAllocCopy(tmp->rest, str);
+
+		    StrAllocCopy(tmp->href, cp);
+
+		    if (menu_head) {
+			for (mp = menu_head;
+			     mp && mp->next != NULL;
+			     mp = mp->next) {
+			    ;
+			}
+			if (mp != NULL) {
+			    mp->next = tmp;
+			    used = TRUE;
+			}
+		    } else {
+			menu_head = tmp;
+			used = TRUE;
+		    }
+		}
+	    }
+	}
+    }
+    if (!used)
+	FREE(tmp);
 }
 
 void reset_dired_menu(void)