1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2024-12-22 07:41:08 +00:00

Victime boloss

This commit is contained in:
Antoine Bartuccio 2017-05-29 19:09:19 +02:00
parent d85f4db5cc
commit 9b3938894d
4 changed files with 14 additions and 8 deletions

View File

@ -28,7 +28,9 @@ Settings *getSettings() {
filename = strcat(filename, (char*) FISH_RC_FILE);
s->passwd = user;
s->PS1 = extractVariable(filename, (char*) "PS1");
if (s->PS1 == NULL) s->PS1 = strdup("->");
s->PS2 = extractVariable(filename, (char*) "PS2");
if (s->PS2 == NULL) s->PS2 = strdup("->");
free(filename);
return s;
@ -36,6 +38,8 @@ Settings *getSettings() {
void freeSettings(Settings *settings){
if (settings != NULL){
settings->PS1[0] = '\0';
settings->PS2[0] = '\0';
free(settings->PS1);
free(settings->PS2);
free(settings);
@ -73,7 +77,7 @@ char* extractVariable(char* filename, char* var){
else {
perror ( filename ); /* why didn't the file open? */
}
return NULL;
return tmp;
}

View File

@ -10,4 +10,5 @@ Settings * getSettings(); //TESTEDssssss
void freeSettings(Settings *settings); //TESTED
char* extractVariable(char* filename, char* var);//TESTED
#endif //FISH_FISH_SETTINGS_H
#endif //FISH_FISH_SETTINGS_H

View File

@ -3,14 +3,13 @@
#include "../fish_shell/fish_settings.h"
TEST(free_settings_Test, freeSettings){
Settings *s1 = getSettings();
Settings *s2 = getSettings();
Settings *s = getSettings();
freeSettings(s1);
ASSERT_STREQ(s->PS1, "->");
ASSERT_STRNE(s1->PS1, s2->PS1);
freeSettings(s);
freeSettings(s2);
ASSERT_STRNE(s->PS1, "->");
}
TEST(extract_variable_Test, extractVariable){
@ -25,4 +24,4 @@ TEST(get_settings_Test, getSettings){
ASSERT_FALSE(s ==NULL);
ASSERT_FALSE(s->passwd == NULL);
freeSettings(s);
}
}

2
fish_shell_tests/fishrc Normal file
View File

@ -0,0 +1,2 @@
PS1=sli->
PS2=sony