1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2024-11-21 16:23:20 +00:00

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

This commit is contained in:
Antoine Bartuccio 2017-05-15 16:27:44 +02:00
parent 9a6020d97c
commit 0a26964d62
2 changed files with 40 additions and 15 deletions

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>

View File

@ -48,31 +48,21 @@ int countSeparators(char *string, char *separators) {
} }
WordArray * split(char *string, char *separator){ WordArray * split(char *string, char *separator){
int array_size = countSeparators(string, separator) + 1; WordList *list = createWordList();
WordArray *tokens = (WordArray*) malloc(sizeof(WordArray));
char *to_delete = strdup(string); char *to_delete = strdup(string);
char *to_delete_bak = to_delete; char *to_delete_bak = to_delete;
char *token = NULL; char *token = NULL;
int i = 0;
if (tokens != NULL){ if (to_delete == 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){
crash(); crash();
} }
while((token = strsep(&to_delete, separator)) != NULL){ while((token = strsep(&to_delete, separator)) != NULL)
tokens->words[i] = strdup(token); addWordList(list, token);
i++;
}
free(to_delete_bak); free(to_delete_bak);
return tokens; return wordListToWordArray(list);
} }
char *fishReadLine() { char *fishReadLine() {