[Mono-list] Mono.DataConvert

Kenneth D. Weinert kenw at quarter-flash.com
Wed Mar 12 00:28:03 EDT 2008


Is this the right way to do this?  Have the patch inline with the
message?

I had a problem with compiler error messages with the [CLSCompliant
(false)] attributes (I was using the 1.2.4 compiler), so I just
commented them out.

The 496,502 block is a fencepost error - I wasn't getting the last
element parsed out.

The 615,621 fixes the problem I found with a template of "_6C!i!i"
since the index never got past the '6' it would go into an endless
loop.

The 706,712 fixes another fencepost error.

There are a couple of other spots where it looks like there are
inadvertent blank lines added. I can clean those up and resubmit if
that makes the patch cleaner.


*** old/DataConverter.cs	2008-03-11 22:15:26.000000000 -0600
--- new/DataConverter.cs	2008-03-11 22:16:02.000000000 -0600
***************
*** 63,73 ****
  
  		public abstract short  GetInt16  (byte [] data, int index);
  
!                 [CLSCompliant (false)]
  		public abstract uint   GetUInt32 (byte [] data, int index);
!                 [CLSCompliant (false)]
  		public abstract ushort GetUInt16 (byte [] data, int index);
!                 [CLSCompliant (false)]
  		public abstract ulong  GetUInt64 (byte [] data, int index);
  		
  		public abstract void PutBytes (byte [] dest, int destIdx, double
value);
--- 63,73 ----
  
  		public abstract short  GetInt16  (byte [] data, int index);
  
!                 //[CLSCompliant (false)]
  		public abstract uint   GetUInt32 (byte [] data, int index);
!                 //[CLSCompliant (false)]
  		public abstract ushort GetUInt16 (byte [] data, int index);
!                 //[CLSCompliant (false)]
  		public abstract ulong  GetUInt64 (byte [] data, int index);
  		
  		public abstract void PutBytes (byte [] dest, int destIdx, double
value);
***************
*** 76,86 ****
  		public abstract void PutBytes (byte [] dest, int destIdx, long
value);
  		public abstract void PutBytes (byte [] dest, int destIdx, short
value);
  
!                 [CLSCompliant (false)]
  		public abstract void PutBytes (byte [] dest, int destIdx, ushort
value);
!                 [CLSCompliant (false)]
  		public abstract void PutBytes (byte [] dest, int destIdx, uint
value);
!                 [CLSCompliant (false)]
  		public abstract void PutBytes (byte [] dest, int destIdx, ulong
value);
  
  		public byte[] GetBytes (double value)
--- 76,86 ----
  		public abstract void PutBytes (byte [] dest, int destIdx, long
value);
  		public abstract void PutBytes (byte [] dest, int destIdx, short
value);
  
!                 //[CLSCompliant (false)]
  		public abstract void PutBytes (byte [] dest, int destIdx, ushort
value);
!                 //[CLSCompliant (false)]
  		public abstract void PutBytes (byte [] dest, int destIdx, uint
value);
!                 //[CLSCompliant (false)]
  		public abstract void PutBytes (byte [] dest, int destIdx, ulong
value);
  
  		public byte[] GetBytes (double value)
***************
*** 118,124 ****
  			return ret;
  		}
  
!                 [CLSCompliant (false)]
  		public byte[] GetBytes (ushort value)
  		{
  			byte [] ret = new byte [2];
--- 118,124 ----
  			return ret;
  		}
  
!                 //[CLSCompliant (false)]
  		public byte[] GetBytes (ushort value)
  		{
  			byte [] ret = new byte [2];
***************
*** 126,132 ****
  			return ret;
  		}
  		
!                 [CLSCompliant (false)]
  		public byte[] GetBytes (uint value)
  		{
  			byte [] ret = new byte [4];
--- 126,132 ----
  			return ret;
  		}
  		
!                 //[CLSCompliant (false)]
  		public byte[] GetBytes (uint value)
  		{
  			byte [] ret = new byte [4];
***************
*** 134,140 ****
  			return ret;
  		}
  		
!                 [CLSCompliant (false)]
  		public byte[] GetBytes (ulong value)
  		{
  			byte [] ret = new byte [8];
--- 134,140 ----
  			return ret;
  		}
  		
!                 //[CLSCompliant (false)]
  		public byte[] GetBytes (ulong value)
  		{
  			byte [] ret = new byte [8];
***************
*** 496,502 ****
  				idx = Align (idx, size);
  				align = false;
  			}
! 			if (idx + size >= buffer.Length){
  				idx = buffer.Length;
  				return false;
  			}
--- 496,502 ----
  				idx = Align (idx, size);
  				align = false;
  			}
! 			if (idx + size > buffer.Length){
  				idx = buffer.Length;
  				return false;
  			}
***************
*** 512,517 ****
--- 512,518 ----
  			int repeat = 0, n;
  			
  			for (int i = 0; i < description.Length && idx < buffer.Length; ){
+ 
  				int save = i;
  				
  				switch (description [i]){
***************
*** 614,619 ****
--- 615,621 ----
  				case '1': case '2': case '3': case '4': case '5':
  				case '6': case '7': case '8': case '9':
  					repeat = ((short) description [i]) - ((short) '0');
+ 						save = i + 1;
  					break;
  
  				case '*':
***************
*** 704,710 ****
  							if (buffer [k] == 0 && buffer [k+1] == 0)
  								break;
  						}
! 						result.Add (e.GetChars (buffer, idx, k-idx));
  						if (k == buffer.Length)
  							idx = k;
  						else
--- 706,712 ----
  							if (buffer [k] == 0 && buffer [k+1] == 0)
  								break;
  						}
! 						result.Add (e.GetChars (buffer, idx, k-idx+2));
  						if (k == buffer.Length)
  							idx = k;
  						else
***************
*** 738,743 ****
--- 740,746 ----
  						i = save;
  				} else
  					i++;
+ 					
  			}
  			return result;
  		}

-- 
Ken Weinert
http://quarter-flash.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20080311/5607d8f8/attachment.bin 


More information about the Mono-list mailing list