@@ -343,25 +343,27 @@ load_path::set (const std::string& p, bool warn, bool is_init)
343
343
for (const auto & elt : elts)
344
344
append (elt, warn);
345
345
346
+ // Always prepend current directory.
347
+ prepend (" ." , warn);
348
+
346
349
// Restore add hook and execute for all newly added directories.
347
350
frame.run_first ();
348
351
349
- // FIXME: Shouldn't the test for add_hook be outside the for loop?
350
- // Why not use const here? Does add_hook change dir_info_list?
351
- // FIXME: We should be able to assume that the current directory is always
352
- // the first element in the list. When we assume C++20 or later,
353
- // consider replacing the range-based loop with:
354
- // for (auto& di : m_dir_info_list | std::views::drop (1))
355
- // Then, the string comparison inside the loop could be dropped.
356
- for (auto & di : m_dir_info_list)
352
+ if (m_add_hook)
357
353
{
358
- // execute PKG_ADD script (but not in the current directory)
359
- if (m_add_hook && di.dir_name .compare (" ." ))
360
- m_add_hook (di.dir_name );
354
+ // FIXME: Why not use const here? Does add_hook change dir_info_list?
355
+ // FIXME: We should be able to assume that the current directory is
356
+ // always the first element in the list. When we assume C++20 or
357
+ // later, consider replacing the range-based loop with:
358
+ // for (auto& di : m_dir_info_list | std::views::drop (1))
359
+ // Then, the string comparison inside the loop could be dropped.
360
+ for (auto & di : m_dir_info_list)
361
+ {
362
+ // execute PKG_ADD script (but not in the current directory)
363
+ if (di.dir_name .compare (" ." ))
364
+ m_add_hook (di.dir_name );
365
+ }
361
366
}
362
-
363
- // Always prepend current directory.
364
- prepend (" ." , warn);
365
367
}
366
368
367
369
void
@@ -1136,7 +1138,8 @@ load_path::add (const std::string& dir_arg, bool at_end, bool warn)
1136
1138
warning (" addpath: %s: %s" , dir_arg.c_str (), msg.c_str ());
1137
1139
}
1138
1140
1139
- // FIXME: is there a better way to do this?
1141
+ // FIXME: Is there a better way to keep "." at the front of the various lists
1142
+ // that are kept with information about the load path?
1140
1143
1141
1144
i = find_dir_info (" ." );
1142
1145
0 commit comments