@@ -2867,9 +2867,8 @@ std::string SystemToolsStatic::FindName(
2867
2867
path.reserve (path.size () + userPaths.size ());
2868
2868
path.insert (path.end (), userPaths.begin (), userPaths.end ());
2869
2869
// now look for the file
2870
- std::string tryPath;
2871
2870
for (std::string const & p : path) {
2872
- tryPath = p;
2871
+ std::string tryPath = p;
2873
2872
if (tryPath.empty () || tryPath.back () != ' /' ) {
2874
2873
tryPath += ' /' ;
2875
2874
}
@@ -2938,8 +2937,6 @@ std::string SystemTools::FindProgram(const std::string& name,
2938
2937
const std::vector<std::string>& userPaths,
2939
2938
bool no_system_path)
2940
2939
{
2941
- std::string tryPath;
2942
-
2943
2940
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
2944
2941
std::vector<std::string> extensions;
2945
2942
// check to see if the name already has a .xxx at
@@ -2951,7 +2948,7 @@ std::string SystemTools::FindProgram(const std::string& name,
2951
2948
2952
2949
// first try with extensions if the os supports them
2953
2950
for (std::string const & ext : extensions) {
2954
- tryPath = name;
2951
+ std::string tryPath = name;
2955
2952
tryPath += ext;
2956
2953
if (SystemTools::FileIsExecutable (tryPath)) {
2957
2954
return SystemTools::CollapseFullPath (tryPath);
@@ -2988,7 +2985,7 @@ std::string SystemTools::FindProgram(const std::string& name,
2988
2985
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
2989
2986
// first try with extensions
2990
2987
for (std::string const & ext : extensions) {
2991
- tryPath = p;
2988
+ std::string tryPath = p;
2992
2989
tryPath += name;
2993
2990
tryPath += ext;
2994
2991
if (SystemTools::FileIsExecutable (tryPath)) {
@@ -2997,7 +2994,7 @@ std::string SystemTools::FindProgram(const std::string& name,
2997
2994
}
2998
2995
#endif
2999
2996
// now try it without them
3000
- tryPath = p;
2997
+ std::string tryPath = p;
3001
2998
tryPath += name;
3002
2999
if (SystemTools::FileIsExecutable (tryPath)) {
3003
3000
return SystemTools::CollapseFullPath (tryPath);
@@ -3152,16 +3149,13 @@ bool SystemTools::FileIsDirectory(const std::string& inName)
3152
3149
#if defined(_WIN32)
3153
3150
DWORD attr =
3154
3151
GetFileAttributesW (Encoding::ToWindowsExtendedPath (name).c_str ());
3155
- if (attr != INVALID_FILE_ATTRIBUTES) {
3156
- return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0 ;
3152
+ return (attr != INVALID_FILE_ATTRIBUTES) &&
3153
+ (attr & FILE_ATTRIBUTE_DIRECTORY);
3157
3154
#else
3158
3155
struct stat fs;
3159
- if ( stat (name, &fs) == 0 ) {
3160
- return S_ISDIR (fs.st_mode );
3156
+
3157
+ return ( stat (name, &fs) == 0 ) && S_ISDIR (fs.st_mode );
3161
3158
#endif
3162
- } else {
3163
- return false ;
3164
- }
3165
3159
}
3166
3160
3167
3161
bool SystemTools::FileIsExecutable (const std::string& inName)
@@ -3226,11 +3220,7 @@ bool SystemTools::FileIsSymlink(const std::string& name)
3226
3220
return FileIsSymlinkWithAttr (path, GetFileAttributesW (path.c_str ()));
3227
3221
#else
3228
3222
struct stat fs;
3229
- if (lstat (name.c_str (), &fs) == 0 ) {
3230
- return S_ISLNK (fs.st_mode );
3231
- } else {
3232
- return false ;
3233
- }
3223
+ return (lstat (name.c_str (), &fs) == 0 ) && S_ISLNK (fs.st_mode );
3234
3224
#endif
3235
3225
}
3236
3226
@@ -3248,11 +3238,7 @@ bool SystemTools::FileIsFIFO(const std::string& name)
3248
3238
return type == FILE_TYPE_PIPE;
3249
3239
#else
3250
3240
struct stat fs;
3251
- if (lstat (name.c_str (), &fs) == 0 ) {
3252
- return S_ISFIFO (fs.st_mode );
3253
- } else {
3254
- return false ;
3255
- }
3241
+ return (lstat (name.c_str (), &fs) == 0 ) && S_ISFIFO (fs.st_mode );
3256
3242
#endif
3257
3243
}
3258
3244
@@ -4889,7 +4875,7 @@ SystemToolsManager::~SystemToolsManager()
4889
4875
4890
4876
#if defined(__VMS)
4891
4877
// On VMS we configure the run time C library to be more UNIX like.
4892
- // http ://h71000.www7.hp.com/doc/732final/5763/5763pro_004.html
4878
+ // https ://h71000.www7.hp.com/doc/732final/5763/5763pro_004.html
4893
4879
extern " C" int decc$feature_get_index (char * name);
4894
4880
extern " C" int decc$feature_set_value (int index, int mode, int value);
4895
4881
static int SetVMSFeature (char * name, int value)
0 commit comments