Mercurial > vim
comparison src/option.c @ 18808:7982f65d8f54 v8.1.2392
patch 8.1.2392: using old C style comments
Commit: https://github.com/vim/vim/commit/6e0ce171e19d0118ecd7c2b16e2a1bd50aa76013
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 5 20:12:41 2019 +0100
patch 8.1.2392: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 05 Dec 2019 20:15:04 +0100 |
parents | fd95d4dbeb37 |
children | 847cc7932c42 |
comparison
equal
deleted
inserted
replaced
18807:7e28c71af59a | 18808:7982f65d8f54 |
---|---|
79 | 79 |
80 #ifdef FEAT_LANGMAP | 80 #ifdef FEAT_LANGMAP |
81 langmap_init(); | 81 langmap_init(); |
82 #endif | 82 #endif |
83 | 83 |
84 /* Be Vi compatible by default */ | 84 // Be Vi compatible by default |
85 p_cp = TRUE; | 85 p_cp = TRUE; |
86 | 86 |
87 /* Use POSIX compatibility when $VIM_POSIX is set. */ | 87 // Use POSIX compatibility when $VIM_POSIX is set. |
88 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) | 88 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) |
89 { | 89 { |
90 set_string_default("cpo", (char_u *)CPO_ALL); | 90 set_string_default("cpo", (char_u *)CPO_ALL); |
91 set_string_default("shm", (char_u *)SHM_POSIX); | 91 set_string_default("shm", (char_u *)SHM_POSIX); |
92 } | 92 } |
154 else | 154 else |
155 # endif | 155 # endif |
156 p = vim_getenv((char_u *)names[n], &mustfree); | 156 p = vim_getenv((char_u *)names[n], &mustfree); |
157 if (p != NULL && *p != NUL) | 157 if (p != NULL && *p != NUL) |
158 { | 158 { |
159 /* First time count the NUL, otherwise count the ','. */ | 159 // First time count the NUL, otherwise count the ','. |
160 len = (int)STRLEN(p) + 3; | 160 len = (int)STRLEN(p) + 3; |
161 if (ga_grow(&ga, len) == OK) | 161 if (ga_grow(&ga, len) == OK) |
162 { | 162 { |
163 if (ga.ga_len > 0) | 163 if (ga.ga_len > 0) |
164 STRCAT(ga.ga_data, ","); | 164 STRCAT(ga.ga_data, ","); |
188 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) | 188 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) |
189 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) | 189 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) |
190 #endif | 190 #endif |
191 { | 191 { |
192 #ifdef HAVE_AVAIL_MEM | 192 #ifdef HAVE_AVAIL_MEM |
193 /* Use amount of memory available at this moment. */ | 193 // Use amount of memory available at this moment. |
194 n = (mch_avail_mem(FALSE) >> 1); | 194 n = (mch_avail_mem(FALSE) >> 1); |
195 #else | 195 #else |
196 # ifdef HAVE_TOTAL_MEM | 196 # ifdef HAVE_TOTAL_MEM |
197 /* Use amount of memory available to Vim. */ | 197 // Use amount of memory available to Vim. |
198 n = (mch_total_mem(FALSE) >> 1); | 198 n = (mch_total_mem(FALSE) >> 1); |
199 # else | 199 # else |
200 n = (0x7fffffff >> 11); | 200 n = (0x7fffffff >> 11); |
201 # endif | 201 # endif |
202 #endif | 202 #endif |
219 char_u *buf; | 219 char_u *buf; |
220 int i; | 220 int i; |
221 int j; | 221 int j; |
222 int mustfree = FALSE; | 222 int mustfree = FALSE; |
223 | 223 |
224 /* Initialize the 'cdpath' option's default value. */ | 224 // Initialize the 'cdpath' option's default value. |
225 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); | 225 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); |
226 if (cdpath != NULL) | 226 if (cdpath != NULL) |
227 { | 227 { |
228 buf = alloc((STRLEN(cdpath) << 1) + 2); | 228 buf = alloc((STRLEN(cdpath) << 1) + 2); |
229 if (buf != NULL) | 229 if (buf != NULL) |
230 { | 230 { |
231 buf[0] = ','; /* start with ",", current dir first */ | 231 buf[0] = ','; // start with ",", current dir first |
232 j = 1; | 232 j = 1; |
233 for (i = 0; cdpath[i] != NUL; ++i) | 233 for (i = 0; cdpath[i] != NUL; ++i) |
234 { | 234 { |
235 if (vim_ispathlistsep(cdpath[i])) | 235 if (vim_ispathlistsep(cdpath[i])) |
236 buf[j++] = ','; | 236 buf[j++] = ','; |
247 { | 247 { |
248 options[opt_idx].def_val[VI_DEFAULT] = buf; | 248 options[opt_idx].def_val[VI_DEFAULT] = buf; |
249 options[opt_idx].flags |= P_DEF_ALLOCED; | 249 options[opt_idx].flags |= P_DEF_ALLOCED; |
250 } | 250 } |
251 else | 251 else |
252 vim_free(buf); /* cannot happen */ | 252 vim_free(buf); // cannot happen |
253 } | 253 } |
254 if (mustfree) | 254 if (mustfree) |
255 vim_free(cdpath); | 255 vim_free(cdpath); |
256 } | 256 } |
257 } | 257 } |
258 #endif | 258 #endif |
259 | 259 |
260 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) | 260 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) |
261 /* Set print encoding on platforms that don't default to latin1 */ | 261 // Set print encoding on platforms that don't default to latin1 |
262 set_string_default("penc", | 262 set_string_default("penc", |
263 # if defined(MSWIN) | 263 # if defined(MSWIN) |
264 (char_u *)"cp1252" | 264 (char_u *)"cp1252" |
265 # else | 265 # else |
266 # ifdef VMS | 266 # ifdef VMS |
269 # ifdef EBCDIC | 269 # ifdef EBCDIC |
270 (char_u *)"ebcdic-uk" | 270 (char_u *)"ebcdic-uk" |
271 # else | 271 # else |
272 # ifdef MAC | 272 # ifdef MAC |
273 (char_u *)"mac-roman" | 273 (char_u *)"mac-roman" |
274 # else /* HPUX */ | 274 # else // HPUX |
275 (char_u *)"hp-roman8" | 275 (char_u *)"hp-roman8" |
276 # endif | 276 # endif |
277 # endif | 277 # endif |
278 # endif | 278 # endif |
279 # endif | 279 # endif |
280 ); | 280 ); |
281 #endif | 281 #endif |
282 | 282 |
283 #ifdef FEAT_POSTSCRIPT | 283 #ifdef FEAT_POSTSCRIPT |
284 /* 'printexpr' must be allocated to be able to evaluate it. */ | 284 // 'printexpr' must be allocated to be able to evaluate it. |
285 set_string_default("pexpr", | 285 set_string_default("pexpr", |
286 # if defined(MSWIN) | 286 # if defined(MSWIN) |
287 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" | 287 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" |
288 # else | 288 # else |
289 # ifdef VMS | 289 # ifdef VMS |
324 if (found_reverse_arg) | 324 if (found_reverse_arg) |
325 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); | 325 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); |
326 #endif | 326 #endif |
327 | 327 |
328 curbuf->b_p_initialized = TRUE; | 328 curbuf->b_p_initialized = TRUE; |
329 curbuf->b_p_ar = -1; /* no local 'autoread' value */ | 329 curbuf->b_p_ar = -1; // no local 'autoread' value |
330 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; | 330 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
331 check_buf_options(curbuf); | 331 check_buf_options(curbuf); |
332 check_win_options(curwin); | 332 check_win_options(curwin); |
333 check_options(); | 333 check_options(); |
334 | 334 |
335 /* Must be before option_expand(), because that one needs vim_isIDc() */ | 335 // Must be before option_expand(), because that one needs vim_isIDc() |
336 didset_options(); | 336 didset_options(); |
337 | 337 |
338 #ifdef FEAT_SPELL | 338 #ifdef FEAT_SPELL |
339 /* Use the current chartab for the generic chartab. This is not in | 339 // Use the current chartab for the generic chartab. This is not in |
340 * didset_options() because it only depends on 'encoding'. */ | 340 // didset_options() because it only depends on 'encoding'. |
341 init_spell_chartab(); | 341 init_spell_chartab(); |
342 #endif | 342 #endif |
343 | 343 |
344 /* | 344 /* |
345 * Expand environment variables and things like "~" for the defaults. | 345 * Expand environment variables and things like "~" for the defaults. |
358 else | 358 else |
359 p = option_expand(opt_idx, NULL); | 359 p = option_expand(opt_idx, NULL); |
360 if (p != NULL && (p = vim_strsave(p)) != NULL) | 360 if (p != NULL && (p = vim_strsave(p)) != NULL) |
361 { | 361 { |
362 *(char_u **)options[opt_idx].var = p; | 362 *(char_u **)options[opt_idx].var = p; |
363 /* VIMEXP | 363 // VIMEXP |
364 * Defaults for all expanded options are currently the same for Vi | 364 // Defaults for all expanded options are currently the same for Vi |
365 * and Vim. When this changes, add some code here! Also need to | 365 // and Vim. When this changes, add some code here! Also need to |
366 * split P_DEF_ALLOCED in two. | 366 // split P_DEF_ALLOCED in two. |
367 */ | |
368 if (options[opt_idx].flags & P_DEF_ALLOCED) | 367 if (options[opt_idx].flags & P_DEF_ALLOCED) |
369 vim_free(options[opt_idx].def_val[VI_DEFAULT]); | 368 vim_free(options[opt_idx].def_val[VI_DEFAULT]); |
370 options[opt_idx].def_val[VI_DEFAULT] = p; | 369 options[opt_idx].def_val[VI_DEFAULT] = p; |
371 options[opt_idx].flags |= P_DEF_ALLOCED; | 370 options[opt_idx].flags |= P_DEF_ALLOCED; |
372 } | 371 } |
373 } | 372 } |
374 | 373 |
375 save_file_ff(curbuf); /* Buffer is unchanged */ | 374 save_file_ff(curbuf); // Buffer is unchanged |
376 | 375 |
377 #if defined(FEAT_ARABIC) | 376 #if defined(FEAT_ARABIC) |
378 /* Detect use of mlterm. | 377 // Detect use of mlterm. |
379 * Mlterm is a terminal emulator akin to xterm that has some special | 378 // Mlterm is a terminal emulator akin to xterm that has some special |
380 * abilities (bidi namely). | 379 // abilities (bidi namely). |
381 * NOTE: mlterm's author is being asked to 'set' a variable | 380 // NOTE: mlterm's author is being asked to 'set' a variable |
382 * instead of an environment variable due to inheritance. | 381 // instead of an environment variable due to inheritance. |
383 */ | |
384 if (mch_getenv((char_u *)"MLTERM") != NULL) | 382 if (mch_getenv((char_u *)"MLTERM") != NULL) |
385 set_option_value((char_u *)"tbidi", 1L, NULL, 0); | 383 set_option_value((char_u *)"tbidi", 1L, NULL, 0); |
386 #endif | 384 #endif |
387 | 385 |
388 didset_options2(); | 386 didset_options2(); |
394 */ | 392 */ |
395 if (mch_getenv((char_u *)"LANG") == NULL) | 393 if (mch_getenv((char_u *)"LANG") == NULL) |
396 { | 394 { |
397 char buf[20]; | 395 char buf[20]; |
398 | 396 |
399 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. | 397 // Could use LOCALE_SISO639LANGNAME, but it's not in Win95. |
400 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use | 398 // LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use |
401 * only the first two. */ | 399 // only the first two. |
402 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, | 400 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, |
403 (LPTSTR)buf, 20); | 401 (LPTSTR)buf, 20); |
404 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) | 402 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) |
405 { | 403 { |
406 /* There are a few exceptions (probably more) */ | 404 // There are a few exceptions (probably more) |
407 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) | 405 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) |
408 STRCPY(buf, "zh_TW"); | 406 STRCPY(buf, "zh_TW"); |
409 else if (STRNICMP(buf, "chs", 3) == 0 | 407 else if (STRNICMP(buf, "chs", 3) == 0 |
410 || STRNICMP(buf, "zhc", 3) == 0) | 408 || STRNICMP(buf, "zhc", 3) == 0) |
411 STRCPY(buf, "zh_CN"); | 409 STRCPY(buf, "zh_CN"); |
412 else if (STRNICMP(buf, "jp", 2) == 0) | 410 else if (STRNICMP(buf, "jp", 2) == 0) |
413 STRCPY(buf, "ja"); | 411 STRCPY(buf, "ja"); |
414 else | 412 else |
415 buf[2] = NUL; /* truncate to two-letter code */ | 413 buf[2] = NUL; // truncate to two-letter code |
416 vim_setenv((char_u *)"LANG", (char_u *)buf); | 414 vim_setenv((char_u *)"LANG", (char_u *)buf); |
417 } | 415 } |
418 } | 416 } |
419 # else | 417 # else |
420 # ifdef MACOS_CONVERT | 418 # ifdef MACOS_CONVERT |
421 /* Moved to os_mac_conv.c to avoid dependency problems. */ | 419 // Moved to os_mac_conv.c to avoid dependency problems. |
422 mac_lang_init(); | 420 mac_lang_init(); |
423 # endif | 421 # endif |
424 # endif | 422 # endif |
425 | 423 |
426 /* enc_locale() will try to find the encoding of the current locale. */ | 424 // enc_locale() will try to find the encoding of the current locale. |
427 p = enc_locale(); | 425 p = enc_locale(); |
428 if (p != NULL) | 426 if (p != NULL) |
429 { | 427 { |
430 char_u *save_enc; | 428 char_u *save_enc; |
431 | 429 |
432 /* Try setting 'encoding' and check if the value is valid. | 430 // Try setting 'encoding' and check if the value is valid. |
433 * If not, go back to the default "latin1". */ | 431 // If not, go back to the default "latin1". |
434 save_enc = p_enc; | 432 save_enc = p_enc; |
435 p_enc = p; | 433 p_enc = p; |
436 if (STRCMP(p_enc, "gb18030") == 0) | 434 if (STRCMP(p_enc, "gb18030") == 0) |
437 { | 435 { |
438 /* We don't support "gb18030", but "cp936" is a good substitute | 436 // We don't support "gb18030", but "cp936" is a good substitute |
439 * for practical purposes, thus use that. It's not an alias to | 437 // for practical purposes, thus use that. It's not an alias to |
440 * still support conversion between gb18030 and utf-8. */ | 438 // still support conversion between gb18030 and utf-8. |
441 p_enc = vim_strsave((char_u *)"cp936"); | 439 p_enc = vim_strsave((char_u *)"cp936"); |
442 vim_free(p); | 440 vim_free(p); |
443 } | 441 } |
444 if (mb_init() == NULL) | 442 if (mb_init() == NULL) |
445 { | 443 { |
451 } | 449 } |
452 | 450 |
453 #if defined(MSWIN) || defined(MACOS_X) || defined(VMS) | 451 #if defined(MSWIN) || defined(MACOS_X) || defined(VMS) |
454 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) | 452 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8) |
455 { | 453 { |
456 /* Adjust the default for 'isprint' and 'iskeyword' to match | 454 // Adjust the default for 'isprint' and 'iskeyword' to match |
457 * latin1. Also set the defaults for when 'nocompatible' is | 455 // latin1. Also set the defaults for when 'nocompatible' is |
458 * set. */ | 456 // set. |
459 set_string_option_direct((char_u *)"isp", -1, | 457 set_string_option_direct((char_u *)"isp", -1, |
460 ISP_LATIN1, OPT_FREE, SID_NONE); | 458 ISP_LATIN1, OPT_FREE, SID_NONE); |
461 set_string_option_direct((char_u *)"isk", -1, | 459 set_string_option_direct((char_u *)"isk", -1, |
462 ISK_LATIN1, OPT_FREE, SID_NONE); | 460 ISK_LATIN1, OPT_FREE, SID_NONE); |
463 opt_idx = findoption((char_u *)"isp"); | 461 opt_idx = findoption((char_u *)"isp"); |
469 (void)init_chartab(); | 467 (void)init_chartab(); |
470 } | 468 } |
471 #endif | 469 #endif |
472 | 470 |
473 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) | 471 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
474 /* Win32 console: When GetACP() returns a different value from | 472 // Win32 console: When GetACP() returns a different value from |
475 * GetConsoleCP() set 'termencoding'. */ | 473 // GetConsoleCP() set 'termencoding'. |
476 if ( | 474 if ( |
477 # ifdef VIMDLL | 475 # ifdef VIMDLL |
478 (!gui.in_use && !gui.starting) && | 476 (!gui.in_use && !gui.starting) && |
479 # endif | 477 # endif |
480 GetACP() != GetConsoleCP()) | 478 GetACP() != GetConsoleCP()) |
481 { | 479 { |
482 char buf[50]; | 480 char buf[50]; |
483 | 481 |
484 /* Win32 console: In ConPTY, GetConsoleCP() returns zero. | 482 // Win32 console: In ConPTY, GetConsoleCP() returns zero. |
485 * Use an alternative value. */ | 483 // Use an alternative value. |
486 if (GetConsoleCP() == 0) | 484 if (GetConsoleCP() == 0) |
487 sprintf(buf, "cp%ld", (long)GetACP()); | 485 sprintf(buf, "cp%ld", (long)GetACP()); |
488 else | 486 else |
489 sprintf(buf, "cp%ld", (long)GetConsoleCP()); | 487 sprintf(buf, "cp%ld", (long)GetConsoleCP()); |
490 p_tenc = vim_strsave((char_u *)buf); | 488 p_tenc = vim_strsave((char_u *)buf); |
502 else | 500 else |
503 p_tenc = empty_option; | 501 p_tenc = empty_option; |
504 } | 502 } |
505 #endif | 503 #endif |
506 #if defined(MSWIN) | 504 #if defined(MSWIN) |
507 /* $HOME may have characters in active code page. */ | 505 // $HOME may have characters in active code page. |
508 init_homedir(); | 506 init_homedir(); |
509 #endif | 507 #endif |
510 } | 508 } |
511 else | 509 else |
512 { | 510 { |
514 p_enc = save_enc; | 512 p_enc = save_enc; |
515 } | 513 } |
516 } | 514 } |
517 | 515 |
518 #ifdef FEAT_MULTI_LANG | 516 #ifdef FEAT_MULTI_LANG |
519 /* Set the default for 'helplang'. */ | 517 // Set the default for 'helplang'. |
520 set_helplang_default(get_mess_lang()); | 518 set_helplang_default(get_mess_lang()); |
521 #endif | 519 #endif |
522 } | 520 } |
523 | 521 |
524 /* | 522 /* |
526 * This does not take care of side effects! | 524 * This does not take care of side effects! |
527 */ | 525 */ |
528 static void | 526 static void |
529 set_option_default( | 527 set_option_default( |
530 int opt_idx, | 528 int opt_idx, |
531 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ | 529 int opt_flags, // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
532 int compatible) /* use Vi default value */ | 530 int compatible) // use Vi default value |
533 { | 531 { |
534 char_u *varp; /* pointer to variable for current option */ | 532 char_u *varp; // pointer to variable for current option |
535 int dvi; /* index in def_val[] */ | 533 int dvi; // index in def_val[] |
536 long_u flags; | 534 long_u flags; |
537 long_u *flagsp; | 535 long_u *flagsp; |
538 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; | 536 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; |
539 | 537 |
540 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); | 538 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); |
541 flags = options[opt_idx].flags; | 539 flags = options[opt_idx].flags; |
542 if (varp != NULL) /* skip hidden option, nothing to do for it */ | 540 if (varp != NULL) // skip hidden option, nothing to do for it |
543 { | 541 { |
544 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | 542 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
545 if (flags & P_STRING) | 543 if (flags & P_STRING) |
546 { | 544 { |
547 /* Use set_string_option_direct() for local options to handle | 545 // Use set_string_option_direct() for local options to handle |
548 * freeing and allocating the value. */ | 546 // freeing and allocating the value. |
549 if (options[opt_idx].indir != PV_NONE) | 547 if (options[opt_idx].indir != PV_NONE) |
550 set_string_option_direct(NULL, opt_idx, | 548 set_string_option_direct(NULL, opt_idx, |
551 options[opt_idx].def_val[dvi], opt_flags, 0); | 549 options[opt_idx].def_val[dvi], opt_flags, 0); |
552 else | 550 else |
553 { | 551 { |
570 // 'scrolloff' and 'sidescrolloff' local values have a | 568 // 'scrolloff' and 'sidescrolloff' local values have a |
571 // different default value than the global default. | 569 // different default value than the global default. |
572 *(long *)varp = -1; | 570 *(long *)varp = -1; |
573 else | 571 else |
574 *(long *)varp = def_val; | 572 *(long *)varp = def_val; |
575 /* May also set global value for local option. */ | 573 // May also set global value for local option. |
576 if (both) | 574 if (both) |
577 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | 575 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = |
578 def_val; | 576 def_val; |
579 } | 577 } |
580 } | 578 } |
581 else /* P_BOOL */ | 579 else // P_BOOL |
582 { | 580 { |
583 /* the cast to long is required for Manx C, long_i is needed for | 581 // the cast to long is required for Manx C, long_i is needed for |
584 * MSVC */ | 582 // MSVC |
585 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; | 583 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; |
586 #ifdef UNIX | 584 #ifdef UNIX |
587 /* 'modeline' defaults to off for root */ | 585 // 'modeline' defaults to off for root |
588 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) | 586 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) |
589 *(int *)varp = FALSE; | 587 *(int *)varp = FALSE; |
590 #endif | 588 #endif |
591 /* May also set global value for local option. */ | 589 // May also set global value for local option. |
592 if (both) | 590 if (both) |
593 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = | 591 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = |
594 *(int *)varp; | 592 *(int *)varp; |
595 } | 593 } |
596 | 594 |
597 /* The default value is not insecure. */ | 595 // The default value is not insecure. |
598 flagsp = insecure_flag(opt_idx, opt_flags); | 596 flagsp = insecure_flag(opt_idx, opt_flags); |
599 *flagsp = *flagsp & ~P_INSECURE; | 597 *flagsp = *flagsp & ~P_INSECURE; |
600 } | 598 } |
601 | 599 |
602 #ifdef FEAT_EVAL | 600 #ifdef FEAT_EVAL |
608 * Set all options (except terminal options) to their default value. | 606 * Set all options (except terminal options) to their default value. |
609 * When "opt_flags" is non-zero skip 'encoding'. | 607 * When "opt_flags" is non-zero skip 'encoding'. |
610 */ | 608 */ |
611 static void | 609 static void |
612 set_options_default( | 610 set_options_default( |
613 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ | 611 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL |
614 { | 612 { |
615 int i; | 613 int i; |
616 win_T *wp; | 614 win_T *wp; |
617 tabpage_T *tp; | 615 tabpage_T *tp; |
618 | 616 |
625 && options[i].var != (char_u *)&p_key | 623 && options[i].var != (char_u *)&p_key |
626 # endif | 624 # endif |
627 ))) | 625 ))) |
628 set_option_default(i, opt_flags, p_cp); | 626 set_option_default(i, opt_flags, p_cp); |
629 | 627 |
630 /* The 'scroll' option must be computed for all windows. */ | 628 // The 'scroll' option must be computed for all windows. |
631 FOR_ALL_TAB_WINDOWS(tp, wp) | 629 FOR_ALL_TAB_WINDOWS(tp, wp) |
632 win_comp_scroll(wp); | 630 win_comp_scroll(wp); |
633 #ifdef FEAT_CINDENT | 631 #ifdef FEAT_CINDENT |
634 parse_cino(curbuf); | 632 parse_cino(curbuf); |
635 #endif | 633 #endif |
648 | 646 |
649 if (escape && vim_strchr(val, ' ') != NULL) | 647 if (escape && vim_strchr(val, ' ') != NULL) |
650 p = vim_strsave_escaped(val, (char_u *)" "); | 648 p = vim_strsave_escaped(val, (char_u *)" "); |
651 else | 649 else |
652 p = vim_strsave(val); | 650 p = vim_strsave(val); |
653 if (p != NULL) /* we don't want a NULL */ | 651 if (p != NULL) // we don't want a NULL |
654 { | 652 { |
655 opt_idx = findoption((char_u *)name); | 653 opt_idx = findoption((char_u *)name); |
656 if (opt_idx >= 0) | 654 if (opt_idx >= 0) |
657 { | 655 { |
658 if (options[opt_idx].flags & P_DEF_ALLOCED) | 656 if (options[opt_idx].flags & P_DEF_ALLOCED) |
726 | 724 |
727 for (i = 0; !istermoption_idx(i); i++) | 725 for (i = 0; !istermoption_idx(i); i++) |
728 { | 726 { |
729 if (options[i].indir == PV_NONE) | 727 if (options[i].indir == PV_NONE) |
730 { | 728 { |
731 /* global option: free value and default value. */ | 729 // global option: free value and default value. |
732 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) | 730 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) |
733 free_string_option(*(char_u **)options[i].var); | 731 free_string_option(*(char_u **)options[i].var); |
734 if (options[i].flags & P_DEF_ALLOCED) | 732 if (options[i].flags & P_DEF_ALLOCED) |
735 free_string_option(options[i].def_val[VI_DEFAULT]); | 733 free_string_option(options[i].def_val[VI_DEFAULT]); |
736 } | 734 } |
737 else if (options[i].var != VAR_WIN | 735 else if (options[i].var != VAR_WIN |
738 && (options[i].flags & P_STRING)) | 736 && (options[i].flags & P_STRING)) |
739 /* buffer-local option: free global value */ | 737 // buffer-local option: free global value |
740 free_string_option(*(char_u **)options[i].var); | 738 free_string_option(*(char_u **)options[i].var); |
741 } | 739 } |
742 } | 740 } |
743 #endif | 741 #endif |
744 | 742 |
767 */ | 765 */ |
768 if (!option_was_set((char_u *)"window")) | 766 if (!option_was_set((char_u *)"window")) |
769 p_window = Rows - 1; | 767 p_window = Rows - 1; |
770 set_number_default("window", Rows - 1); | 768 set_number_default("window", Rows - 1); |
771 | 769 |
772 /* For DOS console the default is always black. */ | 770 // For DOS console the default is always black. |
773 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) | 771 #if !((defined(MSWIN)) && !defined(FEAT_GUI)) |
774 /* | 772 /* |
775 * If 'background' wasn't set by the user, try guessing the value, | 773 * If 'background' wasn't set by the user, try guessing the value, |
776 * depending on the terminal name. Only need to check for terminals | 774 * depending on the terminal name. Only need to check for terminals |
777 * with a dark background, that can handle color. | 775 * with a dark background, that can handle color. |
779 idx = findoption((char_u *)"bg"); | 777 idx = findoption((char_u *)"bg"); |
780 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) | 778 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) |
781 && *term_bg_default() == 'd') | 779 && *term_bg_default() == 'd') |
782 { | 780 { |
783 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); | 781 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); |
784 /* don't mark it as set, when starting the GUI it may be | 782 // don't mark it as set, when starting the GUI it may be |
785 * changed again */ | 783 // changed again |
786 options[idx].flags &= ~P_WAS_SET; | 784 options[idx].flags &= ~P_WAS_SET; |
787 } | 785 } |
788 #endif | 786 #endif |
789 | 787 |
790 #ifdef CURSOR_SHAPE | 788 #ifdef CURSOR_SHAPE |
791 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ | 789 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' |
792 #endif | 790 #endif |
793 #ifdef FEAT_MOUSESHAPE | 791 #ifdef FEAT_MOUSESHAPE |
794 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */ | 792 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape' |
795 #endif | 793 #endif |
796 #ifdef FEAT_PRINTER | 794 #ifdef FEAT_PRINTER |
797 (void)parse_printoptions(); /* parse 'printoptions' default value */ | 795 (void)parse_printoptions(); // parse 'printoptions' default value |
798 #endif | 796 #endif |
799 } | 797 } |
800 | 798 |
801 /* | 799 /* |
802 * Initialize the options, part three: After reading the .vimrc | 800 * Initialize the options, part three: After reading the .vimrc |
861 p_srr = (char_u *)">&"; | 859 p_srr = (char_u *)">&"; |
862 options[idx_srr].def_val[VI_DEFAULT] = p_srr; | 860 options[idx_srr].def_val[VI_DEFAULT] = p_srr; |
863 } | 861 } |
864 } | 862 } |
865 else | 863 else |
866 /* Always use bourne shell style redirection if we reach this */ | 864 // Always use bourne shell style redirection if we reach this |
867 if ( fnamecmp(p, "sh") == 0 | 865 if ( fnamecmp(p, "sh") == 0 |
868 || fnamecmp(p, "ksh") == 0 | 866 || fnamecmp(p, "ksh") == 0 |
869 || fnamecmp(p, "mksh") == 0 | 867 || fnamecmp(p, "mksh") == 0 |
870 || fnamecmp(p, "pdksh") == 0 | 868 || fnamecmp(p, "pdksh") == 0 |
871 || fnamecmp(p, "zsh") == 0 | 869 || fnamecmp(p, "zsh") == 0 |
924 { | 922 { |
925 p_shcf = (char_u *)"-c"; | 923 p_shcf = (char_u *)"-c"; |
926 options[idx3].def_val[VI_DEFAULT] = p_shcf; | 924 options[idx3].def_val[VI_DEFAULT] = p_shcf; |
927 } | 925 } |
928 | 926 |
929 /* Somehow Win32 requires the quotes around the redirection too */ | 927 // Somehow Win32 requires the quotes around the redirection too |
930 idx3 = findoption((char_u *)"sxq"); | 928 idx3 = findoption((char_u *)"sxq"); |
931 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) | 929 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) |
932 { | 930 { |
933 p_sxq = (char_u *)"\""; | 931 p_sxq = (char_u *)"\""; |
934 options[idx3].def_val[VI_DEFAULT] = p_sxq; | 932 options[idx3].def_val[VI_DEFAULT] = p_sxq; |
969 | 967 |
970 if (BUFEMPTY()) | 968 if (BUFEMPTY()) |
971 { | 969 { |
972 int idx_ffs = findoption((char_u *)"ffs"); | 970 int idx_ffs = findoption((char_u *)"ffs"); |
973 | 971 |
974 /* Apply the first entry of 'fileformats' to the initial buffer. */ | 972 // Apply the first entry of 'fileformats' to the initial buffer. |
975 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET)) | 973 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET)) |
976 set_fileformat(default_fileformat(), OPT_LOCAL); | 974 set_fileformat(default_fileformat(), OPT_LOCAL); |
977 } | 975 } |
978 | 976 |
979 #ifdef FEAT_TITLE | 977 #ifdef FEAT_TITLE |
989 void | 987 void |
990 set_helplang_default(char_u *lang) | 988 set_helplang_default(char_u *lang) |
991 { | 989 { |
992 int idx; | 990 int idx; |
993 | 991 |
994 if (lang == NULL || STRLEN(lang) < 2) /* safety check */ | 992 if (lang == NULL || STRLEN(lang) < 2) // safety check |
995 return; | 993 return; |
996 idx = findoption((char_u *)"hlg"); | 994 idx = findoption((char_u *)"hlg"); |
997 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) | 995 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) |
998 { | 996 { |
999 if (options[idx].flags & P_ALLOCED) | 997 if (options[idx].flags & P_ALLOCED) |
1083 * | 1081 * |
1084 * returns FAIL if an error is detected, OK otherwise | 1082 * returns FAIL if an error is detected, OK otherwise |
1085 */ | 1083 */ |
1086 int | 1084 int |
1087 do_set( | 1085 do_set( |
1088 char_u *arg, /* option string (may be written to!) */ | 1086 char_u *arg, // option string (may be written to!) |
1089 int opt_flags) | 1087 int opt_flags) |
1090 { | 1088 { |
1091 int opt_idx; | 1089 int opt_idx; |
1092 char *errmsg; | 1090 char *errmsg; |
1093 char errbuf[80]; | 1091 char errbuf[80]; |
1094 char_u *startarg; | 1092 char_u *startarg; |
1095 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ | 1093 int prefix; // 1: nothing, 0: "no", 2: "inv" in front of name |
1096 int nextchar; /* next non-white char after option name */ | 1094 int nextchar; // next non-white char after option name |
1097 int afterchar; /* character just after option name */ | 1095 int afterchar; // character just after option name |
1098 int len; | 1096 int len; |
1099 int i; | 1097 int i; |
1100 varnumber_T value; | 1098 varnumber_T value; |
1101 int key; | 1099 int key; |
1102 long_u flags; /* flags for current option */ | 1100 long_u flags; // flags for current option |
1103 char_u *varp = NULL; /* pointer to variable for current option */ | 1101 char_u *varp = NULL; // pointer to variable for current option |
1104 int did_show = FALSE; /* already showed one value */ | 1102 int did_show = FALSE; // already showed one value |
1105 int adding; /* "opt+=arg" */ | 1103 int adding; // "opt+=arg" |
1106 int prepending; /* "opt^=arg" */ | 1104 int prepending; // "opt^=arg" |
1107 int removing; /* "opt-=arg" */ | 1105 int removing; // "opt-=arg" |
1108 int cp_val = 0; | 1106 int cp_val = 0; |
1109 char_u key_name[2]; | 1107 char_u key_name[2]; |
1110 | 1108 |
1111 if (*arg == NUL) | 1109 if (*arg == NUL) |
1112 { | 1110 { |
1113 showoptions(0, opt_flags); | 1111 showoptions(0, opt_flags); |
1114 did_show = TRUE; | 1112 did_show = TRUE; |
1115 goto theend; | 1113 goto theend; |
1116 } | 1114 } |
1117 | 1115 |
1118 while (*arg != NUL) /* loop to process all options */ | 1116 while (*arg != NUL) // loop to process all options |
1119 { | 1117 { |
1120 errmsg = NULL; | 1118 errmsg = NULL; |
1121 startarg = arg; /* remember for error message */ | 1119 startarg = arg; // remember for error message |
1122 | 1120 |
1123 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) | 1121 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) |
1124 && !(opt_flags & OPT_MODELINE)) | 1122 && !(opt_flags & OPT_MODELINE)) |
1125 { | 1123 { |
1126 /* | 1124 /* |
1129 */ | 1127 */ |
1130 arg += 3; | 1128 arg += 3; |
1131 if (*arg == '&') | 1129 if (*arg == '&') |
1132 { | 1130 { |
1133 ++arg; | 1131 ++arg; |
1134 /* Only for :set command set global value of local options. */ | 1132 // Only for :set command set global value of local options. |
1135 set_options_default(OPT_FREE | opt_flags); | 1133 set_options_default(OPT_FREE | opt_flags); |
1136 didset_options(); | 1134 didset_options(); |
1137 didset_options2(); | 1135 didset_options2(); |
1138 redraw_all_later(CLEAR); | 1136 redraw_all_later(CLEAR); |
1139 } | 1137 } |
1162 { | 1160 { |
1163 prefix = 2; | 1161 prefix = 2; |
1164 arg += 3; | 1162 arg += 3; |
1165 } | 1163 } |
1166 | 1164 |
1167 /* find end of name */ | 1165 // find end of name |
1168 key = 0; | 1166 key = 0; |
1169 if (*arg == '<') | 1167 if (*arg == '<') |
1170 { | 1168 { |
1171 opt_idx = -1; | 1169 opt_idx = -1; |
1172 /* look out for <t_>;> */ | 1170 // look out for <t_>;> |
1173 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) | 1171 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) |
1174 len = 5; | 1172 len = 5; |
1175 else | 1173 else |
1176 { | 1174 { |
1177 len = 1; | 1175 len = 1; |
1181 if (arg[len] != '>') | 1179 if (arg[len] != '>') |
1182 { | 1180 { |
1183 errmsg = e_invarg; | 1181 errmsg = e_invarg; |
1184 goto skip; | 1182 goto skip; |
1185 } | 1183 } |
1186 arg[len] = NUL; /* put NUL after name */ | 1184 arg[len] = NUL; // put NUL after name |
1187 if (arg[1] == 't' && arg[2] == '_') /* could be term code */ | 1185 if (arg[1] == 't' && arg[2] == '_') // could be term code |
1188 opt_idx = findoption(arg + 1); | 1186 opt_idx = findoption(arg + 1); |
1189 arg[len++] = '>'; /* restore '>' */ | 1187 arg[len++] = '>'; // restore '>' |
1190 if (opt_idx == -1) | 1188 if (opt_idx == -1) |
1191 key = find_key_option(arg + 1, TRUE); | 1189 key = find_key_option(arg + 1, TRUE); |
1192 } | 1190 } |
1193 else | 1191 else |
1194 { | 1192 { |
1200 len = 4; | 1198 len = 4; |
1201 else | 1199 else |
1202 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') | 1200 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') |
1203 ++len; | 1201 ++len; |
1204 nextchar = arg[len]; | 1202 nextchar = arg[len]; |
1205 arg[len] = NUL; /* put NUL after name */ | 1203 arg[len] = NUL; // put NUL after name |
1206 opt_idx = findoption(arg); | 1204 opt_idx = findoption(arg); |
1207 arg[len] = nextchar; /* restore nextchar */ | 1205 arg[len] = nextchar; // restore nextchar |
1208 if (opt_idx == -1) | 1206 if (opt_idx == -1) |
1209 key = find_key_option(arg, FALSE); | 1207 key = find_key_option(arg, FALSE); |
1210 } | 1208 } |
1211 | 1209 |
1212 /* remember character after option name */ | 1210 // remember character after option name |
1213 afterchar = arg[len]; | 1211 afterchar = arg[len]; |
1214 | 1212 |
1215 /* skip white space, allow ":set ai ?" */ | 1213 // skip white space, allow ":set ai ?" |
1216 while (VIM_ISWHITE(arg[len])) | 1214 while (VIM_ISWHITE(arg[len])) |
1217 ++len; | 1215 ++len; |
1218 | 1216 |
1219 adding = FALSE; | 1217 adding = FALSE; |
1220 prepending = FALSE; | 1218 prepending = FALSE; |
1221 removing = FALSE; | 1219 removing = FALSE; |
1222 if (arg[len] != NUL && arg[len + 1] == '=') | 1220 if (arg[len] != NUL && arg[len + 1] == '=') |
1223 { | 1221 { |
1224 if (arg[len] == '+') | 1222 if (arg[len] == '+') |
1225 { | 1223 { |
1226 adding = TRUE; /* "+=" */ | 1224 adding = TRUE; // "+=" |
1227 ++len; | 1225 ++len; |
1228 } | 1226 } |
1229 else if (arg[len] == '^') | 1227 else if (arg[len] == '^') |
1230 { | 1228 { |
1231 prepending = TRUE; /* "^=" */ | 1229 prepending = TRUE; // "^=" |
1232 ++len; | 1230 ++len; |
1233 } | 1231 } |
1234 else if (arg[len] == '-') | 1232 else if (arg[len] == '-') |
1235 { | 1233 { |
1236 removing = TRUE; /* "-=" */ | 1234 removing = TRUE; // "-=" |
1237 ++len; | 1235 ++len; |
1238 } | 1236 } |
1239 } | 1237 } |
1240 nextchar = arg[len]; | 1238 nextchar = arg[len]; |
1241 | 1239 |
1242 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ | 1240 if (opt_idx == -1 && key == 0) // found a mismatch: skip |
1243 { | 1241 { |
1244 errmsg = N_("E518: Unknown option"); | 1242 errmsg = N_("E518: Unknown option"); |
1245 goto skip; | 1243 goto skip; |
1246 } | 1244 } |
1247 | 1245 |
1248 if (opt_idx >= 0) | 1246 if (opt_idx >= 0) |
1249 { | 1247 { |
1250 if (options[opt_idx].var == NULL) /* hidden option: skip */ | 1248 if (options[opt_idx].var == NULL) // hidden option: skip |
1251 { | 1249 { |
1252 /* Only give an error message when requesting the value of | 1250 // Only give an error message when requesting the value of |
1253 * a hidden option, ignore setting it. */ | 1251 // a hidden option, ignore setting it. |
1254 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL | 1252 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL |
1255 && (!(options[opt_idx].flags & P_BOOL) | 1253 && (!(options[opt_idx].flags & P_BOOL) |
1256 || nextchar == '?')) | 1254 || nextchar == '?')) |
1257 errmsg = N_("E519: Option not supported"); | 1255 errmsg = N_("E519: Option not supported"); |
1258 goto skip; | 1256 goto skip; |
1274 key_name[0] = KS_KEY; | 1272 key_name[0] = KS_KEY; |
1275 key_name[1] = (key & 0xff); | 1273 key_name[1] = (key & 0xff); |
1276 } | 1274 } |
1277 } | 1275 } |
1278 | 1276 |
1279 /* Skip all options that are not window-local (used when showing | 1277 // Skip all options that are not window-local (used when showing |
1280 * an already loaded buffer in a window). */ | 1278 // an already loaded buffer in a window). |
1281 if ((opt_flags & OPT_WINONLY) | 1279 if ((opt_flags & OPT_WINONLY) |
1282 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) | 1280 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) |
1283 goto skip; | 1281 goto skip; |
1284 | 1282 |
1285 /* Skip all options that are window-local (used for :vimgrep). */ | 1283 // Skip all options that are window-local (used for :vimgrep). |
1286 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 | 1284 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 |
1287 && options[opt_idx].var == VAR_WIN) | 1285 && options[opt_idx].var == VAR_WIN) |
1288 goto skip; | 1286 goto skip; |
1289 | 1287 |
1290 /* Disallow changing some options from modelines. */ | 1288 // Disallow changing some options from modelines. |
1291 if (opt_flags & OPT_MODELINE) | 1289 if (opt_flags & OPT_MODELINE) |
1292 { | 1290 { |
1293 if (flags & (P_SECURE | P_NO_ML)) | 1291 if (flags & (P_SECURE | P_NO_ML)) |
1294 { | 1292 { |
1295 errmsg = _("E520: Not allowed in a modeline"); | 1293 errmsg = _("E520: Not allowed in a modeline"); |
1299 { | 1297 { |
1300 errmsg = _("E992: Not allowed in a modeline when 'modelineexpr' is off"); | 1298 errmsg = _("E992: Not allowed in a modeline when 'modelineexpr' is off"); |
1301 goto skip; | 1299 goto skip; |
1302 } | 1300 } |
1303 #ifdef FEAT_DIFF | 1301 #ifdef FEAT_DIFF |
1304 /* In diff mode some options are overruled. This avoids that | 1302 // In diff mode some options are overruled. This avoids that |
1305 * 'foldmethod' becomes "marker" instead of "diff" and that | 1303 // 'foldmethod' becomes "marker" instead of "diff" and that |
1306 * "wrap" gets set. */ | 1304 // "wrap" gets set. |
1307 if (curwin->w_p_diff | 1305 if (curwin->w_p_diff |
1308 && opt_idx >= 0 /* shut up coverity warning */ | 1306 && opt_idx >= 0 // shut up coverity warning |
1309 && ( | 1307 && ( |
1310 #ifdef FEAT_FOLDING | 1308 #ifdef FEAT_FOLDING |
1311 options[opt_idx].indir == PV_FDM || | 1309 options[opt_idx].indir == PV_FDM || |
1312 #endif | 1310 #endif |
1313 options[opt_idx].indir == PV_WRAP)) | 1311 options[opt_idx].indir == PV_WRAP)) |
1314 goto skip; | 1312 goto skip; |
1315 #endif | 1313 #endif |
1316 } | 1314 } |
1317 | 1315 |
1318 #ifdef HAVE_SANDBOX | 1316 #ifdef HAVE_SANDBOX |
1319 /* Disallow changing some options in the sandbox */ | 1317 // Disallow changing some options in the sandbox |
1320 if (sandbox != 0 && (flags & P_SECURE)) | 1318 if (sandbox != 0 && (flags & P_SECURE)) |
1321 { | 1319 { |
1322 errmsg = _(e_sandbox); | 1320 errmsg = _(e_sandbox); |
1323 goto skip; | 1321 goto skip; |
1324 } | 1322 } |
1328 { | 1326 { |
1329 arg += len; | 1327 arg += len; |
1330 cp_val = p_cp; | 1328 cp_val = p_cp; |
1331 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') | 1329 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') |
1332 { | 1330 { |
1333 if (arg[3] == 'm') /* "opt&vim": set to Vim default */ | 1331 if (arg[3] == 'm') // "opt&vim": set to Vim default |
1334 { | 1332 { |
1335 cp_val = FALSE; | 1333 cp_val = FALSE; |
1336 arg += 3; | 1334 arg += 3; |
1337 } | 1335 } |
1338 else /* "opt&vi": set to Vi default */ | 1336 else // "opt&vi": set to Vi default |
1339 { | 1337 { |
1340 cp_val = TRUE; | 1338 cp_val = TRUE; |
1341 arg += 2; | 1339 arg += 2; |
1342 } | 1340 } |
1343 } | 1341 } |
1360 { | 1358 { |
1361 /* | 1359 /* |
1362 * print value | 1360 * print value |
1363 */ | 1361 */ |
1364 if (did_show) | 1362 if (did_show) |
1365 msg_putchar('\n'); /* cursor below last one */ | 1363 msg_putchar('\n'); // cursor below last one |
1366 else | 1364 else |
1367 { | 1365 { |
1368 gotocmdline(TRUE); /* cursor at status line */ | 1366 gotocmdline(TRUE); // cursor at status line |
1369 did_show = TRUE; /* remember that we did a line */ | 1367 did_show = TRUE; // remember that we did a line |
1370 } | 1368 } |
1371 if (opt_idx >= 0) | 1369 if (opt_idx >= 0) |
1372 { | 1370 { |
1373 showoneopt(&options[opt_idx], opt_flags); | 1371 showoneopt(&options[opt_idx], opt_flags); |
1374 #ifdef FEAT_EVAL | 1372 #ifdef FEAT_EVAL |
1375 if (p_verbose > 0) | 1373 if (p_verbose > 0) |
1376 { | 1374 { |
1377 /* Mention where the option was last set. */ | 1375 // Mention where the option was last set. |
1378 if (varp == options[opt_idx].var) | 1376 if (varp == options[opt_idx].var) |
1379 last_set_msg(options[opt_idx].script_ctx); | 1377 last_set_msg(options[opt_idx].script_ctx); |
1380 else if ((int)options[opt_idx].indir & PV_WIN) | 1378 else if ((int)options[opt_idx].indir & PV_WIN) |
1381 last_set_msg(curwin->w_p_script_ctx[ | 1379 last_set_msg(curwin->w_p_script_ctx[ |
1382 (int)options[opt_idx].indir & PV_MASK]); | 1380 (int)options[opt_idx].indir & PV_MASK]); |
1406 else | 1404 else |
1407 { | 1405 { |
1408 int value_is_replaced = !prepending && !adding && !removing; | 1406 int value_is_replaced = !prepending && !adding && !removing; |
1409 int value_checked = FALSE; | 1407 int value_checked = FALSE; |
1410 | 1408 |
1411 if (flags & P_BOOL) /* boolean */ | 1409 if (flags & P_BOOL) // boolean |
1412 { | 1410 { |
1413 if (nextchar == '=' || nextchar == ':') | 1411 if (nextchar == '=' || nextchar == ':') |
1414 { | 1412 { |
1415 errmsg = e_invarg; | 1413 errmsg = e_invarg; |
1416 goto skip; | 1414 goto skip; |
1427 value = (int)(long)(long_i)options[opt_idx].def_val[ | 1425 value = (int)(long)(long_i)options[opt_idx].def_val[ |
1428 ((flags & P_VI_DEF) || cp_val) | 1426 ((flags & P_VI_DEF) || cp_val) |
1429 ? VI_DEFAULT : VIM_DEFAULT]; | 1427 ? VI_DEFAULT : VIM_DEFAULT]; |
1430 else if (nextchar == '<') | 1428 else if (nextchar == '<') |
1431 { | 1429 { |
1432 /* For 'autoread' -1 means to use global value. */ | 1430 // For 'autoread' -1 means to use global value. |
1433 if ((int *)varp == &curbuf->b_p_ar | 1431 if ((int *)varp == &curbuf->b_p_ar |
1434 && opt_flags == OPT_LOCAL) | 1432 && opt_flags == OPT_LOCAL) |
1435 value = -1; | 1433 value = -1; |
1436 else | 1434 else |
1437 value = *(int *)get_varp_scope(&(options[opt_idx]), | 1435 value = *(int *)get_varp_scope(&(options[opt_idx]), |
1446 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) | 1444 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) |
1447 { | 1445 { |
1448 errmsg = e_trailing; | 1446 errmsg = e_trailing; |
1449 goto skip; | 1447 goto skip; |
1450 } | 1448 } |
1451 if (prefix == 2) /* inv */ | 1449 if (prefix == 2) // inv |
1452 value = *(int *)(varp) ^ 1; | 1450 value = *(int *)(varp) ^ 1; |
1453 else | 1451 else |
1454 value = prefix; | 1452 value = prefix; |
1455 } | 1453 } |
1456 | 1454 |
1457 errmsg = set_bool_option(opt_idx, varp, (int)value, | 1455 errmsg = set_bool_option(opt_idx, varp, (int)value, |
1458 opt_flags); | 1456 opt_flags); |
1459 } | 1457 } |
1460 else /* numeric or string */ | 1458 else // numeric or string |
1461 { | 1459 { |
1462 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL | 1460 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL |
1463 || prefix != 1) | 1461 || prefix != 1) |
1464 { | 1462 { |
1465 errmsg = e_invarg; | 1463 errmsg = e_invarg; |
1466 goto skip; | 1464 goto skip; |
1467 } | 1465 } |
1468 | 1466 |
1469 if (flags & P_NUM) /* numeric */ | 1467 if (flags & P_NUM) // numeric |
1470 { | 1468 { |
1471 /* | 1469 /* |
1472 * Different ways to set a number option: | 1470 * Different ways to set a number option: |
1473 * & set to default value | 1471 * & set to default value |
1474 * < set to global value | 1472 * < set to global value |
1482 value = (long)(long_i)options[opt_idx].def_val[ | 1480 value = (long)(long_i)options[opt_idx].def_val[ |
1483 ((flags & P_VI_DEF) || cp_val) | 1481 ((flags & P_VI_DEF) || cp_val) |
1484 ? VI_DEFAULT : VIM_DEFAULT]; | 1482 ? VI_DEFAULT : VIM_DEFAULT]; |
1485 else if (nextchar == '<') | 1483 else if (nextchar == '<') |
1486 { | 1484 { |
1487 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to | 1485 // For 'undolevels' NO_LOCAL_UNDOLEVEL means to |
1488 * use the global value. */ | 1486 // use the global value. |
1489 if ((long *)varp == &curbuf->b_p_ul | 1487 if ((long *)varp == &curbuf->b_p_ul |
1490 && opt_flags == OPT_LOCAL) | 1488 && opt_flags == OPT_LOCAL) |
1491 value = NO_LOCAL_UNDOLEVEL; | 1489 value = NO_LOCAL_UNDOLEVEL; |
1492 else | 1490 else |
1493 value = *(long *)get_varp_scope( | 1491 value = *(long *)get_varp_scope( |
1508 goto skip; | 1506 goto skip; |
1509 } | 1507 } |
1510 } | 1508 } |
1511 else if (*arg == '-' || VIM_ISDIGIT(*arg)) | 1509 else if (*arg == '-' || VIM_ISDIGIT(*arg)) |
1512 { | 1510 { |
1513 /* Allow negative (for 'undolevels'), octal and | 1511 // Allow negative (for 'undolevels'), octal and |
1514 * hex numbers. */ | 1512 // hex numbers. |
1515 vim_str2nr(arg, NULL, &i, STR2NR_ALL, | 1513 vim_str2nr(arg, NULL, &i, STR2NR_ALL, |
1516 &value, NULL, 0, TRUE); | 1514 &value, NULL, 0, TRUE); |
1517 if (i == 0 || (arg[i] != NUL | 1515 if (i == 0 || (arg[i] != NUL |
1518 && !VIM_ISWHITE(arg[i]))) | 1516 && !VIM_ISWHITE(arg[i]))) |
1519 { | 1517 { |
1534 if (removing) | 1532 if (removing) |
1535 value = *(long *)varp - value; | 1533 value = *(long *)varp - value; |
1536 errmsg = set_num_option(opt_idx, varp, value, | 1534 errmsg = set_num_option(opt_idx, varp, value, |
1537 errbuf, sizeof(errbuf), opt_flags); | 1535 errbuf, sizeof(errbuf), opt_flags); |
1538 } | 1536 } |
1539 else if (opt_idx >= 0) /* string */ | 1537 else if (opt_idx >= 0) // string |
1540 { | 1538 { |
1541 char_u *save_arg = NULL; | 1539 char_u *save_arg = NULL; |
1542 char_u *s = NULL; | 1540 char_u *s = NULL; |
1543 char_u *oldval = NULL; /* previous value if *varp */ | 1541 char_u *oldval = NULL; // previous value if *varp |
1544 char_u *newval; | 1542 char_u *newval; |
1545 char_u *origval = NULL; | 1543 char_u *origval = NULL; |
1546 char_u *origval_l = NULL; | 1544 char_u *origval_l = NULL; |
1547 char_u *origval_g = NULL; | 1545 char_u *origval_g = NULL; |
1548 #if defined(FEAT_EVAL) | 1546 #if defined(FEAT_EVAL) |
1552 char_u *saved_newval = NULL; | 1550 char_u *saved_newval = NULL; |
1553 #endif | 1551 #endif |
1554 unsigned newlen; | 1552 unsigned newlen; |
1555 int comma; | 1553 int comma; |
1556 int bs; | 1554 int bs; |
1557 int new_value_alloced; /* new string option | 1555 int new_value_alloced; // new string option |
1558 was allocated */ | 1556 // was allocated |
1559 | 1557 |
1560 /* When using ":set opt=val" for a global option | 1558 // When using ":set opt=val" for a global option |
1561 * with a local value the local value will be | 1559 // with a local value the local value will be |
1562 * reset, use the global value here. */ | 1560 // reset, use the global value here. |
1563 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 | 1561 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 |
1564 && ((int)options[opt_idx].indir & PV_BOTH)) | 1562 && ((int)options[opt_idx].indir & PV_BOTH)) |
1565 varp = options[opt_idx].var; | 1563 varp = options[opt_idx].var; |
1566 | 1564 |
1567 /* The old value is kept until we are sure that the | 1565 // The old value is kept until we are sure that the |
1568 * new value is valid. */ | 1566 // new value is valid. |
1569 oldval = *(char_u **)varp; | 1567 oldval = *(char_u **)varp; |
1570 | 1568 |
1571 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | 1569 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
1572 { | 1570 { |
1573 origval_l = *(char_u **)get_varp_scope( | 1571 origval_l = *(char_u **)get_varp_scope( |
1590 origval = *(char_u **)get_varp( | 1588 origval = *(char_u **)get_varp( |
1591 &options[opt_idx]); | 1589 &options[opt_idx]); |
1592 else | 1590 else |
1593 origval = oldval; | 1591 origval = oldval; |
1594 | 1592 |
1595 if (nextchar == '&') /* set to default val */ | 1593 if (nextchar == '&') // set to default val |
1596 { | 1594 { |
1597 newval = options[opt_idx].def_val[ | 1595 newval = options[opt_idx].def_val[ |
1598 ((flags & P_VI_DEF) || cp_val) | 1596 ((flags & P_VI_DEF) || cp_val) |
1599 ? VI_DEFAULT : VIM_DEFAULT]; | 1597 ? VI_DEFAULT : VIM_DEFAULT]; |
1600 if ((char_u **)varp == &p_bg) | 1598 if ((char_u **)varp == &p_bg) |
1601 { | 1599 { |
1602 /* guess the value of 'background' */ | 1600 // guess the value of 'background' |
1603 #ifdef FEAT_GUI | 1601 #ifdef FEAT_GUI |
1604 if (gui.in_use) | 1602 if (gui.in_use) |
1605 newval = gui_bg_default(); | 1603 newval = gui_bg_default(); |
1606 else | 1604 else |
1607 #endif | 1605 #endif |
1608 newval = term_bg_default(); | 1606 newval = term_bg_default(); |
1609 } | 1607 } |
1610 | 1608 |
1611 /* expand environment variables and ~ (since the | 1609 // expand environment variables and ~ (since the |
1612 * default value was already expanded, only | 1610 // default value was already expanded, only |
1613 * required when an environment variable was set | 1611 // required when an environment variable was set |
1614 * later */ | 1612 // later |
1615 if (newval == NULL) | 1613 if (newval == NULL) |
1616 newval = empty_option; | 1614 newval = empty_option; |
1617 else | 1615 else |
1618 { | 1616 { |
1619 s = option_expand(opt_idx, newval); | 1617 s = option_expand(opt_idx, newval); |
1621 s = newval; | 1619 s = newval; |
1622 newval = vim_strsave(s); | 1620 newval = vim_strsave(s); |
1623 } | 1621 } |
1624 new_value_alloced = TRUE; | 1622 new_value_alloced = TRUE; |
1625 } | 1623 } |
1626 else if (nextchar == '<') /* set to global val */ | 1624 else if (nextchar == '<') // set to global val |
1627 { | 1625 { |
1628 newval = vim_strsave(*(char_u **)get_varp_scope( | 1626 newval = vim_strsave(*(char_u **)get_varp_scope( |
1629 &(options[opt_idx]), OPT_GLOBAL)); | 1627 &(options[opt_idx]), OPT_GLOBAL)); |
1630 new_value_alloced = TRUE; | 1628 new_value_alloced = TRUE; |
1631 } | 1629 } |
1632 else | 1630 else |
1633 { | 1631 { |
1634 ++arg; /* jump to after the '=' or ':' */ | 1632 ++arg; // jump to after the '=' or ':' |
1635 | 1633 |
1636 /* | 1634 /* |
1637 * Set 'keywordprg' to ":help" if an empty | 1635 * Set 'keywordprg' to ":help" if an empty |
1638 * value was passed to :set by the user. | 1636 * value was passed to :set by the user. |
1639 * Misuse errbuf[] for the resulting string. | 1637 * Misuse errbuf[] for the resulting string. |
1694 STRCAT(errbuf, "h,l,"); | 1692 STRCAT(errbuf, "h,l,"); |
1695 if (i & 8) | 1693 if (i & 8) |
1696 STRCAT(errbuf, "<,>,"); | 1694 STRCAT(errbuf, "<,>,"); |
1697 if (i & 16) | 1695 if (i & 16) |
1698 STRCAT(errbuf, "[,],"); | 1696 STRCAT(errbuf, "[,],"); |
1699 if (*errbuf != NUL) /* remove trailing , */ | 1697 if (*errbuf != NUL) // remove trailing , |
1700 errbuf[STRLEN(errbuf) - 1] = NUL; | 1698 errbuf[STRLEN(errbuf) - 1] = NUL; |
1701 save_arg = arg; | 1699 save_arg = arg; |
1702 arg = (char_u *)errbuf; | 1700 arg = (char_u *)errbuf; |
1703 } | 1701 } |
1704 /* | 1702 /* |
1715 /* | 1713 /* |
1716 * Copy the new string into allocated memory. | 1714 * Copy the new string into allocated memory. |
1717 * Can't use set_string_option_direct(), because | 1715 * Can't use set_string_option_direct(), because |
1718 * we need to remove the backslashes. | 1716 * we need to remove the backslashes. |
1719 */ | 1717 */ |
1720 /* get a bit too much */ | 1718 // get a bit too much |
1721 newlen = (unsigned)STRLEN(arg) + 1; | 1719 newlen = (unsigned)STRLEN(arg) + 1; |
1722 if (adding || prepending || removing) | 1720 if (adding || prepending || removing) |
1723 newlen += (unsigned)STRLEN(origval) + 1; | 1721 newlen += (unsigned)STRLEN(origval) + 1; |
1724 newval = alloc(newlen); | 1722 newval = alloc(newlen); |
1725 if (newval == NULL) /* out of mem, don't change */ | 1723 if (newval == NULL) // out of mem, don't change |
1726 break; | 1724 break; |
1727 s = newval; | 1725 s = newval; |
1728 | 1726 |
1729 /* | 1727 /* |
1730 * Copy the string, skip over escaped chars. | 1728 * Copy the string, skip over escaped chars. |
1743 && (arg[1] != '\\' | 1741 && (arg[1] != '\\' |
1744 || (s == newval | 1742 || (s == newval |
1745 && arg[2] != '\\'))) | 1743 && arg[2] != '\\'))) |
1746 #endif | 1744 #endif |
1747 ) | 1745 ) |
1748 ++arg; /* remove backslash */ | 1746 ++arg; // remove backslash |
1749 if (has_mbyte | 1747 if (has_mbyte |
1750 && (i = (*mb_ptr2len)(arg)) > 1) | 1748 && (i = (*mb_ptr2len)(arg)) > 1) |
1751 { | 1749 { |
1752 /* copy multibyte char */ | 1750 // copy multibyte char |
1753 mch_memmove(s, arg, (size_t)i); | 1751 mch_memmove(s, arg, (size_t)i); |
1754 arg += i; | 1752 arg += i; |
1755 s += i; | 1753 s += i; |
1756 } | 1754 } |
1757 else | 1755 else |
1779 break; | 1777 break; |
1780 STRCPY(newval, s); | 1778 STRCPY(newval, s); |
1781 } | 1779 } |
1782 } | 1780 } |
1783 | 1781 |
1784 /* locate newval[] in origval[] when removing it | 1782 // locate newval[] in origval[] when removing it |
1785 * and when adding to avoid duplicates */ | 1783 // and when adding to avoid duplicates |
1786 i = 0; /* init for GCC */ | 1784 i = 0; // init for GCC |
1787 if (removing || (flags & P_NODUP)) | 1785 if (removing || (flags & P_NODUP)) |
1788 { | 1786 { |
1789 i = (int)STRLEN(newval); | 1787 i = (int)STRLEN(newval); |
1790 bs = 0; | 1788 bs = 0; |
1791 for (s = origval; *s; ++s) | 1789 for (s = origval; *s; ++s) |
1796 && STRNCMP(s, newval, i) == 0 | 1794 && STRNCMP(s, newval, i) == 0 |
1797 && (!(flags & P_COMMA) | 1795 && (!(flags & P_COMMA) |
1798 || s[i] == ',' | 1796 || s[i] == ',' |
1799 || s[i] == NUL)) | 1797 || s[i] == NUL)) |
1800 break; | 1798 break; |
1801 /* Count backslashes. Only a comma with an | 1799 // Count backslashes. Only a comma with an |
1802 * even number of backslashes or a single | 1800 // even number of backslashes or a single |
1803 * backslash preceded by a comma before it | 1801 // backslash preceded by a comma before it |
1804 * is recognized as a separator */ | 1802 // is recognized as a separator |
1805 if ((s > origval + 1 | 1803 if ((s > origval + 1 |
1806 && s[-1] == '\\' | 1804 && s[-1] == '\\' |
1807 && s[-2] != ',') | 1805 && s[-2] != ',') |
1808 || (s == origval + 1 | 1806 || (s == origval + 1 |
1809 && s[-1] == '\\')) | 1807 && s[-1] == '\\')) |
1811 ++bs; | 1809 ++bs; |
1812 else | 1810 else |
1813 bs = 0; | 1811 bs = 0; |
1814 } | 1812 } |
1815 | 1813 |
1816 /* do not add if already there */ | 1814 // do not add if already there |
1817 if ((adding || prepending) && *s) | 1815 if ((adding || prepending) && *s) |
1818 { | 1816 { |
1819 prepending = FALSE; | 1817 prepending = FALSE; |
1820 adding = FALSE; | 1818 adding = FALSE; |
1821 STRCPY(newval, origval); | 1819 STRCPY(newval, origval); |
1822 } | 1820 } |
1823 } | 1821 } |
1824 | 1822 |
1825 /* concatenate the two strings; add a ',' if | 1823 // concatenate the two strings; add a ',' if |
1826 * needed */ | 1824 // needed |
1827 if (adding || prepending) | 1825 if (adding || prepending) |
1828 { | 1826 { |
1829 comma = ((flags & P_COMMA) && *origval != NUL | 1827 comma = ((flags & P_COMMA) && *origval != NUL |
1830 && *newval != NUL); | 1828 && *newval != NUL); |
1831 if (adding) | 1829 if (adding) |
1832 { | 1830 { |
1833 i = (int)STRLEN(origval); | 1831 i = (int)STRLEN(origval); |
1834 /* strip a trailing comma, would get 2 */ | 1832 // strip a trailing comma, would get 2 |
1835 if (comma && i > 1 | 1833 if (comma && i > 1 |
1836 && (flags & P_ONECOMMA) == P_ONECOMMA | 1834 && (flags & P_ONECOMMA) == P_ONECOMMA |
1837 && origval[i - 1] == ',' | 1835 && origval[i - 1] == ',' |
1838 && origval[i - 2] != '\\') | 1836 && origval[i - 2] != '\\') |
1839 i--; | 1837 i--; |
1848 } | 1846 } |
1849 if (comma) | 1847 if (comma) |
1850 newval[i] = ','; | 1848 newval[i] = ','; |
1851 } | 1849 } |
1852 | 1850 |
1853 /* Remove newval[] from origval[]. (Note: "i" has | 1851 // Remove newval[] from origval[]. (Note: "i" has |
1854 * been set above and is used here). */ | 1852 // been set above and is used here). |
1855 if (removing) | 1853 if (removing) |
1856 { | 1854 { |
1857 STRCPY(newval, origval); | 1855 STRCPY(newval, origval); |
1858 if (*s) | 1856 if (*s) |
1859 { | 1857 { |
1860 /* may need to remove a comma */ | 1858 // may need to remove a comma |
1861 if (flags & P_COMMA) | 1859 if (flags & P_COMMA) |
1862 { | 1860 { |
1863 if (s == origval) | 1861 if (s == origval) |
1864 { | 1862 { |
1865 /* include comma after string */ | 1863 // include comma after string |
1866 if (s[i] == ',') | 1864 if (s[i] == ',') |
1867 ++i; | 1865 ++i; |
1868 } | 1866 } |
1869 else | 1867 else |
1870 { | 1868 { |
1871 /* include comma before string */ | 1869 // include comma before string |
1872 --s; | 1870 --s; |
1873 ++i; | 1871 ++i; |
1874 } | 1872 } |
1875 } | 1873 } |
1876 STRMOVE(newval + (s - origval), s + i); | 1874 STRMOVE(newval + (s - origval), s + i); |
1877 } | 1875 } |
1878 } | 1876 } |
1879 | 1877 |
1880 if (flags & P_FLAGLIST) | 1878 if (flags & P_FLAGLIST) |
1881 { | 1879 { |
1882 /* Remove flags that appear twice. */ | 1880 // Remove flags that appear twice. |
1883 for (s = newval; *s;) | 1881 for (s = newval; *s;) |
1884 { | 1882 { |
1885 /* if options have P_FLAGLIST and | 1883 // if options have P_FLAGLIST and |
1886 * P_ONECOMMA such as 'whichwrap' */ | 1884 // P_ONECOMMA such as 'whichwrap' |
1887 if (flags & P_ONECOMMA) | 1885 if (flags & P_ONECOMMA) |
1888 { | 1886 { |
1889 if (*s != ',' && *(s + 1) == ',' | 1887 if (*s != ',' && *(s + 1) == ',' |
1890 && vim_strchr(s + 2, *s) != NULL) | 1888 && vim_strchr(s + 2, *s) != NULL) |
1891 { | 1889 { |
1892 /* Remove the duplicated value and | 1890 // Remove the duplicated value and |
1893 * the next comma. */ | 1891 // the next comma. |
1894 STRMOVE(s, s + 2); | 1892 STRMOVE(s, s + 2); |
1895 continue; | 1893 continue; |
1896 } | 1894 } |
1897 } | 1895 } |
1898 else | 1896 else |
1906 } | 1904 } |
1907 ++s; | 1905 ++s; |
1908 } | 1906 } |
1909 } | 1907 } |
1910 | 1908 |
1911 if (save_arg != NULL) /* number for 'whichwrap' */ | 1909 if (save_arg != NULL) // number for 'whichwrap' |
1912 arg = save_arg; | 1910 arg = save_arg; |
1913 new_value_alloced = TRUE; | 1911 new_value_alloced = TRUE; |
1914 } | 1912 } |
1915 | 1913 |
1916 /* | 1914 /* |
1923 # ifdef FEAT_CRYPT | 1921 # ifdef FEAT_CRYPT |
1924 && options[opt_idx].indir != PV_KEY | 1922 && options[opt_idx].indir != PV_KEY |
1925 # endif | 1923 # endif |
1926 && origval != NULL && newval != NULL) | 1924 && origval != NULL && newval != NULL) |
1927 { | 1925 { |
1928 /* origval may be freed by | 1926 // origval may be freed by |
1929 * did_set_string_option(), make a copy. */ | 1927 // did_set_string_option(), make a copy. |
1930 saved_origval = vim_strsave(origval); | 1928 saved_origval = vim_strsave(origval); |
1931 /* newval (and varp) may become invalid if the | 1929 // newval (and varp) may become invalid if the |
1932 * buffer is closed by autocommands. */ | 1930 // buffer is closed by autocommands. |
1933 saved_newval = vim_strsave(newval); | 1931 saved_newval = vim_strsave(newval); |
1934 if (origval_l != NULL) | 1932 if (origval_l != NULL) |
1935 saved_origval_l = vim_strsave(origval_l); | 1933 saved_origval_l = vim_strsave(origval_l); |
1936 if (origval_g != NULL) | 1934 if (origval_g != NULL) |
1937 saved_origval_g = vim_strsave(origval_g); | 1935 saved_origval_g = vim_strsave(origval_g); |
1975 vim_free(saved_origval); | 1973 vim_free(saved_origval); |
1976 vim_free(saved_origval_l); | 1974 vim_free(saved_origval_l); |
1977 vim_free(saved_origval_g); | 1975 vim_free(saved_origval_g); |
1978 vim_free(saved_newval); | 1976 vim_free(saved_newval); |
1979 #endif | 1977 #endif |
1980 /* If error detected, print the error message. */ | 1978 // If error detected, print the error message. |
1981 if (errmsg != NULL) | 1979 if (errmsg != NULL) |
1982 goto skip; | 1980 goto skip; |
1983 } | 1981 } |
1984 else /* key code option */ | 1982 else // key code option |
1985 { | 1983 { |
1986 char_u *p; | 1984 char_u *p; |
1987 | 1985 |
1988 if (nextchar == '&') | 1986 if (nextchar == '&') |
1989 { | 1987 { |
1990 if (add_termcap_entry(key_name, TRUE) == FAIL) | 1988 if (add_termcap_entry(key_name, TRUE) == FAIL) |
1991 errmsg = N_("E522: Not found in termcap"); | 1989 errmsg = N_("E522: Not found in termcap"); |
1992 } | 1990 } |
1993 else | 1991 else |
1994 { | 1992 { |
1995 ++arg; /* jump to after the '=' or ':' */ | 1993 ++arg; // jump to after the '=' or ':' |
1996 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) | 1994 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) |
1997 if (*p == '\\' && p[1] != NUL) | 1995 if (*p == '\\' && p[1] != NUL) |
1998 ++p; | 1996 ++p; |
1999 nextchar = *p; | 1997 nextchar = *p; |
2000 *p = NUL; | 1998 *p = NUL; |
2034 { | 2032 { |
2035 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); | 2033 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); |
2036 i = (int)STRLEN(IObuff) + 2; | 2034 i = (int)STRLEN(IObuff) + 2; |
2037 if (i + (arg - startarg) < IOSIZE) | 2035 if (i + (arg - startarg) < IOSIZE) |
2038 { | 2036 { |
2039 /* append the argument with the error */ | 2037 // append the argument with the error |
2040 STRCAT(IObuff, ": "); | 2038 STRCAT(IObuff, ": "); |
2041 mch_memmove(IObuff + i, startarg, (arg - startarg)); | 2039 mch_memmove(IObuff + i, startarg, (arg - startarg)); |
2042 IObuff[i + (arg - startarg)] = NUL; | 2040 IObuff[i + (arg - startarg)] = NUL; |
2043 } | 2041 } |
2044 /* make sure all characters are printable */ | 2042 // make sure all characters are printable |
2045 trans_characters(IObuff, IOSIZE); | 2043 trans_characters(IObuff, IOSIZE); |
2046 | 2044 |
2047 ++no_wait_return; // wait_return done later | 2045 ++no_wait_return; // wait_return done later |
2048 emsg((char *)IObuff); // show error highlighted | 2046 emsg((char *)IObuff); // show error highlighted |
2049 --no_wait_return; | 2047 --no_wait_return; |
2055 } | 2053 } |
2056 | 2054 |
2057 theend: | 2055 theend: |
2058 if (silent_mode && did_show) | 2056 if (silent_mode && did_show) |
2059 { | 2057 { |
2060 /* After displaying option values in silent mode. */ | 2058 // After displaying option values in silent mode. |
2061 silent_mode = FALSE; | 2059 silent_mode = FALSE; |
2062 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | 2060 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
2063 msg_putchar('\n'); | 2061 msg_putchar('\n'); |
2064 cursor_on(); /* msg_start() switches it off */ | 2062 cursor_on(); // msg_start() switches it off |
2065 out_flush(); | 2063 out_flush(); |
2066 silent_mode = TRUE; | 2064 silent_mode = TRUE; |
2067 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ | 2065 info_message = FALSE; // use mch_msg(), not mch_errmsg() |
2068 } | 2066 } |
2069 | 2067 |
2070 return OK; | 2068 return OK; |
2071 } | 2069 } |
2072 | 2070 |
2084 { | 2082 { |
2085 long_u *p; | 2083 long_u *p; |
2086 | 2084 |
2087 options[opt_idx].flags |= P_WAS_SET; | 2085 options[opt_idx].flags |= P_WAS_SET; |
2088 | 2086 |
2089 /* When an option is set in the sandbox, from a modeline or in secure mode | 2087 // When an option is set in the sandbox, from a modeline or in secure mode |
2090 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the | 2088 // set the P_INSECURE flag. Otherwise, if a new value is stored reset the |
2091 * flag. */ | 2089 // flag. |
2092 p = insecure_flag(opt_idx, opt_flags); | 2090 p = insecure_flag(opt_idx, opt_flags); |
2093 if (!value_checked && (secure | 2091 if (!value_checked && (secure |
2094 #ifdef HAVE_SANDBOX | 2092 #ifdef HAVE_SANDBOX |
2095 || sandbox != 0 | 2093 || sandbox != 0 |
2096 #endif | 2094 #endif |
2141 */ | 2139 */ |
2142 void | 2140 void |
2143 set_options_bin( | 2141 set_options_bin( |
2144 int oldval, | 2142 int oldval, |
2145 int newval, | 2143 int newval, |
2146 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ | 2144 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
2147 { | 2145 { |
2148 /* | 2146 /* |
2149 * The option values that are changed when 'bin' changes are | 2147 * The option values that are changed when 'bin' changes are |
2150 * copied when 'bin is set and restored when 'bin' is reset. | 2148 * copied when 'bin is set and restored when 'bin' is reset. |
2151 */ | 2149 */ |
2152 if (newval) | 2150 if (newval) |
2153 { | 2151 { |
2154 if (!oldval) /* switched on */ | 2152 if (!oldval) // switched on |
2155 { | 2153 { |
2156 if (!(opt_flags & OPT_GLOBAL)) | 2154 if (!(opt_flags & OPT_GLOBAL)) |
2157 { | 2155 { |
2158 curbuf->b_p_tw_nobin = curbuf->b_p_tw; | 2156 curbuf->b_p_tw_nobin = curbuf->b_p_tw; |
2159 curbuf->b_p_wm_nobin = curbuf->b_p_wm; | 2157 curbuf->b_p_wm_nobin = curbuf->b_p_wm; |
2169 } | 2167 } |
2170 } | 2168 } |
2171 | 2169 |
2172 if (!(opt_flags & OPT_GLOBAL)) | 2170 if (!(opt_flags & OPT_GLOBAL)) |
2173 { | 2171 { |
2174 curbuf->b_p_tw = 0; /* no automatic line wrap */ | 2172 curbuf->b_p_tw = 0; // no automatic line wrap |
2175 curbuf->b_p_wm = 0; /* no automatic line wrap */ | 2173 curbuf->b_p_wm = 0; // no automatic line wrap |
2176 curbuf->b_p_ml = 0; /* no modelines */ | 2174 curbuf->b_p_ml = 0; // no modelines |
2177 curbuf->b_p_et = 0; /* no expandtab */ | 2175 curbuf->b_p_et = 0; // no expandtab |
2178 } | 2176 } |
2179 if (!(opt_flags & OPT_LOCAL)) | 2177 if (!(opt_flags & OPT_LOCAL)) |
2180 { | 2178 { |
2181 p_tw = 0; | 2179 p_tw = 0; |
2182 p_wm = 0; | 2180 p_wm = 0; |
2183 p_ml = FALSE; | 2181 p_ml = FALSE; |
2184 p_et = FALSE; | 2182 p_et = FALSE; |
2185 p_bin = TRUE; /* needed when called for the "-b" argument */ | 2183 p_bin = TRUE; // needed when called for the "-b" argument |
2186 } | 2184 } |
2187 } | 2185 } |
2188 else if (oldval) /* switched off */ | 2186 else if (oldval) // switched off |
2189 { | 2187 { |
2190 if (!(opt_flags & OPT_GLOBAL)) | 2188 if (!(opt_flags & OPT_GLOBAL)) |
2191 { | 2189 { |
2192 curbuf->b_p_tw = curbuf->b_p_tw_nobin; | 2190 curbuf->b_p_tw = curbuf->b_p_tw_nobin; |
2193 curbuf->b_p_wm = curbuf->b_p_wm_nobin; | 2191 curbuf->b_p_wm = curbuf->b_p_wm_nobin; |
2211 * Return pointer to NameBuff, or NULL when not expanded. | 2209 * Return pointer to NameBuff, or NULL when not expanded. |
2212 */ | 2210 */ |
2213 static char_u * | 2211 static char_u * |
2214 option_expand(int opt_idx, char_u *val) | 2212 option_expand(int opt_idx, char_u *val) |
2215 { | 2213 { |
2216 /* if option doesn't need expansion nothing to do */ | 2214 // if option doesn't need expansion nothing to do |
2217 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) | 2215 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) |
2218 return NULL; | 2216 return NULL; |
2219 | 2217 |
2220 /* If val is longer than MAXPATHL no meaningful expansion can be done, | 2218 // If val is longer than MAXPATHL no meaningful expansion can be done, |
2221 * expand_env() would truncate the string. */ | 2219 // expand_env() would truncate the string. |
2222 if (val != NULL && STRLEN(val) > MAXPATHL) | 2220 if (val != NULL && STRLEN(val) > MAXPATHL) |
2223 return NULL; | 2221 return NULL; |
2224 | 2222 |
2225 if (val == NULL) | 2223 if (val == NULL) |
2226 val = *(char_u **)options[opt_idx].var; | 2224 val = *(char_u **)options[opt_idx].var; |
2235 (char_u **)options[opt_idx].var == &p_tags, FALSE, | 2233 (char_u **)options[opt_idx].var == &p_tags, FALSE, |
2236 #ifdef FEAT_SPELL | 2234 #ifdef FEAT_SPELL |
2237 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : | 2235 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : |
2238 #endif | 2236 #endif |
2239 NULL); | 2237 NULL); |
2240 if (STRCMP(NameBuff, val) == 0) /* they are the same */ | 2238 if (STRCMP(NameBuff, val) == 0) // they are the same |
2241 return NULL; | 2239 return NULL; |
2242 | 2240 |
2243 return NameBuff; | 2241 return NameBuff; |
2244 } | 2242 } |
2245 | 2243 |
2248 * option values. | 2246 * option values. |
2249 */ | 2247 */ |
2250 static void | 2248 static void |
2251 didset_options(void) | 2249 didset_options(void) |
2252 { | 2250 { |
2253 /* initialize the table for 'iskeyword' et.al. */ | 2251 // initialize the table for 'iskeyword' et.al. |
2254 (void)init_chartab(); | 2252 (void)init_chartab(); |
2255 | 2253 |
2256 didset_string_options(); | 2254 didset_string_options(); |
2257 | 2255 |
2258 #ifdef FEAT_SPELL | 2256 #ifdef FEAT_SPELL |
2264 #ifdef FEAT_CMDWIN | 2262 #ifdef FEAT_CMDWIN |
2265 // set cedit_key | 2263 // set cedit_key |
2266 (void)check_cedit(); | 2264 (void)check_cedit(); |
2267 #endif | 2265 #endif |
2268 #ifdef FEAT_LINEBREAK | 2266 #ifdef FEAT_LINEBREAK |
2269 /* initialize the table for 'breakat'. */ | 2267 // initialize the table for 'breakat'. |
2270 fill_breakat_flags(); | 2268 fill_breakat_flags(); |
2271 #endif | 2269 #endif |
2272 after_copy_winopt(curwin); | 2270 after_copy_winopt(curwin); |
2273 } | 2271 } |
2274 | 2272 |
2276 * More side effects of setting options. | 2274 * More side effects of setting options. |
2277 */ | 2275 */ |
2278 static void | 2276 static void |
2279 didset_options2(void) | 2277 didset_options2(void) |
2280 { | 2278 { |
2281 /* Initialize the highlight_attr[] table. */ | 2279 // Initialize the highlight_attr[] table. |
2282 (void)highlight_changed(); | 2280 (void)highlight_changed(); |
2283 | 2281 |
2284 /* Parse default for 'wildmode' */ | 2282 // Parse default for 'wildmode' |
2285 check_opt_wim(); | 2283 check_opt_wim(); |
2286 | 2284 |
2287 (void)set_chars_option(&p_lcs); | 2285 (void)set_chars_option(&p_lcs); |
2288 /* Parse default for 'fillchars'. */ | 2286 // Parse default for 'fillchars'. |
2289 (void)set_chars_option(&p_fcs); | 2287 (void)set_chars_option(&p_fcs); |
2290 | 2288 |
2291 #ifdef FEAT_CLIPBOARD | 2289 #ifdef FEAT_CLIPBOARD |
2292 /* Parse default for 'clipboard' */ | 2290 // Parse default for 'clipboard' |
2293 (void)check_clipboard_option(); | 2291 (void)check_clipboard_option(); |
2294 #endif | 2292 #endif |
2295 #ifdef FEAT_VARTABS | 2293 #ifdef FEAT_VARTABS |
2296 vim_free(curbuf->b_p_vsts_array); | 2294 vim_free(curbuf->b_p_vsts_array); |
2297 tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array); | 2295 tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array); |
2392 case PV_INEX: return &curbuf->b_p_inex_flags; | 2390 case PV_INEX: return &curbuf->b_p_inex_flags; |
2393 # endif | 2391 # endif |
2394 #endif | 2392 #endif |
2395 } | 2393 } |
2396 | 2394 |
2397 /* Nothing special, return global flags field. */ | 2395 // Nothing special, return global flags field. |
2398 return &options[opt_idx].flags; | 2396 return &options[opt_idx].flags; |
2399 } | 2397 } |
2400 #endif | 2398 #endif |
2401 | 2399 |
2402 #if defined(FEAT_TITLE) || defined(PROTO) | 2400 #if defined(FEAT_TITLE) || defined(PROTO) |
2437 int indir = (int)options[opt_idx].indir; | 2435 int indir = (int)options[opt_idx].indir; |
2438 sctx_T new_script_ctx = script_ctx; | 2436 sctx_T new_script_ctx = script_ctx; |
2439 | 2437 |
2440 new_script_ctx.sc_lnum += sourcing_lnum; | 2438 new_script_ctx.sc_lnum += sourcing_lnum; |
2441 | 2439 |
2442 /* Remember where the option was set. For local options need to do that | 2440 // Remember where the option was set. For local options need to do that |
2443 * in the buffer or window structure. */ | 2441 // in the buffer or window structure. |
2444 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) | 2442 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) |
2445 options[opt_idx].script_ctx = new_script_ctx; | 2443 options[opt_idx].script_ctx = new_script_ctx; |
2446 if (both || (opt_flags & OPT_LOCAL)) | 2444 if (both || (opt_flags & OPT_LOCAL)) |
2447 { | 2445 { |
2448 if (indir & PV_BUF) | 2446 if (indir & PV_BUF) |
2483 * Set the value of a boolean option, and take care of side effects. | 2481 * Set the value of a boolean option, and take care of side effects. |
2484 * Returns NULL for success, or an error message for an error. | 2482 * Returns NULL for success, or an error message for an error. |
2485 */ | 2483 */ |
2486 static char * | 2484 static char * |
2487 set_bool_option( | 2485 set_bool_option( |
2488 int opt_idx, /* index in options[] table */ | 2486 int opt_idx, // index in options[] table |
2489 char_u *varp, /* pointer to the option variable */ | 2487 char_u *varp, // pointer to the option variable |
2490 int value, /* new value */ | 2488 int value, // new value |
2491 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ | 2489 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
2492 { | 2490 { |
2493 int old_value = *(int *)varp; | 2491 int old_value = *(int *)varp; |
2494 #if defined(FEAT_EVAL) | 2492 #if defined(FEAT_EVAL) |
2495 int old_global_value = 0; | 2493 int old_global_value = 0; |
2496 #endif | 2494 #endif |
2497 | 2495 |
2498 /* Disallow changing some options from secure mode */ | 2496 // Disallow changing some options from secure mode |
2499 if ((secure | 2497 if ((secure |
2500 #ifdef HAVE_SANDBOX | 2498 #ifdef HAVE_SANDBOX |
2501 || sandbox != 0 | 2499 || sandbox != 0 |
2502 #endif | 2500 #endif |
2503 ) && (options[opt_idx].flags & P_SECURE)) | 2501 ) && (options[opt_idx].flags & P_SECURE)) |
2510 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | 2508 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
2511 old_global_value = *(int *)get_varp_scope(&(options[opt_idx]), | 2509 old_global_value = *(int *)get_varp_scope(&(options[opt_idx]), |
2512 OPT_GLOBAL); | 2510 OPT_GLOBAL); |
2513 #endif | 2511 #endif |
2514 | 2512 |
2515 *(int *)varp = value; /* set the new value */ | 2513 *(int *)varp = value; // set the new value |
2516 #ifdef FEAT_EVAL | 2514 #ifdef FEAT_EVAL |
2517 /* Remember where the option was set. */ | 2515 // Remember where the option was set. |
2518 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); | 2516 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
2519 #endif | 2517 #endif |
2520 | 2518 |
2521 #ifdef FEAT_GUI | 2519 #ifdef FEAT_GUI |
2522 need_mouse_correct = TRUE; | 2520 need_mouse_correct = TRUE; |
2523 #endif | 2521 #endif |
2524 | 2522 |
2525 /* May set global value for local option. */ | 2523 // May set global value for local option. |
2526 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | 2524 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
2527 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; | 2525 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; |
2528 | 2526 |
2529 /* | 2527 /* |
2530 * Handle side effects of changing a bool option. | 2528 * Handle side effects of changing a bool option. |
2531 */ | 2529 */ |
2532 | 2530 |
2533 /* 'compatible' */ | 2531 // 'compatible' |
2534 if ((int *)varp == &p_cp) | 2532 if ((int *)varp == &p_cp) |
2535 compatible_set(); | 2533 compatible_set(); |
2536 | 2534 |
2537 #ifdef FEAT_LANGMAP | 2535 #ifdef FEAT_LANGMAP |
2538 if ((int *)varp == &p_lrm) | 2536 if ((int *)varp == &p_lrm) |
2539 /* 'langremap' -> !'langnoremap' */ | 2537 // 'langremap' -> !'langnoremap' |
2540 p_lnr = !p_lrm; | 2538 p_lnr = !p_lrm; |
2541 else if ((int *)varp == &p_lnr) | 2539 else if ((int *)varp == &p_lnr) |
2542 /* 'langnoremap' -> !'langremap' */ | 2540 // 'langnoremap' -> !'langremap' |
2543 p_lrm = !p_lnr; | 2541 p_lrm = !p_lnr; |
2544 #endif | 2542 #endif |
2545 | 2543 |
2546 #ifdef FEAT_SYN_HL | 2544 #ifdef FEAT_SYN_HL |
2547 else if ((int *)varp == &curwin->w_p_cul && !value && old_value) | 2545 else if ((int *)varp == &curwin->w_p_cul && !value && old_value) |
2548 reset_cursorline(); | 2546 reset_cursorline(); |
2549 #endif | 2547 #endif |
2550 | 2548 |
2551 #ifdef FEAT_PERSISTENT_UNDO | 2549 #ifdef FEAT_PERSISTENT_UNDO |
2552 /* 'undofile' */ | 2550 // 'undofile' |
2553 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) | 2551 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) |
2554 { | 2552 { |
2555 /* Only take action when the option was set. When reset we do not | 2553 // Only take action when the option was set. When reset we do not |
2556 * delete the undo file, the option may be set again without making | 2554 // delete the undo file, the option may be set again without making |
2557 * any changes in between. */ | 2555 // any changes in between. |
2558 if (curbuf->b_p_udf || p_udf) | 2556 if (curbuf->b_p_udf || p_udf) |
2559 { | 2557 { |
2560 char_u hash[UNDO_HASH_SIZE]; | 2558 char_u hash[UNDO_HASH_SIZE]; |
2561 buf_T *save_curbuf = curbuf; | 2559 buf_T *save_curbuf = curbuf; |
2562 | 2560 |
2563 FOR_ALL_BUFFERS(curbuf) | 2561 FOR_ALL_BUFFERS(curbuf) |
2564 { | 2562 { |
2565 /* When 'undofile' is set globally: for every buffer, otherwise | 2563 // When 'undofile' is set globally: for every buffer, otherwise |
2566 * only for the current buffer: Try to read in the undofile, | 2564 // only for the current buffer: Try to read in the undofile, |
2567 * if one exists, the buffer wasn't changed and the buffer was | 2565 // if one exists, the buffer wasn't changed and the buffer was |
2568 * loaded */ | 2566 // loaded |
2569 if ((curbuf == save_curbuf | 2567 if ((curbuf == save_curbuf |
2570 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) | 2568 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) |
2571 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) | 2569 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) |
2572 { | 2570 { |
2573 u_compute_hash(hash); | 2571 u_compute_hash(hash); |
2579 } | 2577 } |
2580 #endif | 2578 #endif |
2581 | 2579 |
2582 else if ((int *)varp == &curbuf->b_p_ro) | 2580 else if ((int *)varp == &curbuf->b_p_ro) |
2583 { | 2581 { |
2584 /* when 'readonly' is reset globally, also reset readonlymode */ | 2582 // when 'readonly' is reset globally, also reset readonlymode |
2585 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) | 2583 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) |
2586 readonlymode = FALSE; | 2584 readonlymode = FALSE; |
2587 | 2585 |
2588 /* when 'readonly' is set may give W10 again */ | 2586 // when 'readonly' is set may give W10 again |
2589 if (curbuf->b_p_ro) | 2587 if (curbuf->b_p_ro) |
2590 curbuf->b_did_warn = FALSE; | 2588 curbuf->b_did_warn = FALSE; |
2591 | 2589 |
2592 #ifdef FEAT_TITLE | 2590 #ifdef FEAT_TITLE |
2593 redraw_titles(); | 2591 redraw_titles(); |
2600 if (!p_mh) | 2598 if (!p_mh) |
2601 gui_mch_mousehide(FALSE); | 2599 gui_mch_mousehide(FALSE); |
2602 } | 2600 } |
2603 #endif | 2601 #endif |
2604 | 2602 |
2605 /* when 'modifiable' is changed, redraw the window title */ | 2603 // when 'modifiable' is changed, redraw the window title |
2606 else if ((int *)varp == &curbuf->b_p_ma) | 2604 else if ((int *)varp == &curbuf->b_p_ma) |
2607 { | 2605 { |
2608 # ifdef FEAT_TERMINAL | 2606 # ifdef FEAT_TERMINAL |
2609 /* Cannot set 'modifiable' when in Terminal mode. */ | 2607 // Cannot set 'modifiable' when in Terminal mode. |
2610 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) | 2608 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf) |
2611 && curbuf->b_term != NULL && !term_is_finished(curbuf)))) | 2609 && curbuf->b_term != NULL && !term_is_finished(curbuf)))) |
2612 { | 2610 { |
2613 curbuf->b_p_ma = FALSE; | 2611 curbuf->b_p_ma = FALSE; |
2614 return N_("E946: Cannot make a terminal with running job modifiable"); | 2612 return N_("E946: Cannot make a terminal with running job modifiable"); |
2617 # ifdef FEAT_TITLE | 2615 # ifdef FEAT_TITLE |
2618 redraw_titles(); | 2616 redraw_titles(); |
2619 # endif | 2617 # endif |
2620 } | 2618 } |
2621 #ifdef FEAT_TITLE | 2619 #ifdef FEAT_TITLE |
2622 /* when 'endofline' is changed, redraw the window title */ | 2620 // when 'endofline' is changed, redraw the window title |
2623 else if ((int *)varp == &curbuf->b_p_eol) | 2621 else if ((int *)varp == &curbuf->b_p_eol) |
2624 { | 2622 { |
2625 redraw_titles(); | 2623 redraw_titles(); |
2626 } | 2624 } |
2627 /* when 'fixeol' is changed, redraw the window title */ | 2625 // when 'fixeol' is changed, redraw the window title |
2628 else if ((int *)varp == &curbuf->b_p_fixeol) | 2626 else if ((int *)varp == &curbuf->b_p_fixeol) |
2629 { | 2627 { |
2630 redraw_titles(); | 2628 redraw_titles(); |
2631 } | 2629 } |
2632 /* when 'bomb' is changed, redraw the window title and tab page text */ | 2630 // when 'bomb' is changed, redraw the window title and tab page text |
2633 else if ((int *)varp == &curbuf->b_p_bomb) | 2631 else if ((int *)varp == &curbuf->b_p_bomb) |
2634 { | 2632 { |
2635 redraw_titles(); | 2633 redraw_titles(); |
2636 } | 2634 } |
2637 #endif | 2635 #endif |
2638 | 2636 |
2639 /* when 'bin' is set also set some other options */ | 2637 // when 'bin' is set also set some other options |
2640 else if ((int *)varp == &curbuf->b_p_bin) | 2638 else if ((int *)varp == &curbuf->b_p_bin) |
2641 { | 2639 { |
2642 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); | 2640 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); |
2643 #ifdef FEAT_TITLE | 2641 #ifdef FEAT_TITLE |
2644 redraw_titles(); | 2642 redraw_titles(); |
2645 #endif | 2643 #endif |
2646 } | 2644 } |
2647 | 2645 |
2648 /* when 'buflisted' changes, trigger autocommands */ | 2646 // when 'buflisted' changes, trigger autocommands |
2649 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) | 2647 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) |
2650 { | 2648 { |
2651 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, | 2649 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, |
2652 NULL, NULL, TRUE, curbuf); | 2650 NULL, NULL, TRUE, curbuf); |
2653 } | 2651 } |
2654 | 2652 |
2655 /* when 'swf' is set, create swapfile, when reset remove swapfile */ | 2653 // when 'swf' is set, create swapfile, when reset remove swapfile |
2656 else if ((int *)varp == &curbuf->b_p_swf) | 2654 else if ((int *)varp == &curbuf->b_p_swf) |
2657 { | 2655 { |
2658 if (curbuf->b_p_swf && p_uc) | 2656 if (curbuf->b_p_swf && p_uc) |
2659 ml_open_file(curbuf); /* create the swap file */ | 2657 ml_open_file(curbuf); // create the swap file |
2660 else | 2658 else |
2661 /* no need to reset curbuf->b_may_swap, ml_open_file() will check | 2659 // no need to reset curbuf->b_may_swap, ml_open_file() will check |
2662 * buf->b_p_swf */ | 2660 // buf->b_p_swf |
2663 mf_close_file(curbuf, TRUE); /* remove the swap file */ | 2661 mf_close_file(curbuf, TRUE); // remove the swap file |
2664 } | 2662 } |
2665 | 2663 |
2666 /* when 'terse' is set change 'shortmess' */ | 2664 // when 'terse' is set change 'shortmess' |
2667 else if ((int *)varp == &p_terse) | 2665 else if ((int *)varp == &p_terse) |
2668 { | 2666 { |
2669 char_u *p; | 2667 char_u *p; |
2670 | 2668 |
2671 p = vim_strchr(p_shm, SHM_SEARCH); | 2669 p = vim_strchr(p_shm, SHM_SEARCH); |
2672 | 2670 |
2673 /* insert 's' in p_shm */ | 2671 // insert 's' in p_shm |
2674 if (p_terse && p == NULL) | 2672 if (p_terse && p == NULL) |
2675 { | 2673 { |
2676 STRCPY(IObuff, p_shm); | 2674 STRCPY(IObuff, p_shm); |
2677 STRCAT(IObuff, "s"); | 2675 STRCAT(IObuff, "s"); |
2678 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); | 2676 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); |
2679 } | 2677 } |
2680 /* remove 's' from p_shm */ | 2678 // remove 's' from p_shm |
2681 else if (!p_terse && p != NULL) | 2679 else if (!p_terse && p != NULL) |
2682 STRMOVE(p, p + 1); | 2680 STRMOVE(p, p + 1); |
2683 } | 2681 } |
2684 | 2682 |
2685 /* when 'paste' is set or reset also change other options */ | 2683 // when 'paste' is set or reset also change other options |
2686 else if ((int *)varp == &p_paste) | 2684 else if ((int *)varp == &p_paste) |
2687 { | 2685 { |
2688 paste_option_changed(); | 2686 paste_option_changed(); |
2689 } | 2687 } |
2690 | 2688 |
2691 /* when 'insertmode' is set from an autocommand need to do work here */ | 2689 // when 'insertmode' is set from an autocommand need to do work here |
2692 else if ((int *)varp == &p_im) | 2690 else if ((int *)varp == &p_im) |
2693 { | 2691 { |
2694 if (p_im) | 2692 if (p_im) |
2695 { | 2693 { |
2696 if ((State & INSERT) == 0) | 2694 if ((State & INSERT) == 0) |
2697 need_start_insertmode = TRUE; | 2695 need_start_insertmode = TRUE; |
2698 stop_insert_mode = FALSE; | 2696 stop_insert_mode = FALSE; |
2699 } | 2697 } |
2700 /* only reset if it was set previously */ | 2698 // only reset if it was set previously |
2701 else if (old_value) | 2699 else if (old_value) |
2702 { | 2700 { |
2703 need_start_insertmode = FALSE; | 2701 need_start_insertmode = FALSE; |
2704 stop_insert_mode = TRUE; | 2702 stop_insert_mode = TRUE; |
2705 if (restart_edit != 0 && mode_displayed) | 2703 if (restart_edit != 0 && mode_displayed) |
2706 clear_cmdline = TRUE; /* remove "(insert)" */ | 2704 clear_cmdline = TRUE; // remove "(insert)" |
2707 restart_edit = 0; | 2705 restart_edit = 0; |
2708 } | 2706 } |
2709 } | 2707 } |
2710 | 2708 |
2711 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ | 2709 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw |
2712 else if ((int *)varp == &p_ic && p_hls) | 2710 else if ((int *)varp == &p_ic && p_hls) |
2713 { | 2711 { |
2714 redraw_all_later(SOME_VALID); | 2712 redraw_all_later(SOME_VALID); |
2715 } | 2713 } |
2716 | 2714 |
2717 #ifdef FEAT_SEARCH_EXTRA | 2715 #ifdef FEAT_SEARCH_EXTRA |
2718 /* when 'hlsearch' is set or reset: reset no_hlsearch */ | 2716 // when 'hlsearch' is set or reset: reset no_hlsearch |
2719 else if ((int *)varp == &p_hls) | 2717 else if ((int *)varp == &p_hls) |
2720 { | 2718 { |
2721 set_no_hlsearch(FALSE); | 2719 set_no_hlsearch(FALSE); |
2722 } | 2720 } |
2723 #endif | 2721 #endif |
2724 | 2722 |
2725 /* when 'scrollbind' is set: snapshot the current position to avoid a jump | 2723 // when 'scrollbind' is set: snapshot the current position to avoid a jump |
2726 * at the end of normal_cmd() */ | 2724 // at the end of normal_cmd() |
2727 else if ((int *)varp == &curwin->w_p_scb) | 2725 else if ((int *)varp == &curwin->w_p_scb) |
2728 { | 2726 { |
2729 if (curwin->w_p_scb) | 2727 if (curwin->w_p_scb) |
2730 { | 2728 { |
2731 do_check_scrollbind(FALSE); | 2729 do_check_scrollbind(FALSE); |
2732 curwin->w_scbind_pos = curwin->w_topline; | 2730 curwin->w_scbind_pos = curwin->w_topline; |
2733 } | 2731 } |
2734 } | 2732 } |
2735 | 2733 |
2736 #if defined(FEAT_QUICKFIX) | 2734 #if defined(FEAT_QUICKFIX) |
2737 /* There can be only one window with 'previewwindow' set. */ | 2735 // There can be only one window with 'previewwindow' set. |
2738 else if ((int *)varp == &curwin->w_p_pvw) | 2736 else if ((int *)varp == &curwin->w_p_pvw) |
2739 { | 2737 { |
2740 if (curwin->w_p_pvw) | 2738 if (curwin->w_p_pvw) |
2741 { | 2739 { |
2742 win_T *win; | 2740 win_T *win; |
2749 } | 2747 } |
2750 } | 2748 } |
2751 } | 2749 } |
2752 #endif | 2750 #endif |
2753 | 2751 |
2754 /* when 'textmode' is set or reset also change 'fileformat' */ | 2752 // when 'textmode' is set or reset also change 'fileformat' |
2755 else if ((int *)varp == &curbuf->b_p_tx) | 2753 else if ((int *)varp == &curbuf->b_p_tx) |
2756 { | 2754 { |
2757 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); | 2755 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); |
2758 } | 2756 } |
2759 | 2757 |
2760 /* when 'textauto' is set or reset also change 'fileformats' */ | 2758 // when 'textauto' is set or reset also change 'fileformats' |
2761 else if ((int *)varp == &p_ta) | 2759 else if ((int *)varp == &p_ta) |
2762 { | 2760 { |
2763 set_string_option_direct((char_u *)"ffs", -1, | 2761 set_string_option_direct((char_u *)"ffs", -1, |
2764 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", | 2762 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", |
2765 OPT_FREE | opt_flags, 0); | 2763 OPT_FREE | opt_flags, 0); |
2770 * keyword characters. | 2768 * keyword characters. |
2771 */ | 2769 */ |
2772 #ifdef FEAT_LISP | 2770 #ifdef FEAT_LISP |
2773 else if (varp == (char_u *)&(curbuf->b_p_lisp)) | 2771 else if (varp == (char_u *)&(curbuf->b_p_lisp)) |
2774 { | 2772 { |
2775 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ | 2773 (void)buf_init_chartab(curbuf, FALSE); // ignore errors |
2776 } | 2774 } |
2777 #endif | 2775 #endif |
2778 | 2776 |
2779 #ifdef FEAT_TITLE | 2777 #ifdef FEAT_TITLE |
2780 /* when 'title' changed, may need to change the title; same for 'icon' */ | 2778 // when 'title' changed, may need to change the title; same for 'icon' |
2781 else if ((int *)varp == &p_title || (int *)varp == &p_icon) | 2779 else if ((int *)varp == &p_title || (int *)varp == &p_icon) |
2782 { | 2780 { |
2783 did_set_title(); | 2781 did_set_title(); |
2784 } | 2782 } |
2785 #endif | 2783 #endif |
2786 | 2784 |
2787 else if ((int *)varp == &curbuf->b_changed) | 2785 else if ((int *)varp == &curbuf->b_changed) |
2788 { | 2786 { |
2789 if (!value) | 2787 if (!value) |
2790 save_file_ff(curbuf); /* Buffer is unchanged */ | 2788 save_file_ff(curbuf); // Buffer is unchanged |
2791 #ifdef FEAT_TITLE | 2789 #ifdef FEAT_TITLE |
2792 redraw_titles(); | 2790 redraw_titles(); |
2793 #endif | 2791 #endif |
2794 modified_was_set = value; | 2792 modified_was_set = value; |
2795 } | 2793 } |
2808 psepc = '\\'; | 2806 psepc = '\\'; |
2809 psepcN = '/'; | 2807 psepcN = '/'; |
2810 pseps[0] = '\\'; | 2808 pseps[0] = '\\'; |
2811 } | 2809 } |
2812 | 2810 |
2813 /* need to adjust the file name arguments and buffer names. */ | 2811 // need to adjust the file name arguments and buffer names. |
2814 buflist_slash_adjust(); | 2812 buflist_slash_adjust(); |
2815 alist_slash_adjust(); | 2813 alist_slash_adjust(); |
2816 # ifdef FEAT_EVAL | 2814 # ifdef FEAT_EVAL |
2817 scriptnames_slash_adjust(); | 2815 scriptnames_slash_adjust(); |
2818 # endif | 2816 # endif |
2819 } | 2817 } |
2820 #endif | 2818 #endif |
2821 | 2819 |
2822 /* If 'wrap' is set, set w_leftcol to zero. */ | 2820 // If 'wrap' is set, set w_leftcol to zero. |
2823 else if ((int *)varp == &curwin->w_p_wrap) | 2821 else if ((int *)varp == &curwin->w_p_wrap) |
2824 { | 2822 { |
2825 if (curwin->w_p_wrap) | 2823 if (curwin->w_p_wrap) |
2826 curwin->w_leftcol = 0; | 2824 curwin->w_leftcol = 0; |
2827 } | 2825 } |
2865 #endif | 2863 #endif |
2866 | 2864 |
2867 #ifdef FEAT_AUTOCHDIR | 2865 #ifdef FEAT_AUTOCHDIR |
2868 else if ((int *)varp == &p_acd) | 2866 else if ((int *)varp == &p_acd) |
2869 { | 2867 { |
2870 /* Change directories when the 'acd' option is set now. */ | 2868 // Change directories when the 'acd' option is set now. |
2871 DO_AUTOCHDIR; | 2869 DO_AUTOCHDIR; |
2872 } | 2870 } |
2873 #endif | 2871 #endif |
2874 | 2872 |
2875 #ifdef FEAT_DIFF | 2873 #ifdef FEAT_DIFF |
2876 /* 'diff' */ | 2874 // 'diff' |
2877 else if ((int *)varp == &curwin->w_p_diff) | 2875 else if ((int *)varp == &curwin->w_p_diff) |
2878 { | 2876 { |
2879 /* May add or remove the buffer from the list of diff buffers. */ | 2877 // May add or remove the buffer from the list of diff buffers. |
2880 diff_buf_adjust(curwin); | 2878 diff_buf_adjust(curwin); |
2881 # ifdef FEAT_FOLDING | 2879 # ifdef FEAT_FOLDING |
2882 if (foldmethodIsDiff(curwin)) | 2880 if (foldmethodIsDiff(curwin)) |
2883 foldUpdateAll(curwin); | 2881 foldUpdateAll(curwin); |
2884 # endif | 2882 # endif |
2885 } | 2883 } |
2886 #endif | 2884 #endif |
2887 | 2885 |
2888 #ifdef HAVE_INPUT_METHOD | 2886 #ifdef HAVE_INPUT_METHOD |
2889 /* 'imdisable' */ | 2887 // 'imdisable' |
2890 else if ((int *)varp == &p_imdisable) | 2888 else if ((int *)varp == &p_imdisable) |
2891 { | 2889 { |
2892 /* Only de-activate it here, it will be enabled when changing mode. */ | 2890 // Only de-activate it here, it will be enabled when changing mode. |
2893 if (p_imdisable) | 2891 if (p_imdisable) |
2894 im_set_active(FALSE); | 2892 im_set_active(FALSE); |
2895 else if (State & INSERT) | 2893 else if (State & INSERT) |
2896 /* When the option is set from an autocommand, it may need to take | 2894 // When the option is set from an autocommand, it may need to take |
2897 * effect right away. */ | 2895 // effect right away. |
2898 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); | 2896 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); |
2899 } | 2897 } |
2900 #endif | 2898 #endif |
2901 | 2899 |
2902 #ifdef FEAT_SPELL | 2900 #ifdef FEAT_SPELL |
2903 /* 'spell' */ | 2901 // 'spell' |
2904 else if ((int *)varp == &curwin->w_p_spell) | 2902 else if ((int *)varp == &curwin->w_p_spell) |
2905 { | 2903 { |
2906 if (curwin->w_p_spell) | 2904 if (curwin->w_p_spell) |
2907 { | 2905 { |
2908 char *errmsg = did_set_spelllang(curwin); | 2906 char *errmsg = did_set_spelllang(curwin); |
2921 /* | 2919 /* |
2922 * 'arabic' is set, handle various sub-settings. | 2920 * 'arabic' is set, handle various sub-settings. |
2923 */ | 2921 */ |
2924 if (!p_tbidi) | 2922 if (!p_tbidi) |
2925 { | 2923 { |
2926 /* set rightleft mode */ | 2924 // set rightleft mode |
2927 if (!curwin->w_p_rl) | 2925 if (!curwin->w_p_rl) |
2928 { | 2926 { |
2929 curwin->w_p_rl = TRUE; | 2927 curwin->w_p_rl = TRUE; |
2930 changed_window_setting(); | 2928 changed_window_setting(); |
2931 } | 2929 } |
2932 | 2930 |
2933 /* Enable Arabic shaping (major part of what Arabic requires) */ | 2931 // Enable Arabic shaping (major part of what Arabic requires) |
2934 if (!p_arshape) | 2932 if (!p_arshape) |
2935 { | 2933 { |
2936 p_arshape = TRUE; | 2934 p_arshape = TRUE; |
2937 redraw_later_clear(); | 2935 redraw_later_clear(); |
2938 } | 2936 } |
2939 } | 2937 } |
2940 | 2938 |
2941 /* Arabic requires a utf-8 encoding, inform the user if its not | 2939 // Arabic requires a utf-8 encoding, inform the user if its not |
2942 * set. */ | 2940 // set. |
2943 if (STRCMP(p_enc, "utf-8") != 0) | 2941 if (STRCMP(p_enc, "utf-8") != 0) |
2944 { | 2942 { |
2945 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); | 2943 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); |
2946 | 2944 |
2947 msg_source(HL_ATTR(HLF_W)); | 2945 msg_source(HL_ATTR(HLF_W)); |
2949 #ifdef FEAT_EVAL | 2947 #ifdef FEAT_EVAL |
2950 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); | 2948 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); |
2951 #endif | 2949 #endif |
2952 } | 2950 } |
2953 | 2951 |
2954 /* set 'delcombine' */ | 2952 // set 'delcombine' |
2955 p_deco = TRUE; | 2953 p_deco = TRUE; |
2956 | 2954 |
2957 # ifdef FEAT_KEYMAP | 2955 # ifdef FEAT_KEYMAP |
2958 /* Force-set the necessary keymap for arabic */ | 2956 // Force-set the necessary keymap for arabic |
2959 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", | 2957 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", |
2960 OPT_LOCAL); | 2958 OPT_LOCAL); |
2961 # endif | 2959 # endif |
2962 } | 2960 } |
2963 else | 2961 else |
2965 /* | 2963 /* |
2966 * 'arabic' is reset, handle various sub-settings. | 2964 * 'arabic' is reset, handle various sub-settings. |
2967 */ | 2965 */ |
2968 if (!p_tbidi) | 2966 if (!p_tbidi) |
2969 { | 2967 { |
2970 /* reset rightleft mode */ | 2968 // reset rightleft mode |
2971 if (curwin->w_p_rl) | 2969 if (curwin->w_p_rl) |
2972 { | 2970 { |
2973 curwin->w_p_rl = FALSE; | 2971 curwin->w_p_rl = FALSE; |
2974 changed_window_setting(); | 2972 changed_window_setting(); |
2975 } | 2973 } |
2976 | 2974 |
2977 /* 'arabicshape' isn't reset, it is a global option and | 2975 // 'arabicshape' isn't reset, it is a global option and |
2978 * another window may still need it "on". */ | 2976 // another window may still need it "on". |
2979 } | 2977 } |
2980 | 2978 |
2981 /* 'delcombine' isn't reset, it is a global option and another | 2979 // 'delcombine' isn't reset, it is a global option and another |
2982 * window may still want it "on". */ | 2980 // window may still want it "on". |
2983 | 2981 |
2984 # ifdef FEAT_KEYMAP | 2982 # ifdef FEAT_KEYMAP |
2985 /* Revert to the default keymap */ | 2983 // Revert to the default keymap |
2986 curbuf->b_p_iminsert = B_IMODE_NONE; | 2984 curbuf->b_p_iminsert = B_IMODE_NONE; |
2987 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; | 2985 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; |
2988 # endif | 2986 # endif |
2989 } | 2987 } |
2990 } | 2988 } |
3008 redraw_all_later(CLEAR); | 3006 redraw_all_later(CLEAR); |
3009 } | 3007 } |
3010 #endif | 3008 #endif |
3011 | 3009 |
3012 #ifdef FEAT_TERMGUICOLORS | 3010 #ifdef FEAT_TERMGUICOLORS |
3013 /* 'termguicolors' */ | 3011 // 'termguicolors' |
3014 else if ((int *)varp == &p_tgc) | 3012 else if ((int *)varp == &p_tgc) |
3015 { | 3013 { |
3016 # ifdef FEAT_VTP | 3014 # ifdef FEAT_VTP |
3017 /* Do not turn on 'tgc' when 24-bit colors are not supported. */ | 3015 // Do not turn on 'tgc' when 24-bit colors are not supported. |
3018 if ( | 3016 if ( |
3019 # ifdef VIMDLL | 3017 # ifdef VIMDLL |
3020 !gui.in_use && !gui.starting && | 3018 !gui.in_use && !gui.starting && |
3021 # endif | 3019 # endif |
3022 !has_vtp_working()) | 3020 !has_vtp_working()) |
3030 # ifdef FEAT_GUI | 3028 # ifdef FEAT_GUI |
3031 if (!gui.in_use && !gui.starting) | 3029 if (!gui.in_use && !gui.starting) |
3032 # endif | 3030 # endif |
3033 highlight_gui_started(); | 3031 highlight_gui_started(); |
3034 # ifdef FEAT_VTP | 3032 # ifdef FEAT_VTP |
3035 /* reset t_Co */ | 3033 // reset t_Co |
3036 if (is_term_win32()) | 3034 if (is_term_win32()) |
3037 { | 3035 { |
3038 control_console_color_rgb(); | 3036 control_console_color_rgb(); |
3039 set_termname(T_NAME); | 3037 set_termname(T_NAME); |
3040 init_highlight(TRUE, FALSE); | 3038 init_highlight(TRUE, FALSE); |
3045 | 3043 |
3046 /* | 3044 /* |
3047 * End of handling side effects for bool options. | 3045 * End of handling side effects for bool options. |
3048 */ | 3046 */ |
3049 | 3047 |
3050 /* after handling side effects, call autocommand */ | 3048 // after handling side effects, call autocommand |
3051 | 3049 |
3052 options[opt_idx].flags |= P_WAS_SET; | 3050 options[opt_idx].flags |= P_WAS_SET; |
3053 | 3051 |
3054 #if defined(FEAT_EVAL) | 3052 #if defined(FEAT_EVAL) |
3055 // Don't do this while starting up or recursively. | 3053 // Don't do this while starting up or recursively. |
3091 NULL, FALSE, NULL); | 3089 NULL, FALSE, NULL); |
3092 reset_v_option_vars(); | 3090 reset_v_option_vars(); |
3093 } | 3091 } |
3094 #endif | 3092 #endif |
3095 | 3093 |
3096 comp_col(); /* in case 'ruler' or 'showcmd' changed */ | 3094 comp_col(); // in case 'ruler' or 'showcmd' changed |
3097 if (curwin->w_curswant != MAXCOL | 3095 if (curwin->w_curswant != MAXCOL |
3098 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) | 3096 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3099 curwin->w_set_curswant = TRUE; | 3097 curwin->w_set_curswant = TRUE; |
3100 check_redraw(options[opt_idx].flags); | 3098 check_redraw(options[opt_idx].flags); |
3101 | 3099 |
3106 * Set the value of a number option, and take care of side effects. | 3104 * Set the value of a number option, and take care of side effects. |
3107 * Returns NULL for success, or an error message for an error. | 3105 * Returns NULL for success, or an error message for an error. |
3108 */ | 3106 */ |
3109 static char * | 3107 static char * |
3110 set_num_option( | 3108 set_num_option( |
3111 int opt_idx, /* index in options[] table */ | 3109 int opt_idx, // index in options[] table |
3112 char_u *varp, /* pointer to the option variable */ | 3110 char_u *varp, // pointer to the option variable |
3113 long value, /* new value */ | 3111 long value, // new value |
3114 char *errbuf, /* buffer for error messages */ | 3112 char *errbuf, // buffer for error messages |
3115 size_t errbuflen, /* length of "errbuf" */ | 3113 size_t errbuflen, // length of "errbuf" |
3116 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and | 3114 int opt_flags) // OPT_LOCAL, OPT_GLOBAL and |
3117 OPT_MODELINE */ | 3115 // OPT_MODELINE |
3118 { | 3116 { |
3119 char *errmsg = NULL; | 3117 char *errmsg = NULL; |
3120 long old_value = *(long *)varp; | 3118 long old_value = *(long *)varp; |
3121 #if defined(FEAT_EVAL) | 3119 #if defined(FEAT_EVAL) |
3122 long old_global_value = 0; // only used when setting a local and | 3120 long old_global_value = 0; // only used when setting a local and |
3124 #endif | 3122 #endif |
3125 long old_Rows = Rows; // remember old Rows | 3123 long old_Rows = Rows; // remember old Rows |
3126 long old_Columns = Columns; // remember old Columns | 3124 long old_Columns = Columns; // remember old Columns |
3127 long *pp = (long *)varp; | 3125 long *pp = (long *)varp; |
3128 | 3126 |
3129 /* Disallow changing some options from secure mode. */ | 3127 // Disallow changing some options from secure mode. |
3130 if ((secure | 3128 if ((secure |
3131 #ifdef HAVE_SANDBOX | 3129 #ifdef HAVE_SANDBOX |
3132 || sandbox != 0 | 3130 || sandbox != 0 |
3133 #endif | 3131 #endif |
3134 ) && (options[opt_idx].flags & P_SECURE)) | 3132 ) && (options[opt_idx].flags & P_SECURE)) |
3143 OPT_GLOBAL); | 3141 OPT_GLOBAL); |
3144 #endif | 3142 #endif |
3145 | 3143 |
3146 *pp = value; | 3144 *pp = value; |
3147 #ifdef FEAT_EVAL | 3145 #ifdef FEAT_EVAL |
3148 /* Remember where the option was set. */ | 3146 // Remember where the option was set. |
3149 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); | 3147 set_option_sctx_idx(opt_idx, opt_flags, current_sctx); |
3150 #endif | 3148 #endif |
3151 #ifdef FEAT_GUI | 3149 #ifdef FEAT_GUI |
3152 need_mouse_correct = TRUE; | 3150 need_mouse_correct = TRUE; |
3153 #endif | 3151 #endif |
3185 { | 3183 { |
3186 errmsg = e_positive; | 3184 errmsg = e_positive; |
3187 p_hh = 0; | 3185 p_hh = 0; |
3188 } | 3186 } |
3189 | 3187 |
3190 /* Change window height NOW */ | 3188 // Change window height NOW |
3191 if (!ONE_WINDOW) | 3189 if (!ONE_WINDOW) |
3192 { | 3190 { |
3193 if (pp == &p_wh && curwin->w_height < p_wh) | 3191 if (pp == &p_wh && curwin->w_height < p_wh) |
3194 win_setheight((int)p_wh); | 3192 win_setheight((int)p_wh); |
3195 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) | 3193 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) |
3223 { | 3221 { |
3224 errmsg = e_winwidth; | 3222 errmsg = e_winwidth; |
3225 p_wiw = p_wmw; | 3223 p_wiw = p_wmw; |
3226 } | 3224 } |
3227 | 3225 |
3228 /* Change window width NOW */ | 3226 // Change window width NOW |
3229 if (!ONE_WINDOW && curwin->w_width < p_wiw) | 3227 if (!ONE_WINDOW && curwin->w_width < p_wiw) |
3230 win_setwidth((int)p_wiw); | 3228 win_setwidth((int)p_wiw); |
3231 } | 3229 } |
3232 else if (pp == &p_wmw) | 3230 else if (pp == &p_wmw) |
3233 { | 3231 { |
3243 p_wmw = p_wiw; | 3241 p_wmw = p_wiw; |
3244 } | 3242 } |
3245 win_setminwidth(); | 3243 win_setminwidth(); |
3246 } | 3244 } |
3247 | 3245 |
3248 /* (re)set last window status line */ | 3246 // (re)set last window status line |
3249 else if (pp == &p_ls) | 3247 else if (pp == &p_ls) |
3250 { | 3248 { |
3251 last_status(FALSE); | 3249 last_status(FALSE); |
3252 } | 3250 } |
3253 | 3251 |
3254 /* (re)set tab page line */ | 3252 // (re)set tab page line |
3255 else if (pp == &p_stal) | 3253 else if (pp == &p_stal) |
3256 { | 3254 { |
3257 shell_new_rows(); /* recompute window positions and heights */ | 3255 shell_new_rows(); // recompute window positions and heights |
3258 } | 3256 } |
3259 | 3257 |
3260 #ifdef FEAT_GUI | 3258 #ifdef FEAT_GUI |
3261 else if (pp == &p_linespace) | 3259 else if (pp == &p_linespace) |
3262 { | 3260 { |
3263 /* Recompute gui.char_height and resize the Vim window to keep the | 3261 // Recompute gui.char_height and resize the Vim window to keep the |
3264 * same number of lines. */ | 3262 // same number of lines. |
3265 if (gui.in_use && gui_mch_adjust_charheight() == OK) | 3263 if (gui.in_use && gui_mch_adjust_charheight() == OK) |
3266 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); | 3264 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); |
3267 } | 3265 } |
3268 #endif | 3266 #endif |
3269 | 3267 |
3270 #ifdef FEAT_FOLDING | 3268 #ifdef FEAT_FOLDING |
3271 /* 'foldlevel' */ | 3269 // 'foldlevel' |
3272 else if (pp == &curwin->w_p_fdl) | 3270 else if (pp == &curwin->w_p_fdl) |
3273 { | 3271 { |
3274 if (curwin->w_p_fdl < 0) | 3272 if (curwin->w_p_fdl < 0) |
3275 curwin->w_p_fdl = 0; | 3273 curwin->w_p_fdl = 0; |
3276 newFoldLevel(); | 3274 newFoldLevel(); |
3277 } | 3275 } |
3278 | 3276 |
3279 /* 'foldminlines' */ | 3277 // 'foldminlines' |
3280 else if (pp == &curwin->w_p_fml) | 3278 else if (pp == &curwin->w_p_fml) |
3281 { | 3279 { |
3282 foldUpdateAll(curwin); | 3280 foldUpdateAll(curwin); |
3283 } | 3281 } |
3284 | 3282 |
3285 /* 'foldnestmax' */ | 3283 // 'foldnestmax' |
3286 else if (pp == &curwin->w_p_fdn) | 3284 else if (pp == &curwin->w_p_fdn) |
3287 { | 3285 { |
3288 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) | 3286 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) |
3289 foldUpdateAll(curwin); | 3287 foldUpdateAll(curwin); |
3290 } | 3288 } |
3291 | 3289 |
3292 /* 'foldcolumn' */ | 3290 // 'foldcolumn' |
3293 else if (pp == &curwin->w_p_fdc) | 3291 else if (pp == &curwin->w_p_fdc) |
3294 { | 3292 { |
3295 if (curwin->w_p_fdc < 0) | 3293 if (curwin->w_p_fdc < 0) |
3296 { | 3294 { |
3297 errmsg = e_positive; | 3295 errmsg = e_positive; |
3301 { | 3299 { |
3302 errmsg = e_invarg; | 3300 errmsg = e_invarg; |
3303 curwin->w_p_fdc = 12; | 3301 curwin->w_p_fdc = 12; |
3304 } | 3302 } |
3305 } | 3303 } |
3306 #endif /* FEAT_FOLDING */ | 3304 #endif // FEAT_FOLDING |
3307 | 3305 |
3308 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) | 3306 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) |
3309 /* 'shiftwidth' or 'tabstop' */ | 3307 // 'shiftwidth' or 'tabstop' |
3310 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) | 3308 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) |
3311 { | 3309 { |
3312 # ifdef FEAT_FOLDING | 3310 # ifdef FEAT_FOLDING |
3313 if (foldmethodIsIndent(curwin)) | 3311 if (foldmethodIsIndent(curwin)) |
3314 foldUpdateAll(curwin); | 3312 foldUpdateAll(curwin); |
3315 # endif | 3313 # endif |
3316 # ifdef FEAT_CINDENT | 3314 # ifdef FEAT_CINDENT |
3317 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes: | 3315 // When 'shiftwidth' changes, or it's zero and 'tabstop' changes: |
3318 * parse 'cinoptions'. */ | 3316 // parse 'cinoptions'. |
3319 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) | 3317 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) |
3320 parse_cino(curbuf); | 3318 parse_cino(curbuf); |
3321 # endif | 3319 # endif |
3322 } | 3320 } |
3323 #endif | 3321 #endif |
3324 | 3322 |
3325 /* 'maxcombine' */ | 3323 // 'maxcombine' |
3326 else if (pp == &p_mco) | 3324 else if (pp == &p_mco) |
3327 { | 3325 { |
3328 if (p_mco > MAX_MCO) | 3326 if (p_mco > MAX_MCO) |
3329 p_mco = MAX_MCO; | 3327 p_mco = MAX_MCO; |
3330 else if (p_mco < 0) | 3328 else if (p_mco < 0) |
3331 p_mco = 0; | 3329 p_mco = 0; |
3332 screenclear(); /* will re-allocate the screen */ | 3330 screenclear(); // will re-allocate the screen |
3333 } | 3331 } |
3334 | 3332 |
3335 else if (pp == &curbuf->b_p_iminsert) | 3333 else if (pp == &curbuf->b_p_iminsert) |
3336 { | 3334 { |
3337 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) | 3335 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) |
3338 { | 3336 { |
3339 errmsg = e_invarg; | 3337 errmsg = e_invarg; |
3340 curbuf->b_p_iminsert = B_IMODE_NONE; | 3338 curbuf->b_p_iminsert = B_IMODE_NONE; |
3341 } | 3339 } |
3342 p_iminsert = curbuf->b_p_iminsert; | 3340 p_iminsert = curbuf->b_p_iminsert; |
3343 if (termcap_active) /* don't do this in the alternate screen */ | 3341 if (termcap_active) // don't do this in the alternate screen |
3344 showmode(); | 3342 showmode(); |
3345 #if defined(FEAT_KEYMAP) | 3343 #if defined(FEAT_KEYMAP) |
3346 /* Show/unshow value of 'keymap' in status lines. */ | 3344 // Show/unshow value of 'keymap' in status lines. |
3347 status_redraw_curbuf(); | 3345 status_redraw_curbuf(); |
3348 #endif | 3346 #endif |
3349 } | 3347 } |
3350 | 3348 |
3351 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) | 3349 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) |
3352 /* 'imstyle' */ | 3350 // 'imstyle' |
3353 else if (pp == &p_imst) | 3351 else if (pp == &p_imst) |
3354 { | 3352 { |
3355 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) | 3353 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) |
3356 errmsg = e_invarg; | 3354 errmsg = e_invarg; |
3357 } | 3355 } |
3374 } | 3372 } |
3375 p_imsearch = curbuf->b_p_imsearch; | 3373 p_imsearch = curbuf->b_p_imsearch; |
3376 } | 3374 } |
3377 | 3375 |
3378 #ifdef FEAT_TITLE | 3376 #ifdef FEAT_TITLE |
3379 /* if 'titlelen' has changed, redraw the title */ | 3377 // if 'titlelen' has changed, redraw the title |
3380 else if (pp == &p_titlelen) | 3378 else if (pp == &p_titlelen) |
3381 { | 3379 { |
3382 if (p_titlelen < 0) | 3380 if (p_titlelen < 0) |
3383 { | 3381 { |
3384 errmsg = e_positive; | 3382 errmsg = e_positive; |
3387 if (starting != NO_SCREEN && old_value != p_titlelen) | 3385 if (starting != NO_SCREEN && old_value != p_titlelen) |
3388 need_maketitle = TRUE; | 3386 need_maketitle = TRUE; |
3389 } | 3387 } |
3390 #endif | 3388 #endif |
3391 | 3389 |
3392 /* if p_ch changed value, change the command line height */ | 3390 // if p_ch changed value, change the command line height |
3393 else if (pp == &p_ch) | 3391 else if (pp == &p_ch) |
3394 { | 3392 { |
3395 if (p_ch < 1) | 3393 if (p_ch < 1) |
3396 { | 3394 { |
3397 errmsg = e_positive; | 3395 errmsg = e_positive; |
3398 p_ch = 1; | 3396 p_ch = 1; |
3399 } | 3397 } |
3400 if (p_ch > Rows - min_rows() + 1) | 3398 if (p_ch > Rows - min_rows() + 1) |
3401 p_ch = Rows - min_rows() + 1; | 3399 p_ch = Rows - min_rows() + 1; |
3402 | 3400 |
3403 /* Only compute the new window layout when startup has been | 3401 // Only compute the new window layout when startup has been |
3404 * completed. Otherwise the frame sizes may be wrong. */ | 3402 // completed. Otherwise the frame sizes may be wrong. |
3405 if (p_ch != old_value && full_screen | 3403 if (p_ch != old_value && full_screen |
3406 #ifdef FEAT_GUI | 3404 #ifdef FEAT_GUI |
3407 && !gui.starting | 3405 && !gui.starting |
3408 #endif | 3406 #endif |
3409 ) | 3407 ) |
3410 command_height(); | 3408 command_height(); |
3411 } | 3409 } |
3412 | 3410 |
3413 /* when 'updatecount' changes from zero to non-zero, open swap files */ | 3411 // when 'updatecount' changes from zero to non-zero, open swap files |
3414 else if (pp == &p_uc) | 3412 else if (pp == &p_uc) |
3415 { | 3413 { |
3416 if (p_uc < 0) | 3414 if (p_uc < 0) |
3417 { | 3415 { |
3418 errmsg = e_positive; | 3416 errmsg = e_positive; |
3440 else if (pp == &p_mzq) | 3438 else if (pp == &p_mzq) |
3441 mzvim_reset_timer(); | 3439 mzvim_reset_timer(); |
3442 #endif | 3440 #endif |
3443 | 3441 |
3444 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) | 3442 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) |
3445 /* 'pyxversion' */ | 3443 // 'pyxversion' |
3446 else if (pp == &p_pyx) | 3444 else if (pp == &p_pyx) |
3447 { | 3445 { |
3448 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) | 3446 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) |
3449 errmsg = e_invarg; | 3447 errmsg = e_invarg; |
3450 } | 3448 } |
3451 #endif | 3449 #endif |
3452 | 3450 |
3453 /* sync undo before 'undolevels' changes */ | 3451 // sync undo before 'undolevels' changes |
3454 else if (pp == &p_ul) | 3452 else if (pp == &p_ul) |
3455 { | 3453 { |
3456 /* use the old value, otherwise u_sync() may not work properly */ | 3454 // use the old value, otherwise u_sync() may not work properly |
3457 p_ul = old_value; | 3455 p_ul = old_value; |
3458 u_sync(TRUE); | 3456 u_sync(TRUE); |
3459 p_ul = value; | 3457 p_ul = value; |
3460 } | 3458 } |
3461 else if (pp == &curbuf->b_p_ul) | 3459 else if (pp == &curbuf->b_p_ul) |
3462 { | 3460 { |
3463 /* use the old value, otherwise u_sync() may not work properly */ | 3461 // use the old value, otherwise u_sync() may not work properly |
3464 curbuf->b_p_ul = old_value; | 3462 curbuf->b_p_ul = old_value; |
3465 u_sync(TRUE); | 3463 u_sync(TRUE); |
3466 curbuf->b_p_ul = value; | 3464 curbuf->b_p_ul = value; |
3467 } | 3465 } |
3468 | 3466 |
3469 #ifdef FEAT_LINEBREAK | 3467 #ifdef FEAT_LINEBREAK |
3470 /* 'numberwidth' must be positive */ | 3468 // 'numberwidth' must be positive |
3471 else if (pp == &curwin->w_p_nuw) | 3469 else if (pp == &curwin->w_p_nuw) |
3472 { | 3470 { |
3473 if (curwin->w_p_nuw < 1) | 3471 if (curwin->w_p_nuw < 1) |
3474 { | 3472 { |
3475 errmsg = e_positive; | 3473 errmsg = e_positive; |
3478 if (curwin->w_p_nuw > 20) | 3476 if (curwin->w_p_nuw > 20) |
3479 { | 3477 { |
3480 errmsg = e_invarg; | 3478 errmsg = e_invarg; |
3481 curwin->w_p_nuw = 20; | 3479 curwin->w_p_nuw = 20; |
3482 } | 3480 } |
3483 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */ | 3481 curwin->w_nrwidth_line_count = 0; // trigger a redraw |
3484 } | 3482 } |
3485 #endif | 3483 #endif |
3486 | 3484 |
3487 else if (pp == &curbuf->b_p_tw) | 3485 else if (pp == &curbuf->b_p_tw) |
3488 { | 3486 { |
3531 * If the screen (shell) height has been changed, assume it is the | 3529 * If the screen (shell) height has been changed, assume it is the |
3532 * physical screenheight. | 3530 * physical screenheight. |
3533 */ | 3531 */ |
3534 if (old_Rows != Rows || old_Columns != Columns) | 3532 if (old_Rows != Rows || old_Columns != Columns) |
3535 { | 3533 { |
3536 /* Changing the screen size is not allowed while updating the screen. */ | 3534 // Changing the screen size is not allowed while updating the screen. |
3537 if (updating_screen) | 3535 if (updating_screen) |
3538 *pp = old_value; | 3536 *pp = old_value; |
3539 else if (full_screen | 3537 else if (full_screen |
3540 #ifdef FEAT_GUI | 3538 #ifdef FEAT_GUI |
3541 && !gui.starting | 3539 && !gui.starting |
3542 #endif | 3540 #endif |
3543 ) | 3541 ) |
3544 set_shellsize((int)Columns, (int)Rows, TRUE); | 3542 set_shellsize((int)Columns, (int)Rows, TRUE); |
3545 else | 3543 else |
3546 { | 3544 { |
3547 /* Postpone the resizing; check the size and cmdline position for | 3545 // Postpone the resizing; check the size and cmdline position for |
3548 * messages. */ | 3546 // messages. |
3549 check_shellsize(); | 3547 check_shellsize(); |
3550 if (cmdline_row > Rows - p_ch && Rows > p_ch) | 3548 if (cmdline_row > Rows - p_ch && Rows > p_ch) |
3551 cmdline_row = Rows - p_ch; | 3549 cmdline_row = Rows - p_ch; |
3552 } | 3550 } |
3553 if (p_window >= Rows || !option_was_set((char_u *)"window")) | 3551 if (p_window >= Rows || !option_was_set((char_u *)"window")) |
3573 { | 3571 { |
3574 if (curwin->w_p_scr != 0) | 3572 if (curwin->w_p_scr != 0) |
3575 errmsg = e_scroll; | 3573 errmsg = e_scroll; |
3576 win_comp_scroll(curwin); | 3574 win_comp_scroll(curwin); |
3577 } | 3575 } |
3578 /* If 'scroll' became invalid because of a side effect silently adjust | 3576 // If 'scroll' became invalid because of a side effect silently adjust |
3579 * it. */ | 3577 // it. |
3580 else if (curwin->w_p_scr <= 0) | 3578 else if (curwin->w_p_scr <= 0) |
3581 curwin->w_p_scr = 1; | 3579 curwin->w_p_scr = 1; |
3582 else /* curwin->w_p_scr > curwin->w_height */ | 3580 else // curwin->w_p_scr > curwin->w_height |
3583 curwin->w_p_scr = curwin->w_height; | 3581 curwin->w_p_scr = curwin->w_height; |
3584 } | 3582 } |
3585 if (p_hi < 0) | 3583 if (p_hi < 0) |
3586 { | 3584 { |
3587 errmsg = e_positive; | 3585 errmsg = e_positive; |
3602 errmsg = e_positive; | 3600 errmsg = e_positive; |
3603 p_report = 1; | 3601 p_report = 1; |
3604 } | 3602 } |
3605 if ((p_sj < -100 || p_sj >= Rows) && full_screen) | 3603 if ((p_sj < -100 || p_sj >= Rows) && full_screen) |
3606 { | 3604 { |
3607 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ | 3605 if (Rows != old_Rows) // Rows changed, just adjust p_sj |
3608 p_sj = Rows / 2; | 3606 p_sj = Rows / 2; |
3609 else | 3607 else |
3610 { | 3608 { |
3611 errmsg = e_scroll; | 3609 errmsg = e_scroll; |
3612 p_sj = 1; | 3610 p_sj = 1; |
3638 { | 3636 { |
3639 errmsg = e_positive; | 3637 errmsg = e_positive; |
3640 p_ss = 0; | 3638 p_ss = 0; |
3641 } | 3639 } |
3642 | 3640 |
3643 /* May set global value for local option. */ | 3641 // May set global value for local option. |
3644 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) | 3642 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) |
3645 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; | 3643 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; |
3646 | 3644 |
3647 options[opt_idx].flags |= P_WAS_SET; | 3645 options[opt_idx].flags |= P_WAS_SET; |
3648 | 3646 |
3683 NULL, FALSE, NULL); | 3681 NULL, FALSE, NULL); |
3684 reset_v_option_vars(); | 3682 reset_v_option_vars(); |
3685 } | 3683 } |
3686 #endif | 3684 #endif |
3687 | 3685 |
3688 comp_col(); /* in case 'columns' or 'ls' changed */ | 3686 comp_col(); // in case 'columns' or 'ls' changed |
3689 if (curwin->w_curswant != MAXCOL | 3687 if (curwin->w_curswant != MAXCOL |
3690 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) | 3688 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) |
3691 curwin->w_set_curswant = TRUE; | 3689 curwin->w_set_curswant = TRUE; |
3692 check_redraw(options[opt_idx].flags); | 3690 check_redraw(options[opt_idx].flags); |
3693 | 3691 |
3698 * Called after an option changed: check if something needs to be redrawn. | 3696 * Called after an option changed: check if something needs to be redrawn. |
3699 */ | 3697 */ |
3700 void | 3698 void |
3701 check_redraw(long_u flags) | 3699 check_redraw(long_u flags) |
3702 { | 3700 { |
3703 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ | 3701 // Careful: P_RCLR and P_RALL are a combination of other P_ flags |
3704 int doclear = (flags & P_RCLR) == P_RCLR; | 3702 int doclear = (flags & P_RCLR) == P_RCLR; |
3705 int all = ((flags & P_RALL) == P_RALL || doclear); | 3703 int all = ((flags & P_RALL) == P_RALL || doclear); |
3706 | 3704 |
3707 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ | 3705 if ((flags & P_RSTAT) || all) // mark all status lines dirty |
3708 status_redraw_all(); | 3706 status_redraw_all(); |
3709 | 3707 |
3710 if ((flags & P_RBUF) || (flags & P_RWIN) || all) | 3708 if ((flags & P_RBUF) || (flags & P_RWIN) || all) |
3711 changed_window_setting(); | 3709 changed_window_setting(); |
3712 if (flags & P_RBUF) | 3710 if (flags & P_RBUF) |
3726 int | 3724 int |
3727 findoption(char_u *arg) | 3725 findoption(char_u *arg) |
3728 { | 3726 { |
3729 int opt_idx; | 3727 int opt_idx; |
3730 char *s, *p; | 3728 char *s, *p; |
3731 static short quick_tab[27] = {0, 0}; /* quick access table */ | 3729 static short quick_tab[27] = {0, 0}; // quick access table |
3732 int is_term_opt; | 3730 int is_term_opt; |
3733 | 3731 |
3734 /* | 3732 /* |
3735 * For first call: Initialize the quick-access table. | 3733 * For first call: Initialize the quick-access table. |
3736 * It contains the index for the first option that starts with a certain | 3734 * It contains the index for the first option that starts with a certain |
3767 opt_idx = quick_tab[26]; | 3765 opt_idx = quick_tab[26]; |
3768 else | 3766 else |
3769 opt_idx = quick_tab[CharOrdLow(arg[0])]; | 3767 opt_idx = quick_tab[CharOrdLow(arg[0])]; |
3770 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) | 3768 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) |
3771 { | 3769 { |
3772 if (STRCMP(arg, s) == 0) /* match full name */ | 3770 if (STRCMP(arg, s) == 0) // match full name |
3773 break; | 3771 break; |
3774 } | 3772 } |
3775 if (s == NULL && !is_term_opt) | 3773 if (s == NULL && !is_term_opt) |
3776 { | 3774 { |
3777 opt_idx = quick_tab[CharOrdLow(arg[0])]; | 3775 opt_idx = quick_tab[CharOrdLow(arg[0])]; |
3778 for ( ; options[opt_idx].fullname != NULL; opt_idx++) | 3776 for ( ; options[opt_idx].fullname != NULL; opt_idx++) |
3779 { | 3777 { |
3780 s = options[opt_idx].shortname; | 3778 s = options[opt_idx].shortname; |
3781 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ | 3779 if (s != NULL && STRCMP(arg, s) == 0) // match short name |
3782 break; | 3780 break; |
3783 s = NULL; | 3781 s = NULL; |
3784 } | 3782 } |
3785 } | 3783 } |
3786 if (s == NULL) | 3784 if (s == NULL) |
3801 */ | 3799 */ |
3802 int | 3800 int |
3803 get_option_value( | 3801 get_option_value( |
3804 char_u *name, | 3802 char_u *name, |
3805 long *numval, | 3803 long *numval, |
3806 char_u **stringval, /* NULL when only checking existence */ | 3804 char_u **stringval, // NULL when only checking existence |
3807 int opt_flags) | 3805 int opt_flags) |
3808 { | 3806 { |
3809 int opt_idx; | 3807 int opt_idx; |
3810 char_u *varp; | 3808 char_u *varp; |
3811 | 3809 |
3812 opt_idx = findoption(name); | 3810 opt_idx = findoption(name); |
3813 if (opt_idx < 0) /* unknown option */ | 3811 if (opt_idx < 0) // unknown option |
3814 { | 3812 { |
3815 int key; | 3813 int key; |
3816 | 3814 |
3817 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' | 3815 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' |
3818 && (key = find_key_option(name, FALSE)) != 0) | 3816 && (key = find_key_option(name, FALSE)) != 0) |
3843 | 3841 |
3844 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | 3842 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
3845 | 3843 |
3846 if (options[opt_idx].flags & P_STRING) | 3844 if (options[opt_idx].flags & P_STRING) |
3847 { | 3845 { |
3848 if (varp == NULL) /* hidden option */ | 3846 if (varp == NULL) // hidden option |
3849 return -2; | 3847 return -2; |
3850 if (stringval != NULL) | 3848 if (stringval != NULL) |
3851 { | 3849 { |
3852 #ifdef FEAT_CRYPT | 3850 #ifdef FEAT_CRYPT |
3853 /* never return the value of the crypt key */ | 3851 // never return the value of the crypt key |
3854 if ((char_u **)varp == &curbuf->b_p_key | 3852 if ((char_u **)varp == &curbuf->b_p_key |
3855 && **(char_u **)(varp) != NUL) | 3853 && **(char_u **)(varp) != NUL) |
3856 *stringval = vim_strsave((char_u *)"*****"); | 3854 *stringval = vim_strsave((char_u *)"*****"); |
3857 else | 3855 else |
3858 #endif | 3856 #endif |
3859 *stringval = vim_strsave(*(char_u **)(varp)); | 3857 *stringval = vim_strsave(*(char_u **)(varp)); |
3860 } | 3858 } |
3861 return 0; | 3859 return 0; |
3862 } | 3860 } |
3863 | 3861 |
3864 if (varp == NULL) /* hidden option */ | 3862 if (varp == NULL) // hidden option |
3865 return -1; | 3863 return -1; |
3866 if (options[opt_idx].flags & P_NUM) | 3864 if (options[opt_idx].flags & P_NUM) |
3867 *numval = *(long *)varp; | 3865 *numval = *(long *)varp; |
3868 else | 3866 else |
3869 { | 3867 { |
3870 /* Special case: 'modified' is b_changed, but we also want to consider | 3868 // Special case: 'modified' is b_changed, but we also want to consider |
3871 * it set when 'ff' or 'fenc' changed. */ | 3869 // it set when 'ff' or 'fenc' changed. |
3872 if ((int *)varp == &curbuf->b_changed) | 3870 if ((int *)varp == &curbuf->b_changed) |
3873 *numval = curbufIsChanged(); | 3871 *numval = curbufIsChanged(); |
3874 else | 3872 else |
3875 *numval = (long) *(int *)varp; | 3873 *numval = (long) *(int *)varp; |
3876 } | 3874 } |
3899 */ | 3897 */ |
3900 int | 3898 int |
3901 get_option_value_strict( | 3899 get_option_value_strict( |
3902 char_u *name, | 3900 char_u *name, |
3903 long *numval, | 3901 long *numval, |
3904 char_u **stringval, /* NULL when only obtaining attributes */ | 3902 char_u **stringval, // NULL when only obtaining attributes |
3905 int opt_type, | 3903 int opt_type, |
3906 void *from) | 3904 void *from) |
3907 { | 3905 { |
3908 int opt_idx; | 3906 int opt_idx; |
3909 char_u *varp = NULL; | 3907 char_u *varp = NULL; |
3914 if (opt_idx < 0) | 3912 if (opt_idx < 0) |
3915 return 0; | 3913 return 0; |
3916 | 3914 |
3917 p = &(options[opt_idx]); | 3915 p = &(options[opt_idx]); |
3918 | 3916 |
3919 /* Hidden option */ | 3917 // Hidden option |
3920 if (p->var == NULL) | 3918 if (p->var == NULL) |
3921 return 0; | 3919 return 0; |
3922 | 3920 |
3923 if (p->flags & P_BOOL) | 3921 if (p->flags & P_BOOL) |
3924 r |= SOPT_BOOL; | 3922 r |= SOPT_BOOL; |
3930 if (p->indir == PV_NONE) | 3928 if (p->indir == PV_NONE) |
3931 { | 3929 { |
3932 if (opt_type == SREQ_GLOBAL) | 3930 if (opt_type == SREQ_GLOBAL) |
3933 r |= SOPT_GLOBAL; | 3931 r |= SOPT_GLOBAL; |
3934 else | 3932 else |
3935 return 0; /* Did not request global-only option */ | 3933 return 0; // Did not request global-only option |
3936 } | 3934 } |
3937 else | 3935 else |
3938 { | 3936 { |
3939 if (p->indir & PV_BOTH) | 3937 if (p->indir & PV_BOTH) |
3940 r |= SOPT_GLOBAL; | 3938 r |= SOPT_GLOBAL; |
3941 else if (opt_type == SREQ_GLOBAL) | 3939 else if (opt_type == SREQ_GLOBAL) |
3942 return 0; /* Requested global option */ | 3940 return 0; // Requested global option |
3943 | 3941 |
3944 if (p->indir & PV_WIN) | 3942 if (p->indir & PV_WIN) |
3945 { | 3943 { |
3946 if (opt_type == SREQ_BUF) | 3944 if (opt_type == SREQ_BUF) |
3947 return 0; /* Did not request window-local option */ | 3945 return 0; // Did not request window-local option |
3948 else | 3946 else |
3949 r |= SOPT_WIN; | 3947 r |= SOPT_WIN; |
3950 } | 3948 } |
3951 else if (p->indir & PV_BUF) | 3949 else if (p->indir & PV_BUF) |
3952 { | 3950 { |
3953 if (opt_type == SREQ_WIN) | 3951 if (opt_type == SREQ_WIN) |
3954 return 0; /* Did not request buffer-local option */ | 3952 return 0; // Did not request buffer-local option |
3955 else | 3953 else |
3956 r |= SOPT_BUF; | 3954 r |= SOPT_BUF; |
3957 } | 3955 } |
3958 } | 3956 } |
3959 | 3957 |
3964 varp = p->var; | 3962 varp = p->var; |
3965 else | 3963 else |
3966 { | 3964 { |
3967 if (opt_type == SREQ_BUF) | 3965 if (opt_type == SREQ_BUF) |
3968 { | 3966 { |
3969 /* Special case: 'modified' is b_changed, but we also want to | 3967 // Special case: 'modified' is b_changed, but we also want to |
3970 * consider it set when 'ff' or 'fenc' changed. */ | 3968 // consider it set when 'ff' or 'fenc' changed. |
3971 if (p->indir == PV_MOD) | 3969 if (p->indir == PV_MOD) |
3972 { | 3970 { |
3973 *numval = bufIsChanged((buf_T *)from); | 3971 *numval = bufIsChanged((buf_T *)from); |
3974 varp = NULL; | 3972 varp = NULL; |
3975 } | 3973 } |
3976 #ifdef FEAT_CRYPT | 3974 #ifdef FEAT_CRYPT |
3977 else if (p->indir == PV_KEY) | 3975 else if (p->indir == PV_KEY) |
3978 { | 3976 { |
3979 /* never return the value of the crypt key */ | 3977 // never return the value of the crypt key |
3980 *stringval = NULL; | 3978 *stringval = NULL; |
3981 varp = NULL; | 3979 varp = NULL; |
3982 } | 3980 } |
3983 #endif | 3981 #endif |
3984 else | 3982 else |
4048 else | 4046 else |
4049 *option = (void *) (((struct vimoption *) (*option)) + 1); | 4047 *option = (void *) (((struct vimoption *) (*option)) + 1); |
4050 | 4048 |
4051 ret = ((struct vimoption *) (*option)); | 4049 ret = ((struct vimoption *) (*option)); |
4052 | 4050 |
4053 /* Hidden option */ | 4051 // Hidden option |
4054 if (ret->var == NULL) | 4052 if (ret->var == NULL) |
4055 { | 4053 { |
4056 ret = NULL; | 4054 ret = NULL; |
4057 continue; | 4055 continue; |
4058 } | 4056 } |
4166 char * | 4164 char * |
4167 set_option_value( | 4165 set_option_value( |
4168 char_u *name, | 4166 char_u *name, |
4169 long number, | 4167 long number, |
4170 char_u *string, | 4168 char_u *string, |
4171 int opt_flags) /* OPT_LOCAL or 0 (both) */ | 4169 int opt_flags) // OPT_LOCAL or 0 (both) |
4172 { | 4170 { |
4173 int opt_idx; | 4171 int opt_idx; |
4174 char_u *varp; | 4172 char_u *varp; |
4175 long_u flags; | 4173 long_u flags; |
4176 | 4174 |
4205 } | 4203 } |
4206 else | 4204 else |
4207 { | 4205 { |
4208 flags = options[opt_idx].flags; | 4206 flags = options[opt_idx].flags; |
4209 #ifdef HAVE_SANDBOX | 4207 #ifdef HAVE_SANDBOX |
4210 /* Disallow changing some options in the sandbox */ | 4208 // Disallow changing some options in the sandbox |
4211 if (sandbox > 0 && (flags & P_SECURE)) | 4209 if (sandbox > 0 && (flags & P_SECURE)) |
4212 { | 4210 { |
4213 emsg(_(e_sandbox)); | 4211 emsg(_(e_sandbox)); |
4214 return NULL; | 4212 return NULL; |
4215 } | 4213 } |
4217 if (flags & P_STRING) | 4215 if (flags & P_STRING) |
4218 return set_string_option(opt_idx, string, opt_flags); | 4216 return set_string_option(opt_idx, string, opt_flags); |
4219 else | 4217 else |
4220 { | 4218 { |
4221 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | 4219 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
4222 if (varp != NULL) /* hidden option is not changed */ | 4220 if (varp != NULL) // hidden option is not changed |
4223 { | 4221 { |
4224 if (number == 0 && string != NULL) | 4222 if (number == 0 && string != NULL) |
4225 { | 4223 { |
4226 int idx; | 4224 int idx; |
4227 | 4225 |
4228 /* Either we are given a string or we are setting option | 4226 // Either we are given a string or we are setting option |
4229 * to zero. */ | 4227 // to zero. |
4230 for (idx = 0; string[idx] == '0'; ++idx) | 4228 for (idx = 0; string[idx] == '0'; ++idx) |
4231 ; | 4229 ; |
4232 if (string[idx] != NUL || idx == 0) | 4230 if (string[idx] != NUL || idx == 0) |
4233 { | 4231 { |
4234 /* There's another character after zeros or the string | 4232 // There's another character after zeros or the string |
4235 * is empty. In both cases, we are trying to set a | 4233 // is empty. In both cases, we are trying to set a |
4236 * num option using a string. */ | 4234 // num option using a string. |
4237 semsg(_("E521: Number required: &%s = '%s'"), | 4235 semsg(_("E521: Number required: &%s = '%s'"), |
4238 name, string); | 4236 name, string); |
4239 return NULL; /* do nothing as we hit an error */ | 4237 return NULL; // do nothing as we hit an error |
4240 | 4238 |
4241 } | 4239 } |
4242 } | 4240 } |
4243 if (flags & P_NUM) | 4241 if (flags & P_NUM) |
4244 return set_num_option(opt_idx, varp, number, | 4242 return set_num_option(opt_idx, varp, number, |
4315 */ | 4313 */ |
4316 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) | 4314 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) |
4317 key = TERMCAP2KEY(arg[2], arg[3]); | 4315 key = TERMCAP2KEY(arg[2], arg[3]); |
4318 else if (has_lt) | 4316 else if (has_lt) |
4319 { | 4317 { |
4320 --arg; /* put arg at the '<' */ | 4318 --arg; // put arg at the '<' |
4321 modifiers = 0; | 4319 modifiers = 0; |
4322 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE, TRUE, NULL); | 4320 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE, TRUE, NULL); |
4323 if (modifiers) /* can't handle modifiers here */ | 4321 if (modifiers) // can't handle modifiers here |
4324 key = 0; | 4322 key = 0; |
4325 } | 4323 } |
4326 return key; | 4324 return key; |
4327 } | 4325 } |
4328 | 4326 |
4332 * if 'all' == 2: show all terminal options | 4330 * if 'all' == 2: show all terminal options |
4333 */ | 4331 */ |
4334 static void | 4332 static void |
4335 showoptions( | 4333 showoptions( |
4336 int all, | 4334 int all, |
4337 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ | 4335 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL |
4338 { | 4336 { |
4339 struct vimoption *p; | 4337 struct vimoption *p; |
4340 int col; | 4338 int col; |
4341 int isterm; | 4339 int isterm; |
4342 char_u *varp; | 4340 char_u *varp; |
4353 | 4351 |
4354 items = ALLOC_MULT(struct vimoption *, PARAM_COUNT); | 4352 items = ALLOC_MULT(struct vimoption *, PARAM_COUNT); |
4355 if (items == NULL) | 4353 if (items == NULL) |
4356 return; | 4354 return; |
4357 | 4355 |
4358 /* Highlight title */ | 4356 // Highlight title |
4359 if (all == 2) | 4357 if (all == 2) |
4360 msg_puts_title(_("\n--- Terminal codes ---")); | 4358 msg_puts_title(_("\n--- Terminal codes ---")); |
4361 else if (opt_flags & OPT_GLOBAL) | 4359 else if (opt_flags & OPT_GLOBAL) |
4362 msg_puts_title(_("\n--- Global option values ---")); | 4360 msg_puts_title(_("\n--- Global option values ---")); |
4363 else if (opt_flags & OPT_LOCAL) | 4361 else if (opt_flags & OPT_LOCAL) |
4395 && ((all == 2 && isterm) | 4393 && ((all == 2 && isterm) |
4396 || (all == 1 && !isterm) | 4394 || (all == 1 && !isterm) |
4397 || (all == 0 && !optval_default(p, varp, p_cp)))) | 4395 || (all == 0 && !optval_default(p, varp, p_cp)))) |
4398 { | 4396 { |
4399 if (p->flags & P_BOOL) | 4397 if (p->flags & P_BOOL) |
4400 len = 1; /* a toggle option fits always */ | 4398 len = 1; // a toggle option fits always |
4401 else | 4399 else |
4402 { | 4400 { |
4403 option_value2string(p, opt_flags); | 4401 option_value2string(p, opt_flags); |
4404 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; | 4402 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; |
4405 } | 4403 } |
4417 cols = (Columns + GAP - 3) / INC; | 4415 cols = (Columns + GAP - 3) / INC; |
4418 if (cols == 0) | 4416 if (cols == 0) |
4419 cols = 1; | 4417 cols = 1; |
4420 rows = (item_count + cols - 1) / cols; | 4418 rows = (item_count + cols - 1) / cols; |
4421 } | 4419 } |
4422 else /* run == 2 */ | 4420 else // run == 2 |
4423 rows = item_count; | 4421 rows = item_count; |
4424 for (row = 0; row < rows && !got_int; ++row) | 4422 for (row = 0; row < rows && !got_int; ++row) |
4425 { | 4423 { |
4426 msg_putchar('\n'); /* go to next line */ | 4424 msg_putchar('\n'); // go to next line |
4427 if (got_int) /* 'q' typed in more */ | 4425 if (got_int) // 'q' typed in more |
4428 break; | 4426 break; |
4429 col = 0; | 4427 col = 0; |
4430 for (i = row; i < item_count; i += rows) | 4428 for (i = row; i < item_count; i += rows) |
4431 { | 4429 { |
4432 msg_col = col; /* make columns */ | 4430 msg_col = col; // make columns |
4433 showoneopt(items[i], opt_flags); | 4431 showoneopt(items[i], opt_flags); |
4434 col += INC; | 4432 col += INC; |
4435 } | 4433 } |
4436 out_flush(); | 4434 out_flush(); |
4437 ui_breakcheck(); | 4435 ui_breakcheck(); |
4447 optval_default(struct vimoption *p, char_u *varp, int compatible) | 4445 optval_default(struct vimoption *p, char_u *varp, int compatible) |
4448 { | 4446 { |
4449 int dvi; | 4447 int dvi; |
4450 | 4448 |
4451 if (varp == NULL) | 4449 if (varp == NULL) |
4452 return TRUE; /* hidden option is always at default */ | 4450 return TRUE; // hidden option is always at default |
4453 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; | 4451 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; |
4454 if (p->flags & P_NUM) | 4452 if (p->flags & P_NUM) |
4455 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); | 4453 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); |
4456 if (p->flags & P_BOOL) | 4454 if (p->flags & P_BOOL) |
4457 /* the cast to long is required for Manx C, long_i is | 4455 // the cast to long is required for Manx C, long_i is |
4458 * needed for MSVC */ | 4456 // needed for MSVC |
4459 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); | 4457 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); |
4460 /* P_STRING */ | 4458 // P_STRING |
4461 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); | 4459 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); |
4462 } | 4460 } |
4463 | 4461 |
4464 /* | 4462 /* |
4465 * showoneopt: show the value of one option | 4463 * showoneopt: show the value of one option |
4466 * must not be called with a hidden option! | 4464 * must not be called with a hidden option! |
4467 */ | 4465 */ |
4468 static void | 4466 static void |
4469 showoneopt( | 4467 showoneopt( |
4470 struct vimoption *p, | 4468 struct vimoption *p, |
4471 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */ | 4469 int opt_flags) // OPT_LOCAL or OPT_GLOBAL |
4472 { | 4470 { |
4473 char_u *varp; | 4471 char_u *varp; |
4474 int save_silent = silent_mode; | 4472 int save_silent = silent_mode; |
4475 | 4473 |
4476 silent_mode = FALSE; | 4474 silent_mode = FALSE; |
4477 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ | 4475 info_message = TRUE; // use mch_msg(), not mch_errmsg() |
4478 | 4476 |
4479 varp = get_varp_scope(p, opt_flags); | 4477 varp = get_varp_scope(p, opt_flags); |
4480 | 4478 |
4481 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ | 4479 // for 'modified' we also need to check if 'ff' or 'fenc' changed. |
4482 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed | 4480 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed |
4483 ? !curbufIsChanged() : !*(int *)varp)) | 4481 ? !curbufIsChanged() : !*(int *)varp)) |
4484 msg_puts("no"); | 4482 msg_puts("no"); |
4485 else if ((p->flags & P_BOOL) && *(int *)varp < 0) | 4483 else if ((p->flags & P_BOOL) && *(int *)varp < 0) |
4486 msg_puts("--"); | 4484 msg_puts("--"); |
4488 msg_puts(" "); | 4486 msg_puts(" "); |
4489 msg_puts(p->fullname); | 4487 msg_puts(p->fullname); |
4490 if (!(p->flags & P_BOOL)) | 4488 if (!(p->flags & P_BOOL)) |
4491 { | 4489 { |
4492 msg_putchar('='); | 4490 msg_putchar('='); |
4493 /* put value string in NameBuff */ | 4491 // put value string in NameBuff |
4494 option_value2string(p, opt_flags); | 4492 option_value2string(p, opt_flags); |
4495 msg_outtrans(NameBuff); | 4493 msg_outtrans(NameBuff); |
4496 } | 4494 } |
4497 | 4495 |
4498 silent_mode = save_silent; | 4496 silent_mode = save_silent; |
4523 */ | 4521 */ |
4524 int | 4522 int |
4525 makeset(FILE *fd, int opt_flags, int local_only) | 4523 makeset(FILE *fd, int opt_flags, int local_only) |
4526 { | 4524 { |
4527 struct vimoption *p; | 4525 struct vimoption *p; |
4528 char_u *varp; /* currently used value */ | 4526 char_u *varp; // currently used value |
4529 char_u *varp_fresh; /* local value */ | 4527 char_u *varp_fresh; // local value |
4530 char_u *varp_local = NULL; /* fresh value */ | 4528 char_u *varp_local = NULL; // fresh value |
4531 char *cmd; | 4529 char *cmd; |
4532 int round; | 4530 int round; |
4533 int pri; | 4531 int pri; |
4534 | 4532 |
4535 /* | 4533 /* |
4543 for (p = &options[0]; !istermoption(p); p++) | 4541 for (p = &options[0]; !istermoption(p); p++) |
4544 if (!(p->flags & P_NO_MKRC) | 4542 if (!(p->flags & P_NO_MKRC) |
4545 && !istermoption(p) | 4543 && !istermoption(p) |
4546 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) | 4544 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) |
4547 { | 4545 { |
4548 /* skip global option when only doing locals */ | 4546 // skip global option when only doing locals |
4549 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) | 4547 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) |
4550 continue; | 4548 continue; |
4551 | 4549 |
4552 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc | 4550 // Do not store options like 'bufhidden' and 'syntax' in a vimrc |
4553 * file, they are always buffer-specific. */ | 4551 // file, they are always buffer-specific. |
4554 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) | 4552 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) |
4555 continue; | 4553 continue; |
4556 | 4554 |
4557 /* Global values are only written when not at the default value. */ | 4555 // Global values are only written when not at the default value. |
4558 varp = get_varp_scope(p, opt_flags); | 4556 varp = get_varp_scope(p, opt_flags); |
4559 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) | 4557 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp)) |
4560 continue; | 4558 continue; |
4561 | 4559 |
4562 round = 2; | 4560 round = 2; |
4563 if (p->indir != PV_NONE) | 4561 if (p->indir != PV_NONE) |
4564 { | 4562 { |
4565 if (p->var == VAR_WIN) | 4563 if (p->var == VAR_WIN) |
4566 { | 4564 { |
4567 /* skip window-local option when only doing globals */ | 4565 // skip window-local option when only doing globals |
4568 if (!(opt_flags & OPT_LOCAL)) | 4566 if (!(opt_flags & OPT_LOCAL)) |
4569 continue; | 4567 continue; |
4570 /* When fresh value of window-local option is not at the | 4568 // When fresh value of window-local option is not at the |
4571 * default, need to write it too. */ | 4569 // default, need to write it too. |
4572 if (!(opt_flags & OPT_GLOBAL) && !local_only) | 4570 if (!(opt_flags & OPT_GLOBAL) && !local_only) |
4573 { | 4571 { |
4574 varp_fresh = get_varp_scope(p, OPT_GLOBAL); | 4572 varp_fresh = get_varp_scope(p, OPT_GLOBAL); |
4575 if (!optval_default(p, varp_fresh, p_cp)) | 4573 if (!optval_default(p, varp_fresh, p_cp)) |
4576 { | 4574 { |
4580 } | 4578 } |
4581 } | 4579 } |
4582 } | 4580 } |
4583 } | 4581 } |
4584 | 4582 |
4585 /* Round 1: fresh value for window-local options. | 4583 // Round 1: fresh value for window-local options. |
4586 * Round 2: other values */ | 4584 // Round 2: other values |
4587 for ( ; round <= 2; varp = varp_local, ++round) | 4585 for ( ; round <= 2; varp = varp_local, ++round) |
4588 { | 4586 { |
4589 if (round == 1 || (opt_flags & OPT_GLOBAL)) | 4587 if (round == 1 || (opt_flags & OPT_GLOBAL)) |
4590 cmd = "set"; | 4588 cmd = "set"; |
4591 else | 4589 else |
4599 else if (p->flags & P_NUM) | 4597 else if (p->flags & P_NUM) |
4600 { | 4598 { |
4601 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) | 4599 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) |
4602 return FAIL; | 4600 return FAIL; |
4603 } | 4601 } |
4604 else /* P_STRING */ | 4602 else // P_STRING |
4605 { | 4603 { |
4606 int do_endif = FALSE; | 4604 int do_endif = FALSE; |
4607 | 4605 |
4608 /* Don't set 'syntax' and 'filetype' again if the value is | 4606 // Don't set 'syntax' and 'filetype' again if the value is |
4609 * already right, avoids reloading the syntax file. */ | 4607 // already right, avoids reloading the syntax file. |
4610 if ( | 4608 if ( |
4611 #if defined(FEAT_SYN_HL) | 4609 #if defined(FEAT_SYN_HL) |
4612 p->indir == PV_SYN || | 4610 p->indir == PV_SYN || |
4613 #endif | 4611 #endif |
4614 p->indir == PV_FT) | 4612 p->indir == PV_FT) |
4677 | 4675 |
4678 if (fprintf(fd, "%s %s=", cmd, name) < 0) | 4676 if (fprintf(fd, "%s %s=", cmd, name) < 0) |
4679 return FAIL; | 4677 return FAIL; |
4680 if (*valuep != NULL) | 4678 if (*valuep != NULL) |
4681 { | 4679 { |
4682 /* Output 'pastetoggle' as key names. For other | 4680 // Output 'pastetoggle' as key names. For other |
4683 * options some characters have to be escaped with | 4681 // options some characters have to be escaped with |
4684 * CTRL-V or backslash */ | 4682 // CTRL-V or backslash |
4685 if (valuep == &p_pt) | 4683 if (valuep == &p_pt) |
4686 { | 4684 { |
4687 s = *valuep; | 4685 s = *valuep; |
4688 while (*s != NUL) | 4686 while (*s != NUL) |
4689 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) | 4687 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) |
4759 | 4757 |
4760 if (fprintf(fd, "%s %s=", cmd, name) < 0) | 4758 if (fprintf(fd, "%s %s=", cmd, name) < 0) |
4761 return FAIL; | 4759 return FAIL; |
4762 if (wc_use_keyname((char_u *)valuep, &wc)) | 4760 if (wc_use_keyname((char_u *)valuep, &wc)) |
4763 { | 4761 { |
4764 /* print 'wildchar' and 'wildcharm' as a key name */ | 4762 // print 'wildchar' and 'wildcharm' as a key name |
4765 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) | 4763 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) |
4766 return FAIL; | 4764 return FAIL; |
4767 } | 4765 } |
4768 else if (fprintf(fd, "%ld", *valuep) < 0) | 4766 else if (fprintf(fd, "%ld", *valuep) < 0) |
4769 return FAIL; | 4767 return FAIL; |
4777 FILE *fd, | 4775 FILE *fd, |
4778 char *cmd, | 4776 char *cmd, |
4779 char *name, | 4777 char *name, |
4780 int value) | 4778 int value) |
4781 { | 4779 { |
4782 if (value < 0) /* global/local option using global value */ | 4780 if (value < 0) // global/local option using global value |
4783 return OK; | 4781 return OK; |
4784 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 | 4782 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 |
4785 || put_eol(fd) < 0) | 4783 || put_eol(fd) < 0) |
4786 return FAIL; | 4784 return FAIL; |
4787 return OK; | 4785 return OK; |
4800 * outputting a few things that the terminal doesn't understand, but the | 4798 * outputting a few things that the terminal doesn't understand, but the |
4801 * screen will be cleared later, so this is OK. | 4799 * screen will be cleared later, so this is OK. |
4802 */ | 4800 */ |
4803 mch_setmouse(FALSE); // switch mouse off | 4801 mch_setmouse(FALSE); // switch mouse off |
4804 #ifdef FEAT_TITLE | 4802 #ifdef FEAT_TITLE |
4805 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */ | 4803 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
4806 #endif | 4804 #endif |
4807 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) | 4805 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) |
4808 /* When starting the GUI close the display opened for the clipboard. | 4806 // When starting the GUI close the display opened for the clipboard. |
4809 * After restoring the title, because that will need the display. */ | 4807 // After restoring the title, because that will need the display. |
4810 if (gui.starting) | 4808 if (gui.starting) |
4811 clear_xterm_clip(); | 4809 clear_xterm_clip(); |
4812 #endif | 4810 #endif |
4813 stoptermcap(); /* stop termcap mode */ | 4811 stoptermcap(); // stop termcap mode |
4814 | 4812 |
4815 free_termoptions(); | 4813 free_termoptions(); |
4816 } | 4814 } |
4817 | 4815 |
4818 void | 4816 void |
4879 } | 4877 } |
4880 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); | 4878 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); |
4881 if (p->flags & P_ALLOCED) | 4879 if (p->flags & P_ALLOCED) |
4882 { | 4880 { |
4883 p->flags |= P_DEF_ALLOCED; | 4881 p->flags |= P_DEF_ALLOCED; |
4884 p->flags &= ~P_ALLOCED; /* don't free the value now */ | 4882 p->flags &= ~P_ALLOCED; // don't free the value now |
4885 } | 4883 } |
4886 } | 4884 } |
4887 } | 4885 } |
4888 } | 4886 } |
4889 | 4887 |
4921 return; | 4919 return; |
4922 p = &(options[opt_idx]); | 4920 p = &(options[opt_idx]); |
4923 | 4921 |
4924 switch ((int)p->indir) | 4922 switch ((int)p->indir) |
4925 { | 4923 { |
4926 /* global option with local value: use local value if it's been set */ | 4924 // global option with local value: use local value if it's been set |
4927 case PV_EP: | 4925 case PV_EP: |
4928 clear_string_option(&buf->b_p_ep); | 4926 clear_string_option(&buf->b_p_ep); |
4929 break; | 4927 break; |
4930 case PV_KP: | 4928 case PV_KP: |
4931 clear_string_option(&buf->b_p_kp); | 4929 clear_string_option(&buf->b_p_kp); |
5069 case PV_LW: return (char_u *)&(curbuf->b_p_lw); | 5067 case PV_LW: return (char_u *)&(curbuf->b_p_lw); |
5070 #endif | 5068 #endif |
5071 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); | 5069 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); |
5072 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); | 5070 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); |
5073 } | 5071 } |
5074 return NULL; /* "cannot happen" */ | 5072 return NULL; // "cannot happen" |
5075 } | 5073 } |
5076 return get_varp(p); | 5074 return get_varp(p); |
5077 } | 5075 } |
5078 | 5076 |
5079 /* | 5077 /* |
5090 * Get pointer to option variable. | 5088 * Get pointer to option variable. |
5091 */ | 5089 */ |
5092 static char_u * | 5090 static char_u * |
5093 get_varp(struct vimoption *p) | 5091 get_varp(struct vimoption *p) |
5094 { | 5092 { |
5095 /* hidden option, always return NULL */ | 5093 // hidden option, always return NULL |
5096 if (p->var == NULL) | 5094 if (p->var == NULL) |
5097 return NULL; | 5095 return NULL; |
5098 | 5096 |
5099 switch ((int)p->indir) | 5097 switch ((int)p->indir) |
5100 { | 5098 { |
5101 case PV_NONE: return p->var; | 5099 case PV_NONE: return p->var; |
5102 | 5100 |
5103 /* global option with local value: use local value if it's been set */ | 5101 // global option with local value: use local value if it's been set |
5104 case PV_EP: return *curbuf->b_p_ep != NUL | 5102 case PV_EP: return *curbuf->b_p_ep != NUL |
5105 ? (char_u *)&curbuf->b_p_ep : p->var; | 5103 ? (char_u *)&curbuf->b_p_ep : p->var; |
5106 case PV_KP: return *curbuf->b_p_kp != NUL | 5104 case PV_KP: return *curbuf->b_p_kp != NUL |
5107 ? (char_u *)&curbuf->b_p_kp : p->var; | 5105 ? (char_u *)&curbuf->b_p_kp : p->var; |
5108 case PV_PATH: return *curbuf->b_p_path != NUL | 5106 case PV_PATH: return *curbuf->b_p_path != NUL |
5333 case PV_VSTS: return (char_u *)&(curbuf->b_p_vsts); | 5331 case PV_VSTS: return (char_u *)&(curbuf->b_p_vsts); |
5334 case PV_VTS: return (char_u *)&(curbuf->b_p_vts); | 5332 case PV_VTS: return (char_u *)&(curbuf->b_p_vts); |
5335 #endif | 5333 #endif |
5336 default: iemsg(_("E356: get_varp ERROR")); | 5334 default: iemsg(_("E356: get_varp ERROR")); |
5337 } | 5335 } |
5338 /* always return a valid pointer to avoid a crash! */ | 5336 // always return a valid pointer to avoid a crash! |
5339 return (char_u *)&(curbuf->b_p_wm); | 5337 return (char_u *)&(curbuf->b_p_wm); |
5340 } | 5338 } |
5341 | 5339 |
5342 /* | 5340 /* |
5343 * Return a pointer to the variable for option at 'opt_idx' | 5341 * Return a pointer to the variable for option at 'opt_idx' |
5484 #ifdef FEAT_EVAL | 5482 #ifdef FEAT_EVAL |
5485 // Copy the script context so that we know where the value was last set. | 5483 // Copy the script context so that we know where the value was last set. |
5486 mch_memmove(to->wo_script_ctx, from->wo_script_ctx, | 5484 mch_memmove(to->wo_script_ctx, from->wo_script_ctx, |
5487 sizeof(to->wo_script_ctx)); | 5485 sizeof(to->wo_script_ctx)); |
5488 #endif | 5486 #endif |
5489 check_winopt(to); /* don't want NULL pointers */ | 5487 check_winopt(to); // don't want NULL pointers |
5490 } | 5488 } |
5491 | 5489 |
5492 /* | 5490 /* |
5493 * Check string options in a window for a NULL value. | 5491 * Check string options in a window for a NULL value. |
5494 */ | 5492 */ |
5625 */ | 5623 */ |
5626 void | 5624 void |
5627 buf_copy_options(buf_T *buf, int flags) | 5625 buf_copy_options(buf_T *buf, int flags) |
5628 { | 5626 { |
5629 int should_copy = TRUE; | 5627 int should_copy = TRUE; |
5630 char_u *save_p_isk = NULL; /* init for GCC */ | 5628 char_u *save_p_isk = NULL; // init for GCC |
5631 int dont_do_help; | 5629 int dont_do_help; |
5632 int did_isk = FALSE; | 5630 int did_isk = FALSE; |
5633 | 5631 |
5634 /* | 5632 /* |
5635 * Skip this when the option defaults have not been set yet. Happens when | 5633 * Skip this when the option defaults have not been set yet. Happens when |
5676 * reset 'readonly' and copy 'fileformat'. | 5674 * reset 'readonly' and copy 'fileformat'. |
5677 */ | 5675 */ |
5678 if (!buf->b_p_initialized) | 5676 if (!buf->b_p_initialized) |
5679 { | 5677 { |
5680 free_buf_options(buf, TRUE); | 5678 free_buf_options(buf, TRUE); |
5681 buf->b_p_ro = FALSE; /* don't copy readonly */ | 5679 buf->b_p_ro = FALSE; // don't copy readonly |
5682 buf->b_p_tx = p_tx; | 5680 buf->b_p_tx = p_tx; |
5683 buf->b_p_fenc = vim_strsave(p_fenc); | 5681 buf->b_p_fenc = vim_strsave(p_fenc); |
5684 switch (*p_ffs) | 5682 switch (*p_ffs) |
5685 { | 5683 { |
5686 case 'm': | 5684 case 'm': |
5807 #ifdef FEAT_LISP | 5805 #ifdef FEAT_LISP |
5808 buf->b_p_lisp = p_lisp; | 5806 buf->b_p_lisp = p_lisp; |
5809 COPY_OPT_SCTX(buf, BV_LISP); | 5807 COPY_OPT_SCTX(buf, BV_LISP); |
5810 #endif | 5808 #endif |
5811 #ifdef FEAT_SYN_HL | 5809 #ifdef FEAT_SYN_HL |
5812 /* Don't copy 'syntax', it must be set */ | 5810 // Don't copy 'syntax', it must be set |
5813 buf->b_p_syn = empty_option; | 5811 buf->b_p_syn = empty_option; |
5814 buf->b_p_smc = p_smc; | 5812 buf->b_p_smc = p_smc; |
5815 COPY_OPT_SCTX(buf, BV_SMC); | 5813 COPY_OPT_SCTX(buf, BV_SMC); |
5816 buf->b_s.b_syn_isk = empty_option; | 5814 buf->b_s.b_syn_isk = empty_option; |
5817 #endif | 5815 #endif |
5850 #endif | 5848 #endif |
5851 #ifdef FEAT_TERMINAL | 5849 #ifdef FEAT_TERMINAL |
5852 buf->b_p_twsl = p_twsl; | 5850 buf->b_p_twsl = p_twsl; |
5853 COPY_OPT_SCTX(buf, BV_TWSL); | 5851 COPY_OPT_SCTX(buf, BV_TWSL); |
5854 #endif | 5852 #endif |
5855 /* This isn't really an option, but copying the langmap and IME | 5853 // This isn't really an option, but copying the langmap and IME |
5856 * state from the current buffer is better than resetting it. */ | 5854 // state from the current buffer is better than resetting it. |
5857 buf->b_p_iminsert = p_iminsert; | 5855 buf->b_p_iminsert = p_iminsert; |
5858 COPY_OPT_SCTX(buf, BV_IMI); | 5856 COPY_OPT_SCTX(buf, BV_IMI); |
5859 buf->b_p_imsearch = p_imsearch; | 5857 buf->b_p_imsearch = p_imsearch; |
5860 COPY_OPT_SCTX(buf, BV_IMS); | 5858 COPY_OPT_SCTX(buf, BV_IMS); |
5861 | 5859 |
5862 /* options that are normally global but also have a local value | 5860 // options that are normally global but also have a local value |
5863 * are not copied, start using the global value */ | 5861 // are not copied, start using the global value |
5864 buf->b_p_ar = -1; | 5862 buf->b_p_ar = -1; |
5865 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; | 5863 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; |
5866 buf->b_p_bkc = empty_option; | 5864 buf->b_p_bkc = empty_option; |
5867 buf->b_bkc_flags = 0; | 5865 buf->b_bkc_flags = 0; |
5868 #ifdef FEAT_QUICKFIX | 5866 #ifdef FEAT_QUICKFIX |
5949 */ | 5947 */ |
5950 if (should_copy) | 5948 if (should_copy) |
5951 buf->b_p_initialized = TRUE; | 5949 buf->b_p_initialized = TRUE; |
5952 } | 5950 } |
5953 | 5951 |
5954 check_buf_options(buf); /* make sure we don't have NULLs */ | 5952 check_buf_options(buf); // make sure we don't have NULLs |
5955 if (did_isk) | 5953 if (did_isk) |
5956 (void)buf_init_chartab(buf, FALSE); | 5954 (void)buf_init_chartab(buf, FALSE); |
5957 } | 5955 } |
5958 | 5956 |
5959 /* | 5957 /* |
5995 | 5993 |
5996 void | 5994 void |
5997 set_context_in_set_cmd( | 5995 set_context_in_set_cmd( |
5998 expand_T *xp, | 5996 expand_T *xp, |
5999 char_u *arg, | 5997 char_u *arg, |
6000 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ | 5998 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
6001 { | 5999 { |
6002 int nextchar; | 6000 int nextchar; |
6003 long_u flags = 0; /* init for GCC */ | 6001 long_u flags = 0; // init for GCC |
6004 int opt_idx = 0; /* init for GCC */ | 6002 int opt_idx = 0; // init for GCC |
6005 char_u *p; | 6003 char_u *p; |
6006 char_u *s; | 6004 char_u *s; |
6007 int is_term_option = FALSE; | 6005 int is_term_option = FALSE; |
6008 int key; | 6006 int key; |
6009 | 6007 |
6022 return; | 6020 return; |
6023 } | 6021 } |
6024 while (p > arg) | 6022 while (p > arg) |
6025 { | 6023 { |
6026 s = p; | 6024 s = p; |
6027 /* count number of backslashes before ' ' or ',' */ | 6025 // count number of backslashes before ' ' or ',' |
6028 if (*p == ' ' || *p == ',') | 6026 if (*p == ' ' || *p == ',') |
6029 { | 6027 { |
6030 while (s > arg && *(s - 1) == '\\') | 6028 while (s > arg && *(s - 1) == '\\') |
6031 --s; | 6029 --s; |
6032 } | 6030 } |
6033 /* break at a space with an even number of backslashes */ | 6031 // break at a space with an even number of backslashes |
6034 if (*p == ' ' && ((p - s) & 1) == 0) | 6032 if (*p == ' ' && ((p - s) & 1) == 0) |
6035 { | 6033 { |
6036 ++p; | 6034 ++p; |
6037 break; | 6035 break; |
6038 } | 6036 } |
6050 } | 6048 } |
6051 xp->xp_pattern = arg = p; | 6049 xp->xp_pattern = arg = p; |
6052 if (*arg == '<') | 6050 if (*arg == '<') |
6053 { | 6051 { |
6054 while (*p != '>') | 6052 while (*p != '>') |
6055 if (*p++ == NUL) /* expand terminal option name */ | 6053 if (*p++ == NUL) // expand terminal option name |
6056 return; | 6054 return; |
6057 key = get_special_key_code(arg + 1); | 6055 key = get_special_key_code(arg + 1); |
6058 if (key == 0) /* unknown name */ | 6056 if (key == 0) // unknown name |
6059 { | 6057 { |
6060 xp->xp_context = EXPAND_NOTHING; | 6058 xp->xp_context = EXPAND_NOTHING; |
6061 return; | 6059 return; |
6062 } | 6060 } |
6063 nextchar = *++p; | 6061 nextchar = *++p; |
6071 { | 6069 { |
6072 p += 2; | 6070 p += 2; |
6073 if (*p != NUL) | 6071 if (*p != NUL) |
6074 ++p; | 6072 ++p; |
6075 if (*p == NUL) | 6073 if (*p == NUL) |
6076 return; /* expand option name */ | 6074 return; // expand option name |
6077 nextchar = *++p; | 6075 nextchar = *++p; |
6078 is_term_option = TRUE; | 6076 is_term_option = TRUE; |
6079 expand_option_name[2] = p[-2]; | 6077 expand_option_name[2] = p[-2]; |
6080 expand_option_name[3] = p[-1]; | 6078 expand_option_name[3] = p[-1]; |
6081 } | 6079 } |
6082 else | 6080 else |
6083 { | 6081 { |
6084 /* Allow * wildcard */ | 6082 // Allow * wildcard |
6085 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') | 6083 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') |
6086 p++; | 6084 p++; |
6087 if (*p == NUL) | 6085 if (*p == NUL) |
6088 return; | 6086 return; |
6089 nextchar = *p; | 6087 nextchar = *p; |
6101 xp->xp_context = EXPAND_NOTHING; | 6099 xp->xp_context = EXPAND_NOTHING; |
6102 return; | 6100 return; |
6103 } | 6101 } |
6104 } | 6102 } |
6105 } | 6103 } |
6106 /* handle "-=" and "+=" */ | 6104 // handle "-=" and "+=" |
6107 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') | 6105 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') |
6108 { | 6106 { |
6109 ++p; | 6107 ++p; |
6110 nextchar = '='; | 6108 nextchar = '='; |
6111 } | 6109 } |
6158 xp->xp_backslash = XP_BS_ONE; | 6156 xp->xp_backslash = XP_BS_ONE; |
6159 } | 6157 } |
6160 else | 6158 else |
6161 { | 6159 { |
6162 xp->xp_context = EXPAND_FILES; | 6160 xp->xp_context = EXPAND_FILES; |
6163 /* for 'tags' need three backslashes for a space */ | 6161 // for 'tags' need three backslashes for a space |
6164 if (p == (char_u *)&p_tags) | 6162 if (p == (char_u *)&p_tags) |
6165 xp->xp_backslash = XP_BS_THREE; | 6163 xp->xp_backslash = XP_BS_THREE; |
6166 else | 6164 else |
6167 xp->xp_backslash = XP_BS_ONE; | 6165 xp->xp_backslash = XP_BS_ONE; |
6168 } | 6166 } |
6169 } | 6167 } |
6170 | 6168 |
6171 /* For an option that is a list of file names, find the start of the | 6169 // For an option that is a list of file names, find the start of the |
6172 * last file name. */ | 6170 // last file name. |
6173 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) | 6171 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) |
6174 { | 6172 { |
6175 /* count number of backslashes before ' ' or ',' */ | 6173 // count number of backslashes before ' ' or ',' |
6176 if (*p == ' ' || *p == ',') | 6174 if (*p == ' ' || *p == ',') |
6177 { | 6175 { |
6178 s = p; | 6176 s = p; |
6179 while (s > xp->xp_pattern && *(s - 1) == '\\') | 6177 while (s > xp->xp_pattern && *(s - 1) == '\\') |
6180 --s; | 6178 --s; |
6185 break; | 6183 break; |
6186 } | 6184 } |
6187 } | 6185 } |
6188 | 6186 |
6189 #ifdef FEAT_SPELL | 6187 #ifdef FEAT_SPELL |
6190 /* for 'spellsuggest' start at "file:" */ | 6188 // for 'spellsuggest' start at "file:" |
6191 if (options[opt_idx].var == (char_u *)&p_sps | 6189 if (options[opt_idx].var == (char_u *)&p_sps |
6192 && STRNCMP(p, "file:", 5) == 0) | 6190 && STRNCMP(p, "file:", 5) == 0) |
6193 { | 6191 { |
6194 xp->xp_pattern = p + 5; | 6192 xp->xp_pattern = p + 5; |
6195 break; | 6193 break; |
6205 expand_T *xp, | 6203 expand_T *xp, |
6206 regmatch_T *regmatch, | 6204 regmatch_T *regmatch, |
6207 int *num_file, | 6205 int *num_file, |
6208 char_u ***file) | 6206 char_u ***file) |
6209 { | 6207 { |
6210 int num_normal = 0; /* Nr of matching non-term-code settings */ | 6208 int num_normal = 0; // Nr of matching non-term-code settings |
6211 int num_term = 0; /* Nr of matching terminal code settings */ | 6209 int num_term = 0; // Nr of matching terminal code settings |
6212 int opt_idx; | 6210 int opt_idx; |
6213 int match; | 6211 int match; |
6214 int count = 0; | 6212 int count = 0; |
6215 char_u *str; | 6213 char_u *str; |
6216 int loop; | 6214 int loop; |
6217 int is_term_opt; | 6215 int is_term_opt; |
6218 char_u name_buf[MAX_KEY_NAME_LEN]; | 6216 char_u name_buf[MAX_KEY_NAME_LEN]; |
6219 static char *(names[]) = {"all", "termcap"}; | 6217 static char *(names[]) = {"all", "termcap"}; |
6220 int ic = regmatch->rm_ic; /* remember the ignore-case flag */ | 6218 int ic = regmatch->rm_ic; // remember the ignore-case flag |
6221 | 6219 |
6222 /* do this loop twice: | 6220 // do this loop twice: |
6223 * loop == 0: count the number of matching options | 6221 // loop == 0: count the number of matching options |
6224 * loop == 1: copy the matching options into allocated memory | 6222 // loop == 1: copy the matching options into allocated memory |
6225 */ | |
6226 for (loop = 0; loop <= 1; ++loop) | 6223 for (loop = 0; loop <= 1; ++loop) |
6227 { | 6224 { |
6228 regmatch->rm_ic = ic; | 6225 regmatch->rm_ic = ic; |
6229 if (xp->xp_context != EXPAND_BOOL_SETTINGS) | 6226 if (xp->xp_context != EXPAND_BOOL_SETTINGS) |
6230 { | 6227 { |
6325 } | 6322 } |
6326 | 6323 |
6327 /* | 6324 /* |
6328 * Check special key names. | 6325 * Check special key names. |
6329 */ | 6326 */ |
6330 regmatch->rm_ic = TRUE; /* ignore case here */ | 6327 regmatch->rm_ic = TRUE; // ignore case here |
6331 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) | 6328 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) |
6332 { | 6329 { |
6333 name_buf[0] = '<'; | 6330 name_buf[0] = '<'; |
6334 STRCPY(name_buf + 1, str); | 6331 STRCPY(name_buf + 1, str); |
6335 STRCAT(name_buf, ">"); | 6332 STRCAT(name_buf, ">"); |
6363 } | 6360 } |
6364 | 6361 |
6365 int | 6362 int |
6366 ExpandOldSetting(int *num_file, char_u ***file) | 6363 ExpandOldSetting(int *num_file, char_u ***file) |
6367 { | 6364 { |
6368 char_u *var = NULL; /* init for GCC */ | 6365 char_u *var = NULL; // init for GCC |
6369 char_u *buf; | 6366 char_u *buf; |
6370 | 6367 |
6371 *num_file = 0; | 6368 *num_file = 0; |
6372 *file = ALLOC_ONE(char_u *); | 6369 *file = ALLOC_ONE(char_u *); |
6373 if (*file == NULL) | 6370 if (*file == NULL) |
6383 expand_option_idx = findoption(expand_option_name); | 6380 expand_option_idx = findoption(expand_option_name); |
6384 } | 6381 } |
6385 | 6382 |
6386 if (expand_option_idx >= 0) | 6383 if (expand_option_idx >= 0) |
6387 { | 6384 { |
6388 /* put string of option value in NameBuff */ | 6385 // put string of option value in NameBuff |
6389 option_value2string(&options[expand_option_idx], expand_option_flags); | 6386 option_value2string(&options[expand_option_idx], expand_option_flags); |
6390 var = NameBuff; | 6387 var = NameBuff; |
6391 } | 6388 } |
6392 else if (var == NULL) | 6389 else if (var == NULL) |
6393 var = (char_u *)""; | 6390 var = (char_u *)""; |
6394 | 6391 |
6395 /* A backslash is required before some characters. This is the reverse of | 6392 // A backslash is required before some characters. This is the reverse of |
6396 * what happens in do_set(). */ | 6393 // what happens in do_set(). |
6397 buf = vim_strsave_escaped(var, escape_chars); | 6394 buf = vim_strsave_escaped(var, escape_chars); |
6398 | 6395 |
6399 if (buf == NULL) | 6396 if (buf == NULL) |
6400 { | 6397 { |
6401 VIM_CLEAR(*file); | 6398 VIM_CLEAR(*file); |
6402 return FAIL; | 6399 return FAIL; |
6403 } | 6400 } |
6404 | 6401 |
6405 #ifdef BACKSLASH_IN_FILENAME | 6402 #ifdef BACKSLASH_IN_FILENAME |
6406 /* For MS-Windows et al. we don't double backslashes at the start and | 6403 // For MS-Windows et al. we don't double backslashes at the start and |
6407 * before a file name character. */ | 6404 // before a file name character. |
6408 for (var = buf; *var != NUL; MB_PTR_ADV(var)) | 6405 for (var = buf; *var != NUL; MB_PTR_ADV(var)) |
6409 if (var[0] == '\\' && var[1] == '\\' | 6406 if (var[0] == '\\' && var[1] == '\\' |
6410 && expand_option_idx >= 0 | 6407 && expand_option_idx >= 0 |
6411 && (options[expand_option_idx].flags & P_EXPAND) | 6408 && (options[expand_option_idx].flags & P_EXPAND) |
6412 && vim_isfilec(var[2]) | 6409 && vim_isfilec(var[2]) |
6424 * NameBuff[]. Must not be called with a hidden option! | 6421 * NameBuff[]. Must not be called with a hidden option! |
6425 */ | 6422 */ |
6426 static void | 6423 static void |
6427 option_value2string( | 6424 option_value2string( |
6428 struct vimoption *opp, | 6425 struct vimoption *opp, |
6429 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ | 6426 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL |
6430 { | 6427 { |
6431 char_u *varp; | 6428 char_u *varp; |
6432 | 6429 |
6433 varp = get_varp_scope(opp, opt_flags); | 6430 varp = get_varp_scope(opp, opt_flags); |
6434 | 6431 |
6441 else if (wc != 0) | 6438 else if (wc != 0) |
6442 STRCPY(NameBuff, transchar((int)wc)); | 6439 STRCPY(NameBuff, transchar((int)wc)); |
6443 else | 6440 else |
6444 sprintf((char *)NameBuff, "%ld", *(long *)varp); | 6441 sprintf((char *)NameBuff, "%ld", *(long *)varp); |
6445 } | 6442 } |
6446 else /* P_STRING */ | 6443 else // P_STRING |
6447 { | 6444 { |
6448 varp = *(char_u **)(varp); | 6445 varp = *(char_u **)(varp); |
6449 if (varp == NULL) /* just in case */ | 6446 if (varp == NULL) // just in case |
6450 NameBuff[0] = NUL; | 6447 NameBuff[0] = NUL; |
6451 #ifdef FEAT_CRYPT | 6448 #ifdef FEAT_CRYPT |
6452 /* don't show the actual value of 'key', only that it's set */ | 6449 // don't show the actual value of 'key', only that it's set |
6453 else if (opp->var == (char_u *)&p_key && *varp) | 6450 else if (opp->var == (char_u *)&p_key && *varp) |
6454 STRCPY(NameBuff, "*****"); | 6451 STRCPY(NameBuff, "*****"); |
6455 #endif | 6452 #endif |
6456 else if (opp->flags & P_EXPAND) | 6453 else if (opp->flags & P_EXPAND) |
6457 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); | 6454 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); |
6458 /* Translate 'pastetoggle' into special key names */ | 6455 // Translate 'pastetoggle' into special key names |
6459 else if ((char_u **)opp->var == &p_pt) | 6456 else if ((char_u **)opp->var == &p_pt) |
6460 str2specialbuf(p_pt, NameBuff, MAXPATHL); | 6457 str2specialbuf(p_pt, NameBuff, MAXPATHL); |
6461 else | 6458 else |
6462 vim_strncpy(NameBuff, varp, MAXPATHL - 1); | 6459 vim_strncpy(NameBuff, varp, MAXPATHL - 1); |
6463 } | 6460 } |
6529 * Paste switched from off to on. | 6526 * Paste switched from off to on. |
6530 * Save the current values, so they can be restored later. | 6527 * Save the current values, so they can be restored later. |
6531 */ | 6528 */ |
6532 if (!old_p_paste) | 6529 if (!old_p_paste) |
6533 { | 6530 { |
6534 /* save options for each buffer */ | 6531 // save options for each buffer |
6535 FOR_ALL_BUFFERS(buf) | 6532 FOR_ALL_BUFFERS(buf) |
6536 { | 6533 { |
6537 buf->b_p_tw_nopaste = buf->b_p_tw; | 6534 buf->b_p_tw_nopaste = buf->b_p_tw; |
6538 buf->b_p_wm_nopaste = buf->b_p_wm; | 6535 buf->b_p_wm_nopaste = buf->b_p_wm; |
6539 buf->b_p_sts_nopaste = buf->b_p_sts; | 6536 buf->b_p_sts_nopaste = buf->b_p_sts; |
6545 buf->b_p_vsts_nopaste = buf->b_p_vsts && buf->b_p_vsts != empty_option | 6542 buf->b_p_vsts_nopaste = buf->b_p_vsts && buf->b_p_vsts != empty_option |
6546 ? vim_strsave(buf->b_p_vsts) : NULL; | 6543 ? vim_strsave(buf->b_p_vsts) : NULL; |
6547 #endif | 6544 #endif |
6548 } | 6545 } |
6549 | 6546 |
6550 /* save global options */ | 6547 // save global options |
6551 save_sm = p_sm; | 6548 save_sm = p_sm; |
6552 save_sta = p_sta; | 6549 save_sta = p_sta; |
6553 #ifdef FEAT_CMDL_INFO | 6550 #ifdef FEAT_CMDL_INFO |
6554 save_ru = p_ru; | 6551 save_ru = p_ru; |
6555 #endif | 6552 #endif |
6556 #ifdef FEAT_RIGHTLEFT | 6553 #ifdef FEAT_RIGHTLEFT |
6557 save_ri = p_ri; | 6554 save_ri = p_ri; |
6558 save_hkmap = p_hkmap; | 6555 save_hkmap = p_hkmap; |
6559 #endif | 6556 #endif |
6560 /* save global values for local buffer options */ | 6557 // save global values for local buffer options |
6561 p_ai_nopaste = p_ai; | 6558 p_ai_nopaste = p_ai; |
6562 p_et_nopaste = p_et; | 6559 p_et_nopaste = p_et; |
6563 p_sts_nopaste = p_sts; | 6560 p_sts_nopaste = p_sts; |
6564 p_tw_nopaste = p_tw; | 6561 p_tw_nopaste = p_tw; |
6565 p_wm_nopaste = p_wm; | 6562 p_wm_nopaste = p_wm; |
6572 | 6569 |
6573 /* | 6570 /* |
6574 * Always set the option values, also when 'paste' is set when it is | 6571 * Always set the option values, also when 'paste' is set when it is |
6575 * already on. | 6572 * already on. |
6576 */ | 6573 */ |
6577 /* set options for each buffer */ | 6574 // set options for each buffer |
6578 FOR_ALL_BUFFERS(buf) | 6575 FOR_ALL_BUFFERS(buf) |
6579 { | 6576 { |
6580 buf->b_p_tw = 0; /* textwidth is 0 */ | 6577 buf->b_p_tw = 0; // textwidth is 0 |
6581 buf->b_p_wm = 0; /* wrapmargin is 0 */ | 6578 buf->b_p_wm = 0; // wrapmargin is 0 |
6582 buf->b_p_sts = 0; /* softtabstop is 0 */ | 6579 buf->b_p_sts = 0; // softtabstop is 0 |
6583 buf->b_p_ai = 0; /* no auto-indent */ | 6580 buf->b_p_ai = 0; // no auto-indent |
6584 buf->b_p_et = 0; /* no expandtab */ | 6581 buf->b_p_et = 0; // no expandtab |
6585 #ifdef FEAT_VARTABS | 6582 #ifdef FEAT_VARTABS |
6586 if (buf->b_p_vsts) | 6583 if (buf->b_p_vsts) |
6587 free_string_option(buf->b_p_vsts); | 6584 free_string_option(buf->b_p_vsts); |
6588 buf->b_p_vsts = empty_option; | 6585 buf->b_p_vsts = empty_option; |
6589 if (buf->b_p_vsts_array) | 6586 if (buf->b_p_vsts_array) |
6590 vim_free(buf->b_p_vsts_array); | 6587 vim_free(buf->b_p_vsts_array); |
6591 buf->b_p_vsts_array = 0; | 6588 buf->b_p_vsts_array = 0; |
6592 #endif | 6589 #endif |
6593 } | 6590 } |
6594 | 6591 |
6595 /* set global options */ | 6592 // set global options |
6596 p_sm = 0; /* no showmatch */ | 6593 p_sm = 0; // no showmatch |
6597 p_sta = 0; /* no smarttab */ | 6594 p_sta = 0; // no smarttab |
6598 #ifdef FEAT_CMDL_INFO | 6595 #ifdef FEAT_CMDL_INFO |
6599 if (p_ru) | 6596 if (p_ru) |
6600 status_redraw_all(); /* redraw to remove the ruler */ | 6597 status_redraw_all(); // redraw to remove the ruler |
6601 p_ru = 0; /* no ruler */ | 6598 p_ru = 0; // no ruler |
6602 #endif | 6599 #endif |
6603 #ifdef FEAT_RIGHTLEFT | 6600 #ifdef FEAT_RIGHTLEFT |
6604 p_ri = 0; /* no reverse insert */ | 6601 p_ri = 0; // no reverse insert |
6605 p_hkmap = 0; /* no Hebrew keyboard */ | 6602 p_hkmap = 0; // no Hebrew keyboard |
6606 #endif | 6603 #endif |
6607 /* set global values for local buffer options */ | 6604 // set global values for local buffer options |
6608 p_tw = 0; | 6605 p_tw = 0; |
6609 p_wm = 0; | 6606 p_wm = 0; |
6610 p_sts = 0; | 6607 p_sts = 0; |
6611 p_ai = 0; | 6608 p_ai = 0; |
6612 #ifdef FEAT_VARTABS | 6609 #ifdef FEAT_VARTABS |
6619 /* | 6616 /* |
6620 * Paste switched from on to off: Restore saved values. | 6617 * Paste switched from on to off: Restore saved values. |
6621 */ | 6618 */ |
6622 else if (old_p_paste) | 6619 else if (old_p_paste) |
6623 { | 6620 { |
6624 /* restore options for each buffer */ | 6621 // restore options for each buffer |
6625 FOR_ALL_BUFFERS(buf) | 6622 FOR_ALL_BUFFERS(buf) |
6626 { | 6623 { |
6627 buf->b_p_tw = buf->b_p_tw_nopaste; | 6624 buf->b_p_tw = buf->b_p_tw_nopaste; |
6628 buf->b_p_wm = buf->b_p_wm_nopaste; | 6625 buf->b_p_wm = buf->b_p_wm_nopaste; |
6629 buf->b_p_sts = buf->b_p_sts_nopaste; | 6626 buf->b_p_sts = buf->b_p_sts_nopaste; |
6641 else | 6638 else |
6642 buf->b_p_vsts_array = 0; | 6639 buf->b_p_vsts_array = 0; |
6643 #endif | 6640 #endif |
6644 } | 6641 } |
6645 | 6642 |
6646 /* restore global options */ | 6643 // restore global options |
6647 p_sm = save_sm; | 6644 p_sm = save_sm; |
6648 p_sta = save_sta; | 6645 p_sta = save_sta; |
6649 #ifdef FEAT_CMDL_INFO | 6646 #ifdef FEAT_CMDL_INFO |
6650 if (p_ru != save_ru) | 6647 if (p_ru != save_ru) |
6651 status_redraw_all(); /* redraw to draw the ruler */ | 6648 status_redraw_all(); // redraw to draw the ruler |
6652 p_ru = save_ru; | 6649 p_ru = save_ru; |
6653 #endif | 6650 #endif |
6654 #ifdef FEAT_RIGHTLEFT | 6651 #ifdef FEAT_RIGHTLEFT |
6655 p_ri = save_ri; | 6652 p_ri = save_ri; |
6656 p_hkmap = save_hkmap; | 6653 p_hkmap = save_hkmap; |
6657 #endif | 6654 #endif |
6658 /* set global values for local buffer options */ | 6655 // set global values for local buffer options |
6659 p_ai = p_ai_nopaste; | 6656 p_ai = p_ai_nopaste; |
6660 p_et = p_et_nopaste; | 6657 p_et = p_et_nopaste; |
6661 p_sts = p_sts_nopaste; | 6658 p_sts = p_sts_nopaste; |
6662 p_tw = p_tw_nopaste; | 6659 p_tw = p_tw_nopaste; |
6663 p_wm = p_wm_nopaste; | 6660 p_wm = p_wm_nopaste; |
6699 if (fname != NULL) | 6696 if (fname != NULL) |
6700 { | 6697 { |
6701 p = vim_getenv(envname, &dofree); | 6698 p = vim_getenv(envname, &dofree); |
6702 if (p == NULL) | 6699 if (p == NULL) |
6703 { | 6700 { |
6704 /* Set $MYVIMRC to the first vimrc file found. */ | 6701 // Set $MYVIMRC to the first vimrc file found. |
6705 p = FullName_save(fname, FALSE); | 6702 p = FullName_save(fname, FALSE); |
6706 if (p != NULL) | 6703 if (p != NULL) |
6707 { | 6704 { |
6708 vim_setenv(envname, p); | 6705 vim_setenv(envname, p); |
6709 vim_free(p); | 6706 vim_free(p); |
6740 option_was_set(char_u *name) | 6737 option_was_set(char_u *name) |
6741 { | 6738 { |
6742 int idx; | 6739 int idx; |
6743 | 6740 |
6744 idx = findoption(name); | 6741 idx = findoption(name); |
6745 if (idx < 0) /* unknown option */ | 6742 if (idx < 0) // unknown option |
6746 return FALSE; | 6743 return FALSE; |
6747 if (options[idx].flags & P_WAS_SET) | 6744 if (options[idx].flags & P_WAS_SET) |
6748 return TRUE; | 6745 return TRUE; |
6749 return FALSE; | 6746 return FALSE; |
6750 } | 6747 } |
6809 /* | 6806 /* |
6810 * Check if backspacing over something is allowed. | 6807 * Check if backspacing over something is allowed. |
6811 */ | 6808 */ |
6812 int | 6809 int |
6813 can_bs( | 6810 can_bs( |
6814 int what) /* BS_INDENT, BS_EOL or BS_START */ | 6811 int what) // BS_INDENT, BS_EOL or BS_START |
6815 { | 6812 { |
6816 #ifdef FEAT_JOB_CHANNEL | 6813 #ifdef FEAT_JOB_CHANNEL |
6817 if (what == BS_START && bt_prompt(curbuf)) | 6814 if (what == BS_START && bt_prompt(curbuf)) |
6818 return FALSE; | 6815 return FALSE; |
6819 #endif | 6816 #endif |