mcedit issues



Hello, Rolland,

your last "simplification" remove charset conversion.
Also some people collect all of used glib stuff in our glibcompat.c
to eliminate libglib dependancy, and so you enforce them to import g_string_*()
there.

-- 
Regards,
Andrew V. Samoilov.
edit/ChangeLog:

	* syntax.c (get_args): Use "argc" to check "args" size.
	(edit_read_syntax_rules): Add new parameter "argc" (size of the
	"args" buffer) to prevent buffer overflow.

	* editcmd.c (edit_replace_prompt): Rollback last "simplification"
	to resurrect charset conversion and eliminate g_string_* usage.
	
--- edit/syntax.c~	Mon Oct 18 11:28:20 2004
+++ edit/syntax.c	Thu Nov  4 19:33:19 2004
@@ -564,8 +564,8 @@ static char *convert (char *s)
 
 static void get_args (char *l, char **args, int *argc)
 {
-    *argc = 0;
-    for (;;) {
+    int i;
+    for (i = 1; i < *argc; i++) {
 	char *p = l;
 	while (*p && whiteness (*p))
 	    p++;
@@ -574,11 +574,10 @@ static void get_args (char *l, char **ar
 	for (l = p + 1; *l && !whiteness (*l); l++);
 	if (*l)
 	    *l++ = '\0';
-	*args = convert (p);
-	(*argc)++;
-	args++;
+	*args++ = convert (p);
     }
-    *args = 0;
+    *args = (char *) NULL;
+    *argc = i;
 }
 
 #define free_args(x)
@@ -639,7 +638,7 @@ static FILE *open_include_file (const ch
 
 /* returns line number on error */
 static int
-edit_read_syntax_rules (WEdit *edit, FILE *f, char **args)
+edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int argc)
 {
     FILE *g = 0;
     char *fg, *bg;
@@ -650,7 +649,7 @@ edit_read_syntax_rules (WEdit *edit, FIL
     int save_line = 0, line = 0;
     struct context_rule **r, *c = 0;
     int num_words = -1, num_contexts = -1;
-    int argc, result = 0;
+    int result = 0;
     int i, j;
     int alloc_contexts = MAX_CONTEXTS,
     	alloc_words_per_context = MAX_WORDS_PER_CONTEXT,
@@ -1036,8 +1035,8 @@ edit_read_syntax_file (WEdit * edit, cha
 		int line_error;
 		char *syntax_type;
 	      found_type:
-		syntax_type =  args[2];
-		line_error = edit_read_syntax_rules (edit, g ? g : f, args);
+		syntax_type = args[2];
+		line_error = edit_read_syntax_rules (edit, g ? g : f, args, 1024);
 		if (line_error) {
 		    if (!error_file_name)	/* an included file */
 			result = line + line_error;
--- edit/editcmd.c.orig	Thu Nov  4 20:12:16 2004
+++ edit/editcmd.c	Thu Nov  4 20:19:09 2004
@@ -1181,15 +1181,15 @@ edit_replace_prompt (WEdit * edit, char 
 	 0, 0, 0, 0, 0},
 	 NULL_QuickWidget};
 
-    GString *label_text = g_string_new (_(" Replace with: "));
+    char *msg = _(" Replace with: ");
     if (*replace_text) {
-        g_string_append (label_text, replace_text);
-        convert_to_display (label_text->str + label_text->len);
+	size_t msg_len = strlen (msg);
+	msg = catstrs (msg, replace_text, (char *) NULL);
+	convert_to_display (msg + msg_len);
     }
-    quick_widgets[5].text = label_text->str;
+    quick_widgets[5].text = msg;
 
     {
-    	int retval;
 	QuickDialog Quick_input =
 	{CONFIRM_DLG_WIDTH, CONFIRM_DLG_HEIGTH, 0, 0, N_ (" Confirm replace "),
 	 "[Input Line Keys]", 0 /*quick_widgets */, 0 };
@@ -1204,9 +1204,7 @@ edit_replace_prompt (WEdit * edit, char 
 	    ypos -= CONFIRM_DLG_HEIGTH;
 
 	Quick_input.ypos = ypos;
-	retval = quick_dialog (&Quick_input);
-	g_string_free (label_text, TRUE);
-	return retval;
+	return quick_dialog (&Quick_input);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]