Fixed CSV Parsing on tools
This commit is contained in:
@ -56,23 +56,22 @@ int main(int argc, char *argv[]) {
|
||||
size_t readSize = fread(buffer, 1, fileSize, file);
|
||||
fclose(file);
|
||||
if(readSize < fileSize) {
|
||||
free(buffer);
|
||||
printf("Failed to read all data from CSV\n");
|
||||
free(buffer);
|
||||
return 1;
|
||||
}
|
||||
buffer[fileSize] = '\0';
|
||||
|
||||
csvParse(buffer, &csv);
|
||||
free(buffer);
|
||||
printf("Parsed\n");
|
||||
|
||||
// Prepare output file for writing.
|
||||
sprintf(path, "%s.language", out);
|
||||
fileMkdirp(path);
|
||||
file = fopen(path, "wb");
|
||||
if(file == NULL) {
|
||||
csvDispose(&csv);
|
||||
printf("Failed to create output language file\n");
|
||||
csvDispose(&csv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -85,14 +84,13 @@ int main(int argc, char *argv[]) {
|
||||
csvDispose(&csv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
char *key = csvGetCell(&csv, y, 0);
|
||||
char *value = csvGetCell(&csv, y, 1);
|
||||
|
||||
// 23/01/14 - Replace \r in CSV.
|
||||
stringRemoveAll(key, '\r');
|
||||
stringRemoveAll(value, '\r');
|
||||
|
||||
if(strlen(key) <= 0 || strlen(value) <= 0) {
|
||||
printf("Failed to parse language. Line %i has an invalid string\n", y);
|
||||
fclose(file);
|
||||
|
Reference in New Issue
Block a user