[whups] Email wordwrap patch

Mike Baptiste mike@msbnetworks.net
Tue Nov 12 01:52:40 2002


This is a multi-part message in MIME format.
---------------------- multipart/mixed attachment
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

/me smacks self for not attaching patch in the first place and having
gpg screw it up.  Again.  Grrr.

Mike Baptiste wrote:

| Below is a patch which changes how comments are formatted in
| notification emails.  The current code strips out all line feeds and
| outputs the comment in 80 char chunks.  While this made for a compact
| email, it really scrambled stuff like code snippets, data lists, etc
|
| So instead of packing the comment down, we just wrap any long lines
| using wordwrap.
|
| I realize this is a change vs a bug fix.  If there are folks that prefer
| compressed comments, maybe we can make it an option.  One thing I did
| notice is the current code didn't replace the linefeeds with spaces so
| words got joined together that had linefeeds between them. This would be
| fixed by adding a space to $result in the while (pos) loop I think.
|
|
- --
Mike Baptiste - MSB Networks - mike@msbnetworks.net
Download my GnuPG key at http://msbnetworks.net/msbnet.gpg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAj3QXugACgkQtbf8BjvL+3F4EwCcD+I8J8dkUhHU5svoWrE2JvhP
FD0AnRULzG37NNjWd6NjvPo9Ldrv+YCw
=Vsq+
-----END PGP SIGNATURE-----

---------------------- multipart/mixed attachment
Index: Driver.php
===================================================================
RCS file: /repository/whups/lib/Driver.php,v
retrieving revision 1.26
diff -u -r1.26 Driver.php
--- Driver.php	28 Oct 2002 22:23:44 -0000	1.26
+++ Driver.php	12 Nov 2002 01:41:09 -0000
@@ -254,34 +254,7 @@
 
     function _splitMessage($message)
     {
-        $set = split("[ \t]+", $message);
-        $len = 0;
-        $result = '';
-
-        foreach ($set as $substr) {
-            while (($pos = strpos($substr, "\n")) !== false) {
-                $result .= substr($substr, 0, $pos);
-                $len = 0;
-                $substr = substr($substr, $pos + 1);
-            }
-
-            $slen = strlen($substr);
-
-            if (!$slen) {
-                continue;
-            }
-
-            $len += $slen + 1;
-
-            if ($len > 80) {
-                $len = $slen;
-                $result .= "\n" . $substr . ' ';
-            } else {
-                $result .= $substr . ' ';
-            }
-        }
-
-        return $result;
+          return wordwrap($message, 80, "\n", 1);
     }
 
 }

---------------------- multipart/mixed attachment--



More information about the whups mailing list