CVS: rdesktop xclip.c,1.45,1.46

Peter Åstrand <[email protected]> Wed, 25 Apr 2007 05:44:28 -0700
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21996

Modified Files:
	xclip.c 
Log Message:
Applied patch #1700909 from Ilya Konstantinov: Linebreak (CR-LF) fixes for clipboard code

Index: xclip.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xclip.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** xclip.c	7 Mar 2007 15:48:08 -0000	1.45
--- xclip.c	25 Apr 2007 12:44:26 -0000	1.46
***************
*** 131,136 ****
  static uint32 g_clip_buflen = 0;
  
! /* Translate LF to CR-LF. To do this, we must allocate more memory.
!    The returned string is null-terminated, as required by CF_TEXT.
     Does not stop on embedded nulls.
     The length is updated. */
--- 131,136 ----
  static uint32 g_clip_buflen = 0;
  
! /* Translates CR-LF to LF.
!    Changes the string in-place.
     Does not stop on embedded nulls.
     The length is updated. */
***************
*** 171,174 ****
--- 171,175 ----
  	swap_endianess = (*inptr == 0xfffe);
  
+ 	uint16 uvalue_previous = 0;	/* Kept so we'll avoid translating CR-LF to CR-CR-LF */
  	while ((uint8 *) inptr < data + *size)
  	{
***************
*** 176,181 ****
  		if (swap_endianess)
  			uvalue = ((uvalue << 8) & 0xff00) + (uvalue >> 8);
! 		if (uvalue == 0x0a)
  			*outptr++ = swap_endianess ? 0x0d00 : 0x0d;
  		*outptr++ = *inptr++;
  	}
--- 177,183 ----
  		if (swap_endianess)
  			uvalue = ((uvalue << 8) & 0xff00) + (uvalue >> 8);
! 		if ((uvalue == 0x0a) && (uvalue_previous != 0x0d))
  			*outptr++ = swap_endianess ? 0x0d00 : 0x0d;
+ 		uvalue_previous = uvalue;
  		*outptr++ = *inptr++;
  	}
***************
*** 199,206 ****
  	o = result;
  
  	while (p < data + *length)
  	{
! 		if (*p == '\x0a')
  			*o++ = '\x0d';
  		*o++ = *p++;
  	}
--- 201,210 ----
  	o = result;
  
+ 	uint8 previous = '\0';	/* Kept to avoid translating CR-LF to CR-CR-LF */
  	while (p < data + *length)
  	{
! 		if ((*p == '\x0a') && (previous != '\x0d'))
  			*o++ = '\x0d';
+ 		previous = *p;
  		*o++ = *p++;
  	}
***************
*** 1007,1010 ****
--- 1011,1016 ----
  			data = (uint8 *) utf8_data;
  			length = utf8_length - utf8_length_remaining;
+ 			/* translate linebreaks (works just as well on UTF-8) */
+ 			crlf2lf(data, &length);
  		}
  	}


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/