Blame clients/uil/UilMain.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[] = "$XConsortium: UilMain.c /main/14 1996/06/03 15:49:20 pascale $"
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 is the main procedure of the UIL Compiler.
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 <X11/Xlocale.h>
Packit b099d7
/* Sun's locale.h defines ON && OFF, which is also defined in UilLexPars.h */
Packit b099d7
#ifdef ON
Packit b099d7
#undef ON
Packit b099d7
#endif
Packit b099d7
#ifdef OFF
Packit b099d7
#undef OFF
Packit b099d7
#endif
Packit b099d7
#ifndef X_NOT_STDC_ENV
Packit b099d7
#include <stdlib.h>
Packit b099d7
#endif
Packit b099d7
#include "UilDefI.h"
Packit b099d7
#include <setjmp.h>
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  TABLE OF CONTENTS
Packit b099d7
**
Packit b099d7
*/
Packit b099d7
Packit b099d7
/*
Packit b099d7
** FORWARD DECLARATIONS
Packit b099d7
*/
Packit b099d7
Packit b099d7
Packit b099d7
extern int main  _ARGUMENTS(( int l_argc , char *rac_argv []));
Packit b099d7
Packit b099d7
static void common_main  _ARGUMENTS(( void ));
Packit b099d7
static void common_cleanup  _ARGUMENTS(( void ));
Packit b099d7
Packit b099d7
#ifdef CALLABLE
Packit b099d7
static void UilWrapup _ARGUMENTS((Uil_compile_desc_type *compile_desc));
Packit b099d7
#endif	/* CALLABLE */
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  EXTERNAL Definitions
Packit b099d7
**
Packit b099d7
*/
Packit b099d7
Packit b099d7
Packit b099d7
#ifndef NO_MESSAGE_CATALOG
Packit b099d7
#include <nl_types.h>
Packit b099d7
#if !defined(NL_CAT_LOCALE)
Packit b099d7
#define NL_CAT_LOCALE	0
Packit b099d7
#endif
Packit b099d7
Packit b099d7
externaldef(uilmsg) nl_catd uil_catd = NULL;
Packit b099d7
Packit b099d7
#endif
Packit b099d7
Packit b099d7
/*
Packit b099d7
**
Packit b099d7
**  MODULE Definitions
Packit b099d7
**
Packit b099d7
*/
Packit b099d7
Packit b099d7
static status      return_status = 0;
Packit b099d7
static jmp_buf     environment;
Packit b099d7
static unsigned    module_flags = 0;
Packit b099d7
static unsigned	   doing_exit = 0;
Packit b099d7
Packit b099d7
/*  Bit definitions for module_flags */
Packit b099d7
Packit b099d7
#define     compiler_called (1 << 0)
Packit b099d7
Packit b099d7

Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FUNCTIONAL DESCRIPTION:
Packit b099d7
**
Packit b099d7
**      This is the common part of the main routine.
Packit b099d7
**
Packit b099d7
**  FORMAL PARAMETERS:
Packit b099d7
**
Packit b099d7
**      none
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
**      compilation occurs
Packit b099d7
**
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
static void	common_main()
Packit b099d7
{
Packit b099d7
#ifndef NO_MESSAGE_CATALOG
Packit b099d7
  if (uil_catd == NULL)
Packit b099d7
    uil_catd = catopen("Uil", NL_CAT_LOCALE);
Packit b099d7
#endif
Packit b099d7
Packit b099d7
  /* Initialize the X toolkit. */
Packit b099d7
  XtToolkitInitialize(); 
Packit b099d7
  
Packit b099d7
    /* use the user supplied data base instead */
Packit b099d7
    if (Uil_cmd_z_command.v_database)
Packit b099d7
	db_incorporate();
Packit b099d7
Packit b099d7
    /* initialize the diagnostic system */
Packit b099d7
    diag_initialize_diagnostics();
Packit b099d7
Packit b099d7
    /* initialize the symbol table */
Packit b099d7
    sym_initialize_storage();
Packit b099d7
Packit b099d7
    /* initialize the source */
Packit b099d7
    src_initialize_source();
Packit b099d7
Packit b099d7
    /* open listing file if requested */
Packit b099d7
    if (Uil_cmd_z_command.v_listing_file)
Packit b099d7
	lst_open_listing();
Packit b099d7
Packit b099d7
    /* initialize the lexical analyzer */
Packit b099d7
    lex_initialize_analyzer();
Packit b099d7
Packit b099d7
    /* initialize the keyword table */
Packit b099d7
    key_initialize();
Packit b099d7
Packit b099d7
    /* initialize the sar data structures */
Packit b099d7
    sar_initialize();
Packit b099d7
Packit b099d7
    /* call YACC to parse the source file */
Packit b099d7
    /* return 0 for success, 1 for failure */
Packit b099d7
    /* Make sure the root entry sections pointer is filled in */
Packit b099d7
    if (yyparse() != 0)
Packit b099d7
    	diag_issue_diagnostic
Packit b099d7
	    (d_inv_module, diag_k_no_source, diag_k_no_column);
Packit b099d7
    sym_az_root_entry->sections = sym_az_current_section_entry;
Packit b099d7
Packit b099d7
    /* call forward reference resolver */
Packit b099d7
    sem_resolve_forward_refs();
Packit b099d7
Packit b099d7
    /* call semantic validation */
Packit b099d7
    sem_validation ();
Packit b099d7
Packit b099d7
    /* call the output phase if requested */
Packit b099d7
    if (Uil_cmd_z_command.v_resource_file)
Packit b099d7
	sem_output_uid_file();
Packit b099d7
Packit b099d7
    /* call symbol table dumper - if requested */
Packit b099d7
#if debug_version
Packit b099d7
    if (uil_v_dump_symbols == TRUE)
Packit b099d7
	sym_dump_symbols();
Packit b099d7
#endif
Packit b099d7
Packit b099d7
Packit b099d7
    /* write compilation summary */
Packit b099d7
    diag_issue_summary();
Packit b099d7
Packit b099d7
Packit b099d7
    /* write listing file if requested */
Packit b099d7
    if (Uil_cmd_z_command.v_listing_file)
Packit b099d7
	lst_output_listing();
Packit b099d7
Packit b099d7
    /* Storage is not cleaned up, since we will exit */
Packit b099d7
    uil_exit( uil_l_compile_status );
Packit b099d7
Packit b099d7
}
Packit b099d7
Packit b099d7

Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FUNCTIONAL DESCRIPTION:
Packit b099d7
**
Packit b099d7
**      This is the image termination procedure for the UIL compiler.
Packit b099d7
**
Packit b099d7
**  FORMAL PARAMETERS:
Packit b099d7
**
Packit b099d7
**      severity	status of compilation on exit
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
**      never return from this procedure
Packit b099d7
**
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
void	uil_exit(severity)
Packit b099d7
Packit b099d7
int	severity;
Packit b099d7
Packit b099d7
{
Packit b099d7
Packit b099d7
Packit b099d7
Packit b099d7
Packit b099d7
    /* Prevent multiple looping through this routine */
Packit b099d7
    if ( doing_exit ) return;
Packit b099d7
    doing_exit = 1;
Packit b099d7
Packit b099d7
    return_status = (severity >= uil_k_error_status);
Packit b099d7
Packit b099d7
    /* Close and remove the uid file if it's still open. */
Packit b099d7
    /* It will only be open if a severe error occurred during the output */
Packit b099d7
    /* of the uid file. */
Packit b099d7
Packit b099d7
    if (out_az_idbfile_id != NULL)
Packit b099d7
	UrmIdbCloseFile (out_az_idbfile_id, FALSE);
Packit b099d7
Packit b099d7
    /* If compiler called, return to calling program rather than */
Packit b099d7
    /* exiting process */
Packit b099d7
Packit b099d7
    if (module_flags & compiler_called)
Packit b099d7
        longjmp (environment, 1);
Packit b099d7
Packit b099d7
    /* RAP FIX for listing files */
Packit b099d7
    common_cleanup();
Packit b099d7
Packit b099d7
Packit b099d7
    exit(return_status);
Packit b099d7
}
Packit b099d7
Packit b099d7

