Mercurial > vim
comparison src/os_unix.c @ 16764:ef00b6bc186b v8.1.1384
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
commit https://github.com/vim/vim/commit/964b3746b9c81e65887e2ac9a335f181db2bb592
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 24 18:54:09 2019 +0200
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Problem: Using "int" for alloc() often results in compiler warnings.
Solution: Use "size_t" and remove type casts. Remove alloc_check(), Vim
only works with 32 bit ints anyway.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 May 2019 19:00:07 +0200 |
parents | 0422b14bce58 |
children | 695d9ef00b03 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
2445 return er; | 2445 return er; |
2446 } | 2446 } |
2447 #endif | 2447 #endif |
2448 | 2448 |
2449 /* | 2449 /* |
2450 * Get name of current directory into buffer 'buf' of length 'len' bytes. | 2450 * Get name of current directory into buffer "buf" of length "len" bytes. |
2451 * "len" must be at least PATH_MAX. | |
2451 * Return OK for success, FAIL for failure. | 2452 * Return OK for success, FAIL for failure. |
2452 */ | 2453 */ |
2453 int | 2454 int |
2454 mch_dirname(char_u *buf, int len) | 2455 mch_dirname(char_u *buf, int len) |
2455 { | 2456 { |
2514 if ((force || !mch_isFullName(fname)) | 2515 if ((force || !mch_isFullName(fname)) |
2515 && ((p = vim_strrchr(fname, '/')) == NULL || p != fname)) | 2516 && ((p = vim_strrchr(fname, '/')) == NULL || p != fname)) |
2516 { | 2517 { |
2517 /* | 2518 /* |
2518 * If the file name has a path, change to that directory for a moment, | 2519 * If the file name has a path, change to that directory for a moment, |
2519 * and then do the getwd() (and get back to where we were). | 2520 * and then get the directory (and get back to where we were). |
2520 * This will get the correct path name with "../" things. | 2521 * This will get the correct path name with "../" things. |
2521 */ | 2522 */ |
2522 if (p != NULL) | 2523 if (p != NULL) |
2523 { | 2524 { |
2524 #ifdef HAVE_FCHDIR | 2525 #ifdef HAVE_FCHDIR |
3122 } | 3123 } |
3123 | 3124 |
3124 p = (char_u *)getenv("PATH"); | 3125 p = (char_u *)getenv("PATH"); |
3125 if (p == NULL || *p == NUL) | 3126 if (p == NULL || *p == NUL) |
3126 return -1; | 3127 return -1; |
3127 buf = alloc((unsigned)(STRLEN(name) + STRLEN(p) + 2)); | 3128 buf = alloc(STRLEN(name) + STRLEN(p) + 2); |
3128 if (buf == NULL) | 3129 if (buf == NULL) |
3129 return -1; | 3130 return -1; |
3130 | 3131 |
3131 /* | 3132 /* |
3132 * Walk through all entries in $PATH to check if "name" exists there and | 3133 * Walk through all entries in $PATH to check if "name" exists there and |
4321 if (extra_shell_arg != NULL) | 4322 if (extra_shell_arg != NULL) |
4322 argv[argc++] = (char *)extra_shell_arg; | 4323 argv[argc++] = (char *)extra_shell_arg; |
4323 | 4324 |
4324 /* Break 'shellcmdflag' into white separated parts. This doesn't | 4325 /* Break 'shellcmdflag' into white separated parts. This doesn't |
4325 * handle quoted strings, they are very unlikely to appear. */ | 4326 * handle quoted strings, they are very unlikely to appear. */ |
4326 *shcf_tofree = alloc((unsigned)STRLEN(p_shcf) + 1); | 4327 *shcf_tofree = alloc(STRLEN(p_shcf) + 1); |
4327 if (*shcf_tofree == NULL) /* out of memory */ | 4328 if (*shcf_tofree == NULL) /* out of memory */ |
4328 return FAIL; | 4329 return FAIL; |
4329 s = *shcf_tofree; | 4330 s = *shcf_tofree; |
4330 p = p_shcf; | 4331 p = p_shcf; |
4331 while (*p != NUL) | 4332 while (*p != NUL) |
6897 /* Skip files that are not executable if we check for that. */ | 6898 /* Skip files that are not executable if we check for that. */ |
6898 if (!dir && (flags & EW_EXEC) | 6899 if (!dir && (flags & EW_EXEC) |
6899 && !mch_can_exe((*file)[i], NULL, !(flags & EW_SHELLCMD))) | 6900 && !mch_can_exe((*file)[i], NULL, !(flags & EW_SHELLCMD))) |
6900 continue; | 6901 continue; |
6901 | 6902 |
6902 p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir)); | 6903 p = alloc(STRLEN((*file)[i]) + 1 + dir); |
6903 if (p) | 6904 if (p) |
6904 { | 6905 { |
6905 STRCPY(p, (*file)[i]); | 6906 STRCPY(p, (*file)[i]); |
6906 if (dir) | 6907 if (dir) |
6907 add_pathsep(p); /* add '/' to a directory name */ | 6908 add_pathsep(p); /* add '/' to a directory name */ |