Skip to content

Commit 7c678b8

Browse files
committed
fixed variable parsing
1 parent 3a9d846 commit 7c678b8

File tree

2 files changed

+35
-36
lines changed

2 files changed

+35
-36
lines changed

src/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int readConfig(const char* configFilePath, int overwrite)
8080
line[strlen(line) - 1] = 0;
8181
parse_env(&line);
8282

83-
if((line[0] != '#' || (line[0] != '/' && line[1] != '/')) && strstr(line, "=") != 0)
83+
if(((line[0] != '#') && ((line[0] != '/') && (line[1] != '/'))) && (strstr(line, "=") != 0))
8484
{
8585
char* key = strtok(line, "=");
8686
char* value = strchr(line, '\0') + 1;

src/install.c

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,36 @@ int f_install_package_source(const char* spm_path, int as_dep, char* repo) {
7575
QUEUE_COUNT++;
7676
dbg(1, "Added %s to the queue", pkg.name);
7777

78+
// Set the package info section as environment vadiables for make script
79+
setenv("NAME", pkg.name, 1);
80+
setenv("VERSION", pkg.version, 1);
7881

79-
// Get global environment variables
82+
if (pkg.url != NULL)
83+
{
84+
parse_env(&(pkg.url));
85+
dbg(1, "URL: %s", pkg.url);
86+
setenv("URL", pkg.url, 1);
87+
}
88+
89+
if (pkg.type != NULL)
90+
{
91+
setenv("TYPE", pkg.type, 1);
92+
}
8093

94+
if (pkg.license != NULL)
95+
{
96+
setenv("LICENSE", pkg.license, 1);
97+
}
98+
99+
if (pkg.sha256 != NULL)
100+
{
101+
setenv("SHA256", pkg.sha256, 1);
102+
}
103+
104+
// Set environment variables for building
105+
setenv("BUILD_ROOT", build_dir, 1);
106+
107+
// Get global environment variables
81108
if (pkg.environment != NULL)
82109
{
83110
dbg(1, "Getting environment variables...");
@@ -88,7 +115,6 @@ int f_install_package_source(const char* spm_path, int as_dep, char* repo) {
88115
}
89116

90117
// Set global environment variables
91-
92118
if (pkg.exports != NULL && pkg.exportsCount > 0 && strlen(pkg.exports[0]) > 0)
93119
{
94120
dbg(1, "Setting environment variables...");
@@ -101,11 +127,13 @@ int f_install_package_source(const char* spm_path, int as_dep, char* repo) {
101127
for (int i = 0; i < pkg.exportsCount; i++)
102128
{
103129
fprintf(env_file, "%s\n", pkg.exports[i]);
130+
char* line = strdup(pkg.exports[i]);
131+
parse_env(&line);
104132

105-
if((pkg.exports[i][0] != '#' || (pkg.exports[i][0] != '/' && pkg.exports[i][1] != '/')) && strstr(pkg.exports[i], "=") != 0)
133+
if(((line[0] != '#') && ((line[0] != '/') && (line[1] != '/'))) && (strstr(line, "=") != 0))
106134
{
107-
char* key = strtok(pkg.exports[i], "=");
108-
char* value = strchr(pkg.exports[i], '\0') + 1;
135+
char* key = strtok(line, "=");
136+
char* value = strchr(line, '\0') + 1;
109137

110138
if (key == NULL || value == NULL)
111139
{
@@ -117,41 +145,12 @@ int f_install_package_source(const char* spm_path, int as_dep, char* repo) {
117145
// Set environment variables based on the key-value pairs in the config file
118146
setenv(key, value, 1);
119147
}
148+
free(line);
120149
}
121150

122151
fclose(env_file);
123152
}
124153

125-
// Set the package info section as environment vadiables for make script
126-
127-
setenv("NAME", pkg.name, 1);
128-
setenv("VERSION", pkg.version, 1);
129-
130-
if (pkg.url != NULL)
131-
{
132-
parse_env(&(pkg.url));
133-
dbg(1, "URL: %s", pkg.url);
134-
setenv("URL", pkg.url, 1);
135-
}
136-
137-
if (pkg.type != NULL)
138-
{
139-
setenv("TYPE", pkg.type, 1);
140-
}
141-
142-
if (pkg.license != NULL)
143-
{
144-
setenv("LICENSE", pkg.license, 1);
145-
}
146-
147-
if (pkg.sha256 != NULL)
148-
{
149-
setenv("SHA256", pkg.sha256, 1);
150-
}
151-
152-
// Set environment variables for building
153-
setenv("BUILD_ROOT", build_dir, 1);
154-
155154

156155
// Check if a package is a collection
157156
if(strcmp(pkg.type, "con") != 0)

0 commit comments

Comments
 (0)