Index: src/common/libmondo-filelist.c
===================================================================
--- src/common/libmondo-filelist.c	(révision 1120)
+++ src/common/libmondo-filelist.c	(copie de travail)
@@ -297,6 +297,7 @@
 					err++;
 					goto end_of_func;
 				}
+				assert(noof_lines != 0);
 				update_evalcall_form((int) (lino * 100 / noof_lines));
 			}
 		}
@@ -996,6 +997,7 @@
 			fprintf(fout, "%s\n", str);
 //      }
 			if (!(++lino % 1111)) {
+				assert(lines_in_filelist);
 				percentage = (int) (lino * 100 / lines_in_filelist);
 				update_evalcall_form(percentage);
 			}
@@ -1287,7 +1289,7 @@
  * @return 0, always.
  * @bug Return value should be @c void.
  */
-int open_and_list_dir(char *dir, char *sth, FILE * fout,
+int open_and_list_dir(char *dir, char *sth, FILE *fout,
 					  time_t time_of_last_full_backup)
 {
 	const char delims[] = " ";
@@ -1296,17 +1298,13 @@
 
 	struct stat statbuf;
 	char new[MAX_STR_LEN];
-	char *tmp = NULL;
-	char *sth_B = NULL;
 	static int percentage = 0;
-	char *ith_B = NULL;
-	char *skip_these = NULL;
 	char *new_with_spaces = NULL;
-	static char *name_of_evalcall_form = NULL;
-	int i = 0;
 	char *strtmp = NULL;
 	char *token = NULL;
 	char *find_excludes = NULL;
+	static char *name_of_evalcall_form = NULL;
+	int i;
 	int lastpos = 0;
 	static int depth = 0;
 	char *p = NULL;
@@ -1317,10 +1315,7 @@
 	static time_t last_time = 0;
 	time_t this_time;
 
-	malloc_string(tmp);
-	malloc_string(sth_B);
-	malloc_string(ith_B);
-	malloc_string(new_with_spaces);
+	//malloc_string(new_with_spaces);
 	p = strrchr(dir, '/');
 	if (p) {
 		if (!strcmp(p, "/.") || !strcmp(p, "/..")) {
@@ -1329,13 +1324,12 @@
 	}
 
 	if (!depth) {
-		malloc_string(name_of_evalcall_form);
 		malloc_string(find_skeleton_marker);
-		asprintf(&find_excludes, " ");
+		mr_asprintf(&find_excludes, " ");
 		while((token = mr_strtok (sth, delims, &lastpos))) {
-		  asprintf(&strtmp,"%s", find_excludes);
+		  mr_asprintf(&strtmp,"%s", find_excludes);
 		  mr_free(find_excludes);
-		  asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
+		  mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
 		  mr_free(strtmp);
 		  mr_free(token);
 		}
@@ -1354,10 +1348,11 @@
 		mr_msg(5, "find command = %s", strtmp);
 		system(strtmp);
 		mr_free(strtmp);
-		sprintf(tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
+		mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
 		g_skeleton_entries =
 			1 + atol(call_program_and_get_last_line_of_output(tmp));
-		sprintf(name_of_evalcall_form, "Making catalog of %s", dir);
+		mr_free(tmp);
+		mr_asprintf(&name_of_evalcall_form, "Making catalog of %s", dir);
 		open_evalcall_form(name_of_evalcall_form);
 		find_skeleton_marker[0] = '\0';
 		skeleton_lino = 1;
@@ -1370,12 +1365,13 @@
 				g_skeleton_filelist, g_skeleton_filelist);
 //    mr_msg(0, "fsm = %s", find_skeleton_marker);
 		if (!system(find_skeleton_marker)) {
+			assert(g_skeleton_entries);
 			percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
 			skeleton_lino++;
 //        mr_msg(5, "Found %s", dir);
 //        mr_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
-			sprintf(find_skeleton_marker, "mv -f %s.new %s",
-					g_skeleton_filelist, g_skeleton_filelist);
+			mr_asprintf(find_skeleton_marker, "mv -f %s.new %s",
+						g_skeleton_filelist, g_skeleton_filelist);
 //        mr_msg(6, "fsm = %s", find_skeleton_marker);
 			run_program_and_log_output(find_skeleton_marker, 8);
 			time(&this_time);
@@ -1383,8 +1379,9 @@
 				last_time = this_time;
 #ifndef _XWIN
 				if (!g_text_mode) {
-					sprintf(tmp, "Reading %-68s", dir);
+					mr_asprintf(&tmp, "Reading %-68s", dir);
 					newtDrawRootText(0, g_noof_rows - 3, tmp);
+					mr_free(tmp);
 				}
 #endif
 				update_evalcall_form(percentage);
@@ -1394,17 +1391,10 @@
 
 	depth++;
 
-//  mr_msg(0, "Cataloguing %s", dir);
-	if (sth[0] == ' ') {
-		skip_these = sth;
-	} else {
-		skip_these = sth_B;
-		sprintf(skip_these, " %s ", sth);
-	}
-	sprintf(new_with_spaces, " %s ", dir);
+	mr_asprintf(&new_with_spaces, " %s ", dir);
 	if ((dip = opendir(dir)) == NULL) {
 		log_OS_error("opendir");
-	} else if (strstr(skip_these, new_with_spaces)) {
+	} else if (strstr(sth, new_with_spaces)) {
 		fprintf(fout, "%s\n", dir);	// if excluded dir then print dir ONLY
 	} else {
 		fprintf(fout, "%s\n", dir);
@@ -1415,16 +1405,15 @@
 				strcat(new, "/");
 			}
 			strcat(new, dit->d_name);
-			new_with_spaces[0] = ' ';
-			strcpy(new_with_spaces + 1, new);
-			strcat(new_with_spaces, " ");
-			if (strstr(skip_these, new_with_spaces)) {
+			mr_free(new_with_spaces);
+			asprintf(&new_with_spaces, " %s ", new);
+			if (strstr(sth, new_with_spaces)) {
 				fprintf(fout, "%s\n", new);
 			} else {
 				if (!lstat(new, &statbuf)) {
 					if (!S_ISLNK(statbuf.st_mode)
 						&& S_ISDIR(statbuf.st_mode)) {
-						open_and_list_dir(new, skip_these, fout,
+						open_and_list_dir(new, sth, fout,
 										  time_of_last_full_backup);
 					} else {
 						if (time_of_last_full_backup == 0
@@ -1434,7 +1423,7 @@
 							if ((counter++) > 128) {
 								counter = 0;
 								uberctr++;
-								sprintf(tmp, " %c ",
+								asprintf(&tmp, " %c ",
 										special_dot_char(uberctr));
 #ifndef _XWIN
 								if (!g_text_mode) {
@@ -1442,6 +1431,7 @@
 													 tmp);
 									newtRefresh();
 								}
+								mr_free(tmp);
 #endif
 							}
 						}
@@ -1463,9 +1453,6 @@
 		unlink(g_skeleton_filelist);
 		mr_msg(5, "g_skeleton_entries = %ld", g_skeleton_entries);
 	}
-	mr_free(tmp);
-	mr_free(sth_B);
-	mr_free(ith_B);
 	mr_free(new_with_spaces);
 	return (0);
 }
