Mercurial > vim
comparison src/misc1.c @ 29892:db0939444c96 v9.0.0284
patch 9.0.0284: using static buffer for multiple completion functions
Commit: https://github.com/vim/vim/commit/5ff595d9db2d9a33aa10cc9f18f256826226862f
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 26 22:36:41 2022 +0100
patch 9.0.0284: using static buffer for multiple completion functions
Problem: Using static buffer for multiple completion functions.
Solution: Use one buffer in expand_T.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 26 Aug 2022 23:45:03 +0200 |
parents | 68ef14b21d01 |
children | 4fcf816aa806 |
comparison
equal
deleted
inserted
replaced
29891:6c571257924c | 29892:db0939444c96 |
---|---|
2014 char_u * | 2014 char_u * |
2015 get_env_name( | 2015 get_env_name( |
2016 expand_T *xp UNUSED, | 2016 expand_T *xp UNUSED, |
2017 int idx) | 2017 int idx) |
2018 { | 2018 { |
2019 # if defined(AMIGA) | 2019 #if defined(AMIGA) |
2020 /* | 2020 // No environ[] on the Amiga. |
2021 * No environ[] on the Amiga. | |
2022 */ | |
2023 return NULL; | 2021 return NULL; |
2024 # else | 2022 #else |
2025 # ifndef __WIN32__ | 2023 # ifndef __WIN32__ |
2026 // Borland C++ 5.2 has this in a header file. | 2024 // Borland C++ 5.2 has this in a header file. |
2027 extern char **environ; | 2025 extern char **environ; |
2028 # endif | 2026 # endif |
2029 # define ENVNAMELEN 100 | |
2030 static char_u name[ENVNAMELEN]; | |
2031 char_u *str; | 2027 char_u *str; |
2032 int n; | 2028 int n; |
2033 | 2029 |
2034 str = (char_u *)environ[idx]; | 2030 str = (char_u *)environ[idx]; |
2035 if (str == NULL) | 2031 if (str == NULL) |
2036 return NULL; | 2032 return NULL; |
2037 | 2033 |
2038 for (n = 0; n < ENVNAMELEN - 1; ++n) | 2034 for (n = 0; n < EXPAND_BUF_LEN - 1; ++n) |
2039 { | 2035 { |
2040 if (str[n] == '=' || str[n] == NUL) | 2036 if (str[n] == '=' || str[n] == NUL) |
2041 break; | 2037 break; |
2042 name[n] = str[n]; | 2038 xp->xp_buf[n] = str[n]; |
2043 } | 2039 } |
2044 name[n] = NUL; | 2040 xp->xp_buf[n] = NUL; |
2045 return name; | 2041 return xp->xp_buf; |
2046 # endif | 2042 #endif |
2047 } | 2043 } |
2048 | 2044 |
2049 /* | 2045 /* |
2050 * Add a user name to the list of users in ga_users. | 2046 * Add a user name to the list of users in ga_users. |
2051 * Do nothing if user name is NULL or empty. | 2047 * Do nothing if user name is NULL or empty. |