about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LYForms.c19
-rw-r--r--src/LYStrings.c17
-rw-r--r--src/LYStrings.h5
-rw-r--r--src/LYUtils.c6
4 files changed, 33 insertions, 14 deletions
diff --git a/src/LYForms.c b/src/LYForms.c
index 5573277f..ef832d9c 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -1,3 +1,4 @@
+/* $LynxId: LYForms.c,v 1.76 2008/09/05 00:28:05 tom Exp $ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <HTTP.h>
@@ -204,7 +205,7 @@ int change_form_link_ex(int cur,
     case F_PASSWORD_TYPE:
 	c = form_getstr(cur, use_last_tfpos, redraw_only);
 	LYSetHilite(cur, (form->type == F_PASSWORD_TYPE)
-		    ? STARS(strlen(form->value))
+		    ? STARS(LYstrCells(form->value))
 		    : form->value);
 	break;
 
@@ -457,8 +458,9 @@ static int form_getstr(int cur,
     }
 #endif /* TEXTFIELDS_MAY_NEED_ACTIVATION && INACTIVE_INPUT_STYLE_VH */
     LYRefreshEdit(&MyEdit);
-    if (redraw_only)
+    if (redraw_only) {
 	return 0;		/*return value won't be analysed */
+    }
 
     /*
      * And go for it!
@@ -686,7 +688,7 @@ static int form_getstr(int cur,
 	switch (ch) {
 	default:
 	    /* [ 1999/04/14 (Wed) 15:01:33 ]
-	     * Left arrrow in column 0 deserves special treatment here, else
+	     * Left arrow in column 0 deserves special treatment here, else
 	     * you can get trapped in a form without submit button!
 	     */
 	    if (action == LYE_BACK && MyEdit.pos == 0 && repeat == -1) {
@@ -798,7 +800,6 @@ static int form_getstr(int cur,
     }
   breakfor:
     if (Edited) {
-	char *p;
 
 	/*
 	 * Load the new value.
@@ -810,10 +811,13 @@ static int form_getstr(int cur,
 	     */
 	    StrAllocCopy(form->value, MyEdit.buffer);
 	} else {
+	    int old_len = strlen(form->value);
+	    int new_len = strlen(value);
+
 	    /*
 	     * Combine the modified tail with the unmodified head.  - FM
 	     */
-	    form->value[(strlen(form->value) - strlen(value))] = '\0';
+	    form->value[(old_len > new_len) ? (old_len - new_len) : 0] = '\0';
 	    StrAllocCat(form->value, MyEdit.buffer);
 	    HTUserMsg(FORM_TAIL_COMBINED_WITH_HEAD);
 	}
@@ -828,10 +832,7 @@ static int form_getstr(int cur,
 	 * form????
 	 */
 	if (LYtrimInputFields) {
-	    p = &(form->value[strlen(form->value)]);
-	    while ((p != form->value) && (p[-1] == ' '))
-		p--;
-	    *p = '\0';
+	    LYTrimTrailing(form->value);
 	}
 
 	/*
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 3ac742a1..41083eed 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYStrings.c,v 1.146 2008/09/04 00:21:11 tom Exp $ */
+/* $LynxId: LYStrings.c,v 1.147 2008/09/05 00:17:48 tom Exp $ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <UCAux.h>
@@ -662,6 +662,21 @@ const char *LYmbcs_skip_glyphs(const char *data,
     return data;
 }
 
+const char *LYmbcs_skip_cells(const char *data,
+			      int n_cells,
+			      BOOL utf_flag)
+{
+    const char *result;
+    int actual;
+    int target = n_cells;
+
+    do {
+	result = LYmbcs_skip_glyphs(data, target--, utf_flag);
+	actual = LYstrExtent2(data, result - data);
+    } while ((actual > 0) && (actual > n_cells));
+    return result;
+}
+
 /*
  * LYmbcsstrlen() returns the printable length of a string that might contain
  * IsSpecial or multibyte (CJK or UTF8) characters.  - FM
diff --git a/src/LYStrings.h b/src/LYStrings.h
index 4e821cf4..85d0958c 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYStrings.h,v 1.66 2008/09/01 15:09:03 tom Exp $
+ * $LynxId: LYStrings.h,v 1.67 2008/09/05 00:18:18 tom Exp $
  */
 #ifndef LYSTRINGS_H
 #define LYSTRINGS_H
@@ -53,6 +53,9 @@ extern "C" {
 			       int n_bytes,
 			       int n_glyphs,
 			       BOOL utf_flag);
+    extern const char *LYmbcs_skip_cells(const char *data,
+					 int n_cells,
+					 BOOL utf_flag);
     extern const char *LYmbcs_skip_glyphs(const char *data,
 					  int n_glyphs,
 					  BOOL utf_flag);
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 4a7063ab..7b1cb164 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYUtils.c,v 1.169 2008/08/31 19:03:45 tom Exp $ */
+/* $LynxId: LYUtils.c,v 1.170 2008/09/05 00:19:21 tom Exp $ */
 #include <HTUtils.h>
 #include <HTTCP.h>
 #include <HTParse.h>
@@ -1091,8 +1091,8 @@ void LYhighlight(int flag,
 	    if (avail_space > links[cur].l_form->size)
 		avail_space = links[cur].l_form->size;
 
-	    gllen = LYmbcsstrlen(text, utf_flag, NO);
-	    len = LYmbcs_skip_glyphs(text, avail_space, utf_flag) - text;
+	    gllen = LYmbcsstrlen(text, utf_flag, YES);
+	    len = LYmbcs_skip_cells(text, avail_space, utf_flag) - text;
 	    LYwaddnstr(LYwin, text, len);
 	    while (gllen++ < avail_space)
 		LYaddch('_');