/[rdesktop]/sourceforge.net/trunk/rdesktop/xclip.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xclip.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1403 by stargo, Wed Mar 7 15:48:08 2007 UTC revision 1404 by astrand, Wed Apr 25 12:44:26 2007 UTC
# Line 130  static uint8 *g_clip_buffer = 0; Line 130  static uint8 *g_clip_buffer = 0;
130  /* Denotes the size of g_clip_buffer. */  /* Denotes the size of g_clip_buffer. */
131  static uint32 g_clip_buflen = 0;  static uint32 g_clip_buflen = 0;
132    
133  /* Translate LF to CR-LF. To do this, we must allocate more memory.  /* Translates CR-LF to LF.
134     The returned string is null-terminated, as required by CF_TEXT.     Changes the string in-place.
135     Does not stop on embedded nulls.     Does not stop on embedded nulls.
136     The length is updated. */     The length is updated. */
137  static void  static void
# Line 170  utf16_lf2crlf(uint8 * data, uint32 * siz Line 170  utf16_lf2crlf(uint8 * data, uint32 * siz
170          /* Check for a reversed BOM */          /* Check for a reversed BOM */
171          swap_endianess = (*inptr == 0xfffe);          swap_endianess = (*inptr == 0xfffe);
172    
173            uint16 uvalue_previous = 0;     /* Kept so we'll avoid translating CR-LF to CR-CR-LF */
174          while ((uint8 *) inptr < data + *size)          while ((uint8 *) inptr < data + *size)
175          {          {
176                  uint16 uvalue = *inptr;                  uint16 uvalue = *inptr;
177                  if (swap_endianess)                  if (swap_endianess)
178                          uvalue = ((uvalue << 8) & 0xff00) + (uvalue >> 8);                          uvalue = ((uvalue << 8) & 0xff00) + (uvalue >> 8);
179                  if (uvalue == 0x0a)                  if ((uvalue == 0x0a) && (uvalue_previous != 0x0d))
180                          *outptr++ = swap_endianess ? 0x0d00 : 0x0d;                          *outptr++ = swap_endianess ? 0x0d00 : 0x0d;
181                    uvalue_previous = uvalue;
182                  *outptr++ = *inptr++;                  *outptr++ = *inptr++;
183          }          }
184          *outptr++ = 0;          /* null termination */          *outptr++ = 0;          /* null termination */
# Line 198  lf2crlf(uint8 * data, uint32 * length) Line 200  lf2crlf(uint8 * data, uint32 * length)
200          p = data;          p = data;
201          o = result;          o = result;
202    
203            uint8 previous = '\0';  /* Kept to avoid translating CR-LF to CR-CR-LF */
204          while (p < data + *length)          while (p < data + *length)
205          {          {
206                  if (*p == '\x0a')                  if ((*p == '\x0a') && (previous != '\x0d'))
207                          *o++ = '\x0d';                          *o++ = '\x0d';
208                    previous = *p;
209                  *o++ = *p++;                  *o++ = *p++;
210          }          }
211          *length = o - result;          *length = o - result;
# Line 1006  ui_clip_handle_data(uint8 * data, uint32 Line 1010  ui_clip_handle_data(uint8 * data, uint32
1010                          free_data = True;                          free_data = True;
1011                          data = (uint8 *) utf8_data;                          data = (uint8 *) utf8_data;
1012                          length = utf8_length - utf8_length_remaining;                          length = utf8_length - utf8_length_remaining;
1013                            /* translate linebreaks (works just as well on UTF-8) */
1014                            crlf2lf(data, &length);
1015                  }                  }
1016          }          }
1017          else if (selection_request.target == format_unicode_atom)          else if (selection_request.target == format_unicode_atom)

Legend:
Removed from v.1403  
changed lines
  Added in v.1404

  ViewVC Help
Powered by ViewVC 1.1.26