strutil8bit.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. /*
  2. 8bit 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. /* Functions for singlebyte encodings, all characters have width 1
  25. * using standard system functions.
  26. * There are only small differences between functions in strutil8bit.c
  27. * and strutilascii.c.
  28. */
  29. /*** global variables ****************************************************************************/
  30. /*** file scope macro definitions ****************************************************************/
  31. /*
  32. * Inlines to equalize 'char' signedness for single 'char' encodings.
  33. * Instead of writing
  34. * isspace ((unsigned char) c);
  35. * you can write
  36. * char_isspace (c);
  37. */
  38. #define DECLARE_CTYPE_WRAPPER(func_name) \
  39. static inline int char_##func_name(char c) \
  40. { \
  41. return func_name((int)(unsigned char)c); \
  42. }
  43. /*** file scope type declarations ****************************************************************/
  44. /*** forward declarations (file scope functions) *************************************************/
  45. /*** file scope variables ************************************************************************/
  46. static const char replch = '?';
  47. /* --------------------------------------------------------------------------------------------- */
  48. /*** file scope functions ************************************************************************/
  49. /* --------------------------------------------------------------------------------------------- */
  50. /* *INDENT-OFF* */
  51. DECLARE_CTYPE_WRAPPER (isalnum)
  52. DECLARE_CTYPE_WRAPPER (isdigit)
  53. DECLARE_CTYPE_WRAPPER (isprint)
  54. DECLARE_CTYPE_WRAPPER (ispunct)
  55. DECLARE_CTYPE_WRAPPER (isspace)
  56. DECLARE_CTYPE_WRAPPER (toupper)
  57. DECLARE_CTYPE_WRAPPER (tolower)
  58. /* *INDENT-ON* */
  59. /* --------------------------------------------------------------------------------------------- */
  60. static void
  61. str_8bit_insert_replace_char (GString *buffer)
  62. {
  63. g_string_append_c (buffer, replch);
  64. }
  65. /* --------------------------------------------------------------------------------------------- */
  66. static gboolean
  67. str_8bit_is_valid_string (const char *text)
  68. {
  69. (void) text;
  70. return TRUE;
  71. }
  72. /* --------------------------------------------------------------------------------------------- */
  73. static int
  74. str_8bit_is_valid_char (const char *ch, size_t size)
  75. {
  76. (void) ch;
  77. (void) size;
  78. return 1;
  79. }
  80. /* --------------------------------------------------------------------------------------------- */
  81. static void
  82. str_8bit_cnext_char (const char **text)
  83. {
  84. (*text)++;
  85. }
  86. /* --------------------------------------------------------------------------------------------- */
  87. static void
  88. str_8bit_cprev_char (const char **text)
  89. {
  90. (*text)--;
  91. }
  92. /* --------------------------------------------------------------------------------------------- */
  93. static int
  94. str_8bit_cnext_noncomb_char (const char **text)
  95. {
  96. if (*text[0] == '\0')
  97. return 0;
  98. (*text)++;
  99. return 1;
  100. }
  101. /* --------------------------------------------------------------------------------------------- */
  102. static int
  103. str_8bit_cprev_noncomb_char (const char **text, const char *begin)
  104. {
  105. if ((*text) == begin)
  106. return 0;
  107. (*text)--;
  108. return 1;
  109. }
  110. /* --------------------------------------------------------------------------------------------- */
  111. static gboolean
  112. str_8bit_isspace (const char *text)
  113. {
  114. return char_isspace (text[0]) != 0;
  115. }
  116. /* --------------------------------------------------------------------------------------------- */
  117. static gboolean
  118. str_8bit_ispunct (const char *text)
  119. {
  120. return char_ispunct (text[0]) != 0;
  121. }
  122. /* --------------------------------------------------------------------------------------------- */
  123. static gboolean
  124. str_8bit_isalnum (const char *text)
  125. {
  126. return char_isalnum (text[0]) != 0;
  127. }
  128. /* --------------------------------------------------------------------------------------------- */
  129. static gboolean
  130. str_8bit_isdigit (const char *text)
  131. {
  132. return char_isdigit (text[0]) != 0;
  133. }
  134. /* --------------------------------------------------------------------------------------------- */
  135. static gboolean
  136. str_8bit_isprint (const char *text)
  137. {
  138. return char_isprint (text[0]) != 0;
  139. }
  140. /* --------------------------------------------------------------------------------------------- */
  141. static gboolean
  142. str_8bit_iscombiningmark (const char *text)
  143. {
  144. (void) text;
  145. return FALSE;
  146. }
  147. /* --------------------------------------------------------------------------------------------- */
  148. static int
  149. str_8bit_toupper (const char *text, char **out, size_t *remain)
  150. {
  151. if (*remain <= 1)
  152. return FALSE;
  153. (*out)[0] = char_toupper (text[0]);
  154. (*out)++;
  155. (*remain)--;
  156. return TRUE;
  157. }
  158. /* --------------------------------------------------------------------------------------------- */
  159. static gboolean
  160. str_8bit_tolower (const char *text, char **out, size_t *remain)
  161. {
  162. if (*remain <= 1)
  163. return FALSE;
  164. (*out)[0] = char_tolower (text[0]);
  165. (*out)++;
  166. (*remain)--;
  167. return TRUE;
  168. }
  169. /* --------------------------------------------------------------------------------------------- */
  170. static int
  171. str_8bit_length (const char *text)
  172. {
  173. return strlen (text);
  174. }
  175. /* --------------------------------------------------------------------------------------------- */
  176. static int
  177. str_8bit_length2 (const char *text, int size)
  178. {
  179. size_t length;
  180. length = strlen (text);
  181. return (size >= 0) ? MIN (length, (size_t) size) : length;
  182. }
  183. /* --------------------------------------------------------------------------------------------- */
  184. static gchar *
  185. str_8bit_conv_gerror_message (GError *mcerror, const char *def_msg)
  186. {
  187. GIConv conv;
  188. gchar *ret;
  189. /* glib messages are in UTF-8 charset */
  190. conv = str_crt_conv_from ("UTF-8");
  191. if (conv == INVALID_CONV)
  192. ret = g_strdup (def_msg != NULL ? def_msg : "");
  193. else
  194. {
  195. GString *buf;
  196. buf = g_string_new ("");
  197. if (str_convert (conv, mcerror->message, buf) != ESTR_FAILURE)
  198. ret = g_string_free (buf, FALSE);
  199. else
  200. {
  201. ret = g_strdup (def_msg != NULL ? def_msg : "");
  202. g_string_free (buf, TRUE);
  203. }
  204. str_close_conv (conv);
  205. }
  206. return ret;
  207. }
  208. /* --------------------------------------------------------------------------------------------- */
  209. static estr_t
  210. str_8bit_vfs_convert_to (GIConv coder, const char *string, int size, GString *buffer)
  211. {
  212. estr_t result = ESTR_SUCCESS;
  213. if (coder == str_cnv_not_convert)
  214. g_string_append_len (buffer, string, size);
  215. else
  216. result = str_nconvert (coder, string, size, buffer);
  217. return result;
  218. }
  219. /* --------------------------------------------------------------------------------------------- */
  220. static const char *
  221. str_8bit_term_form (const char *text)
  222. {
  223. static char result[BUF_MEDIUM];
  224. char *actual;
  225. size_t remain;
  226. size_t length;
  227. size_t pos = 0;
  228. actual = result;
  229. remain = sizeof (result);
  230. length = strlen (text);
  231. for (; pos < length && remain > 1; pos++, actual++, remain--)
  232. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  233. actual[0] = '\0';
  234. return result;
  235. }
  236. /* --------------------------------------------------------------------------------------------- */
  237. static const char *
  238. str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
  239. {
  240. static char result[BUF_MEDIUM];
  241. char *actual;
  242. size_t remain;
  243. int ident = 0;
  244. size_t length;
  245. size_t pos = 0;
  246. length = strlen (text);
  247. actual = result;
  248. remain = sizeof (result);
  249. if ((int) length <= width)
  250. {
  251. switch (HIDE_FIT (just_mode))
  252. {
  253. case J_CENTER_LEFT:
  254. case J_CENTER:
  255. ident = (width - length) / 2;
  256. break;
  257. case J_RIGHT:
  258. ident = width - length;
  259. break;
  260. default:
  261. break;
  262. }
  263. if ((int) remain <= ident)
  264. goto finally;
  265. memset (actual, ' ', ident);
  266. actual += ident;
  267. remain -= ident;
  268. for (; pos < length && remain > 1; pos++, actual++, remain--)
  269. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  270. if (width - length - ident > 0)
  271. {
  272. if (remain <= width - length - ident)
  273. goto finally;
  274. memset (actual, ' ', width - length - ident);
  275. actual += width - length - ident;
  276. }
  277. }
  278. else if (IS_FIT (just_mode))
  279. {
  280. for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
  281. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  282. if (remain <= 1)
  283. goto finally;
  284. actual[0] = '~';
  285. actual++;
  286. remain--;
  287. pos += length - width + 1;
  288. for (; pos < length && remain > 1; pos++, actual++, remain--)
  289. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  290. }
  291. else
  292. {
  293. switch (HIDE_FIT (just_mode))
  294. {
  295. case J_CENTER:
  296. ident = (length - width) / 2;
  297. break;
  298. case J_RIGHT:
  299. ident = length - width;
  300. break;
  301. default:
  302. break;
  303. }
  304. pos += ident;
  305. for (; pos < (gsize) (ident + width) && remain > 1; pos++, actual++, remain--)
  306. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  307. }
  308. finally:
  309. if (actual >= result + sizeof (result))
  310. actual = result + sizeof (result) - 1;
  311. actual[0] = '\0';
  312. return result;
  313. }
  314. /* --------------------------------------------------------------------------------------------- */
  315. static const char *
  316. str_8bit_term_trim (const char *text, int width)
  317. {
  318. static char result[BUF_MEDIUM];
  319. size_t remain;
  320. char *actual;
  321. size_t length;
  322. length = strlen (text);
  323. actual = result;
  324. remain = sizeof (result);
  325. if (width > 0)
  326. {
  327. size_t pos;
  328. if (width >= (int) length)
  329. {
  330. for (pos = 0; pos < length && remain > 1; pos++, actual++, remain--)
  331. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  332. }
  333. else if (width <= 3)
  334. {
  335. memset (actual, '.', width);
  336. actual += width;
  337. }
  338. else
  339. {
  340. memset (actual, '.', 3);
  341. actual += 3;
  342. remain -= 3;
  343. for (pos = length - width + 3; pos < length && remain > 1; pos++, actual++, remain--)
  344. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  345. }
  346. }
  347. actual[0] = '\0';
  348. return result;
  349. }
  350. /* --------------------------------------------------------------------------------------------- */
  351. static int
  352. str_8bit_term_width2 (const char *text, size_t length)
  353. {
  354. size_t text_len;
  355. text_len = strlen (text);
  356. return (length != (size_t) (-1)) ? MIN (text_len, length) : text_len;
  357. }
  358. /* --------------------------------------------------------------------------------------------- */
  359. static int
  360. str_8bit_term_width1 (const char *text)
  361. {
  362. return str_8bit_term_width2 (text, (size_t) (-1));
  363. }
  364. /* --------------------------------------------------------------------------------------------- */
  365. static int
  366. str_8bit_term_char_width (const char *text)
  367. {
  368. (void) text;
  369. return 1;
  370. }
  371. /* --------------------------------------------------------------------------------------------- */
  372. static const char *
  373. str_8bit_term_substring (const char *text, int start, int width)
  374. {
  375. static char result[BUF_MEDIUM];
  376. size_t remain;
  377. char *actual;
  378. size_t length;
  379. actual = result;
  380. remain = sizeof (result);
  381. length = strlen (text);
  382. if (start < (int) length)
  383. {
  384. size_t pos;
  385. for (pos = start; pos < length && width > 0 && remain > 1;
  386. pos++, width--, actual++, remain--)
  387. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  388. }
  389. for (; width > 0 && remain > 1; actual++, remain--, width--)
  390. actual[0] = ' ';
  391. actual[0] = '\0';
  392. return result;
  393. }
  394. /* --------------------------------------------------------------------------------------------- */
  395. static const char *
  396. str_8bit_trunc (const char *text, int width)
  397. {
  398. static char result[MC_MAXPATHLEN];
  399. int remain;
  400. char *actual;
  401. size_t pos = 0;
  402. size_t length;
  403. actual = result;
  404. remain = sizeof (result);
  405. length = strlen (text);
  406. if ((int) length > width)
  407. {
  408. for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
  409. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  410. if (remain <= 1)
  411. goto finally;
  412. actual[0] = '~';
  413. actual++;
  414. remain--;
  415. pos += length - width + 1;
  416. for (; pos < length && remain > 1; pos++, actual++, remain--)
  417. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  418. }
  419. else
  420. {
  421. for (; pos < length && remain > 1; pos++, actual++, remain--)
  422. actual[0] = char_isprint (text[pos]) ? text[pos] : '.';
  423. }
  424. finally:
  425. actual[0] = '\0';
  426. return result;
  427. }
  428. /* --------------------------------------------------------------------------------------------- */
  429. static int
  430. str_8bit_offset_to_pos (const char *text, size_t length)
  431. {
  432. (void) text;
  433. return (int) length;
  434. }
  435. /* --------------------------------------------------------------------------------------------- */
  436. static int
  437. str_8bit_column_to_pos (const char *text, size_t pos)
  438. {
  439. (void) text;
  440. return (int) pos;
  441. }
  442. /* --------------------------------------------------------------------------------------------- */
  443. static char *
  444. str_8bit_create_search_needle (const char *needle, gboolean case_sen)
  445. {
  446. (void) case_sen;
  447. return (char *) needle;
  448. }
  449. /* --------------------------------------------------------------------------------------------- */
  450. static void
  451. str_8bit_release_search_needle (char *needle, gboolean case_sen)
  452. {
  453. (void) case_sen;
  454. (void) needle;
  455. }
  456. /* --------------------------------------------------------------------------------------------- */
  457. static char *
  458. str_8bit_strdown (const char *str)
  459. {
  460. char *rets, *p;
  461. if (str == NULL)
  462. return NULL;
  463. rets = g_strdup (str);
  464. for (p = rets; *p != '\0'; p++)
  465. *p = char_tolower (*p);
  466. return rets;
  467. }
  468. /* --------------------------------------------------------------------------------------------- */
  469. static const char *
  470. str_8bit_search_first (const char *text, const char *search, gboolean case_sen)
  471. {
  472. char *fold_text;
  473. char *fold_search;
  474. const char *match;
  475. fold_text = case_sen ? (char *) text : str_8bit_strdown (text);
  476. fold_search = case_sen ? (char *) search : str_8bit_strdown (search);
  477. match = g_strstr_len (fold_text, -1, fold_search);
  478. if (match != NULL)
  479. {
  480. size_t offset;
  481. offset = match - fold_text;
  482. match = text + offset;
  483. }
  484. if (!case_sen)
  485. {
  486. g_free (fold_text);
  487. g_free (fold_search);
  488. }
  489. return match;
  490. }
  491. /* --------------------------------------------------------------------------------------------- */
  492. static const char *
  493. str_8bit_search_last (const char *text, const char *search, gboolean case_sen)
  494. {
  495. char *fold_text;
  496. char *fold_search;
  497. const char *match;
  498. fold_text = case_sen ? (char *) text : str_8bit_strdown (text);
  499. fold_search = case_sen ? (char *) search : str_8bit_strdown (search);
  500. match = g_strrstr_len (fold_text, -1, fold_search);
  501. if (match != NULL)
  502. {
  503. size_t offset;
  504. offset = match - fold_text;
  505. match = text + offset;
  506. }
  507. if (!case_sen)
  508. {
  509. g_free (fold_text);
  510. g_free (fold_search);
  511. }
  512. return match;
  513. }
  514. /* --------------------------------------------------------------------------------------------- */
  515. static int
  516. str_8bit_compare (const char *t1, const char *t2)
  517. {
  518. return strcmp (t1, t2);
  519. }
  520. /* --------------------------------------------------------------------------------------------- */
  521. static int
  522. str_8bit_ncompare (const char *t1, const char *t2)
  523. {
  524. size_t l1, l2;
  525. l1 = strlen (t1);
  526. l2 = strlen (t2);
  527. return strncmp (t1, t2, MIN (l1, l2));
  528. }
  529. /* --------------------------------------------------------------------------------------------- */
  530. static int
  531. str_8bit_casecmp (const char *s1, const char *s2)
  532. {
  533. /* code from GLib */
  534. #ifdef HAVE_STRCASECMP
  535. g_return_val_if_fail (s1 != NULL, 0);
  536. g_return_val_if_fail (s2 != NULL, 0);
  537. return strcasecmp (s1, s2);
  538. #else
  539. g_return_val_if_fail (s1 != NULL, 0);
  540. g_return_val_if_fail (s2 != NULL, 0);
  541. for (; *s1 != '\0' && *s2 != '\0'; s1++, s2++)
  542. {
  543. gint c1, c2;
  544. /* According to A. Cox, some platforms have islower's that
  545. * don't work right on non-uppercase
  546. */
  547. c1 = isupper ((guchar) * s1) ? tolower ((guchar) * s1) : *s1;
  548. c2 = isupper ((guchar) * s2) ? tolower ((guchar) * s2) : *s2;
  549. if (c1 != c2)
  550. return (c1 - c2);
  551. }
  552. return (((gint) (guchar) * s1) - ((gint) (guchar) * s2));
  553. #endif
  554. }
  555. /* --------------------------------------------------------------------------------------------- */
  556. static int
  557. str_8bit_ncasecmp (const char *s1, const char *s2)
  558. {
  559. size_t l1, l2;
  560. size_t n;
  561. g_return_val_if_fail (s1 != NULL, 0);
  562. g_return_val_if_fail (s2 != NULL, 0);
  563. l1 = strlen (s1);
  564. l2 = strlen (s2);
  565. n = MIN (l1, l2);
  566. /* code from GLib */
  567. #ifdef HAVE_STRNCASECMP
  568. return strncasecmp (s1, s2, n);
  569. #else
  570. for (; *s1 != '\0' && *s2 != '\0'; s1++, s2++)
  571. {
  572. gint c1, c2;
  573. n--;
  574. /* According to A. Cox, some platforms have islower's that
  575. * don't work right on non-uppercase
  576. */
  577. c1 = isupper ((guchar) * s1) ? tolower ((guchar) * s1) : *s1;
  578. c2 = isupper ((guchar) * s2) ? tolower ((guchar) * s2) : *s2;
  579. if (c1 != c2)
  580. return (c1 - c2);
  581. }
  582. if (n == 0)
  583. return 0;
  584. return (((gint) (guchar) * s1) - ((gint) (guchar) * s2));
  585. #endif
  586. }
  587. /* --------------------------------------------------------------------------------------------- */
  588. static int
  589. str_8bit_prefix (const char *text, const char *prefix)
  590. {
  591. int result;
  592. for (result = 0; text[result] != '\0' && prefix[result] != '\0'
  593. && text[result] == prefix[result]; result++);
  594. return result;
  595. }
  596. /* --------------------------------------------------------------------------------------------- */
  597. static int
  598. str_8bit_caseprefix (const char *text, const char *prefix)
  599. {
  600. int result;
  601. for (result = 0; text[result] != '\0' && prefix[result] != '\0'
  602. && char_toupper (text[result]) == char_toupper (prefix[result]); result++);
  603. return result;
  604. }
  605. /* --------------------------------------------------------------------------------------------- */
  606. static void
  607. str_8bit_fix_string (char *text)
  608. {
  609. (void) text;
  610. }
  611. /* --------------------------------------------------------------------------------------------- */
  612. static char *
  613. str_8bit_create_key (const char *text, gboolean case_sen)
  614. {
  615. return case_sen ? (char *) text : str_8bit_strdown (text);
  616. }
  617. /* --------------------------------------------------------------------------------------------- */
  618. static int
  619. str_8bit_key_collate (const char *t1, const char *t2, gboolean case_sen)
  620. {
  621. return case_sen ? strcmp (t1, t2) : strcoll (t1, t2);
  622. }
  623. /* --------------------------------------------------------------------------------------------- */
  624. static void
  625. str_8bit_release_key (char *key, gboolean case_sen)
  626. {
  627. if (!case_sen)
  628. g_free (key);
  629. }
  630. /* --------------------------------------------------------------------------------------------- */
  631. /*** public functions ****************************************************************************/
  632. /* --------------------------------------------------------------------------------------------- */
  633. struct str_class
  634. str_8bit_init (void)
  635. {
  636. struct str_class result;
  637. result.conv_gerror_message = str_8bit_conv_gerror_message;
  638. result.vfs_convert_to = str_8bit_vfs_convert_to;
  639. result.insert_replace_char = str_8bit_insert_replace_char;
  640. result.is_valid_string = str_8bit_is_valid_string;
  641. result.is_valid_char = str_8bit_is_valid_char;
  642. result.cnext_char = str_8bit_cnext_char;
  643. result.cprev_char = str_8bit_cprev_char;
  644. result.cnext_char_safe = str_8bit_cnext_char;
  645. result.cprev_char_safe = str_8bit_cprev_char;
  646. result.cnext_noncomb_char = str_8bit_cnext_noncomb_char;
  647. result.cprev_noncomb_char = str_8bit_cprev_noncomb_char;
  648. result.char_isspace = str_8bit_isspace;
  649. result.char_ispunct = str_8bit_ispunct;
  650. result.char_isalnum = str_8bit_isalnum;
  651. result.char_isdigit = str_8bit_isdigit;
  652. result.char_isprint = str_8bit_isprint;
  653. result.char_iscombiningmark = str_8bit_iscombiningmark;
  654. result.char_toupper = str_8bit_toupper;
  655. result.char_tolower = str_8bit_tolower;
  656. result.length = str_8bit_length;
  657. result.length2 = str_8bit_length2;
  658. result.length_noncomb = str_8bit_length;
  659. result.fix_string = str_8bit_fix_string;
  660. result.term_form = str_8bit_term_form;
  661. result.fit_to_term = str_8bit_fit_to_term;
  662. result.term_trim = str_8bit_term_trim;
  663. result.term_width2 = str_8bit_term_width2;
  664. result.term_width1 = str_8bit_term_width1;
  665. result.term_char_width = str_8bit_term_char_width;
  666. result.term_substring = str_8bit_term_substring;
  667. result.trunc = str_8bit_trunc;
  668. result.offset_to_pos = str_8bit_offset_to_pos;
  669. result.column_to_pos = str_8bit_column_to_pos;
  670. result.create_search_needle = str_8bit_create_search_needle;
  671. result.release_search_needle = str_8bit_release_search_needle;
  672. result.search_first = str_8bit_search_first;
  673. result.search_last = str_8bit_search_last;
  674. result.compare = str_8bit_compare;
  675. result.ncompare = str_8bit_ncompare;
  676. result.casecmp = str_8bit_casecmp;
  677. result.ncasecmp = str_8bit_ncasecmp;
  678. result.prefix = str_8bit_prefix;
  679. result.caseprefix = str_8bit_caseprefix;
  680. result.create_key = str_8bit_create_key;
  681. result.create_key_for_filename = str_8bit_create_key;
  682. result.key_collate = str_8bit_key_collate;
  683. result.release_key = str_8bit_release_key;
  684. return result;
  685. }
  686. /* --------------------------------------------------------------------------------------------- */