Karsten Hopp eadf55
To: vim_dev@googlegroups.com
Karsten Hopp eadf55
Subject: Patch 7.3.1262
Karsten Hopp eadf55
Fcc: outbox
Karsten Hopp eadf55
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp eadf55
Mime-Version: 1.0
Karsten Hopp eadf55
Content-Type: text/plain; charset=UTF-8
Karsten Hopp eadf55
Content-Transfer-Encoding: 8bit
Karsten Hopp eadf55
------------
Karsten Hopp eadf55
Karsten Hopp eadf55
Patch 7.3.1262
Karsten Hopp eadf55
Problem:    Crash and compilation warnings with Cygwin.
Karsten Hopp eadf55
Solution:   Check return value of XmbTextListToTextProperty(). Add type casts.
Karsten Hopp eadf55
	    Adjust #ifdefs. (Lech Lorens)
Karsten Hopp eadf55
Files:	    src/main.c, src/os_unix.c, src/ui.c
Karsten Hopp eadf55
Karsten Hopp eadf55
Karsten Hopp eadf55
*** ../vim-7.3.1261/src/main.c	2013-06-15 21:54:11.000000000 +0200
Karsten Hopp eadf55
--- src/main.c	2013-06-29 14:04:10.000000000 +0200
Karsten Hopp eadf55
***************
Karsten Hopp eadf55
*** 2408,2414 ****
Karsten Hopp eadf55
  	     * Look for evidence of non-Cygwin paths before we bother.
Karsten Hopp eadf55
  	     * This is only for when using the Unix files.
Karsten Hopp eadf55
  	     */
Karsten Hopp eadf55
! 	    if (strpbrk(p, "\\:") != NULL && !path_with_url(p))
Karsten Hopp eadf55
  	    {
Karsten Hopp eadf55
  		char posix_path[PATH_MAX];
Karsten Hopp eadf55
  
Karsten Hopp eadf55
--- 2408,2414 ----
Karsten Hopp eadf55
  	     * Look for evidence of non-Cygwin paths before we bother.
Karsten Hopp eadf55
  	     * This is only for when using the Unix files.
Karsten Hopp eadf55
  	     */
Karsten Hopp eadf55
! 	    if (vim_strpbrk(p, "\\:") != NULL && !path_with_url(p))
Karsten Hopp eadf55
  	    {
Karsten Hopp eadf55
  		char posix_path[PATH_MAX];
Karsten Hopp eadf55
  
Karsten Hopp eadf55
***************
Karsten Hopp eadf55
*** 2418,2424 ****
Karsten Hopp eadf55
  		cygwin_conv_to_posix_path(p, posix_path);
Karsten Hopp eadf55
  # endif
Karsten Hopp eadf55
  		vim_free(p);
Karsten Hopp eadf55
! 		p = vim_strsave(posix_path);
Karsten Hopp eadf55
  		if (p == NULL)
Karsten Hopp eadf55
  		    mch_exit(2);
Karsten Hopp eadf55
  	    }
Karsten Hopp eadf55
--- 2418,2424 ----
Karsten Hopp eadf55
  		cygwin_conv_to_posix_path(p, posix_path);
Karsten Hopp eadf55
  # endif
Karsten Hopp eadf55
  		vim_free(p);
Karsten Hopp eadf55
! 		p = vim_strsave((char_u *)posix_path);
Karsten Hopp eadf55
  		if (p == NULL)
Karsten Hopp eadf55
  		    mch_exit(2);
Karsten Hopp eadf55
  	    }
Karsten Hopp eadf55
*** ../vim-7.3.1261/src/os_unix.c	2013-04-15 15:32:20.000000000 +0200
Karsten Hopp eadf55
--- src/os_unix.c	2013-06-29 14:04:10.000000000 +0200
Karsten Hopp eadf55
***************
Karsten Hopp eadf55
*** 1559,1565 ****
Karsten Hopp eadf55
  {
Karsten Hopp eadf55
      /* This function should not return, it causes exit().  Longjump instead. */
Karsten Hopp eadf55
      LONGJMP(lc_jump_env, 1);
Karsten Hopp eadf55
! #  ifdef VMS
Karsten Hopp eadf55
      return 0;  /* avoid the compiler complains about missing return value */
Karsten Hopp eadf55
  #  endif
Karsten Hopp eadf55
  }