Packit b099d7
Packit b099d7
Packit b099d7

Packit b099d7
Packit b099d7
#ifndef CALLABLE
Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FUNCTIONAL DESCRIPTION:
Packit b099d7
**
Packit b099d7
**      This is the main routine
Packit b099d7
**
Packit b099d7
**  FORMAL PARAMETERS:
Packit b099d7
**
Packit b099d7
**      l_argc:	    the number of command line arguments
Packit b099d7
**	rac_argv:   an array of pointers to character array arguments
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
**  COMPLETION CODES:
Packit b099d7
**
Packit b099d7
**      1 if errors; 0 otherwise
Packit b099d7
**
Packit b099d7
**  SIDE EFFECTS:
Packit b099d7
**
Packit b099d7
**	produce possibly a resource file and a listing file
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
int	main( l_argc, rac_argv )
Packit b099d7
int	l_argc;
Packit b099d7
char	*rac_argv[ ];
Packit b099d7
{
Packit b099d7
    
Packit b099d7
    setlocale(LC_ALL, "");
Packit b099d7
Packit b099d7
    /* call routine to parse the command line */
Packit b099d7
Packit b099d7
    cmd_decode_command_line( l_argc, rac_argv );
Packit b099d7
Packit b099d7
    /* call common main routine */
Packit b099d7
Packit b099d7
    common_main();
Packit b099d7
Packit b099d7
    return 0;    /* make compiler happy */
Packit b099d7
}
Packit b099d7
#endif /* !CALLABLE */
Packit b099d7
Packit b099d7
Packit b099d7

Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FUNCTIONAL DESCRIPTION:
Packit b099d7
**
Packit b099d7
**      This is the dynamic memory cleanup routine.  It calls all facility
Packit b099d7
**	provided cleanup routines so that dynamic structures can be released.
Packit b099d7
**
Packit b099d7
**  FORMAL PARAMETERS:
Packit b099d7
**
Packit b099d7
**      none
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
**      all dynamic memory is freed 
Packit b099d7
**
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
static void	common_cleanup()
Packit b099d7
{
Packit b099d7
Packit b099d7
    /* cleanup the source file information */
Packit b099d7
Packit b099d7
    Uil_src_cleanup_source();
Packit b099d7
Packit b099d7
Packit b099d7
    /* cleanup listing facility */
Packit b099d7
Packit b099d7
    Uil_lst_cleanup_listing();
Packit b099d7
Packit b099d7
Packit b099d7
    /* cleanup the lexical analyzer */
Packit b099d7
Packit b099d7
    Uil_lex_cleanup_analyzer();
Packit b099d7
Packit b099d7
Packit b099d7
    return;
Packit b099d7
}
Packit b099d7
Packit b099d7

