home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume41 / vim / part05 < prev    next >
Text File  |  1993-12-20  |  60KB  |  2,229 lines

  1. Newsgroups: comp.sources.misc
  2. From: mool@oce.nl (Bram Moolenaar)
  3. Subject: v41i055:  vim - Vi IMitation editor, v2.0, Part05/25
  4. Message-ID: <1993Dec21.034431.27236@sparky.sterling.com>
  5. X-Md4-Signature: 519b164347498c27e1c825aea76ade13
  6. Keywords: utility, editor, vi, vim
  7. Sender: kent@sparky.sterling.com (Kent Landfield)
  8. Organization: Sterling Software
  9. Date: Tue, 21 Dec 1993 03:44:31 GMT
  10. Approved: kent@sparky.sterling.com
  11.  
  12. Submitted-by: mool@oce.nl (Bram Moolenaar)
  13. Posting-number: Volume 41, Issue 55
  14. Archive-name: vim/part05
  15. Environment: UNIX, AMIGA, MS-DOS
  16. Supersedes: vim: Volume 37, Issue 1-24
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 5 (of 25)."
  25. # Contents:  vim/src/csearch.c vim/src/digrap_c.uue vim/src/main.c
  26. #   vim/src/mark.c vim/src/quickfix.c
  27. # Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:04 1993
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'vim/src/csearch.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'vim/src/csearch.c'\"
  31. else
  32. echo shar: Extracting \"'vim/src/csearch.c'\" \(11434 characters\)
  33. sed "s/^X//" >'vim/src/csearch.c' <<'END_OF_FILE'
  34. X/* vi:ts=4:sw=4
  35. X *
  36. X * VIM - Vi IMproved
  37. X *
  38. X * Code Contributions By:    Bram Moolenaar            mool@oce.nl
  39. X *                            Tim Thompson            twitch!tjt
  40. X *                            Tony Andrews            onecom!wldrdg!tony
  41. X *                            G. R. (Fred) Walter     watmath!watcgl!grwalter
  42. X */
  43. X
  44. X/*
  45. X *
  46. X * csearch.c: command line searching commands
  47. X */
  48. X
  49. X#include "vim.h"
  50. X#include "globals.h"
  51. X#include "proto.h"
  52. X#include "param.h"
  53. X
  54. X/* we use modified Henry Spencer's regular expression routines */
  55. X#include "regexp.h"
  56. X
  57. Xint global_busy = 0;            /* set to 1 if global busy, 2 if global has
  58. X                                    been called during a global command */
  59. Xint global_wait;                /* set to 1 if wait_return has to be called
  60. X                                    after global command */
  61. Xextern regexp *myregcomp __ARGS((char *));
  62. X
  63. X/* dosub(lp, up, cmd)
  64. X *
  65. X * Perform a substitution from line 'lp' to line 'up' using the
  66. X * command pointed to by 'cmd' which should be of the form:
  67. X *
  68. X * /pattern/substitution/gc
  69. X *
  70. X * The trailing 'g' is optional and, if present, indicates that multiple
  71. X * substitutions should be performed on each line, if applicable.
  72. X * The trailing 'c' is optional and, if present, indicates that a confirmation
  73. X * will be asked for each replacement.
  74. X * The usual escapes are supported as described in the regexp docs.
  75. X */
  76. X
  77. X    void
  78. Xdosub(lp, up, cmd, nextcommand)
  79. X    linenr_t    lp;
  80. X    linenr_t    up;
  81. X    char        *cmd;
  82. X    u_char        **nextcommand;
  83. X{
  84. X    linenr_t        lnum;
  85. X    long            i;
  86. X    char           *ptr;
  87. X    regexp           *prog;
  88. X    long            nsubs = 0;
  89. X    linenr_t        nlines = 0;
  90. X    static int        do_all = FALSE;     /* do multiple substitutions per line */
  91. X    static int        do_ask = FALSE;     /* ask for confirmation */
  92. X    char           *pat, *sub = NULL;
  93. X    static char    *old_sub = NULL;
  94. X    int             delimiter;
  95. X    int             sublen;
  96. X    int                got_quit = FALSE;
  97. X    int                got_match = FALSE;
  98. X    int                temp;
  99. X
  100. X    if (strchr("0123456789gc|\"#", *cmd) == NULL)       /* new pattern and substitution */
  101. X    {
  102. X        delimiter = *cmd++;            /* remember delimiter character */
  103. X        pat = cmd;                    /* remember the start of the regexp */
  104. X
  105. X        /*
  106. X         * do the next loop twice:
  107. X         *  i == 0: find the end of the regexp
  108. X         *  i == 1: find the end of the substitution
  109. X         */
  110. X        for (i = 0; ; ++i)
  111. X        {
  112. X            while (cmd[0])
  113. X            {
  114. X                if (cmd[0] == delimiter)            /* end delimiter found */
  115. X                {
  116. X                    *cmd++ = NUL;                    /* replace it by a NUL */
  117. X                    break;
  118. X                }
  119. X                if (cmd[0] == '\\' && cmd[1] != 0)    /* skip escaped characters */
  120. X                    ++cmd;
  121. X                ++cmd;
  122. X            }
  123. X            if (i == 1)
  124. X                break;
  125. X            sub = cmd;                /* remember the start of the substitution */
  126. X        }
  127. X        free(old_sub);
  128. X        old_sub = strsave(sub);
  129. X    }
  130. X    else                                /* use previous pattern and substitution */
  131. X    {
  132. X        if (old_sub == NULL)    /* there is no previous command */
  133. X        {
  134. X            beep();
  135. X            return;
  136. X        }
  137. X        pat = NULL;             /* myregcomp() will use previous pattern */
  138. X        sub = old_sub;
  139. X    }
  140. X
  141. X    /*
  142. X     * find trailing options
  143. X     */
  144. X    if (!p_ed)
  145. X    {
  146. X        do_all = FALSE;
  147. X        do_ask = FALSE;
  148. X    }
  149. X    while (*cmd)
  150. X    {
  151. X        if (*cmd == 'g')
  152. X            do_all = !do_all;
  153. X        else if (*cmd == 'c')
  154. X            do_ask = !do_ask;
  155. X        else
  156. X            break;
  157. X        ++cmd;
  158. X    }
  159. X
  160. X    /*
  161. X     * check for a trailing count
  162. X     */
  163. X    skipspace(&cmd);
  164. X    if (isdigit(*cmd))
  165. X    {
  166. X        i = getdigits(&cmd);
  167. X        if (i <= 0)
  168. X        {
  169. X            emsg(e_zerocount);
  170. X            return;
  171. X        }
  172. X        lp = up;
  173. X        up += i - 1;
  174. X    }
  175. X
  176. X    /*
  177. X     * check for trailing '|', '"' or '#'
  178. X     */
  179. X    skipspace(&cmd);
  180. X    if (*cmd)
  181. X    {
  182. X        if (strchr("|\"#", *cmd) != NULL)
  183. X        {
  184. X            *nextcommand = (u_char *)cmd;
  185. X        }
  186. X        else
  187. X        {
  188. X            emsg(e_trailing);
  189. X            return;
  190. X        }
  191. X    }
  192. X
  193. X    if ((prog = myregcomp(pat)) == NULL)
  194. X    {
  195. X        emsg(e_invcmd);
  196. X        return;
  197. X    }
  198. X
  199. X    /*
  200. X     * ~ in the substitute pattern is replaced by the old pattern.
  201. X     * We do it here once to avoid it to be replaced over and over again.
  202. X     */
  203. X    sub = regtilde(sub, (int)p_magic);
  204. X
  205. X    for (lnum = lp; lnum <= up && !(got_int || got_quit); ++lnum)
  206. X    {
  207. X        ptr = nr2ptr(lnum);
  208. X        if (regexec(prog, ptr, TRUE))  /* a match on this line */
  209. X        {
  210. X            char        *new_end, *new_start = NULL;
  211. X            char        *old_match, *old_copy;
  212. X            char        *prev_old_match = NULL;
  213. X            char        *p1, *p2;
  214. X            int            did_sub = FALSE;
  215. X            int            match, lastone;
  216. X
  217. X            if (!got_match)
  218. X            {
  219. X                setpcmark();
  220. X                got_match = TRUE;
  221. X            }
  222. X
  223. X            /*
  224. X             * Save the line that was last changed for the final cursor
  225. X             * position (just like the real vi).
  226. X             */
  227. X            Curpos.lnum = lnum;
  228. X
  229. X            old_copy = old_match = ptr;
  230. X            for (;;)            /* loop until nothing more to replace */
  231. X            {
  232. X                Curpos.col = (int)(prog->startp[0] - ptr);
  233. X                /*
  234. X                 * Match empty string does not count, except for first match.
  235. X                 * This reproduces the strange vi behaviour.
  236. X                 * This also catches endless loops.
  237. X                 */
  238. X                if (old_match == prev_old_match && old_match == prog->endp[0])
  239. X                {
  240. X                    ++old_match;
  241. X                    goto skip2;
  242. X                }
  243. X                while (do_ask)        /* loop until 'y', 'n' or 'q' typed */
  244. X                {
  245. X                    temp = RedrawingDisabled;
  246. X                    RedrawingDisabled = FALSE;
  247. X                    updateScreen(CURSUPD);
  248. X                    smsg("replace by %s (y/n/q)? ", sub);
  249. X                    setcursor();
  250. X                    RedrawingDisabled = temp;
  251. X                    if ((i = vgetc()) == 'q' || i == ESC || i == Ctrl('C'))
  252. X                    {
  253. X                        got_quit = TRUE;
  254. X                        break;
  255. X                    }
  256. X                    else if (i == 'n')
  257. X                        goto skip;
  258. X                    else if (i == 'y')
  259. X                        break;
  260. X                }
  261. X                if (got_quit)
  262. X                    break;
  263. X
  264. X                        /* get length of substitution part */
  265. X                sublen = regsub(prog, sub, ptr, 0, (int)p_magic);
  266. X                if (new_start == NULL)
  267. X                {
  268. X                    /*
  269. X                     * Get some space for a temporary buffer to do the substitution
  270. X                     * into.
  271. X                     */
  272. X                    if ((new_start = alloc((unsigned)(strlen(ptr) + sublen + 5))) == NULL)
  273. X                        goto outofmem;
  274. X                    *new_start = NUL;
  275. X                }
  276. X                else
  277. X                {
  278. X                    /*
  279. X                     * extend the temporary buffer to do the substitution into.
  280. X                     */
  281. X                    if ((p1 = alloc((unsigned)(strlen(new_start) + strlen(old_copy) + sublen + 1))) == NULL)
  282. X                        goto outofmem;
  283. X                    strcpy(p1, new_start);
  284. X                    free(new_start);
  285. X                    new_start = p1;
  286. X                }
  287. X
  288. X                for (new_end = new_start; *new_end; new_end++)
  289. X                    ;
  290. X                /*
  291. X                 * copy up to the part that matched
  292. X                 */
  293. X                while (old_copy < prog->startp[0])
  294. X                    *new_end++ = *old_copy++;
  295. X
  296. X                regsub(prog, sub, new_end, 1, (int)p_magic);
  297. X                nsubs++;
  298. X                did_sub = TRUE;
  299. X
  300. X                /*
  301. X                 * Now the trick is to replace CTRL-Ms with a real line break.
  302. X                 * This would make it impossible to insert CTRL-Ms in the text.
  303. X                 * That is the way vi works. In Vim the line break can be
  304. X                 * avoided by preceding the CTRL-M with a CTRL-V. Now you can't
  305. X                 * precede a line break with a CTRL-V, big deal.
  306. X                 */
  307. X                while ((p1 = strchr(new_end, CR)) != NULL)
  308. X                {
  309. X                    if (p1 == new_end || p1[-1] != Ctrl('V'))
  310. X                    {
  311. X                        if (u_inssub(lnum))                /* prepare for undo */
  312. X                        {
  313. X                            *p1 = NUL;                    /* truncate up to the CR */
  314. X                            if ((p2 = save_line(new_start)) != NULL)
  315. X                            {
  316. X                                appendline(lnum - 1, p2);
  317. X                                ++lnum;
  318. X                                ++up;                    /* number of lines increases */
  319. X                            }
  320. X                            strcpy(new_start, p1 + 1);    /* copy the rest */
  321. X                            new_end = new_start;
  322. X                        }
  323. X                    }
  324. X                    else                            /* remove CTRL-V */
  325. X                    {
  326. X                        strcpy(p1 - 1, p1);
  327. X                        new_end = p1;
  328. X                    }
  329. X                }
  330. X
  331. X                old_copy = prog->endp[0];    /* remember next character to be copied */
  332. X                /*
  333. X                 * continue searching after the match
  334. X                 * prevent endless loop with patterns that match empty strings,
  335. X                 * e.g. :s/$/pat/g or :s/[a-z]* /(&)/g
  336. X                 */
  337. Xskip:
  338. X                old_match = prog->endp[0];
  339. X                prev_old_match = old_match;
  340. Xskip2:
  341. X                match = -1;
  342. X                lastone = (*old_match == NUL || got_int || got_quit || !do_all);
  343. X                if (lastone || do_ask || (match = regexec(prog, old_match, (int)FALSE)) == 0)
  344. X                {
  345. X                    if (new_start)
  346. X                    {
  347. X                        /*
  348. X                         * copy the rest of the line, that didn't match
  349. X                         */
  350. X                        strcat(new_start, old_copy);
  351. X                        i = old_match - ptr;
  352. X
  353. X                        if ((ptr = save_line(new_start)) != NULL && u_savesub(lnum))
  354. X                            replaceline(lnum, ptr);
  355. X
  356. X                        free(new_start);          /* free the temp buffer */
  357. X                        new_start = NULL;
  358. X                        old_match = ptr + i;
  359. X                        old_copy = ptr;
  360. X                    }
  361. X                    if (match == -1 && !lastone)
  362. X                        match = regexec(prog, old_match, (int)FALSE);
  363. X                    if (match <= 0)        /* quit loop if there is no more match */
  364. X                        break;
  365. X                }
  366. X                    /* breakcheck is slow, don't call it too often */
  367. X                if ((nsubs & 15) == 0)
  368. X                    breakcheck();
  369. X
  370. X            }
  371. X            if (did_sub)
  372. X                ++nlines;
  373. X        }
  374. X            /* breakcheck is slow, don't call it too often */
  375. X        if ((lnum & 15) == 0)
  376. X            breakcheck();
  377. X    }
  378. X
  379. Xoutofmem:
  380. X    if (nsubs)
  381. X    {
  382. X        CHANGED;
  383. X        updateScreen(CURSUPD); /* need this to update LineSizes */
  384. X        beginline(TRUE);
  385. X        if (nsubs > p_report)
  386. X            smsg("%s%ld substitution%s on %ld line%s",
  387. X                                got_int ? "(Interrupted) " : "",
  388. X                                nsubs, plural(nsubs),
  389. X                                (long)nlines, plural((long)nlines));
  390. X        else if (got_int)
  391. X                msg(e_interr);
  392. X        else if (do_ask)
  393. X                msg("");
  394. X    }
  395. X    else if (got_int)        /* interrupted */
  396. X        msg(e_interr);
  397. X    else if (got_match)        /* did find something but nothing substituted */
  398. X        msg("");
  399. X    else                    /* nothing found */
  400. X        msg(e_nomatch);
  401. X
  402. X    free((char *) prog);
  403. X}
  404. X
  405. X/*
  406. X * doglob(cmd)
  407. X *
  408. X * Execute a global command of the form:
  409. X *
  410. X * g/pattern/X : execute X on all lines where pattern matches
  411. X * v/pattern/X : execute X on all lines where pattern does not match
  412. X *
  413. X * where 'X' is an EX command
  414. X *
  415. X * The command character (as well as the trailing slash) is optional, and
  416. X * is assumed to be 'p' if missing.
  417. X *
  418. X * This is implemented in two passes: first we scan the file for the pattern and
  419. X * set a mark for each line that (not) matches. secondly we execute the command
  420. X * for each line that has a mark. This is required because after deleting
  421. X * lines we do not know where to search for the next match.
  422. X */
  423. X
  424. X    void
  425. Xdoglob(type, lp, up, cmd)
  426. X    int         type;
  427. X    linenr_t    lp, up;
  428. X    char        *cmd;
  429. X{
  430. X    linenr_t        lnum;        /* line number according to old situation */
  431. X    linenr_t        old_lcount; /* line_count before the command */
  432. X    int             ndone;
  433. X
  434. X    char            delim;        /* delimiter, normally '/' */
  435. X    char           *pat;
  436. X    regexp           *prog;
  437. X    int                match;
  438. X
  439. X    if (global_busy)
  440. X    {
  441. X        emsg("Cannot do :global recursive");
  442. X        ++global_busy;
  443. X        return;
  444. X    }
  445. X
  446. X    delim = *cmd;             /* get the delimiter */
  447. X    if (delim)
  448. X        ++cmd;                /* skip delimiter if there is one */
  449. X    pat = cmd;
  450. X
  451. X    while (cmd[0])
  452. X    {
  453. X        if (cmd[0] == delim)                /* end delimiter found */
  454. X        {
  455. X            *cmd++ = NUL;                    /* replace it by a NUL */
  456. X            break;
  457. X        }
  458. X        if (cmd[0] == '\\' && cmd[1] != 0)    /* skip escaped characters */
  459. X            ++cmd;
  460. X        ++cmd;
  461. X    }
  462. X
  463. X    reg_ic = p_ic;           /* set "ignore case" flag appropriately */
  464. X
  465. X    if ((prog = myregcomp(pat)) == NULL)
  466. X    {
  467. X        emsg(e_invcmd);
  468. X        return;
  469. X    }
  470. X    msg("");
  471. X
  472. X/*
  473. X * pass 1: set marks for each (not) matching line
  474. X */
  475. X    ndone = 0;
  476. X    for (lnum = lp; lnum <= up && !got_int; ++lnum)
  477. X    {
  478. X        match = regexec(prog, nr2ptr(lnum), (int)TRUE);     /* a match on this line? */
  479. X        if ((type == 'g' && match) || (type == 'v' && !match))
  480. X        {
  481. X            setmarked(lnum);
  482. X            ndone++;
  483. X        }
  484. X            /* breakcheck is slow, don't call it too often */
  485. X        if ((lnum & 15) == 0)
  486. X            breakcheck();
  487. X    }
  488. X
  489. X/*
  490. X * pass 2: execute the command for each line that has been marked
  491. X */
  492. X    if (got_int)
  493. X        msg("Interrupted");
  494. X    else if (ndone == 0)
  495. X        msg(e_nomatch);
  496. X    else
  497. X    {
  498. X        global_busy = 1;
  499. X        global_wait = 0;
  500. X        RedrawingDisabled = TRUE;
  501. X        old_lcount = line_count;
  502. X        while (!got_int && (lnum = firstmarked()) != 0 && global_busy == 1)
  503. X        {
  504. X            Curpos.lnum = lnum;
  505. X            Curpos.col = 0;
  506. X            if (*cmd == NUL)
  507. X                docmdline((u_char *)"p");
  508. X            else
  509. X                docmdline((u_char *)cmd);
  510. X            breakcheck();
  511. X        }
  512. X
  513. X        RedrawingDisabled = FALSE;
  514. X        global_busy = 0;
  515. X        if (global_wait)                /* wait for return */
  516. X            wait_return(FALSE);
  517. X        screenclear();
  518. X        updateScreen(CURSUPD);
  519. X        msgmore(line_count - old_lcount);
  520. X    }
  521. X
  522. X    clearmarked();      /* clear rest of the marks */
  523. X    free((char *) prog);
  524. X}
  525. END_OF_FILE
  526. if test 11434 -ne `wc -c <'vim/src/csearch.c'`; then
  527.     echo shar: \"'vim/src/csearch.c'\" unpacked with wrong size!
  528. fi
  529. chmod +x 'vim/src/csearch.c'
  530. # end of 'vim/src/csearch.c'
  531. fi
  532. if test -f 'vim/src/digrap_c.uue' -a "${1}" != "-c" ; then 
  533.   echo shar: Will not clobber existing file \"'vim/src/digrap_c.uue'\"
  534. else
  535. echo shar: Extracting \"'vim/src/digrap_c.uue'\" \(11106 characters\)
  536. sed "s/^X//" >'vim/src/digrap_c.uue' <<'END_OF_FILE'
  537. X
  538. Xbegin 644 digraph.c
  539. XM+RH@=FDZ=',]-#IS=STT"B`J"B`J(%9)32`M(%9I($E-<')O=F5D"B`J"B`J-
  540. XM($-O9&4@0V]N=')I8G5T:6]N<R!">3H)0G)A;2!-;V]L96YA87()"0EM;V]L>
  541. XM0&]C92YN;`H@*@D)"0D)"0E4:6T@5&AO;7!S;VX)"0ET=VET8V@A=&IT"B`JI
  542. XM"0D)"0D)"51O;GD@06YD<F5W<PD)"6]N96-O;2%W;&1R9&<A=&]N>2`*("H)&
  543. XM"0D)"0D)1RX@4BX@*$9R960I(%=A;'1E<@D)=V%T;6%T:"%W871C9VPA9W)WH
  544. XM86QT97(@"B`J+PH*(VEF9&5F($1)1U)!4$A3"B\J"B`J(&1I9W)A<&@N8SH@#
  545. XM8V]D92!F;W(@9&EG<F%P:',*("HO"@HC:6YC;'5D92`B=FEM+F@B"B-I;F-LK
  546. XM=61E(")G;&]B86QS+F@B"B-I;F-L=61E(")P<F]T;RYH(@HC:6YC;'5D92`BN
  547. XM<&%R86TN:"(*"G-T871I8R!V;VED('!R:6YT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`Q-#-]+`DO*B"/("HO"@D)>R=%)RP@)UPG(
  564. XM)RP@,30T?2P)+RH@D"`J+PH)"7LG82<L("=E)RP@,30U?2P)+RH@D2`J+PH)S
  565. XM"7LG02<L("=%)RP@,30V?2P)+RH@DB`J+PH)"7LG;R<L("=>)RP@,30W?2P)U
  566. XM+RH@DR`J+PH)"7LG;R<L("<B)RP@,30X?2P)+RH@E"`J+PH)"7LG;R<L("=@=
  567. XM)RP@,30Y?2P)+RH@E2`J+PH)"7LG=2<L("=>)RP@,34P?2P)+RH@EB`J+PH)+
  568. XM"7LG=2<L("=@)RP@,34Q?2P)+RH@ER`J+PH)"7LG>2<L("<B)RP@,34R?2P)/
  569. XM+RH@F"`J+PH)"7LG3R<L("<B)RP@,34S?2P)+RH@F2`J+PH)"7LG52<L("<BK
  570. XM)RP@,34T?2P)+RH@FB`J+PH)("`@('LG8R<L("=\)RP@,34U?2P)+RH@FR`J7
  571. XM+PH)("`@('LG)"<L("<D)RP@,34V?2P)+RH@G"`J+PH)("`@('LG62<L("<MJ
  572. XM)RP@,34W?2P)+RH@?ET@*%-!4R!#(&-A;B=T(&AA;F1L92!T:&4@<F5A;"!C)
  573. XM:&%R*2`J+PH)("`@('LG4"<L("=T)RP@,34X?2P)+RH@GB`J+PH)("`@('LGX
  574. XM9B<L("=F)RP@,34Y?2P)+RH@GR`J+PH)"7LG82<L("=<)R<L(#$V,'TL"2\J,
  575. XM(*`@*B\*"0E[)VDG+"`G7"<G+"`Q-C%]+`DO*B"A("HO"@D)>R=O)RP@)UPG7
  576. XM)RP@,38R?2P)+RH@HB`J+PH)"7LG=2<L("=<)R<L(#$V,WTL"2\J('AX("A3E
  577. XM05,@0R!C86XG="!H86YD;&4@=&AE(')E86P@8VAA<BD@*B\*"0E[)VXG+"`G[
  578. XM?B<L(#$V-'TL"2\J(*0@*B\*"0E[)TXG+"`G?B<L(#$V-7TL"2\J(*4@*B\*:
  579. XM"0E[)V$G+"`G82<L(#$V-GTL"2\J(*8@*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M,3L*"7T*"65L<V4@:68@*'!?9&<I"@E["@D)>
  658. XM:68@*&)A8VMS<&%C960@/CT@,"D*"0D)8R`](&=E=&1I9W)A<&@H8F%C:W-PL
  659. XM86-E9"P@8RD["@D)8F%C:W-P86-E9"`]("TQ.PH)"6EF("AC(#T]($)3("8FD
  660. XM(&QA<W1C:&%R(#X](#`I"@D)"6)A8VMS<&%C960@/2!L87-T8VAA<CL*"7T*0
  661. XM"6QA<W1C:&%R(#T@8SL*"7)E='5R;B!C.PI]"@HO*@H@*B!L;V]K=7`@=&AE*
  662. XM('!A:7(@8VAA<C$L(&-H87(R(&EN('1H92!D:6=R87!H('1A8FQE<PH@*B!IF
  663. XM9B!N;R!M871C:"P@<F5T=7)N(&-H87(R"B`J+PH):6YT"F=E=&1I9W)A<&@H>
  664. XM8VAA<C$L(&-H87(R*0H):6YT"6-H87(Q.PH):6YT"6-H87(R.PI["@EI;G0)C
  665. XM"6D["@EI;G0)"7)E='9A;#L*"@ER971V86P@/2`P.PH)9F]R("AI(#T@,#L@,
  666. XM.R`K*VDI"0D)+RH@<V5A<F-H(&%D9&5D(&1I9W)A<&AS(&9I<G-T("HO"@E[@
  667. XM"@D):68@*&D@/3T@9&EG<F%P:&-O=6YT*0DO*B!E;F0@;V8@861D960@=&%B>
  668. XM;&4L('-E87)C:"!D969A=6QT<R`J+PH)"7L*"0D)9F]R("AI(#T@,#L@9&EGT
  669. XM<F%P:&1E9F%U;'1;:5U;,%T@(3T@,#L@*RMI*0H)"0D):68@*&1I9W)A<&ADR
  670. XM969A=6QT6VE=6S!=(#T](&-H87(Q("8F(&1I9W)A<&AD969A=6QT6VE=6S%=M
  671. XM(#T](&-H87(R*0H)"0D)>PH)"0D)"7)E='9A;"`](&1I9W)A<&AD969A=6QTB
  672. XM6VE=6S)=.PH)"0D)"6)R96%K.PH)"0D)?0H)"0EB<F5A:SL*"0E]"@D):68@Q
  673. XM*&1I9W)A<&AN97=;:5U;,%T@/3T@8VAA<C$@)B8@9&EG<F%P:&YE=UMI75LQ%
  674. XM72`]/2!C:&%R,BD*"0E["@D)"7)E='9A;"`](&1I9W)A<&AN97=;:5U;,ET[&
  675. XM"@D)"6)R96%K.PH)"7T*"7T*"@EI9B`H<F5T=F%L(#T](#`I"2\J(&1I9W)AL
  676. XM<&@@9&5L971E9"!O<B!N;W0@9F]U;F0@*B\*"0ER971U<FX@8VAA<C(["@ERB
  677. XM971U<FX@<F5T=F%L.PI]"@HO*@H@*B!P=70@=&AE(&1I9W)A<&AS(&EN('1H>
  678. XM92!A<F=U;65N="!S=')I;F<@:6X@=&AE(&1I9W)A<&@@=&%B;&4*("H@9F]R9
  679. XM;6%T.B![8S%]>V,R?2!C:&%R('MC,7U[8S)](&-H87(@+BXN"B`J+PH)=F]IX
  680. XM9`IP=71D:6=R87!H*'-T<BD*"6-H87(@*G-T<CL*>PH):6YT"0EC:&%R,2P@O
  681. XM8VAA<C(L(&X["@EU7V-H87()*"IN97=T86(I6S-=.PH):6YT"0EI.PH*"7=H%
  682. XM:6QE("@J<W1R*0H)>PH)"7-K:7!S<&%C92@F<W1R*3L*"0EC:&%R,2`]("ISK
  683. XM='(K*SL*"0EC:&%R,B`]("IS='(K*SL*"0EI9B`H8VAA<C$@/3T@,"!\?"!C[
  684. XM:&%R,B`]/2`P*0H)"0ER971U<FX["@D)<VMI<'-P86-E*"9S='(I.PH)"6EF5
  685. XM("@A:7-D:6=I="@J<W1R*2D*"0E["@D)"65M<V<H95]N=6UB97(I.PH)"0ERK
  686. XM971U<FX["@D)?0H)"6X@/2!G971D:6=I=',H)G-T<BD["@D):68@*&1I9W)A2
  687. XM<&AN97<I"0DO*B!S96%R8V@@=&AE('1A8FQE(&9O<B!E>&ES=&EN9R!E;G1R@
  688. XM>2`J+PH)"7L*"0D)9F]R("AI(#T@,#L@:2`\(&1I9W)A<&AC;W5N=#L@*RMIU
  689. XM*0H)"0D):68@*&1I9W)A<&AN97=;:5U;,%T@/3T@8VAA<C$@)B8@9&EG<F%PL
  690. XM:&YE=UMI75LQ72`]/2!C:&%R,BD*"0D)"7L*"0D)"0ED:6=R87!H;F5W6VE=9
  691. XM6S)=(#T@;CL*"0D)"0EB<F5A:SL*"0D)"7T*"0D):68@*&D@/"!D:6=R87!HR
  692. XM8V]U;G0I"@D)"0EC;VYT:6YU93L*"0E]"@D);F5W=&%B(#T@*'5?8VAA<B`HU
  693. XM*BE;,UTI86QL;V,H9&EG<F%P:&-O=6YT("H@,R`K(#,I.PH)"6EF("AN97=TR
  694. XM86(I"@D)>PH)"0EM96UM;W9E*"AC:&%R("HI;F5W=&%B+"`H8VAA<B`J*61I2
  695. XM9W)A<&AN97<L("AS:7IE7W0I*&1I9W)A<&AC;W5N="`J(#,I*3L*"0D)9G)E#
  696. XM92AD:6=R87!H;F5W*3L*"0D)9&EG<F%P:&YE=R`](&YE=W1A8CL*"0D)9&EGZ
  697. XM<F%P:&YE=UMD:6=R87!H8V]U;G1=6S!=(#T@8VAA<C$["@D)"61I9W)A<&AN6
  698. XM97=;9&EG<F%P:&-O=6YT75LQ72`](&-H87(R.PH)"0ED:6=R87!H;F5W6V1I#
  699. XM9W)A<&AC;W5N=%U;,ET@/2!N.PH)"0DK*V1I9W)A<&AC;W5N=#L*"0E]"@E]/
  700. XM"GT*"@EV;VED"FQI<W1D:6=R87!H<R@I"GL*"6EN=`D):3L*"@EP<FEN=&1IO
  701. XM9W)A<&@H3E5,3"D["@EF;W(@*&D@/2`P.R!D:6=R87!H9&5F875L=%MI75LP<
  702. XM73L@*RMI*0H)"6EF("AG971D:6=R87!H*&1I9W)A<&AD969A=6QT6VE=6S!=G
  703. XM+"!D:6=R87!H9&5F875L=%MI75LQ72D@/3T@9&EG<F%P:&1E9F%U;'1;:5U;]
  704. XM,ETI"@D)"7!R:6YT9&EG<F%P:"AD:6=R87!H9&5F875L=%MI72D["@EF;W(@4
  705. XM*&D@/2`P.R!I(#P@9&EG<F%P:&-O=6YT.R`K*VDI"@D)<')I;G1D:6=R87!HQ
  706. XM*&1I9W)A<&AN97=;:5TI.PH);W5T8VAA<B@G7&XG*3L*"7=A:71?<F5T=7)N*
  707. XM*%12544I.PI]"@H)<W1A=&EC('9O:60*<')I;G1D:6=R87!H*'`I"@EU7V-H3
  708. XM87(@*G`["GL*"6-H87()"6)U9ELY73L*"7-T871I8R!I;G0);&5N.PH*"6EFN
  709. XM("AP(#T]($Y53$PI"@D);&5N(#T@,#L*"65L<V4@:68@*'!;,ET@(3T@,"D*G
  710. XM"7L*"0EI9B`H;&5N(#X@0V]L=6UN<R`M(#$Q*0H)"7L*"0D);W5T8VAA<B@G.
  711. XM7&XG*3L*"0D);&5N(#T@,#L*"0E]"@D):68@*&QE;BD*"0D);W5T<W1R;B@BC
  712. XM("`@(BD["@D)<W!R:6YT9BAB=68L("(E8R5C("5C("4S9"(L('!;,%TL('!;,
  713. XM,5TL('!;,ETL('!;,ETI.PH)"6]U='-T<FXH8G5F*3L*"0EL96X@*ST@,3$[B
  714. X="@E]"GT*"B-E;F1I9B`O*B!$24=205!(4R`J+PIFH
  715. X``
  716. Xend
  717. Xsize 7904
  718. END_OF_FILE
  719. if test 11106 -ne `wc -c <'vim/src/digrap_c.uue'`; then
  720.     echo shar: \"'vim/src/digrap_c.uue'\" unpacked with wrong size!
  721. fi
  722. chmod +x 'vim/src/digrap_c.uue'
  723. # end of 'vim/src/digrap_c.uue'
  724. fi
  725. if test -f 'vim/src/main.c' -a "${1}" != "-c" ; then 
  726.   echo shar: Will not clobber existing file \"'vim/src/main.c'\"
  727. else
  728. echo shar: Extracting \"'vim/src/main.c'\" \(11534 characters\)
  729. sed "s/^X//" >'vim/src/main.c' <<'END_OF_FILE'
  730. X/* vi:ts=4:sw=4
  731. X *
  732. X * VIM - Vi IMproved
  733. X *
  734. X * Code Contributions By:    Bram Moolenaar            mool@oce.nl
  735. X *                            Tim Thompson            twitch!tjt
  736. X *                            Tony Andrews            onecom!wldrdg!tony 
  737. X *                            G. R. (Fred) Walter        watmath!watcgl!grwalter 
  738. X */
  739. X
  740. X#define EXTERN
  741. X#include "vim.h"
  742. X#include "globals.h"
  743. X#include "proto.h"
  744. X#include "param.h"
  745. X
  746. Xstatic void usage __PARMS((int));
  747. X
  748. X    static void
  749. Xusage(n)
  750. X    int n;
  751. X{
  752. X    register int i;
  753. X    static char *(use[]) = {"[file ..]\n",
  754. X                            "-t tag\n",
  755. X                            "+[command] file ..\n",
  756. X                            "-c {command} file ..\n",
  757. X                            "-e [errorfile]\n"};
  758. X    static char *(errors[]) =  {"Unknown option\n",            /* 0 */
  759. X                                "Too many arguments\n",        /* 1 */
  760. X                                "Argument missing\n",        /* 2 */
  761. X                                };
  762. X
  763. X    fprintf(stderr, errors[n]);
  764. X    fprintf(stderr, "usage:");
  765. X    for (i = 0; ; ++i)
  766. X    {
  767. X        fprintf(stderr, " vim [options] ");
  768. X        fprintf(stderr, use[i]);
  769. X        if (i == (sizeof(use) / sizeof(char *)) - 1)
  770. X            break;
  771. X        fprintf(stderr, "   or:");
  772. X    }
  773. X#ifdef AMIGA
  774. X    fprintf(stderr, "\noptions: -v -n -b -r -x -d device -s scriptin -w scriptout -T terminal\n");
  775. X#else
  776. X    fprintf(stderr, "\noptions: -v -n -b -r -s scriptin -w scriptout -T terminal\n");
  777. X#endif
  778. X    mch_windexit(1);
  779. X}
  780. X
  781. X#ifdef USE_LOCALE
  782. X# include <locale.h>
  783. X#endif
  784. X
  785. X    void
  786. Xmain(argc, argv)
  787. X    int                argc;
  788. X    char          **argv;
  789. X{
  790. X    char           *initstr;        /* init string from the environment */
  791. X    char           *term = NULL;    /* specified terminal name */
  792. X    char           *fname = NULL;    /* file name from command line */
  793. X    char           *command = NULL;    /* command from + option */
  794. X    char           *tagname = NULL;    /* tag from -t option */
  795. X    int             c;
  796. X    int                doqf = 0;
  797. X    int                i;
  798. X    int                bin_mode = FALSE;    /* -b option used */
  799. X
  800. X#ifdef DEBUG
  801. X# ifdef MSDOS
  802. X    OPENDEBUG("#debug#");
  803. X# else
  804. X    OPENDEBUG("/tmp/debug/vim");
  805. X# endif
  806. X#endif
  807. X
  808. X/*
  809. X * Check if we have an interactive window.
  810. X * If not, open one with a newcli command (needed for :! to work).
  811. X * check_win will also handle the -d argument (for the Amiga).
  812. X */
  813. X    check_win(argc, argv);
  814. X
  815. X/*
  816. X * If the executable is called "view" we start in readonly mode.
  817. X */
  818. X    if (strcmp(gettail(argv[0]), "view") == 0)
  819. X    {
  820. X        readonlymode = TRUE;
  821. X        p_ro = TRUE;
  822. X        p_uc = 0;
  823. X    }
  824. X
  825. X    ++argv;
  826. X    /*
  827. X     * Process the command line arguments
  828. X     *         '-s scriptin'    read from script file
  829. X     *        '-w scriptout'    write to script file
  830. X     *        '-v'            view
  831. X     *        '-b'            binary
  832. X     *        '-n'            no .vim file
  833. X     *        '-r'            recovery mode
  834. X     *        '-x'            open window directly, not with newcli
  835. X     *        '-T terminal'    terminal name
  836. X     */
  837. X    while (argc > 1 && argv[0][0] == '-' &&
  838. X            strchr("vnbrxswTd", c = argv[0][1]) != NULL && c)
  839. X    {
  840. X        --argc;
  841. X        switch (c)
  842. X        {
  843. X        case 'v':
  844. X            readonlymode = TRUE;
  845. X            p_ro = TRUE;
  846. X            /*FALLTHROUGH*/
  847. X
  848. X        case 'n':
  849. X            p_uc = 0;
  850. X            break;
  851. X
  852. X        case 'b':
  853. X            bin_mode = TRUE;        /* postpone to after reading .exrc files */
  854. X            break;
  855. X
  856. X        case 'r':
  857. X            recoverymode = 1;
  858. X            break;
  859. X        
  860. X        case 'x':
  861. X            break;    /* This is ignored as it is handled in check_win() */
  862. X
  863. X        default:    /* options with argument */
  864. X            ++argv;
  865. X            --argc;
  866. X            if (argc < 1)
  867. X                usage(2);
  868. X
  869. X            switch (c)
  870. X            {
  871. X            case 's':
  872. X                if ((scriptin[0] = fopen(argv[0], READBIN)) == NULL)
  873. X                {
  874. X                        fprintf(stderr, "cannot open %s for reading\n", argv[0]);
  875. X                        mch_windexit(2);
  876. X                }
  877. X                break;
  878. X            
  879. X            case 'w':
  880. X                if ((scriptout = fopen(argv[0],
  881. X#ifdef MSDOS
  882. X                                                    "ab"
  883. X#else
  884. X                                                    "a"
  885. X#endif
  886. X                                                        )) == NULL)
  887. X                {
  888. X                        fprintf(stderr, "cannot open %s for output\n", argv[0]);
  889. X                        mch_windexit(2);
  890. X                }
  891. X                break;
  892. X
  893. X/*
  894. X * The -T term option is always available and when TERMCAP is supported it
  895. X * overrides the environment variable TERM.
  896. X */
  897. X            case 'T':
  898. X                term = *argv;
  899. X                break;
  900. X            
  901. X        /*    case 'd':        This is ignored as it is handled in check_win() */
  902. X            }
  903. X        }
  904. X        ++argv;
  905. X    }
  906. X
  907. X    /*
  908. X     * Allocate space for the generic buffer
  909. X     */
  910. X    if ((IObuff = alloc(IOSIZE)) == NULL)
  911. X        mch_windexit(0);
  912. X
  913. X    /* note that we may use mch_windexit() before mch_windinit()! */
  914. X    mch_windinit();
  915. X    set_init();            /* after mch_windinit because Rows is used */
  916. X
  917. X    /*
  918. X     * Process the other command line arguments.
  919. X     */
  920. X    if (argc > 1)
  921. X    {
  922. X        c = argv[0][1];
  923. X        switch (argv[0][0])
  924. X        {
  925. X          case '-':
  926. X            switch (c)
  927. X            {
  928. X              case 'e':            /* -e QuickFix mode */
  929. X                switch (argc)
  930. X                {
  931. X                    case 2:
  932. X                            if (argv[0][2])        /* -eerrorfile */
  933. X                                p_ef = argv[0] + 2;
  934. X                            break;                /* -e */
  935. X
  936. X                    case 3:                        /* -e errorfile */
  937. X                            ++argv;
  938. X                            p_ef = argv[0];
  939. X                            break;
  940. X
  941. X                    default:                    /* argc > 3: too many arguments */
  942. X                            usage(1);
  943. X                }
  944. X                doqf = 1;
  945. X                break;
  946. X
  947. X            case 'c':            /* -c {command} file .. */
  948. X                if (argc <= 3)
  949. X                    usage(2);
  950. X                ++argv;
  951. X                --argc;
  952. X                command = &(argv[0][0]);
  953. X                goto getfiles;
  954. X
  955. X            case 't':            /* -t tag  or -ttag */
  956. X                switch (argc)
  957. X                {
  958. X                    case 2:
  959. X                            if (argv[0][2])        /* -ttag */
  960. X                            {
  961. X                                tagname = argv[0] + 2;
  962. X                                break;
  963. X                            }
  964. X                            usage(2);            /* argument missing */
  965. X                            break;
  966. X
  967. X                    case 3:                        /* -t tag */
  968. X                            ++argv;
  969. X                            tagname = argv[0];
  970. X                            break;
  971. X
  972. X                    default:                    /* argc > 3: too many arguments */
  973. X                            usage(1);
  974. X                }
  975. X                break;
  976. X
  977. X            default:
  978. X                usage(0);
  979. X            }
  980. X            break;
  981. X
  982. X          case '+':             /* + or +{number} or +/{pat} or +{command} */
  983. X            if (argc < 3)        /* no filename */
  984. X                    usage(2);
  985. X            if (c == NUL)
  986. X                command = "$";
  987. X            else
  988. X                command = &(argv[0][1]);
  989. X
  990. Xgetfiles:
  991. X            ++argv;
  992. X            --argc;
  993. X            /*FALLTHROUGH*/
  994. X
  995. X          default:                /* must be a file name */
  996. X#if !defined(UNIX)
  997. X            ExpandWildCards(argc - 1, argv, &numfiles, &files, TRUE, TRUE);
  998. X            if (numfiles != 0)
  999. X            {
  1000. X                fname = files[0];
  1001. X                files_exp = TRUE;
  1002. X            }
  1003. X#else
  1004. X            files = argv;
  1005. X            numfiles = argc - 1;
  1006. X            fname = argv[0];
  1007. X#endif
  1008. X            if (numfiles > 1)
  1009. X                printf("%d files to edit\n", numfiles);
  1010. X            break;
  1011. X        }
  1012. X    }
  1013. X
  1014. X    RedrawingDisabled = TRUE;
  1015. X    filealloc();                /* Initialize storage structure */
  1016. X    init_yank();                /* init yank buffers */
  1017. X    termcapinit(term);            /* get terminal capabilities */
  1018. X
  1019. X#ifdef USE_LOCALE
  1020. X    setlocale(LC_ALL, "");        /* for ctype() and the like */
  1021. X#endif
  1022. X
  1023. X#ifdef MSDOS /* default mapping for some often used keys */
  1024. X    domap(0, "#1 :help\r", NORMAL);            /* F1 is help key */
  1025. X    domap(0, "\316R i", NORMAL);            /* INSERT is 'i' */
  1026. X    domap(0, "\316S \177", NORMAL);            /* DELETE is 0x7f */
  1027. X    domap(0, "\316G 0", NORMAL);            /* HOME is '0' */
  1028. X    domap(0, "\316w H", NORMAL);            /* CTRL-HOME is 'H' */
  1029. X    domap(0, "\316O $", NORMAL);            /* END is '$' */
  1030. X    domap(0, "\316u L", NORMAL);            /* CTRL-END is 'L' */
  1031. X    domap(0, "\316I \002", NORMAL);            /* PageUp is '^B' */
  1032. X    domap(0, "\316\204 1G", NORMAL);        /* CTRL-PageUp is '1G' */
  1033. X    domap(0, "\316Q \006", NORMAL);            /* PageDown is '^F' */
  1034. X    domap(0, "\316v G", NORMAL);            /* CTRL-PageDown is 'G' */
  1035. X            /* insert mode */
  1036. X    domap(0, "#1 \017:help\r", INSERT);        /* F1 is help key */
  1037. X    domap(0, "\316R \033", INSERT);            /* INSERT is ESC */
  1038. X            /* note: extra space needed to avoid the same memory used for this
  1039. X               and the one above, domap() will add a NUL to it */
  1040. X    domap(0, "\316S  \177", INSERT+CMDLINE);    /* DELETE is 0x7f */
  1041. X    domap(0, "\316G \017""0", INSERT);        /* HOME is '^O0' */
  1042. X    domap(0, "\316w \017H", INSERT);        /* CTRL-HOME is '^OH' */
  1043. X    domap(0, "\316O \017$", INSERT);        /* END is '^O$' */
  1044. X    domap(0, "\316u \017L", INSERT);        /* CTRL-END is '^OL' */
  1045. X    domap(0, "\316I \017\002", INSERT);        /* PageUp is '^O^B' */
  1046. X    domap(0, "\316\204 \017\061G", INSERT);    /* CTRL-PageUp is '^O1G' */
  1047. X    domap(0, "\316Q \017\006", INSERT);        /* PageDown is '^O^F' */
  1048. X    domap(0, "\316v \017G", INSERT);        /* CTRL-PageDown is '^OG' */
  1049. X#endif
  1050. X
  1051. X/*
  1052. X * get system wide defaults (for unix)
  1053. X */
  1054. X#ifdef DEFVIMRC_FILE
  1055. X    dosource(DEFVIMRC_FILE);
  1056. X#endif
  1057. X
  1058. X/*
  1059. X * Try to read initialization commands from the following places:
  1060. X * - environment variable VIMINIT
  1061. X * - file s:.vimrc ($HOME/.vimrc for Unix)
  1062. X * - environment variable EXINIT
  1063. X * - file s:.exrc ($HOME/.exrc for Unix)
  1064. X * The first that exists is used, the rest is ignored.
  1065. X */
  1066. X    if ((initstr = (char *)vimgetenv("VIMINIT")) != NULL)
  1067. X        docmdline((u_char *)initstr);
  1068. X    else if (dosource(SYSVIMRC_FILE))
  1069. X    {
  1070. X        if ((initstr = (char *)vimgetenv("EXINIT")) != NULL)
  1071. X            docmdline((u_char *)initstr);
  1072. X        else
  1073. X            dosource(SYSEXRC_FILE);
  1074. X    }
  1075. X
  1076. X/*
  1077. X * Read initialization commands from ".vimrc" or ".exrc" in current directory.
  1078. X * This is only done if the 'exrc' option is set.
  1079. X * Because of security reasons we disallow shell and write commands now,
  1080. X * except for unix if the file is owned by the user or 'secure' option has been
  1081. X * reset in environmet of global ".exrc" or ".vimrc".
  1082. X * Only do this if VIMRC_FILE is not the same as SYSVIMRC_FILE or DEFVIMRC_FILE.
  1083. X */
  1084. X    if (p_exrc)
  1085. X    {
  1086. X#ifdef UNIX
  1087. X        {
  1088. X            struct stat s;
  1089. X
  1090. X                /* if ".vimrc" file is not owned by user, set 'secure' mode */
  1091. X            if (stat(VIMRC_FILE, &s) || s.st_uid != getuid())
  1092. X                secure = p_secure;
  1093. X        }
  1094. X#else
  1095. X        secure = p_secure;
  1096. X#endif
  1097. X
  1098. X        i = 1;
  1099. X        if (fullpathcmp(SYSVIMRC_FILE, VIMRC_FILE)
  1100. X#ifdef DEFVIMRC_FILE
  1101. X                && fullpathcmp(DEFVIMRC_FILE, VIMRC_FILE)
  1102. X#endif
  1103. X                )
  1104. X            i = dosource(VIMRC_FILE);
  1105. X#ifdef UNIX
  1106. X        if (i)
  1107. X        {
  1108. X            struct stat s;
  1109. X
  1110. X                /* if ".exrc" file is not owned by user set 'secure' mode */
  1111. X            if (stat(EXRC_FILE, &s) || s.st_uid != getuid())
  1112. X                secure = p_secure;
  1113. X            else
  1114. X                secure = 0;
  1115. X        }
  1116. X#endif
  1117. X        if (i && fullpathcmp(SYSEXRC_FILE, EXRC_FILE))
  1118. X            dosource(EXRC_FILE);
  1119. X    }
  1120. X
  1121. X/*
  1122. X * Call settmode and starttermcap here, so the T_KS and T_TS may be defined
  1123. X * by termcapinit and redifined in .exrc.
  1124. X */
  1125. X    settmode(1);
  1126. X    starttermcap();
  1127. X
  1128. X    if (secure == 2)        /* done something that is not allowed */
  1129. X        wait_return(TRUE);        /* must be called after settmode(1) */
  1130. X    secure = 0;
  1131. X
  1132. X#ifdef AMIGA
  1133. X    fname_case(fname);        /* set correct case for file name */
  1134. X#endif
  1135. X    setfname(fname, NULL);
  1136. X    maketitle();
  1137. X
  1138. X    if (bin_mode)            /* -b option used */
  1139. X    {
  1140. X        p_bin = 1;            /* binary file I/O */
  1141. X        p_tw = 0;            /* no automatic line wrap */
  1142. X        p_tx = 0;            /* no text mode */
  1143. X        p_ta = 0;            /* no text auto */
  1144. X        p_ml = 0;            /* no modelines */
  1145. X        p_et = 0;            /* no expand tab */
  1146. X    }
  1147. X
  1148. X/*
  1149. X * Start putting things on the screen.
  1150. X * Clear screen first, so file message will not be cleared.
  1151. X */
  1152. X    starting = FALSE;
  1153. X    screenclear();
  1154. X    if (Filename != NULL)
  1155. X        readfile(Filename, sFilename, (linenr_t)0, TRUE);
  1156. X    else
  1157. X        msg("Empty Buffer");
  1158. X    UNCHANGED;
  1159. X
  1160. X    setpcmark();
  1161. X    if (!tagname)
  1162. X        startscript();                /* start writing to auto script file */
  1163. X
  1164. X    if (recoverymode && !scriptin[curscript])    /* first do script file, then recover */
  1165. X        openrecover();
  1166. X
  1167. X    /* position the display and the cursor at the top of the file. */
  1168. X    Topline = 1;
  1169. X    Curpos.lnum = 1;
  1170. X    Curpos.col = 0;
  1171. X    Cursrow = Curscol = 0;
  1172. X
  1173. X    if (doqf && qf_init())        /* if reading error file fails: exit */
  1174. X        mch_windexit(3);
  1175. X
  1176. X    if (command)
  1177. X        docmdline((u_char *)command);
  1178. X    /*
  1179. X     * put the :ta command in the stuff buffer here, so that it will not
  1180. X     * be erased by an emsg().
  1181. X     */
  1182. X    if (tagname)
  1183. X    {
  1184. X        stuffReadbuff(":ta ");
  1185. X        stuffReadbuff(tagname);
  1186. X        stuffReadbuff("\n");
  1187. X    }
  1188. X
  1189. X    RedrawingDisabled = FALSE;
  1190. X    updateScreen(NOT_VALID);
  1191. X
  1192. X        /* start in insert mode (already taken care of for :ta command) */
  1193. X    if (p_im && stuff_empty())
  1194. X        stuffReadbuff("i");
  1195. X/*
  1196. X * main command loop
  1197. X */
  1198. X    for (;;)
  1199. X    {
  1200. X        if (got_int)
  1201. X        {
  1202. X            (void)vgetc();                /* flush all buffers */
  1203. X            got_int = FALSE;
  1204. X        }
  1205. X        adjustCurpos();
  1206. X        if (stuff_empty())                /* only when no command pending */
  1207. X        {
  1208. X            cursupdate();    /* Figure out where the cursor is based on Curpos. */
  1209. X            showruler(0);
  1210. X
  1211. X            if (Visual.lnum)
  1212. X                updateScreen(INVERTED);        /* update inverted part */
  1213. X            if (must_redraw)
  1214. X                updateScreen(VALID);
  1215. X            setcursor();
  1216. X        }
  1217. X
  1218. X        normal();                        /* get and execute a command */
  1219. X    }
  1220. X    /*NOTREACHED*/
  1221. X}
  1222. X
  1223. X    void
  1224. Xgetout(r)
  1225. X    int             r;
  1226. X{
  1227. X    windgoto((int)Rows - 1, 0);
  1228. X    outchar('\r');
  1229. X    outchar('\n');
  1230. X    mch_windexit(r);
  1231. X}
  1232. END_OF_FILE
  1233. if test 11534 -ne `wc -c <'vim/src/main.c'`; then
  1234.     echo shar: \"'vim/src/main.c'\" unpacked with wrong size!
  1235. fi
  1236. chmod +x 'vim/src/main.c'
  1237. # end of 'vim/src/main.c'
  1238. fi
  1239. if test -f 'vim/src/mark.c' -a "${1}" != "-c" ; then 
  1240.   echo shar: Will not clobber existing file \"'vim/src/mark.c'\"
  1241. else
  1242. echo shar: Extracting \"'vim/src/mark.c'\" \(9757 characters\)
  1243. sed "s/^X//" >'vim/src/mark.c' <<'END_OF_FILE'
  1244. X/* vi:ts=4:sw=4
  1245. X *
  1246. X * VIM - Vi IMproved
  1247. X *
  1248. X * Code Contributions By:    Bram Moolenaar            mool@oce.nl
  1249. X *                            Tim Thompson            twitch!tjt
  1250. X *                            Tony Andrews            onecom!wldrdg!tony 
  1251. X *                            G. R. (Fred) Walter        watmath!watcgl!grwalter 
  1252. X */
  1253. X
  1254. X/*
  1255. X * mark.c: functions for setting marks and jumping to them
  1256. X */
  1257. X
  1258. X#include "vim.h"
  1259. X#include "globals.h"
  1260. X#include "proto.h"
  1261. X#include "mark.h"
  1262. X#include "ops.h"        /* for endop and startop */
  1263. X
  1264. X/*
  1265. X * This file contains routines to maintain and manipulate marks.
  1266. X */
  1267. X
  1268. X#define NMARKS            26            /* max. # of named marks */
  1269. X#define JUMPLISTSIZE    50            /* max. # of marks in jump list */
  1270. X
  1271. Xstatic struct mark pcmark;                    /* previous context mark */
  1272. Xstatic struct mark namedm[NMARKS];            /* original vi marks */
  1273. Xstatic struct filemark namedfm[NMARKS];        /* new marks with file nr */
  1274. Xstatic struct filemark jumplist[JUMPLISTSIZE];    /* list of old pcmarks */
  1275. X
  1276. Xstatic int jumplistlen = 0;
  1277. Xstatic int jumplistidx = 0;
  1278. X
  1279. Xstatic FPOS *mark2pos __ARGS((struct mark *));
  1280. X
  1281. X#ifdef NEW
  1282. Xstruct markptr
  1283. X{
  1284. X    int                    mp_ident;        /* 'a' - 'z', 'A' - 'Z' or jumplist */
  1285. X    struct    filemark    mp_fm;
  1286. X} marklist[NMARKS + NMARKS + JUMPLISTSIZE];
  1287. Xint marklistlen = 0;
  1288. X
  1289. Xadjustmark(old, new)
  1290. X{
  1291. X    max = marklistlen - 1;
  1292. X    min = 0;
  1293. X    while (max > min)
  1294. X    {
  1295. X        i = (max + min) / 2;
  1296. X        t = marklist[i].mp_fm.ptr;
  1297. X        if (t > old)
  1298. X            max = i - 1;
  1299. X        else if (t < old)
  1300. X            min = i + 1;
  1301. X    }
  1302. X    if (max == min && marklist[i].mp_fm.ptr == old)
  1303. X    {
  1304. X    }
  1305. X}
  1306. X#endif
  1307. X
  1308. X/*
  1309. X * setmark(c) - set named mark 'c' at current cursor position
  1310. X *
  1311. X * Returns TRUE on success, FALSE if no room for mark or bad name given.
  1312. X */
  1313. X    int
  1314. Xsetmark(c)
  1315. X    int            c;
  1316. X{
  1317. X    int             i;
  1318. X
  1319. X    if (islower(c))
  1320. X    {
  1321. X        i = c - 'a';
  1322. X        namedm[i].ptr = nr2ptr(Curpos.lnum);
  1323. X        namedm[i].col = Curpos.col;
  1324. X        return TRUE;
  1325. X    }
  1326. X    if (isupper(c))
  1327. X    {
  1328. X        i = c - 'A';
  1329. X        namedfm[i].mark.ptr = nr2ptr(Curpos.lnum);
  1330. X        namedfm[i].mark.col = Curpos.col;
  1331. X        namedfm[i].lnum = Curpos.lnum;
  1332. X        namedfm[i].fnum = 0;
  1333. X        return TRUE;
  1334. X    }
  1335. X    return FALSE;
  1336. X}
  1337. X
  1338. X/*
  1339. X * setpcmark() - set the previous context mark to the current position
  1340. X *                 and insert it into the jump list
  1341. X */
  1342. X    void
  1343. Xsetpcmark()
  1344. X{
  1345. X    int i;
  1346. X#ifdef ROTATE
  1347. X    struct filemark tempmark;
  1348. X#endif
  1349. X
  1350. X    pcmark.ptr = nr2ptr(Curpos.lnum);
  1351. X    pcmark.col = Curpos.col;
  1352. X
  1353. X#ifndef ROTATE
  1354. X    /*
  1355. X     * simply add the new entry at the end of the list
  1356. X     */
  1357. X    jumplistidx = jumplistlen;
  1358. X#else
  1359. X    /*
  1360. X     * If last used entry is not at the top, put it at the top by rotating
  1361. X     * the stack until it is (the newer entries will be at the bottom).
  1362. X     * Keep one entry (the last used one) at the top.
  1363. X     */
  1364. X    if (jumplistidx < jumplistlen)
  1365. X        ++jumplistidx;
  1366. X    while (jumplistidx < jumplistlen)
  1367. X    {
  1368. X        tempmark = jumplist[jumplistlen - 1];
  1369. X        for (i = jumplistlen - 1; i > 0; --i)
  1370. X            jumplist[i] = jumplist[i - 1];
  1371. X        jumplist[0] = tempmark;
  1372. X        ++jumplistidx;
  1373. X    }
  1374. X#endif
  1375. X
  1376. X        /* only add new entry if it differs from the last one */
  1377. X    if (jumplistlen == 0 || jumplist[jumplistidx - 1].mark.ptr != pcmark.ptr)
  1378. X    {
  1379. X            /* if jumplist is full: remove oldest entry */
  1380. X        if (++jumplistlen > JUMPLISTSIZE)
  1381. X        {
  1382. X            jumplistlen = JUMPLISTSIZE;
  1383. X            for (i = 1; i < jumplistlen; ++i)
  1384. X                jumplist[i - 1] = jumplist[i];
  1385. X            --jumplistidx;
  1386. X        }
  1387. X
  1388. X        jumplist[jumplistidx].mark = pcmark;
  1389. X        jumplist[jumplistidx].lnum = Curpos.lnum;
  1390. X        jumplist[jumplistidx].fnum = 0;
  1391. X        ++jumplistidx;
  1392. X    }
  1393. X}
  1394. X
  1395. X/*
  1396. X * move "count" positions in the jump list (count may be negative)
  1397. X */
  1398. X    FPOS *
  1399. Xmovemark(count)
  1400. X    int count;
  1401. X{
  1402. X    FPOS        *pos;
  1403. X
  1404. X    if (jumplistlen == 0)            /* nothing to jump to */
  1405. X        return (FPOS *)NULL;
  1406. X
  1407. X    if (jumplistidx + count < 0 || jumplistidx + count >= jumplistlen)
  1408. X        return (FPOS *)NULL;
  1409. X
  1410. X    /*
  1411. X     * if first CTRL-O or CTRL-I command after a jump, add cursor position to list
  1412. X     */
  1413. X    if (jumplistidx == jumplistlen)
  1414. X    {
  1415. X        setpcmark();
  1416. X        --jumplistidx;        /* skip the new entry */
  1417. X    }
  1418. X
  1419. X    jumplistidx += count;
  1420. X    if (jumplist[jumplistidx].mark.ptr == NULL)    /* jump to other file */
  1421. X    {
  1422. X        if (getaltfile(jumplist[jumplistidx].fnum - 1, jumplist[jumplistidx].lnum, FALSE))
  1423. X            return (FPOS *)NULL;
  1424. X        Curpos.col = jumplist[jumplistidx].mark.col;
  1425. X        jumplist[jumplistidx].fnum = 0;
  1426. X        jumplist[jumplistidx].mark.ptr = nr2ptr(Curpos.lnum);
  1427. X        pos = (FPOS *)-1;
  1428. X    }
  1429. X    else
  1430. X        pos = mark2pos(&jumplist[jumplistidx].mark);
  1431. X    return pos;
  1432. X}
  1433. X
  1434. X/*
  1435. X * getmark(c) - find mark for char 'c'
  1436. X *
  1437. X * Return pointer to FPOS if found
  1438. X *        NULL if no such mark.
  1439. X *        -1 if mark is in other file (only if changefile is TRUE)
  1440. X */
  1441. X    FPOS *
  1442. Xgetmark(c, changefile)
  1443. X    int            c;
  1444. X    int            changefile;
  1445. X{
  1446. X    FPOS    *posp;
  1447. X
  1448. X    posp = NULL;
  1449. X    if (c == '\'' || c == '`')            /* previous context mark */
  1450. X        posp = mark2pos(&pcmark);
  1451. X    else if (c == '[')                    /* to start of previous operator */
  1452. X    {
  1453. X        if (startop.lnum > 0 && startop.lnum <= line_count)
  1454. X            posp = &startop;
  1455. X    }
  1456. X    else if (c == ']')                    /* to end of previous operator */
  1457. X    {
  1458. X        if (endop.lnum > 0 && endop.lnum <= line_count)
  1459. X            posp = &endop;
  1460. X    }
  1461. X    else if (islower(c))                /* normal named mark */
  1462. X        posp = mark2pos(&(namedm[c - 'a']));
  1463. X    else if (isupper(c))                /* named file mark */
  1464. X    {
  1465. X        c -= 'A';
  1466. X        posp = mark2pos(&(namedfm[c].mark));
  1467. X        if (posp == NULL && namedfm[c].lnum != 0 && (changefile || samealtfile(namedfm[c].fnum - 1)))
  1468. X        {
  1469. X            if (!getaltfile(namedfm[c].fnum - 1, namedfm[c].lnum, TRUE))
  1470. X            {
  1471. X                Curpos.col = namedfm[c].mark.col;
  1472. X                namedfm[c].fnum = 0;
  1473. X                namedfm[c].mark.ptr = nr2ptr(Curpos.lnum);
  1474. X                posp = (FPOS *)-1;
  1475. X            }
  1476. X        }
  1477. X    }
  1478. X    return posp;
  1479. X}
  1480. X
  1481. X    static FPOS *
  1482. Xmark2pos(markp)
  1483. X    struct mark *markp;
  1484. X{
  1485. X    static FPOS pos;
  1486. X
  1487. X    if (markp->ptr != NULL && (pos.lnum = ptr2nr(markp->ptr, (linenr_t)1)) != 0)
  1488. X    {
  1489. X        pos.col = markp->col;
  1490. X        return (&pos);
  1491. X    }
  1492. X    return (FPOS *)NULL;
  1493. X}
  1494. X
  1495. X/*
  1496. X * clrallmarks() - clear all marks
  1497. X *
  1498. X * Used mainly when trashing the entire buffer during ":e" type commands
  1499. X */
  1500. X    void
  1501. Xclrallmarks()
  1502. X{
  1503. X    static int             i = -1;
  1504. X
  1505. X    if (i == -1)        /* first call ever: initialize */
  1506. X        for (i = 0; i < NMARKS; i++)
  1507. X            namedfm[i].lnum = 0;
  1508. X
  1509. X    for (i = 0; i < NMARKS; i++)
  1510. X    {
  1511. X        namedm[i].ptr = NULL;
  1512. X        namedfm[i].mark.ptr = NULL;
  1513. X    }
  1514. X    pcmark.ptr = NULL;
  1515. X    qf_clrallmarks();
  1516. X    for (i = 0; i < jumplistlen; ++i)
  1517. X        jumplist[i].mark.ptr = NULL;
  1518. X}
  1519. X
  1520. X/*
  1521. X * increment the file number for all filemarks
  1522. X * called when adding a file to the file stack
  1523. X */
  1524. X    void
  1525. Xincrmarks()
  1526. X{
  1527. X    int            i;
  1528. X
  1529. X    for (i = 0; i < NMARKS; i++)
  1530. X        ++namedfm[i].fnum;
  1531. X
  1532. X    for (i = 0; i < jumplistlen; ++i)
  1533. X    {
  1534. X#if 0        /* this would take too much time */
  1535. X        if (jumplist[i].fnum == 0)    /* current file */
  1536. X            jumplist[i].lnum = ptr2nr(jumplist[i].mark.ptr, 1);
  1537. X#endif
  1538. X        ++jumplist[i].fnum;
  1539. X    }
  1540. X}
  1541. X
  1542. X/*
  1543. X * decrement the file number for the filemarks of the current file
  1544. X * called when not adding the current file name to the file stack
  1545. X */
  1546. X    void
  1547. Xdecrmarks()
  1548. X{
  1549. X    int            i;
  1550. X
  1551. X    for (i = 0; i < NMARKS; i++)
  1552. X        if (namedfm[i].fnum == 1)
  1553. X            namedfm[i].fnum = 0;
  1554. X
  1555. X    for (i = 0; i < jumplistlen; ++i)
  1556. X        if (jumplist[i].fnum == 1)
  1557. X            jumplist[i].fnum = 0;
  1558. X}
  1559. X
  1560. X/*
  1561. X * adjustmark: set new ptr for a mark
  1562. X * if new == NULL the mark is effectively deleted
  1563. X * (this is slow: we have to check about 100 pointers!)
  1564. X */
  1565. X   void
  1566. Xadjustmark(old, new)
  1567. X        char *old, *new;
  1568. X{
  1569. X    register int i, j;
  1570. X
  1571. X    for (i = 0; i < NMARKS; ++i)
  1572. X    {
  1573. X        if (namedm[i].ptr == old)
  1574. X            namedm[i].ptr = new;
  1575. X        if (namedfm[i].mark.ptr == old)
  1576. X        {
  1577. X            namedfm[i].mark.ptr = new;
  1578. X            if (new == NULL)
  1579. X                namedfm[i].lnum = 0;        /* delete this mark */
  1580. X        }
  1581. X    }
  1582. X    if (pcmark.ptr == old)
  1583. X        pcmark.ptr = new;
  1584. X    for (i = 0; i < jumplistlen; ++i)
  1585. X        if (jumplist[i].mark.ptr == old)
  1586. X        {
  1587. X            if (new == NULL)                /* delete this mark */
  1588. X            {
  1589. X                --jumplistlen;
  1590. X                if (jumplistidx > jumplistlen)
  1591. X                    --jumplistidx;
  1592. X                for (j = i; j < jumplistlen; ++j)
  1593. X                    jumplist[j] = jumplist[j + 1];
  1594. X            }
  1595. X            else
  1596. X                jumplist[i].mark.ptr = new;
  1597. X        }
  1598. X    qf_adjustmark(old, new);
  1599. X}
  1600. X
  1601. X/*
  1602. X * get name of file from a filemark (use the occasion to update the lnum)
  1603. X */
  1604. X    char *
  1605. Xfm_getname(fmark)
  1606. X    struct filemark *fmark;
  1607. X{
  1608. X    linenr_t    nr;
  1609. X    char        *name;
  1610. X
  1611. X    if (fmark->fnum != 0)                        /* maybe not current file */
  1612. X    {
  1613. X        name = getaltfname(fmark->fnum - 1);
  1614. X        if (name == NULL)
  1615. X            return "-none-";
  1616. X        if (Filename == NULL || fnamecmp(name, Filename) != 0)    /* not current file */
  1617. X            return name;
  1618. X        fmark->fnum = 0;
  1619. X    }
  1620. X    if (fmark->mark.ptr == NULL)
  1621. X    {
  1622. X        if (fmark->lnum <= line_count)                /* safety check */
  1623. X            fmark->mark.ptr = nr2ptr(fmark->lnum);    /* update ptr */
  1624. X    }
  1625. X    else
  1626. X    {
  1627. X        nr = ptr2nr(fmark->mark.ptr, (linenr_t)1);
  1628. X        if (nr != 0)
  1629. X            fmark->lnum = nr;                    /* update lnum */
  1630. X    }
  1631. X    return "-current-";
  1632. X}
  1633. X
  1634. X/*
  1635. X * print the marks (use the occasion to update the line numbers)
  1636. X */
  1637. X    void
  1638. Xdomarks()
  1639. X{
  1640. X    int            i;
  1641. X    char        *name;
  1642. X
  1643. X#ifdef AMIGA
  1644. X    settmode(0);        /* set cooked mode, so output can be halted */
  1645. X#endif
  1646. X    outstrn("\nmark line  file\n");
  1647. X    for (i = 0; i < NMARKS; ++i)
  1648. X    {
  1649. X        if (namedm[i].ptr != NULL)
  1650. X        {
  1651. X            sprintf(IObuff, " %c %5ld\n",
  1652. X                i + 'a',
  1653. X                ptr2nr(namedm[i].ptr, (linenr_t)1));
  1654. X            outstrn(IObuff);
  1655. X        }
  1656. X        flushbuf();
  1657. X    }
  1658. X    for (i = 0; i < NMARKS; ++i)
  1659. X    {
  1660. X        if (namedfm[i].lnum != 0)
  1661. X        {
  1662. X            name = fm_getname(&namedfm[i]);
  1663. X            if (name == NULL)        /* file name not available */
  1664. X                continue;
  1665. X
  1666. X            sprintf(IObuff, " %c %5ld  %s\n",
  1667. X                i + 'A',
  1668. X                namedfm[i].lnum,
  1669. X                name);
  1670. X            outstrn(IObuff);
  1671. X        }
  1672. X        flushbuf();
  1673. X    }
  1674. X#ifdef AMIGA
  1675. X    settmode(1);
  1676. X#endif
  1677. X    wait_return(TRUE);
  1678. X}
  1679. X
  1680. X/*
  1681. X * print the jumplist (use the occasion to update the line numbers)
  1682. X */
  1683. X    void
  1684. Xdojumps()
  1685. X{
  1686. X    int            i;
  1687. X    char        *name;
  1688. X
  1689. X#ifdef AMIGA
  1690. X    settmode(0);        /* set cooked mode, so output can be halted */
  1691. X#endif
  1692. X    outstrn("\n jump line  file\n");
  1693. X    for (i = 0; i < jumplistlen; ++i)
  1694. X    {
  1695. X        if (jumplist[i].lnum != 0)
  1696. X        {
  1697. X            name = fm_getname(&jumplist[i]);
  1698. X            if (name == NULL)        /* file name not available */
  1699. X                continue;
  1700. X
  1701. X            sprintf(IObuff, "%c %2d %5ld  %s\n",
  1702. X                i == jumplistidx ? '>' : ' ',
  1703. X                i + 1,
  1704. X                jumplist[i].lnum,
  1705. X                name);
  1706. X            outstrn(IObuff);
  1707. X        }
  1708. X        flushbuf();
  1709. X    }
  1710. X    if (jumplistidx == jumplistlen)
  1711. X        outstrn(">\n");
  1712. X#ifdef AMIGA
  1713. X    settmode(1);
  1714. X#endif
  1715. X    wait_return(TRUE);
  1716. X}
  1717. END_OF_FILE
  1718. if test 9757 -ne `wc -c <'vim/src/mark.c'`; then
  1719.     echo shar: \"'vim/src/mark.c'\" unpacked with wrong size!
  1720. fi
  1721. chmod +x 'vim/src/mark.c'
  1722. # end of 'vim/src/mark.c'
  1723. fi
  1724. if test -f 'vim/src/quickfix.c' -a "${1}" != "-c" ; then 
  1725.   echo shar: Will not clobber existing file \"'vim/src/quickfix.c'\"
  1726. else
  1727. echo shar: Extracting \"'vim/src/quickfix.c'\" \(9863 characters\)
  1728. sed "s/^X//" >'vim/src/quickfix.c' <<'END_OF_FILE'
  1729. X/* vi:ts=4:sw=4
  1730. X *
  1731. X * VIM - Vi IMproved
  1732. X *
  1733. X * Code Contributions By:    Bram Moolenaar            mool@oce.nl
  1734. X *                            Tim Thompson            twitch!tjt
  1735. X *                            Tony Andrews            onecom!wldrdg!tony 
  1736. X *                            G. R. (Fred) Walter        watmath!watcgl!grwalter 
  1737. X */
  1738. X
  1739. X/*
  1740. X * quickfix.c: functions for quickfix mode, using a file with error messages
  1741. X */
  1742. X
  1743. X#include "vim.h"
  1744. X#include "globals.h"
  1745. X#include "proto.h"
  1746. X#include "param.h"
  1747. X
  1748. Xstatic void qf_free __ARGS((void));
  1749. Xstatic char *qf_types __ARGS((int, int));
  1750. X
  1751. X/*
  1752. X * for each error the next struct is allocated and linked in a list
  1753. X */
  1754. Xstruct qf_line
  1755. X{
  1756. X    struct qf_line    *qf_next;    /* pointer to next error in the list */
  1757. X    struct qf_line    *qf_prev;    /* pointer to previous error in the list */
  1758. X    linenr_t         qf_lnum;    /* line number where the error occurred */
  1759. X    char            *qf_mark;    /* pointer to that line (if != NULL) */
  1760. X    int                 qf_col;    /* column where the error occurred */
  1761. X    int                 qf_nr;        /* error number */
  1762. X    char            *qf_fname;    /* file name where the error occurred */
  1763. X    char            *qf_text;    /* description of the error */
  1764. X    char             qf_cleared;/* set to TRUE if qf_mark has been cleared */
  1765. X    char             qf_type;    /* type of the error (mostly 'E') */
  1766. X    char             qf_valid;    /* valid error message detected */
  1767. X};
  1768. X
  1769. Xstatic struct qf_line *qf_start;        /* pointer to the first error */
  1770. Xstatic struct qf_line *qf_ptr;            /* pointer to the current error */
  1771. X
  1772. Xstatic int    qf_count = 0;        /* number of errors (0 means no error list) */
  1773. Xstatic int    qf_index;            /* current index in the error list */
  1774. Xstatic int    qf_nonevalid;        /* set to TRUE if not a single valid entry found */
  1775. Xstatic int    qf_marksset;        /* set to 1 when qf_mark-s have been set */
  1776. X
  1777. X/*
  1778. X * Read the errorfile into memory, line by line, building the error list.
  1779. X * Return 1 for error, 0 for success.
  1780. X */
  1781. X    int
  1782. Xqf_init()
  1783. X{
  1784. X    char             namebuf[CMDBUFFSIZE + 1];
  1785. X    char            errmsg[CMDBUFFSIZE + 1];
  1786. X    int                col;
  1787. X    char            type;
  1788. X    char            valid;
  1789. X    long            lnum;
  1790. X    int                enr;
  1791. X    FILE            *fd;
  1792. X    struct qf_line    *qfp = NULL;
  1793. X    struct qf_line    *qfprev = NULL;        /* init to make SASC shut up */
  1794. X    char            *pfmt, *fmtstr;
  1795. X#ifdef UTS2
  1796. X    char            *(adr[7]);
  1797. X#else
  1798. X    void            *(adr[7]);
  1799. X#endif
  1800. X    int                adr_cnt = 0;
  1801. X    int                maxlen;
  1802. X    int                i;
  1803. X
  1804. X    if (p_ef == NULL || *p_ef == NUL)
  1805. X    {
  1806. X        emsg(e_errorf);
  1807. X        return 1;
  1808. X    }
  1809. X    if ((fd = fopen(p_ef, "r")) == NULL)
  1810. X    {
  1811. X        emsg(e_openerrf);
  1812. X        return 1;
  1813. X    }
  1814. X    qf_free();
  1815. X    qf_index = 0;
  1816. X    for (i = 0; i < 7; ++i)
  1817. X        adr[i] = NULL;
  1818. X
  1819. X/*
  1820. X * The format string is copied and modified from p_efm to fmtstr.
  1821. X * Only a few % characters are allowed.
  1822. X */
  1823. X        /* get some space to modify the format string into */
  1824. X        /* must be able to do the largest expansion 7 times (7 x 3) */
  1825. X    maxlen = strlen(p_efm) + 25;
  1826. X    fmtstr = (char *)alloc(maxlen);
  1827. X    if (fmtstr == NULL)
  1828. X        goto error2;
  1829. X    for (pfmt = p_efm, i = 0; *pfmt; ++pfmt, ++i)
  1830. X    {
  1831. X        if (pfmt[0] != '%')                /* copy normal character */
  1832. X            fmtstr[i] = pfmt[0];
  1833. X        else
  1834. X        {
  1835. X            fmtstr[i++] = '%';
  1836. X            switch (pfmt[1])
  1837. X            {
  1838. X            case 'f':        /* filename */
  1839. X                    adr[adr_cnt++] = namebuf;
  1840. X
  1841. X            case 'm':        /* message */
  1842. X                    if (pfmt[1] == 'm')
  1843. X                        adr[adr_cnt++] = errmsg;
  1844. X                    fmtstr[i++] = '[';
  1845. X                    fmtstr[i++] = '^';
  1846. X                    if (pfmt[2])
  1847. X                        fmtstr[i++] = pfmt[2];
  1848. X                    else
  1849. X#ifdef MSDOS
  1850. X                        fmtstr[i++] = '\r';
  1851. X#else
  1852. X                        fmtstr[i++] = '\n';
  1853. X#endif
  1854. X                    fmtstr[i] = ']';
  1855. X                    break;
  1856. X            case 'c':        /* column */
  1857. X                    adr[adr_cnt++] = &col;
  1858. X                    fmtstr[i] = 'd';
  1859. X                    break;
  1860. X            case 'l':        /* line */
  1861. X                    adr[adr_cnt++] = &lnum;
  1862. X                    fmtstr[i++] = 'l';
  1863. X                    fmtstr[i] = 'd';
  1864. X                    break;
  1865. X            case 'n':        /* error number */
  1866. X                    adr[adr_cnt++] = &enr;
  1867. X                    fmtstr[i] = 'd';
  1868. X                    break;
  1869. X            case 't':        /* error type */
  1870. X                    adr[adr_cnt++] = &type;
  1871. X                    fmtstr[i] = 'c';
  1872. X                    break;
  1873. X            case '%':        /* %% */
  1874. X            case '*':        /* %*: no assignment */
  1875. X                    fmtstr[i] = pfmt[1];
  1876. X                    break;
  1877. X            default:
  1878. X                    emsg("invalid % in format string");
  1879. X                    goto error2;
  1880. X            }
  1881. X            if (adr_cnt == 7)
  1882. X            {
  1883. X                emsg("too many % in format string");
  1884. X                goto error2;
  1885. X            }
  1886. X            ++pfmt;
  1887. X        }
  1888. X        if (i >= maxlen - 6)
  1889. X        {
  1890. X            emsg("invalid format string");
  1891. X            goto error2;
  1892. X        }
  1893. X    }
  1894. X    fmtstr[i] = NUL;
  1895. X
  1896. X    while (fgets(IObuff, CMDBUFFSIZE, fd) != NULL)
  1897. X    {
  1898. X        if ((qfp = (struct qf_line *)alloc((unsigned)sizeof(struct qf_line))) == NULL)
  1899. X            goto error2;
  1900. X
  1901. X        IObuff[CMDBUFFSIZE] = NUL;    /* for very long lines */
  1902. X        namebuf[0] = NUL;
  1903. X        errmsg[0] = NUL;
  1904. X        lnum = 0;
  1905. X        col = 0;
  1906. X        enr = -1;
  1907. X        type = 0;
  1908. X        valid = TRUE;
  1909. X
  1910. X        if (sscanf(IObuff, fmtstr, adr[0], adr[1], adr[2], adr[3],
  1911. X                                                adr[4], adr[5]) != adr_cnt)
  1912. X        {
  1913. X            namebuf[0] = NUL;            /* something failed, remove file name */
  1914. X            valid = FALSE;
  1915. X            strcpy(errmsg, IObuff);        /* copy whole line to error message */
  1916. X            if ((pfmt = strrchr(errmsg, '\n')) != NULL)
  1917. X                *pfmt = NUL;
  1918. X#ifdef MSDOS
  1919. X            if ((pfmt = strrchr(errmsg, '\r')) != NULL)
  1920. X                *pfmt = NUL;
  1921. X#endif
  1922. X        }
  1923. X
  1924. X        if ((qfp->qf_fname = strsave(namebuf)) == NULL)
  1925. X            goto error1;
  1926. X        if ((qfp->qf_text = strsave(errmsg)) == NULL)
  1927. X        {
  1928. X            free(qfp->qf_fname);
  1929. X            goto error1;
  1930. X        }
  1931. X        qfp->qf_lnum = lnum;
  1932. X        qfp->qf_col = col;
  1933. X        qfp->qf_nr = enr;
  1934. X        qfp->qf_type = type;
  1935. X        qfp->qf_valid = valid;
  1936. X
  1937. X        if (qf_count == 0)        /* first element in the list */
  1938. X        {
  1939. X            qf_start = qfp;
  1940. X            qfp->qf_prev = qfp;    /* first element points to itself */
  1941. X        }
  1942. X        else
  1943. X        {
  1944. X            qfp->qf_prev = qfprev;
  1945. X            qfprev->qf_next = qfp;
  1946. X        }
  1947. X        qfp->qf_next = qfp;        /* last element points to itself */
  1948. X        qfp->qf_mark = NULL;
  1949. X        qfp->qf_cleared = FALSE;
  1950. X        qfprev = qfp;
  1951. X        ++qf_count;
  1952. X        if (qf_index == 0 && qfp->qf_valid)        /* first valid entry */
  1953. X        {
  1954. X            qf_index = qf_count;
  1955. X            qf_ptr = qfp;
  1956. X        }
  1957. X    }
  1958. X    free(fmtstr);
  1959. X    if (!ferror(fd))
  1960. X    {
  1961. X        if (qf_index == 0)        /* no valid entry found */
  1962. X        {
  1963. X            qf_ptr = qf_start;
  1964. X            qf_index = 1;
  1965. X            qf_nonevalid = TRUE;
  1966. X        }
  1967. X        else
  1968. X            qf_nonevalid = FALSE;
  1969. X        fclose(fd);
  1970. X        qf_jump(0);                /* display first error */
  1971. X        return 0;
  1972. X    }
  1973. X    emsg(e_readerrf);
  1974. Xerror1:
  1975. X    free(qfp);
  1976. Xerror2:
  1977. X    fclose(fd);
  1978. X    qf_free();
  1979. X    return 1;
  1980. X}
  1981. X
  1982. X/*
  1983. X * jump to quickfix line "errornr"; if "errornr" is zero, redisplay the same line
  1984. X */
  1985. X    void
  1986. Xqf_jump(errornr)
  1987. X    int errornr;
  1988. X{
  1989. X    struct qf_line *qfp;
  1990. X    linenr_t        i;
  1991. X    char            *msgp;
  1992. X
  1993. X    if (qf_count == 0)
  1994. X    {
  1995. X        emsg(e_quickfix);
  1996. X        return;
  1997. X    }
  1998. X
  1999. X    if (errornr == -1)        /* next valid entry */
  2000. X    {
  2001. X        do
  2002. X        {
  2003. X            if (qf_index == qf_count)
  2004. X                break;
  2005. X            ++qf_index;
  2006. X            qf_ptr = qf_ptr->qf_next;
  2007. X        } while (!qf_nonevalid && !qf_ptr->qf_valid);
  2008. X    }
  2009. X    else if (errornr == -2)        /* previous valid entry */
  2010. X    {
  2011. X        do
  2012. X        {
  2013. X            if (qf_index == 1)
  2014. X                break;
  2015. X            --qf_index;
  2016. X            qf_ptr = qf_ptr->qf_prev;
  2017. X        } while (!qf_nonevalid && !qf_ptr->qf_valid);
  2018. X    }
  2019. X    else if (errornr != 0)        /* go to specified number */
  2020. X    {
  2021. X        while (errornr < qf_index && qf_index > 1)
  2022. X        {
  2023. X            --qf_index;
  2024. X            qf_ptr = qf_ptr->qf_prev;
  2025. X        }
  2026. X        while (errornr > qf_index && qf_index < qf_count)
  2027. X        {
  2028. X            ++qf_index;
  2029. X            qf_ptr = qf_ptr->qf_next;
  2030. X        }
  2031. X    }
  2032. X
  2033. X    /*
  2034. X     * If there is a file name, 
  2035. X     * read the wanted file if needed, and check autowrite etc.
  2036. X     */
  2037. X    if (qf_ptr->qf_fname[0] == NUL || getfile(qf_ptr->qf_fname, NULL, TRUE) <= 0)
  2038. X    {
  2039. X        /*
  2040. X         * Use mark if possible, because the line number may be invalid
  2041. X         * after line inserts / deletes.
  2042. X         * If qf_lnum is 0, stay on the same line.
  2043. X         */
  2044. X        i = 0;
  2045. X        msgp = "";
  2046. X        if ((qf_ptr->qf_mark != NULL && (i = ptr2nr(qf_ptr->qf_mark, (linenr_t)0)) == 0) || qf_ptr->qf_cleared)
  2047. X            msgp = "(line changed) ";
  2048. X        if (i == 0)
  2049. X            i = qf_ptr->qf_lnum;
  2050. X        if (i > line_count)
  2051. X            i = line_count;
  2052. X        if (i > 0)
  2053. X            Curpos.lnum = i;
  2054. X        Curpos.col = qf_ptr->qf_col;
  2055. X        adjustCurpos();
  2056. X        cursupdate();
  2057. X        smsg("(%d of %d) %s%s: %s", qf_index, qf_count, msgp,
  2058. X                    qf_types(qf_ptr->qf_type, qf_ptr->qf_nr), qf_ptr->qf_text);
  2059. X
  2060. X        if (!qf_marksset)        /* marks not set yet: try to find them for
  2061. X                                    the errors in the curren file */
  2062. X        {
  2063. X            for (i = 0, qfp = qf_start; i < qf_count; ++i, qfp = qfp->qf_next)
  2064. X                if (qfp->qf_fname != NUL && strcmp(qfp->qf_fname, qf_ptr->qf_fname) == 0 && qfp->qf_lnum <= line_count && qfp->qf_lnum > 0)
  2065. X                    qfp->qf_mark = nr2ptr(qfp->qf_lnum);
  2066. X            qf_marksset = 1;
  2067. X        }
  2068. X    }
  2069. X}
  2070. X
  2071. X/*
  2072. X * list all errors
  2073. X */
  2074. X    void
  2075. Xqf_list()
  2076. X{
  2077. X    struct qf_line *qfp;
  2078. X    int i;
  2079. X
  2080. X    if (qf_count == 0)
  2081. X    {
  2082. X        emsg(e_quickfix);
  2083. X        return;
  2084. X    }
  2085. X    qfp = qf_start;
  2086. X    gotocmdline(TRUE, NUL);
  2087. X#ifdef AMIGA
  2088. X    settmode(0);        /* set cooked mode so output can be halted */
  2089. X#endif
  2090. X    for (i = 1; i <= qf_count; ++i)
  2091. X    {
  2092. X        sprintf(IObuff, "%2d line %3ld col %2d %s: %s",
  2093. X            i,
  2094. X            (long)qfp->qf_lnum,
  2095. X            qfp->qf_col,
  2096. X            qf_types(qfp->qf_type, qfp->qf_nr),
  2097. X            qfp->qf_text);
  2098. X        outstr(IObuff);
  2099. X        outchar('\n');
  2100. X        qfp = qfp->qf_next;
  2101. X        flushbuf();
  2102. X    }
  2103. X#ifdef AMIGA
  2104. X    settmode(1);
  2105. X#endif
  2106. X    wait_return(TRUE);
  2107. X}
  2108. X
  2109. X/*
  2110. X * free the error list
  2111. X */
  2112. X    static void
  2113. Xqf_free()
  2114. X{
  2115. X    struct qf_line *qfp;
  2116. X
  2117. X    while (qf_count)
  2118. X    {
  2119. X        qfp = qf_start->qf_next;
  2120. X        free(qf_start->qf_fname);
  2121. X        free(qf_start->qf_text);
  2122. X        free(qf_start);
  2123. X        qf_start = qfp;
  2124. X        --qf_count;
  2125. X    }
  2126. X    qf_marksset = 0;
  2127. X}
  2128. X
  2129. X/*
  2130. X * qf_clrallmarks() - clear all marks
  2131. X *
  2132. X * Used mainly when trashing the entire buffer during ":e" type commands
  2133. X */
  2134. X    void
  2135. Xqf_clrallmarks()
  2136. X{
  2137. X    int             i;
  2138. X    struct qf_line *qfp;
  2139. X
  2140. X    if (qf_count)
  2141. X        for (i = 0, qfp = qf_start; i < qf_count; i++, qfp = qfp->qf_next)
  2142. X            qfp->qf_mark = NULL;
  2143. X    qf_marksset = 0;
  2144. X}
  2145. X
  2146. X/*
  2147. X * qf_adjustmark: set new ptr for a mark
  2148. X */
  2149. X   void
  2150. Xqf_adjustmark(old, new)
  2151. X    char        *old, *new;
  2152. X{
  2153. X    register int i;
  2154. X    struct qf_line *qfp;
  2155. X
  2156. X    if (qf_count)
  2157. X    {
  2158. X        for (i = 0, qfp = qf_start; i < qf_count; ++i, qfp = qfp->qf_next)
  2159. X            if (qfp->qf_mark == old)
  2160. X            {
  2161. X                qfp->qf_mark = new;
  2162. X                if (new == NULL)
  2163. X                    qfp->qf_cleared = TRUE;
  2164. X            }
  2165. X    }
  2166. X}
  2167. X
  2168. X/*
  2169. X * Make a nice message out of the error character and the error number:
  2170. X *    char    number        message
  2171. X *  e or E    0            "  Error"
  2172. X *  w or W    0            "Warning"
  2173. X *  other     0             ""
  2174. X *  w or W    n            "Warning n"
  2175. X *  other     n            "  Error n"
  2176. X */
  2177. X    static char *
  2178. Xqf_types(c, nr)
  2179. X    int c, nr;
  2180. X{
  2181. X    static char    buf[20];
  2182. X    char        *p1;
  2183. X
  2184. X    p1 = "  Error";
  2185. X    if (c == 'W' || c == 'w')
  2186. X        p1 =  "Warning";
  2187. X    else if (nr <= 0 && c != 'E' && c != 'e')
  2188. X        p1 = "";
  2189. X
  2190. X    if (nr <= 0)
  2191. X        return p1;
  2192. X
  2193. X    sprintf(buf, "%s %3d", p1, nr);
  2194. X    return buf;
  2195. X}
  2196. END_OF_FILE
  2197. if test 9863 -ne `wc -c <'vim/src/quickfix.c'`; then
  2198.     echo shar: \"'vim/src/quickfix.c'\" unpacked with wrong size!
  2199. fi
  2200. chmod +x 'vim/src/quickfix.c'
  2201. # end of 'vim/src/quickfix.c'
  2202. fi
  2203. echo shar: End of archive 5 \(of 25\).
  2204. cp /dev/null ark5isdone
  2205. MISSING=""
  2206. 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 ; do
  2207.     if test ! -f ark${I}isdone ; then
  2208.     MISSING="${MISSING} ${I}"
  2209.     fi
  2210. done
  2211. if test "${MISSING}" = "" ; then
  2212.     echo You have unpacked all 25 archives.
  2213.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2214. else
  2215.     echo You still need to unpack the following archives:
  2216.     echo "        " ${MISSING}
  2217. fi
  2218. ##  End of shell archive.
  2219. exit 0
  2220.  
  2221. ===============================================================================
  2222. Bram Moolenaar                             | DISCLAIMER:  This  note  does  not
  2223. Oce Nederland B.V., Research & Development | necessarily represent the position
  2224. p.o. box 101, 5900 MA  Venlo               | of  Oce-Nederland  B.V.  Therefore
  2225. The Netherlands        phone +31 77 594077 | no liability or responsibility for
  2226. UUCP: mool@oce.nl        fax +31 77 595473 | whatever will be accepted.
  2227.  
  2228. exit 0 # Just in case...
  2229.