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

« back to all changes in this revision

Viewing changes to src/ex_cmds2.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:
2842
2842
    linenr_T                save_sourcing_lnum;
2843
2843
    char_u                  *p;
2844
2844
    char_u                  *fname_exp;
 
2845
    char_u                  *firstline = NULL;
2845
2846
    int                     retval = FAIL;
2846
2847
#ifdef FEAT_EVAL
2847
2848
    scid_T                  save_current_SID;
2992
2993
 
2993
2994
    cookie.level = ex_nesting_level;
2994
2995
#endif
2995
 
#ifdef FEAT_MBYTE
2996
 
    cookie.conv.vc_type = CONV_NONE;            /* no conversion */
2997
 
 
2998
 
    /* Try reading the first few bytes to check for a UTF-8 BOM. */
2999
 
    {
3000
 
        char_u      buf[3];
3001
 
 
3002
 
        if (fread((char *)buf, sizeof(char_u), (size_t)3, cookie.fp)
3003
 
                                                                  == (size_t)3
3004
 
                && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)
3005
 
            /* Found BOM, setup conversion and skip over it. */
3006
 
            convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
3007
 
        else
3008
 
            /* No BOM found, rewind. */
3009
 
            fseek(cookie.fp, 0L, SEEK_SET);
3010
 
    }
3011
 
#endif
3012
2996
 
3013
2997
    /*
3014
2998
     * Keep the sourcing name/lnum, for recursive calls.
3018
3002
    save_sourcing_lnum = sourcing_lnum;
3019
3003
    sourcing_lnum = 0;
3020
3004
 
 
3005
#ifdef FEAT_MBYTE
 
3006
    cookie.conv.vc_type = CONV_NONE;            /* no conversion */
 
3007
 
 
3008
    /* Read the first line so we can check for a UTF-8 BOM. */
 
3009
    firstline = getsourceline(0, (void *)&cookie, 0);
 
3010
    if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
 
3011
                              && firstline[1] == 0xbb && firstline[2] == 0xbf)
 
3012
    {
 
3013
        /* Found BOM; setup conversion, skip over BOM and recode the line. */
 
3014
        convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
 
3015
        p = string_convert(&cookie.conv, firstline + 3, NULL);
 
3016
        if (p == NULL)
 
3017
            p = vim_strsave(firstline + 3);
 
3018
        if (p != NULL)
 
3019
        {
 
3020
            vim_free(firstline);
 
3021
            firstline = p;
 
3022
        }
 
3023
    }
 
3024
#endif
 
3025
 
3021
3026
#ifdef STARTUPTIME
3022
3027
    time_push(&tv_rel, &tv_start);
3023
3028
#endif
3111
3116
    /*
3112
3117
     * Call do_cmdline, which will call getsourceline() to get the lines.
3113
3118
     */
3114
 
    do_cmdline(NULL, getsourceline, (void *)&cookie,
 
3119
    do_cmdline(firstline, getsourceline, (void *)&cookie,
3115
3120
                                     DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
3116
 
 
3117
3121
    retval = OK;
3118
3122
 
3119
3123
#ifdef FEAT_PROFILE
3171
3175
#endif
3172
3176
    fclose(cookie.fp);
3173
3177
    vim_free(cookie.nextline);
 
3178
    vim_free(firstline);
3174
3179
#ifdef FEAT_MBYTE
3175
3180
    convert_setup(&cookie.conv, NULL, NULL);
3176
3181
#endif