Karsten Hopp 53adff
To: vim_dev@googlegroups.com
Karsten Hopp 53adff
Subject: Patch 7.3.341
Karsten Hopp 53adff
Fcc: outbox
Karsten Hopp 53adff
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 53adff
Mime-Version: 1.0
Karsten Hopp 53adff
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 53adff
Content-Transfer-Encoding: 8bit
Karsten Hopp 53adff
------------
Karsten Hopp 53adff
Karsten Hopp 53adff
Patch 7.3.341
Karsten Hopp 53adff
Problem:    Local help files are only listed in help.txt, not in translated
Karsten Hopp 53adff
	    help files.
Karsten Hopp 53adff
Solution:   Also find translated help files. (Yasuhiro Matsumoto)
Karsten Hopp 53adff
Files:	    src/ex_cmds.c
Karsten Hopp 53adff
Karsten Hopp 53adff
Karsten Hopp 53adff
*** ../vim-7.3.340/src/ex_cmds.c	2011-09-30 17:30:27.000000000 +0200
Karsten Hopp 53adff
--- src/ex_cmds.c	2011-10-20 17:39:45.000000000 +0200
Karsten Hopp 53adff
***************
Karsten Hopp 53adff
*** 5982,5987 ****
Karsten Hopp 53adff
--- 5982,5988 ----
Karsten Hopp 53adff
      char_u	*line;
Karsten Hopp 53adff
      int		in_example = FALSE;
Karsten Hopp 53adff
      int		len;
Karsten Hopp 53adff
+     char_u	*fname;
Karsten Hopp 53adff
      char_u	*p;
Karsten Hopp 53adff
      char_u	*rt;
Karsten Hopp 53adff
      int		mustfree;
Karsten Hopp 53adff
***************
Karsten Hopp 53adff
*** 6028,6151 ****
Karsten Hopp 53adff
      }
Karsten Hopp 53adff
  
Karsten Hopp 53adff
      /*
Karsten Hopp 53adff
!      * In the "help.txt" file, add the locally added help files.
Karsten Hopp 53adff
!      * This uses the very first line in the help file.
Karsten Hopp 53adff
       */
Karsten Hopp 53adff
!     if (fnamecmp(gettail(curbuf->b_fname), "help.txt") == 0)
Karsten Hopp 53adff
      {
Karsten Hopp 53adff
  	for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum)
