X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e4a82dfad76e5fe783001540d8a7fb0e34078775..ceb7a8d8e39fbd7f0e87d3c8da4528c2de0fc59e:/src/xbt/xbt_str.c diff --git a/src/xbt/xbt_str.c b/src/xbt/xbt_str.c index dfe4f28d96..2ca23ab4ad 100644 --- a/src/xbt/xbt_str.c +++ b/src/xbt/xbt_str.c @@ -350,6 +350,7 @@ XBT_TEST_UNIT("xbt_str_split_quoted",test_split_quoted, "test the function xbt_s xbt_dynar_t d; char *s; + mytest("Empty", "", ""); mytest("Basic test", "toto tutu", "totoXXXtutu"); mytest("Useless backslashes", "\\t\\o\\t\\o \\t\\u\\t\\u", "totoXXXtutu"); mytest("Protected space", "toto\\ tutu", "toto tutu"); @@ -372,6 +373,10 @@ char *xbt_str_join(xbt_dynar_t dyn, const char*sep) { int cpt; char *cursor; char *res,*p; + + if (!dyn_len) + return xbt_strdup(""); + /* compute the length */ xbt_dynar_foreach(dyn,cpt,cursor) { len+=strlen(cursor); @@ -448,6 +453,7 @@ static xbt_matrix_t diff_build_LCS(xbt_dynar_t da, xbt_dynar_t db) { xbt_matrix_t C = xbt_matrix_new(xbt_dynar_length(da),xbt_dynar_length(db), sizeof(int),NULL); int i,j; + /* Compute the LCS */ /* C = array(0..m, 0..n) @@ -463,11 +469,13 @@ static xbt_matrix_t diff_build_LCS(xbt_dynar_t da, xbt_dynar_t db) { C[i,j] := max(C[i,j-1], C[i-1,j]) return C[m,n] */ - for (i=0; i=0 && - (i<=0 || xbt_matrix_get_as(C,i,j-1,int) >= xbt_matrix_get_as(C,i-1,j,int))) { + (i<=0 ||j==0|| xbt_matrix_get_as(C,i,j-1,int) >= xbt_matrix_get_as(C,i-1,j,int))) { diff_build_diff(res,C,da,db,i,j-1); topush = bprintf("+ %s",xbt_dynar_get_as(db,j,char*)); xbt_dynar_push(res,&topush);