~ubuntu-branches/ubuntu/maverick/vim/maverick

« back to all changes in this revision

Viewing changes to src/fileio.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-05-04 11:13:42 UTC
  • mfrom: (1.1.8 upstream) (0.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090504111342-60miqybsixdpc345
Tags: 2:7.2.148-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/runtime/vimrc: "syntax on" is a sane default for non-tiny vim.
  - runtime/syntax/debcontrol.vim:
    + Add "metapackages" to the list of valid sections.
  - runtime/syntax/grub.vim:
    + Add Ubuntu-specific 'quiet' keyword.
  - Drop vim-lesstif package and lesstif2-dev build-dependency.
  - Enable Python interpreter on basic builds.
  - Disable autoindent, line-wrapping, and backup files by default.
* Dropped changes, merged in Debian:
  - Add jaunty, karmic to the list of valid suites.
  - runtime/syntax/debsources.vim:
    + Add "jaunty" to debsourcesDistrKeyword
  - Create a .pot file for translations.
* Drop gutsy from the list of valid distro series, it's been EOLed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
static int au_find_group __ARGS((char_u *name));
70
70
 
71
71
# define AUGROUP_DEFAULT    -1      /* default autocmd group */
72
 
# define AUGROUP_ERROR      -2      /* errornouse autocmd group */
 
72
# define AUGROUP_ERROR      -2      /* erroneous autocmd group */
73
73
# define AUGROUP_ALL        -3      /* all autocmd groups */
74
74
#endif
75
75
 
144
144
# endif
145
145
#endif
146
146
static int move_lines __ARGS((buf_T *frombuf, buf_T *tobuf));
147
 
 
 
147
#ifdef FEAT_AUTOCMD
 
148
static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name");
 
149
#endif
148
150
 
149
151
    void
150
152
filemess(buf, name, s, attr)
295
297
    int         conv_restlen = 0;       /* nr of bytes in conv_rest[] */
296
298
#endif
297
299
 
 
300
#ifdef FEAT_AUTOCMD
 
301
    /* Remember the initial values of curbuf, curbuf->b_ffname and
 
302
     * curbuf->b_fname to detect whether they are altered as a result of
 
303
     * executing nasty autocommands.  Also check if "fname" and "sfname"
 
304
     * point to one of these values. */
 
305
    buf_T   *old_curbuf = curbuf;
 
306
    char_u  *old_b_ffname = curbuf->b_ffname;
 
307
    char_u  *old_b_fname = curbuf->b_fname;
 
308
    int     using_b_ffname = (fname == curbuf->b_ffname)
 
309
                                              || (sfname == curbuf->b_ffname);
 
310
    int     using_b_fname = (fname == curbuf->b_fname)
 
311
                                               || (sfname == curbuf->b_fname);
 
312
#endif
298
313
    write_no_eol_lnum = 0;      /* in case it was set by the previous read */
299
314
 
300
315
    /*
589
604
#ifdef FEAT_QUICKFIX
590
605
                    if (!bt_dontwrite(curbuf))
591
606
#endif
 
607
                    {
592
608
                        check_need_swap(newfile);
 
609
#ifdef FEAT_AUTOCMD
 
610
                        /* SwapExists autocommand may mess things up */
 
611
                        if (curbuf != old_curbuf
 
612
                                || (using_b_ffname
 
613
                                        && (old_b_ffname != curbuf->b_ffname))
 
614
                                || (using_b_fname
 
615
                                         && (old_b_fname != curbuf->b_fname)))
 
616
                        {
 
617
                            EMSG(_(e_auchangedbuf));
 
618
                            return FAIL;
 
619
                        }
 
620
#endif
 
621
                    }
593
622
                    if (dir_of_file_exists(fname))
594
623
                        filemess(curbuf, sfname, (char_u *)_("[New File]"), 0);
595
624
                    else
