strutilascii.c 22 KB

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