Packit b099d7
#ifdef CALLABLE
Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FUNCTIONAL DESCRIPTION:
Packit b099d7
**
Packit b099d7
**      This is the callable entry point for the UIL Compiler. 
Packit b099d7
**
Packit b099d7
**  FORMAL PARAMETERS:
Packit b099d7
**
Packit b099d7
**      command_desc    pointer to data structure defining UIL command line
Packit b099d7
**
Packit b099d7
**	compile_desc	pointer to data structure describing the results of
Packit b099d7
**			the compilation.
Packit b099d7
**
Packit b099d7
**	message_cb	callback routine to process messages
Packit b099d7
**
Packit b099d7
**	message_data	user-data passed to the message_cb
Packit b099d7
**
Packit b099d7
**	status_cb	callback routine to process messages
Packit b099d7
**
Packit b099d7
**	status_data	user-data passed to the status_cb
Packit b099d7
**
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
**  COMPLETION CODES:
Packit b099d7
**
Packit b099d7
**      uil$_normal if no errors; uil$_no_output otherwise
Packit b099d7
**
Packit b099d7
**  SIDE EFFECTS:
Packit b099d7
**
Packit b099d7
**	    none
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
Packit b099d7
Uil_status_type Uil 
Packit b099d7
Packit b099d7
(Uil_command_type        *command_desc,
Packit b099d7
Uil_compile_desc_type   *compile_desc,
Packit b099d7
Uil_continue_type       (*message_cb)(),
Packit b099d7
char            *message_data,
Packit b099d7
Uil_continue_type       (*status_cb)(),
Packit b099d7
char            *status_data)
Packit b099d7
Packit b099d7
Packit b099d7
{
Packit b099d7
Packit b099d7
    /* Indicate compiler called rather than being started via command line */
Packit b099d7
Packit b099d7
    module_flags = module_flags | compiler_called;
Packit b099d7
    doing_exit = 0;
Packit b099d7
Packit b099d7
Packit b099d7
    /* Initialize command line data structure */
Packit b099d7
Packit b099d7
    Uil_cmd_z_command.ac_database = command_desc -> database;
Packit b099d7
    Uil_cmd_z_command.v_database = command_desc -> database_flag;
Packit b099d7
    Uil_cmd_z_command.ac_source_file = command_desc -> source_file;
Packit b099d7
    Uil_cmd_z_command.ac_resource_file = command_desc -> resource_file;
Packit b099d7
    Uil_cmd_z_command.ac_listing_file = command_desc -> listing_file;
Packit b099d7
    Uil_cmd_z_command.include_dir_count = command_desc -> include_dir_count;
Packit b099d7
    Uil_cmd_z_command.ac_include_dir = command_desc -> include_dir;
Packit b099d7
    Uil_cmd_z_command.v_listing_file = command_desc -> listing_file_flag;
Packit b099d7
    Uil_cmd_z_command.v_resource_file = command_desc -> resource_file_flag;
Packit b099d7
    Uil_cmd_z_command.v_show_machine_code = command_desc -> machine_code_flag;
Packit b099d7
    Uil_cmd_z_command.v_report_info_msg = command_desc -> report_info_msg_flag;
Packit b099d7
    Uil_cmd_z_command.v_report_warn_msg = command_desc -> report_warn_msg_flag;
Packit b099d7
    Uil_cmd_z_command.v_parse_tree = command_desc -> parse_tree_flag;
Packit b099d7
    Uil_cmd_z_command.v_use_setlocale = command_desc -> use_setlocale_flag;
Packit b099d7
    Uil_cmd_z_command.v_issue_summary = command_desc -> issue_summary;
Packit b099d7
    Uil_cmd_z_command.status_update_delay = command_desc -> status_update_delay;
Packit b099d7
    Uil_cmd_z_command.message_cb = message_cb;
Packit b099d7
    Uil_cmd_z_command.message_data = message_data;
Packit b099d7
    Uil_cmd_z_command.status_cb = status_cb;
Packit b099d7
    Uil_cmd_z_command.status_data = status_data;
Packit b099d7
Packit b099d7
    /* The setjmp function allows us to unwind from a fatal error setjmp is */
Packit b099d7
    /* nonzero if we are returning from a fatal error			    */
Packit b099d7
Packit b099d7
        if (setjmp(environment) == 0) {
Packit b099d7
    
Packit b099d7
	    /* use the user supplied data base instead. If no source file
Packit b099d7
	       is given (this call is only to change the database), return at
Packit b099d7
	       this point with a success. */
Packit b099d7
	    if ( Uil_cmd_z_command.v_database )
Packit b099d7
		{
Packit b099d7
		db_incorporate ();
Packit b099d7
		if ( Uil_cmd_z_command.ac_source_file == NULL )
Packit b099d7
		    uil_exit (uil_k_success_status);
Packit b099d7
		}
Packit b099d7
Packit b099d7
            /* initialize the diagnostic system */
Packit b099d7
	    uil_l_compile_status = uil_k_success_status;
Packit b099d7
            diag_initialize_diagnostics();
Packit b099d7
    
Packit b099d7
            /* initialize the symbol table */
Packit b099d7
            sym_initialize_storage();
Packit b099d7
    
Packit b099d7
            /* initialize the source */
Packit b099d7
            src_initialize_source();
Packit b099d7
    
Packit b099d7
            /* open listing file if requested */
Packit b099d7
            if (Uil_cmd_z_command.v_listing_file)
Packit b099d7
            	lst_open_listing();
Packit b099d7
Packit b099d7
            /* initialize the lexical analyzer */
Packit b099d7
            lex_initialize_analyzer();
Packit b099d7
    
Packit b099d7
            /* initialize the keyword table */
Packit b099d7
            key_initialize();
Packit b099d7
    
Packit b099d7
	    /* initialize the sar data structures */
Packit b099d7
	    sar_initialize();
Packit b099d7
Packit b099d7
	    /* call YACC to parse the source file */
Packit b099d7
            /* return 0 for success, 1 for failure */
Packit b099d7
	    /* Make sure the root entry sections pointer is filled in */
Packit b099d7
            if (yyparse() != 0)
Packit b099d7
            	diag_issue_diagnostic
Packit b099d7
        	    (d_inv_module, diag_k_no_source, diag_k_no_column);
Packit b099d7
	    sym_az_root_entry->sections = sym_az_current_section_entry;
Packit b099d7
    
Packit b099d7
            /* call forward reference resolver */
Packit b099d7
            sem_resolve_forward_refs();
Packit b099d7
        
Packit b099d7
	    /* call semantic validation */
Packit b099d7
	    sem_validation ();
Packit b099d7
Packit b099d7
            /* call the output phase if requested */
Packit b099d7
            if (Uil_cmd_z_command.v_resource_file)
Packit b099d7
            	sem_output_uid_file();
Packit b099d7
Packit b099d7
            /* call symbol table dumper - if requested */
Packit b099d7
#if debug_version
Packit b099d7
		if (uil_v_dump_symbols == TRUE)
Packit b099d7
		    sym_dump_symbols();
Packit b099d7
#endif
Packit b099d7
Packit b099d7
	    /* Perform standard wrapup processing */
Packit b099d7
	    UilWrapup (compile_desc);
Packit b099d7
    
Packit b099d7
/*
Packit b099d7
 * Fix for CR 5534 - call the routine to restore the old signal handlers
Packit b099d7
 */
Packit b099d7
            diag_restore_diagnostics();
Packit b099d7
/*
Packit b099d7
 * End Fix for CR 5534 
Packit b099d7
 */
Packit b099d7
Packit b099d7
	    /* exit with the compile status */
Packit b099d7
	    return uil_l_compile_status;
Packit b099d7
Packit b099d7
            }
Packit b099d7
Packit b099d7
	/*
Packit b099d7
	**  longjmp return from setjmp.  This is the case of a return via 
Packit b099d7
	**  uil_exit the value return_status is set by uil_exit.
Packit b099d7
	*/
Packit b099d7
        else
Packit b099d7
	    {
Packit b099d7
	    /* Do standard compiler wrapup */
Packit b099d7
	    UilWrapup (compile_desc);
Packit b099d7
Packit b099d7
	    /* return the status set by uil_exit */
Packit b099d7
	    return uil_l_compile_status;
Packit b099d7
Packit b099d7
	    }
Packit b099d7
Packit b099d7
}
Packit b099d7
Packit b099d7
/*
Packit b099d7
 * Local function to provide compiler wrapup processing. It is called both
Packit b099d7
 * from the longjmp and sequential paths in the callable compiler above.
Packit b099d7
 */
