Skip to content

Commit

Permalink
Merge pull request #4282 from yebblies/fixboolx
Browse files Browse the repository at this point in the history
[cleanup] Turn some more ints into bools
  • Loading branch information
9rnsr committed Jan 12, 2015
2 parents d02870d + 672b017 commit cb117bd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/func.c
Expand Up @@ -1188,7 +1188,7 @@ void FuncDeclaration::semantic(Scope *sc)
if (type && mod)
{
printedMain = true;
const char *name = FileName::searchPath(global.path, mod->srcfile->toChars(), 1);
const char *name = FileName::searchPath(global.path, mod->srcfile->toChars(), true);
fprintf(global.stdmsg, "entry %-10s\t%s\n", type, name);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/inifile.c
Expand Up @@ -88,7 +88,7 @@ const char *findConfFile(const char *argv0, const char *inifile)
printf("\tPATH='%s'\n", p);
#endif
Strings *paths = FileName::splitPath(p);
const char *abspath = FileName::searchPath(paths, argv0, 0);
const char *abspath = FileName::searchPath(paths, argv0, false);
if (abspath)
{
const char *absname = FileName::replaceName(abspath, inifile);
Expand Down
26 changes: 13 additions & 13 deletions src/root/filename.c
Expand Up @@ -177,7 +177,7 @@ bool FileName::equals(RootObject *obj)
return compare(obj) == 0;
}

int FileName::equals(const char *name1, const char *name2)
bool FileName::equals(const char *name1, const char *name2)
{
return compare(name1, name2) == 0;
}
Expand All @@ -186,7 +186,7 @@ int FileName::equals(const char *name1, const char *name2)
* Return !=0 if absolute path name.
*/

int FileName::absolute(const char *name)
bool FileName::absolute(const char *name)
{
#if _WIN32
return (*name == '\\') ||
Expand Down Expand Up @@ -413,28 +413,28 @@ const char *FileName::forceExt(const char *name, const char *ext)
* Return !=0 if extensions match.
*/

int FileName::equalsExt(const char *ext)
bool FileName::equalsExt(const char *ext)
{
return equalsExt(str, ext);
}

int FileName::equalsExt(const char *name, const char *ext)
bool FileName::equalsExt(const char *name, const char *ext)
{
const char *e = FileName::ext(name);
if (!e && !ext)
return 1;
return true;
if (!e || !ext)
return 0;
return false;
return FileName::compare(e, ext) == 0;
}

/*************************************
* Search Path for file.
* Input:
* cwd if !=0, search current directory before searching path
* cwd if true, search current directory before searching path
*/

const char *FileName::searchPath(Strings *path, const char *name, int cwd)
const char *FileName::searchPath(Strings *path, const char *name, bool cwd)
{
if (absolute(name))
{
Expand Down Expand Up @@ -489,7 +489,7 @@ const char *FileName::safeSearchPath(Strings *path, const char *name)
}
}

return FileName::searchPath(path, name, 0);
return FileName::searchPath(path, name, false);
#elif POSIX
/* Even with realpath(), we must check for // and disallow it
*/
Expand Down Expand Up @@ -571,7 +571,7 @@ int FileName::exists(const char *name)
#endif
}

int FileName::ensurePathExists(const char *path)
bool FileName::ensurePathExists(const char *path)
{
//printf("FileName::ensurePathExists(%s)\n", path ? path : "");
if (path && *path)
Expand All @@ -589,7 +589,7 @@ int FileName::ensurePathExists(const char *path)
return 0;
}
#endif
int r = ensurePathExists(p);
bool r = ensurePathExists(p);
mem.free((void *)p);
if (r)
return r;
Expand All @@ -614,12 +614,12 @@ int FileName::ensurePathExists(const char *path)
* this directory
*/
if (errno != EEXIST)
return 1;
return true;
}
}
}
}
return 0;
return false;
}

/******************************************
Expand Down
12 changes: 6 additions & 6 deletions src/root/filename.h
Expand Up @@ -26,10 +26,10 @@ struct FileName
const char *str;
FileName(const char *str);
bool equals(RootObject *obj);
static int equals(const char *name1, const char *name2);
static bool equals(const char *name1, const char *name2);
int compare(RootObject *obj);
static int compare(const char *name1, const char *name2);
static int absolute(const char *name);
static bool absolute(const char *name);
static const char *ext(const char *);
const char *ext();
static const char *removeExt(const char *str);
Expand All @@ -42,14 +42,14 @@ struct FileName
static Strings *splitPath(const char *path);
static const char *defaultExt(const char *name, const char *ext);
static const char *forceExt(const char *name, const char *ext);
static int equalsExt(const char *name, const char *ext);
static bool equalsExt(const char *name, const char *ext);

int equalsExt(const char *ext);
bool equalsExt(const char *ext);

static const char *searchPath(Strings *path, const char *name, int cwd);
static const char *searchPath(Strings *path, const char *name, bool cwd);
static const char *safeSearchPath(Strings *path, const char *name);
static int exists(const char *name);
static int ensurePathExists(const char *path);
static bool ensurePathExists(const char *path);
static const char *canonicalName(const char *name);

static void free(const char *str);
Expand Down
22 changes: 11 additions & 11 deletions src/template.c
Expand Up @@ -94,7 +94,7 @@ Parameter *isParameter(RootObject *o)
/**************************************
* Is this Object an error?
*/
int isError(RootObject *o)
bool isError(RootObject *o)
{
Type *t = isType(o);
if (t)
Expand All @@ -108,22 +108,22 @@ int isError(RootObject *o)
Dsymbol *s = isDsymbol(o);
assert(s);
if (s->errors)
return 1;
return s->parent ? isError(s->parent) : 0;
return true;
return s->parent ? isError(s->parent) : false;
}

/**************************************
* Are any of the Objects an error?
*/
int arrayObjectIsError(Objects *args)
bool arrayObjectIsError(Objects *args)
{
for (size_t i = 0; i < args->dim; i++)
{
RootObject *o = (*args)[i];
if (isError(o))
return 1;
return true;
}
return 0;
return false;
}

/***********************
Expand Down Expand Up @@ -263,11 +263,11 @@ bool definitelyValueParameter(Expression *e)
}

/******************************
* If o1 matches o2, return 1.
* Else, return 0.
* If o1 matches o2, return true.
* Else, return false.
*/

int match(RootObject *o1, RootObject *o2)
bool match(RootObject *o1, RootObject *o2)
{
Type *t1 = isType(o1);
Type *t2 = isType(o2);
Expand Down Expand Up @@ -334,11 +334,11 @@ int match(RootObject *o1, RootObject *o2)
goto Lnomatch;
}
//printf("match\n");
return 1; // match
return true; // match

Lnomatch:
//printf("nomatch\n");
return 0; // nomatch;
return false; // nomatch;
}


Expand Down
4 changes: 2 additions & 2 deletions src/template.h
Expand Up @@ -392,8 +392,8 @@ Dsymbol *isDsymbol(RootObject *o);
Type *isType(RootObject *o);
Tuple *isTuple(RootObject *o);
Parameter *isParameter(RootObject *o);
int arrayObjectIsError(Objects *args);
int isError(RootObject *o);
bool arrayObjectIsError(Objects *args);
bool isError(RootObject *o);
Type *getType(RootObject *o);
Dsymbol *getDsymbol(RootObject *o);

Expand Down

0 comments on commit cb117bd

Please sign in to comment.