diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-02-22 08:39:57 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-02-22 08:39:57 +0000 |
commit | df177f679e950a2ab2ad5fe7d45c1daface004d7 (patch) | |
tree | 21c0c50e9144ef873af675daf53b86beb26dd677 /src | |
parent | 6bdcfc08cb9c192972336e28a2a842b7abbb2811 (diff) |
updated for version 7.0051
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 6 | ||||
-rw-r--r-- | src/ex_docmd.c | 362 | ||||
-rw-r--r-- | src/fileio.c | 18 | ||||
-rw-r--r-- | src/globals.h | 11 | ||||
-rw-r--r-- | src/mbyte.c | 9 | ||||
-rw-r--r-- | src/message.c | 38 | ||||
-rw-r--r-- | src/netbeans.c | 14 | ||||
-rw-r--r-- | src/normal.c | 8 | ||||
-rw-r--r-- | src/os_unix.c | 335 | ||||
-rw-r--r-- | src/po/Make_ming.mak | 4 | ||||
-rw-r--r-- | src/po/Makefile | 4 | ||||
-rw-r--r-- | src/proto/ex_docmd.pro | 1 | ||||
-rw-r--r-- | src/proto/gui_mac.pro | 1 | ||||
-rw-r--r-- | src/proto/main.pro | 2 | ||||
-rw-r--r-- | src/proto/message.pro | 3 | ||||
-rw-r--r-- | src/quickfix.c | 13 | ||||
-rw-r--r-- | src/regexp.c | 407 | ||||
-rw-r--r-- | src/testdir/test11.in | 1 | ||||
-rw-r--r-- | src/vim.h | 9 |
19 files changed, 965 insertions, 281 deletions
diff --git a/src/Makefile b/src/Makefile index b2dc0153fc..0ea38f70b4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -505,6 +505,7 @@ CClink = $(CC) # Often used for GCC: mixed optimizing, lot of optimizing, debugging #CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes #CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wmissing-prototypes +#CFLAGS = -g -Wall -Wmissing-prototypes #CFLAGS = -O6 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes #CFLAGS = -g -DDEBUG -Wall -Wshadow -Wmissing-prototypes #CFLAGS = -g -O2 '-DSTARTUPTIME="vimstartup"' -fno-strength-reduce -Wall -Wmissing-prototypes @@ -2410,6 +2411,11 @@ $(APPDIR): bundle-dir bundle-executable bundle-info bundle-resource \ bundle-dir: $(APPDIR)/Contents $(VIMTARGET) -@srcdir=`pwd`; cd $(HELPSOURCE); $(MAKE) VIMEXE=$$srcdir/$(VIMTARGET) vimtags cp -R ../runtime $(APPDIR) +# When using CVS some CVS directories might have been copied. + cvs=`find $(APPDIR) \( -name CVS -o -name AAPDIR \) -print`; \ + if test -n "$$cvs"; then \ + rm -rf $$cvs; \ + fi bundle-executable: $(VIMTARGET) cp $(VIMTARGET) $(APPDIR)/Contents/MacOS/$(VIMTARGET) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index d2e933af46..2bb5aeb2fc 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -128,6 +128,7 @@ static int getargopt __ARGS((exarg_T *eap)); static int check_more __ARGS((int, int)); static linenr_T get_address __ARGS((char_u **, int skip, int to_other_file)); +static void get_flags __ARGS((exarg_T *eap)); #if !defined(FEAT_PERL) || !defined(FEAT_PYTHON) || !defined(FEAT_TCL) \ || !defined(FEAT_RUBY) || !defined(FEAT_MZSCHEME) static void ex_script_ni __ARGS((exarg_T *eap)); @@ -185,6 +186,7 @@ static void ex_recover __ARGS((exarg_T *eap)); static void ex_mode __ARGS((exarg_T *eap)); static void ex_wrongmodifier __ARGS((exarg_T *eap)); static void ex_find __ARGS((exarg_T *eap)); +static void ex_open __ARGS((exarg_T *eap)); static void ex_edit __ARGS((exarg_T *eap)); #if !defined(FEAT_GUI) && !defined(FEAT_CLIENTSERVER) # define ex_drop ex_ni @@ -271,6 +273,7 @@ static void ex_winpos __ARGS((exarg_T *eap)); static void ex_operators __ARGS((exarg_T *eap)); static void ex_put __ARGS((exarg_T *eap)); static void ex_copymove __ARGS((exarg_T *eap)); +static void ex_may_print __ARGS((exarg_T *eap)); static void ex_submagic __ARGS((exarg_T *eap)); static void ex_join __ARGS((exarg_T *eap)); static void ex_at __ARGS((exarg_T *eap)); @@ -570,19 +573,22 @@ do_exmode(improved) int save_msg_scroll; int prev_msg_row; linenr_T prev_line; + int changedtick; - save_msg_scroll = msg_scroll; - ++RedrawingDisabled; /* don't redisplay the window */ - ++no_wait_return; /* don't wait for return */ if (improved) exmode_active = EXMODE_VIM; else - { - settmode(TMODE_COOK); exmode_active = EXMODE_NORMAL; - } - State = NORMAL; + + /* When using ":global /pat/ visual" and then "Q" we return to continue + * the :global command. */ + if (global_busy) + return; + + save_msg_scroll = msg_scroll; + ++RedrawingDisabled; /* don't redisplay the window */ + ++no_wait_return; /* don't wait for return */ #ifdef FEAT_GUI /* Ignore scrollbar and mouse events in Ex mode */ ++hold_gui_events; @@ -606,6 +612,7 @@ do_exmode(improved) need_wait_return = FALSE; ex_pressedreturn = FALSE; ex_no_reprint = FALSE; + changedtick = curbuf->b_changedtick; prev_msg_row = msg_row; prev_line = curwin->w_cursor.lnum; #ifdef FEAT_SNIFF @@ -620,29 +627,38 @@ do_exmode(improved) do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); lines_left = Rows - 1; - if (prev_line != curwin->w_cursor.lnum && !ex_no_reprint) + if ((prev_line != curwin->w_cursor.lnum + || changedtick != curbuf->b_changedtick) && !ex_no_reprint) { - if (ex_pressedreturn) + if (curbuf->b_ml.ml_flags & ML_EMPTY) + EMSG(_(e_emptybuf)); + else { - /* go up one line, to overwrite the ":<CR>" line, so the - * output doensn't contain empty lines. */ - msg_row = prev_msg_row; - if (prev_msg_row == Rows - 1) - msg_row--; + if (ex_pressedreturn) + { + /* go up one line, to overwrite the ":<CR>" line, so the + * output doensn't contain empty lines. */ + msg_row = prev_msg_row; + if (prev_msg_row == Rows - 1) + msg_row--; + } + msg_col = 0; + print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); + msg_clr_eos(); } - msg_col = 0; - print_line_no_prefix(curwin->w_cursor.lnum, FALSE); - msg_clr_eos(); } - else if (ex_pressedreturn) /* must be at EOF */ - EMSG(_("E501: At end-of-file")); + else if (ex_pressedreturn && !ex_no_reprint) /* must be at EOF */ + { + if (curbuf->b_ml.ml_flags & ML_EMPTY) + EMSG(_(e_emptybuf)); + else + EMSG(_("E501: At end-of-file")); + } } #ifdef FEAT_GUI --hold_gui_events; #endif - if (!improved) - settmode(TMODE_RAW); --RedrawingDisabled; --no_wait_return; update_screen(CLEAR); @@ -1663,7 +1679,8 @@ do_one_cmd(cmdlinep, sourcing, /* in ex mode, an empty line works like :+ */ if (*ea.cmd == NUL && exmode_active && (getline_equal(getline, cookie, getexmodeline) - || getline_equal(getline, cookie, getexline))) + || getline_equal(getline, cookie, getexline)) + && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { ea.cmd = (char_u *)"+"; ex_pressedreturn = TRUE; @@ -1671,7 +1688,10 @@ do_one_cmd(cmdlinep, sourcing, /* ignore comment and empty lines */ if (*ea.cmd == '"' || *ea.cmd == NUL) + { + ex_pressedreturn = TRUE; goto doend; + } /* * 2. handle command modifiers. @@ -1936,7 +1956,7 @@ do_one_cmd(cmdlinep, sourcing, */ if (ea.skip) /* skip this if inside :if */ goto doend; - if (*ea.cmd == '|') + if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) { ea.cmdidx = CMD_print; ea.argt = RANGE+COUNT+TRLBAR; @@ -1948,14 +1968,12 @@ do_one_cmd(cmdlinep, sourcing, } else if (ea.addr_count != 0) { - if (ea.line2 < 0) - errormsg = invalid_range(&ea); + if (ea.line2 < 0 || ea.line2 > curbuf->b_ml.ml_line_count) + errormsg = (char_u *)_(e_invrange); else { if (ea.line2 == 0) curwin->w_cursor.lnum = 1; - else if (ea.line2 > curbuf->b_ml.ml_line_count) - curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; else curwin->w_cursor.lnum = ea.line2; beginline(BL_SOL | BL_FIX); @@ -2090,7 +2108,7 @@ do_one_cmd(cmdlinep, sourcing, */ if (!global_busy && ea.line1 > ea.line2) { - if (sourcing) + if (sourcing || exmode_active) { errormsg = (char_u *)_("E493: Backwards range given"); goto doend; @@ -2280,9 +2298,13 @@ do_one_cmd(cmdlinep, sourcing, /* * Check for <newline> to end a shell command. - * Also do this for ":read !cmd" and ":write !cmd". + * Also do this for ":read !cmd", ":write !cmd" and ":global". + * Any others? */ - else if (ea.cmdidx == CMD_bang || ea.usefilter) + else if (ea.cmdidx == CMD_bang + || ea.cmdidx == CMD_global + || ea.cmdidx == CMD_vglobal + || ea.usefilter) { for (p = ea.arg; *p; ++p) { @@ -2367,6 +2389,12 @@ do_one_cmd(cmdlinep, sourcing, ea.line2 = curbuf->b_ml.ml_line_count; } } + + /* + * Check for flags: 'l', 'p' and '#'. + */ + if (ea.argt & EXFLAGS) + get_flags(&ea); /* no arguments allowed */ if (!ni && !(ea.argt & EXTRA) && *ea.arg != NUL && vim_strchr((char_u *)"|\"", *ea.arg) == NULL) @@ -2661,6 +2689,7 @@ find_command(eap, full) { int len; char_u *p; + int i; /* * Isolate the command and search for it in the command table. @@ -2669,6 +2698,7 @@ find_command(eap, full) * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' * but :sre[wind] is another command, as are :scrip[tnames], * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. + * - the "d" command can directly be followed by 'l' or 'p' flag. */ p = eap->cmd; if (*p == 'k') @@ -2694,6 +2724,22 @@ find_command(eap, full) if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) ++p; len = (int)(p - eap->cmd); + if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) + { + /* Check for ":dl", ":dell", etc. to ":deletel": that's + * :delete with the 'l' flag. Same for 'p'. */ + for (i = 0; i < len; ++i) + if (eap->cmd[i] != "delete"[i]) + break; + if (i == len - 1) + { + --len; + if (p[-1] == 'l') + eap->flags |= EXFLAG_LIST; + else + eap->flags |= EXFLAG_PRINT; + } + } if (ASCII_ISLOWER(*eap->cmd)) eap->cmdidx = cmdidxs[CharOrdLow(*eap->cmd)]; @@ -2928,8 +2974,6 @@ set_one_cmd_context(xp, buff) /* * 4. parse command */ - - cmd = skipwhite(cmd); xp->xp_pattern = cmd; if (*cmd == NUL) return NULL; @@ -3281,6 +3325,7 @@ set_one_cmd_context(xp, buff) case CMD_botright: case CMD_browse: case CMD_confirm: + case CMD_debug: case CMD_folddoclosed: case CMD_folddoopen: case CMD_hide: @@ -3633,6 +3678,7 @@ set_one_cmd_context(xp, buff) * Backslashed delimiters after / or ? will be skipped, and commands will * not be expanded between /'s and ?'s or after "'". * + * Also skip white space and ":" characters. * Returns the "cmd" pointer advanced to beyond the range. */ char_u * @@ -3642,8 +3688,7 @@ skip_range(cmd, ctx) { int delim; - while (*cmd != NUL && (vim_isspace(*cmd) || VIM_ISDIGIT(*cmd) || - vim_strchr((char_u *)".$%'/?-+,;", *cmd) != NULL)) + while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL) { if (*cmd == '\'') { @@ -3662,6 +3707,11 @@ skip_range(cmd, ctx) if (*cmd != NUL) ++cmd; } + + /* Skip ":" and white space. */ + while (*cmd == ':') + cmd = skipwhite(cmd + 1); + return cmd; } @@ -3856,6 +3906,25 @@ error: } /* + * Get flags from an Ex command argument. + */ + static void +get_flags(eap) + exarg_T *eap; +{ + while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) + { + if (*eap->arg == 'l') + eap->flags |= EXFLAG_LIST; + else if (*eap->arg == 'p') + eap->flags |= EXFLAG_PRINT; + else + eap->flags |= EXFLAG_NR; + eap->arg = skipwhite(eap->arg + 1); + } +} + +/* * Function called for command which is Not Implemented. NI! */ void @@ -4280,7 +4349,7 @@ separate_nextcmd(eap) #ifdef FEAT_EVAL /* Skip over `=expr` when wildcards are expanded. */ - else if (p[0] == '`' && p[1] == '=') + else if (p[0] == '`' && p[1] == '=' && (eap->argt & XFILE)) { p += 2; (void)skip_expr(&p); @@ -6116,31 +6185,27 @@ ex_exit(eap) ex_print(eap) exarg_T *eap; { - int save_list = 0; /* init for GCC */ - - if (eap->cmdidx == CMD_list) + if (curbuf->b_ml.ml_flags & ML_EMPTY) + EMSG(_(e_emptybuf)); + else { - save_list = curwin->w_p_list; - curwin->w_p_list = 1; + for ( ;!got_int; ui_breakcheck()) + { + print_line(eap->line1, + (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound + || (eap->flags & EXFLAG_NR)), + eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); + if (++eap->line1 > eap->line2) + break; + out_flush(); /* show one line at a time */ + } + setpcmark(); + /* put cursor at last line */ + curwin->w_cursor.lnum = eap->line2; + beginline(BL_SOL | BL_FIX); } - for ( ;!got_int; ui_breakcheck()) - { - print_line(eap->line1, - (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound)); - if (++eap->line1 > eap->line2) - break; - out_flush(); /* show one line at a time */ - } - setpcmark(); - /* put cursor at last line */ - curwin->w_cursor.lnum = eap->line2; - beginline(BL_SOL | BL_FIX); - ex_no_reprint = TRUE; - - if (eap->cmdidx == CMD_list) - curwin->w_p_list = save_list; } #ifdef FEAT_BYTEOFF @@ -6689,7 +6754,45 @@ ex_find(eap) } /* - * ":edit", ":badd". + * ":open" simulation: for now just work like ":visual". + */ + static void +ex_open(eap) + exarg_T *eap; +{ + regmatch_T regmatch; + char_u *p; + + curwin->w_cursor.lnum = eap->line2; + beginline(BL_SOL | BL_FIX); + if (*eap->arg == '/') + { + /* ":open /pattern/": put cursor in column found with pattern */ + ++eap->arg; + p = skip_regexp(eap->arg, '/', p_magic, NULL); + *p = NUL; + regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); + if (regmatch.regprog != NULL) + { + regmatch.rm_ic = p_ic; + p = ml_get_curline(); + if (vim_regexec(®match, p, (colnr_T)0)) + curwin->w_cursor.col = regmatch.startp[0] - p; + else + EMSG(_(e_nomatch)); + vim_free(regmatch.regprog); + } + /* Move to the NUL, ignore any other arguments. */ + eap->arg += STRLEN(eap->arg); + } + check_cursor(); + + eap->cmdidx = CMD_visual; + do_exedit(eap, NULL); +} + +/* + * ":edit", ":badd", ":visual". */ static void ex_edit(eap) @@ -6711,6 +6814,7 @@ do_exedit(eap, old_curwin) #ifdef FEAT_WINDOWS int need_hide; #endif + int exmode_was = exmode_active; /* * ":vi" command ends Ex mode. @@ -6720,7 +6824,45 @@ do_exedit(eap, old_curwin) { exmode_active = FALSE; if (*eap->arg == NUL) + { + /* Special case: ":global/pat/visual\NLvi-commands" */ + if (global_busy) + { + int rd = RedrawingDisabled; + int nwr = no_wait_return; + int ms = msg_scroll; +#ifdef FEAT_GUI + int he = hold_gui_events; +#endif + + if (eap->nextcmd != NULL) + { + stuffReadbuff(eap->nextcmd); + eap->nextcmd = NULL; + } + + if (exmode_was != EXMODE_VIM) + settmode(TMODE_RAW); + RedrawingDisabled = 0; + no_wait_return = 0; + need_wait_return = FALSE; + msg_scroll = 0; +#ifdef FEAT_GUI + hold_gui_events = 0; +#endif + must_redraw = CLEAR; + + main_loop(FALSE, TRUE); + + RedrawingDisabled = rd; + no_wait_return = nwr; + msg_scroll = ms; +#ifdef FEAT_GUI + hold_gui_events = he; +#endif + } return; + } } if ((eap->cmdidx == CMD_new @@ -6961,7 +7103,9 @@ ex_syncbind(eap) ex_read(eap) exarg_T *eap; { - int i; + int i; + int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); + linenr_T lnum; if (eap->usefilter) /* :r!cmd */ do_bang(1, eap, FALSE, FALSE, TRUE); @@ -7011,7 +7155,25 @@ ex_read(eap) EMSG2(_(e_notopen), eap->arg); } else + { + if (empty && exmode_active) + { + /* Delete the empty line that remains. Historically ex does + * this but vi doesn't. */ + if (eap->line2 == 0) + lnum = curbuf->b_ml.ml_line_count; + else + lnum = 1; + if (*ml_get(lnum) == NUL) + { + ml_delete(lnum, FALSE); + deleted_lines_mark(lnum, 1L); + if (curwin->w_cursor.lnum >= lnum) + --curwin->w_cursor.lnum; + } + } redraw_curbuf_later(VALID); + } } } @@ -7034,6 +7196,13 @@ ex_cd(eap) else #endif { + if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged() + && !eap->forceit) + { + EMSG(_("E747: Cannot change directory, buffer is modifed (add ! to override)")); + return; + } + /* ":cd -": Change to previous directory */ if (STRCMP(new_dir, "-") == 0) { @@ -7132,6 +7301,7 @@ ex_equal(eap) exarg_T *eap; { smsg((char_u *)"%ld", (long)eap->line2); + ex_may_print(eap); } static void @@ -7361,6 +7531,7 @@ ex_operators(eap) #ifdef FEAT_VIRTUALEDIT virtual_op = MAYBE; #endif + ex_may_print(eap); } /* @@ -7377,7 +7548,8 @@ ex_put(eap) eap->forceit = TRUE; } curwin->w_cursor.lnum = eap->line2; - do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, PUT_LINE); + do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, + PUT_LINE|PUT_CURSLINE); } /* @@ -7395,6 +7567,7 @@ ex_copymove(eap) eap->nextcmd = NULL; return; } + get_flags(eap); /* * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' @@ -7414,6 +7587,22 @@ ex_copymove(eap) ex_copy(eap->line1, eap->line2, n); u_clearline(); beginline(BL_SOL | BL_FIX); + ex_may_print(eap); +} + +/* + * Print the current line if flags were given to the Ex command. + */ + static void +ex_may_print(eap) + exarg_T *eap; +{ + if (eap->flags != 0) + { + print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), + (eap->flags & EXFLAG_LIST)); + ex_no_reprint = TRUE; + } } /* @@ -7451,6 +7640,7 @@ ex_join(eap) } do_do_join(eap->line2 - eap->line1 + 1, !eap->forceit); beginline(BL_WHITE | BL_FIX); + ex_may_print(eap); } /* @@ -7474,7 +7664,9 @@ ex_at(eap) c = '@'; /* put the register in mapbuf */ if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL) == FAIL) + { beep_flush(); + } else { int save_efr = exec_from_reg; @@ -7602,18 +7794,36 @@ ex_redir(eap) /* make register empty */ write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); } - if (*arg != NUL) - EMSG2(_(e_invarg2), eap->arg); } - else + if (*arg != NUL) + { EMSG2(_(e_invarg2), eap->arg); + redir_reg = 0; + } + } + else if (*arg == '=' && arg[1] == '>') + { + int append; + + /* redirect to a variable */ + close_redir(); + arg += 2; + + if (*arg == '>') + { + ++arg; + append = TRUE; + } + else + append = FALSE; + + if (var_redir_start(skipwhite(arg), append) == OK) + redir_vname = 1; } #endif /* TODO: redirect to a buffer */ - /* TODO: redirect to an internal variable */ - else EMSG2(_(e_invarg2), eap->arg); } @@ -7690,6 +7900,11 @@ close_redir() } #ifdef FEAT_EVAL redir_reg = 0; + if (redir_vname) + { + var_redir_stop(); + redir_vname = 0; + } #endif } @@ -7774,8 +7989,7 @@ ex_mkrc(eap) #if defined(FEAT_SESSION) && defined(vim_mkdir) /* When using 'viewdir' may have to create the directory. */ if (using_vdir && !mch_isdir(p_vdir)) - if (vim_mkdir(p_vdir, 0755) != 0) - EMSG2(_("E739: Cannot create directory: %s"), p_vdir); + vim_mkdir_emsg(p_vdir, 0755); #endif fd = open_exfile(fname, eap->forceit, WRITEBIN); @@ -7893,6 +8107,22 @@ theend: #endif } +#if ((defined(FEAT_SESSION) || defined(FEAT_EVAL)) && defined(vim_mkdir)) \ + || defined(PROTO) + int +vim_mkdir_emsg(name, prot) + char_u *name; + int prot; +{ + if (vim_mkdir(name, prot) != 0) + { + EMSG2(_("E739: Cannot create directory: %s"), name); + return FAIL; + } + return OK; +} +#endif + /* * Open a file for writing for an Ex command, with some checks. * Return file descriptor, or NULL on failure. diff --git a/src/fileio.c b/src/fileio.c index 9dd1d49752..0644688705 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -140,10 +140,6 @@ static int get_mac_fio_flags __ARGS((char_u *ptr)); #endif static int move_lines __ARGS((buf_T *frombuf, buf_T *tobuf)); -static linenr_T write_no_eol_lnum = 0; /* non-zero lnum when last line of - next binary write should not have - an end-of-line */ - void filemess(buf, name, s, attr) buf_T *buf; @@ -288,9 +284,7 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags) int conv_restlen = 0; /* nr of bytes in conv_rest[] */ #endif -#ifdef FEAT_AUTOCMD write_no_eol_lnum = 0; /* in case it was set by the previous read */ -#endif /* * If there is no file name yet, use the one for the read file. @@ -308,6 +302,10 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags) curbuf->b_flags |= BF_NOTEDITED; } + /* After reading a file the cursor line changes but we don't want to + * display the line. */ + ex_no_reprint = TRUE; + /* * For Unix: Use the short file name whenever possible. * Avoids problems with networks and when directory names are changed. @@ -2230,7 +2228,6 @@ failed: check_marks_read(); #endif -#ifdef FEAT_AUTOCMD /* * Trick: We remember if the last line of the read didn't have * an eol for when writing it again. This is required for @@ -2238,6 +2235,7 @@ failed: */ write_no_eol_lnum = read_no_eol_lnum; +#ifdef FEAT_AUTOCMD if (!read_stdin && !read_buffer) { int m = msg_scroll; @@ -2628,6 +2626,10 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit, # endif #endif + /* After writing a file changedtick changes but we don't want to display + * the line. */ + ex_no_reprint = TRUE; + /* * If there is no file name yet, use the one for the written file. * BF_NOTEDITED is set to reflect this (in case the write fails). @@ -6267,7 +6269,7 @@ buf_store_time(buf, st, fname) write_lnum_adjust(offset) linenr_T offset; { - if (write_no_eol_lnum) /* only if there is a missing eol */ + if (write_no_eol_lnum != 0) /* only if there is a missing eol */ write_no_eol_lnum += offset; } diff --git a/src/globals.h b/src/globals.h index 1df8b87fe0..2c1c53a3dd 100644 --- a/src/globals.h +++ b/src/globals.h @@ -155,6 +155,7 @@ EXTERN int did_endif INIT(= FALSE); /* just had ":endif" */ EXTERN int did_emsg; /* set by emsg() when the message is displayed or thrown */ EXTERN int called_emsg; /* always set by emsg() */ +EXTERN int ex_exitval INIT(= 0); /* exit value for ex mode */ EXTERN int emsg_on_display INIT(= FALSE); /* there is an error message */ EXTERN int rc_did_emsg INIT(= FALSE); /* vim_regcomp() called emsg() */ @@ -181,6 +182,7 @@ EXTERN int x_force_connect INIT(= FALSE); /* Do connect to X server. "exclude" in 'clipboard'. */ # endif #endif +EXTERN int ex_keep_indent INIT(= FALSE); /* getexmodeline(): keep indent */ EXTERN int vgetc_busy INIT(= FALSE); /* inside vgetc() now */ EXTERN int didset_vim INIT(= FALSE); /* did set $VIM ourselves */ @@ -927,6 +929,10 @@ EXTERN int autocmd_bufnr INIT(= 0); /* fnum for <abuf> on cmdline */ EXTERN char_u *autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */ #endif +EXTERN linenr_T write_no_eol_lnum INIT(= 0); /* non-zero lnum when last line + of next binary write should + not have an end-of-line */ + #ifdef FEAT_WINDOWS EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */ EXTERN int postponed_split_flags INIT(= 0); /* args for win_split() */ @@ -957,6 +963,7 @@ EXTERN int redir_off INIT(= FALSE); /* no redirection for a moment */ EXTERN FILE *redir_fd INIT(= NULL); /* message redirection file */ #ifdef FEAT_EVAL EXTERN int redir_reg INIT(= 0); /* message redirection register */ +EXTERN int redir_vname INIT(= 0); /* message redirection variable */ #endif #ifdef FEAT_LANGMAP @@ -1399,14 +1406,12 @@ EXTERN char_u e_invexprmsg[] INIT(=N_("E449: Invalid expression received")); EXTERN char_u e_guarded[] INIT(=N_("E463: Region is guarded, cannot modify")); EXTERN char_u e_nbreadonly[] INIT(=N_("E744: NetBeans does not allow changes in read-only files")); #endif -#if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) EXTERN char_u e_intern2[] INIT(=N_("E685: Internal error: %s")); -#endif #if defined(HAVE_SETJMP_H) || defined(HAVE_TRY_EXCEPT) EXTERN char_u e_complex[] INIT(=N_("E361: Crash intercepted; regexp too complex?")); #endif EXTERN char_u e_outofstack[] INIT(=N_("E363: pattern caused out-of-stack error")); - +EXTERN char_u e_emptybuf[] INIT(=N_("E749: empty buffer")); #ifdef MACOS_X_UNIX EXTERN short disallow_gui INIT(= FALSE); diff --git a/src/mbyte.c b/src/mbyte.c index f3092556df..89b53c2e5a 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -2871,12 +2871,16 @@ enc_locale() # ifdef HAVE_NL_LANGINFO_CODESET if ((s = nl_langinfo(CODESET)) == NULL || *s == NUL) # endif -# if defined(HAVE_LOCALE_H) || defined(X_LOCALE) +# ifdef MACOS + s = "utf-8"; +# else +# if defined(HAVE_LOCALE_H) || defined(X_LOCALE) if ((s = setlocale(LC_CTYPE, NULL)) == NULL || *s == NUL) -# endif +# endif if ((s = getenv("LC_ALL")) == NULL || *s == NUL) if ((s = getenv("LC_CTYPE")) == NULL || *s == NUL) s = getenv("LANG"); +# endif if (s == NULL || *s == NUL) return FAIL; @@ -5578,6 +5582,7 @@ convert_setup(vcp, from, to) # endif if (vcp->vc_type == CONV_NONE) return FAIL; + return OK; } diff --git a/src/message.c b/src/message.c index 6f2e7c1556..f6494847f5 100644 --- a/src/message.c +++ b/src/message.c @@ -518,6 +518,7 @@ emsg(s) #endif called_emsg = TRUE; + ex_exitval = 1; /* * If "emsg_severe" is TRUE: When an error exception is to be thrown, @@ -533,7 +534,7 @@ emsg(s) * If 'debug' is set: do error message anyway, but without side effects. * If "emsg_skip" is set: never do error messages. */ - if ((emsg_off > 0 && *p_debug == NUL) + if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL) #ifdef FEAT_EVAL || emsg_skip > 0 #endif @@ -638,7 +639,7 @@ emsg2(s, a1) emsg3(s, a1, a2) char_u *s, *a1, *a2; { - if ((emsg_off > 0 && *p_debug == NUL) + if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL) #ifdef FEAT_EVAL || emsg_skip > 0 #endif @@ -667,7 +668,7 @@ emsgn(s, n) char_u *s; long n; { - if ((emsg_off > 0 && *p_debug == NUL) + if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL) #ifdef FEAT_EVAL || emsg_skip > 0 #endif @@ -677,6 +678,13 @@ emsgn(s, n) return emsg(IObuff); } + void +emsg_invreg(name) + int name; +{ + EMSG2(_("E354: Invalid register name: '%s'"), transchar(name)); +} + /* * Like msg(), but truncate to a single line if p_shm contains 't', or when * "force" is TRUE. This truncates in another way as for normal messages. @@ -1481,8 +1489,9 @@ str2specialbuf(sp, buf, len) * print line for :print or :list command */ void -msg_prt_line(s) +msg_prt_line(s, list) char_u *s; + int list; { int c; int col = 0; @@ -1497,8 +1506,11 @@ msg_prt_line(s) char_u buf[MB_MAXBYTES + 1]; #endif + if (curwin->w_p_list) + list = TRUE; + /* find start of trailing whitespace */ - if (curwin->w_p_list && lcs_trail) + if (list && lcs_trail) { trail = s + STRLEN(s); while (trail > s && vim_iswhite(trail[-1])) @@ -1507,7 +1519,7 @@ msg_prt_line(s) /* output a space for an empty line, otherwise the line will be * overwritten */ - if (*s == NUL && !(curwin->w_p_list && lcs_eol != NUL)) + if (*s == NUL && !(list && lcs_eol != NUL)) msg_putchar(' '); for (;;) @@ -1535,11 +1547,11 @@ msg_prt_line(s) { attr = 0; c = *s++; - if (c == TAB && (!curwin->w_p_list || lcs_tab1)) + if (c == TAB && (!list || lcs_tab1)) { /* tab amount depends on current column */ n_extra = curbuf->b_p_ts - col % curbuf->b_p_ts - 1; - if (!curwin->w_p_list) + if (!list) { c = ' '; c_extra = ' '; @@ -1551,7 +1563,7 @@ msg_prt_line(s) attr = hl_attr(HLF_8); } } - else if (c == NUL && curwin->w_p_list && lcs_eol != NUL) + else if (c == NUL && list && lcs_eol != NUL) { p_extra = (char_u *)""; c_extra = NUL; @@ -2521,7 +2533,7 @@ redir_write(str, maxlen) if ((redir_fd != NULL #ifdef FEAT_EVAL - || redir_reg + || redir_reg || redir_vname #endif ) && !redir_off) { @@ -2533,6 +2545,8 @@ redir_write(str, maxlen) #ifdef FEAT_EVAL if (redir_reg) write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE); + else if (redir_vname) + var_redir_str((char_u *)" ", -1); else if (redir_fd) #endif fputs(" ", redir_fd); @@ -2543,13 +2557,15 @@ redir_write(str, maxlen) #ifdef FEAT_EVAL if (redir_reg) write_reg_contents(redir_reg, s, maxlen, TRUE); + if (redir_vname) + var_redir_str(s, maxlen); #endif /* Adjust the current column */ while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) { #ifdef FEAT_EVAL |