Karsten Hopp 53adff
  	{
Karsten Hopp 53adff
  	    line = ml_get_buf(curbuf, lnum, FALSE);
Karsten Hopp 53adff
! 	    if (strstr((char *)line, "*local-additions*") != NULL)
Karsten Hopp 53adff
  	    {
Karsten Hopp 53adff
! 		/* Go through all directories in 'runtimepath', skipping
Karsten Hopp 53adff
! 		 * $VIMRUNTIME. */
Karsten Hopp 53adff
! 		p = p_rtp;
Karsten Hopp 53adff
! 		while (*p != NUL)
Karsten Hopp 53adff
  		{
Karsten Hopp 53adff
! 		    copy_option_part(&p, NameBuff, MAXPATHL, ",");
Karsten Hopp 53adff
! 		    mustfree = FALSE;
Karsten Hopp 53adff
! 		    rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
Karsten Hopp 53adff
! 		    if (fullpathcmp(rt, NameBuff, FALSE) != FPC_SAME)
Karsten Hopp 53adff
! 		    {
Karsten Hopp 53adff
! 			int	fcount;
Karsten Hopp 53adff
! 			char_u	**fnames;
Karsten Hopp 53adff
! 			FILE	*fd;
Karsten Hopp 53adff
! 			char_u	*s;
Karsten Hopp 53adff
! 			int	fi;
Karsten Hopp 53adff
  #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 			vimconv_T	vc;
Karsten Hopp 53adff
! 			char_u		*cp;
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
  
Karsten Hopp 53adff
! 			/* Find all "doc/ *.txt" files in this directory. */
Karsten Hopp 53adff
! 			add_pathsep(NameBuff);
Karsten Hopp 53adff
! 			STRCAT(NameBuff, "doc/*.txt");
Karsten Hopp 53adff
! 			if (gen_expand_wildcards(1, &NameBuff, &fcount,
Karsten Hopp 53adff
! 					     &fnames, EW_FILE|EW_SILENT) == OK
Karsten Hopp 53adff
! 				&& fcount > 0)
Karsten Hopp 53adff
  			{
Karsten Hopp 53adff
! 			    for (fi = 0; fi < fcount; ++fi)
Karsten Hopp 53adff
  			    {
Karsten Hopp 53adff
! 				fd = mch_fopen((char *)fnames[fi], "r");
Karsten Hopp 53adff
! 				if (fd != NULL)
Karsten Hopp 53adff
  				{
Karsten Hopp 53adff
! 				    vim_fgets(IObuff, IOSIZE, fd);
Karsten Hopp 53adff
! 				    if (IObuff[0] == '*'
Karsten Hopp 53adff
! 					    && (s = vim_strchr(IObuff + 1, '*'))
Karsten Hopp 53adff
! 								      != NULL)
Karsten Hopp 53adff
! 				    {
Karsten Hopp 53adff
! #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 					int	this_utf = MAYBE;
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
! 					/* Change tag definition to a
Karsten Hopp 53adff
! 					 * reference and remove <CR>/<NL>. */
Karsten Hopp 53adff
! 					IObuff[0] = '|';
Karsten Hopp 53adff
! 					*s = '|';
Karsten Hopp 53adff
! 					while (*s != NUL)
Karsten Hopp 53adff
! 					{
Karsten Hopp 53adff
! 					    if (*s == '\r' || *s == '\n')
Karsten Hopp 53adff
! 						*s = NUL;
Karsten Hopp 53adff
  #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 					    /* The text is utf-8 when a byte
Karsten Hopp 53adff
! 					     * above 127 is found and no
Karsten Hopp 53adff
! 					     * illegal byte sequence is found.
Karsten Hopp 53adff
! 					     */
Karsten Hopp 53adff
! 					    if (*s >= 0x80 && this_utf != FALSE)
Karsten Hopp 53adff
! 					    {
Karsten Hopp 53adff
! 						int	l;
Karsten Hopp 53adff
! 
Karsten Hopp 53adff
! 						this_utf = TRUE;
Karsten Hopp 53adff
! 						l = utf_ptr2len(s);
Karsten Hopp 53adff
! 						if (l == 1)
Karsten Hopp 53adff
! 						    this_utf = FALSE;
Karsten Hopp 53adff
! 						s += l - 1;
Karsten Hopp 53adff
! 					    }
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
! 					    ++s;
Karsten Hopp 53adff
! 					}
Karsten Hopp 53adff
  #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 					/* The help file is latin1 or utf-8;
Karsten Hopp 53adff
! 					 * conversion to the current
Karsten Hopp 53adff
! 					 * 'encoding' may be required. */
Karsten Hopp 53adff
! 					vc.vc_type = CONV_NONE;
Karsten Hopp 53adff
! 					convert_setup(&vc, (char_u *)(
Karsten Hopp 53adff
! 						    this_utf == TRUE ? "utf-8"
Karsten Hopp 53adff
! 							  : "latin1"), p_enc);
Karsten Hopp 53adff
! 					if (vc.vc_type == CONV_NONE)
Karsten Hopp 53adff
! 					    /* No conversion needed. */
Karsten Hopp 53adff
! 					    cp = IObuff;
Karsten Hopp 53adff
! 					else
Karsten Hopp 53adff
  					{
Karsten Hopp 53adff
! 					    /* Do the conversion.  If it fails
Karsten Hopp 53adff
! 					     * use the unconverted text. */
Karsten Hopp 53adff
! 					    cp = string_convert(&vc, IObuff,
Karsten Hopp 53adff
! 									NULL);
Karsten Hopp 53adff
! 					    if (cp == NULL)
Karsten Hopp 53adff
! 						cp = IObuff;
Karsten Hopp 53adff
  					}
Karsten Hopp 53adff
! 					convert_setup(&vc, NULL, NULL);
Karsten Hopp 53adff
  
Karsten Hopp 53adff
! 					ml_append(lnum, cp, (colnr_T)0, FALSE);
Karsten Hopp 53adff
! 					if (cp != IObuff)
Karsten Hopp 53adff
! 					    vim_free(cp);
Karsten Hopp 53adff
  #else
Karsten Hopp 53adff
! 					ml_append(lnum, IObuff, (colnr_T)0,
Karsten Hopp 53adff
! 								       FALSE);
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
! 					++lnum;
Karsten Hopp 53adff
! 				    }
Karsten Hopp 53adff
! 				    fclose(fd);
Karsten Hopp 53adff
  				}
Karsten Hopp 53adff
  			    }
Karsten Hopp 53adff
- 			    FreeWild(fcount, fnames);
Karsten Hopp 53adff
  			}
Karsten Hopp 53adff
  		    }
Karsten Hopp 53adff
- 		    if (mustfree)
Karsten Hopp 53adff
- 			vim_free(rt);
Karsten Hopp 53adff
  		}
Karsten Hopp 53adff
! 		break;
Karsten Hopp 53adff
  	    }
Karsten Hopp 53adff
  	}
