Mercurial > vim
comparison src/ex_cmds2.c @ 1802:8978513bb5e3 v7.2.100
updated for version 7.2-100
author | vimboss |
---|---|
date | Wed, 04 Feb 2009 16:50:47 +0000 |
parents | 734d5bdae499 |
children | f38b7359dafd |
comparison
equal
deleted
inserted
replaced
1801:c4d5f3d8ad71 | 1802:8978513bb5e3 |
---|---|
2840 struct source_cookie cookie; | 2840 struct source_cookie cookie; |
2841 char_u *save_sourcing_name; | 2841 char_u *save_sourcing_name; |
2842 linenr_T save_sourcing_lnum; | 2842 linenr_T save_sourcing_lnum; |
2843 char_u *p; | 2843 char_u *p; |
2844 char_u *fname_exp; | 2844 char_u *fname_exp; |
2845 char_u *firstline = NULL; | |
2845 int retval = FAIL; | 2846 int retval = FAIL; |
2846 #ifdef FEAT_EVAL | 2847 #ifdef FEAT_EVAL |
2847 scid_T save_current_SID; | 2848 scid_T save_current_SID; |
2848 static scid_T last_current_SID = 0; | 2849 static scid_T last_current_SID = 0; |
2849 void *save_funccalp; | 2850 void *save_funccalp; |
2990 cookie.fname = fname_exp; | 2991 cookie.fname = fname_exp; |
2991 cookie.dbg_tick = debug_tick; | 2992 cookie.dbg_tick = debug_tick; |
2992 | 2993 |
2993 cookie.level = ex_nesting_level; | 2994 cookie.level = ex_nesting_level; |
2994 #endif | 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 * Keep the sourcing name/lnum, for recursive calls. | 2998 * Keep the sourcing name/lnum, for recursive calls. |
3015 */ | 2999 */ |
3016 save_sourcing_name = sourcing_name; | 3000 save_sourcing_name = sourcing_name; |
3017 sourcing_name = fname_exp; | 3001 sourcing_name = fname_exp; |
3018 save_sourcing_lnum = sourcing_lnum; | 3002 save_sourcing_lnum = sourcing_lnum; |
3019 sourcing_lnum = 0; | 3003 sourcing_lnum = 0; |
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 { | |
3018 vim_free(firstline); | |
3019 firstline = p; | |
3020 } | |
3021 } | |
3022 #endif | |
3020 | 3023 |
3021 #ifdef STARTUPTIME | 3024 #ifdef STARTUPTIME |
3022 time_push(&tv_rel, &tv_start); | 3025 time_push(&tv_rel, &tv_start); |
3023 #endif | 3026 #endif |
3024 | 3027 |
3109 #endif | 3112 #endif |
3110 | 3113 |
3111 /* | 3114 /* |
3112 * Call do_cmdline, which will call getsourceline() to get the lines. | 3115 * Call do_cmdline, which will call getsourceline() to get the lines. |
3113 */ | 3116 */ |
3114 do_cmdline(NULL, getsourceline, (void *)&cookie, | 3117 do_cmdline(firstline, getsourceline, (void *)&cookie, |
3115 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT); | 3118 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT); |
3116 | |
3117 retval = OK; | 3119 retval = OK; |
3118 | 3120 |
3119 #ifdef FEAT_PROFILE | 3121 #ifdef FEAT_PROFILE |
3120 if (do_profiling == PROF_YES) | 3122 if (do_profiling == PROF_YES) |
3121 { | 3123 { |
3169 prof_child_exit(&wait_start); /* leaving a child now */ | 3171 prof_child_exit(&wait_start); /* leaving a child now */ |
3170 # endif | 3172 # endif |
3171 #endif | 3173 #endif |
3172 fclose(cookie.fp); | 3174 fclose(cookie.fp); |
3173 vim_free(cookie.nextline); | 3175 vim_free(cookie.nextline); |
3176 vim_free(firstline); | |
3174 #ifdef FEAT_MBYTE | 3177 #ifdef FEAT_MBYTE |
3175 convert_setup(&cookie.conv, NULL, NULL); | 3178 convert_setup(&cookie.conv, NULL, NULL); |
3176 #endif | 3179 #endif |
3177 | 3180 |
3178 theend: | 3181 theend: |