home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume44
/
vim
/
part21
< prev
next >
Wrap
Internet Message Format
|
1994-08-18
|
71KB
From: mool@oce.nl (Bram Moolenaar)
Newsgroups: comp.sources.misc
Subject: v44i040: vim - Vi IMproved editor, v3.0, Part21/26
Date: 18 Aug 1994 14:03:30 -0500
Organization: Sterling Software
Sender: kent@sparky.sterling.com
Approved: kent@sparky.sterling.com
Message-ID: <330ba2$e7u@sparky.sterling.com>
X-Md4-Signature: b210fb44b49f8358762dc616a08b3395
Submitted-by: mool@oce.nl (Bram Moolenaar)
Posting-number: Volume 44, Issue 40
Archive-name: vim/part21
Environment: UNIX, AMIGA, MS-DOS, Windows NT
Supersedes: vim: Volume 41, Issue 50-75
#! /bin/sh
# This is a shell archive. Remove anything before this line, then feed it
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# Contents: vim/src/csearch.c vim/src/main.c vim/src/makefile.unix
# vim/src/regsub.c vim/src/structs.h
# Wrapped by kent@sparky on Mon Aug 15 21:44:12 1994
PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 21 (of 26)."'
if test -f 'vim/src/csearch.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/csearch.c'\"
else
echo shar: Extracting \"'vim/src/csearch.c'\" \(14449 characters\)
sed "s/^X//" >'vim/src/csearch.c' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved by Bram Moolenaar
X *
X * Read the file "credits.txt" for a list of people who contributed.
X * Read the file "uganda.txt" for copying and usage conditions.
X */
X
X/*
X *
X * csearch.c: dosub() and doglob() for :s, :g and :v
X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X
X/* we use modified Henry Spencer's regular expression routines */
X#include "regexp.h"
X
X/* dosub(lp, up, cmd)
X *
X * Perform a substitution from line 'lp' to line 'up' using the
X * command pointed to by 'cmd' which should be of the form:
X *
X * /pattern/substitution/gc
X *
X * The trailing 'g' is optional and, if present, indicates that multiple
X * substitutions should be performed on each line, if applicable.
X * The trailing 'c' is optional and, if present, indicates that a confirmation
X * will be asked for each replacement.
X * The usual escapes are supported as described in the regexp docs.
X *
X * use_old == 0 for :substitute
X * use_old == 1 for :&
X * use_old == 2 for :~
X */
X
X void
Xdosub(lp, up, cmd, nextcommand, use_old)
X linenr_t lp;
X linenr_t up;
X char_u *cmd;
X char_u **nextcommand;
X int use_old;
X{
X linenr_t lnum;
X long i;
X char_u *ptr;
X char_u *old_line;
X regexp *prog;
X long nsubs = 0;
X linenr_t nlines = 0;
X static int do_all = FALSE; /* do multiple substitutions per line */
X static int do_ask = FALSE; /* ask for confirmation */
X char_u *pat = NULL, *sub = NULL;
X static char_u *old_sub = NULL;
X int delimiter;
X int sublen;
X int got_quit = FALSE;
X int got_match = FALSE;
X int temp;
X int which_pat;
X
X if (use_old == 2)
X which_pat = 2; /* use last used regexp */
X else
X which_pat = 1; /* use last substitute regexp */
X
X /* new pattern and substitution */
X if (use_old == 0 && *cmd != NUL && strchr("0123456789gcr|\"", *cmd) == NULL)
X {
X if (isalpha(*cmd)) /* don't accept alpha for separator */
X {
X emsg(e_invarg);
X return;
X }
X /*
X * undocumented vi feature:
X * "\/sub/" and "\?sub?" use last used search pattern (almost like //sub/r).
X * "\&sub&" use last substitute pattern (like //sub/).
X */
X if (*cmd == '\\')
X {
X ++cmd;
X if (strchr("/?&", *cmd) == NULL)
X {
X emsg(e_backslash);
X return;
X }
X if (*cmd != '&')
X which_pat = 0; /* use last '/' pattern */
X pat = (char_u *)""; /* empty search pattern */
X delimiter = *cmd++; /* remember delimiter character */
X }
X else /* find the end of the regexp */
X {
X delimiter = *cmd++; /* remember delimiter character */
X pat = cmd; /* remember start of search pattern */
X cmd = skip_regexp(cmd, delimiter);
X if (cmd[0] == delimiter) /* end delimiter found */
X *cmd++ = NUL; /* replace it by a NUL */
X }
X
X /*
X * Small incompatibility: vi sees '\n' as end of the command, but in
X * Vim we want to use '\n' to find/substitute a NUL.
X */
X sub = cmd; /* remember the start of the substitution */
X
X while (cmd[0])
X {
X if (cmd[0] == delimiter) /* end delimiter found */
X {
X *cmd++ = NUL; /* replace it by a NUL */
X break;
X }
X if (cmd[0] == '\\' && cmd[1] != 0) /* skip escaped characters */
X ++cmd;
X ++cmd;
X }
X
X free(old_sub);
X old_sub = strsave(sub);
X }
X else /* use previous pattern and substitution */
X {
X if (old_sub == NULL) /* there is no previous command */
X {
X emsg(e_nopresub);
X return;
X }
X pat = NULL; /* myregcomp() will use previous pattern */
X sub = old_sub;
X }
X
X /*
X * find trailing options
X */
X if (!p_ed)
X {
X if (p_gd) /* default is global on */
X do_all = TRUE;
X else
X do_all = FALSE;
X do_ask = FALSE;
X }
X while (*cmd)
X {
X /*
X * Note that 'g' and 'c' are always inverted, also when p_ed is off
X * 'r' is never inverted.
X */
X if (*cmd == 'g')
X do_all = !do_all;
X else if (*cmd == 'c')
X do_ask = !do_ask;
X else if (*cmd == 'r') /* use last used regexp */
X which_pat = 2;
X else
X break;
X ++cmd;
X }
X
X /*
X * check for a trailing count
X */
X skipspace(&cmd);
X if (isdigit(*cmd))
X {
X i = getdigits(&cmd);
X if (i <= 0)
X {
X emsg(e_zerocount);
X return;
X }
X lp = up;
X up += i - 1;
X }
X
X /*
X * check for trailing '|', '"' or '\n'
X */
X skipspace(&cmd);
X if (*cmd)
X {
X if (strchr("|\"\n", *cmd) == NULL)
X {
X emsg(e_trailing);
X return;
X }
X else
X *nextcommand = cmd;
X }
X
X if ((prog = myregcomp(pat, 1, which_pat)) == NULL)
X {
X emsg(e_invcmd);
X return;
X }
X
X /*
X * ~ in the substitute pattern is replaced by the old pattern.
X * We do it here once to avoid it to be replaced over and over again.
X */
X sub = regtilde(sub, (int)p_magic);
X
X old_line = NULL;
X for (lnum = lp; lnum <= up && !(got_int || got_quit); ++lnum)
X {
X ptr = ml_get(lnum);
X if (regexec(prog, ptr, TRUE)) /* a match on this line */
X {
X char_u *new_end, *new_start = NULL;
X char_u *old_match, *old_copy;
X char_u *prev_old_match = NULL;
X char_u *p1;
X int did_sub = FALSE;
X int match, lastone;
X
X /* make a copy of the line, so it won't be taken away when updating
X the screen */
X if ((old_line = strsave(ptr)) == NULL)
X continue;
X regexec(prog, old_line, TRUE); /* match again on this line to update the pointers. TODO: remove extra regexec() */
X if (!got_match)
X {
X setpcmark();
X got_match = TRUE;
X }
X
X old_copy = old_match = old_line;
X for (;;) /* loop until nothing more to replace */
X {
X /*
X * Save the position of the last change for the final cursor
X * position (just like the real vi).
X */
X curwin->w_cursor.lnum = lnum;
X curwin->w_cursor.col = (int)(prog->startp[0] - old_line);
X
X /*
X * Match empty string does not count, except for first match.
X * This reproduces the strange vi behaviour.
X * This also catches endless loops.
X */
X if (old_match == prev_old_match && old_match == prog->endp[0])
X {
X ++old_match;
X goto skip;
X }
X old_match = prog->endp[0];
X prev_old_match = old_match;
X
X while (do_ask) /* loop until 'y', 'n' or 'q' typed */
X {
X temp = RedrawingDisabled;
X RedrawingDisabled = FALSE;
X comp_Botline(curwin);
X updateScreen(CURSUPD);
X /* same highlighting as for wait_return */
X (void)set_highlight('r');
X msg_highlight = TRUE;
X smsg((char_u *)"replace by %s (y/n/q)?", sub);
X showruler(TRUE);
X setcursor();
X RedrawingDisabled = temp;
X if ((i = vgetc()) == 'q' || i == ESC || i == Ctrl('C'))
X {
X got_quit = TRUE;
X break;
X }
X else if (i == 'n')
X goto skip;
X else if (i == 'y')
X break;
X }
X if (got_quit)
X break;
X
X /* get length of substitution part */
X sublen = regsub(prog, sub, old_line, 0, (int)p_magic);
X if (new_start == NULL)
X {
X /*
X * Get some space for a temporary buffer to do the substitution
X * into.
X */
X if ((new_start = alloc((unsigned)(STRLEN(old_line) + sublen + 5))) == NULL)
X goto outofmem;
X *new_start = NUL;
X }
X else
X {
X /*
X * extend the temporary buffer to do the substitution into.
X */
X if ((p1 = alloc((unsigned)(STRLEN(new_start) + STRLEN(old_copy) + sublen + 1))) == NULL)
X goto outofmem;
X STRCPY(p1, new_start);
X free(new_start);
X new_start = p1;
X }
X
X for (new_end = new_start; *new_end; new_end++)
X ;
X /*
X * copy up to the part that matched
X */
X while (old_copy < prog->startp[0])
X *new_end++ = *old_copy++;
X
X regsub(prog, sub, new_end, 1, (int)p_magic);
X nsubs++;
X did_sub = TRUE;
X
X /*
X * Now the trick is to replace CTRL-Ms with a real line break.
X * This would make it impossible to insert CTRL-Ms in the text.
X * That is the way vi works. In Vim the line break can be
X * avoided by preceding the CTRL-M with a CTRL-V. Now you can't
X * precede a line break with a CTRL-V, big deal.
X */
X while ((p1 = STRCHR(new_end, CR)) != NULL)
X {
X if (p1 == new_end || p1[-1] != Ctrl('V'))
X {
X if (u_inssub(lnum)) /* prepare for undo */
X {
X *p1 = NUL; /* truncate up to the CR */
X mark_adjust(lnum, MAXLNUM, 1L);
X ml_append(lnum - 1, new_start, (colnr_t)(p1 - new_start + 1), FALSE);
X ++lnum;
X ++up; /* number of lines increases */
X STRCPY(new_start, p1 + 1); /* copy the rest */
X new_end = new_start;
X }
X }
X else /* remove CTRL-V */
X {
X STRCPY(p1 - 1, p1);
X new_end = p1;
X }
X }
X
X old_copy = prog->endp[0]; /* remember next character to be copied */
X /*
X * continue searching after the match
X * prevent endless loop with patterns that match empty strings,
X * e.g. :s/$/pat/g or :s/[a-z]* /(&)/g
X */
Xskip:
X match = -1;
X lastone = (*old_match == NUL || got_int || got_quit || !do_all);
X if (lastone || do_ask || (match = regexec(prog, old_match, (int)FALSE)) == 0)
X {
X if (new_start)
X {
X /*
X * Copy the rest of the line, that didn't match.
X * Old_match has to be adjusted, we use the end of the line
X * as reference, because the substitute may have changed
X * the number of characters.
X */
X STRCAT(new_start, old_copy);
X i = old_line + STRLEN(old_line) - old_match;
X if (u_savesub(lnum))
X ml_replace(lnum, new_start, TRUE);
X
X free(old_line); /* free the temp buffer */
X old_line = new_start;
X new_start = NULL;
X old_match = old_line + STRLEN(old_line) - i;
X if (old_match < old_line) /* safety check */
X {
X EMSG("dosub internal error: old_match < old_line");
X old_match = old_line;
X }
X old_copy = old_line;
X }
X if (match == -1 && !lastone)
X match = regexec(prog, old_match, (int)FALSE);
X if (match <= 0) /* quit loop if there is no more match */
X break;
X }
X /* breakcheck is slow, don't call it too often */
X if ((nsubs & 15) == 0)
X breakcheck();
X
X }
X if (did_sub)
X ++nlines;
X free(old_line); /* free the copy of the original line */
X old_line = NULL;
X }
X /* breakcheck is slow, don't call it too often */
X if ((lnum & 15) == 0)
X breakcheck();
X }
X
Xoutofmem:
X free(old_line); /* may have to free an allocated copy of the line */
X if (nsubs)
X {
X CHANGED;
X updateScreen(CURSUPD); /* need this to update LineSizes */
X beginline(TRUE);
X if (nsubs > p_report)
X smsg((char_u *)"%s%ld substitution%s on %ld line%s",
X got_int ? "(Interrupted) " : "",
X nsubs, plural(nsubs),
X (long)nlines, plural((long)nlines));
X else if (got_int)
X emsg(e_interr);
X else if (do_ask)
X MSG("");
X }
X else if (got_int) /* interrupted */
X emsg(e_interr);
X else if (got_match) /* did find something but nothing substituted */
X MSG("");
X else /* nothing found */
X emsg(e_nomatch);
X
X free(prog);
X}
X
X/*
X * doglob(cmd)
X *
X * Execute a global command of the form:
X *
X * g/pattern/X : execute X on all lines where pattern matches
X * v/pattern/X : execute X on all lines where pattern does not match
X *
X * where 'X' is an EX command
X *
X * The command character (as well as the trailing slash) is optional, and
X * is assumed to be 'p' if missing.
X *
X * This is implemented in two passes: first we scan the file for the pattern and
X * set a mark for each line that (not) matches. secondly we execute the command
X * for each line that has a mark. This is required because after deleting
X * lines we do not know where to search for the next match.
X */
X
X void
Xdoglob(type, lp, up, cmd)
X int type;
X linenr_t lp, up;
X char_u *cmd;
X{
X linenr_t lnum; /* line number according to old situation */
X linenr_t old_lcount; /* curbuf->b_ml.ml_line_count before the command */
X int ndone;
X
X char_u delim; /* delimiter, normally '/' */
X char_u *pat;
X regexp *prog;
X int match;
X int which_pat;
X
X if (global_busy)
X {
X EMSG("Cannot do :global recursive");
X ++global_busy;
X return;
X }
X
X which_pat = 2; /* default: use last used regexp */
X
X /*
X * undocumented vi feature:
X * "\/" and "\?": use previous search pattern.
X * "\&": use previous substitute pattern.
X */
X if (*cmd == '\\')
X {
X ++cmd;
X if (strchr("/?&", *cmd) == NULL)
X {
X emsg(e_backslash);
X return;
X }
X if (*cmd == '&')
X which_pat = 1; /* use previous substitute pattern */
X else
X which_pat = 0; /* use previous search pattern */
X ++cmd;
X pat = (char_u *)"";
X }
X else
X {
X delim = *cmd; /* get the delimiter */
X if (delim)
X ++cmd; /* skip delimiter if there is one */
X pat = cmd; /* remember start of pattern */
X cmd = skip_regexp(cmd, delim);
X if (cmd[0] == delim) /* end delimiter found */
X *cmd++ = NUL; /* replace it by a NUL */
X }
X
X reg_ic = p_ic; /* set "ignore case" flag appropriately */
X
X if ((prog = myregcomp(pat, 2, which_pat)) == NULL)
X {
X emsg(e_invcmd);
X return;
X }
X MSG("");
X
X/*
X * pass 1: set marks for each (not) matching line
X */
X ndone = 0;
X for (lnum = lp; lnum <= up && !got_int; ++lnum)
X {
X match = regexec(prog, ml_get(lnum), (int)TRUE); /* a match on this line? */
X if ((type == 'g' && match) || (type == 'v' && !match))
X {
X ml_setmarked(lnum);
X ndone++;
X }
X /* breakcheck is slow, don't call it too often */
X if ((lnum & 15) == 0)
X breakcheck();
X }
X
X/*
X * pass 2: execute the command for each line that has been marked
X */
X if (got_int)
X MSG("Interrupted");
X else if (ndone == 0)
X msg(e_nomatch);
X else
X {
X global_busy = 1;
X dont_sleep = 1; /* don't sleep in emsg() */
X no_wait_return = 1; /* dont wait for return until finished */
X need_wait_return = FALSE;
X RedrawingDisabled = TRUE;
X old_lcount = curbuf->b_ml.ml_line_count;
X did_msg = FALSE;
X while (!got_int && (lnum = ml_firstmarked()) != 0 && global_busy == 1)
X {
X /*
X * If there was a message from the previous command, scroll
X * the lines up for the next, otherwise it will be overwritten.
X * did_msg is set by msg_start().
X */
X if (did_msg)
X {
X cmdline_row = msg_row;
X did_msg = FALSE;
X }
X curwin->w_cursor.lnum = lnum;
X curwin->w_cursor.col = 0;
X if (*cmd == NUL || *cmd == '\n')
X docmdline((char_u *)"p");
X else
X docmdline(cmd);
X breakcheck();
X }
X
X RedrawingDisabled = FALSE;
X global_busy = 0;
X dont_sleep = 0;
X no_wait_return = 0;
X if (need_wait_return) /* wait for return now */
X wait_return(FALSE);
X
X screenclear();
X updateScreen(CURSUPD);
X msgmore(curbuf->b_ml.ml_line_count - old_lcount);
X }
X
X ml_clearmarked(); /* clear rest of the marks */
X free(prog);
X}
END_OF_FILE
if test 14449 -ne `wc -c <'vim/src/csearch.c'`; then
echo shar: \"'vim/src/csearch.c'\" unpacked with wrong size!
fi
# end of 'vim/src/csearch.c'
fi
if test -f 'vim/src/main.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/main.c'\"
else
echo shar: Extracting \"'vim/src/main.c'\" \(14502 characters\)
sed "s/^X//" >'vim/src/main.c' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved by Bram Moolenaar
X *
X * Read the file "credits.txt" for a list of people who contributed.
X * Read the file "uganda.txt" for copying and usage conditions.
X */
X
X#define EXTERN
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X#include "param.h"
X
X#ifdef SPAWNO
X# include <spawno.h> /* special MSDOS swapping library */
X#endif
X
Xstatic void usage __PARMS((int));
X
X static void
Xusage(n)
X int n;
X{
X register int i;
X static char_u *(use[]) = {(char_u *)"[file ..]\n",
X (char_u *)"-t tag\n",
X (char_u *)"-e [errorfile]\n"};
X static char_u *(errors[]) = {(char_u *)"Unknown option\n", /* 0 */
X (char_u *)"Too many arguments\n", /* 1 */
X (char_u *)"Argument missing\n", /* 2 */
X };
X
X fprintf(stderr, (char *)errors[n]);
X fprintf(stderr, "usage:");
X for (i = 0; ; ++i)
X {
X fprintf(stderr, " vim [options] ");
X fprintf(stderr, (char *)use[i]);
X if (i == (sizeof(use) / sizeof(char_u *)) - 1)
X break;
X fprintf(stderr, " or:");
X }
X fprintf(stderr, "\noptions:\t-v\t\treadonly mode (view)\n");
X fprintf(stderr, "\t\t-n\t\tno swap file, use memory only\n");
X fprintf(stderr, "\t\t-b\t\tbinary mode\n");
X fprintf(stderr, "\t\t-r\t\trecovery mode\n");
X#ifdef AMIGA
X fprintf(stderr, "\t\t-x\t\tdon't use newcli to open window\n");
X fprintf(stderr, "\t\t-d device\tuse device for I/O\n");
X#endif
X fprintf(stderr, "\t\t-T terminal\tset terminal type\n");
X fprintf(stderr, "\t\t-o[N]\t\topen N windows (def: one for each file)\n");
X fprintf(stderr, "\t\t+\t\tstart at end of file\n");
X fprintf(stderr, "\t\t+lnum\t\tstart at line lnum\n");
X fprintf(stderr, "\t\t-c command\texecute command first\n");
X fprintf(stderr, "\t\t-s scriptin\tread commands from script file\n");
X fprintf(stderr, "\t\t-w scriptout\twrite commands in script file\n");
X mch_windexit(1);
X}
X
X#ifdef USE_LOCALE
X# include <locale.h>
X#endif
X
X void
Xmain(argc, argv)
X int argc;
X char **argv;
X{
X char_u *initstr; /* init string from the environment */
X char_u *term = NULL; /* specified terminal name */
X char_u *fname = NULL; /* file name from command line */
X char_u *command = NULL; /* command from + or -c option */
X char_u *tagname = NULL; /* tag from -t option */
X int c;
X int doqf = 0;
X int i;
X int bin_mode = FALSE; /* -b option used */
X int win_count = 1; /* number of windows to use */
X
X#ifdef USE_LOCALE
X setlocale(LC_ALL, ""); /* for ctype() and the like */
X#endif
X
X/*
X * Check if we have an interactive window.
X * If not, open one with a newcli command (needed for :! to work).
X * check_win will also handle the -d argument (for the Amiga).
X */
X check_win(argc, argv);
X
X/*
X * allocate the first window and buffer. Can't to anything without it
X */
X if ((curwin = win_alloc(NULL)) == NULL ||
X (curbuf = buflist_new(NULL, NULL, 1L, FALSE)) == NULL)
X mch_windexit(0);
X curwin->w_buffer = curbuf;
X
X/*
X * If the executable is called "view" we start in readonly mode.
X */
X if (STRCMP(gettail((char_u *)argv[0]), (char_u *)"view") == 0)
X {
X readonlymode = TRUE;
X curbuf->b_p_ro = TRUE;
X p_uc = 0;
X }
X
X ++argv;
X /*
X * Process the command line arguments
X * '-c {command}' execute command
X * '+{command}' execute command
X * '-s scriptin' read from script file
X * '-w scriptout' write to script file
X * '-v' view
X * '-b' binary
X * '-n' no .vim file
X * '-r' recovery mode
X * '-x' open window directly, not with newcli
X * '-o[N]' open N windows (default: number of files)
X * '-T terminal' terminal name
X */
X while (argc > 1 && ((c = argv[0][0]) == '+' || (c == '-' &&
X strchr("vnbrxocswTd", c = argv[0][1]) != NULL && c != NUL)))
X {
X --argc;
X switch (c)
X {
X case '+': /* + or +{number} or +/{pat} or +{command} */
X c = argv[0][1];
X if (c == NUL)
X command = (char_u *)"$";
X else
X command = (char_u *)&(argv[0][1]);
X break;
X
X case 'v':
X readonlymode = TRUE;
X curbuf->b_p_ro = TRUE;
X /*FALLTHROUGH*/
X
X case 'n':
X p_uc = 0;
X break;
X
X case 'b':
X bin_mode = TRUE; /* postpone to after reading .exrc files */
X break;
X
X case 'r':
X recoverymode = 1;
X break;
X
X case 'x':
X break; /* This is ignored as it is handled in check_win() */
X
X case 'o':
X c = argv[0][2];
X if (c != NUL && !isdigit(c))
X {
X fprintf(stderr, "-o option needs numeric argument (or none)\n");
X mch_windexit(2);
X }
X win_count = atoi(&(argv[0][2])); /* 0 means: number of files */
X break;
X
X default: /* options with argument */
X ++argv;
X --argc;
X if (argc < 1)
X usage(2);
X
X switch (c)
X {
X case 'c': /* -c {command} */
X command = (char_u *)&(argv[0][0]);
X break;
X
X case 's':
X if ((scriptin[0] = fopen(argv[0], READBIN)) == NULL)
X {
X fprintf(stderr, "cannot open %s for reading\n", argv[0]);
X mch_windexit(2);
X }
X break;
X
X case 'w':
X if ((scriptout = fopen(argv[0], APPENDBIN)) == NULL)
X {
X fprintf(stderr, "cannot open %s for output\n", argv[0]);
X mch_windexit(2);
X }
X break;
X
X/*
X * The -T term option is always available and when TERMCAP is supported it
X * overrides the environment variable TERM.
X */
X case 'T':
X term = (char_u *)*argv;
X break;
X
X /* case 'd': This is ignored as it is handled in check_win() */
X }
X }
X ++argv;
X }
X
X /*
X * Allocate space for the generic buffers
X */
X if ((IObuff = alloc(IOSIZE)) == NULL || (NameBuff = alloc(MAXPATHL)) == NULL)
X mch_windexit(0);
X
X /* note that we may use mch_windexit() before mch_windinit()! */
X mch_windinit();
X set_init(); /* after mch_windinit because Rows is used */
X firstwin->w_height = Rows - 1;
X cmdline_row = Rows - 1;
X
X /*
X * Process the other command line arguments.
X */
X if (argc > 1)
X {
X c = argv[0][1];
X switch (argv[0][0])
X {
X case '-':
X switch (c)
X {
X case 'e': /* -e QuickFix mode */
X switch (argc)
X {
X case 2:
X if (argv[0][2]) /* -eerrorfile */
X p_ef = (char_u *)argv[0] + 2;
X break; /* -e */
X
X case 3: /* -e errorfile */
X ++argv;
X p_ef = (char_u *)argv[0];
X break;
X
X default: /* argc > 3: too many arguments */
X usage(1);
X }
X doqf = 1;
X break;
X
X case 't': /* -t tag or -ttag */
X switch (argc)
X {
X case 2:
X if (argv[0][2]) /* -ttag */
X {
X tagname = (char_u *)argv[0] + 2;
X break;
X }
X usage(2); /* argument missing */
X break;
X
X case 3: /* -t tag */
X ++argv;
X tagname = (char_u *)argv[0];
X break;
X
X default: /* argc > 3: too many arguments */
X usage(1);
X }
X break;
X
X default:
X usage(0);
X }
X break;
X
X default: /* must be a file name */
X#if !defined(UNIX) || defined(ARCHIE)
X if (ExpandWildCards(argc - 1, (char_u **)argv, &arg_count,
X &arg_files, TRUE, TRUE) == OK && arg_count != 0)
X {
X fname = arg_files[0];
X arg_exp = TRUE;
X }
X#else
X arg_files = (char_u **)argv;
X arg_count = argc - 1;
X fname = (char_u *)argv[0];
X#endif
X if (arg_count > 1)
X printf("%d files to edit\n", arg_count);
X break;
X }
X }
X
X RedrawingDisabled = TRUE;
X
X curbuf->b_nwindows = 1; /* there is one window */
X win_init(curwin); /* init cursor position */
X init_yank(); /* init yank buffers */
X termcapinit(term); /* get terminal capabilities */
X screenclear(); /* clear screen (just inits screen structures,
X because starting is TRUE) */
X
X#ifdef MSDOS /* default mapping for some often used keys */
X domap(0, "#1 :help\r", NORMAL); /* F1 is help key */
X domap(0, "\316R i", NORMAL); /* INSERT is 'i' */
X domap(0, "\316S \177", NORMAL); /* DELETE is 0x7f */
X domap(0, "\316G 0", NORMAL); /* HOME is '0' */
X domap(0, "\316w H", NORMAL); /* CTRL-HOME is 'H' */
X domap(0, "\316O $", NORMAL); /* END is '$' */
X domap(0, "\316u L", NORMAL); /* CTRL-END is 'L' */
X domap(0, "\316I \002", NORMAL); /* PageUp is '^B' */
X domap(0, "\316\204 1G", NORMAL); /* CTRL-PageUp is '1G' */
X domap(0, "\316Q \006", NORMAL); /* PageDown is '^F' */
X domap(0, "\316v G", NORMAL); /* CTRL-PageDown is 'G' */
X /* insert mode */
X domap(0, "#1 \017:help\r", INSERT); /* F1 is help key */
X domap(0, "\316R \033", INSERT); /* INSERT is ESC */
X /* note: extra space needed to avoid the same memory used for this
X and the one above, domap() will add a NUL to it */
X domap(0, "\316S \177", INSERT+CMDLINE); /* DELETE is 0x7f */
X domap(0, "\316G \017""0", INSERT); /* HOME is '^O0' */
X domap(0, "\316w \017H", INSERT); /* CTRL-HOME is '^OH' */
X domap(0, "\316O \017$", INSERT); /* END is '^O$' */
X domap(0, "\316u \017L", INSERT); /* CTRL-END is '^OL' */
X domap(0, "\316I \017\002", INSERT); /* PageUp is '^O^B' */
X domap(0, "\316\204 \017\061G", INSERT); /* CTRL-PageUp is '^O1G' */
X domap(0, "\316Q \017\006", INSERT); /* PageDown is '^O^F' */
X domap(0, "\316v \017G", INSERT); /* CTRL-PageDown is '^OG' */
X#endif
X
X msg_start(); /* in case a mapping is printed */
X no_wait_return = TRUE;
X
X/*
X * get system wide defaults (for unix)
X */
X#ifdef DEFVIMRC_FILE
X (void)dosource(DEFVIMRC_FILE);
X#endif
X
X/*
X * Try to read initialization commands from the following places:
X * - environment variable VIMINIT
X * - file s:.vimrc ($HOME/.vimrc for Unix)
X * - environment variable EXINIT
X * - file s:.exrc ($HOME/.exrc for Unix)
X * The first that exists is used, the rest is ignored.
X */
X if ((initstr = vimgetenv((char_u *)"VIMINIT")) != NULL)
X docmdline(initstr);
X else if (dosource((char_u *)SYSVIMRC_FILE) == FAIL)
X {
X if ((initstr = vimgetenv((char_u *)"EXINIT")) != NULL)
X docmdline(initstr);
X else
X (void)dosource((char_u *)SYSEXRC_FILE);
X }
X
X/*
X * Read initialization commands from ".vimrc" or ".exrc" in current directory.
X * This is only done if the 'exrc' option is set.
X * Because of security reasons we disallow shell and write commands now,
X * except for unix if the file is owned by the user or 'secure' option has been
X * reset in environmet of global ".exrc" or ".vimrc".
X * Only do this if VIMRC_FILE is not the same as SYSVIMRC_FILE or DEFVIMRC_FILE.
X */
X if (p_exrc)
X {
X#ifdef UNIX
X {
X struct stat s;
X
X /* if ".vimrc" file is not owned by user, set 'secure' mode */
X if (stat(VIMRC_FILE, &s) || s.st_uid != getuid())
X secure = p_secure;
X }
X#else
X secure = p_secure;
X#endif
X
X i = FAIL;
X if (fullpathcmp((char_u *)SYSVIMRC_FILE, (char_u *)VIMRC_FILE)
X#ifdef DEFVIMRC_FILE
X && fullpathcmp((char_u *)DEFVIMRC_FILE, (char_u *)VIMRC_FILE)
X#endif
X )
X i = dosource((char_u *)VIMRC_FILE);
X#ifdef UNIX
X if (i == FAIL)
X {
X struct stat s;
X
X /* if ".exrc" file is not owned by user set 'secure' mode */
X if (stat(EXRC_FILE, &s) || s.st_uid != getuid())
X secure = p_secure;
X else
X secure = 0;
X }
X#endif
X if (i == FAIL && fullpathcmp((char_u *)SYSEXRC_FILE, (char_u *)EXRC_FILE))
X (void)dosource((char_u *)EXRC_FILE);
X }
X
X#ifdef SPAWNO /* special MSDOS swapping library */
X init_SPAWNO("", SWAP_ANY);
X#endif
X/*
X * Call settmode and starttermcap here, so the T_KS and T_TS may be defined
X * by termcapinit and redifined in .exrc.
X */
X settmode(1);
X starttermcap();
X
X no_wait_return = FALSE;
X /* done something that is not allowed or error message */
X if (secure == 2 || need_wait_return)
X wait_return(TRUE); /* must be called after settmode(1) */
X secure = 0;
X
X if (bin_mode) /* -b option used */
X {
X curbuf->b_p_bin = 1; /* binary file I/O */
X curbuf->b_p_tw = 0; /* no automatic line wrap */
X curbuf->b_p_wm = 0; /* no automatic line wrap */
X curbuf->b_p_tx = 0; /* no text mode */
X p_ta = 0; /* no text auto */
X curbuf->b_p_ml = 0; /* no modelines */
X curbuf->b_p_et = 0; /* no expand tab */
X }
X
X (void)setfname(fname, NULL, TRUE);
X maketitle();
X
X if (win_count == 0)
X win_count = arg_count;
X if (win_count > 1)
X win_count = make_windows(win_count);
X else
X win_count = 1;
X
X/*
X * Start putting things on the screen.
X * Scroll screen down before drawing over it
X * Clear screen now, so file message will not be cleared.
X */
X starting = FALSE;
X if (T_CVV != NULL && *T_CVV)
X {
X outstr(T_CVV);
X outstr(T_CV);
X }
X screenclear(); /* clear screen */
X
X if (recoverymode) /* do recover */
X {
X if (ml_open() == FAIL) /* Initialize storage structure */
X getout(1);
X ml_recover();
X }
X else
X (void)open_buffer(); /* create memfile and read file */
X
X setpcmark();
X
X if (doqf && qf_init() == FAIL) /* if reading error file fails: exit */
X mch_windexit(3);
X
X /*
X * If opened more than one window, start editing files in the other windows.
X * Make_windows() has already opened the windows.
X * This is all done by putting commands in the stuff buffer.
X */
X for (i = 1; i < win_count; ++i)
X {
X if (curwin->w_next == NULL) /* just checking */
X break;
X win_enter(curwin->w_next, FALSE);
X /* edit file i, if there is one */
X (void)doecmd(i < arg_count ? arg_files[i] : NULL,
X NULL, NULL, TRUE, (linenr_t)1);
X curwin->w_arg_idx = i;
X }
X win_enter(firstwin, FALSE); /* back to first window */
X
X /*
X * If there are more file names in the argument list than windows,
X * put the rest of the names in the buffer list.
X */
X for (i = win_count; i < arg_count; ++i)
X (void)buflist_add(arg_files[i]);
X
X if (command)
X docmdline(command);
X /*
X * put the :ta command in the stuff buffer here, so that it will not
X * be erased by an emsg().
X */
X if (tagname)
X {
X stuffReadbuff((char_u *)":ta ");
X stuffReadbuff(tagname);
X stuffReadbuff((char_u *)"\n");
X }
X
X RedrawingDisabled = FALSE;
X updateScreen(NOT_VALID);
X
X /* start in insert mode (already taken care of for :ta command) */
X if (p_im && stuff_empty())
X stuffReadbuff((char_u *)"i");
X/*
X * main command loop
X */
X for (;;)
X {
X if (got_int)
X {
X (void)vgetc(); /* flush all buffers */
X got_int = FALSE;
X }
X adjust_cursor(); /* put cursor on an existing line */
X if (skip_redraw) /* skip redraw (for ":" in wait_return()) */
X skip_redraw = FALSE;
X else if (stuff_empty()) /* only when no command pending */
X {
X cursupdate(); /* Figure out where the cursor is based
X on curwin->w_cursor. */
X if (VIsual.lnum)
X updateScreen(INVERTED); /* update inverted part */
X if (must_redraw)
X updateScreen(must_redraw);
X if (keep_msg)
X msg(keep_msg); /* display message after redraw */
X
X showruler(FALSE);
X
X setcursor();
X cursor_on();
X }
X
X normal(); /* get and execute a command */
X }
X /*NOTREACHED*/
X}
X
X void
Xgetout(r)
X int r;
X{
X windgoto((int)Rows - 1, 0);
X outchar('\r');
X outchar('\n');
X mch_windexit(r);
X}
END_OF_FILE
if test 14502 -ne `wc -c <'vim/src/main.c'`; then
echo shar: \"'vim/src/main.c'\" unpacked with wrong size!
fi
# end of 'vim/src/main.c'
fi
if test -f 'vim/src/makefile.unix' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/makefile.unix'\"
else
echo shar: Extracting \"'vim/src/makefile.unix'\" \(13424 characters\)
sed "s/^X//" >'vim/src/makefile.unix' <<'END_OF_FILE'
X#
X# Makefile for Vim on Unix
X#
X
X# Note: You MUST uncomment three hardware dependend lines!
X
X# There are three types of defines:
X#
X# 1. configuration dependend
X# Used for "make install". Adjust the path names and protections
X# to your desire. Also defines the root for the X11 files (not required).
X#
X# 2. various choices
X# Can be changed to match your compiler or your preferences (not
X# required).
X#
X# 3. hardware dependend
X# If you machine is in the list, remove one '#' in front of the defines
X# following it. Otherwise: Find a machine that is similar and change the
X# defines to make it work. Normally you can just try and see what error
X# messages you get. (REQUIRED).
X
X# The following systems have entries below. They have been tested and should
X# work without modification. But later code changes may cause small problems.
X# There are entries for other systems, but these have not been tested recently.
X
X#system: tested configurations: tested by:
X
X#Sun 4.1.x cc gcc X11 no X11 (jw) (mool)
X#FreeBSD cc gcc X11 no X11 (mool)
X#linux 1.0 cc X11
X#Linux 1.0.9 gcc no X11 (jw)
X#ULTRIX 4.2A on MIPS cc gcc no X11 (mool)
X#HPUX cc gcc X11 no X11 (jw) (mool)
X#irix 4.0.5H cc X11
X#IRIX 4.0 SGI cc X11 (jw)
X#SINIX-L 5.41 cc no X11
X#MOT188 cc no X11
X#Sequent/ptx 1.3 cc no X11 (jw)
X#osf1 cc no X11 (jw)
X#Unisys 6035 cc no X11
X#SCO 3.2 cc gcc no X11 jos@oce.nl
X#Solaris cc X11
X#Solaris/Sun OS 5.3 cc no X11 (jw)
X#AIX (rs6000) cc no X11 (jw)
X#RISCos on MIPS cc X11 no X11 (jw)
X
X# configurations marked by (jw) have been tested by Juergen Weigert:
X# jnweiger@uni-erlangen.de
X
X#
X# PART 1: configuration dependend
X#
X
X### root directory for X11 files (unless overruled in hardware-dependend part)
X### Unfortunately there is no standard for these, everybody puts them
X### somewhere else
XX11LIBDIR = /usr/openwin/lib
XX11INCDIR = /usr/openwin/include
X### for some hpux systems:
X#X11LIBDIR = /usr/lib/X11R5
X#X11INCDIR = /usr/include/X11R5
X
X### Prefix for location of files
XPREFIX = /usr/local
X
X### Location of binary
XBINLOC = $(PREFIX)/bin
X
X### Name of target
XTARGET = vim
X
X### Location of man page
XMANLOC = $(PREFIX)/man/man1
X
X### Location of help file
XHELPLOC = $(PREFIX)/lib
X
X### Program to run on installed binary
XSTRIP = strip
X
X### Permissions for vim binary
XBINMOD = 755
X
X### Permissions for man page
XMANMOD = 644
X
X### Permissions for help file
XHELPMOD = 644
X
XMANFILE = ../doc/vim.1
X
XHELPFILE = ../doc/vim.hlp
X
X#
X# PART 2: various choices
X#
X
X### -DDIGRAPHS digraph support
X### -DNO_FREE_NULL do not call free() with a null pointer
X### -DCOMPATIBLE start in vi-compatible mode
X### -DNOBACKUP default is no backup file
X### -DDEBUG output a lot of debugging garbage
X### -DSTRNCASECMP use strncasecmp() instead of internal function
X### -DUSE_LOCALE use setlocale() to change ctype() and others
X### -DTERMCAP full termcap/terminfo file support
X### -DTERMINFO use terminfo instead of termcap entries for builtin terms
X### -DNO_BUILTIN_TCAPS do not include builtin termcap entries
X### (use only with -DTERMCAP)
X### -DSOME_BUILTIN_TCAPS include most useful builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
X### -DALL_BUILTIN_TCAPS include all builtin termcap entries
X### (use only without -DNO_BUILTIN_TCAPS)
X### -DMAXNAMLEN 31 maximum length of a file name (if not defined in sys/dir.h)
X### -Dconst= for compilers that don't have type const
X### -DVIMRC_FILE=name name of the .vimrc file in current dir
X### -DEXRC_FILE=name name of the .exrc file in current dir
X### -DSYSVIMRC_FILE=name name of the global .vimrc file
X### -DSYSEXRC_FILE=name name of the global .exrc file
X### -DDEFVIMRC_FILE=name name of the system-wide .vimrc file
X### -DVIM_HLP=name name of the help file
X### -DUSE_SYSTEM use system() instead of fork/exec for starting a shell
X### -DVIM_ISSPACE use when isspace() can't handle meta chars
X### -DNOLIMITS limits.h does not exist
X### -DNOSTDLIB stdlib.h does not exist
X### -DUSE_X11 include code for xterm title saving
X### -DWEBB_COMPLETE include Webb's code for command line completion
X### -DWEBB_KEYWORD_COMPL include Webb's code for keyword completion
X### -DNOTITLE 'title' option off by default
XDEFS = -DDIGRAPHS -DTERMCAP -DSOME_BUILTIN_TCAPS -DNO_FREE_NULL -DVIM_ISSPACE \
X -DWEBB_COMPLETE -DWEBB_KEYWORD_COMPL \
X -DVIM_HLP=\"$(HELPLOC)/vim.hlp\"
X
X#
X# PART 3: hardware dependend
X#
X
X### CC entry: name and arguments for the compiler (also for linking)
X### MACHINE entry: defines used for compiling (not for linking)
X### LIBS: defines used for linking
X
X# generic for Sun, NeXT, POSIX and SYSV R4 (?) (TESTED for Sun 4.1.x)
X# standard cc with optimizer
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE -DUSE_X11
X#CC=cc -O -I$(X11INCDIR)
X#LIBS = -ltermlib -L$(X11LIBDIR) -lX11
X
X# generic for Sun, FreeBSD, NetBSD, NeXT, POSIX and SYSV R4 (?) without x11 code
X# (TESTED for Sun 4.1.x and FreeBSD)
X# standard cc with optimizer
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE
X#CC=cc -O
X#LIBS = -ltermlib
X
X# FreeBSD and NetBSD with Xfree (TESTED for FreeBSD)
X# standard cc with optimizer
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE -DUSE_X11
X#CC=cc -O -L/usr/X386/lib -I/usr/X386/include
X#LIBS = -ltermlib -lX11
X
X# FreeBSD and NetBSD with Xfree (TESTED for FreeBSD)
X# gcc with optimizer
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE -DUSE_X11
X#CC=gcc -O -Wall -traditional -Dconst= -I/usr/X386/include
X#LIBS = -ltermlib -L/usr/X386/lib -lX11
X
X# like generic, but with termcap, for Linux, NeXT and others (NOT TESTED YET)
X# standard cc with optimizer
X#
X#MACHINE = -DBSD_UNIX
X#CC=cc -O
X#LIBS = -ltermcap
X
X# linux 1.0 with X11 (TESTED)
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE -DUSE_X11
X#CC=cc -O -I/usr/X11/include
X#LIBS = -ltermcap -L/usr/X11/lib -lX11
X
X# like generic, but with debugging (NOT TESTED YET)
X#
X#MACHINE = -DBSD_UNIX -g
X#CC=cc
X#LIBS = -ltermlib
X
X# like generic, but with gcc and X11 (TESTED on Sun 4.1.x)
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE -DUSE_X11
X#CC=gcc -O -Wall -traditional -Dconst= -L$(X11LIBDIR) -I$(X11INCDIR)
X#LIBS = -ltermlib -lX11
X
X# like generic, but with gcc, without X11 (TESTED on ULTRIX 4.2A on MIPS)
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE
X#CC=gcc -O -Wall -traditional -Dconst=
X#LIBS = -ltermlib
X
X# like generic, but with gcc 2.5.8 (TESTED on Sun 4.1.3_U1)
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE
X#CC=gcc -O1000
X#LIBS = -ltermlib
X
X# standard cc with optimizer for ULTRIX 4.2A on MIPS (ultrix defined) (TESTED)
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE
X#CC=cc -O -Olimit 1500
X#LIBS = -ltermlib
X
X# GCC (2.2.2d) on Linux (1.0.9) (TESTED)
X#
X#MACHINE = -DBSD_UNIX
X#CC=gcc -O6 -Wall
X#LIBS = -ltermcap
X
X# Apollo DOMAIN (with SYSTYPE = bsd4.3) (NOT TESTED YET)
X#
X#MACHINE = -DBSD_UNIX -DDOMAIN
X#CC=cc -O -A systype,bsd4.3
X#LIBS = -ltermlib
X
X# HPUX with X11 (TESTED) (hpux is defined)
X#
X#MACHINE = -DBSD_UNIX -DTERMINFO -DUSE_X11
X#CC=cc -O -I$(X11INCDIR)
X#LIBS = -ltermcap -L$(X11LIBDIR) -lX11
X
X# HPUX (TESTED) (hpux is defined)
X#
X#MACHINE = -DBSD_UNIX -DTERMINFO
X#CC=cc -O
X#LIBS = -ltermcap
X
X# HPUX with gcc (TESTED) (hpux is defined)
X#
X#MACHINE = -DBSD_UNIX -DTERMINFO
X#CC=gcc -O
X#LIBS = -ltermcap
X
X# hpux 9.01 (with termlib instead of termcap) (TESTED)
X# irix 4.0.5H (TESTED)
X#
X#MACHINE = -DBSD_UNIX -DUSE_LOCALE -DUSE_X11
X#CC=cc -O -I$(X11INCDIR)
X#LIBS = -ltermlib -L$(X11LIBDIR) -lX11
X
X# IRIX 4.0 (Silicon Graphics Indigo, __sgi will be defined) (TESTED)
X#
X#MACHINE = -DBSD_UNIX -DUSE_X11
X#CC=cc -O -Olimit 1500
X#LIBS = -ltermlib -lX11 -lmalloc -lc_s
X
X# Convex (NOT TESTED YET)
X#
X#MACHINE = -DBSD_UNIX -DCONVEX
X#CC=cc -O
X#LIBS = -ltermcap
X
X# generic SYSV_UNIX for Dynix/PTX and SYSV R3 (and R4?) (TESTED on SINIX-L 5.41)
X# (TESTED on MOT188) (TESTED on Sequent/ptx 1.3) (TESTED on osf1)
X# First try the line with locale. If this gives error messages try the other one.
X#
X#MACHINE = -DSYSV_UNIX -DUSE_LOCALE
X#MACHINE = -DSYSV_UNIX
X#CC=cc -O
X#LIBS = -ltermlib
X
X# generic SYSV_UNIX with LOCALE (TESTED on Unisys 6035)
X#
X#MACHINE = -DSYSV_UNIX -DUSE_LOCALE -DUNISYS
X#CC=cc -O
X#LIBS = -ltermlib
X
X# SCO Xenix (NOT TESTED YET)
X#
X#MACHINE = -DSYSV_UNIX -DSCO
X#CC=cc -O
X#LIBS = -ltermlib
X
X# GCC on SCO 3.2 (TESTED by jos@oce.nl)
X# cc works too.
X#
X#MACHINE = -DSYSV_UNIX -UM_XENIX -DSCO
X#CC=gcc -O -Wall
X#LIBS = -ltinfo
X
X# GCC on another SCO Unix (NOT TESTED YET)
X#
X#MACHINE = -DSYSV_UNIX -UM_XENIX -DSCO -g
X#CC=gcc -O6 -fpcc-struct-return -fwritable-strings
X#LIBS = -ltermlib -lmalloc
X
X# Dynix with gcc (NOT TESTED YET)
X#
X#MACHINE = -DSYSV_UNIX
X#CC=gcc -O -Wall -traditional
X#LIBS = -ltermlib
X
X# SOLARIS with X11 anc cc (TESTED)
X#
X#MACHINE = -DSYSV_UNIX -DSOLARIS -DTERMINFO -DUSE_X11
X#CC=cc -O -Xa -v -R$(X11LIBDIR) -L$(X11LIBDIR) -I$(X11INCDIR)
X#LIBS = -ltermlib -lX11
X
X# SOLARIS with X11 and gcc (TESTED with SOLARIS 2.3 and gcc 2.5.8)
X#
X#MACHINE = -DSYSV_UNIX -DSOLARIS -DTERMINFO -DUSE_X11
X#CC=gcc -O -R$(X11LIBDIR) -L$(X11LIBDIR) -I$(X11INCDIR)
X#LIBS = -ltermlib -lX11
X
X# SOLARIS (also works for Esix 4.0.3, SYSV R4?) (TESTED on Sun OS 5.3)
X#
X#MACHINE = -DSYSV_UNIX -DSOLARIS -DTERMINFO
X#CC=cc -O -Xa -v
X#LIBS = -ltermlib
X
X# UNICOS (NOT TESTED YET)
X#
X#MACHINE = -DSYSV_UNIX -DUNICOS
X#CC=cc -O
X#LIBS = -ltermlib
X
X# AIX (rs6000) (TESTED)
X#
X#MACHINE = -DSYSV_UNIX -DAIX
X#CC=cc -O
X#LIBS=-lcur
X
X# UTS2 for Amdahl UTS 2.1.x (disable termcap below) (NOT TESTED YET)
X#
X#MACHINE = -DSYSV_UNIX -DUTS2
X#CC=cc -O
X#LIBS = -ltermlib -lsocket
X
X# UTS4 for Amdahl UTS 4.x (NOT TESTED YET)
X#
X#MACHINE = -DSYSV_UNIX -DUTS4 -Xa
X#CC=cc -O
X#LIBS = -ltermlib
X
X# USL for Unix Systems Laboratories (SYSV 4.2) (NOT TESTED YET)
X#
X#MACHINE = -DSYSV_UNIX -DUSL
X#CC=cc -O
X#LIBS = -ltermlib
X
X# RISCos on MIPS without X11 (TESTED)
X#
X#MACHINE = -DSYSV_UNIX -DMIPS
X#CC=cc -O
X#LIBS = -ltermlib
X
X# RISCos on MIPS with X11 (TESTED)
X#
X#MACHINE=-DSYSV_UNIX -DUSE_LOCALE -DUSE_X11
X#CC=cc -O -I$(X11INCDIR)
X#LIBS=-ltermlib -L$(X11LIBDIR) -lX11 -lsun
X
X################################################
X## no changes required below this line ##
X################################################
X
XCFLAGS = -c $(MACHINE) $(DEFS)
X
XINCL = vim.h globals.h param.h keymap.h macros.h ascii.h term.h unix.h structs.h proto.h
X
XOBJ = alloc.o unix.o buffer.o charset.o cmdcmds.o cmdline.o \
X csearch.o digraph.o edit.o fileio.o getchar.o help.o \
X linefunc.o main.o mark.o memfile.o memline.o message.o misccmds.o \
X normal.o ops.o param.o quickfix.o regexp.o \
X regsub.o screen.o search.o \
X tag.o term.o undo.o window.o $(TERMLIB)
X
X$(TARGET): $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(CC) -o $(TARGET) $(OBJ) version.o $(LIBS)
X
Xdebug: $(OBJ) version.c
X $(CC) $(CFLAGS) version.c
X $(CC) -o $(TARGET) -g $(OBJ) version.o $(LIBS)
X
Xctags:
X ctags *.c *.h
X
Xinstall: $(TARGET)
X -mkdir $(BINLOC)
X cp $(TARGET) $(BINLOC)
X chmod $(BINMOD) $(BINLOC)/$(TARGET)
X $(STRIP) $(BINLOC)/$(TARGET)
X -mkdir $(MANLOC)
X cp $(MANFILE) $(MANLOC)
X chmod $(MANMOD) $(MANLOC)/vim.1
X -mkdir $(HELPLOC)
X cp $(HELPFILE) $(HELPLOC)
X chmod $(HELPMOD) $(HELPLOC)/vim.hlp
X
Xclean:
X -rm -f $(OBJ) mkcmdtab.o version.o core $(TARGET) mkcmdtab cmdtab.h
X -rm -f *.bak
X
X#use this in case the files have been transported via an MSDOS system
X
XFILES = *.c *.h makefile makefile.* cmdtab.tab proto/*.pro tags
X
Xdos2unix:
X -mv arp_prot.h arp_proto.h
X -mv ptx_stdl.h ptx_stdlib.h
X -mv sun_stdl.h sun_stdlib.h
X -mv makefile.dic makefile.dice
X -mv makefile.uni makefile.unix
X -mv makefile.man makefile.manx
X -mv makefile.6sa makefile.6sas
X -mv makefile.5sa makefile.5sas
X for i in $(FILES); do tr -d '\r\032' < $$i > ~tmp~; mv ~tmp~ $$i; echo $$i; done
X
X###########################################################################
X
Xalloc.o: alloc.c $(INCL)
X $(CC) $(CFLAGS) alloc.c
X
Xunix.o: unix.c $(INCL)
X $(CC) $(CFLAGS) unix.c
X
Xbuffer.o: buffer.c $(INCL)
X $(CC) $(CFLAGS) buffer.c
X
Xcharset.o: charset.c $(INCL)
X $(CC) $(CFLAGS) charset.c
X
Xcmdcmds.o: cmdcmds.c $(INCL)
X $(CC) $(CFLAGS) cmdcmds.c
X
Xcmdline.o: cmdline.c $(INCL) cmdtab.h ops.h
X $(CC) $(CFLAGS) cmdline.c
X
Xcsearch.o: csearch.c $(INCL)
X $(CC) $(CFLAGS) csearch.c
X
Xdigraph.o: digraph.c $(INCL)
X $(CC) $(CFLAGS) digraph.c
X
Xedit.o: edit.c $(INCL) ops.h
X $(CC) $(CFLAGS) edit.c
X
Xfileio.o: fileio.c $(INCL)
X $(CC) $(CFLAGS) fileio.c
X
Xgetchar.o: getchar.c $(INCL)
X $(CC) $(CFLAGS) getchar.c
X
Xhelp.o: help.c $(INCL)
X $(CC) $(CFLAGS) help.c
X
Xlinefunc.o: linefunc.c $(INCL)
X $(CC) $(CFLAGS) linefunc.c
X
Xmain.o: main.c $(INCL)
X $(CC) $(CFLAGS) main.c
X
Xmark.o: mark.c $(INCL)
X $(CC) $(CFLAGS) mark.c
X
Xmemfile.o: memfile.c $(INCL)
X $(CC) $(CFLAGS) memfile.c
X
Xmemline.o: memline.c $(INCL)
X $(CC) $(CFLAGS) memline.c
X
Xmessage.o: message.c $(INCL)
X $(CC) $(CFLAGS) message.c
X
Xmisccmds.o: misccmds.c $(INCL)
X $(CC) $(CFLAGS) misccmds.c
X
Xnormal.o: normal.c $(INCL) ops.h
X $(CC) $(CFLAGS) normal.c
X
Xops.o: ops.c $(INCL) ops.h
X $(CC) $(CFLAGS) ops.c
X
Xparam.o: param.c $(INCL)
X $(CC) $(CFLAGS) param.c
X
Xquickfix.o: quickfix.c $(INCL)
X $(CC) $(CFLAGS) quickfix.c
X
Xregexp.o: regexp.c $(INCL)
X $(CC) $(CFLAGS) regexp.c
X
Xregsub.o: regsub.c $(INCL)
X $(CC) $(CFLAGS) regsub.c
X
Xscreen.o: screen.c $(INCL)
X $(CC) $(CFLAGS) screen.c
X
Xsearch.o: search.c $(INCL) ops.h
X $(CC) $(CFLAGS) search.c
X
Xtag.o: tag.c $(INCL)
X $(CC) $(CFLAGS) tag.c
X
Xterm.o: term.c $(INCL)
X $(CC) $(CFLAGS) term.c
X
Xundo.o: undo.c $(INCL)
X $(CC) $(CFLAGS) undo.c
X
Xwindow.o: window.c $(INCL)
X $(CC) $(CFLAGS) window.c
X
Xcmdtab.h: cmdtab.tab mkcmdtab
X ./mkcmdtab cmdtab.tab cmdtab.h
X
Xmkcmdtab: mkcmdtab.o
X $(CC) -o mkcmdtab mkcmdtab.o
X
Xmkcmdtab.o: mkcmdtab.c
X $(CC) $(CFLAGS) mkcmdtab.c
END_OF_FILE
if test 13424 -ne `wc -c <'vim/src/makefile.unix'`; then
echo shar: \"'vim/src/makefile.unix'\" unpacked with wrong size!
fi
# end of 'vim/src/makefile.unix'
fi
if test -f 'vim/src/regsub.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/regsub.c'\"
else
echo shar: Extracting \"'vim/src/regsub.c'\" \(7512 characters\)
sed "s/^X//" >'vim/src/regsub.c' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * This is NOT the original regular expression code as written by
X * Henry Spencer. This code has been modified specifically for use
X * with the VIM editor, and should not be used apart from compiling
X * VIM. If you want a good regular expression library, get the
X * original code. The copyright notice that follows is from the
X * original.
X *
X * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
X *
X * regsub
X *
X * Copyright (c) 1986 by University of Toronto.
X * Written by Henry Spencer. Not derived from licensed software.
X *
X * Permission is granted to anyone to use this software for any
X * purpose on any computer system, and to redistribute it freely,
X * subject to the following restrictions:
X *
X * 1. The author is not responsible for the consequences of use of
X * this software, no matter how awful, even if they arise
X * from defects in it.
X *
X * 2. The origin of this software must not be misrepresented, either
X * by explicit claim or by omission.
X *
X * 3. Altered versions must be plainly marked as such, and must not
X * be misrepresented as being the original software.
X *
X * $Log: regsub.c,v $
X * Revision 1.2 88/04/28 08:11:25 tony
X * First modification of the regexp library. Added an external variable
X * 'reg_ic' which can be set to indicate that case should be ignored.
X * Added a new parameter to regexec() to indicate that the given string
X * comes from the beginning of a line and is thus eligible to match
X * 'beginning-of-line'.
X *
X * Revisions by Olaf 'Rhialto' Seibert, rhialto@cs.kun.nl:
X * Changes for vi: (the semantics of several things were rather different)
X * - Added lexical analyzer, because in vi magicness of characters
X * is rather difficult, and may change over time.
X * - Added support for \< \> \1-\9 and ~
X * - Left some magic stuff in, but only backslashed: \| \+
X * - * and \+ still work after \) even though they shouldn't.
X */
X
X#include "vim.h"
X#include "globals.h"
X#include "proto.h"
X
X#ifdef MSDOS
X# define __ARGS(a) a
X#endif
X
X#define CASECONVERT
X
X#include <stdio.h>
X#include "regexp.h"
X#include "regmagic.h"
X
X#ifdef LATTICE
X# include <sys/types.h> /* for size_t */
X#endif
X
X#ifndef CHARBITS
X#define UCHARAT(p) ((int)*(char_u *)(p))
X#else
X#define UCHARAT(p) ((int)*(p)&CHARBITS)
X#endif
X
Xextern char_u *reg_prev_sub;
X
X#ifdef CASECONVERT
X /*
X * We should define ftpr as a pointer to a function returning a pointer to
X * a function returning a pointer to a function ...
X * This is impossible, so we declare a pointer to a function returning a
X * pointer to a function returning void. This should work for all compilers.
X */
Xtypedef void (*(*fptr) __ARGS((char_u *, int)))();
Xstatic fptr strnfcpy __ARGS((fptr, char_u *, char_u *, int));
X
Xstatic fptr do_Copy __ARGS((char_u *, int));
Xstatic fptr do_upper __ARGS((char_u *, int));
Xstatic fptr do_Upper __ARGS((char_u *, int));
Xstatic fptr do_lower __ARGS((char_u *, int));
Xstatic fptr do_Lower __ARGS((char_u *, int));
X
X static fptr
Xdo_Copy(d, c)
X char_u *d;
X int c;
X{
X *d = c;
X
X return (fptr)do_Copy;
X}
X
X static fptr
Xdo_upper(d, c)
X char_u *d;
X int c;
X{
X *d = TO_UPPER(c);
X
X return (fptr)do_Copy;
X}
X
X static fptr
Xdo_Upper(d, c)
X char_u *d;
X int c;
X{
X *d = TO_UPPER(c);
X
X return (fptr)do_Upper;
X}
X
X static fptr
Xdo_lower(d, c)
X char_u *d;
X int c;
X{
X *d = TO_LOWER(c);
X
X return (fptr)do_Copy;
X}
X
X static fptr
Xdo_Lower(d, c)
X char_u *d;
X int c;
X{
X *d = TO_LOWER(c);
X
X return (fptr)do_Lower;
X}
X
X static fptr
Xstrnfcpy(f, d, s, n)
X fptr f;
X char_u *d;
X char_u *s;
X int n;
X{
X while (n-- > 0) {
X f = (fptr)(f(d, *s)); /* Turbo C complains without the typecast */
X if (!*s++)
X break;
X d++;
X }
X
X return f;
X}
X#endif
X
X/*
X * regtilde: replace tildes in the pattern by the old pattern
X *
X * Short explanation of the tilde: it stands for the previous replacement
X * pattern. If that previous pattern also contains a ~ we should go back
X * a step further... but we insert the previous pattern into the current one
X * and remember that.
X * This still does not handle the case where "magic" changes. TODO?
X *
X * New solution: The tilde's are parsed once before the first call to regsub().
X * In the old solution (tilde handled in regsub()) is was possible to get an
X * endless loop.
X */
X char_u *
Xregtilde(source, magic)
X char_u *source;
X int magic;
X{
X char_u *newsub = NULL;
X char_u *tmpsub;
X char_u *p;
X int len;
X int prevlen;
X
X for (p = source; *p; ++p)
X {
X if ((*p == '~' && magic) || (*p == '\\' && *(p + 1) == '~' && !magic))
X {
X if (reg_prev_sub)
X {
X /* length = len(current) - 1 + len(previous) + 1 */
X prevlen = STRLEN(reg_prev_sub);
X tmpsub = alloc((unsigned)(STRLEN(source) + prevlen));
X if (tmpsub)
X {
X /* copy prefix */
X len = (int)(p - source); /* not including ~ */
X STRNCPY(tmpsub, source, (size_t)len);
X /* interpretate tilde */
X STRCPY(tmpsub + len, reg_prev_sub);
X /* copy postfix */
X if (!magic)
X ++p; /* back off \ */
X STRCAT(tmpsub + len, p + 1);
X
X free(newsub);
X newsub = tmpsub;
X p = newsub + len + prevlen;
X }
X }
X else if (magic)
X STRCPY(p, p + 1); /* remove '~' */
X else
X STRCPY(p, p + 2); /* remove '\~' */
X }
X else if (*p == '\\' && p[1]) /* skip escaped characters */
X ++p;
X }
X
X free(reg_prev_sub);
X if (newsub)
X {
X source = newsub;
X reg_prev_sub = newsub;
X }
X else
X reg_prev_sub = strsave(source);
X return source;
X}
X
X/*
X - regsub - perform substitutions after a regexp match
X *
X * Returns the size of the replacement, including terminating \0.
X */
X int
Xregsub(prog, source, dest, copy, magic)
X regexp *prog;
X char_u *source;
X char_u *dest;
X int copy;
X int magic;
X{
X register char_u *src;
X register char_u *dst;
X register int c;
X register int no;
X register int len;
X#ifdef CASECONVERT
X fptr func = (fptr)do_Copy;
X#endif
X
X if (prog == NULL || source == NULL || dest == NULL)
X {
X emsg(e_null);
X return 0;
X }
X if (UCHARAT(prog->program) != MAGIC)
X {
X emsg(e_re_corr);
X return 0;
X }
X src = source;
X dst = dest;
X
X while ((c = *src++) != '\0')
X {
X no = -1;
X if (c == '&' && magic)
X no = 0;
X else if (c == '\\' && *src != NUL)
X {
X if (*src == '&' && !magic)
X {
X ++src;
X no = 0;
X }
X else if ('0' <= *src && *src <= '9')
X {
X no = *src++ - '0';
X }
X#ifdef CASECONVERT
X else if (strchr("uUlLeE", *src))
X {
X switch (*src++)
X {
X case 'u': func = (fptr)do_upper;
X continue;
X case 'U': func = (fptr)do_Upper;
X continue;
X case 'l': func = (fptr)do_lower;
X continue;
X case 'L': func = (fptr)do_Lower;
X continue;
X case 'e':
X case 'E': func = (fptr)do_Copy;
X continue;
X }
X }
X#endif
X }
X if (no < 0) /* Ordinary character. */
X {
X if (c == '\\' && *src != NUL)
X c = *src++;
X if (copy)
X {
X#ifdef CASECONVERT
X func = (fptr)(func(dst, c));
X /* Turbo C complains without the typecast */
X#else
X *dst = c;
X#endif
X }
X dst++;
X }
X else if (prog->startp[no] != NULL && prog->endp[no] != NULL)
X {
X len = (int)(prog->endp[no] - prog->startp[no]);
X if (copy)
X {
X#ifdef CASECONVERT
X func = strnfcpy(func, dst, prog->startp[no], len);
X#else
X (void) STRNCPY(dst, prog->startp[no], len);
X#endif
X }
X dst += len;
X if (copy && len != 0 && *(dst - 1) == '\0') { /* strncpy hit NUL. */
X emsg(e_re_damg);
X goto exit;
X }
X }
X }
X if (copy)
X *dst = '\0';
X
Xexit:
X return (int)((dst - dest) + 1);
X}
END_OF_FILE
if test 7512 -ne `wc -c <'vim/src/regsub.c'`; then
echo shar: \"'vim/src/regsub.c'\" unpacked with wrong size!
fi
# end of 'vim/src/regsub.c'
fi
if test -f 'vim/src/structs.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'vim/src/structs.h'\"
else
echo shar: Extracting \"'vim/src/structs.h'\" \(14475 characters\)
sed "s/^X//" >'vim/src/structs.h' <<'END_OF_FILE'
X/* vi:ts=4:sw=4
X *
X * VIM - Vi IMproved by Bram Moolenaar
X *
X * Read the file "credits.txt" for a list of people who contributed.
X * Read the file "uganda.txt" for copying and usage conditions.
X */
X
X/*
X * This file contains various definitions of structures that are used by Vim
X */
X
X/*
X * file position
X */
X
Xtypedef struct fpos FPOS;
X/*
X * there is something wrong in the SAS compiler that makes typedefs not
X * valid in include files
X */
X#ifdef SASC
Xtypedef long linenr_t;
Xtypedef unsigned colnr_t;
Xtypedef unsigned short short_u;
X#endif
X
Xstruct fpos
X{
X linenr_t lnum; /* line number */
X colnr_t col; /* column number */
X};
X
X/*
X * marks: positions in a file
X * (a normal mark is a lnum/col pair, the same as a file position)
X */
X
X#define NMARKS 26 /* max. # of named marks */
X#define JUMPLISTSIZE 30 /* max. # of marks in jump list */
X#define TAGSTACKSIZE 20 /* max. # of tags in tag stack */
X
Xstruct filemark
X{
X FPOS mark; /* cursor position */
X int fnum; /* file number */
X};
X
X/*
X * the taggy struct is used to store the information about a :tag command:
X * the tag name and the cursor position BEFORE the :tag command
X */
Xstruct taggy
X{
X char_u *tagname; /* tag name */
X struct filemark fmark; /* cursor position */
X};
X
X/*
X * line number list
X */
X
X/*
X * Each window can have a different line number associated with a buffer.
X * The window-pointer/line-number pairs are kept in the line number list.
X * The list of line numbers is kept in most-recently-used order.
X */
X
Xtypedef struct window WIN;
Xtypedef struct winlnum WINLNUM;
X
Xstruct winlnum
X{
X WINLNUM *wl_next; /* next entry or NULL for last entry */
X WINLNUM *wl_prev; /* previous entry or NULL for first entry */
X WIN *wl_win; /* pointer to window that did set wl_lnum */
X linenr_t wl_lnum; /* last cursor line in the file */
X};
X
X/*
X * stuctures used for undo
X */
X
Xstruct u_entry
X{
X struct u_entry *ue_next; /* pointer to next entry in list */
X linenr_t ue_top; /* number of line above undo block */
X linenr_t ue_bot; /* number of line below undo block */
X linenr_t ue_lcount; /* linecount when u_save called */
X char_u **ue_array; /* array of lines in undo block */
X long ue_size; /* number of lines in ue_array */
X};
X
Xstruct u_header
X{
X struct u_header *uh_next; /* pointer to next header in list */
X struct u_header *uh_prev; /* pointer to previous header in list */
X struct u_entry *uh_entry; /* pointer to first entry */
X FPOS uh_cursor; /* cursor position before saving */
X int uh_changed;/* b_changed flag before undo/after redo */
X FPOS uh_namedm[NMARKS]; /* marks before undo/after redo */
X};
X
X/*
X * stuctures used in undo.c
X */
X#ifdef UNIX
X# define ALIGN_LONG /* longword alignment and use filler byte */
X# define ALIGN_SIZE (sizeof(long))
X#else
X# define ALIGN_SIZE (sizeof(short))
X#endif
X
X#define ALIGN_MASK (ALIGN_SIZE - 1)
X
Xtypedef struct m_info info_t;
X
X/*
X * stucture used to link chunks in one of the free chunk lists.
X */
Xstruct m_info
X{
X#ifdef ALIGN_LONG
X long_u m_size; /* size of the chunk (including m_info) */
X#else
X short_u m_size; /* size of the chunk (including m_info) */
X#endif
X info_t *m_next; /* pointer to next free chunk in the list */
X};
X
X/*
X * structure used to link blocks in the list of allocated blocks.
X */
Xstruct m_block
X{
X struct m_block *mb_next; /* pointer to next allocated block */
X info_t mb_info; /* head of free chuck list for this block */
X};
X
X/*
X * things used in memfile.c
X */
X
Xtypedef struct block_hdr BHDR;
Xtypedef struct memfile MEMFILE;
Xtypedef long blocknr_t;
X
X/*
X * for each (previously) used block in the memfile there is one block header.
X *
X * The block may be linked in the used list OR in the free list.
X * The used blocks are also kept in hash lists.
X *
X * The used list is a doubly linked list, most recently used block first.
X * The blocks in the used list have a block of memory allocated.
X * mf_used_count is the number of pages in the used list.
X * The hash lists are used to quickly find a block in the used list.
X * The free list is a single linked list, not sorted.
X * The blocks in the free list have no block of memory allocated and
X * the contents of the block in the file (if any) is irrelevant.
X */
X
Xstruct block_hdr
X{
X BHDR *bh_next; /* next block_hdr in free or used list */
X BHDR *bh_prev; /* previous block_hdr in used list */
X BHDR *bh_hash_next; /* next block_hdr in hash list */
X BHDR *bh_hash_prev; /* previous block_hdr in hash list */
X blocknr_t bh_bnum; /* block number */
X char_u *bh_data; /* pointer to memory (for used block) */
X int bh_page_count; /* number of pages in this block */
X
X#define BH_DIRTY 1
X#define BH_LOCKED 2
X char bh_flags; /* BH_DIRTY or BH_LOCKED */
X};
X
X/*
X * when a block with a negative number is flushed to the file, it gets
X * a positive number. Because the reference to the block is still the negative
X * number, we remember the translation to the new positive number in the
X * double linked trans lists. The structure is the same as the hash lists.
X */
Xtypedef struct nr_trans NR_TRANS;
X
Xstruct nr_trans
X{
X NR_TRANS *nt_next; /* next nr_trans in hash list */
X NR_TRANS *nt_prev; /* previous nr_trans in hash list */
X blocknr_t nt_old_bnum; /* old, negative, number */
X blocknr_t nt_new_bnum; /* new, positive, number */
X};
X
X/*
X * Simplistic hashing scheme to quickly locate the blocks in the used list.
X * 64 blocks are found directly (64 * 4K = 256K, most files are smaller).
X */
X#define MEMHASHSIZE 64
X#define MEMHASH(nr) ((nr) & (MEMHASHSIZE - 1))
X
Xstruct memfile
X{
X char_u *mf_fname; /* name of the file */
X char_u *mf_xfname; /* idem, full path */
X int mf_fd; /* file descriptor */
X BHDR *mf_free_first; /* first block_hdr in free list */
X BHDR *mf_used_first; /* mru block_hdr in used list */
X BHDR *mf_used_last; /* lru block_hdr in used list */
X unsigned mf_used_count; /* number of pages in used list */
X unsigned mf_used_count_max; /* maximum number of pages in memory */
X BHDR *mf_hash[MEMHASHSIZE]; /* array of hash lists */
X NR_TRANS *mf_trans[MEMHASHSIZE]; /* array of trans lists */
X blocknr_t mf_blocknr_max; /* highest positive block number + 1*/
X blocknr_t mf_blocknr_min; /* lowest negative block number - 1 */
X blocknr_t mf_neg_count; /* number of negative blocks numbers */
X blocknr_t mf_infile_count; /* number of pages in the file */
X unsigned mf_page_size; /* number of bytes in a page */
X int mf_dirty; /* Set to TRUE if there are dirty blocks */
X};
X
X/*
X * things used in memline.c
X */
Xtypedef struct info_pointer IPTR; /* block/index pair */
X
X/*
X * When searching for a specific line, we remember what blocks in the tree
X * are the branches leading to that block. This is stored in ml_stack.
X * Each entry is a pointer to info in a block (may be data block or pointer block)
X */
Xstruct info_pointer
X{
X blocknr_t ip_bnum; /* block number */
X linenr_t ip_low; /* lowest lnum in this block */
X linenr_t ip_high; /* highest lnum in this block */
X int ip_index; /* index for block with current lnum */
X};
X
Xtypedef struct memline MEMLINE;
X
X/*
X * the memline structure holds all the information about a memline
X */
Xstruct memline
X{
X linenr_t ml_line_count; /* number of lines in the buffer */
X
X MEMFILE *ml_mfp; /* pointer to associated memfile */
X
X#define ML_EMPTY 1 /* empty buffer (one empty line */
X#define ML_LINE_DIRTY 2 /* cached line was changed and allocated */
X#define ML_LOCKED_DIRTY 4 /* ml_locked was changed */
X#define ML_LOCKED_POS 8 /* ml_locked needs positive block number */
X int ml_flags;
X
X IPTR *ml_stack; /* stack of pointer blocks (array of IPTRs) */
X int ml_stack_top; /* current top if ml_stack */
X int ml_stack_size; /* total number of entries in ml_stack */
X
X linenr_t ml_line_lnum; /* line number of cached line, 0 if not valid */
X char_u *ml_line_ptr; /* pointer to cached line */
X
X BHDR *ml_locked; /* block used by last ml_get */
X linenr_t ml_locked_low; /* first line in ml_locked */
X linenr_t ml_locked_high; /* last line in ml_locked */
X int ml_locked_lineadd; /* number of lines inserted in ml_locked */
X};
X
X/*
X * buffer: structure that holds information about one file
X *
X * Several windows can share a single Buffer
X * A buffer is unallocated if there is no memfile for it.
X * A buffer is new if the associated file has never been loaded yet.
X */
X
Xtypedef struct buffer BUF;
X
Xstruct buffer
X{
X MEMLINE b_ml; /* associated memline (also contains
X * line count) */
X
X BUF *b_next; /* links in list of buffers */
X BUF *b_prev;
X
X int b_changed; /* Set to 1 if something in the file has
X * been changed and not written out. */
X
X int b_notedited; /* Set to TRUE when file name is
X * changed after starting to edit,
X * reset when file is written out. */
X
X int b_nwindows; /* nr of windows open on this buffer */
X
X int b_neverloaded; /* file has never been loaded into
X * buffer, many variables still need
X * to be set */
X
X /*
X * b_filename has the full path of the file.
X * b_sfilename is the name as the user typed it.
X * b_xfilename is the same as b_sfilename, unless did_cd is set, then it
X * is the same as b_filename.
X */
X char_u *b_filename;
X char_u *b_sfilename;
X char_u *b_xfilename;
X
X int b_fnum; /* file number for this file. */
X WINLNUM *b_winlnum; /* list of last used lnum for
X * each window */
X
X long b_mtime; /* last change time of original file */
X
X /*
X * The following only used in mark.c.
X */
X FPOS b_namedm[NMARKS]; /* current marks */
X
X /*
X * start and end of an operator, also used for '[ and ']
X */
X FPOS b_startop;
X FPOS b_endop;
X
X /*
X * The following only used in undo.c.
X */
X struct u_header *b_u_oldhead; /* pointer to oldest header */
X struct u_header *b_u_newhead; /* pointer to newest header */
X struct u_header *b_u_curhead; /* pointer to current header */
X int b_u_numhead; /* current number of headers */
X int b_u_synced; /* entry lists are synced */
X
X /*
X * variables for "U" command in undo.c
X */
X char_u *b_u_line_ptr; /* saved line for "U" command */
X linenr_t b_u_line_lnum; /* line number of line in u_line */
X colnr_t b_u_line_colnr; /* optional column number */
X
X /*
X * The following only used in undo.c
X */
X struct m_block b_block_head; /* head of allocated memory block list */
X info_t *b_m_search; /* pointer to chunk before previously
X * allocated/freed chunk */
X struct m_block *b_mb_current; /* block where m_search points in */
X
X /*
X * Variables "local" to a buffer.
X * They are here because their value depends on the type of file
X * or contents of the file being edited.
X * The "save" options are for when the paste option is set.
X */
X int b_p_ai, b_p_si, b_p_ro;
X int b_p_bin, b_p_eol, b_p_et, b_p_ml, b_p_sn, b_p_tx;
X long b_p_sw, b_p_ts, b_p_tw, b_p_wm;
X int b_p_ai_save, b_p_si_save;
X long b_p_tw_save, b_p_wm_save;
X
X char b_did_warn; /* Set to 1 if user has been warned on
X * first change of a read-only file */
X
X#ifndef MSDOS
X int b_shortname; /* this file has an 8.3 filename */
X#endif
X};
X
X/*
X * Structure which contains all information that belongs to a window
X *
X * All row numbers are relative to the start of the window, except w_winpos.
X */
X
Xstruct window
X{
X BUF *w_buffer; /* buffer we are a window into */
X
X WIN *w_prev; /* link to previous window (above) */
X WIN *w_next; /* link to next window (below) */
X
X FPOS w_cursor; /* cursor's position in buffer */
X
X /*
X * These elements are related to the cursor's position in the window.
X * This is related to character positions in the window, not in the file.
X */
X int w_row, w_col; /* cursor's position in window */
X
X colnr_t w_virtcol; /* column number of the file's actual */
X /* line, as opposed to the column */
X /* number we're at on the screen. */
X /* This makes a difference on lines */
X /* which span more than one screen */
X /* line. */
X
X colnr_t w_curswant; /* The column we'd like to be at. */
X /* This is used to try to stay in */
X /* the same column through up/down */
X /* cursor motions. */
X
X int w_set_curswant; /* If set, then update w_curswant */
X /* the next time through cursupdate() */
X /* to the current virtual column */
X
X linenr_t w_topline; /* number of the line at the top of
X * the screen */
X linenr_t w_botline; /* number of the line below the bottom
X * of the screen */
X int w_empty_rows; /* number of ~ rows in window */
X
X int w_winpos; /* row of topline of window in screen */
X int w_height; /* number of rows in window, excluding
X status/command line */
X int w_status_height; /* number of status lines (0 or 1) */
X
X int w_redr_status; /* if TRUE status line must be redrawn */
X int w_redr_type; /* type of redraw to be performed on win */
X
X int w_leftcol; /* starting column of the screen */
X
X/*
X * The height of the lines currently in the window is remembered
X * to avoid recomputing it every time. The number of entries is w_nrows.
X */
X int w_lsize_valid; /* nr. of valid LineSizes */
X linenr_t *w_lsize_lnum; /* array of line numbers for w_lsize */
X char_u *w_lsize; /* array of line heights */
X
X int w_alt_fnum; /* alternate file (for # and CTRL-^) */
X
X int w_arg_idx; /* current index in argument list */
X
X /*
X * Variables "local" to a window.
X * They are here because they influence the layout of the window or
X * depend on the window layout.
X */
X int w_p_list,
X w_p_nu,
X w_p_wrap;
X long w_p_scroll;
X
X /*
X * The w_prev_pcmark field is used to check whether we really did jump to
X * a new line after setting the w_pcmark. If not, then we revert to
X * using the previous w_pcmark.
X */
X FPOS w_pcmark; /* previous context mark */
X FPOS w_prev_pcmark; /* previous w_pcmark */
X
X /*
X * the jumplist contains old cursor positions
X */
X struct filemark w_jumplist[JUMPLISTSIZE];
X int w_jumplistlen; /* number of active entries */
X int w_jumplistidx; /* current position */
X
X /*
X * the tagstack grows from 0 upwards:
X * entry 0: older
X * entry 1: newer
X * entry 2: newest
X */
X struct taggy w_tagstack[TAGSTACKSIZE]; /* the tag stack */
X int w_tagstackidx; /* index just below active entry */
X int w_tagstacklen; /* number of tags on the stack */
X
X};
END_OF_FILE
if test 14475 -ne `wc -c <'vim/src/structs.h'`; then
echo shar: \"'vim/src/structs.h'\" unpacked with wrong size!
fi
# end of 'vim/src/structs.h'
fi
echo shar: End of archive 21 \(of 26\).
cp /dev/null ark21isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 26 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still must unpack the following archives:
echo " " ${MISSING}
fi
exit 0
exit 0 # Just in case...