Karsten Hopp 53adff
      }
Karsten Hopp 53adff
  }
Karsten Hopp 53adff
--- 6029,6215 ----
Karsten Hopp 53adff
      }
Karsten Hopp 53adff
  
Karsten Hopp 53adff
      /*
Karsten Hopp 53adff
!      * In the "help.txt" and "help.abx" file, add the locally added help
Karsten Hopp 53adff
!      * files.  This uses the very first line in the help file.
Karsten Hopp 53adff
       */
Karsten Hopp 53adff
!     fname = gettail(curbuf->b_fname);
Karsten Hopp 53adff
!     if (fnamecmp(fname, "help.txt") == 0
Karsten Hopp 53adff
! #ifdef FEAT_MULTI_LANG
Karsten Hopp 53adff
! 	|| (fnamencmp(fname, "help.", 5) == 0
Karsten Hopp 53adff
! 	    && ASCII_ISALPHA(fname[5])
Karsten Hopp 53adff
! 	    && ASCII_ISALPHA(fname[6])
Karsten Hopp 53adff
! 	    && TOLOWER_ASC(fname[7]) == 'x'
Karsten Hopp 53adff
! 	    && fname[8] == NUL)
Karsten Hopp 53adff
! #endif
Karsten Hopp 53adff
! 	)
Karsten Hopp 53adff
      {
Karsten Hopp 53adff
  	for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum)