Karsten Hopp eadf55
--- 1559,1565 ----
Karsten Hopp eadf55
  {
Karsten Hopp eadf55
      /* This function should not return, it causes exit().  Longjump instead. */
Karsten Hopp eadf55
      LONGJMP(lc_jump_env, 1);
Karsten Hopp eadf55
! #  if defined(VMS) || defined(__CYGWIN__) || defined(__CYGWIN32__)
Karsten Hopp eadf55
      return 0;  /* avoid the compiler complains about missing return value */
Karsten Hopp eadf55
  #  endif
Karsten Hopp eadf55
  }
Karsten Hopp eadf55
***************
Karsten Hopp eadf55
*** 1581,1587 ****
Karsten Hopp eadf55
  
Karsten Hopp eadf55
      /* This function should not return, it causes exit().  Longjump instead. */
Karsten Hopp eadf55
      LONGJMP(x_jump_env, 1);
Karsten Hopp eadf55
! # ifdef VMS
Karsten Hopp eadf55
      return 0;  /* avoid the compiler complains about missing return value */
Karsten Hopp eadf55
  # endif
Karsten Hopp eadf55
  }
Karsten Hopp eadf55
--- 1581,1587 ----
Karsten Hopp eadf55
  
Karsten Hopp eadf55
      /* This function should not return, it causes exit().  Longjump instead. */
Karsten Hopp eadf55
      LONGJMP(x_jump_env, 1);
Karsten Hopp eadf55
! # if defined(VMS) || defined(__CYGWIN__) || defined(__CYGWIN32__)
Karsten Hopp eadf55
      return 0;  /* avoid the compiler complains about missing return value */
Karsten Hopp eadf55
  # endif
Karsten Hopp eadf55
  }
Karsten Hopp eadf55
***************
Karsten Hopp eadf55
*** 5929,5935 ****
Karsten Hopp eadf55
  # if defined(__CYGWIN__) || defined(__CYGWIN32__)
Karsten Hopp eadf55
      /* Translate <CR><NL> into <NL>.  Caution, buffer may contain NUL. */
Karsten Hopp eadf55
      p = buffer;
Karsten Hopp eadf55
!     for (i = 0; i < len; ++i)
Karsten Hopp eadf55
  	if (!(buffer[i] == CAR && buffer[i + 1] == NL))
Karsten Hopp eadf55
  	    *p++ = buffer[i];
Karsten Hopp eadf55
      len = p - buffer;
Karsten Hopp eadf55
--- 5929,5935 ----
Karsten Hopp eadf55
  # if defined(__CYGWIN__) || defined(__CYGWIN32__)
Karsten Hopp eadf55
      /* Translate <CR><NL> into <NL>.  Caution, buffer may contain NUL. */
Karsten Hopp eadf55
      p = buffer;
Karsten Hopp eadf55
!     for (i = 0; i < (int)len; ++i)
Karsten Hopp eadf55
  	if (!(buffer[i] == CAR && buffer[i + 1] == NL))
Karsten Hopp eadf55
  	    *p++ = buffer[i];
Karsten Hopp eadf55
      len = p - buffer;
