mirror of
https://gitlab.com/klmp200/fish.git
synced 2024-12-21 23:31:10 +00:00
Début d'un refactor avec des listes chaînées
This commit is contained in:
parent
9a6020d97c
commit
0a26964d62
35
.idea/codeStyleSettings.xml
generated
Normal file
35
.idea/codeStyleSettings.xml
generated
Normal 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>
|
@ -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…
Reference in New Issue
Block a user