Mailfs Bugs/Patches

2009-06-17 Thread Peter Daum

Hi,

With the current mailfs implementation, I ran into some problems:

1.) By definition (see e.g. http://www.qmail.org/man/man5/mbox.html),
in a Berkeley MBox File,the beginning of a message is marked by a line
starting with From  (_exactly_ like this)
at the beginning of the file or after an empty line.
So the regex /^from\s+\w+(\.\w+)*@/i currently used is just wrong, because
- any other capitalization of from does _not_ introduce a new message
- anything else following afterwards is optional
2.) malformed date headers currently will produce a warning

Regards,
 Peter
--- mailfs.mc_dist	2009-01-25 13:36:48.0 +0100
+++ mailfs	2009-06-17 10:25:39.0 +0200
@@ -15,7 +15,7 @@
 import Date::Parse;
 $parse_date=
 	sub {
-	local $ftime = str2time($_[0],$TZ);
+	local $ftime = str2time($_[0],$TZ) || return $fallback;
 	$_ = localtime($ftime);
 	/^(...) (...) ([ \d]\d) (\d\d:\d\d):\d\d (\d\d\d\d)$/;
 	if ($ftime + 6 * 30 * 24 * 60 * 60  $now ||
@@ -135,7 +135,7 @@
 
 while(IN) {
 	s/\r$//;
-	if($blank  /^from\s+\w+(\.\w+)*@/i) { # Start of header
+	if($blank  /^From /) { # Start of header
 	print_dir_line unless (!$msg_nr);
 	$size=length;
 	$msg_nr++;
@@ -160,7 +160,7 @@
 my $blank = 1;
 while(IN) {
 	s/\r$//;
-	if($blank  /^from\s+\w+(\.\w+)*@/i) {
+if($blank  /^From /) {
 	$msg_nr++;
 	exit(0) if ($msg_nr  $nr);
 	$blank= 0;
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


[PATCH] trivial optimization in file.c::panel_operate()

2009-06-17 Thread Denys Vlasenko
Hi Slava,

I noticed an incorrectly indented if() in file.c::panel_operate().
Took a better look, and found out it can be tweaked in several ways.

This patch is the result.
It contains the following trivial optimizations:

* merged two identical dest_dir_ = g_strdup (dest_dir) ops.
* simplified check for trailing '/' (no need to strcmp 1-char string).
* since g_free (NULL) is safe, merged two separate
  if empty string then bail out code paths.
* fixed wording in a comment.

Slava, is it ok to send patches in attachments?

Do you want kernel-style Signed-off-by lines in patch submissions?
--
vda
diff -d -urpN mc.1/src/file.c mc.2/src/file.c
--- mc.1/src/file.c	2009-06-16 16:57:06.0 +0200
+++ mc.2/src/file.c	2009-06-17 14:58:30.0 +0200
@@ -1806,19 +1806,18 @@ panel_operate (void *source_panel, FileO
 	else
 	dest_dir = panel-cwd;
 	/*
-	 * Add trailing backslash only when do non-locally ops.
+	 * Add trailing backslash only when do non-local ops.
 	 * It saves user from occasional file renames (when destination
 	 * dir is deleted)
 	 */
-	if (force_single)
-	/* just copy */
-	dest_dir_ = g_strdup (dest_dir);
-	else
+	if (!force_single
+	  dest_dir[0]
+	  dest_dir[strlen(dest_dir)-1] != PATH_SEP) {
 	/* add trailing separator */
-	if (*dest_dir  strcmp(dest_dir[strlen(dest_dir)-1], PATH_SEP_STR)) {
-		dest_dir_ = g_strconcat (dest_dir, PATH_SEP_STR, (char*)0);
+	dest_dir_ = g_strconcat (dest_dir, PATH_SEP_STR, (char*)0);
 	} else {
-		dest_dir_ = g_strdup (dest_dir);
+	/* just copy */
+	dest_dir_ = g_strdup (dest_dir);
 	}
 	if (!dest_dir_) {
 	file_op_context_destroy (ctx);
@@ -1830,11 +1829,7 @@ panel_operate (void *source_panel, FileO
 			  single_entry, do_bg);
 	g_free(dest_dir_);
 
-	if (!dest) {
-	file_op_context_destroy (ctx);
-	return 0;
-	}
-	if (!*dest) {
+	if (!dest || !dest[0]) {
 	file_op_context_destroy (ctx);
 	g_free (dest);
 	return 0;
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel


Re: [PATCH] trivial optimization in file.c::panel_operate()

2009-06-17 Thread Slava Zanko
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Denys Vlasenko wrote:

 I noticed an incorrectly indented if() in file.c::panel_operate().
 Took a better look, and found out it can be tweaked in several ways.

Big thanks! Now created ticket: http://www.midnight-commander.org/ticket/415

 Slava, is it ok to send patches in attachments?

No problem. In any case new ticket will created into trac.

 
 Do you want kernel-style Signed-off-by lines in patch submissions?

Not needed, but if this don't hard for you... :)
Also, better way - publish patches via 'git format-patch' command.

Thanks again.

WBR, Slavaz.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFKOPG+b3oGR6aVLpoRAsJ0AJ93TYigCGfSB2WzJHm6OzqpJvQyngCfV4fI
Hdi+HhKkj8ymhr7b9GHXph0=
=N67Z
-END PGP SIGNATURE-
___
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel