To: vim-dev@vim.org Subject: Patch 6.2.455 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.455 (after 6.2.297) Problem: In Python commands the current locale changes how certain Python functions work. (Eugene M. Minkovskii) Solution: Set the LC_NUMERIC locale to "C" while executing a Python command. Files: src/if_python.c *** ../vim-6.2.454/src/if_python.c Mon Mar 1 20:07:25 2004 --- src/if_python.c Tue Apr 6 20:17:13 2004 *************** *** 490,495 **** --- 490,498 ---- #if defined(MACOS) && !defined(MACOS_X_UNIX) GrafPtr oldPort; #endif + #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) + char *saved_locale; + #endif #ifndef PY_CAN_RECURSE if (recursive) *************** *** 513,518 **** --- 516,534 ---- RangeEnd = eap->line2; Python_Release_Vim(); /* leave vim */ + #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) + /* Python only works properly when the LC_NUMERIC locale is "C". */ + saved_locale = setlocale(LC_NUMERIC, NULL); + if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0) + saved_locale = NULL; + else + { + /* Need to make a copy, value may change when setting new locale. */ + saved_locale = vim_strsave(saved_locale); + (void)setlocale(LC_NUMERIC, "C"); + } + #endif + #ifdef PY_CAN_RECURSE pygilstate = PyGILState_Ensure(); #else *************** *** 525,530 **** --- 541,554 ---- PyGILState_Release(pygilstate); #else Python_SaveThread(); /* leave python */ + #endif + + #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) + if (saved_locale != NULL) + { + (void)setlocale(LC_NUMERIC, saved_locale); + vim_free(saved_locale); + } #endif Python_Lock_Vim(); /* enter vim */ *** ../vim-6.2.454/src/version.c Tue Apr 6 20:14:01 2004 --- src/version.c Tue Apr 6 20:15:57 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 455, /**/ -- GALAHAD: No, please. Please! I can defeat them! There's only a hundred. GIRLS: He will beat us easily. We haven't a chance. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///