2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
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.
35 static char rcsid[] = "$TOG: UilSarInc.c /main/12 1997/03/12 15:21:31 dbl $"
40 * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
46 ** User Interface Language Compiler (UIL)
50 ** This module contain the routines for processing the INCLUDE construct.
68 ** DEFINE and MACRO DEFINITIONS
75 ** EXTERNAL VARIABLE DECLARATIONS
83 ** GLOBAL VARIABLE DECLARATIONS
91 ** OWN VARIABLE DECLARATIONS
98 ** FUNCTIONAL DESCRIPTION:
100 ** This routine handles the include directive.
102 ** FORMAL PARAMETERS:
104 ** file_frame parser stack frame that contains the name of the
105 ** file to be included.
126 void sar_include_file ( file_frame, include_frame, semi_frame )
128 yystype * file_frame;
129 yystype * include_frame;
130 yystype * semi_frame;
133 sym_value_entry_type * value_entry;
134 sym_include_file_entry_type * include_entry;
135 sym_section_entry_type * section_entry;
136 sym_section_entry_type * section_tail_entry;
142 (sym_value_entry_type *) file_frame -> value . az_symbol_entry;
145 * Fix for CR 5465 - If the value_entry is not of type char_8, print an
146 * error message and abort the compilation
148 if ((value_entry->b_type != sym_k_char_8_value) &&
149 (value_entry->b_type != sym_k_localized_string_value))
150 diag_issue_diagnostic (
152 _sar_source_pos2(value_entry));
154 * End Fix for CR 5465
157 * If the direction is RtoL then reverse the include file.
159 if (value_entry->b_direction == XmSTRING_DIRECTION_R_TO_L)
162 ** Just reverse the bytes from the first to last
164 for (i=0, j=value_entry->w_length-1;
165 i < (int)((int)value_entry->w_length>>1);
168 tmp1 = value_entry->value.c_value[ i ];
169 value_entry->value.c_value[ i ] =
170 value_entry->value.c_value[ j ];
171 value_entry->value.c_value[ j ] = tmp1;
175 _assert (value_entry -> header . b_tag == sym_k_value_entry,
176 "missing value entry for include");
179 ** Allocate an INCLUDE entry
182 include_entry = (sym_include_file_entry_type *) sem_allocate_node
183 ( sym_k_include_file_entry, sym_k_include_file_entry_size );
186 ** Open the include file. Set up a null-terminated name string.
189 buffer = (char *) _get_memory (value_entry -> w_length + 1);
190 _move (buffer, value_entry -> value . c_value,
191 value_entry -> w_length);
192 buffer [value_entry -> w_length] = 0 ;
194 src_open_file (buffer, include_entry->full_file_name);
197 ** Allocate a section entry for this include "section".
198 ** Store the source info in it
201 section_entry = (sym_section_entry_type *) sem_allocate_node
202 ( sym_k_section_entry, sym_k_section_entry_size );
204 section_entry->header.b_type = sym_k_include_section;
206 _sar_save_source_info ( §ion_entry->header , include_frame , semi_frame );
209 ** Link this section into the current section list.
212 section_entry->next = (sym_entry_type *) sym_az_current_section_entry;
213 section_entry->prev_section = sym_az_current_section_entry->prev_section;
214 sym_az_current_section_entry = section_entry;
217 ** Link the include intry we created earlier onto the section list
220 section_entry->entries = (sym_entry_type *)include_entry;
223 ** Save the file name
226 _move (include_entry->file_name, buffer, value_entry->w_length);
227 include_entry->file_name [value_entry->w_length] = 0;
230 ** Since this is an INCLUDE we want included sections to hang off
231 ** of it so we create a new place holder entry (tail) and change the
232 ** "current" section list to it.
235 section_tail_entry = (sym_section_entry_type *) sem_allocate_node
236 ( sym_k_section_entry, sym_k_section_entry_size );
238 section_tail_entry->header.b_type = sym_k_section_tail;
240 include_entry->sections = section_tail_entry;
242 section_tail_entry->prev_section = sym_az_current_section_entry;
243 sym_az_current_section_entry = section_tail_entry;
245 _free_memory (buffer);