[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Add a method of automatically sorting the spelling files



Use csplit to prevent sorting the header.
Use sort -u to eliminate duplicates.
Use LC_ALL to set the right sort order.
---
 data/spelling/Makefile              | 6 ++++++
 data/spelling/corrections           | 2 +-
 data/spelling/corrections-case      | 2 +-
 data/spelling/corrections-multiword | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100644 data/spelling/Makefile

diff --git a/data/spelling/Makefile b/data/spelling/Makefile
new file mode 100644
index 0000000..4554dfc
--- /dev/null
+++ b/data/spelling/Makefile
@@ -0,0 +1,6 @@
+sort: sort-corrections sort-corrections-case sort-corrections-multiword
+
+sort-%: %
+	csplit --prefix $<- $< '/^$$/'
+	LC_ALL=en_US sort -u $<-01 | cat $<-00 - > $<
+	rm -f $<-0[01]
diff --git a/data/spelling/corrections b/data/spelling/corrections
index 0e15ef7..a1516f3 100644
--- a/data/spelling/corrections
+++ b/data/spelling/corrections
@@ -15,7 +15,7 @@
 # Note that corrections involving multiple word mistakes or case errors
 # should be included in the appropriate data file, rather than here.
 #
-# Please keep the list sorted (using the en_US locale).
+# Please keep the list sorted using `make sort`
 
 abailable||available
 abandonned||abandoned
diff --git a/data/spelling/corrections-case b/data/spelling/corrections-case
index 99d8f18..e874cce 100644
--- a/data/spelling/corrections-case
+++ b/data/spelling/corrections-case
@@ -6,7 +6,7 @@
 # The format of each line is:
 # mistake||correction
 #
-# Please keep the list sorted (using the en_US locale).
+# Please keep the list sorted using `make sort`
 
 american||American
 apache||Apache
diff --git a/data/spelling/corrections-multiword b/data/spelling/corrections-multiword
index cae8c06..559bbe1 100644
--- a/data/spelling/corrections-multiword
+++ b/data/spelling/corrections-multiword
@@ -5,7 +5,7 @@
 # The format of each line is:
 # SPELLING_MISTAKE_REGEX||correction
 #
-# Please keep the list sorted (using the en_US locale).
+# Please keep the list sorted using `make sort`
 
 (?i)allows to||allows one to
 (?i)allow to||allow one to
-- 
2.9.3


Reply to: