Changeset 3394 for trunk/src/kmk/function.c
- Timestamp:
- Jul 1, 2020, 10:24:52 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/function.c
r3389 r3394 90 90 # include "kmkbuiltin/mscfakes.h" 91 91 # endif 92 # include "version_compare.h" 92 93 #endif 93 94 … … 1766 1767 } 1767 1768 1769 #ifdef KMK 1770 /* Compare strings *S1 and *S2. 1771 Return negative if the first is less, positive if it is greater, 1772 zero if they are equal. */ 1773 1774 static int 1775 version_compare_wrapper (const void *v1, const void *v2) 1776 { 1777 const char *s1 = *((char **)v1); 1778 const char *s2 = *((char **)v2); 1779 return version_compare (s1, s2); 1780 } 1781 #endif /* KMK */ 1768 1782 1769 1783 /* … … 1806 1820 1807 1821 /* Now sort the list of words. */ 1822 #ifdef KMK 1823 if (funcname[0] == 'v' || funcname[1] == 'v') 1824 qsort (words, wordi, sizeof (char *), version_compare_wrapper); 1825 else 1826 qsort (words, wordi, sizeof (char *), alpha_compare); 1827 #else 1808 1828 qsort (words, wordi, sizeof (char *), alpha_compare); 1829 #endif 1809 1830 1810 1831 /* Now write the sorted list, uniquified. */ 1811 1832 #ifdef CONFIG_WITH_RSORT 1812 if ( strcmp (funcname, "rsort"))1833 if (*funcname != 'r') 1813 1834 { 1814 1835 /* sort */ … … 6782 6803 6783 6804 static char *common_sortfiles (char *o, char **argv, unsigned int style, 6784 int ascending )6805 int ascending, int version) 6785 6806 { 6786 6807 struct nameseq *chain = helper_parse_file_list (argv[0], style, 0); … … 6840 6861 { 6841 6862 return common_sortfiles (o, argv, Q_IN_QUOTED | Q_RET_QUOTED | Q_SEP_SPACE, 6842 funcname[0] != 'r'); 6863 funcname[0] != 'r', 6864 funcname[0] == 'v' || funcname[1] == 'v'); 6843 6865 } 6844 6866 … … 6851 6873 { 6852 6874 unsigned int const style = helper_file_quoting_style (argv[0], Q_QDEFAULT); 6853 return common_sortfiles (o, &argv[1], style, funcname[1] != 'r'); 6875 return common_sortfiles (o, &argv[1], style, funcname[1] != 'r', 6876 funcname[1] == 'v' || funcname[2] == 'v'); 6854 6877 } 6855 6878 … … 6876 6899 { 6877 6900 PATH_VAR (outbuf); 6878 int doneany = 0;6879 6901 struct nameseq *chain = helper_parse_file_list (line, style, 0); 6880 6902 … … 7408 7430 #ifdef CONFIG_WITH_RSORT 7409 7431 FT_ENTRY ("rsort", 0, 1, 1, func_sort), 7432 # ifdef KMK 7433 FT_ENTRY ("rversort", 0, 1, 1, func_sort), 7434 # endif 7410 7435 #endif 7411 7436 FT_ENTRY ("shell", 0, 1, 1, func_shell), 7412 7437 FT_ENTRY ("sort", 0, 1, 1, func_sort), 7438 # ifdef KMK 7439 FT_ENTRY ("versort", 0, 1, 1, func_sort), 7440 # endif 7413 7441 FT_ENTRY ("strip", 0, 1, 1, func_strip), 7414 7442 #ifdef CONFIG_WITH_WHERE_FUNCTION … … 7570 7598 FT_ENTRY ("foreachfile", 3, 3, 0, func_foreachfile), 7571 7599 FT_ENTRY ("sortfiles", 0, 1, 1, func_sortfiles), 7600 FT_ENTRY ("versortfiles", 0, 1, 1, func_sortfiles), 7572 7601 # ifdef CONFIG_WITH_RSORT 7573 7602 FT_ENTRY ("rsortfiles", 0, 1, 1, func_sortfiles), 7603 FT_ENTRY ("rversortfiles", 0, 1, 1, func_sortfiles), 7574 7604 # endif 7575 7605 /* Function variants with preceding style argument and quoting by default. */ … … 7580 7610 FT_ENTRY ("qforeachfile", 1+3, 1+3, 0, func_q_foreachfile), 7581 7611 FT_ENTRY ("qsortfiles", 1+0, 1+1, 1, func_q_sortfiles), 7612 FT_ENTRY ("qversortfiles",1+0, 1+1, 1, func_q_sortfiles), 7582 7613 # ifdef CONFIG_WITH_RSORT 7583 7614 FT_ENTRY ("qrsortfiles", 1+0, 1+1, 1, func_q_sortfiles), 7615 FT_ENTRY ("qrversortfiles",1+0,1+1, 1, func_q_sortfiles), 7584 7616 # endif 7585 7617 FT_ENTRY ("qabspath", 1+0, 1+1, 1, func_q_abspath),
Note:
See TracChangeset
for help on using the changeset viewer.