10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER START
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The contents of this file are subject to the terms of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Common Development and Distribution License (the "License").
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You may not use this file except in compliance with the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * See the License for the specific language governing permissions
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and limitations under the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If applicable, add the following below this CDDL HEADER, with the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER END
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Use is subject to license terms.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This file contains various unclassified routines. Some main groups:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Memory allocation
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * String handling
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Property handling
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Error message handling
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Make internal state dumping
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * main routine support
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Included files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <mksh/i18n.h> /* get_char_semantics_value() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <stdarg.h> /* va_list, va_start(), va_end() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Defined macros
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * typedefs & structs
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * File table of contents
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void expand_string(register String string, register int length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * getmem(size)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * malloc() version that checks the returned value.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The memory chunk we allocated
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * size The size of the chunk we need
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register char *result = (char *) malloc((unsigned) size);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe sprintf(buf, "*** Error: malloc(%d) failed: %s\n", size, strerror(errno));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe strcat(buf, gettext("mksh: Fatal error: Out of memory\n"));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Cover funtion for free() to make it possible to insert advises.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * p The memory block to free
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) free((char *) p);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * getname_fn(name, len, dont_enter)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Hash a name string to the corresponding nameblock.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The Name block for the string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * name The string we want to internalize
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * len The length of that string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dont_enter Don't enter the name if it does not exist
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * funny The vector of semantic tags for characters
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * hashtab The hashtable used for the nametable
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowegetname_fn(wchar_t *name, register int len, register Boolean dont_enter, register Boolean * foundp)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * First figure out how long the string is.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If the len argument is -1 we count the chars here.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe mbs_name = tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) wcstombs(mbs_name, ws.get_string(), (length * MB_LEN_MAX) + 1);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Look for the string */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe getname_bytes_count += strlen(np->string_mb) + 1;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Fill in the new Name */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Scan the namestring to classify it */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe np->dollar = BOOLEAN((len & (int) dollar_sem) != 0);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe np->meta = BOOLEAN((len & (int) meta_sem) != 0);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe np->percent = BOOLEAN((len & (int) percent_sem) != 0);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe np->wildcard = BOOLEAN((len & (int) wildcard_sem) != 0);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe np->colon = BOOLEAN((len & (int) colon_sem) != 0);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe np->parenleft = BOOLEAN((len & (int) parenleft_sem) != 0);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe freename_bytes_count += strlen(name->string_mb) + 1;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (Property next, p = name->prop; p != NULL; p = next) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * enable_interrupt(handler)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This routine sets a new interrupt handler for the signals make
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * wants to deal with.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * handler The function installed as interrupt handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sigivalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sigqvalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sigtvalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sighvalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweenable_interrupt(register void (*handler) (int))
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * setup_char_semantics()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Load the vector char_semantics[] with lexical markers
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * char_semantics The vector of character semantics that we set
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe const char *s;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe s = "=@-?!+";
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char_semantics[entry] |= (int) command_prefix_sem;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char_semantics[dollar_char_entry] |= (int) dollar_sem;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (s = "#|=^();&<>*?[]:$`'\"\\\n"; MBTOWC(wc_buffer, s); s++) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char_semantics[percent_char_entry] |= (int) percent_sem;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (s = "@*<%?^"; MBTOWC(wc_buffer, s); s++) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char_semantics[entry] |= (int) special_macro_sem;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char_semantics[colon_char_entry] |= (int) colon_sem;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char_semantics[parenleft_char_entry] |= (int) parenleft_sem;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * errmsg(errnum)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return the error message for a system call error
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * An error message string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * errnum The number of the error we want to describe
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sys_errlist A vector of error messages
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sys_nerr The size of sys_errlist
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) sprintf(errbuf, gettext("Error %d"), errnum);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fatal_mksh(format, args...)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Print a message and die
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * format printf type format string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * args Arguments to match the format
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char *mksh_fat_err = gettext("mksh: Fatal error: ");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe char *cur_wrk_dir = gettext("Current working directory: ");
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe size_t buf_len = vsnprintf(static_buf + mksh_fat_err_len,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) vsprintf(buf + mksh_fat_err_len, message, args);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (report_pwd) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fatal_reader_mksh(format, args...)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * format printf style format string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * args arguments to match the format
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (file_being_read != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe WCSTOMBS(mbs_buffer, file_being_read);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (line_number != 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) sprintf(message,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext("%s, line %d: %s"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe line_number,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) sprintf(message,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe pattern = message;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) fprintf(stderr, gettext("mksh: Fatal error in reader: "));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (temp_file_name != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) fprintf(stderr,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe gettext("mksh: Temp-file %s not removed\n"),
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe temp_file_name->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe temp_file_name = NULL;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (report_pwd) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * warning_mksh(format, args...)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Print a message and continue.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * format printf type format string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * args Arguments to match the format
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) fprintf(stderr, gettext("mksh: Warning: "));
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (report_pwd) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * get_current_path_mksh()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Stuff current_path with the current path if it isnt there already.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * append_prop(target, type)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Create a new property and append it to the property list of a Name.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * A new property block for the target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target that wants a new property
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * type The type of property being requested
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweappend_prop(register Name target, register Property_id type)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal_mksh(gettext("Internal error. Unknown prop type %d"), type);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (; prop != NULL; insert = &prop->next, prop = *insert);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * maybe_append_prop(target, type)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Append a property to the Name if none of this type exists
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * else return the one already there
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * A property of the requested type for the target
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target The target that wants a new property
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * type The type of property being requested
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowemaybe_append_prop(register Name target, register Property_id type)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if ((prop = get_prop(target->prop, type)) != NULL) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * get_prop(start, type)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Scan the property list of a Name to find the next property
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * of a given type.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The first property of the type, if any left
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * start The first property block to check for type
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * type The type of property block we need
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweget_prop(register Property start, register Property_id type)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * append_string(from, to, length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Append a C string to a make string expanding it if nessecary
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * from The source (C style) string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * to The destination (make style) string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * length The length of the from string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweappend_string(register wchar_t *from, register String to, register int length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweappend_string(register char *from, register String to, register int length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * expand_string(string, length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Allocate more memory for strings that run out of space.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * string The make style string we want to expand
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * length The new length we need
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Loweexpand_string(register String string, register int length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register wchar_t *p;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* For strings that have no memory allocated */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe string->buffer.end = string->buffer.start + length;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (string->buffer.end - string->buffer.start >= length) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we really don't need more memory. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Get more memory, copy the string and free the old buffer if
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * it is was malloc()'ed.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe string->text.p = p + (string->text.p - string->buffer.start);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe string->text.end = p + (string->text.end - string->buffer.start);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * append_char(from, to)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Append one char to a make string expanding it if nessecary
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * from Single character to append to string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * to The destination (make style) string
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe expand_string(to, to->buffer.end - to->buffer.start + 32);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * handle_interrupt_mksh()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This is where C-C traps are caught.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Make sure the processes running under us terminate first. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * setup_interrupt()
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * This routine saves the original interrupt handler pointers
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sigivalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sigqvalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sigtvalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * sighvalue The original signal handler
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowembstowcs_with_check(wchar_t *pwcs, const char *s, size_t n)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe fatal_mksh(gettext("The string `%s' is not valid in current locale"), s);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_string(name->string_mb, &string, name->hash.length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_string(name->string_mb, &string, name->hash.length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return (Boolean)IS_WEQUALN(string.buffer.start, str, length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return (Boolean)IS_WEQUALN(string.buffer.start, str->string.buffer.start, length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard LoweWstring::equal(wchar_t * str, unsigned off, unsigned length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return (Boolean)IS_WEQUALN(string.buffer.start + off, str, length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return (Boolean)IS_WEQUAL(string.buffer.start + off, str);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard LoweWstring::equal(Wstring * str, unsigned off, unsigned length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return (Boolean)IS_WEQUALN(string.buffer.start + off, str->string.buffer.start, length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return (Boolean)IS_WEQUAL(string.buffer.start + off, str->string.buffer.start);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard LoweWstring::append_to_str(struct _String * str, unsigned off, unsigned length)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe append_string(string.buffer.start + off, str, length);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (res > 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard LoweName_set::insert(const char *key, Boolean &found)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (res > 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe int res = strcmp(name->string_mb, node->name->string_mb);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe } else if (res > 0) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe // should be an error: inserting already existing name
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe unsigned rdepth = (right != 0) ? right->depth : 0;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe unsigned ldepth = (left != 0) ? left->depth : 0;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe for (entry *node = root; node != 0; node = node->left) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while ((node->parent != 0) && (node->parent->right == node)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe return *this;