UilSarComp.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * @OSF_COPYRIGHT@
  25. * COPYRIGHT NOTICE
  26. * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
  27. * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
  28. * the full copyright text.
  29. */
  30. /*
  31. * HISTORY
  32. */
  33. #ifdef REV_INFO
  34. #ifndef lint
  35. static char rcsid[] = "$XConsortium: UilSarComp.c /main/11 1995/07/14 09:36:46 drk $"
  36. #endif
  37. #endif
  38. /*
  39. * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  40. /*
  41. **++
  42. ** FACILITY:
  43. **
  44. ** User Interface Language Compiler (UIL)
  45. **
  46. ** ABSTRACT:
  47. **
  48. ** This module supports compound strings in UIL. It includes
  49. ** the basic operations for creating, copying, and concatenating
  50. ** strings.
  51. **
  52. **--
  53. **/
  54. /*
  55. **
  56. ** INCLUDE FILES
  57. **
  58. **/
  59. #include <Mrm/MrmAppl.h>
  60. #ifdef DXM_V11
  61. #include <DXm/DXmHelpB.h>
  62. #endif
  63. #include "UilDefI.h"
  64. /*
  65. **
  66. ** TABLE OF CONTENTS
  67. **
  68. **/
  69. /*
  70. **
  71. ** DEFINE and MACRO DEFINITIONS
  72. **
  73. **/
  74. #define clear_class_mask (~(sym_m_private | sym_m_imported | sym_m_exported))
  75. /*
  76. **
  77. ** EXTERNAL VARIABLE DECLARATIONS
  78. **
  79. **/
  80. extern yystype yylval;
  81. /*
  82. **
  83. ** GLOBAL VARIABLE DECLARATIONS
  84. **
  85. **/
  86. /*
  87. **
  88. ** OWN VARIABLE DECLARATIONS
  89. **
  90. **/
  91. /*
  92. **++
  93. ** FUNCTIONAL DESCRIPTION:
  94. **
  95. ** This function creates a null compound string.
  96. **
  97. ** FORMAL PARAMETERS:
  98. **
  99. ** none
  100. **
  101. ** IMPLICIT INPUTS:
  102. **
  103. ** none
  104. **
  105. ** IMPLICIT OUTPUTS:
  106. **
  107. ** none
  108. **
  109. ** FUNCTION VALUE:
  110. **
  111. ** none
  112. **
  113. ** SIDE EFFECTS:
  114. **
  115. ** a copy of the primitive string may be made
  116. **
  117. **--
  118. **/
  119. sym_value_entry_type *sem_create_cstr()
  120. {
  121. sym_value_entry_type *az_cstr_entry;
  122. az_cstr_entry = (sym_value_entry_type *)
  123. sem_allocate_node
  124. ( sym_k_value_entry,
  125. sym_k_value_entry_size + sizeof( char * ) );
  126. az_cstr_entry->obj_header.b_flags = sym_m_builtin | sym_m_private;
  127. az_cstr_entry->b_type = sym_k_compound_string_value;
  128. az_cstr_entry->w_length = sizeof (char *);
  129. az_cstr_entry->b_direction = NOSTRING_DIRECTION;
  130. /* Fix for CN 16149 (DTS 10023) part 1 -- initialize charset info */
  131. az_cstr_entry->b_charset = sym_k_error_charset;
  132. az_cstr_entry->az_charset_value = NULL;
  133. _sar_save_source_pos (&az_cstr_entry->header, &yylval);
  134. return az_cstr_entry;
  135. }
  136. /*
  137. **++
  138. ** FUNCTIONAL DESCRIPTION:
  139. **
  140. ** This function creates a null wide_character string.
  141. **
  142. ** FORMAL PARAMETERS:
  143. **
  144. ** none
  145. **
  146. ** IMPLICIT INPUTS:
  147. **
  148. ** none
  149. **
  150. ** IMPLICIT OUTPUTS:
  151. **
  152. ** none
  153. **
  154. ** FUNCTION VALUE:
  155. **
  156. ** none
  157. **
  158. ** SIDE EFFECTS:
  159. **
  160. ** a copy of the primitive string may be made
  161. **
  162. **--
  163. **/
  164. sym_value_entry_type *sem_create_wchar_str()
  165. {
  166. sym_value_entry_type *az_wchar_str_entry;
  167. az_wchar_str_entry = (sym_value_entry_type *)
  168. sem_allocate_node
  169. ( sym_k_value_entry,
  170. sym_k_value_entry_size + sizeof( char * ) );
  171. az_wchar_str_entry->obj_header.b_flags = sym_m_builtin | sym_m_private;
  172. az_wchar_str_entry->b_type = sym_k_wchar_string_value;
  173. az_wchar_str_entry->w_length = sizeof (char *);
  174. az_wchar_str_entry->b_direction = NOSTRING_DIRECTION;
  175. _sar_save_source_pos (&az_wchar_str_entry->header, &yylval);
  176. return az_wchar_str_entry;
  177. }
  178. /*
  179. **++
  180. ** FUNCTIONAL DESCRIPTION:
  181. **
  182. ** This function appends a primitive or a localized string to a
  183. ** compound string.
  184. **
  185. ** FORMAL PARAMETERS:
  186. **
  187. ** az_cstr_entry compound string
  188. ** az_str_entry primitive string or localized string
  189. ** op2_temporary true if op2 is not needed after operation
  190. **
  191. ** IMPLICIT INPUTS:
  192. **
  193. ** none
  194. **
  195. ** IMPLICIT OUTPUTS:
  196. **
  197. ** none
  198. **
  199. ** FUNCTION VALUE:
  200. **
  201. ** none
  202. **
  203. ** SIDE EFFECTS:
  204. **
  205. ** a copy of the primitive string may be made
  206. **
  207. **--
  208. **/
  209. void sem_append_str_to_cstr(az_cstr_entry, az_str_entry, op2_temporary)
  210. sym_value_entry_type *az_cstr_entry;
  211. sym_value_entry_type *az_str_entry;
  212. boolean op2_temporary;
  213. {
  214. sym_value_entry_type *last_str_entry;
  215. sym_value_entry_type **ptr;
  216. sym_value_entry_type *new_str_entry;
  217. boolean merge;
  218. /*
  219. ** A couple of points:
  220. ** 1) if op2_temporary = FALSE - we must make a copy
  221. ** of it
  222. ** 2) if the last string of the compound string has the same attributes
  223. ** as the string being appended, the strings are merged into 1
  224. */
  225. /* find the last string of the compound string */
  226. ptr = &(az_cstr_entry->az_first_table_value);
  227. last_str_entry = *ptr;
  228. merge = FALSE;
  229. if (last_str_entry != NULL)
  230. {
  231. for ( ;
  232. last_str_entry->az_next_table_value != NULL;
  233. ptr = (sym_value_entry_type * *)
  234. &(last_str_entry->az_next_table_value),
  235. last_str_entry = *ptr);
  236. if ((last_str_entry->b_charset == az_str_entry->b_charset)
  237. &&
  238. ((last_str_entry->b_direction)== (az_str_entry->b_direction))
  239. &&
  240. ((last_str_entry->b_aux_flags & sym_m_separate) == 0 ))
  241. merge = TRUE;
  242. else
  243. ptr = (sym_value_entry_type * *)
  244. &(last_str_entry->az_next_table_value);
  245. }
  246. if (merge)
  247. {
  248. new_str_entry =
  249. sem_cat_str_to_str( last_str_entry, TRUE,
  250. az_str_entry, op2_temporary );
  251. }
  252. else
  253. {
  254. /*
  255. ** Append a new segment to the compound string
  256. */
  257. if( op2_temporary == FALSE )
  258. {
  259. unsigned short old_size;
  260. /* must make a copy since user has access to string via name */
  261. new_str_entry = (sym_value_entry_type *)
  262. sem_allocate_node( sym_k_value_entry,
  263. az_str_entry->header.w_node_size<<2 );
  264. old_size = new_str_entry->header.w_node_size;
  265. _sym_copy_entry( new_str_entry,
  266. az_str_entry,
  267. az_str_entry->header.w_node_size );
  268. new_str_entry->header.w_node_size = old_size;
  269. }
  270. else
  271. new_str_entry = az_str_entry;
  272. }
  273. /* link to the end of the compound string */
  274. new_str_entry->b_aux_flags |= sym_m_table_entry;
  275. new_str_entry->obj_header.b_flags = sym_m_private | sym_m_builtin;
  276. new_str_entry->obj_header.az_name = NULL;
  277. new_str_entry->az_next_table_value = NULL;
  278. *ptr = new_str_entry;
  279. }
  280. /*
  281. **++
  282. ** FUNCTIONAL DESCRIPTION:
  283. **
  284. ** This function appends a compound string to a compound string.
  285. **
  286. ** FORMAL PARAMETERS:
  287. **
  288. ** az_cstr1_entry compound string
  289. ** az_cstr2_entry compound string
  290. ** op2_temporary true if op2 is not needed after operation
  291. **
  292. ** IMPLICIT INPUTS:
  293. **
  294. ** none
  295. **
  296. ** IMPLICIT OUTPUTS:
  297. **
  298. ** none
  299. **
  300. ** FUNCTION VALUE:
  301. **
  302. ** none
  303. **
  304. ** SIDE EFFECTS:
  305. **
  306. ** none
  307. **
  308. **--
  309. **/
  310. void sem_append_cstr_to_cstr(az_cstr1_entry, az_cstr2_entry, op2_temporary)
  311. sym_value_entry_type *az_cstr1_entry;
  312. sym_value_entry_type *az_cstr2_entry;
  313. boolean op2_temporary;
  314. {
  315. sym_value_entry_type *last_str_entry;
  316. sym_value_entry_type **ptr;
  317. sym_value_entry_type *next_str_entry;
  318. /*
  319. ** A couple of points:
  320. ** 1) if op2_temporary = FALSE - we must make a copy of 2nd compound
  321. ** string
  322. ** 2) if the last string of 1st compound string has the same attributes
  323. ** as the 1st string of the 2nd compound string being appended,
  324. ** the strings are merged into 1
  325. */
  326. /* find the last string of the 1st compound string */
  327. ptr = &(az_cstr1_entry->az_first_table_value);
  328. last_str_entry = *ptr;
  329. next_str_entry = az_cstr2_entry->az_first_table_value;
  330. if (op2_temporary)
  331. sem_free_node(( sym_entry_type *) az_cstr2_entry );
  332. if (next_str_entry == NULL)
  333. return;
  334. if (last_str_entry != NULL)
  335. {
  336. for ( ;
  337. last_str_entry->az_next_table_value != NULL;
  338. ptr = (sym_value_entry_type * *)
  339. &(last_str_entry->az_next_table_value),
  340. last_str_entry = *ptr);
  341. if ((last_str_entry->b_charset == next_str_entry->b_charset)
  342. &&
  343. ((last_str_entry->b_direction)== (next_str_entry->b_direction))
  344. &&
  345. ((last_str_entry->b_aux_flags & sym_m_separate) == 0 ))
  346. {
  347. last_str_entry =
  348. sem_cat_str_to_str( last_str_entry, TRUE,
  349. next_str_entry, op2_temporary );
  350. last_str_entry->b_aux_flags |= sym_m_table_entry;
  351. *ptr = last_str_entry;
  352. next_str_entry =
  353. (sym_value_entry_type *) next_str_entry->az_next_table_value;
  354. }
  355. ptr = (sym_value_entry_type * *)
  356. &(last_str_entry->az_next_table_value);
  357. }
  358. if (op2_temporary)
  359. {
  360. *ptr = next_str_entry;
  361. return;
  362. }
  363. for ( ;
  364. next_str_entry != NULL;
  365. next_str_entry = (sym_value_entry_type *)
  366. next_str_entry->az_next_table_value )
  367. {
  368. sym_value_entry_type *new_str_entry;
  369. unsigned short old_size;
  370. new_str_entry = (sym_value_entry_type *)
  371. sem_allocate_node( sym_k_value_entry,
  372. next_str_entry->header.w_node_size<<2 );
  373. old_size = new_str_entry->header.w_node_size;
  374. _sym_copy_entry( new_str_entry,
  375. next_str_entry,
  376. next_str_entry->header.w_node_size );
  377. new_str_entry->header.w_node_size = old_size;
  378. new_str_entry->obj_header.b_flags = sym_m_private | sym_m_builtin;
  379. new_str_entry->obj_header.az_name = NULL;
  380. new_str_entry->b_aux_flags |= sym_m_table_entry;
  381. /* link to the end of the compound string */
  382. *ptr = new_str_entry;
  383. ptr = (sym_value_entry_type * *)
  384. &(new_str_entry->az_next_table_value);
  385. }
  386. *ptr = NULL;
  387. }
  388. /*
  389. **++
  390. ** FUNCTIONAL DESCRIPTION:
  391. **
  392. ** This function concatenates 2 primitive strings.
  393. **
  394. ** FORMAL PARAMETERS:
  395. **
  396. ** az_str1_entry primitive string
  397. ** op1_temporary op1 is a temporary string
  398. ** az_str2_entry primitive string
  399. ** op2_temporary op2 is a temporary string
  400. **
  401. ** IMPLICIT INPUTS:
  402. **
  403. ** none
  404. **
  405. ** IMPLICIT OUTPUTS:
  406. **
  407. ** none
  408. **
  409. ** FUNCTION VALUE:
  410. **
  411. ** ptr to the result string
  412. **
  413. ** SIDE EFFECTS:
  414. **
  415. ** none
  416. **
  417. **--
  418. **/
  419. sym_value_entry_type
  420. *sem_cat_str_to_str
  421. (az_str1_entry, op1_temporary, az_str2_entry, op2_temporary)
  422. sym_value_entry_type *az_str1_entry;
  423. boolean op1_temporary;
  424. sym_value_entry_type *az_str2_entry;
  425. boolean op2_temporary;
  426. {
  427. sym_value_entry_type *new_str_entry;
  428. int l1, l2;
  429. /*
  430. ** Can only append two simple strings if they have the same direction and
  431. ** the first does not have the separate attribute.
  432. */
  433. _assert(((az_str1_entry->b_charset == az_str2_entry->b_charset)
  434. &&
  435. ((az_str1_entry->b_direction) == (az_str2_entry->b_direction))
  436. ),
  437. "strings with different attrs concatenated" );
  438. l1 = az_str1_entry->w_length;
  439. l2 = az_str2_entry->w_length;
  440. /* extra 1 is for terminating null */
  441. new_str_entry = (sym_value_entry_type *)
  442. sem_allocate_node( sym_k_value_entry,
  443. sym_k_value_entry_size );
  444. new_str_entry->value.c_value = XtCalloc(1, l1 + l2 + 1);
  445. new_str_entry->obj_header.b_flags = sym_m_builtin | sym_m_private;
  446. _sar_move_source_info_2 (&new_str_entry->header, &az_str1_entry->header);
  447. new_str_entry->b_charset = az_str1_entry->b_charset;
  448. new_str_entry->b_direction = az_str1_entry->b_direction;
  449. new_str_entry->b_aux_flags =
  450. (az_str1_entry->b_aux_flags & sym_m_separate);
  451. new_str_entry->b_type = sym_k_char_8_value;
  452. new_str_entry->w_length = l1 + l2;
  453. _move( new_str_entry->value.c_value,
  454. az_str1_entry->value.c_value, l1 );
  455. _move( &new_str_entry->value.c_value[ l1 ],
  456. az_str2_entry->value.c_value,
  457. l2+1 );
  458. /*
  459. ** if either of the operands is unnamed - free the node
  460. */
  461. if (op1_temporary)
  462. {
  463. _free_memory( az_str1_entry->value.c_value );
  464. sem_free_node(( sym_entry_type *) az_str1_entry );
  465. }
  466. if (op2_temporary)
  467. {
  468. _free_memory( az_str2_entry->value.c_value );
  469. sem_free_node(( sym_entry_type *) az_str2_entry );
  470. }
  471. return new_str_entry;
  472. }
  473. /*
  474. **++
  475. ** FUNCTIONAL DESCRIPTION:
  476. **
  477. ** This function takes the charset sets understood by the parser
  478. ** and maps them to charsets understood by the symbol table and
  479. ** toolkit.
  480. **
  481. ** FORMAL PARAMETERS:
  482. **
  483. ** charset_as_subclass sym_k_..._charset literal naming charset
  484. **
  485. ** IMPLICIT INPUTS:
  486. **
  487. ** none
  488. **
  489. ** IMPLICIT OUTPUTS:
  490. **
  491. ** none
  492. **
  493. ** FUNCTION VALUE:
  494. **
  495. ** sym_k...charset name for charset
  496. **
  497. ** SIDE EFFECTS:
  498. **
  499. ** none
  500. **
  501. **--
  502. **/
  503. int sem_map_subclass_to_charset(charset_as_subclass)
  504. int charset_as_subclass;
  505. {
  506. switch (charset_as_subclass)
  507. {
  508. case lex_k_fontlist_default_tag:
  509. case sym_k_fontlist_default_tag:
  510. return sym_k_fontlist_default_tag;
  511. case lex_k_default_charset:
  512. return uil_sym_default_charset;
  513. case lex_k_userdefined_charset:
  514. return sym_k_userdefined_charset;
  515. default:
  516. _assert (charset_as_subclass!=0, "charset code==0");
  517. _assert (charset_as_subclass<=uil_max_charset, "unknown charset");
  518. return charset_as_subclass;
  519. }
  520. }
  521. /*
  522. **++
  523. ** FUNCTIONAL DESCRIPTION:
  524. **
  525. ** This function verifies the character set indicated by the user.
  526. **
  527. ** FORMAL PARAMETERS:
  528. **
  529. ** current_frame current stack frame
  530. ** charset_frame stack frame of CHARSET token
  531. **
  532. ** IMPLICIT INPUTS:
  533. **
  534. ** none
  535. **
  536. ** IMPLICIT OUTPUTS:
  537. **
  538. ** none
  539. **
  540. ** FUNCTION VALUE:
  541. **
  542. ** none
  543. **
  544. ** SIDE EFFECTS:
  545. **
  546. ** none
  547. **
  548. **--
  549. **/
  550. void sar_charset_verify ( charset_frame )
  551. yystype *charset_frame;
  552. {
  553. key_keytable_entry_type *az_keyword_entry;
  554. _assert(((charset_frame->b_tag == sar_k_token_frame) ||
  555. (charset_frame->b_tag == sar_k_value_frame)),
  556. "token or value frame missing" );
  557. az_keyword_entry = charset_frame->value.az_keyword_entry;
  558. /*
  559. ** Store the current charset so it can be used by LEX to processes a
  560. ** string literal (if the CHARSET_NAME is used to prefix a string literal)
  561. */
  562. Uil_lex_l_literal_charset = az_keyword_entry->b_subclass;
  563. }
  564. /*
  565. **++
  566. ** FUNCTIONAL DESCRIPTION:
  567. **
  568. ** This function converts a random NAME into a CHARSET_NAME
  569. ** with the default charset.
  570. **
  571. ** FORMAL PARAMETERS:
  572. **
  573. ** name_frame current stack frame containing NAME
  574. **
  575. ** IMPLICIT INPUTS:
  576. **
  577. ** none
  578. **
  579. ** IMPLICIT OUTPUTS:
  580. **
  581. ** modified name_frame
  582. **
  583. ** FUNCTION VALUE:
  584. **
  585. ** none
  586. **
  587. ** SIDE EFFECTS:
  588. **
  589. ** name_frame converted from NAME to CHARSET_NAME
  590. **
  591. **--
  592. **/
  593. void sar_make_fallback_charset(name_frame)
  594. yystype *name_frame;
  595. {
  596. sym_name_entry_type *symbol_entry;
  597. static key_keytable_entry_type *az_keyword_entry = NULL;
  598. _assert(((name_frame->b_tag == sar_k_token_frame) ||
  599. (name_frame->b_tag == sar_k_value_frame)),
  600. "token or value frame missing" );
  601. /* Get symbol and check if already used as charset. */
  602. symbol_entry = (sym_name_entry_type *)name_frame->value.az_symbol_entry;
  603. if ((symbol_entry->b_flags & sym_m_charset) == 0)
  604. {
  605. symbol_entry->b_flags |= sym_m_charset;
  606. diag_issue_diagnostic(d_default_charset,
  607. _sar_source_pos2(symbol_entry),
  608. symbol_entry->c_text,
  609. DEFAULT_TAG);
  610. }
  611. /* Get the default charset keyword entry. */
  612. if (az_keyword_entry == NULL)
  613. az_keyword_entry = key_find_keyword(strlen(DEFAULT_TAG), DEFAULT_TAG);
  614. _assert((az_keyword_entry !=NULL), "default charset keyword missing");
  615. /* Change NAME to CHARSET_NAME */
  616. name_frame->value.az_keyword_entry = az_keyword_entry;
  617. name_frame ->b_type = az_keyword_entry->b_token;
  618. /*
  619. ** Store the current charset so it can be used by LEX to processes a
  620. ** string literal (if the NAME is used to prefix a string literal)
  621. */
  622. Uil_lex_l_literal_charset = az_keyword_entry->b_subclass;
  623. }
  624. /*
  625. **++
  626. ** FUNCTIONAL DESCRIPTION:
  627. **
  628. ** This function checks the attributes of CHARACTER_SET function.
  629. **
  630. ** FORMAL PARAMETERS:
  631. **
  632. ** target_frame pointer to resultant token stack frame
  633. ** value_frame pointer to frame holding keyword and value
  634. ** prior_value_frame pointer to previous properties
  635. **
  636. ** IMPLICIT INPUTS:
  637. **
  638. ** none
  639. **
  640. ** IMPLICIT OUTPUTS:
  641. **
  642. ** none
  643. **
  644. ** FUNCTION VALUE:
  645. **
  646. ** void
  647. **
  648. ** SIDE EFFECTS:
  649. **
  650. ** attribute information is stuffed in target frame
  651. **
  652. **--
  653. **/
  654. void sar_chk_charset_attr( target_frame, value_frame, prior_value_frame )
  655. yystype *target_frame;
  656. yystype *value_frame;
  657. yystype *prior_value_frame;
  658. {
  659. /*
  660. ** Set up not specified values in the target frame.
  661. ** b_type will hold the sixteen_bit property
  662. */
  663. switch (prior_value_frame->b_tag)
  664. {
  665. case sar_k_null_frame:
  666. /*
  667. ** no prior values
  668. */
  669. target_frame->b_tag = sar_k_token_frame;
  670. target_frame->b_direction = NOSTRING_DIRECTION;
  671. target_frame->b_charset = uil_sym_default_charset;
  672. target_frame->b_type = 0;
  673. break;
  674. case sar_k_token_frame:
  675. case sar_k_value_frame:
  676. /*
  677. ** prior values - transfer them
  678. */
  679. target_frame->b_tag = sar_k_token_frame;
  680. target_frame->b_direction = prior_value_frame->b_direction;
  681. target_frame->b_charset = prior_value_frame->b_charset;
  682. target_frame->b_type = prior_value_frame->b_type;
  683. break;
  684. default:
  685. _assert( FALSE, "prior value frame missing from stack" );
  686. }
  687. /*
  688. ** Case on the keyword for the attribute given
  689. */
  690. switch (value_frame->b_type)
  691. {
  692. case RIGHT_TO_LEFT:
  693. {
  694. sym_value_entry_type *value_entry;
  695. value_entry =
  696. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  697. /*
  698. ** If the value is a boolean, then just set the corresponding mask
  699. ** accordingly.
  700. */
  701. if (value_entry->b_type == sym_k_bool_value)
  702. if (value_entry->value.l_integer == TRUE)
  703. target_frame->b_direction = XmSTRING_DIRECTION_R_TO_L;
  704. else
  705. target_frame->b_direction = XmSTRING_DIRECTION_L_TO_R;
  706. break;
  707. }
  708. case SIXTEEN_BIT:
  709. {
  710. sym_value_entry_type *value_entry;
  711. value_entry =
  712. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  713. /*
  714. ** If the value is a boolean, then just set the corresponding mask
  715. ** accordingly.
  716. */
  717. if (value_entry->b_type == sym_k_bool_value)
  718. if (value_entry->value.l_integer == TRUE)
  719. target_frame->b_type |= sym_m_sixteen_bit;
  720. else
  721. target_frame->b_type &= ~sym_m_sixteen_bit;
  722. break;
  723. }
  724. default:
  725. _assert( FALSE, "keyword missing from stack" );
  726. }
  727. }
  728. /*
  729. **++
  730. ** FUNCTIONAL DESCRIPTION:
  731. **
  732. ** This function makes a CHARACTER_SET and sets the properties
  733. ** of the string.
  734. **
  735. ** FORMAL PARAMETERS:
  736. **
  737. ** target_frame pointer to resultant token stack frame
  738. ** value_frame pointer to string value
  739. ** attr_frame pointer to strings attributes
  740. ** keyword_frame frame to use as locator for result
  741. **
  742. ** IMPLICIT INPUTS:
  743. **
  744. ** none
  745. **
  746. ** IMPLICIT OUTPUTS:
  747. **
  748. ** none
  749. **
  750. ** FUNCTION VALUE:
  751. **
  752. ** void
  753. **
  754. ** SIDE EFFECTS:
  755. **
  756. ** none
  757. **
  758. **--
  759. **/
  760. void sar_make_charset (target_frame, value_frame, attr_frame, keyword_frame)
  761. yystype *target_frame;
  762. yystype *value_frame;
  763. yystype *attr_frame;
  764. yystype *keyword_frame;
  765. {
  766. sym_value_entry_type *value_entry;
  767. _assert( value_frame->b_tag == sar_k_value_frame,
  768. "value frame missing from stack" );
  769. /*
  770. ** Set the character set information into the symbol table
  771. ** entry for the char_8 string that indentifies the name of this
  772. ** userdefined character set.
  773. */
  774. value_entry =
  775. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  776. value_entry->b_charset = sym_k_userdefined_charset;
  777. /* BEGIN HaL fix CR 5547 */
  778. sem_evaluate_value (value_entry);
  779. if (value_entry->b_type != sym_k_char_8_value)
  780. diag_issue_diagnostic
  781. (d_wrong_type,
  782. _sar_source_pos2( value_entry ),
  783. diag_value_text( value_entry->b_type ),
  784. "null-terminated string");
  785. /* END HaL fix CR 5547 */
  786. /*
  787. ** If the attr_frame is not null, it must be a value frame with contains
  788. ** a pointer to the attributes frame for this userdefined charset.
  789. */
  790. if (attr_frame->b_tag == sar_k_token_frame)
  791. {
  792. /*
  793. ** Set the attributes of the string, as specified by the options
  794. ** to the CHARACTER_SET function, without disturbing any
  795. ** existing bits.
  796. */
  797. value_entry->b_direction = attr_frame->b_direction;
  798. value_entry->b_aux_flags = (attr_frame->b_type & sym_m_sixteen_bit);
  799. }
  800. /*
  801. ** initialize the target frame
  802. */
  803. _sar_move_source_info( target_frame, keyword_frame );
  804. target_frame->b_tag = sar_k_value_frame;
  805. target_frame->b_type = sym_k_char_8_value;
  806. target_frame->b_flags = sym_m_private;
  807. target_frame->value.az_symbol_entry = value_frame->value.az_symbol_entry;
  808. /*
  809. ** Store the current charset so it can be used by LEX to processes a
  810. ** string literal (if the CHARACTER_SET function is used to prefix a
  811. ** string literal)
  812. */
  813. Uil_lex_l_literal_charset = lex_k_userdefined_charset;
  814. Uil_lex_az_literal_charset = value_entry;
  815. }