Blame clients/uil/UilSarInc.c

Packit b099d7
/* 
Packit b099d7
 * Motif
Packit b099d7
 *
Packit b099d7
 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are free software; you can
Packit b099d7
 * redistribute them and/or modify them under the terms of the GNU
Packit b099d7
 * Lesser General Public License as published by the Free Software
Packit b099d7
 * Foundation; either version 2 of the License, or (at your option)
Packit b099d7
 * any later version.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are distributed in the hope that
Packit b099d7
 * they will be useful, but WITHOUT ANY WARRANTY; without even the
Packit b099d7
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Packit b099d7
 * PURPOSE. See the GNU Lesser General Public License for more
Packit b099d7
 * details.
Packit b099d7
 *
Packit b099d7
 * You should have received a copy of the GNU Lesser General Public
Packit b099d7
 * License along with these librararies and programs; if not, write
Packit b099d7
 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
Packit b099d7
 * Floor, Boston, MA 02110-1301 USA
Packit b099d7
*/ 
Packit b099d7
/* 
Packit b099d7
 * HISTORY
Packit b099d7
*/ 
Packit b099d7
#ifdef REV_INFO
Packit b099d7
#ifndef lint
Packit b099d7
static char rcsid[] = "$TOG: UilSarInc.c /main/12 1997/03/12 15:21:31 dbl $"
Packit b099d7
#endif
Packit b099d7
#endif
Packit b099d7
Packit b099d7
#ifdef HAVE_CONFIG_H
Packit b099d7
#include <config.h>
Packit b099d7
#endif
Packit b099d7
Packit b099d7
Packit b099d7
/*
Packit b099d7
*  (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
Packit b099d7
Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FACILITY:
Packit b099d7
**
Packit b099d7
**      User Interface Language Compiler (UIL)
Packit b099d7
**
Packit b099d7
**  ABSTRACT:
Packit b099d7
**
Packit b099d7
**      This module contain the routines for processing the INCLUDE construct.
Packit b099d7
**
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  INCLUDE FILES
Packit b099d7
**
Packit b099d7
**/
Packit b099d7
Packit b099d7
#include <Xm/Xm.h>
Packit b099d7
#include "UilDefI.h"
Packit b099d7
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  DEFINE and MACRO DEFINITIONS
Packit b099d7
**
Packit b099d7
**/
Packit b099d7
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  EXTERNAL VARIABLE DECLARATIONS
Packit b099d7
**
Packit b099d7
**/
Packit b099d7
Packit b099d7
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  GLOBAL VARIABLE DECLARATIONS
Packit b099d7
**
Packit b099d7
**/
Packit b099d7
Packit b099d7
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  OWN VARIABLE DECLARATIONS
Packit b099d7
**
Packit b099d7
**/
Packit b099d7
Packit b099d7

Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FUNCTIONAL DESCRIPTION:
Packit b099d7
**
Packit b099d7
**      This routine handles the include directive.
Packit b099d7
**
Packit b099d7
**  FORMAL PARAMETERS:
Packit b099d7
**
Packit b099d7
**      file_frame	parser stack frame that contains the name of the
Packit b099d7
**			file to be included.
Packit b099d7
**
Packit b099d7
**  IMPLICIT INPUTS:
Packit b099d7
**
Packit b099d7
**      none
Packit b099d7
**
Packit b099d7
**  IMPLICIT OUTPUTS:
Packit b099d7
**
Packit b099d7
**      none
Packit b099d7
**
Packit b099d7
**  FUNCTION VALUE:
Packit b099d7
**
Packit b099d7
**      void
Packit b099d7
**
Packit b099d7
**  SIDE EFFECTS:
Packit b099d7
**
Packit b099d7
**      none
Packit b099d7
**
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
void	sar_include_file ( file_frame, include_frame, semi_frame )
Packit b099d7
Packit b099d7
yystype	    * file_frame;
Packit b099d7
yystype	    * include_frame;
Packit b099d7
yystype	    * semi_frame;
Packit b099d7
Packit b099d7
{
Packit b099d7
    sym_value_entry_type	* value_entry;
Packit b099d7
    sym_include_file_entry_type	* include_entry;
Packit b099d7
    sym_section_entry_type	* section_entry;
Packit b099d7
    sym_section_entry_type	* section_tail_entry;
Packit b099d7
    char			* buffer;
Packit b099d7
    unsigned char		  tmp1;
Packit b099d7
    int				  i,j;
Packit b099d7
Packit b099d7
    value_entry =
Packit b099d7
	(sym_value_entry_type *) file_frame -> value . az_symbol_entry;
Packit b099d7
Packit b099d7
/*
Packit b099d7
 * Fix for CR 5465 - If the value_entry is not of type char_8, print an 
Packit b099d7
 *                   error message and abort the compilation
Packit b099d7
 */
Packit b099d7
    if ((value_entry->b_type != sym_k_char_8_value) &&
Packit b099d7
	(value_entry->b_type != sym_k_localized_string_value))
Packit b099d7
      diag_issue_diagnostic (
Packit b099d7
             d_include_file,
Packit b099d7
             _sar_source_pos2(value_entry));
Packit b099d7
/*
Packit b099d7
 * End Fix for CR 5465
Packit b099d7
 */
Packit b099d7
/*
Packit b099d7
 * If the direction is RtoL then reverse the include file.
Packit b099d7
 */
Packit b099d7
    if (value_entry->b_direction == XmSTRING_DIRECTION_R_TO_L) 
Packit b099d7
	{
Packit b099d7
	/*
Packit b099d7
	**  Just reverse the bytes from the first to last
Packit b099d7
	*/
Packit b099d7
	for (i=0, j=value_entry->w_length-1;  
Packit b099d7
	     i < (int)((int)value_entry->w_length>>1);  
Packit b099d7
	     i++,j--)
Packit b099d7
	    {
Packit b099d7
	    tmp1 = value_entry->value.c_value[ i ];
Packit b099d7
	    value_entry->value.c_value[ i ] = 
Packit b099d7
		value_entry->value.c_value[ j ];
Packit b099d7
	    value_entry->value.c_value[ j ] = tmp1;
Packit b099d7
	    }
Packit b099d7
	}
Packit b099d7
Packit b099d7
    _assert (value_entry -> header . b_tag == sym_k_value_entry,
Packit b099d7
	     "missing value entry for include");
Packit b099d7
Packit b099d7
    /*
Packit b099d7
    ** Allocate an INCLUDE entry
Packit b099d7
    */
Packit b099d7
Packit b099d7
    include_entry = (sym_include_file_entry_type *) sem_allocate_node
Packit b099d7
			( sym_k_include_file_entry, sym_k_include_file_entry_size );
Packit b099d7
Packit b099d7
    /*
Packit b099d7
    ** Open the include file.  Set up a null-terminated name string.
Packit b099d7
    */
Packit b099d7
Packit b099d7
    buffer = (char *) _get_memory (value_entry -> w_length + 1);
Packit b099d7
    _move (buffer, value_entry -> value . c_value,
Packit b099d7
		   value_entry -> w_length);
Packit b099d7
    buffer [value_entry -> w_length] = 0 ;
Packit b099d7
Packit b099d7
    src_open_file (buffer, include_entry->full_file_name);
Packit b099d7
Packit b099d7
    /*
Packit b099d7
    **  Allocate a section entry for this include "section".
Packit b099d7
    **  Store the source info in it
Packit b099d7
    */
Packit b099d7
Packit b099d7
    section_entry = (sym_section_entry_type *) sem_allocate_node
Packit b099d7
			( sym_k_section_entry, sym_k_section_entry_size );
Packit b099d7
Packit b099d7
    section_entry->header.b_type = sym_k_include_section;
Packit b099d7
Packit b099d7
    _sar_save_source_info ( &section_entry->header , include_frame , semi_frame );
Packit b099d7
Packit b099d7
    /*
Packit b099d7
    ** Link this section into the current section list.
Packit b099d7
    */
Packit b099d7
Packit b099d7
    section_entry->next = (sym_entry_type *) sym_az_current_section_entry;
Packit b099d7
    section_entry->prev_section = sym_az_current_section_entry->prev_section;
Packit b099d7
    sym_az_current_section_entry = section_entry;
Packit b099d7
Packit b099d7
    /*
Packit b099d7
    ** Link the include intry we created earlier onto the section list
Packit b099d7
    */
Packit b099d7
Packit b099d7
    section_entry->entries = (sym_entry_type *)include_entry;
Packit b099d7
Packit b099d7
    /*
Packit b099d7
    **  Save the file name
Packit b099d7
    */
Packit b099d7
Packit b099d7
    _move (include_entry->file_name, buffer, value_entry->w_length);
Packit b099d7
    include_entry->file_name [value_entry->w_length] =  0;
Packit b099d7
Packit b099d7
    /*
Packit b099d7
    ** Since this is an INCLUDE we want included sections to hang off
Packit b099d7
    ** of it so we create a new place holder entry (tail) and change the
Packit b099d7
    ** "current" section list to it.
Packit b099d7
    */
Packit b099d7
Packit b099d7
    section_tail_entry = (sym_section_entry_type *) sem_allocate_node
Packit b099d7
			    ( sym_k_section_entry, sym_k_section_entry_size );
Packit b099d7
Packit b099d7
    section_tail_entry->header.b_type = sym_k_section_tail;
Packit b099d7
Packit b099d7
    include_entry->sections = section_tail_entry;
Packit b099d7
Packit b099d7
    section_tail_entry->prev_section = sym_az_current_section_entry;
Packit b099d7
    sym_az_current_section_entry = section_tail_entry;
Packit b099d7
Packit b099d7
    _free_memory (buffer);
Packit b099d7
Packit b099d7
}