strutilascii.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. /*
  2. ASCII strings utilities
  3. Copyright (C) 2007-2017
  4. Free Software Foundation, Inc.
  5. Written by:
  6. Rostislav Benes, 2007
  7. This file is part of the Midnight Commander.
  8. The Midnight Commander is free software: you can redistribute it
  9. and/or modify it under the terms of the GNU General Public License as
  10. published by the Free Software Foundation, either version 3 of the License,
  11. or (at your option) any later version.
  12. The Midnight Commander is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <config.h>
  20. #include <ctype.h>
  21. #include <stdlib.h>
  22. #include "lib/global.h"
  23. #include "lib/strutil.h"
  24. /* using g_ascii function from glib
  25. * on terminal are showed only ascii characters (lower than 0x80)
  26. */
  27. /*** global variables ****************************************************************************/
  28. /*** file scope macro definitions ****************************************************************/
  29. /*** file scope type declarations ****************************************************************/
  30. /*** file scope variables ************************************************************************/
  31. static const char replch = '?';
  32. /* --------------------------------------------------------------------------------------------- */
  33. /*** file scope functions ************************************************************************/
  34. /* --------------------------------------------------------------------------------------------- */
  35. static void
  36. str_ascii_insert_replace_char (GString * buffer)
  37. {
  38. g_string_append_c (buffer, replch);
  39. }
  40. /* --------------------------------------------------------------------------------------------- */
  41. static int
  42. str_ascii_is_valid_string (const char *text)
  43. {
  44. (void) text;
  45. return 1;
  46. }
  47. /* --------------------------------------------------------------------------------------------- */
  48. static int
  49. str_ascii_is_valid_char (const char *ch, size_t size)
  50. {
  51. (void) ch;
  52. (void) size;
  53. return 1;
  54. }
  55. /* --------------------------------------------------------------------------------------------- */
  56. static void
  57. str_ascii_cnext_char (const char **text)
  58. {
  59. (*text)++;
  60. }
  61. /* --------------------------------------------------------------------------------------------- */
  62. static void
  63. str_ascii_cprev_char (const char **text)
  64. {
  65. (*text)--;
  66. }
  67. /* --------------------------------------------------------------------------------------------- */
  68. static int
  69. str_ascii_cnext_noncomb_char (const char **text)
  70. {
  71. if (*text[0] == '\0')
  72. return 0;
  73. (*text)++;
  74. return 1;
  75. }
  76. /* --------------------------------------------------------------------------------------------- */
  77. static int
  78. str_ascii_cprev_noncomb_char (const char **text, const char *begin)
  79. {
  80. if ((*text) == begin)
  81. return 0;
  82. (*text)--;
  83. return 1;
  84. }
  85. /* --------------------------------------------------------------------------------------------- */
  86. static int
  87. str_ascii_isspace (const char *text)
  88. {
  89. return g_ascii_isspace ((gchar) text[0]);
  90. }
  91. /* --------------------------------------------------------------------------------------------- */
  92. static int
  93. str_ascii_ispunct (const char *text)
  94. {
  95. return g_ascii_ispunct ((gchar) text[0]);
  96. }
  97. /* --------------------------------------------------------------------------------------------- */
  98. static int
  99. str_ascii_isalnum (const char *text)
  100. {
  101. return g_ascii_isalnum ((gchar) text[0]);
  102. }
  103. /* --------------------------------------------------------------------------------------------- */
  104. static int
  105. str_ascii_isdigit (const char *text)
  106. {
  107. return g_ascii_isdigit ((gchar) text[0]);
  108. }
  109. /* --------------------------------------------------------------------------------------------- */
  110. static int
  111. str_ascii_isprint (const char *text)
  112. {
  113. return g_ascii_isprint ((gchar) text[0]);
  114. }
  115. /* --------------------------------------------------------------------------------------------- */
  116. static gboolean
  117. str_ascii_iscombiningmark (const char *text)
  118. {
  119. (void) text;
  120. return FALSE;
  121. }
  122. /* --------------------------------------------------------------------------------------------- */
  123. static int
  124. str_ascii_toupper (const char *text, char **out, size_t * remain)
  125. {
  126. if (*remain <= 1)
  127. return 0;
  128. (*out)[0] = (char) g_ascii_toupper ((gchar) text[0]);
  129. (*out)++;
  130. (*remain)--;
  131. return 1;
  132. }
  133. /* --------------------------------------------------------------------------------------------- */
  134. static int
  135. str_ascii_tolower (const char *text, char **out, size_t * remain)
  136. {
  137. if (*remain <= 1)
  138. return 0;
  139. (*out)[0] = (char) g_ascii_tolower ((gchar) text[0]);
  140. (*out)++;
  141. (*remain)--;
  142. return 1;
  143. }
  144. /* --------------------------------------------------------------------------------------------- */
  145. static int
  146. str_ascii_length (const char *text)
  147. {
  148. return strlen (text);
  149. }
  150. /* --------------------------------------------------------------------------------------------- */
  151. static int
  152. str_ascii_length2 (const char *text, int size)
  153. {
  154. return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
  155. }
  156. /* --------------------------------------------------------------------------------------------- */
  157. static gchar *
  158. str_ascii_conv_gerror_message (GError * mcerror, const char *def_msg)
  159. {
  160. /* the same as str_utf8_conv_gerror_message() */
  161. if (mcerror != NULL)
  162. return g_strdup (mcerror->message);
  163. return g_strdup (def_msg != NULL ? def_msg : "");
  164. }
  165. /* --------------------------------------------------------------------------------------------- */
  166. static estr_t
  167. str_ascii_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
  168. {
  169. (void) coder;
  170. g_string_append_len (buffer, string, size);
  171. return ESTR_SUCCESS;
  172. }
  173. /* --------------------------------------------------------------------------------------------- */
  174. static const char *
  175. str_ascii_term_form (const char *text)
  176. {
  177. static char result[BUF_MEDIUM];
  178. char *actual;
  179. size_t remain;
  180. size_t length;
  181. size_t pos = 0;
  182. actual = result;
  183. remain = sizeof (result);
  184. length = strlen (text);
  185. /* go throw all characters and check, if they are ascii and printable */
  186. for (; pos < length && remain > 1; pos++, actual++, remain--)
  187. {
  188. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  189. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  190. }
  191. actual[0] = '\0';
  192. return result;
  193. }
  194. /* --------------------------------------------------------------------------------------------- */
  195. static const char *
  196. str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
  197. {
  198. static char result[BUF_MEDIUM];
  199. char *actual;
  200. size_t remain;
  201. int ident = 0;
  202. size_t length;
  203. size_t pos = 0;
  204. length = strlen (text);
  205. actual = result;
  206. remain = sizeof (result);
  207. if ((int) length <= width)
  208. {
  209. switch (HIDE_FIT (just_mode))
  210. {
  211. case J_CENTER_LEFT:
  212. case J_CENTER:
  213. ident = (width - length) / 2;
  214. break;
  215. case J_RIGHT:
  216. ident = width - length;
  217. break;
  218. default:
  219. break;
  220. }
  221. /* add space before text */
  222. if ((int) remain <= ident)
  223. goto finally;
  224. memset (actual, ' ', ident);
  225. actual += ident;
  226. remain -= ident;
  227. /* copy all characters */
  228. for (; pos < (gsize) length && remain > 1; pos++, actual++, remain--)
  229. {
  230. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  231. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  232. }
  233. /* add space after text */
  234. if (width - length - ident > 0)
  235. {
  236. if (remain <= width - length - ident)
  237. goto finally;
  238. memset (actual, ' ', width - length - ident);
  239. actual += width - length - ident;
  240. }
  241. }
  242. else if (IS_FIT (just_mode))
  243. {
  244. /* copy prefix of text, that is not wider than width / 2 */
  245. for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
  246. {
  247. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  248. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  249. }
  250. if (remain <= 1)
  251. goto finally;
  252. actual[0] = '~';
  253. actual++;
  254. remain--;
  255. pos += length - width + 1;
  256. /* copy suffix of text */
  257. for (; pos < length && remain > 1; pos++, actual++, remain--)
  258. {
  259. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  260. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  261. }
  262. }
  263. else
  264. {
  265. switch (HIDE_FIT (just_mode))
  266. {
  267. case J_CENTER:
  268. ident = (length - width) / 2;
  269. break;
  270. case J_RIGHT:
  271. ident = length - width;
  272. break;
  273. default:
  274. break;
  275. }
  276. /* copy substring text, substring start from ident and take width
  277. * characters from text */
  278. pos += ident;
  279. for (; pos < (gsize) (ident + width) && remain > 1; pos++, actual++, remain--)
  280. {
  281. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  282. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  283. }
  284. }
  285. finally:
  286. if (actual >= result + sizeof (result))
  287. actual = result + sizeof (result) - 1;
  288. actual[0] = '\0';
  289. return result;
  290. }
  291. /* --------------------------------------------------------------------------------------------- */
  292. static const char *
  293. str_ascii_term_trim (const char *text, int width)
  294. {
  295. static char result[BUF_MEDIUM];
  296. size_t remain;
  297. char *actual;
  298. size_t length;
  299. length = strlen (text);
  300. actual = result;
  301. remain = sizeof (result);
  302. if (width > 0)
  303. {
  304. size_t pos;
  305. if (width >= (int) length)
  306. {
  307. /* copy all characters */
  308. for (pos = 0; pos < length && remain > 1; pos++, actual++, remain--)
  309. {
  310. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  311. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  312. }
  313. }
  314. else if (width <= 3)
  315. {
  316. memset (actual, '.', width);
  317. actual += width;
  318. }
  319. else
  320. {
  321. memset (actual, '.', 3);
  322. actual += 3;
  323. remain -= 3;
  324. /* copy suffix of text */
  325. for (pos = length - width + 3; pos < length && remain > 1; pos++, actual++, remain--)
  326. {
  327. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  328. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  329. }
  330. }
  331. }
  332. actual[0] = '\0';
  333. return result;
  334. }
  335. /* --------------------------------------------------------------------------------------------- */
  336. static int
  337. str_ascii_term_width2 (const char *text, size_t length)
  338. {
  339. return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
  340. }
  341. /* --------------------------------------------------------------------------------------------- */
  342. static int
  343. str_ascii_term_width1 (const char *text)
  344. {
  345. return str_ascii_term_width2 (text, (size_t) (-1));
  346. }
  347. /* --------------------------------------------------------------------------------------------- */
  348. static int
  349. str_ascii_term_char_width (const char *text)
  350. {
  351. (void) text;
  352. return 1;
  353. }
  354. /* --------------------------------------------------------------------------------------------- */
  355. static const char *
  356. str_ascii_term_substring (const char *text, int start, int width)
  357. {
  358. static char result[BUF_MEDIUM];
  359. size_t remain;
  360. char *actual;
  361. size_t length;
  362. actual = result;
  363. remain = sizeof (result);
  364. length = strlen (text);
  365. if (start < (int) length)
  366. {
  367. size_t pos;
  368. /* copy at most width characters from text from start */
  369. for (pos = start; pos < length && width > 0 && remain > 1;
  370. pos++, width--, actual++, remain--)
  371. {
  372. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  373. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  374. }
  375. }
  376. /* if text is shorter then width, add space to the end */
  377. for (; width > 0 && remain > 1; actual++, remain--, width--)
  378. actual[0] = ' ';
  379. actual[0] = '\0';
  380. return result;
  381. }
  382. /* --------------------------------------------------------------------------------------------- */
  383. static const char *
  384. str_ascii_trunc (const char *text, int width)
  385. {
  386. static char result[MC_MAXPATHLEN];
  387. int remain;
  388. char *actual;
  389. size_t pos = 0;
  390. size_t length;
  391. actual = result;
  392. remain = sizeof (result);
  393. length = strlen (text);
  394. if ((int) length > width)
  395. {
  396. /* copy prefix of text */
  397. for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
  398. {
  399. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  400. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  401. }
  402. if (remain <= 1)
  403. goto finally;
  404. actual[0] = '~';
  405. actual++;
  406. remain--;
  407. pos += length - width + 1;
  408. /* copy suffix of text */
  409. for (; pos < length && remain > 1; pos++, actual++, remain--)
  410. {
  411. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  412. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  413. }
  414. }
  415. else
  416. {
  417. /* copy all characters */
  418. for (; pos < length && remain > 1; pos++, actual++, remain--)
  419. {
  420. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  421. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  422. }
  423. }
  424. finally:
  425. actual[0] = '\0';
  426. return result;
  427. }
  428. /* --------------------------------------------------------------------------------------------- */
  429. static int
  430. str_ascii_offset_to_pos (const char *text, size_t length)
  431. {
  432. (void) text;
  433. return (int) length;
  434. }
  435. /* --------------------------------------------------------------------------------------------- */
  436. static int
  437. str_ascii_column_to_pos (const char *text, size_t pos)
  438. {
  439. (void) text;
  440. return (int) pos;
  441. }
  442. /* --------------------------------------------------------------------------------------------- */
  443. static char *
  444. str_ascii_create_search_needle (const char *needle, int case_sen)
  445. {
  446. (void) case_sen;
  447. return (char *) needle;
  448. }
  449. /* --------------------------------------------------------------------------------------------- */
  450. static void
  451. str_ascii_release_search_needle (char *needle, int case_sen)
  452. {
  453. (void) case_sen;
  454. (void) needle;
  455. }
  456. /* --------------------------------------------------------------------------------------------- */
  457. static const char *
  458. str_ascii_search_first (const char *text, const char *search, int case_sen)
  459. {
  460. char *fold_text;
  461. char *fold_search;
  462. const char *match;
  463. fold_text = (case_sen) ? (char *) text : g_ascii_strdown (text, -1);
  464. fold_search = (case_sen) ? (char *) search : g_ascii_strdown (search, -1);
  465. match = g_strstr_len (fold_text, -1, fold_search);
  466. if (match != NULL)
  467. {
  468. size_t offset;
  469. offset = match - fold_text;
  470. match = text + offset;
  471. }
  472. if (!case_sen)
  473. {
  474. g_free (fold_text);
  475. g_free (fold_search);
  476. }
  477. return match;
  478. }
  479. /* --------------------------------------------------------------------------------------------- */
  480. static const char *
  481. str_ascii_search_last (const char *text, const char *search, int case_sen)
  482. {
  483. char *fold_text;
  484. char *fold_search;
  485. const char *match;
  486. fold_text = (case_sen) ? (char *) text : g_ascii_strdown (text, -1);
  487. fold_search = (case_sen) ? (char *) search : g_ascii_strdown (search, -1);
  488. match = g_strrstr_len (fold_text, -1, fold_search);
  489. if (match != NULL)
  490. {
  491. size_t offset;
  492. offset = match - fold_text;
  493. match = text + offset;
  494. }
  495. if (!case_sen)
  496. {
  497. g_free (fold_text);
  498. g_free (fold_search);
  499. }
  500. return match;
  501. }
  502. /* --------------------------------------------------------------------------------------------- */
  503. static int
  504. str_ascii_compare (const char *t1, const char *t2)
  505. {
  506. return strcmp (t1, t2);
  507. }
  508. /* --------------------------------------------------------------------------------------------- */
  509. static int
  510. str_ascii_ncompare (const char *t1, const char *t2)
  511. {
  512. return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
  513. }
  514. /* --------------------------------------------------------------------------------------------- */
  515. static int
  516. str_ascii_casecmp (const char *t1, const char *t2)
  517. {
  518. return g_ascii_strcasecmp (t1, t2);
  519. }
  520. /* --------------------------------------------------------------------------------------------- */
  521. static int
  522. str_ascii_ncasecmp (const char *t1, const char *t2)
  523. {
  524. return g_ascii_strncasecmp (t1, t2, MIN (strlen (t1), strlen (t2)));
  525. }
  526. /* --------------------------------------------------------------------------------------------- */
  527. static void
  528. str_ascii_fix_string (char *text)
  529. {
  530. for (; text[0] != '\0'; text++)
  531. text[0] = ((unsigned char) text[0] < 128) ? text[0] : '?';
  532. }
  533. /* --------------------------------------------------------------------------------------------- */
  534. static char *
  535. str_ascii_create_key (const char *text, int case_sen)
  536. {
  537. (void) case_sen;
  538. return (char *) text;
  539. }
  540. /* --------------------------------------------------------------------------------------------- */
  541. static int
  542. str_ascii_key_collate (const char *t1, const char *t2, int case_sen)
  543. {
  544. return (case_sen) ? strcmp (t1, t2) : g_ascii_strcasecmp (t1, t2);
  545. }
  546. /* --------------------------------------------------------------------------------------------- */
  547. static void
  548. str_ascii_release_key (char *key, int case_sen)
  549. {
  550. (void) key;
  551. (void) case_sen;
  552. }
  553. /* --------------------------------------------------------------------------------------------- */
  554. static int
  555. str_ascii_prefix (const char *text, const char *prefix)
  556. {
  557. int result;
  558. for (result = 0; text[result] != '\0' && prefix[result] != '\0'
  559. && text[result] == prefix[result]; result++);
  560. return result;
  561. }
  562. /* --------------------------------------------------------------------------------------------- */
  563. static int
  564. str_ascii_caseprefix (const char *text, const char *prefix)
  565. {
  566. int result;
  567. for (result = 0; text[result] != '\0' && prefix[result] != '\0'
  568. && g_ascii_toupper (text[result]) == g_ascii_toupper (prefix[result]); result++);
  569. return result;
  570. }
  571. /* --------------------------------------------------------------------------------------------- */
  572. /*** public functions ****************************************************************************/
  573. /* --------------------------------------------------------------------------------------------- */
  574. struct str_class
  575. str_ascii_init (void)
  576. {
  577. struct str_class result;
  578. result.conv_gerror_message = str_ascii_conv_gerror_message;
  579. result.vfs_convert_to = str_ascii_vfs_convert_to;
  580. result.insert_replace_char = str_ascii_insert_replace_char;
  581. result.is_valid_string = str_ascii_is_valid_string;
  582. result.is_valid_char = str_ascii_is_valid_char;
  583. result.cnext_char = str_ascii_cnext_char;
  584. result.cprev_char = str_ascii_cprev_char;
  585. result.cnext_char_safe = str_ascii_cnext_char;
  586. result.cprev_char_safe = str_ascii_cprev_char;
  587. result.cnext_noncomb_char = str_ascii_cnext_noncomb_char;
  588. result.cprev_noncomb_char = str_ascii_cprev_noncomb_char;
  589. result.char_isspace = str_ascii_isspace;
  590. result.char_ispunct = str_ascii_ispunct;
  591. result.char_isalnum = str_ascii_isalnum;
  592. result.char_isdigit = str_ascii_isdigit;
  593. result.char_isprint = str_ascii_isprint;
  594. result.char_iscombiningmark = str_ascii_iscombiningmark;
  595. result.char_toupper = str_ascii_toupper;
  596. result.char_tolower = str_ascii_tolower;
  597. result.length = str_ascii_length;
  598. result.length2 = str_ascii_length2;
  599. result.length_noncomb = str_ascii_length;
  600. result.fix_string = str_ascii_fix_string;
  601. result.term_form = str_ascii_term_form;
  602. result.fit_to_term = str_ascii_fit_to_term;
  603. result.term_trim = str_ascii_term_trim;
  604. result.term_width2 = str_ascii_term_width2;
  605. result.term_width1 = str_ascii_term_width1;
  606. result.term_char_width = str_ascii_term_char_width;
  607. result.term_substring = str_ascii_term_substring;
  608. result.trunc = str_ascii_trunc;
  609. result.offset_to_pos = str_ascii_offset_to_pos;
  610. result.column_to_pos = str_ascii_column_to_pos;
  611. result.create_search_needle = str_ascii_create_search_needle;
  612. result.release_search_needle = str_ascii_release_search_needle;
  613. result.search_first = str_ascii_search_first;
  614. result.search_last = str_ascii_search_last;
  615. result.compare = str_ascii_compare;
  616. result.ncompare = str_ascii_ncompare;
  617. result.casecmp = str_ascii_casecmp;
  618. result.ncasecmp = str_ascii_ncasecmp;
  619. result.prefix = str_ascii_prefix;
  620. result.caseprefix = str_ascii_caseprefix;
  621. result.create_key = str_ascii_create_key;
  622. result.create_key_for_filename = str_ascii_create_key;
  623. result.key_collate = str_ascii_key_collate;
  624. result.release_key = str_ascii_release_key;
  625. return result;
  626. }
  627. /* --------------------------------------------------------------------------------------------- */