+ }
+
+ num_names = 0;
+ for (name = namelist; name; name = name->next)
+ num_names++;
+ namelist = merge_sort (namelist, num_names, compare_names);
+
+ for (name = namelist; name; name = name->next)
+ name->found_count = 0;
+
+ if (listed_incremental_option)
+ {
+ for (name = namelist; name && name->name[0] == 0; name++)
+ ;
+ if (name)
+ name->dir_contents = append_incremental_renames (name->dir_contents);
+ }
+}
+
+/* This is like name_match, except that
+ 1. It returns a pointer to the name it matched, and doesn't set FOUND
+ in structure. The caller will have to do that if it wants to.
+ 2. If the namelist is empty, it returns null, unlike name_match, which
+ returns TRUE.
+ 3. The second argument (EXACT) controls matching algorithm. If it
+ is TRUE, the exact matching is used. However, regular expressions are
+ always matched as such, no matter what the value of EXACT is. */
+struct name *
+name_scan (const char *file_name, bool exact)
+{
+ size_t length = strlen (file_name);
+
+ while (1)
+ {
+ struct name *cursor = namelist_match (file_name, length, exact);
+ if (cursor)
+ return cursor;