Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish UPDATE / HELP / SHOW actions + Normalize code #17

Merged
merged 4 commits into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sources/headers/manage_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "config.h"

void trimComma(char *string);
void trimSpaces(char *string);
void trimLeadingSpaces(char *string);
void trimTrailingSpaces(char *string);
Expand Down
2 changes: 1 addition & 1 deletion sources/headers/manage_row.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

StringArray* parseRow(char *row);
int addRows(const Database database, const Table table);
void updateRows(const Database database, const Table table, const int nbValues, const char **values, const int nbConditions, const Condition *conditions);
int updateRows(const Database database, const Table table, StringArray *values, const int nbConditions, const Condition *conditions);
int deleteRows(const Database database, const Table table, const int nbConditions, const Condition *conditions);

#endif
7 changes: 4 additions & 3 deletions sources/headers/read_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include "config.h"

void showDatabases(void);
Table findAllRecords(char* db_name, char* table_name);
StringArray readColumnsName(FILE* f);
StringArray readData(FILE* f);
void showTables(Database database);
Table findAllRecords(char *db_name, char *table_name);
StringArray readColumnsName(FILE *f);
StringArray readData(FILE *f);
int filesFound(char *db_name, char *table_name, char *table_file);

#endif
17 changes: 17 additions & 0 deletions sources/sources/manage_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@
static StringArray manageStringArray(StringArray array);
static IntArray manageIntArray(IntArray array);

//
// Trim a string : remove all comma
//
void trimComma(char *string)
{
char newString[STRING_SIZE] = "";

for (int i = 0; i < strlen(string); ++i) {
if (string[i] != ',') {
char charToString[] = {string[i], '\0'};
strcat(newString, charToString);
}
}

strcpy(string, newString);
}

//
// Trim a string : remove all spaces
//
Expand Down
Loading