about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AttrList.h4
-rw-r--r--src/GridText.c38
-rw-r--r--src/HTAlert.c6
-rw-r--r--src/HTInit.c38
-rw-r--r--src/LYCurses.c59
-rw-r--r--src/LYKeymap.c6
-rw-r--r--src/LYLocal.c6
-rw-r--r--src/LYMail.c14
-rw-r--r--src/LYMainLoop.c5
-rw-r--r--src/LYStrings.c38
-rw-r--r--src/LYStrings.h9
-rw-r--r--src/LYUpload.c12
-rw-r--r--src/LYUtils.c4
-rw-r--r--src/LYmktime.c18
-rw-r--r--src/UCAuto.c8
15 files changed, 130 insertions, 135 deletions
diff --git a/src/AttrList.h b/src/AttrList.h
index d64a7308..cf382615 100644
--- a/src/AttrList.h
+++ b/src/AttrList.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: AttrList.h,v 1.16 2009/04/16 23:42:58 tom Exp $
+ * $LynxId: AttrList.h,v 1.17 2013/05/03 20:54:09 tom Exp $
  */
 #if !defined(__ATTRLIST_H)
 #define __ATTRLIST_H
@@ -47,7 +47,7 @@ extern "C" {
     extern void _internal_HTC(HText *text, int style, int dir);
 
 #define TEMPSTRINGSIZE 256
-    extern char class_string[TEMPSTRINGSIZE];
+    extern char class_string[TEMPSTRINGSIZE + 1];
 
 /* stack of attributes during page rendering */
 #define MAX_LAST_STYLES 128
diff --git a/src/GridText.c b/src/GridText.c
index 07814a06..ce96daed 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.255 2013/05/02 10:47:41 tom Exp $
+ * $LynxId: GridText.c,v 1.258 2013/05/03 20:29:37 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -1576,8 +1576,7 @@ static int display_line(HTLine *line,
 		LastDisplayChar = 'M';
 	    }
 	    if (utf_extra) {
-		StrNCpy(&buffer[1], data, utf_extra);
-		buffer[utf_extra + 1] = '\0';
+		LYStrNCpy(&buffer[1], data, utf_extra);
 		LYaddstr(buffer);
 		buffer[1] = '\0';
 		data += utf_extra;
@@ -2200,8 +2199,7 @@ static void display_page(HText *text,
 			 */
 			utf_extra = utf8_length(text->T.output_utf8, data + itmp);
 			if (utf_extra) {
-			    StrNCpy(&tmp[1], &line->data[itmp + 1], utf_extra);
-			    tmp[utf_extra + 1] = '\0';
+			    LYStrNCpy(&tmp[1], &line->data[itmp + 1], utf_extra);
 			    itmp += utf_extra;
 			    LYaddstr(tmp);
 			    tmp[1] = '\0';
@@ -4121,8 +4119,8 @@ void HText_appendCharacter(HText *text, int ch)
 		if (!text->permissible_split || text->source) {
 		    text->permissible_split = line->size;
 		    while (text->permissible_split > 0 &&
-			   (line->data[text->permissible_split - 1] & 0x80)
-			   == 0xC0) {
+			   (line->data[text->permissible_split - 1] & 0xc0)
+			   == 0x80) {
 			text->permissible_split--;
 		    }
 		    if (text->permissible_split == line->size)
@@ -5692,14 +5690,12 @@ void HText_appendText(HText *text, const char *str)
 {
     const char *p;
 
-    if (str == NULL)
-	return;
-
-    if (text->halted == 3)
-	return;
-
-    for (p = str; *p; p++) {
-	HText_appendCharacter(text, *p);
+    if (str != NULL &&
+	text != NULL &&
+	text->halted != 3) {
+	for (p = str; *p; p++) {
+	    HText_appendCharacter(text, *p);
+	}
     }
 }
 
@@ -13041,8 +13037,7 @@ static int finish_ExtEditForm(LinkInfo * form_link, TextAnchor *start_anchor,
 
 	if (skip_at) {
 	    len0 = (int) (skip_at - lp);
-	    StrNCpy(line, lp, len0);
-	    line[len0] = '\0';
+	    LYStrNCpy(line, lp, len0);
 	    lp = skip_at + skip_num;
 	    skip_at = NULL;
 	    skip_num = 0;
@@ -13706,8 +13701,7 @@ int HText_InsertFile(LinkInfo * form_link)
 	    if (lp[len])
 		lp[len + 1] = '\0';	/* prevent next iteration */
 	}
-	StrNCpy(line, lp, len);
-	*(line + len) = '\0';
+	LYStrNCpy(line, lp, len);
 
 	/*
 	 * If not the first line from the insert file, we need to add
@@ -13917,8 +13911,7 @@ static void redraw_part_of_line(HTLine *line, const char *str,
 		LastDisplayChar = 'M';
 	    }
 	    if (utf_extra) {
-		StrNCpy(&buffer[1], data, utf_extra);
-		buffer[utf_extra + 1] = '\0';
+		LYStrNCpy(&buffer[1], data, utf_extra);
 		LYaddstr(buffer);
 		buffer[1] = '\0';
 		data += utf_extra;
@@ -14397,8 +14390,7 @@ static void move_to_glyph(int YP,
 	    }
 #endif
 	    if (utf_extra) {
-		StrNCpy(&buffer[1], data, utf_extra);
-		buffer[utf_extra + 1] = '\0';
+		LYStrNCpy(&buffer[1], data, utf_extra);
 		if (!drawing && i >= XP_draw_min) {
 		    LYmove(YP, i - 1);
 		    drawing = YES;
diff --git a/src/HTAlert.c b/src/HTAlert.c
index ab04e09c..641b36e3 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAlert.c,v 1.97 2012/11/16 01:22:25 tom Exp $
+ * $LynxId: HTAlert.c,v 1.99 2013/05/03 08:41:08 tom Exp $
  *
  *	Displaying messages and getting input for Lynx Browser
  *	==========================================================
@@ -656,7 +656,7 @@ char *HTPrompt(const char *Msg, const char *deflt)
     BStrCopy0(data, deflt ? deflt : "");
 
     if (!dump_output_immediately)
-	LYgetBString(&data, VISIBLE, 0, NORECALL);
+	(void) LYgetBString(&data, VISIBLE, 0, NORECALL);
 
     StrAllocCopy(rep, data->str);
 
@@ -676,7 +676,7 @@ char *HTPromptPassword(const char *Msg)
     if (!dump_output_immediately) {
 	_statusline(Msg ? Msg : PASSWORD_PROMPT);
 	BStrCopy0(data, "");
-	LYgetBString(&data, HIDDEN, 0, NORECALL);
+	(void) LYgetBString(&data, HIDDEN, 0, NORECALL);
 	StrAllocCopy(result, data->str);
 	BStrFree(data);
     } else {
diff --git a/src/HTInit.c b/src/HTInit.c
index e03a6d4b..103dcbc2 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTInit.c,v 1.79 2013/05/02 11:04:48 tom Exp $
+ * $LynxId: HTInit.c,v 1.83 2013/05/03 19:47:08 tom Exp $
  *
  *		Configuration-specific Initialization		HTInit.c
  *		----------------------------------------
@@ -262,7 +262,7 @@ static char *GetCommand(char *s, char **t)
 		*s2 = '\0';
 		return (++s);
 	    }
-	    if (*s == '\\') {
+	    if (*s == ESCAPE) {
 		quoted = 1;
 		++s;
 	    } else {
@@ -301,23 +301,25 @@ static void TrimCommand(char *command)
 	    if (escape) {
 		escape = FALSE;
 	    } else if (squote) {
-		if (ch == '\'')
+		if (ch == SQUOTE)
 		    squote = FALSE;
 	    } else if (dquote) {
-		if (ch == '"')
+		switch (ch) {
+		case DQUOTE:
 		    dquote = FALSE;
+		    break;
+		case ESCAPE:
+		    escape = TRUE;
+		    break;
+		}
 	    } else {
 		switch (ch) {
-		case '"':
+		case DQUOTE:
 		    dquote = TRUE;
 		    break;
-		case '\'':
+		case SQUOTE:
 		    squote = TRUE;
 		    break;
-		case '\\':
-		    if (dquote)
-			escape = TRUE;
-		    break;
 		}
 	    }
 	    if (!escape && !dquote && !squote) {
@@ -364,7 +366,7 @@ static int ProcessMailcapEntry(FILE *fp, struct MailcapEntry *mc, AcceptMedia me
 
 	    assert(rawentry != NULL);
 	}
-	if (len > 0 && LineBuf[len - 1] == '\\') {
+	if (len > 0 && LineBuf[len - 1] == ESCAPE) {
 	    LineBuf[len - 1] = '\0';
 	    strcat(rawentry, LineBuf);
 	} else {
@@ -497,9 +499,9 @@ static const char *LYSkipQuoted(const char *s)
     while (*s != 0) {
 	if (escaped) {
 	    escaped = 0;
-	} else if (*s == '\\') {
+	} else if (*s == ESCAPE) {
 	    escaped = 1;
-	} else if (*s == '"') {
+	} else if (*s == DQUOTE) {
 	    ++s;
 	    break;
 	}
@@ -524,7 +526,7 @@ static const char *LYSkipToken(const char *s)
 
 static const char *LYSkipValue(const char *s)
 {
-    if (*s == '"')
+    if (*s == DQUOTE)
 	s = LYSkipQuoted(s);
     else
 	s = LYSkipToken(s);
@@ -540,12 +542,12 @@ static char *LYCopyValue(const char *s)
     char *result = 0;
     int j, k;
 
-    if (*s == '"') {
+    if (*s == DQUOTE) {
 	t = LYSkipQuoted(s);
 	StrAllocCopy(result, s + 1);
 	result[t - s - 2] = '\0';
 	for (j = k = 0;; ++j, ++k) {
-	    if (result[j] == '\\') {
+	    if (result[j] == ESCAPE) {
 		++j;
 	    }
 	    if ((result[k] = result[j]) == '\0')
@@ -623,7 +625,7 @@ BOOL LYMailcapUsesPctS(const char *controlstring)
     for (from = controlstring; *from != '\0'; from++) {
 	if (escaped) {
 	    escaped = 0;
-	} else if (*from == '\\') {
+	} else if (*from == ESCAPE) {
 	    escaped = 1;
 	} else if (prefixed) {
 	    prefixed = 0;
@@ -677,7 +679,7 @@ static int BuildCommand(HTChunk *cmd,
 	if (escaped) {
 	    escaped = 0;
 	    HTChunkPutc(cmd, UCH(*from));
-	} else if (*from == '\\') {
+	} else if (*from == ESCAPE) {
 	    escaped = 1;
 	} else if (prefixed) {
 	    prefixed = 0;
diff --git a/src/LYCurses.c b/src/LYCurses.c
index 17bd2169..06816c06 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYCurses.c,v 1.168 2013/05/01 00:07:08 tom Exp $ */
+/* $LynxId: LYCurses.c,v 1.169 2013/05/03 23:19:18 tom Exp $ */
 #include <HTUtils.h>
 #include <HTAlert.h>
 
@@ -258,33 +258,38 @@ int string_to_attr(const char *name)
 #ifdef USE_COLOR_STYLE
 static char *attr_to_string(int code)
 {
-    static char result[sizeof(Mono_Attrs) + 80];
-    unsigned i;
-    int pair = PAIR_NUMBER((unsigned) code);
-    int bold = (pair != 0 && ((unsigned) code & A_BOLD) != 0);
+    static char *result;
 
-    if (bold)
-	code &= (int) ~A_BOLD;
+    if (code >= 0) {
+	unsigned i;
+	int pair = PAIR_NUMBER((unsigned) code);
+	int bold = (pair != 0 && ((unsigned) code & A_BOLD) != 0);
 
-    *result = 0;
-    for (i = 0; i < TABLESIZE(Mono_Attrs); i++) {
-	if (Mono_Attrs[i].code & code) {
-	    if (*result)
-		strcat(result, "+");
-	    strcat(result, Mono_Attrs[i].name);
-	}
-    }
-    if (pair != 0) {
-	short f, b;
+	StrAllocCopy(result, "");
 
-	if (pair_content((short) pair, &f, &b) != ERR) {
-	    const char *fg = lookup_color(bold ? f + COLORS : f);
-	    const char *bg = lookup_color(b);
+	if (bold)
+	    code &= (int) ~A_BOLD;
 
-	    if (*result)
-		strcat(result, "+");
-	    sprintf(result + strlen(result), "%s/%s", fg, bg);
+	for (i = 0; i < TABLESIZE(Mono_Attrs); i++) {
+	    if (Mono_Attrs[i].code & code) {
+		if (non_empty(result))
+		    StrAllocCat(result, "+");
+		StrAllocCat(result, Mono_Attrs[i].name);
+	    }
 	}
+	if (pair != 0) {
+	    short f, b;
+
+	    if (pair_content((short) pair, &f, &b) != ERR) {
+		if (non_empty(result))
+		    StrAllocCat(result, "+");
+		StrAllocCat(result, lookup_color(bold ? f + COLORS : f));
+		StrAllocCat(result, "/");
+		StrAllocCat(result, lookup_color(b));
+	    }
+	}
+    } else {
+	FREE(result);
     }
     return result;
 }
@@ -422,20 +427,24 @@ void setHashStyle(int style,
 static void LYAttrset(WINDOW * win, int color,
 		      int mono)
 {
+    char *shown = NULL;
+
     if (lynx_has_color
 	&& LYShowColor >= SHOW_COLOR_ON
 	&& color >= 0) {
 	CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset color %#x -> (%s)\n",
-			      color, attr_to_string(color)));
+			      color, shown = attr_to_string(color)));
 	(void) wattrset(win, (unsigned) color);
     } else if (mono >= 0) {
 	CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset mono %#x -> (%s)\n",
-			      mono, attr_to_string(mono)));
+			      mono, shown = attr_to_string(mono)));
 	(void) wattrset(win, (unsigned) mono);
     } else {
 	CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset (A_NORMAL)\n"));
 	(void) wattrset(win, A_NORMAL);
     }
+    if (shown != NULL)
+	(void) attr_to_string(-1);
 }
 
 void curses_w_style(WINDOW * win, int style,
diff --git a/src/LYKeymap.c b/src/LYKeymap.c
index a1b522e9..7adb9b5d 100644
--- a/src/LYKeymap.c
+++ b/src/LYKeymap.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYKeymap.c,v 1.84 2013/01/04 00:04:03 tom Exp $ */
+/* $LynxId: LYKeymap.c,v 1.85 2013/05/03 23:07:29 tom Exp $ */
 #include <HTUtils.h>
 #include <LYUtils.h>
 #include <LYGlobalDefs.h>
@@ -1170,7 +1170,7 @@ char *LYKeycodeToString(int c,
     for (n = 0; n < TABLESIZE(named_keys); n++) {
 	if (named_keys[n].key == c) {
 	    named = TRUE;
-	    strcpy(buf, named_keys[n].name);
+	    LYStrNCpy(buf, named_keys[n].name, sizeof(buf) - 1);
 	    break;
 	}
     }
@@ -1259,7 +1259,7 @@ static char *pretty_html(int c)
 	    for (n = 0; n < TABLESIZE(table); n++) {
 		if (c == table[n].code) {
 		    found = TRUE;
-		    strcpy(dst, table[n].name);
+		    LYStrNCpy(dst, table[n].name, sizeof(dst) - 1);
 		    adj += (int) strlen(dst) - 1;
 		    dst += (int) strlen(dst);
 		    break;
diff --git a/src/LYLocal.c b/src/LYLocal.c
index 181ed7c1..78c35e03 100644
--- a/src/LYLocal.c
+++ b/src/LYLocal.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYLocal.c,v 1.124 2013/05/02 10:42:28 tom Exp $
+ * $LynxId: LYLocal.c,v 1.125 2013/05/03 08:43:42 tom Exp $
  *
  *  Routines to manipulate the local filesystem.
  *  Written by: Rick Mallett, Carleton University
@@ -807,7 +807,7 @@ static int modify_tagged(char *testpath)
     _statusline(gettext("Enter new location for tagged items: "));
 
     BStrCopy0(given_target, "");
-    LYgetBString(&given_target, VISIBLE, 0, NORECALL);
+    (void) LYgetBString(&given_target, VISIBLE, 0, NORECALL);
     if (!isBEmpty(given_target)) {
 	/*
 	 * Replace ~/ references to the home directory.
@@ -2210,7 +2210,7 @@ static int get_filename(const char *prompt,
 
     _statusline(prompt);
 
-    LYgetBString(&buf, VISIBLE, 0, NORECALL);
+    (void) LYgetBString(&buf, VISIBLE, 0, NORECALL);
     if (strstr(buf->str, "../") != NULL) {
 	HTAlert(gettext("Illegal filename; request ignored."));
 	return FALSE;
diff --git a/src/LYMail.c b/src/LYMail.c
index 55115e00..a366f945 100644
--- a/src/LYMail.c
+++ b/src/LYMail.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMail.c,v 1.91 2013/05/02 11:02:26 tom Exp $
+ * $LynxId: LYMail.c,v 1.92 2013/05/03 20:29:37 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTParse.h>
@@ -134,8 +134,7 @@ static void extract_subject(char *dst,
 	    *cp1 = '\0';
 	}
 	if (*cp) {
-	    StrNCpy(dst, cp, MAX_SUBJECT);
-	    dst[MAX_SUBJECT] = '\0';
+	    LYStrNCpy(dst, cp, MAX_SUBJECT);
 	    SafeHTUnEscape(dst);
 	}
 	if (cp1) {
@@ -817,8 +816,7 @@ void mailform(const char *mailto_address,
 	i = 0;
 	len = (int) strlen(mailto_content);
 	while (len > 78) {
-	    StrNCpy(buf, &mailto_content[i], 78);
-	    buf[78] = '\0';
+	    LYStrNCpy(buf, &mailto_content[i], 78);
 	    fprintf(fd, "%s\n", buf);
 	    i += 78;
 	    len = (int) strlen(&mailto_content[i]);
@@ -829,8 +827,7 @@ void mailform(const char *mailto_address,
     i = 0;
     len = (int) strlen(mailto_content);
     while (len > 78) {
-	StrNCpy(buf, &mailto_content[i], 78);
-	buf[78] = '\0';
+	LYStrNCpy(buf, &mailto_content[i], 78);
 	fprintf(fd, "%s\n", buf);
 	i += 78;
 	len = (int) strlen(&mailto_content[i]);
@@ -1273,8 +1270,7 @@ void reply_by_mail(char *mail_address,
      * Set the default subject.  - FM
      */
     if ((default_subject[0] == '\0') && non_empty(title)) {
-	StrNCpy(default_subject, title, MAX_SUBJECT);
-	default_subject[MAX_SUBJECT] = '\0';
+	LYStrNCpy(default_subject, title, MAX_SUBJECT);
     }
 
     /*
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 5521ed6b..481685b8 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMainLoop.c,v 1.215 2013/04/30 22:39:19 tom Exp $
+ * $LynxId: LYMainLoop.c,v 1.216 2013/05/03 20:29:37 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAccess.h>
@@ -7262,8 +7262,7 @@ int mainloop(void)
 		    len = MAX_LINE;	/* Required for do_check_goto_URL() */
 		buf = typeMallocn(char, len);
 
-		StrNCpy(buf, (const char *) s, (e - s));
-		buf[e - s] = '\0';
+		LYStrNCpy(buf, (const char *) s, (e - s));
 		t = (unsigned char *) buf;
 
 		while (s < e) {
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 9d16fb99..3d653e42 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYStrings.c,v 1.208 2013/01/04 01:40:27 tom Exp $ */
+/* $LynxId: LYStrings.c,v 1.212 2013/05/03 20:29:37 tom Exp $ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <UCAux.h>
@@ -576,21 +576,21 @@ char *LYstrncpy(char *dst,
 		const char *src,
 		int n)
 {
-    char *val;
+    char *val = dst;
     int len;
 
     if (src == 0)
 	src = "";
     len = (int) strlen(src);
 
-    if (n < 0)
+    if (n > 0) {
+	if (n > len)
+	    n = len;
+	(void) StrNCpy(dst, src, n);
+    } else {
 	n = 0;
-
-    val = StrNCpy(dst, src, n);
-    if (len < n)
-	*(dst + len) = '\0';
-    else
-	*(dst + n) = '\0';
+    }
+    dst[n] = '\0';
     return val;
 }
 
@@ -924,12 +924,6 @@ static SLKeyMap_List_Type *Keymap_List;
 #define MOUSE_KEYSYM 0x0400
 #endif
 
-#define SQUOTE '\''
-#define DQUOTE '"'
-#define ESCAPE '\\'
-#define LPAREN '('
-#define RPAREN ')'
-
 /*
  * For ncurses, we use the predefined keysyms, since that lets us also reuse
  * the CSI logic and other special cases for VMS, NCSA telnet, etc.
@@ -992,8 +986,7 @@ static const char *expand_tiname(const char *first, size_t len, char **result, c
     char name[BUFSIZ];
     int code;
 
-    StrNCpy(name, first, len);
-    name[len] = '\0';
+    LYStrNCpy(name, first, len);
     if ((code = lookup_tiname(name, strnames)) >= 0
 	|| (code = lookup_tiname(name, strfnames)) >= 0) {
 	if (cur_term->type.Strings[code] != 0) {
@@ -1174,8 +1167,7 @@ int map_string_to_keysym(const char *str, int *keysym)
 	    char buf[BUFSIZ];
 
 	    if (othersym >= 0 && other - str - 4 < BUFSIZ) {
-		StrNCpy(buf, str + 4, (other - str - 4));
-		buf[other - str - 4] = '\0';
+		LYStrNCpy(buf, str + 4, (other - str - 4));
 		*keysym = lacname_to_lac(buf);
 		if (*keysym >= 0) {
 		    *keysym = LACLEC_TO_LKC0(*keysym, othersym);
@@ -5294,6 +5286,7 @@ int LYgetBString(bstring **inputline,
 	    fep_off();
 #endif
 	    LYFinishEdit(edit);
+	    BStrCopy0(*inputline, "");
 	    return (-1);
 
 	case LYE_STOP:
@@ -5304,6 +5297,7 @@ int LYgetBString(bstring **inputline,
 #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION
 	    textfields_need_activation = TRUE;
 	    LYFinishEdit(edit);
+	    BStrCopy0(*inputline, "");
 	    return (-1);
 #else
 #ifdef ENHANCED_LINEEDIT
@@ -5958,8 +5952,7 @@ char *SNACopy(char **dest,
 	    outofmem(__FILE__, "SNACopy");
 	    assert(*dest != NULL);
 	}
-	StrNCpy(*dest, src, n);
-	*(*dest + n) = '\0';	/* terminate */
+	LYStrNCpy(*dest, src, n);
     }
     return *dest;
 }
@@ -5980,8 +5973,7 @@ char *SNACat(char **dest,
 	    if (*dest == NULL)
 		outofmem(__FILE__, "SNACat");
 	    assert(*dest != NULL);
-	    StrNCpy(*dest + length, src, n);
-	    *(*dest + length + n) = '\0';	/* terminate */
+	    LYStrNCpy(*dest + length, src, n);
 	} else {
 	    *dest = typeMallocn(char, (unsigned) n + 1);
 
diff --git a/src/LYStrings.h b/src/LYStrings.h
index 1334a107..219413e9 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYStrings.h,v 1.87 2012/02/10 18:36:39 tom Exp $
+ * $LynxId: LYStrings.h,v 1.88 2013/05/03 09:37:02 tom Exp $
  */
 #ifndef LYSTRINGS_H
 #define LYSTRINGS_H
@@ -9,6 +9,13 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+
+#define SQUOTE '\''
+#define DQUOTE '"'
+#define ESCAPE '\\'
+#define LPAREN '('
+#define RPAREN ')'
+
     typedef const char *const Const2CharPtr;
     typedef enum {
 	NORECALL = 0
diff --git a/src/LYUpload.c b/src/LYUpload.c
index f07550e2..1321ece0 100644
--- a/src/LYUpload.c
+++ b/src/LYUpload.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUpload.c,v 1.36 2012/02/09 15:09:38 tom Exp $
+ * $LynxId: LYUpload.c,v 1.38 2013/05/03 10:53:50 tom Exp $
  *
  *  Routines to upload files to the local filesystem.
  *  Created by: Rick Mallett, Carleton University
@@ -175,19 +175,16 @@ int LYUpload_options(char **newfile,
     FILE *fp0;
     lynx_list_item_type *cur_upload;
     int count;
-    static char curloc[LY_MAXPATH];
-    char *cp;
+    char *curloc = NULL;
 
     if ((fp0 = InternalPageFP(tempfile, TRUE)) == 0)
 	return (-1);
 
 #ifdef VMS
-    strcpy(curloc, "/sys$login");
+    StrAllocCopy(curloc, "/sys$login");
 #else
-    cp = HTfullURL_toFile(directory);
-    strcpy(curloc, cp);
+    StrAllocCopy(curloc, HTfullURL_toFile(directory));
     LYTrimPathSep(curloc);
-    FREE(cp);
 #endif /* VMS */
 
     LYLocalFileToURL(newfile, tempfile);
@@ -218,6 +215,7 @@ int LYUpload_options(char **newfile,
     LYCloseTempFP(fp0);
 
     LYforce_no_cache = TRUE;
+    FREE(curloc);
 
     return (0);
 }
diff --git a/src/LYUtils.c b/src/LYUtils.c
index e378e4b7..51fd6526 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.237 2013/05/02 11:00:14 tom Exp $
+ * $LynxId: LYUtils.c,v 1.238 2013/05/03 20:21:20 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -1473,7 +1473,7 @@ void statusline(const char *text)
 	len = (int) strlen(text_buff);
 	if (len >= (int) (sizeof(buffer) - 1))
 	    len = (int) (sizeof(buffer) - 1);
-	StrNCpy(buffer, text_buff, len)[len] = '\0';
+	LYStrNCpy(buffer, text_buff, len);
 	/* FIXME: a binary search might be faster */
 	while (len > 0 && LYstrExtent(buffer, len, len) > max_length)
 	    buffer[--len] = '\0';
diff --git a/src/LYmktime.c b/src/LYmktime.c
index ac4b6088..54356db2 100644
--- a/src/LYmktime.c
+++ b/src/LYmktime.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYmktime.c,v 1.13 2011/05/24 09:51:41 tom Exp $ */
+/* $LynxId: LYmktime.c,v 1.14 2013/05/03 20:14:06 tom Exp $ */
 
 #include <LYStrings.h>
 #include <LYUtils.h>
@@ -106,7 +106,7 @@ time_t LYmktime(char *string,
 	s++;
     if (*s == '\0' || (s - start) > 2)
 	return (0);
-    LYstrncpy(temp, start, (int) (s - start));
+    LYStrNCpy(temp, start, (s - start));
     day = atoi(temp);
     if (day < 1 || day > 31)
 	return (0);
@@ -125,7 +125,7 @@ time_t LYmktime(char *string,
 	(s - start) < (isdigit(UCH(*(s - 1))) ? 2 : 3) ||
 	(s - start) > (isdigit(UCH(*(s - 1))) ? 2 : 9))
 	return (0);
-    LYstrncpy(temp, start, (isdigit(UCH(*(s - 1))) ? 2 : 3));
+    LYStrNCpy(temp, start, (isdigit(UCH(*(s - 1))) ? 2 : 3));
     switch (TOUPPER(temp[0])) {
     case '0':
     case '1':
@@ -213,7 +213,7 @@ time_t LYmktime(char *string,
     while (*s != '\0' && isdigit(UCH(*s)))
 	s++;
     if ((s - start) == 4) {
-	LYstrncpy(temp, start, 4);
+	LYStrNCpy(temp, start, 4);
     } else if ((s - start) == 2) {
 	now = time(NULL);
 	/*
@@ -226,9 +226,9 @@ time_t LYmktime(char *string,
 	 * in 2100 -- setting up the next crisis...) - BL
 	 */
 	if (atoi(start) >= 70)
-	    LYstrncpy(temp, "19", 2);
+	    LYStrNCpy(temp, "19", 2);
 	else
-	    LYstrncpy(temp, "20", 2);
+	    LYStrNCpy(temp, "20", 2);
 	strncat(temp, start, 2);
 	temp[4] = '\0';
     } else {
@@ -251,7 +251,7 @@ time_t LYmktime(char *string,
 	    s++;
 	if (*s != ':' || (s - start) > 2)
 	    return (0);
-	LYstrncpy(temp, start, (int) (s - start));
+	LYStrNCpy(temp, start, (s - start));
 	hour = atoi(temp);
 
 	/*
@@ -266,7 +266,7 @@ time_t LYmktime(char *string,
 	    s++;
 	if (*s != ':' || (s - start) > 2)
 	    return (0);
-	LYstrncpy(temp, start, (int) (s - start));
+	LYStrNCpy(temp, start, (s - start));
 	minutes = atoi(temp);
 
 	/*
@@ -281,7 +281,7 @@ time_t LYmktime(char *string,
 	    s++;
 	if (*s == '\0' || (s - start) > 2)
 	    return (0);
-	LYstrncpy(temp, start, (int) (s - start));
+	LYStrNCpy(temp, start, (s - start));
 	seconds = atoi(temp);
     }
 
diff --git a/src/UCAuto.c b/src/UCAuto.c
index 92936546..4fc0927c 100644
--- a/src/UCAuto.c
+++ b/src/UCAuto.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: UCAuto.c,v 1.49 2013/04/30 09:20:19 tom Exp $
+ * $LynxId: UCAuto.c,v 1.50 2013/05/03 20:30:33 tom Exp $
  *
  *  This file contains code for changing the Linux console mode.
  *  Currently some names for font files are hardwired in here.
@@ -637,8 +637,7 @@ int Find_Best_Display_Charset(int ord)
 	HTInfoMsg(gettext("Charset name in CHARSET_SWITCH_RULES too long"));
 	return ord;
     }
-    StrNCpy(buf, r, s - r);
-    buf[s - r] = '\0';
+    LYStrNCpy(buf, r, s - r);
     n = UCGetLYhndl_byMIME(buf);
     if (n < 0) {
 	sprintf(buf,
@@ -733,7 +732,8 @@ static int _Switch_Display_Charset(int ord, enum switch_display_charset_t really
 
 	rc = VioGetFont(font, 0);	/* Retrieve data for current font */
 	if (rc) {
-	    sprintf(msgbuf, gettext("Can't fetch current font info: err=%#x=%d"), rc, rc);
+	    sprintf(msgbuf,
+		    gettext("Can't fetch current font info: err=%#x=%d"), rc, rc);
 	    HTInfoMsg(msgbuf);
 	    ord = ord1 = auto_display_charset;
 	    goto retry;