ftp.nice.ch/pub/next/unix/editor/vim-5.0f.s.tar.gz#/vim-5.0f/src/version.c

This is version.c in view mode; [Download] [Up]

/* vi:set ts=4 sw=4:
 * vi:set comments=sbl\:*\ -,mb\:*,el\:*\ -,sr\:/\*,mb\:*,el\:*\/,fb\:- :
 *
 * VIM - Vi IMproved		by Bram Moolenaar
 *
 * Do ":help uganda"  in Vim to read copying and usage conditions.
 * Do ":help credits" in Vim to see a list of people who contributed.
 */

#include "vim.h"
#include "globals.h"
#include "proto.h"

/*
 * Vim originated from Stevie version 3.6 (Fish disk 217) by GRWalter (Fred)
 * It has been changed beyond recognition since then.
 *
 * All the remarks about older versions have been removed, they are not very
 * interesting.  Differences between version 3.0 and 4.x can be found in
 * "../doc/version4.txt".
 *
 * Changes between version 5.0e and 5.0f:
 * - Added quite a few highlighting files, and update a few other ones.
 * - Fixed: When there are only keywords, ":syntax" didn't list them, and
 *   highlighting didn't work.
 * - Added configure check for strncasecmp(), stricmp() and strnicmp().  Added
 *   vim_stricmp() for when there's no library function for stricmp().
 * - Fixed: In an xterm that switches screens, after exiting Vim all shell
 *   commands would be highlighted.
 * - Fixed: Blockwise visual mode wasn't correct when moving vertically over a
 *   special character (displayed as two screen characters).
 * - Added 'nrformat' option.  Default: "hex,octal".
 * - Renamed "struct option" to "struct vimoption" to avoid name clash with
 *   GNU getopt().
 * - Fixed: ":abclear" didn't work (but ":iabclear" and ":cabclear" did work).
 * - In Visual mode, "Q" is ignored (just gives a beep).
 * - In Insert mode, "<C-O>Q" didn't redraw after returning.
 * - Fixed: when 'nowrap' used, screen wasn't always updated correctly.
 * - Fixed: "vim -c split file" displayed extra lines.
 * - Added file_readable() function to expressions.
 * - Included patches for Python (Moore).
 * - Fixed: After starting the GUI, searched the termcap for a "gui" term.
 * - Fixed: When 'hls' used, search for "^$" caused a hang.
 * - Fixed for Unix: Only output an extra newline on exit when outputted
 *   something in the alternate screen, or when there is a message that needs
 *   to be cleared.
 * - Fixed: w_curswant wasn't updated always, caused test20 to fail.
 * - Fixed: "/a\{" did strange things, depending on previous search.
 * - Fixed: When 'hls' was set, an error in the last regexp caused trouble.
 * - Fixed:	"c}" only redrawed one line (with -u NONE).
 * - Fixed: Ex mode didn't work for GUI and systems without cooked input.
 * - Fixed: MSDOS an DJGPP versions messed up interrupt handling when going to
 *   Ex mode.  Separated raw/cooked setting and interrupt catching on/off.
 * - Fixed: divide by zero crashed Vim (e.g. in ":echo % % %").
 * - Fixed: Starting GUI in Ex mode could get wrong window height.
 * - Fixed: For mappings, CTRL-META-A was shown as <M-^A> instead of <MC-A>,
 *   while :map only accepts <MC-A>.  Now <M-C-A> is shown.
 * - "/\(.\{2\}\)*" gave bogus error message.
 * - Fixed: syntax regions didn't work correct when no syncing specified
 *   (e.g., a simple string didn't cross lines).
 * - Fixed: Syntax highlighting didn't work for special characters when there
 *   is a 'hls' match in the same line.
 * - Fixed: syntax match which matches an empty string was only recognized
 *   once at the start or just after another match.
 * - Fixed: GUI highlighting: Could not set background or foreground to black
 *   (unless it is the default color)
 * - Fixed: In Insert mode, cursor-right at end of line moved shown cursor left.
 * - Various changes to make the Win32 GUI work better (Webb).
 * - Implemented the "shortest match" regexp "\{-}" (Webb).
 * - Added ":intro" command: Show introductory message.
 * - Fixed: Unix: When using full path name in a tags file, which contains a
 *   link, and 'hidden' set and jumping to a tag in the current file, would
 *   get bogus ATTENTION message.  Solved by always expanding file names, even
 *   when starting with '/'.
 * - Fixed: When inserting a CR with 'cindent' set (and a bunch of other
 *   conditions) the cursor went to a wrong location.
 * - Added: GUI Menu for syntax highlighting in syntax.vim.
 * - Changed '|' register to '=' register (expression evaluation)
 *
 * Changes between version 5.0d and 5.0e:
 * - Use $VIM for global vimrc, gvimrc and menu.vim files.
 * - Removed os_os2_mkpd.c, it only contained the compile flags, which hardly
 *   ever change.
 * - Fixed: After ":global" command, cursor could be past the end of the line.
 * - Fixed: 'hlsearch' highlighting of special characters (e.g., a TAB) didn't
 *   highlight the whole thing.
 * - Fixed: Variable names must not depend on 'iskeyword', because this may
 *   include strange characters, like '(' for help files.
 * - Included xxd version xxd V1.7a (Juergen Weigert).
 * - Fixed: After "Du^R" cursor could be past the end of the line.
 * - Added "%", "#", "<cword>", etc. to expressions (Goldberg).
 * - Added FileChangedShell autocommand event (Goldberg).
 * - Expand <sfile> in an ":autocmd" when it is defined.
 * - Added "nested" flag to ":autocmd", allows nesting.
 * - Handle CTRL-C in GUI for external command, when "setsid()" is supported.
 * - Syncing on C comments is a little bit better for // lines.
 * - Changed syntax of ":region" command to require a '=' for the start, skip
 *   and end items.  More consistent with the ":highlight" command.
 * - Fixed: "r<CR>" didn't work correctly on the last char of a line.
 * - Fixed: sometimes a window resize or other signal caused an endless loop,
 *   involving set_winsize().
 * - Included a few extra syntax files.  Improved a few existing ones.
 * - Fixed: a syntax "end" pattern that matches the start of a line with "^"
 *   didn't work.
 * - Fixed: Syntax keyword matching didn't work when current buffer had other
 *   'iskeyword' setting (e.g., help files).
 * - Added ignoring case for syntax highlighting: ":syntax case [match|ignore]".
 * - Fixed: "vim -r" didn't work, it just hang (using tgetent() while 'term'
 *   is empty).
 * - Fixed: "gk" while 'nowrap' set moved two lines up.
 * - Fixed: when windows are split, a message that causes a scroll-up messed
 *   up one of the windows, which required a CTRL-L to be typed.
 * - Added "mb" termcap option: blink.  Can only be used by assigning it to
 *   one of the other highlight options.
 * - Changed: When an :if or :elseif runs into an error, don't wait for an
 *   :endif, just abort the conditional.
 * - Fixed: possible endless loop when using shell command in the GUI.
 * - Fixed: menu's defined in the .vimrc were removed when GUI started.
 * - Fixed: when syncing in C comments, skip backwards over lines that end in
 *   a backslash.  Helps for multi-line defines.
 * - Allow use of not-yet defined group names after "contains".  Needed for
 *   ALLBUT where the current item is used.
 * - Fixed: A CTRL-C inside an ":if" command stopped the screen updating.
 * - Renamed "various.c" to "misc2.c", "misccmds.c to "misc1.c".
 * - Fixed: was possible to move cursor beyond end of line with "''".
 *
 * Changes between version 5.0c and 5.0d:
 * - Added Win32 GUI version (Robert Webb) !!!
 * - Included Exuberant ctags 1.6b1 (Darren Hiebert).  Made changes to
 *   Makefile to compile it.
 * - Included patches for Python interface from Paul Moore.
 * - Fixed crash when pasting with the mouse in insert mode.
 * - Fixed menu bar not working (or even crashing gvim).
 * - Fixed: RIGHTLEFT didn't work.
 * - Ignore characters after "ex", "view" and "gvim" when checking startup
 *   mode.  Allows the use of "gvim5" et. al.
 * - Added "-Z" argument: start in restricted mode (like "rvim").
 * - Fixed: crash whith ":unmenu *" in .gvimrc for Athena.
 * - Fixed: syntax "ctermfg=" would set "ctermbg=" instead.
 * - Fixed: "5>>" shifted 5 lines 5 times, instead of 1 time.
 * - Fixed: CTRL-C when getting a prompt in ":global" didn't interrupt.
 * - Fixed: CTRL-Y and CTRL-E in Insert mode didn't work.
 * - Fixed: when 'so' is non-zero, and moving the scrollbar completely to the
 *   bottom, there was a lot of flashing.
 * - Fixed: moving cursor with mouse in Insert mode didn't work.
 * - Fixed GUI: scrollbar ident must be long for DEC Alpha.
 * - Made 'guipty' default on, because so many people need it.
 * - "gex" and "gview" start the GUI in ex mode or readonly mode.
 * - Implemented ":set all&", set all options to their default value.
 * - Stop highlighting before clearing the screen, needed for some terminals.
 * - Added "getline()" evaluation function, can be used to check for type of
 *   syntax highlighting in script files.
 * - Added "has_syntax_items" variable, is TRUE when syntax items present.
 * - Fixed: Some functions called vim_regcomp() without setting reg_magic,
 *   which could lead to unpredictable magicness.
 * - Fixed: crash when clicking around the status line, could get a selection
 *   with a backwards range.
 * - Fixed: abbreviations didn't work.
 * - Renamed "sub.c" to "various.c".
 * - Changed ":syntax translate" into ":highlight link".
 * - Handle all syntax stuff like 'magic' is set.
 * - Removed highlight groups local to buffer.  They are all global now, so
 *   they can be shared between buffers.
 * - Added group-name argument to "syntax sync ccomment", so you can specify
 *   the group-name for a comment.
 * - Fixed: when deleting more than one line characterwise, the last character
 *   wasn't deleted.
 * - Fixed: tags filename relative to the current file didn't work.
 *
 * Changes between version 5.0b and 5.0c:
 * - Set time of patch and backup file same as original file (Unix only).
 *   (Hiebert).
 * - INCOMPATIBLE changes to command line arguments:
 *   "-v" now means to start Ex in Vi mode, use "-R" for read-only mode.
 *	 "-e" now means to start Vi in Ex mode, use "-q" for quickfix.
 *	 "-s" in Ex mode now means to run in silent (batch) mode.
 *	 "-x" reserved for crypt, use "-f" to avoid starting a new CLI (Amiga).
 * - Amiga in QuickFix mode no longer opens another window.  Shell commands
 *   can be used now.
 * - Switched to autoconf 2.12.
 * - Added range to ":normal" command.
 * - MSDOS: Added detection of $VIM by finding "vim.exe" in the path.
 * - Win32: Added detection of $VIM by using argv[0].
 * - GUI: fixed: status line could be overwritten when moving the scrollbar
 *   quickly (or when 'wd' is non-zero).
 * - Added decmouse patches from David Binette.
 * - Added "wildcard in path" patches from Karsten Sievert.
 * - Included "shtags" from Stephen Riehm.
 * - Made w_fraction from float to int, so Amiga doesn't need "-lm".
 * - Expand environment variables with expand_env(), instead of calling the
 *   shell.  Makes ":so $VIM/syntax/syntax.vim" a LOT faster.
 * - Fixed: An ESC at the end of a ":normal" command caused a wait for a
 *   terminal code to finish.  Now, a terminal code is not recognized when its
 *   start comes from a mapping or ":normal" command.
 * - Included "<sfile>": file name from a ":source" command.
 * - Renamed strsave() to vim_strsave().  dgux has it as a library function.
 * - Renamed mk_os2pd.c to os_os2_mkpd.c, to put it with the "os_" files.
 * - Renamed perl* to if_perl*.
 * - Added Python interface patches from Paul Moore: if_python*.
 * - Moved a lot of code outside of the big switch() statements in edit.c,
 *   ex_docmd.c and normal.c.  Helps for compiler optimization and makes the
 *   code easier to understand.
 * - Included patches for BeBox from Olaf Seibert.
 * - Included patches from Robert Webb for GUI.  Layout of the windows is now
 *   done inside Vim, instead of letting the layout manager do this.  Makes
 *   Vim work with Lesstif!
 *
 * Changes between version 5.0a and 5.0b:
 * - Renamed b_filename to b_ffname, b_xfilename to b_fname and b_sfilename to
 *   b_sfname.  Renamed mf_xfname to mf_ffname.
 * - Added ":echon" command and changed ":echo" command.
 * - Added register '|': result of expression.
 * - Display '#' register with ":dis" command.
 * - Renamed a lot of files.  All operating system dependent files are now
 *   preceded with "os_".
 * - Read the default menus from $VIM/menu.vim
 *
 * Changes between version < 4.9 and 5.0a:
 * - Added ":echo" command.
 * - Use "datadir" in configure, instead of our own check for HELPDIR.
 * - Reduced output for cursor positioning: Use CR-LF for moving to first few
 *   columns in next few lines;  Don't output CR twice when using termios.
 * - Optimized cursor positioning.  Use CR, BS and NL when it's shorter than
 *   absolute cursor positioning.
 * - Removed ':' from 'isfname' for Unix. Check for "://" in a file name
 *   anyway.  Also check for ":\\", for MS-DOS.
 * - Split cmdline.c into ex_docmd.c and ex_getln.c.
 * - Don't show the mode when redrawing is disabled.
 * - Disable redrawing while repeating insert "1000ii<Esc>".
 * - GUI: Change cursor shape when to vertical bar when inserting and
 *   horizontal bar when replacing text.
 * - Added '@' highlighting flag in 'highlight'.
 * - Added support for "bc" termcap entry.
 * - Count to "K"eyword command, when 'keywordprg' is "man", is inserted in
 *   the man command.  "2K" results in "!man 2 <cword>"
 * - When using "gf" on a relative path name, remove "../" from the filename,
 *   like it's done for filenames in the tags file.
 * - When started as "rvim", disallow shell commands.
 * - Added 'u' flag to 'cpoptions': make "u" work like in vi, but allow
 *   multi-level undo/redo with CTRL-R.
 * - Disallow 'h' flag in 'highlight' (wasn't used anymore since 3.0).
 * - Changed variable names and comments for "yank buffer" to "yank register",
 *   to reflect what is used in the docs.
 * - When finishing recording, don't make the record register the default put
 *   register.
 * - Changed attachment layout for Motif (Sonia Heimann).
 * - Made "d$" or "D" for long lines a lot faster (delete all characters at
 *   once, instead of one by one).
 * - When using "!!", don't put ":5,5!" on the command line, but ":.!".  And
 *   some other enhancements to replace the line number with "." or "$" when
 *   possible.
 * - Renamed normal() to normal_cmd(), a Mac compiler doesn't like normal().
 * - Unix: Added "link.sh" script, which removes a few unneccesary libraries
 *   from the link command.
 * - Added all the syntax highlighting stuff, in sytax.c.
 * - When using $VIM and it's not set, get the directory from 'helpfile',
 *   excluding "/doc/help.txt".
 * - Made the default for the 'helpfile' "$VIM/doc/help.txt" (added the
 *   "/doc" part).
 * - Removed use of IObuff in vim_getenv(), makes life easier.
 * - MSDOS et.al.: Renamed $VIM/viminfo to $VIM/_viminfo.  It's more
 *   consistant: .vimrc/_vimrc and .viminfo/_viminfo
 * - Moved contents of regsub.c into regexp.c, cleaned it up a little.
 * - Included patches from Robert Webb for \{a,b\} in regexp patterns.
 * - Included patches from Eric Fischer for first version of Ex mode.
 * - For systems where case doesn't matter in file names (MSDOS, Amiga), sort
 *   file names while ignoring case.  For buffer names too.
 * - Added 'lazyredraw' option: Don't redraw the screen while executing
 *   macros, registers or other not typed commands.
 * - Added '#' register: alternate file name.
 * - Added ":hide" command, exactly the same as ":close".
 * - When starting the GUI, restrict the window size to the screen size.
 * - Deleted "addcr.c" and "addcr.bat".  They were not very useful.
 * - When resizing the window, don't redraw when redrawing is disabled.  Will
 *   happen later.
 * - Added highlighting to show the match with the last used search pattern,
 *   when 'hlsearch' option is set.
 * - Don't use HPUX digraphs by default, but only when HPUX_DIGRAPHS is
 *   defined.
 * - Added 't_xs', highlighting not erased by overwriting, for hpterm.
 *   Combined with 'weirdinvert'.  Visual mode works on hpterm now.
 * - Made setting special highlighting attributes a lot faster by using
 *   highlight_attr[], instead of searching in the 'highlight' string.
 * - Did some performance optimizations, various changes to source code.
 * - Access option table by first letter, instead of searching from start.
 * - Added expression evaluation, ":let" command in eval.c.
 * - Added ":if", ":else", ":elseif" and ":endif" commands.
 * - Fixed UMR warning in set_expand_context().
 * - Fixed memory leak: b_winlnum list was never freed.
 * - Added patches for using Perl.  ":perldo", ":perl", etc.  Patches made by
 *   Sven Verdoolaege and Matt Gerassimoff.
 * - Allow command line file-arguments and option-arguments to be mixed.
 * - Added "-" commandline argument: read text from stdin.
 * - When reading from stdin doesn't work, read from stderr (helps for
 *   "foo | xargs vim".
 * - Removed the use of "did_cd": Only use the full pathname for files that
 *   are currently open, not for files opened after the ":cd". (Webb)
 * - When resizing windows, try to keep the cursor in the same relative
 *   position.  (Webb)
 */

#include "version.h"

char	*Version = VIM_VERSION_SHORT;
char	*mediumVersion = VIM_VERSION_MEDIUM;
#ifdef HAVE_DATE_TIME
char	*longVersion = VIM_VERSION_LONG_DATE __DATE__ " " __TIME__ ")";
#else
char	*longVersion = VIM_VERSION_LONG;
#endif

static void version_msg __ARGS((char *s));

	int
get_version()
{
	return (VIM_VERSION_MAJOR * 100 + VIM_VERSION_MINOR);
}

	void
do_version(arg)
	char_u	*arg;
{
	long		n;

	if (*arg != NUL)
	{
		found_version = getdigits(&arg) * 100;
		if (*arg == '.' && isdigit(arg[1]))
		{
			/* "4.1"  -> 401, "4.10" -> 410 */
			n = arg[1] - '0';
			if (isdigit(arg[2]))
				found_version += (arg[2] - '0') + n * 10;
			else
				found_version += n;
		}
		if (found_version > get_version())
		{
			MSG("Warning: Found newer version command");
			if (sourcing_name != NULL)
			{
				MSG_PUTS(" in: \"");
				msg_outtrans(sourcing_name);
				MSG_PUTS("\" line: ");
				msg_outnum((long)sourcing_lnum);
			}
		}
	}
	else
	{
		/*
		 * When adding features here, don't forget to update the list of
		 * internal variables in eval.c!
		 */
		msg_putchar('\n');
		MSG(longVersion);
#ifdef WIN32
		MSG_PUTS("\nWindows NT / Windows 95 version");
#endif
#ifdef MSDOS
# ifdef DJGPP
		MSG_PUTS("\n32 bit MS-DOS version");
# else
		MSG_PUTS("\n16 bit MS-DOS version");
# endif
#endif
		MSG_PUTS("\nCompiled with (+) or without (-):\n");
#ifdef AMIGA			/* only for Amiga systems */
# ifdef NO_ARP
		version_msg("-ARP ");
# else
		version_msg("+ARP ");
# endif
#endif
#ifdef AUTOCMD
		version_msg("+autocmd ");
#else
		version_msg("-autocmd ");
#endif
#ifdef NO_BUILTIN_TCAPS
		version_msg("-builtin_terms ");
#endif
#ifdef SOME_BUILTIN_TCAPS
		version_msg("+builtin_terms ");
#endif
#ifdef ALL_BUILTIN_TCAPS
		version_msg("++builtin_terms ");
#endif
#ifdef CINDENT
		version_msg("+cindent ");
#else
		version_msg("-cindent ");
#endif
#ifdef COMPATIBLE
		version_msg("+compatible ");
#else
		version_msg("-compatible ");
#endif
#ifdef DEBUG
		version_msg("+debug ");
#endif
#ifdef DIGRAPHS
		version_msg("+digraphs ");
#else
		version_msg("-digraphs ");
#endif
#ifdef EMACS_TAGS
		version_msg("+emacs_tags ");
#else
		version_msg("-emacs_tags ");
#endif
			/* only interesting on Unix systems */
#if !defined(USE_SYSTEM) && defined(UNIX)
		version_msg("+fork() ");
#endif
#ifdef UNIX
# ifdef USE_GUI_MOTIF
		version_msg("+GUI_Motif ");
# else
#  ifdef USE_GUI_ATHENA
		version_msg("+GUI_Athena ");
#  else
		version_msg("-GUI ");
#  endif
# endif
#endif
#ifdef INSERT_EXPAND
		version_msg("+insert_expand ");
#else
		version_msg("-insert_expand ");
#endif
#ifdef HAVE_LANGMAP
		version_msg("+langmap ");
#else
		version_msg("-langmap ");
#endif
#ifdef LISPINDENT
		version_msg("+lispindent ");
#else
		version_msg("-lispindent ");
#endif
#ifdef HAVE_PERL_INTERP
		version_msg("+perl ");
#else
		version_msg("-perl ");
#endif
#ifdef HAVE_PYTHON
		version_msg("+python ");
#else
		version_msg("-python ");
#endif
#ifdef RIGHTLEFT
		version_msg("+rightleft ");
#else
		version_msg("-rightleft ");
#endif
#ifdef SMARTINDENT
		version_msg("+smartindent ");
#else
		version_msg("-smartindent ");
#endif
			/* only interesting on Unix systems */
#if defined(USE_SYSTEM) && (defined(UNIX) || defined(__EMX__))
		version_msg("+system() ");
#endif
#if defined(UNIX) || defined(__EMX__)
/* only unix (or OS/2 with EMX!) can have terminfo instead of termcap */
# ifdef TERMINFO
		version_msg("+terminfo ");
# else
		version_msg("-terminfo ");
# endif
#else				/* unix always includes termcap support */
# ifdef HAVE_TGETENT
		version_msg("+tgetent ");
# else
		version_msg("-tgetent ");
# endif
#endif
#ifdef VIMINFO
		version_msg("+viminfo ");
#else
		version_msg("-viminfo ");
#endif
#ifdef WRITEBACKUP
		version_msg("+writebackup ");
#else
		version_msg("-writebackup ");
#endif
#ifdef UNIX
# if defined(WANT_X11) && defined(HAVE_X11)
		version_msg("+X11 ");
# else
		version_msg("-X11 ");
# endif
#endif
		msg_putchar('\n');
#ifdef USR_VIMRC_FILE
		version_msg("   user vimrc file: \"");
		version_msg(USR_VIMRC_FILE);
		version_msg("\" ");
#endif
#ifdef USR_EXRC_FILE
		version_msg("    user exrc file: \"");
		version_msg(USR_EXRC_FILE);
		version_msg("\" ");
#endif
#ifdef USE_GUI
		version_msg("  user gvimrc file: \"");
		version_msg(USR_GVIMRC_FILE);
		version_msg("\" ");
#endif
#ifdef SYS_VIMRC_FILE
		msg_putchar('\n');
		version_msg(" system vimrc file: \"");
		version_msg(SYS_VIMRC_FILE);
		version_msg("\"");
#endif
#ifdef USE_GUI
# ifdef SYS_GVIMRC_FILE
		msg_putchar('\n');
		version_msg("system gvimrc file: \"");
		version_msg(SYS_GVIMRC_FILE);
		MSG_PUTS("\"");
# endif
# ifdef SYS_MENU_FILE
		msg_putchar('\n');
		version_msg("  system menu file: \"");
		version_msg(SYS_MENU_FILE);
		MSG_PUTS("\"");
# endif
#endif
#ifdef HAVE_PATHDEF
		msg_putchar('\n');
		version_msg("  default for $VIM: \"");
		version_msg((char *)default_vim_dir);
		MSG_PUTS("\"\n");
		version_msg("Compilation: ");
		version_msg((char *)all_cflags);
		msg_putchar('\n');
		version_msg("Linking: ");
		version_msg((char *)all_lflags);
#endif
	}
}

/*
 * Output a string for the version message.  If it's going to wrap, output a
 * newline, unless the message is too long to fit on the screen anyway.
 */
	static void
version_msg(s)
	char		*s;
{
	int		len = strlen(s);

	if (len < (int)Columns && msg_col + len >= (int)Columns)
		msg_putchar('\n');
	MSG_PUTS(s);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.