Browse Source

Début d'un refactor avec des listes chaînées

merge-requests/2/head
Antoine Bartuccio 2 years ago
parent
commit
0a26964d62
2 changed files with 40 additions and 15 deletions
  1. 35
    0
      .idea/codeStyleSettings.xml
  2. 5
    15
      fish_shell/fish_core.c

+ 35
- 0
.idea/codeStyleSettings.xml View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" />
<pair source="c" header="h" />
</extensions>
</Objective-C-extensions>
</value>
</option>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</component>
</project>

+ 5
- 15
fish_shell/fish_core.c View File

@@ -48,31 +48,21 @@ int countSeparators(char *string, char *separators) {
}

WordArray * split(char *string, char *separator){
int array_size = countSeparators(string, separator) + 1;
WordArray *tokens = (WordArray*) malloc(sizeof(WordArray));
WordList *list = createWordList();
char *to_delete = strdup(string);
char *to_delete_bak = to_delete;
char *token = NULL;
int i = 0;

if (tokens != NULL){
tokens->words = (char **) malloc(sizeof(char*) * (array_size + 1));
tokens->words[array_size] = NULL;
tokens->size = array_size;
}

if (tokens == NULL || to_delete == NULL || tokens->words == NULL){
if (to_delete == NULL){
crash();
}

while((token = strsep(&to_delete, separator)) != NULL){
tokens->words[i] = strdup(token);
i++;
}
while((token = strsep(&to_delete, separator)) != NULL)
addWordList(list, token);

free(to_delete_bak);

return tokens;
return wordListToWordArray(list);
}

char *fishReadLine() {

Loading…
Cancel
Save