[Pkg-mc-commits] r161 - in trunk/debian: . patches patches/bugs

winnie at alioth.debian.org winnie at alioth.debian.org
Mon Jun 23 20:16:27 UTC 2008


Author: winnie
Date: 2008-06-23 20:16:26 +0000 (Mon, 23 Jun 2008)
New Revision: 161

Added:
   trunk/debian/patches/bugs/99a_fix-regex-bol-match.patch
   trunk/debian/patches/bugs/99b_fix-regex-pattern-lengths.patch
   trunk/debian/patches/bugs/99c_fix-regex-newline-match.patch
Removed:
   trunk/debian/patches/bugs/99_regexp-replace-fixed.patch
Modified:
   trunk/debian/changelog
   trunk/debian/patches/all.series
Log:
Fix some more issues


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2008-06-21 13:13:53 UTC (rev 160)
+++ trunk/debian/changelog	2008-06-23 20:16:26 UTC (rev 161)
@@ -13,11 +13,12 @@
   * Fix tar call in mc.ext (Closes: #381353)
   * Suggest dbview. Thanks to Daniel Hahler. (Closes: #486915) 
   * Do not use internal editor per default. (Closes: #413258)
+  * Fix regex patch supplied by Michal Pokrywka (Closes: #487611, #486676)
   * For those who read this changelog: There are very many unresolved bugs
     left in the BTS, it would be cool if someone who has some C coding
     experience would have a look on some and write patches. Thanks in advance.
 
- -- Patrick Winnertz <winnie at debian.org>  Sat, 21 Jun 2008 00:00:18 +0200
+ -- Patrick Winnertz <winnie at debian.org>  Mon, 23 Jun 2008 22:12:28 +0200
 
 mc (2:4.6.2~git20080311-1) unstable; urgency=low
 

Modified: trunk/debian/patches/all.series
===================================================================
--- trunk/debian/patches/all.series	2008-06-21 13:13:53 UTC (rev 160)
+++ trunk/debian/patches/all.series	2008-06-23 20:16:26 UTC (rev 161)
@@ -1,6 +1,9 @@
 bugs/28_mc-dontrewrite.patch
 bugs/61_escaping.patch
 bugs/64_visible_tabs.patch
+bugs/99a_fix-regex-bol-match.patch
+bugs/99b_fix-regex-pattern-lengths.patch
+bugs/99c_fix-regex-newline-match.patch
 debian/01_correct_conffile_paths_in_man.patch
 debian/02_use_correct_smb_conf_path.patch
 debian/04_debian_menu_additions.patch

Deleted: trunk/debian/patches/bugs/99_regexp-replace-fixed.patch
===================================================================
--- trunk/debian/patches/bugs/99_regexp-replace-fixed.patch	2008-06-21 13:13:53 UTC (rev 160)
+++ trunk/debian/patches/bugs/99_regexp-replace-fixed.patch	2008-06-23 20:16:26 UTC (rev 161)
@@ -1,337 +0,0 @@
---- mc-4.6.2~pre1/edit/editcmd.c.orig	2008-04-06 02:25:23.000000000 +0200
-+++ mc-4.6.2~pre1/edit/editcmd.c	2008-04-06 02:40:29.000000000 +0200
-@@ -2074,6 +2074,24 @@
-     edit_error_dialog (_("Error"), _(" Invalid regular expression, or scanf expression with too many conversions "));
- }
- 
-+int mc_isdigit(mc_wchar_t c)
-+{
-+#ifndef UTF8
-+    return isdigit(c);
-+#else /* UTF8 */
-+    return iswdigit(c);
-+#endif /* UTF8 */
-+}
-+
-+mc_wchar_t * mc_memmove(mc_wchar_t *to, mc_wchar_t *from, size_t size)
-+{
-+#ifndef UTF8
-+    return memmove(to, from, size);
-+#else /* UTF8 */
-+    return wmemmove(to, from, size);
-+#endif /* UTF8 */
-+}
-+
- /* call with edit = 0 before shutdown to close memory leaks */
- void
- edit_replace_cmd (WEdit *edit, int again)
-@@ -2090,6 +2108,8 @@
-     int replace_continue;
-     int treplace_prompt = 0;
-     long times_replaced = 0, last_search;
-+    mc_wchar_t *repl_templ;
-+    mc_wchar_t *repl_str;
-     int argord[NUM_REPL_ARGS];
- 
-     if (!edit) {
-@@ -2143,7 +2163,96 @@
- 
-     }
- 
--    {
-+#ifndef UTF8
-+    repl_templ = g_strdup(input2);
-+#else /* UTF8 */
-+    repl_templ = mbstr_to_wchar(input2);
-+#endif /* UTF8 */
-+
-+    if (replace_regexp) {
-+	/*
-+	 * edit replace template - convert subpattern references (\1) to
-+	 * snprintf_p arguments (%s) and fill "argord" array to match captured
-+	 * subpatterns
-+	 */
-+	int ao;
-+	int ord;
-+	mc_wchar_t *s;
-+	mc_wchar_t *param;
-+	mc_wchar_t *endptr;
-+#ifndef UTF8
-+#define char_0		'0'
-+#define char_backslash	'\\'
-+#define char_percent	'%'
-+#define char_s		's'
-+#define char_n		'n'
-+#define char_r		'r'
-+#define char_t		't'
-+#define char_lf		'\n'
-+#define char_cr		'\r'
-+#define char_tab	'\t'
-+#else /* UTF8 */
-+#define char_0		L'0'
-+#define char_backslash	L'\\'
-+#define char_percent	L'%'
-+#define char_s		L's'
-+#define char_n		L'n'
-+#define char_r		L'r'
-+#define char_t		L't'
-+#define char_lf		L'\n'
-+#define char_cr		L'\r'
-+#define char_tab	L'\t'
-+#endif /* UTF8 */
-+
-+#ifndef UTF8
-+	endptr = strchr(repl_templ, '\0');
-+#else /* UTF8 */
-+	endptr = wcschr(repl_templ, L'\0');
-+#endif /* UTF8 */
-+	s = repl_templ;
-+	ao = 0;
-+	while ((
-+#ifndef UTF8
-+	    s = strchr(s, char_backslash)
-+#else /* UTF8 */
-+	    s = wcschr(s, char_backslash)
-+#endif /* UTF8 */
-+		)) {
-+	    param = s;
-+	    s++;
-+	    if (!s) break;
-+	    /* implement \n \r and \t escape sequences in replace string */
-+	    if (*s == char_n) {
-+		*s = char_lf;
-+	    } else if (*s == char_r) {
-+		*s = char_lf;
-+	    } else if (*s == char_t) {
-+		*s = char_tab;
-+	    }
-+	    if (!mc_isdigit(*s)) {
-+		mc_memmove(param, s, endptr - s + 1);
-+		continue;
-+	    }
-+	    ord = 0;
-+	    while (mc_isdigit(*s)) {
-+		ord *= 10;
-+		ord += *s - char_0;
-+		s++;
-+	    }
-+	    if ((ord > 0) && (ord <= NUM_REPL_ARGS)) {
-+		argord[ao++] = ord - 1;
-+		*param++ = char_percent;
-+		*param++ = char_s;
-+		mc_memmove(param, s, endptr - s + 1);
-+		s = param;
-+	    }
-+	}
-+	while (ao < NUM_REPL_ARGS) {
-+	    argord[ao] = ao;
-+	    ao++;
-+	}
-+
-+    } else {
- 	const char *s;
- 	int ord;
- 	size_t i;
-@@ -2174,6 +2283,12 @@
- 	&& !replace_backwards)
- 	edit->search_start++;
- 
-+    if (replace_scanf || replace_regexp) {
-+	repl_str = g_malloc(((MAX_REPL_LEN + 2)+1) * sizeof(mc_wchar_t));
-+    } else {
-+	repl_str = repl_templ;
-+    }
-+
-     do {
- 	int len = 0;
- 	long new_start;
-@@ -2198,8 +2313,55 @@
- 
- 	    replace_yes = 1;
- 
-+	    if (replace_scanf || replace_regexp) {
-+		int ret = 0;
-+
-+		/* we need to fill in sargs just like with scanf */
-+		if (replace_regexp) {
-+		    int k, j;
-+		    for (k = 1; k < NUM_REPL_ARGS && pmatch[k].rm_eo >= 0;
-+			k++) {
-+#ifndef UTF8
-+			unsigned char *t;
-+#else /* UTF8 */
-+			mc_wchar_t *t;
-+#endif
-+
-+			if (pmatch[k].rm_eo - pmatch[k].rm_so > 255) {
-+			    ret = -1;
-+			    break;
-+			}
-+#ifndef UTF8
-+			t = (unsigned char *) &sargs[k - 1][0];
-+#else /* UTF8 */
-+			t = (mc_wchar_t *) &sargs[k - 1][0];
-+#endif /* UTF8 */
-+			for (j = 0; j < pmatch[k].rm_eo - pmatch[k].rm_so &&
-+			    j < 255; j++, t++)
-+			    *t = edit_get_byte (edit, edit->search_start -
-+				pmatch[0].rm_so + pmatch[k].rm_so + j);
-+			*t = '\0';
-+		    }
-+		    for (; k <= NUM_REPL_ARGS; k++)
-+			sargs[k - 1][0] = 0;
-+		}
-+		if (ret >= 0)
-+		    ret = snprintf_p (repl_str, MAX_REPL_LEN + 2, repl_templ,
-+					PRINTF_ARGS);
-+		if (ret < 0) {
-+		    edit_error_dialog (_(" Replace "),
-+			ret == -2
-+			    ? _(" Error in replacement format string. ")
-+			    : _(" Replacement too long. "));
-+		    treplace_prompt = 0;
-+		    replace_yes = 0;
-+		    replace_continue = 0;
-+		}
-+	    }
-+
- 	    if (treplace_prompt) {
- 		int l;
-+		char *displ_repl_str;
- 		l = edit->curs_row - edit->num_widget_lines / 3;
- 		if (l > 0)
- 		    edit_scroll_downward (edit, l);
-@@ -2213,7 +2375,13 @@
- 		/*so that undo stops at each query */
- 		edit_push_key_press (edit);
- 
--		switch (edit_replace_prompt (edit, input2,	/* and prompt 2/3 down */
-+#ifndef UTF8
-+		displ_repl_str = g_strdup(repl_str);
-+#else /* UTF8 */
-+		displ_repl_str = wchar_to_mbstr(repl_str);
-+#endif /* UTF8 */
-+		convert_to_display (displ_repl_str);
-+		switch (edit_replace_prompt (edit, displ_repl_str,	/* and prompt 2/3 down */
- 					     (edit->num_widget_columns -
- 					      CONFIRM_DLG_WIDTH) / 2,
- 					     edit->num_widget_lines * 2 /
-@@ -2235,99 +2403,15 @@
- 		    replace_continue = 0;
- 		    break;
- 		}
-+		g_free(displ_repl_str);
- 	    }
- 	    if (replace_yes) {	/* delete then insert new */
--#ifdef UTF8
--		mc_wchar_t *winput2 = mbstr_to_wchar(input2);
--#endif /* UTF8 */
--		if (replace_scanf) {
--		    mc_wchar_t repl_str[MAX_REPL_LEN + 2];
--		    int ret = 0;
--
--		    /* we need to fill in sargs just like with scanf */
--		    if (replace_regexp) {
--			int k, j;
--			for (k = 1;
--			     k < NUM_REPL_ARGS && pmatch[k].rm_eo >= 0;
--			     k++) {
--#ifndef UTF8
--			    unsigned char *t;
--#else /* UTF8 */
--			    mc_wchar_t *t;
--#endif
--
--			    if (pmatch[k].rm_eo - pmatch[k].rm_so > 255) {
--				ret = -1;
--				break;
--			    }
--#ifndef UTF8
--			    t = (unsigned char *) &sargs[k - 1][0];
--#else /* UTF8 */
--			    t = (mc_wchar_t *) &sargs[k - 1][0];
--#endif /* UTF8 */
--			    for (j = 0;
--				 j < pmatch[k].rm_eo - pmatch[k].rm_so
--				 && j < 255; j++, t++)
--				*t = edit_get_byte (edit,
--								    edit->
--								    search_start
--								    -
--								    pmatch
--								    [0].
--								    rm_so +
--								    pmatch
--								    [k].
--								    rm_so +
--								    j);
--			    *t = '\0';
--			}
--			for (; k <= NUM_REPL_ARGS; k++)
--			    sargs[k - 1][0] = 0;
--		    }
--		    if (!ret)
--			ret =
--#ifndef UTF8
--			    snprintf_p (repl_str, MAX_REPL_LEN + 2, input2,
--#else /* UTF8 */
--			    snprintf_p (repl_str, MAX_REPL_LEN + 2, winput2,
--#endif /* UTF8 */
--					PRINTF_ARGS);
--		    if (ret >= 0) {
--			times_replaced++;
--			while (i--)
--			    edit_delete (edit);
--#ifndef UTF8
--			while (repl_str[++i])
--			    edit_insert (edit, repl_str[i]);
--#else /* UTF8 */
--			while (winput2[++i])
--			    edit_insert (edit, winput2[i]);
--#endif /* UTF8 */
--		    } else {
--			edit_error_dialog (_(" Replace "),
--					   ret ==
--					   -2 ?
--					   _
--					   (" Error in replacement format string. ")
--					   : _(" Replacement too long. "));
--			replace_continue = 0;
--		    }
--		} else {
--		    times_replaced++;
--		    while (i--)
--			edit_delete (edit);
--#ifndef UTF8
--		    while (input2[++i])
--			edit_insert (edit, input2[i]);
--#else /* UTF8 */
--		    while (winput2[++i])
--			edit_insert (edit, winput2[i]);
--#endif /* UTF8 */
--		}
-+		times_replaced++;
-+		while (i--)
-+		    edit_delete (edit);
-+		while (repl_str[++i])
-+		    edit_insert (edit, repl_str[i]);
- 		edit->found_len = i;
--#ifdef UTF8
--		g_free (winput2);
--#endif /* UTF8 */
- 	    }
- 	    /* so that we don't find the same string again */
- 	    if (replace_backwards) {
-@@ -2356,6 +2440,12 @@
- 	}
-     } while (replace_continue);
- 
-+    /* cleanup */
-+    if (replace_scanf || replace_regexp) {
-+	g_free(repl_str);
-+    }
-+    g_free(repl_templ);
-+
-     edit->force = REDRAW_COMPLETELY;
-     edit_scroll_screen_over_cursor (edit);
-   cleanup:

Added: trunk/debian/patches/bugs/99a_fix-regex-bol-match.patch
===================================================================
--- trunk/debian/patches/bugs/99a_fix-regex-bol-match.patch	                        (rev 0)
+++ trunk/debian/patches/bugs/99a_fix-regex-bol-match.patch	2008-06-23 20:16:26 UTC (rev 161)
@@ -0,0 +1,14 @@
+Fix regexp matching beginning of line, bol was matched at cursor after
+starting regexp replace.
+
+--- mc-4.6.2~git20080311/edit/editcmd.c.orig	2008-06-22 16:58:16.000000000 +0200
++++ mc-4.6.2~git20080311/edit/editcmd.c	2008-06-22 16:58:53.000000000 +0200
+@@ -1721,7 +1721,7 @@
+ 	    int found_start, match_bol, move_win = 0;
+ 
+ 	    while (start + offset < last_byte) {
+-		match_bol = (offset == 0 || (*get_byte) (data, start + offset - 1) == '\n');
++		match_bol = (start == 0 || (*get_byte) (data, start + offset - 1) == '\n');
+ 		if (!move_win) {
+ 		    p = start + offset;
+ 		    q = 0;

Added: trunk/debian/patches/bugs/99b_fix-regex-pattern-lengths.patch
===================================================================
--- trunk/debian/patches/bugs/99b_fix-regex-pattern-lengths.patch	                        (rev 0)
+++ trunk/debian/patches/bugs/99b_fix-regex-pattern-lengths.patch	2008-06-23 20:16:26 UTC (rev 161)
@@ -0,0 +1,57 @@
+Fix subpattern byte offsets computation, previously mbstrlen function was used
+which chokes on nonprinting characters, regex substrings that captured tab
+characters were truncated.
+
+--- mc-4.6.2~git20080311/edit/editcmd.c.orig	2008-06-23 01:48:03.000000000 +0200
++++ mc-4.6.2~git20080311/edit/editcmd.c	2008-06-23 01:58:32.000000000 +0200
+@@ -1511,6 +1511,32 @@
+ 		     sargs[argord[8]], sargs[argord[9]], sargs[argord[10]], sargs[argord[11]], \
+ 		     sargs[argord[12]], sargs[argord[13]], sargs[argord[14]], sargs[argord[15]]
+ 
++#ifdef UTF8
++size_t
++real_mbstrlen (const char *str)
++{
++    if (SLsmg_Is_Unicode) {
++        size_t width = 0;
++
++        for (; *str; str++) {
++            wchar_t c;
++            size_t len;
++
++            len = mbrtowc (&c, str, MB_CUR_MAX, NULL);
++	    
++            if (len == (size_t)(-1) || len == (size_t)(-2)) break;
++	    
++            if (len > 0) {
++                width ++;
++                str += len-1;
++            }
++        }
++
++        return width;
++    } else
++	return strlen (str);
++}
++#endif
+ 
+ /* This function is a modification of mc-3.2.10/src/view.c:regexp_view_search() */
+ /* returns -3 on error in pattern, -1 on not found, found_len = 0 if either */
+@@ -1581,7 +1607,7 @@
+ 	    continue;
+ 	tmp = string[pmatch[i].rm_so];
+ 	string[pmatch[i].rm_so] = 0;
+-	new_o = mbstrlen(string);
++	new_o = real_mbstrlen(string);
+ 	string[pmatch[i].rm_so] = tmp;
+ 	pmatch[i].rm_so = new_o; 
+ 
+@@ -1589,7 +1615,7 @@
+ 	    continue;
+ 	tmp = string[pmatch[i].rm_eo];
+ 	string[pmatch[i].rm_eo] = 0;
+-	new_o = mbstrlen(string);
++	new_o = real_mbstrlen(string);
+ 	string[pmatch[i].rm_eo] = tmp;
+ 	pmatch[i].rm_eo = new_o; 
+     }

Added: trunk/debian/patches/bugs/99c_fix-regex-newline-match.patch
===================================================================
--- trunk/debian/patches/bugs/99c_fix-regex-newline-match.patch	                        (rev 0)
+++ trunk/debian/patches/bugs/99c_fix-regex-newline-match.patch	2008-06-23 20:16:26 UTC (rev 161)
@@ -0,0 +1,16 @@
+Add REG_NEWLINE flag to regexp replace matching as it is unusual for '.' to
+match newline, edit_find_string function already splits data on newlines before
+passing it to string_regexp_search so multiline matching is already crippled.
+
+--- mc-4.6.2~git20080311/edit/editcmd.c.orig	2008-06-23 02:22:30.000000000 +0200
++++ mc-4.6.2~git20080311/edit/editcmd.c	2008-06-23 02:23:34.000000000 +0200
+@@ -1570,7 +1570,8 @@
+ 	    g_free (old_pattern);
+ 	    old_pattern = 0;
+ 	}
+-	if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0))) {
++	if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0) |
++	    REG_NEWLINE)) {
+ 	    *found_len = 0;
+ 	    return -3;
+ 	}




More information about the Pkg-mc-commits mailing list