aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/util.h
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-05-03 15:18:24 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-05-03 16:09:45 -0700
commit5c8763be0e68bbdec3fdd1edb5754f4c421098e1 (patch)
tree8b9a5068fa2f87d0a97c61df1336cd083c6b1504 /src/util.h
parentee44879d4d6ae28968885823db5f0ce13e5a6dec (diff)
restyle remaining modules to match project style
For this change I decided to bundle the remaining modules that need to be resytyled because only two were large enough to warrant doing on their own. Reduces lint errors from 225 to 162 (-28%). Line count from 3073 to 2465 (-20%). Another step in resolving issue #2902.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h92
1 files changed, 37 insertions, 55 deletions
diff --git a/src/util.h b/src/util.h
index d073ef83..9d2e4bbb 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,67 +1,49 @@
-/** \file util.h
- Generic utilities library.
-*/
-
+// Generic utilities library.
#ifndef FISH_UTIL_H
#define FISH_UTIL_H
-/**
- Returns the larger of two ints
-*/
-template<typename T>
-inline T maxi(T a, T b)
-{
- return a>b?a:b;
+/// Returns the larger of two ints.
+template <typename T>
+inline T maxi(T a, T b) {
+ return a > b ? a : b;
}
-/**
- Returns the smaller of two ints
- */
-template<typename T>
-inline T mini(T a, T b)
-{
- return a<b?a:b;
+/// Returns the smaller of two ints.
+template <typename T>
+inline T mini(T a, T b) {
+ return a < b ? a : b;
}
-/**
- 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.
-*/
+/// 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
-*/
+/// Get the current time in microseconds since Jan 1, 1970.
long long get_time();
#endif