Packit b099d7
static void UilWrapup (compile_desc)
Packit b099d7
    Uil_compile_desc_type	*compile_desc;
Packit b099d7
Packit b099d7
{
Packit b099d7
Packit b099d7
    int i;  /* loop index for copying message counts		    */
Packit b099d7
Packit b099d7
    /* write compilation summary if requested */
Packit b099d7
    if ( Uil_cmd_z_command.v_issue_summary )
Packit b099d7
	diag_issue_summary();
Packit b099d7
    
Packit b099d7
    /* write listing file if requested */
Packit b099d7
    if (Uil_cmd_z_command.v_listing_file)
Packit b099d7
	lst_output_listing();
Packit b099d7
Packit b099d7
    /*
Packit b099d7
     ** fill in the "parse tree root" in the compile descriptor,
Packit b099d7
     ** and set the version for the compiler and the symbol table
Packit b099d7
     ** structure.
Packit b099d7
     */
Packit b099d7
    compile_desc->parse_tree_root = (char *)sym_az_root_entry;
Packit b099d7
    compile_desc->data_version = _data_version;
Packit b099d7
    compile_desc->compiler_version = _compiler_version_int;
Packit b099d7
Packit b099d7
    /* Fill in the message_summary array in the compile_desc */
Packit b099d7
    for (i = uil_k_min_status; i <= uil_k_max_status; i++)
Packit b099d7
	compile_desc->message_count[i] = Uil_message_count[i];
Packit b099d7
Packit b099d7
    /* If there are any error/severe messages, then don't return */
Packit b099d7
    /* a symbol table for the callable compiler - clean up here */
Packit b099d7
    if ( Uil_message_count[Uil_k_error_status]>0 ||
Packit b099d7
	 Uil_message_count[Uil_k_severe_status]>0 )
Packit b099d7
	{
Packit b099d7
	Uil_cmd_z_command.v_parse_tree = FALSE;
Packit b099d7
	compile_desc->parse_tree_root = NULL;
Packit b099d7
	}
Packit b099d7
Packit b099d7
    /* Call the cleanup routine to free dynamic memory */
Packit b099d7
    common_cleanup();
Packit b099d7
    
Packit b099d7
    /* Cleanup storage; what is cleaned up depends on whether compiler	*/
Packit b099d7
    /* was called or not						*/
Packit b099d7
    Uil_sym_cleanup_storage (Uil_cmd_z_command.v_parse_tree!=1);    
Packit b099d7
Packit b099d7
    }