Karsten Hopp eadf55
*** ../vim-7.3.1261/src/ui.c	2013-04-12 12:27:24.000000000 +0200
Karsten Hopp eadf55
--- src/ui.c	2013-06-29 14:08:21.000000000 +0200
Karsten Hopp eadf55
***************
Karsten Hopp eadf55
*** 2366,2379 ****
Karsten Hopp eadf55
      {
Karsten Hopp eadf55
  	XTextProperty	text_prop;
Karsten Hopp eadf55
  	char		*string_nt = (char *)alloc((unsigned)*length + 1);
Karsten Hopp eadf55
  
Karsten Hopp eadf55
  	/* create NUL terminated string which XmbTextListToTextProperty wants */
Karsten Hopp eadf55
  	mch_memmove(string_nt, string, (size_t)*length);
Karsten Hopp eadf55
  	string_nt[*length] = NUL;
Karsten Hopp eadf55
! 	XmbTextListToTextProperty(X_DISPLAY, (char **)&string_nt, 1,
Karsten Hopp eadf55
! 					      XCompoundTextStyle, &text_prop);
Karsten Hopp eadf55
  	vim_free(string_nt);
Karsten Hopp eadf55
  	XtFree(*value);			/* replace with COMPOUND text */
Karsten Hopp eadf55
  	*value = (XtPointer)(text_prop.value);	/*    from plain text */
Karsten Hopp eadf55
  	*length = text_prop.nitems;
Karsten Hopp eadf55
  	*type = compound_text_atom;
Karsten Hopp eadf55
--- 2366,2385 ----
Karsten Hopp eadf55
      {
Karsten Hopp eadf55
  	XTextProperty	text_prop;
Karsten Hopp eadf55
  	char		*string_nt = (char *)alloc((unsigned)*length + 1);
Karsten Hopp eadf55
+ 	int		conv_result;
Karsten Hopp eadf55
  
Karsten Hopp eadf55
  	/* create NUL terminated string which XmbTextListToTextProperty wants */
Karsten Hopp eadf55
  	mch_memmove(string_nt, string, (size_t)*length);
Karsten Hopp eadf55
  	string_nt[*length] = NUL;
Karsten Hopp eadf55
! 	conv_result = XmbTextListToTextProperty(X_DISPLAY, (char **)&string_nt,
Karsten Hopp eadf55
! 					   1, XCompoundTextStyle, &text_prop);
Karsten Hopp eadf55
  	vim_free(string_nt);
Karsten Hopp eadf55
  	XtFree(*value);			/* replace with COMPOUND text */
Karsten Hopp eadf55
+ 	if (conv_result != Success)
Karsten Hopp eadf55
+ 	{
Karsten Hopp eadf55
+ 	    vim_free(string);
Karsten Hopp eadf55
+ 	    return False;
Karsten Hopp eadf55
+ 	}
Karsten Hopp eadf55
  	*value = (XtPointer)(text_prop.value);	/*    from plain text */
Karsten Hopp eadf55
  	*length = text_prop.nitems;
Karsten Hopp eadf55
  	*type = compound_text_atom;
Karsten Hopp eadf55
*** ../vim-7.3.1261/src/version.c	2013-06-29 13:58:26.000000000 +0200
Karsten Hopp eadf55
--- src/version.c	2013-06-29 14:04:32.000000000 +0200
Karsten Hopp eadf55
***************
Karsten Hopp eadf55
*** 730,731 ****
Karsten Hopp eadf55
--- 730,733 ----
Karsten Hopp eadf55
  {   /* Add new patch number below this line */
Karsten Hopp eadf55
+ /**/
Karsten Hopp eadf55
+     1262,
Karsten Hopp eadf55
  /**/
Karsten Hopp eadf55
Karsten Hopp eadf55
-- 
Karsten Hopp eadf55
MORTICIAN:    Bring out your dead!
Karsten Hopp eadf55
              [clang]
Karsten Hopp eadf55
              Bring out your dead!
Karsten Hopp eadf55
              [clang]
Karsten Hopp eadf55
              Bring out your dead!
Karsten Hopp eadf55
CUSTOMER:     Here's one -- nine pence.
Karsten Hopp eadf55
DEAD PERSON:  I'm not dead!
Karsten Hopp eadf55
                                  The Quest for the Holy Grail (Monty Python)
Karsten Hopp eadf55
Karsten Hopp eadf55
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp eadf55
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp eadf55
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp eadf55
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///