summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorK.Takata <kentkt@csc.jp>2021-06-02 14:56:39 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-02 14:56:39 +0200
commiteecf2b35a146d7d5512f2525ad631d796e19edac (patch)
treef0c23ecc84b037ccf886fbed295db48614a4e3f4 /src/evalfunc.c
parenteeec2548785b2dd245a31ab25d7bde0f88ea1a6d (diff)
patch 8.2.2923: EBCDIC build is brokenv8.2.2923
Problem: EBCDIC build is broken. Solution: Move sortFunctions() to evalfunc.c. (Ken Takata, closes #8306)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index fcb64f67ac..8ea48f9bd5 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1855,6 +1855,33 @@ static funcentry_T global_functions[] =
ret_number, f_xor},
};
+#if defined(EBCDIC) || defined(PROTO)
+/*
+ * Compare funcentry_T by function name.
+ */
+ static int
+compare_func_name(const void *s1, const void *s2)
+{
+ funcentry_T *p1 = (funcentry_T *)s1;
+ funcentry_T *p2 = (funcentry_T *)s2;
+
+ return STRCMP(p1->f_name, p2->f_name);
+}
+
+/*
+ * Sort the function table by function name.
+ * The sorting of the table above is ASCII dependent.
+ * On machines using EBCDIC we have to sort it.
+ */
+ void
+sortFunctions(void)
+{
+ size_t funcCnt = ARRAY_LENGTH(global_functions);
+
+ qsort(global_functions, funcCnt, sizeof(funcentry_T), compare_func_name);
+}
+#endif
+
/*
* Function given to ExpandGeneric() to obtain the list of internal
* or user defined function names.