https://bugzilla.novell.com/show_bug.cgi?id=321988#c4


Miguel de Icaza <[EMAIL PROTECTED]> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
                 CC|                                                |[EMAIL 
PROTECTED]




--- Comment #4 from Miguel de Icaza <[EMAIL PROTECTED]>  2007-11-05 07:48:36 
MST ---
I believe this is a better implementation using a trivial state machine:

                public string ReadLine ()
                {
                        CheckOpen ();
                        List<byte> bytes_read = new List<byte>();
                        byte [] buff = new byte [1];
                        int nl_state = 0;
                        int nl_final = new_line.Length;

                        while (true){
                                int n = stream.Read (buff, 0, 1);

                                if (n == -1)
                                        break;

                                if (buff [0] == new_line [nl_state]){
                                        if (++nl_state == nl_final)
                                                break;
                                } else
                                        nl_state = 0;
                                bytes_read.Add (buff [0]);
                        } 
                        return new String (encoding.GetChars
(bytes_read.ToArray ()));
                }


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to