Commit d526a349 authored by Vesa Oikonen's avatar Vesa Oikonen
Browse files

csvWrite() interface changed

parent 6c113b5a
......@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Error: cannot open file for writing.\n");
csvFree(&csv); return(11);
}
int ret=csvWrite(&csv, fp, &status);
int ret=csvWrite(&csv, 0, fp, &status);
fclose(fp); csvFree(&csv);
if(ret!=TPCERROR_OK) {
fprintf(stderr, "Error: %s\n", errorMsg(status.error));
......
......@@ -248,9 +248,12 @@ int csvRowLength(
int row
) {
if(csv==NULL) return(0);
int i, n=0;
for(i=0; i<csv->nr; i++) if(csv->c[i].row==row) n++;
return(n);
// int i, n=0;
// for(i=0; i<csv->nr; i++) if(csv->c[i].row==row) n++;
// return(n);
int n=-1;
for(int i=0; i<csv->nr; i++) if(csv->c[i].row==row && csv->c[i].col>n) n=csv->c[i].col;
return(1+n);
}
/*****************************************************************************/
......@@ -307,7 +310,7 @@ int csvIsRegular(
/*****************************************************************************/
/*****************************************************************************/
/** Remove empty cells from the right side of CVS table until non-empty column is reached.
/** Remove empty cells from the right side of CVS table until a non-empty column is reached.
Resulting CSV may still not be regular.
......
......@@ -15,17 +15,20 @@
/*****************************************************************************/
/*****************************************************************************/
/** Write CSV data into file opened for writing, using the column separator
specified inside CSV structure.
/** Write CSV data into file opened for writing, using the column separator specified inside CSV structure.
Field contents are written as they are, that is, no conversions for decimal separator is done here.
@return enum tpcerror (TPCERROR_OK when successful).
@author Vesa Oikonen
@sa csvRead, csvMakeRegular
@sa csvRead, csvSetDimensions, csvMakeRegular
*/
int csvWrite(
/** Pointer to CSV structure, contents of which are to be written. */
CSV *csv,
/** Forced regularization (1), or not (0);
if regularized, then row_nr rows are written, each with col_nr columns;
otherwise, empty rows are not written, and missing cells are not written to the end of rows. */
int regular,
/** Output file pointer. */
FILE *fp,
/** Pointer to status data; enter NULL if not needed. */
......@@ -40,14 +43,13 @@ int csvWrite(
statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_DATA);
return TPCERROR_NO_DATA;
}
if(csv->separator!=',' && csv->separator!=';' && csv->separator!='\t'
&& csv->separator!=' ')
{
if(csv->separator!=',' && csv->separator!=';' && csv->separator!='\t' && csv->separator!=' ') {
statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_SEPARATOR);
return TPCERROR_INVALID_SEPARATOR;
}
if(verbose>10) {
printf("%s():\n", __func__);
printf("regular := %d\n", regular);
printf("csv_nr := %d\n", csv->nr);
printf("csv_row_nr := %d\n", csv->row_nr);
printf("csv_col_nr := %d\n", csv->col_nr);
......@@ -57,15 +59,18 @@ int csvWrite(
}
/* Write in file */
int i, row, n=0;
row=0;
for(i=0; i<csv->nr; i++) {
if(csv->c[i].row>row) {row=csv->c[i].row; if(i>0) n+=fprintf(fp, "\n");}
else if(csv->c[i].col>0) n+=fprintf(fp, "%c", csv->separator);
if(csv->c[i].content!=NULL) n+=fprintf(fp, "%s", csv->c[i].content);
int wn=0;
for(int ri=0; ri<csv->row_nr; ri++) {
int n=csv->col_nr;
if(regular==0) {n=csvRowLength(csv, ri); if(n==0) continue;}
for(int ci=0; ci<n; ci++) {
if(ci>0) wn+=fprintf(fp, "%c", csv->separator);
char *cptr=csvCell(csv, ri, ci);
if(cptr!=NULL) wn+=fprintf(fp, "%s", cptr);
}
wn+=fprintf(fp, "\n");
}
n+=fprintf(fp, "\n");
if(n<1) {
if(wn<1) {
statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_CANNOT_WRITE);
return TPCERROR_CANNOT_WRITE;
}
......@@ -78,6 +83,7 @@ int csvWrite(
/*****************************************************************************/
/** Read CSV file contents into CSV structure, allocating memory as needed.
Lines consisting only of space characters, including tabs, are not read.
Partial support for spaces as delimiters.
@return enum tpcerror (TPCERROR_OK when successful).
......@@ -166,14 +172,12 @@ int csvRead(
// Spaces exist, so is space or comma the field separator ?
if(com_nr==0) {
// No commas, thus space is probably field separator
csv->separator=' ';
csv->separator=' ';
} else if(dot_nr>0) {
// Dots and commas exist, probably decimal point, and comma as field
// separator
// Dots and commas exist, probably decimal point, and comma as field separator
csv->separator=',';
} else {
// No dots, but commas and spaces; lets assume that the more frequent
// one is the field separator
// No dots, but commas and spaces; lets assume that the more frequent one is the field separator
if(com_nr>spa_nr) csv->separator=','; else csv->separator=' ';
}
}
......@@ -193,8 +197,7 @@ int csvRead(
/* Write contents into CSV as a new data row */
if(csv->separator!=' ') ret=csvPutLine(csv, line, status);
else ret=csvPutLineWithSpaces(csv, line, status);
if(verbose>1 && ret!=0)
fprintf(stderr, "Warning: cannot read line %d: '%s'.\n", i, line);
if(verbose>1 && ret!=0) fprintf(stderr, "Warning: cannot read line %d: '%s'.\n", i, line);
/* Prepare for the next line */
free(line); cptr+=j; i++;
}
......@@ -211,9 +214,9 @@ int csvRead(
/*****************************************************************************/
/** Process a given text line (string) to add a new row of fields to CSV,
using as field delimiter the character specified in CSV struct.
using as field delimiter the character specified in CSV structure.
@return tpcerror (TPCERROR_OK when successful).
@pre Before first use initialize the CSV struct with csvInit().
@pre Before first use initialize the CSV structure with csvInit().
@post Remember to free the memory in CSV after last use with csvFree().
@author Vesa Oikonen
@sa csvInit, csvFree, csvWrite, csvPutString, csvPutInt, csvPutLineWithSpaces
......
......@@ -117,9 +117,9 @@ int test_csvDuplicate(
v=3.0E-03; csvPutDouble(&csv1, v, 0, 0);
if(verbose>2) {printf("\n duplicate \n"); fflush(stdout);}
if(verbose>3) csvWrite(&csv1, stdout, NULL);
if(verbose>3) csvWrite(&csv1, 1, stdout, NULL);
if(csvDuplicate(&csv1, &csv2)!=TPCERROR_OK) {csvFree(&csv1); csvFree(&csv2); return(101);}
if(verbose>3) csvWrite(&csv2, stdout, NULL);
if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(verbose>2) {printf("\n check results \n"); fflush(stdout);}
if(csv2.col_nr!=4 || csv2.row_nr!=2) {csvFree(&csv1); csvFree(&csv2); return(102);}
if(csv2.nr!=8) {csvFree(&csv1); csvFree(&csv2); return(103);}
......@@ -374,13 +374,13 @@ int test_csvSetDimensions(
i=2; csv.c[i].row=3; csv.c[i].col=3; csv.c[i].content=strdup("cell44");
i=3; csv.c[i].row=3; csv.c[i].col=4; csv.c[i].content=strdup("cell45");
csv.nr=1+i;
if(verbose>3) csvWrite(&csv, stdout, NULL);
if(verbose>3) csvWrite(&csv, 1, stdout, NULL);
if(csvSetDimensions(&csv)!=TPCERROR_OK) return(101);
if(csv.col_nr!=5 || csv.row_nr!=4) return(102);
i=4; csv.c[i].row=4; csv.c[i].col=5; csv.c[i].content=strdup("cell56");
csv.nr=1+i;
if(verbose>3) csvWrite(&csv, stdout, NULL);
if(verbose>3) csvWrite(&csv, 1, stdout, NULL);
if(csvSetDimensions(&csv)!=TPCERROR_OK) return(111);
if(csv.col_nr!=6 || csv.row_nr!=5) return(112);
......@@ -531,10 +531,10 @@ int test_csvMakeRegular(
csvPutString(&csv, "r4c1", 1);
csvPutString(&csv, "r4c2", 0);
csvPutString(&csv, "# r4c2", 0);
if(verbose>3) csvWrite(&csv, stdout, NULL);
if(verbose>3) csvWrite(&csv, 1, stdout, NULL);
if(csvIsRegular(&csv)) {csvFree(&csv); return(100);}
if(csvMakeRegular(&csv)!=TPCERROR_OK) {csvFree(&csv); return(101);}
if(verbose>3) {printf("\n-->\n"); csvWrite(&csv, stdout, NULL);}
if(verbose>3) {printf("\n-->\n"); csvWrite(&csv, 1, stdout, NULL);}
if(!csvIsRegular(&csv)) {csvFree(&csv); return(102);}
if(verbose>1) printf(" ok\n");
......@@ -764,15 +764,15 @@ int test_csvRemoveEmptyRows(
i=2; csv.c[i].row=3; csv.c[i].col=3; csv.c[i].content=strdup("cell44");
i=3; csv.c[i].row=3; csv.c[i].col=4; csv.c[i].content=strdup("cell45");
csv.nr=1+i;
if(verbose>3) csvWrite(&csv, stdout, NULL);
if(verbose>3) csvWrite(&csv, 1, stdout, NULL);
CSV csv2; csvInit(&csv2);
if(verbose>1) printf("\n data with empty rows \n");
csvDuplicate(&csv, &csv2); if(verbose>3) csvWrite(&csv2, stdout, NULL);
csvDuplicate(&csv, &csv2); if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(csvRemoveEmptyRows(&csv2)!=TPCERROR_OK) {csvFree(&csv); csvFree(&csv2); return(101);}
if(verbose>1) printf(" ok\n");
if(verbose>3) csvWrite(&csv2, stdout, NULL);
if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(csv2.row_nr!=2 && csv2.col_nr!=csv.col_nr) {csvFree(&csv); csvFree(&csv2); return(102);}
if(strcmp(csvCell(&csv, 2, 3), csvCell(&csv2, 0, 3))) {csvFree(&csv); csvFree(&csv2); return(110);}
if(strcmp(csvCell(&csv, 3, 4), csvCell(&csv2, 1, 4))) {csvFree(&csv); csvFree(&csv2); return(111);}
......@@ -781,10 +781,10 @@ int test_csvRemoveEmptyRows(
if(verbose>1) printf("\n data with comment \n");
i=csv.nr; csv.c[i].row=1; csv.c[i].col=5; csv.c[i].content=strdup("# cell26");
csv.nr=1+i;
csvDuplicate(&csv, &csv2); if(verbose>3) csvWrite(&csv2, stdout, NULL);
csvDuplicate(&csv, &csv2); if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(csvRemoveEmptyRows(&csv2)!=TPCERROR_OK) {csvFree(&csv); csvFree(&csv2); return(201);}
if(verbose>1) printf(" ok\n");
if(verbose>3) csvWrite(&csv2, stdout, NULL);
if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(csv2.row_nr!=2 && csv2.col_nr!=csv.col_nr) {csvFree(&csv); csvFree(&csv2); return(202);}
if(strcmp(csvCell(&csv, 2, 3), csvCell(&csv2, 0, 3))) {csvFree(&csv); csvFree(&csv2); return(210);}
if(strcmp(csvCell(&csv, 3, 4), csvCell(&csv2, 1, 4))) {csvFree(&csv); csvFree(&csv2); return(211);}
......@@ -825,25 +825,26 @@ int test_csvRemoveComments(
i=2; csv.c[i].row=3; csv.c[i].col=3; csv.c[i].content=strdup("cell44");
i=3; csv.c[i].row=3; csv.c[i].col=4; csv.c[i].content=strdup("cell45");
csv.nr=1+i;
if(verbose>3) csvWrite(&csv, stdout, NULL);
if(verbose>3) csvWrite(&csv, 1, stdout, NULL);
CSV csv2; csvInit(&csv2);
if(csvDuplicate(&csv, &csv2)!=TPCERROR_OK) {csvFree(&csv); csvFree(&csv2); return(110);}
if(verbose>3) csvWrite(&csv2, stdout, NULL);
if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(verbose>1) printf("\nTest with data containing no comments\n");
if(csvRemoveComments(&csv2)!=TPCERROR_OK) {csvFree(&csv); csvFree(&csv2); return(111);}
if(verbose>4) csvWrite(&csv2, stdout, NULL);
if(verbose>4) csvWrite(&csv2, 1, stdout, NULL);
if(csv.nr!=4) {csvFree(&csv); csvFree(&csv2); return(112);}
if(verbose>1) printf(" ok\n");
if(verbose>1) printf("\nTest with data containing empty cells and no comments\n");
if(csvCellReplace(&csv2, 2, 3, "#cell34")!=TPCERROR_OK) {csvFree(&csv); csvFree(&csv2); return(120);}
if(csvCellReplace(&csv2, 3, 3, "")!=TPCERROR_OK) {csvFree(&csv); csvFree(&csv2); return(121);}
if(verbose>3) csvWrite(&csv2, stdout, NULL);
int cnr=csv2.nr;
if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(csvRemoveComments(&csv2)!=TPCERROR_OK) {csvFree(&csv); csvFree(&csv2); return(123);}
if(verbose>3) csvWrite(&csv2, stdout, NULL);
if(csv.nr!=3) {csvFree(&csv); csvFree(&csv2); return(124);}
if(verbose>3) csvWrite(&csv2, 1, stdout, NULL);
if(csv2.nr!=cnr-1) {csvFree(&csv); csvFree(&csv2); return(124);}
if(verbose>1) printf(" ok\n");
csvFree(&csv); csvFree(&csv2);
......
......@@ -101,7 +101,7 @@ int test_csvSearchField(
csvPutString(&csv, "sama", 1);
csvPutString(&csv, "sama", 0);
csvPutString(&csv, "sama", 0);
if(verbose>3) csvWrite(&csv, stdout, NULL);
if(verbose>3) csvWrite(&csv, 0, stdout, NULL);
if(verbose>1) printf("testing with filled input\n");
i=csvSearchField(&csv, NULL, 0); if(i>=0) {csvFree(&csv); return 11;}
......
......@@ -14,13 +14,18 @@ int test_csvWrite(
printf("\n%s\n", __func__);
printf("\n=====================================\n");
}
/* Mainly tested in test_csvRead() */
if(csvWrite(NULL, 0, NULL, NULL)==TPCERROR_OK) return(1);
int ret;
CSV csv;
FILE *fp=NULL;
char fname[]="test.tsv";
TPCSTATUS status;
csvInit(&csv); statusInit(&status);
csv.separator='\t';
ret=csvPutString(&csv, "C1R1", 0);
if(ret==TPCERROR_OK) ret=csvPutString(&csv, "C2R1", 0);
if(ret==TPCERROR_OK) ret=csvPutString(&csv, "C3R1", 0);
......@@ -33,13 +38,27 @@ int test_csvWrite(
if(ret==TPCERROR_OK) ret=csvPutString(&csv, "C2R3", 0);
if(ret==TPCERROR_OK) ret=csvPutString(&csv, "C3R3", 0);
if(ret==TPCERROR_OK) ret=csvPutString(&csv, "C4R3", 0);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 1;}
ret=csvWrite(&csv, fp, NULL);
if(ret==TPCERROR_OK) {csvFree(&csv); return 2;}
if(ret!=TPCERROR_OK) {csvFree(&csv); return 2;}
if(verbose>1) printf("\nwriting to fp==NULL\n");
ret=csvWrite(&csv, 0, fp, NULL);
if(ret==TPCERROR_OK) {csvFree(&csv); return 3;}
ret=csvWrite(&csv, stdout, NULL);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 3;}
if(verbose>1) {
if(verbose>1) printf("\nwriting to stdout\n");
ret=csvWrite(&csv, 1, stdout, NULL);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 10;}
}
if(verbose>1) printf("\nwriting test data\n");
fp=fopen(fname, "w"); if(fp==NULL) {csvFree(&csv); return 20;}
ret=csvWrite(&csv, 0, fp, NULL); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 21;}
if(verbose>1) printf("\nwriting test data\n");
fp=fopen(fname, "w"); if(fp==NULL) {csvFree(&csv); return 30;}
ret=csvWrite(&csv, 0, fp, NULL); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 31;}
csvFree(&csv);
return(0);
......@@ -91,7 +110,7 @@ int test_csvRead(
if(verbose>1) printf("writing test data\n");
fp=fopen(fname, "w"); if(fp==NULL) {csvFree(&csv1); return 2;}
fprintf(fp, "# Test CSV file\n");
ret=csvWrite(&csv1, fp, &status); fclose(fp);
ret=csvWrite(&csv1, 0, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); return 2;}
/* Read it into another CSV struct */
......@@ -99,9 +118,9 @@ int test_csvRead(
fp=fopen(fname, "r"); if(fp==NULL) {csvFree(&csv1); return 3;}
ret=csvRead(&csv2, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); csvFree(&csv2); return 3;}
if(verbose>3) ret=csvWrite(&csv2, stdout, NULL);
if(verbose>3) ret=csvWrite(&csv2, 0, stdout, NULL);
/* Compare CSV structs */
/* Compare CSV structures */
if(verbose>1) printf("comparing test data\n");
if(csv1.nr!=csv2.nr) {csvFree(&csv1); csvFree(&csv2); return 4;}
for(int i=0; i<csv1.nr; i++) {
......@@ -126,7 +145,7 @@ int test_csvRead(
if(verbose>1) printf("open file for writing test data\n");
fp=fopen(fname2, "w"); if(fp==NULL) {csvFree(&csv1); return 12;}
if(verbose>1) printf("writing test data\n");
ret=csvWrite(&csv1, fp, &status); fclose(fp);
ret=csvWrite(&csv1, 0, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); return 12;}
/* Read it into another CSV struct */
......@@ -134,9 +153,9 @@ int test_csvRead(
fp=fopen(fname2, "r"); if(fp==NULL) {csvFree(&csv1); return 13;}
ret=csvRead(&csv2, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); csvFree(&csv2); return 13;}
if(verbose>3) ret=csvWrite(&csv2, stdout, NULL);
if(verbose>3) ret=csvWrite(&csv2, 0, stdout, NULL);
/* Compare CSV structs */
/* Compare CSV structures */
if(verbose>1) printf("comparing test data\n");
//printf("%d vs %d\n", csv1.nr, csv2.nr);
if(csv1.nr!=csv2.nr) {csvFree(&csv1); csvFree(&csv2); return 14;}
......@@ -149,8 +168,58 @@ int test_csvRead(
if(csv2.separator!=' ') {csvFree(&csv1); csvFree(&csv2); return 17;}
if(verbose>2) printf(" ->ok\n");
csvFree(&csv1); csvFree(&csv2); statusFree(&status);
csvFree(&csv1); csvFree(&csv2);
/*
* Regularized writing
*/
{
if(verbose>1) printf("\nTesting regularized writing\n");
char fname3[]="test3a.csv";
if(csvAllocate(&csv1, 30)!=TPCERROR_OK) return(100);
csv1.col_nr=5; csv1.row_nr=6;
csv1.separator=',';
int i;
i=0; csv1.c[i].row=1; csv1.c[i].col=0; csv1.c[i].content=strdup("cell21");
i=1; csv1.c[i].row=2; csv1.c[i].col=1; csv1.c[i].content=strdup("cell32");
i=2; csv1.c[i].row=3; csv1.c[i].col=2; csv1.c[i].content=strdup("cell43");
i=3; csv1.c[i].row=4; csv1.c[i].col=3; csv1.c[i].content=strdup("cell54");
csv1.nr=1+i;
if(verbose>1) printf("open file for writing test data\n");
fp=fopen(fname3, "w"); if(fp==NULL) {csvFree(&csv1); return(101);}
if(verbose>1) printf("writing test data\n");
ret=csvWrite(&csv1, 1, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); return(102);}
if(verbose>1) printf("reading test data\n");
fp=fopen(fname3, "r"); if(fp==NULL) {csvFree(&csv1); return(103);}
ret=csvRead(&csv2, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); csvFree(&csv2); return(104);}
if(verbose>3) ret=csvWrite(&csv2, 1, stdout, NULL);
if(csv2.nr!=30) {csvFree(&csv1); csvFree(&csv2); return(105);}
if(strcmp(csvCell(&csv1, 4, 3), csvCell(&csv2, 4, 3))) {csvFree(&csv1); csvFree(&csv2); return(106);}
if(verbose>2) printf(" ->ok\n");
csvFree(&csv2);
if(verbose>1) printf("\nTesting non-regularized writing with the same data\n");
char fname4[]="test3b.csv";
if(verbose>1) printf("open file for writing test data\n");
fp=fopen(fname4, "w"); if(fp==NULL) {csvFree(&csv1); return(111);}
if(verbose>1) printf("writing test data\n");
ret=csvWrite(&csv1, 0, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); return(112);}
if(verbose>1) printf("reading test data\n");
fp=fopen(fname4, "r"); if(fp==NULL) {csvFree(&csv1); return(113);}
ret=csvRead(&csv2, fp, &status); fclose(fp);
if(ret!=TPCERROR_OK) {csvFree(&csv1); csvFree(&csv2); return(114);}
if(verbose>3) ret=csvWrite(&csv2, 1, stdout, NULL);
if(csv2.nr!=10) {csvFree(&csv1); csvFree(&csv2); return(115);}
if(strcmp(csvCell(&csv1, 4, 3), csvCell(&csv2, 3, 3))) {csvFree(&csv1); csvFree(&csv2); return(116);}
if(verbose>2) printf(" ->ok\n");
csvFree(&csv1); csvFree(&csv2);
}
statusFree(&status);
return(0);
}
/*****************************************************************************/
......@@ -186,7 +255,7 @@ int test_csvPutLine(
csv.separator=',';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 2;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=3; if(csv.nr!=n) {csvFree(&csv); return 2;}
if(strcmp(csv.c[0].content, "one")!=0) {csvFree(&csv); return 2;}
if(strcmp(csv.c[1].content, "two")!=0) {csvFree(&csv); return 2;}
......@@ -198,7 +267,7 @@ int test_csvPutLine(
csv.separator=',';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 3;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=4; if(csv.nr!=n) {csvFree(&csv); return 3;}
if(strcmp(csv.c[0].content, "")!=0) {csvFree(&csv); return 3;}
if(strcmp(csv.c[1].content, "One")!=0) {csvFree(&csv); return 3;}
......@@ -211,7 +280,7 @@ int test_csvPutLine(
csv.separator=',';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 4;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=4; if(csv.nr!=n) {csvFree(&csv); return 4;}
if(strcmp(csv.c[0].content, "1")!=0) {csvFree(&csv); return 4;}
if(strcmp(csv.c[1].content, "2")!=0) {csvFree(&csv); return 4;}
......@@ -224,7 +293,7 @@ int test_csvPutLine(
csv.separator=',';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 5;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=5; if(csv.nr!=n) {csvFree(&csv); return 5;}
if(strcmp(csv.c[0].content, "")!=0) {csvFree(&csv); return 5;}
if(strcmp(csv.c[1].content, "a")!=0) {csvFree(&csv); return 5;}
......@@ -238,7 +307,7 @@ int test_csvPutLine(
csv.separator=';';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 6;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=2; if(csv.nr!=n) {csvFree(&csv); return 6;}
for(i=0; i<n; i++)
if(strcmp(csv.c[i].content, "")!=0) {csvFree(&csv); return 6;}
......@@ -249,7 +318,7 @@ int test_csvPutLine(
csv.separator=';';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 7;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=9; if(csv.nr!=n) {csvFree(&csv); return 7;}
for(i=0; i<n; i++)
if(strcmp(csv.c[i].content, "")!=0) {csvFree(&csv); return 7;}
......@@ -260,7 +329,7 @@ int test_csvPutLine(
csv.separator=';';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 11;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=1; if(csv.nr!=n) {csvFree(&csv); return 11;}
if(strcmp(csv.c[0].content, "\";;;;;;;;\"")!=0) {csvFree(&csv); return 11;}
csvFree(&csv);
......@@ -270,7 +339,7 @@ int test_csvPutLine(
csv.separator=';';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 12;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=1; if(csv.nr!=n) {csvFree(&csv); return 12;}
if(strcmp(csv.c[0].content, "'")!=0) {csvFree(&csv); return 12;}
csvFree(&csv);
......@@ -281,7 +350,7 @@ int test_csvPutLine(
csv.separator=',';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 13;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=4; if(csv.nr!=n) {csvFree(&csv); return 13;}
if(strcmp(csv.c[0].content, "\"Time[min]\"")!=0) {csvFree(&csv); return 13;}
if(strcmp(csv.c[1].content, "\"roi 1\"")!=0) {csvFree(&csv); return 13;}
......@@ -295,7 +364,7 @@ int test_csvPutLine(
csv.separator=';';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 14;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=6; if(csv.nr!=n) {csvFree(&csv); return 14;}
if(strcmp(csv.c[0].content, "")!=0) {csvFree(&csv); return 14;}
if(strcmp(csv.c[1].content, "\"Time[min]\"")!=0) {csvFree(&csv); return 14;}
......@@ -311,7 +380,7 @@ int test_csvPutLine(
csv.separator=',';
ret=csvPutLine(&csv, str, &status); if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 15;}
csv.separator=';'; if(verbose>2) csvWrite(&csv, stdout, &status);
csv.separator=';'; if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=6; if(csv.nr!=n) {csvFree(&csv); return 15;}
if(strcmp(csv.c[0].content, "")!=0) {csvFree(&csv); return 15;}
if(strcmp(csv.c[1].content, "1")!=0) {csvFree(&csv); return 15;}
......@@ -357,7 +426,7 @@ int test_csvPutLineWithSpaces(
ret=csvPutLineWithSpaces(&csv, str, &status);
if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 2;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=3; if(csv.nr!=n) {csvFree(&csv); return 2;}
if(strcmp(csv.c[0].content, "one")!=0) {csvFree(&csv); return 2;}
if(strcmp(csv.c[1].content, "two")!=0) {csvFree(&csv); return 2;}
......@@ -369,7 +438,7 @@ int test_csvPutLineWithSpaces(
ret=csvPutLineWithSpaces(&csv, str, &status);
if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 3;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=3; if(csv.nr!=n) {csvFree(&csv); return 3;}
if(strcmp(csv.c[0].content, "One")!=0) {csvFree(&csv); return 3;}
if(strcmp(csv.c[1].content, "Two")!=0) {csvFree(&csv); return 3;}
......@@ -381,7 +450,7 @@ int test_csvPutLineWithSpaces(
ret=csvPutLineWithSpaces(&csv, str, &status);
if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 4;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=3; if(csv.nr!=n) {csvFree(&csv); return 4;}
if(strcmp(csv.c[0].content, "1")!=0) {csvFree(&csv); return 4;}
if(strcmp(csv.c[1].content, "2")!=0) {csvFree(&csv); return 4;}
......@@ -393,7 +462,7 @@ int test_csvPutLineWithSpaces(
ret=csvPutLineWithSpaces(&csv, str, &status);
if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 5;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=3; if(csv.nr!=n) {csvFree(&csv); return 5;}
if(strcmp(csv.c[0].content, "a")!=0) {csvFree(&csv); return 5;}
if(strcmp(csv.c[1].content, "b")!=0) {csvFree(&csv); return 5;}
......@@ -405,7 +474,7 @@ int test_csvPutLineWithSpaces(
ret=csvPutLineWithSpaces(&csv, str, &status);
if(verbose>3) printf(" -> ret=%d\n", ret);
if(ret!=TPCERROR_OK) {csvFree(&csv); return 6;}
if(verbose>2) csvWrite(&csv, stdout, &status);
if(verbose>2) csvWrite(&csv, 0, stdout, &status);
n=0; if(csv.nr!=n) {csvFree(&csv); return 6;}
// for(i=0; i<n; i++)
// if(strcmp(csv.c[i].content, "")!=0) {csvFree(&csv); return 6;}
......@@ -415,67 +484,67 @@ int test_csvPutLineWithSpaces(