Packit b099d7
Packit b099d7
#endif	/* CALLABLE */
Packit b099d7
Packit b099d7
#ifdef NO_MEMMOVE
Packit b099d7
Packit b099d7
/*
Packit b099d7
**++
Packit b099d7
**  FUNCTIONAL DESCRIPTION:
Packit b099d7
**
Packit b099d7
**      This is a memmove function that explicitly handles
Packit b099d7
**      overlapping memory areas.  Written in response to
Packit b099d7
**      CR 4851.
Packit b099d7
**
Packit b099d7
**  FORMAL PARAMETERS:
Packit b099d7
**
Packit b099d7
**      same as memcpy
Packit b099d7
**
Packit b099d7
**  COMPLETION CODES:
Packit b099d7
**
Packit b099d7
**      same as memcpy
Packit b099d7
**
Packit b099d7
**  SIDE EFFECTS:
Packit b099d7
**
Packit b099d7
**--
Packit b099d7
**/
Packit b099d7
Packit b099d7
char *uil_mmove(s1, s2, n)
Packit b099d7
char *s1, *s2;
Packit b099d7
int n;
Packit b099d7
{
Packit b099d7
     char *temp;
Packit b099d7
Packit b099d7
     if(s2 == s1)
Packit b099d7
         return(s2);
Packit b099d7
     if(s2 < s1 && s1 <= s2 + n){
Packit b099d7
         if(temp = (char *)malloc(n)){
Packit b099d7
             memcpy(temp, s2, n);
Packit b099d7
             memcpy(s1, temp, n);
Packit b099d7
             free(temp);
Packit b099d7
             return(s1);
Packit b099d7
         }
Packit b099d7
         printf("uil_mmove: Memory allocation failed!\n");
Packit b099d7
         exit(-1);
Packit b099d7
     }
Packit b099d7
     return((char *)memcpy(s1, s2, n));
Packit b099d7
}
Packit b099d7
#endif  /* NO_MEMMOVE */