mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-30 14:53:11 +00:00
f92c2921d2
C++11 provides std::min/std::max which we're using all over, obviating the need for our own templates for this. util.h now only provides two things: get_time and wcsfilecmp. This commit removes everything that includes it which doesn't use either; most because they no longer need mini or maxi from it but some others were #including it unnecessarily.
37 lines
1.3 KiB
C
37 lines
1.3 KiB
C
// Generic utilities library.
|
|
#ifndef FISH_UTIL_H
|
|
#define FISH_UTIL_H
|
|
|
|
/// Compares two wide character strings with an (arguably) intuitive ordering. This function tries
|
|
/// to order strings in a way which is intuitive to humans with regards to sorting strings
|
|
/// containing numbers.
|
|
///
|
|
/// Most sorting functions would sort the strings 'file1.txt' 'file5.txt' and 'file12.txt' as:
|
|
///
|
|
/// file1.txt
|
|
/// file12.txt
|
|
/// file5.txt
|
|
///
|
|
/// This function regards any sequence of digits as a single entity when performing comparisons, so
|
|
/// the output is instead:
|
|
///
|
|
/// file1.txt
|
|
/// file5.txt
|
|
/// file12.txt
|
|
///
|
|
/// Which most people would find more intuitive.
|
|
///
|
|
/// This won't return the optimum results for numbers in bases higher than ten, such as hexadecimal,
|
|
/// but at least a stable sort order will result.
|
|
///
|
|
/// This function performs a two-tiered sort, where difference in case and in number of leading
|
|
/// zeroes in numbers only have effect if no other differences between strings are found. This way,
|
|
/// a 'file1' and 'File1' will not be considered identical, and hence their internal sort order is
|
|
/// not arbitrary, but the names 'file1', 'File2' and 'file3' will still be sorted in the order
|
|
/// given above.
|
|
int wcsfilecmp(const wchar_t *a, const wchar_t *b);
|
|
|
|
/// Get the current time in microseconds since Jan 1, 1970.
|
|
long long get_time();
|
|
|
|
#endif
|