668
697
#endif
669
698
    {
670
699
        check_need_swap(newfile);
 
700
#ifdef FEAT_AUTOCMD
 
701
        if (!read_stdin && (curbuf != old_curbuf
 
702
                || (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
 
703
                || (using_b_fname && (old_b_fname != curbuf->b_fname))))
 
704
        {
 
705
            EMSG(_(e_auchangedbuf));
 
706
            if (!read_buffer)
 
707
                close(fd);
 
708
            return FAIL;
 
709
        }
 
710
#endif
671
711
#ifdef UNIX
672
712
        /* Set swap file protection bits after creating it. */
673
713
        if (swap_mode > 0 && curbuf->b_ml.ml_mfp->mf_fname != NULL)
698
738
    {
699
739
        int     m = msg_scroll;
700
740
        int     n = msg_scrolled;
701
 
        buf_T   *old_curbuf = curbuf;
702
741
 
703
742
        /*
704
743
         * The file must be closed again, the autocommands may want to change
740
779
        /*
741
780
         * Don't allow the autocommands to change the current buffer.
742
781
         * Try to re-open the file.
 
782
         *
 
783
         * Don't allow the autocommands to change the buffer name either
 
784
         * (cd for example) if it invalidates fname or sfname.
743
785
         */
744
786
        if (!read_stdin && (curbuf != old_curbuf
 
787
                || (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
 
788
                || (using_b_fname && (old_b_fname != curbuf->b_fname))
745
789
                || (fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0)) < 0))
746
790
        {
747
791
            --no_wait_return;
5244
5288
            /* Convert with iconv(). */
5245
5289
            if (ip->bw_restlen > 0)
5246
5290
            {
 
5291
                char *fp;
 
5292
 
5247
5293
                /* Need to concatenate the remainder of the previous call and
5248
5294
                 * the bytes of the current call.  Use the end of the
5249
5295
                 * conversion buffer for this. */
5250
5296
                fromlen = len + ip->bw_restlen;
5251
 
                from = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen;
5252
 
                mch_memmove((void *)from, ip->bw_rest, (size_t)ip->bw_restlen);
5253
 
                mch_memmove((void *)(from + ip->bw_restlen), buf, (size_t)len);
 
5297
                fp = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen;
 
5298
                mch_memmove(fp, ip->bw_rest, (size_t)ip->bw_restlen);
 
5299
                mch_memmove(fp + ip->bw_restlen, buf, (size_t)len);
 
5300
                from = fp;
5254
5301
                tolen = ip->bw_conv_buflen - fromlen;
5255
5302
            }
5256
5303
            else
6320
6367
 
6321
6368
    if (!stuff_empty() || global_busy || !typebuf_typed()
6322
6369
#ifdef FEAT_AUTOCMD
6323
 
                        || autocmd_busy || curbuf_lock > 0
 
6370
                        || autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0
6324
6371
#endif
6325
6372
                                        )
6326
6373
        need_check_timestamps = TRUE;           /* check later */
6522
6569
            set_vim_var_string(VV_FCS_REASON, (char_u *)reason, -1);
6523
6570
            set_vim_var_string(VV_FCS_CHOICE, (char_u *)"", -1);
6524
6571
# endif
 
6572
            ++allbuf_lock;
6525
6573
            n = apply_autocmds(EVENT_FILECHANGEDSHELL,
6526
6574
                                      buf->b_fname, buf->b_fname, FALSE, buf);
 
6575
            --allbuf_lock;
6527
6576
            busy = FALSE;
6528
6577
            if (n)
6529
6578
            {
6598
6647
            tbuf = alloc((unsigned)(STRLEN(path) + STRLEN(mesg)
6599
6648
                                                        + STRLEN(mesg2) + 2));
6600
6649
            sprintf((char *)tbuf, mesg, path);
 
6650
#ifdef FEAT_EVAL
 
6651
            /* Set warningmsg here, before the unimportant and output-specific
 
6652
             * mesg2 has been appended. */
 
6653
            set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
 
6654
#endif
6601
6655
#if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
6602
6656
            if (can_reload)
6603
6657
            {