Karsten Hopp 53adff
  	{
Karsten Hopp 53adff
  	    line = ml_get_buf(curbuf, lnum, FALSE);
Karsten Hopp 53adff
! 	    if (strstr((char *)line, "*local-additions*") == NULL)
Karsten Hopp 53adff
! 		continue;
Karsten Hopp 53adff
! 
Karsten Hopp 53adff
! 	    /* Go through all directories in 'runtimepath', skipping
Karsten Hopp 53adff
! 	     * $VIMRUNTIME. */
Karsten Hopp 53adff
! 	    p = p_rtp;
Karsten Hopp 53adff
! 	    while (*p != NUL)
Karsten Hopp 53adff
  	    {
Karsten Hopp 53adff
! 		copy_option_part(&p, NameBuff, MAXPATHL, ",");
Karsten Hopp 53adff
! 		mustfree = FALSE;
Karsten Hopp 53adff
! 		rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
Karsten Hopp 53adff
! 		if (fullpathcmp(rt, NameBuff, FALSE) != FPC_SAME)
Karsten Hopp 53adff
  		{
Karsten Hopp 53adff
! 		    int		fcount;
Karsten Hopp 53adff
! 		    char_u	**fnames;
Karsten Hopp 53adff
! 		    FILE	*fd;
Karsten Hopp 53adff
! 		    char_u	*s;
Karsten Hopp 53adff
! 		    int		fi;
Karsten Hopp 53adff
  #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 		    vimconv_T	vc;
Karsten Hopp 53adff
! 		    char_u	*cp;
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
  
Karsten Hopp 53adff
! 		    /* Find all "doc/ *.txt" files in this directory. */
Karsten Hopp 53adff
! 		    add_pathsep(NameBuff);
Karsten Hopp 53adff
! #ifdef FEAT_MULTI_LANG
Karsten Hopp 53adff
! 		    STRCAT(NameBuff, "doc/*.??[tx]");
Karsten Hopp 53adff
! #else
Karsten Hopp 53adff
! 		    STRCAT(NameBuff, "doc/*.txt");
Karsten Hopp 53adff
! #endif
Karsten Hopp 53adff
! 		    if (gen_expand_wildcards(1, &NameBuff, &fcount,
Karsten Hopp 53adff
! 					 &fnames, EW_FILE|EW_SILENT) == OK
Karsten Hopp 53adff
! 			    && fcount > 0)
Karsten Hopp 53adff
! 		    {
Karsten Hopp 53adff
! #ifdef FEAT_MULTI_LANG
Karsten Hopp 53adff
! 			int	i1;
Karsten Hopp 53adff
! 			int	i2;
Karsten Hopp 53adff
! 			char_u	*f1;
Karsten Hopp 53adff
! 			char_u	*f2;
Karsten Hopp 53adff
! 			char_u	*t1;
Karsten Hopp 53adff
! 			char_u	*e1;
Karsten Hopp 53adff
! 			char_u	*e2;
Karsten Hopp 53adff
! 
Karsten Hopp 53adff
! 			/* If foo.abx is found use it instead of foo.txt in
Karsten Hopp 53adff
! 			 * the same directory. */
Karsten Hopp 53adff
! 			for (i1 = 0; i1 < fcount; ++i1)
Karsten Hopp 53adff
  			{
Karsten Hopp 53adff
! 			    for (i2 = 0; i2 < fcount; ++i2)
Karsten Hopp 53adff
  			    {
Karsten Hopp 53adff
! 				if (i1 == i2)
Karsten Hopp 53adff
! 				    continue;
Karsten Hopp 53adff
! 				if (fnames[i1] == NULL || fnames[i2] == NULL)
Karsten Hopp 53adff
! 				    continue;
Karsten Hopp 53adff
! 				f1 = fnames[i1];
Karsten Hopp 53adff
! 				f2 = fnames[i2];
Karsten Hopp 53adff
! 				t1 = gettail(f1);
Karsten Hopp 53adff
! 				if (fnamencmp(f1, f2, t1 - f1) != 0)
Karsten Hopp 53adff
! 				    continue;
Karsten Hopp 53adff
! 				e1 = vim_strrchr(t1, '.');
Karsten Hopp 53adff
! 				e2 = vim_strrchr(gettail(f2), '.');
Karsten Hopp 53adff
! 				if (e1 == NUL || e2 == NUL)
Karsten Hopp 53adff
! 				    continue;
Karsten Hopp 53adff
! 				if (fnamecmp(e1, ".txt") != 0
Karsten Hopp 53adff
! 				    && fnamecmp(e1, fname + 4) != 0)
Karsten Hopp 53adff
  				{
Karsten Hopp 53adff
! 				    /* Not .txt and not .abx, remove it. */
Karsten Hopp 53adff
! 				    vim_free(fnames[i1]);
Karsten Hopp 53adff
! 				    fnames[i1] = NULL;
Karsten Hopp 53adff
! 				    continue;
Karsten Hopp 53adff
! 				}
Karsten Hopp 53adff
! 				if (fnamencmp(f1, f2, e1 - f1) != 0)
Karsten Hopp 53adff
! 				    continue;
Karsten Hopp 53adff
! 				if (fnamecmp(e1, ".txt") == 0
Karsten Hopp 53adff
! 				    && fnamecmp(e2, fname + 4) == 0)
Karsten Hopp 53adff
! 				{
Karsten Hopp 53adff
! 				    /* use .abx instead of .txt */
Karsten Hopp 53adff
! 				    vim_free(fnames[i1]);
Karsten Hopp 53adff
! 				    fnames[i1] = NULL;
Karsten Hopp 53adff
! 				}
Karsten Hopp 53adff
! 			    }
Karsten Hopp 53adff
! 			}
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
! 			for (fi = 0; fi < fcount; ++fi)
Karsten Hopp 53adff
! 			{
Karsten Hopp 53adff
! 			    if (fnames[fi] == NULL)
Karsten Hopp 53adff
! 				continue;
Karsten Hopp 53adff
! 			    fd = mch_fopen((char *)fnames[fi], "r");
Karsten Hopp 53adff
! 			    if (fd != NULL)
Karsten Hopp 53adff
! 			    {
Karsten Hopp 53adff
! 				vim_fgets(IObuff, IOSIZE, fd);
Karsten Hopp 53adff
! 				if (IObuff[0] == '*'
Karsten Hopp 53adff
! 					&& (s = vim_strchr(IObuff + 1, '*'))
Karsten Hopp 53adff
! 								  != NULL)
Karsten Hopp 53adff
! 				{
Karsten Hopp 53adff
  #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 				    int	this_utf = MAYBE;
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
! 				    /* Change tag definition to a
Karsten Hopp 53adff
! 				     * reference and remove <CR>/<NL>. */
Karsten Hopp 53adff
! 				    IObuff[0] = '|';
Karsten Hopp 53adff
! 				    *s = '|';
Karsten Hopp 53adff
! 				    while (*s != NUL)
Karsten Hopp 53adff
! 				    {
Karsten Hopp 53adff
! 					if (*s == '\r' || *s == '\n')
Karsten Hopp 53adff
! 					    *s = NUL;
Karsten Hopp 53adff
  #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 					/* The text is utf-8 when a byte
Karsten Hopp 53adff
! 					 * above 127 is found and no
Karsten Hopp 53adff
! 					 * illegal byte sequence is found.
Karsten Hopp 53adff
! 					 */
Karsten Hopp 53adff
! 					if (*s >= 0x80 && this_utf != FALSE)
Karsten Hopp 53adff
  					{
Karsten Hopp 53adff
! 					    int	l;
Karsten Hopp 53adff
! 
Karsten Hopp 53adff
! 					    this_utf = TRUE;
Karsten Hopp 53adff
! 					    l = utf_ptr2len(s);
Karsten Hopp 53adff
! 					    if (l == 1)
Karsten Hopp 53adff
! 						this_utf = FALSE;
Karsten Hopp 53adff
! 					    s += l - 1;
Karsten Hopp 53adff
  					}
Karsten Hopp 53adff
! #endif
Karsten Hopp 53adff
! 					++s;
Karsten Hopp 53adff
! 				    }
Karsten Hopp 53adff
! #ifdef FEAT_MBYTE
Karsten Hopp 53adff
! 				    /* The help file is latin1 or utf-8;
Karsten Hopp 53adff
! 				     * conversion to the current
Karsten Hopp 53adff
! 				     * 'encoding' may be required. */
Karsten Hopp 53adff
! 				    vc.vc_type = CONV_NONE;
Karsten Hopp 53adff
! 				    convert_setup(&vc, (char_u *)(
Karsten Hopp 53adff
! 						this_utf == TRUE ? "utf-8"
Karsten Hopp 53adff
! 						      : "latin1"), p_enc);
Karsten Hopp 53adff
! 				    if (vc.vc_type == CONV_NONE)
Karsten Hopp 53adff
! 					/* No conversion needed. */
Karsten Hopp 53adff
! 					cp = IObuff;
Karsten Hopp 53adff
! 				    else
Karsten Hopp 53adff
! 				    {
Karsten Hopp 53adff
! 					/* Do the conversion.  If it fails
Karsten Hopp 53adff
! 					 * use the unconverted text. */
Karsten Hopp 53adff
! 					cp = string_convert(&vc, IObuff,
Karsten Hopp 53adff
! 								    NULL);
Karsten Hopp 53adff
! 					if (cp == NULL)
Karsten Hopp 53adff
! 					    cp = IObuff;
Karsten Hopp 53adff
! 				    }
Karsten Hopp 53adff
! 				    convert_setup(&vc, NULL, NULL);
Karsten Hopp 53adff
  
Karsten Hopp 53adff
! 				    ml_append(lnum, cp, (colnr_T)0, FALSE);
Karsten Hopp 53adff
! 				    if (cp != IObuff)
Karsten Hopp 53adff
! 					vim_free(cp);
Karsten Hopp 53adff
  #else
Karsten Hopp 53adff
! 				    ml_append(lnum, IObuff, (colnr_T)0,
Karsten Hopp 53adff
! 								   FALSE);
Karsten Hopp 53adff
  #endif
Karsten Hopp 53adff
! 				    ++lnum;
Karsten Hopp 53adff
  				}
Karsten Hopp 53adff
+ 				fclose(fd);
Karsten Hopp 53adff
  			    }
Karsten Hopp 53adff
  			}
Karsten Hopp 53adff
+ 			FreeWild(fcount, fnames);
Karsten Hopp 53adff
  		    }
Karsten Hopp 53adff
  		}
Karsten Hopp 53adff
! 		if (mustfree)
Karsten Hopp 53adff
! 		    vim_free(rt);
Karsten Hopp 53adff
  	    }
Karsten Hopp 53adff
+ 	    break;
Karsten Hopp 53adff
  	}
Karsten Hopp 53adff
      }
Karsten Hopp 53adff
  }
Karsten Hopp 53adff
*** ../vim-7.3.340/src/version.c	2011-10-20 18:12:27.000000000 +0200
Karsten Hopp 53adff
--- src/version.c	2011-10-20 18:13:46.000000000 +0200
Karsten Hopp 53adff
***************
Karsten Hopp 53adff
*** 711,712 ****
Karsten Hopp 53adff
--- 711,714 ----
Karsten Hopp 53adff
  {   /* Add new patch number below this line */
Karsten Hopp 53adff
+ /**/
Karsten Hopp 53adff
+     341,
Karsten Hopp 53adff
  /**/
Karsten Hopp 53adff
Karsten Hopp 53adff
-- 
Karsten Hopp 53adff
From "know your smileys":
Karsten Hopp 53adff
 :-)-O	Smiling doctor with stethoscope
Karsten Hopp 53adff
Karsten Hopp 53adff
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 53adff
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 53adff
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 53adff
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///