Handle empty values for the directory
This is considered to mean the current directory. As an intended side-effect, the output in verbose mode is slightly nicer.
This commit is contained in:
parent
4190e6dfd4
commit
92a5a95ebc
@ -464,8 +464,11 @@ static int _project_load(ConfigurePrefs * prefs, String const * directory,
|
|||||||
String * path;
|
String * path;
|
||||||
String const * subdirs = NULL;
|
String const * subdirs = NULL;
|
||||||
|
|
||||||
if((path = string_new_append(directory, "/", PROJECT_CONF, NULL))
|
if(directory == NULL || string_length(directory) == 0)
|
||||||
== NULL)
|
path = string_new_append(PROJECT_CONF, NULL);
|
||||||
|
else
|
||||||
|
path = string_new_append(directory, "/", PROJECT_CONF, NULL);
|
||||||
|
if(path == NULL)
|
||||||
return configure_error(1, "%s", error_get(NULL));
|
return configure_error(1, "%s", error_get(NULL));
|
||||||
if((config = config_new()) == NULL)
|
if((config = config_new()) == NULL)
|
||||||
{
|
{
|
||||||
@ -523,10 +526,15 @@ static int _project_load_subdirs_subdir(ConfigurePrefs * prefs,
|
|||||||
int ret;
|
int ret;
|
||||||
String * p;
|
String * p;
|
||||||
|
|
||||||
if((p = string_new_append(directory, "/", subdir, NULL)) == NULL)
|
if(directory == NULL || string_length(directory) == 0)
|
||||||
return error_print(PROGNAME);
|
ret = _project_load(prefs, subdir, ca);
|
||||||
|
else if((p = string_new_append(directory, "/", subdir, NULL)) == NULL)
|
||||||
|
ret = error_print(PROGNAME);
|
||||||
|
else
|
||||||
|
{
|
||||||
ret = _project_load(prefs, p, ca);
|
ret = _project_load(prefs, p, ca);
|
||||||
string_delete(p);
|
string_delete(p);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ int main(int argc, char * argv[])
|
|||||||
ret = configure_error(2, "%s", error_get(NULL));
|
ret = configure_error(2, "%s", error_get(NULL));
|
||||||
else if(optind == argc)
|
else if(optind == argc)
|
||||||
{
|
{
|
||||||
if((ret = configure_project(configure, ".")) != 0)
|
if((ret = configure_project(configure, NULL)) != 0)
|
||||||
configure_error(2, "%s", error_get(NULL));
|
configure_error(2, "%s", error_get(NULL));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -103,8 +103,11 @@ int makefile(Configure * configure, String const * directory, configArray * ca,
|
|||||||
String * filename;
|
String * filename;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if((filename = string_new_append(directory, "/", MAKEFILE, NULL))
|
if(directory == NULL || string_length(directory) == 0)
|
||||||
== NULL)
|
filename = string_new(MAKEFILE);
|
||||||
|
else
|
||||||
|
filename = string_new_append(directory, "/", MAKEFILE, NULL);
|
||||||
|
if(filename == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
makefile.configure = configure;
|
makefile.configure = configure;
|
||||||
makefile.fp = NULL;
|
makefile.fp = NULL;
|
||||||
@ -114,8 +117,7 @@ int makefile(Configure * configure, String const * directory, configArray * ca,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(_makefile_is_flag_set(&makefile, PREFS_v))
|
if(_makefile_is_flag_set(&makefile, PREFS_v))
|
||||||
printf("%s%s/%s", "Creating ", directory,
|
printf("%s%s\n", "Creating ", filename);
|
||||||
MAKEFILE "\n");
|
|
||||||
ret |= _makefile_write(&makefile, ca, from, to);
|
ret |= _makefile_write(&makefile, ca, from, to);
|
||||||
if(makefile.fp != NULL)
|
if(makefile.fp != NULL)
|
||||||
fclose(makefile.fp);
|
fclose(makefile.fp);
|
||||||
|
@ -111,17 +111,20 @@ static int _settings_do(Configure * configure, String const * directory,
|
|||||||
}
|
}
|
||||||
if(configure_is_flag_set(configure, PREFS_n))
|
if(configure_is_flag_set(configure, PREFS_n))
|
||||||
return 0;
|
return 0;
|
||||||
if((filename = string_new_append(directory, "/config.", extension,
|
if(directory == NULL || string_length(directory) == 0)
|
||||||
NULL)) == NULL)
|
filename = string_new_append("config.", extension, NULL);
|
||||||
|
else
|
||||||
|
filename = string_new_append(directory, "/config.", extension,
|
||||||
|
NULL);
|
||||||
|
if(filename == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
if(configure_is_flag_set(configure, PREFS_v))
|
||||||
|
printf("%s%s\n", "Creating ", filename);
|
||||||
if((fp = fopen(filename, "w")) == NULL)
|
if((fp = fopen(filename, "w")) == NULL)
|
||||||
configure_error(0, "%s: %s", filename, strerror(errno));
|
configure_error(0, "%s: %s", filename, strerror(errno));
|
||||||
string_delete(filename);
|
string_delete(filename);
|
||||||
if(fp == NULL)
|
if(fp == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
if(configure_is_flag_set(configure, PREFS_v))
|
|
||||||
printf("%s%s/%s%s\n", "Creating ", directory, "config.",
|
|
||||||
extension);
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case ST_H:
|
case ST_H:
|
||||||
|
Loading…
Reference in New Issue
Block a user