home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Windows 95.com 1996 December
/
WIN95_DEC_1996_4.ISO
/
program
/
mc.exe
/
mc_lib.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-23
|
211KB
|
7,245 lines
/*
* MOAL C Standard Library, version 1.04
*
* Copyright (c) 1996, MOAL Languages. All rights reserved.
*
*
* big-endian or little-endian: see the first comment below
*
* multithreading: If the MOAL C program has multiple threads, then, when
* this library file is compiled for that MOAL C program,
* choose -- assuming there is such a choice -- to use the
* multithreading version of the ANSI C library. Also,
* confine all MOAL C calls of:
*
* fopen(), fclose(), tmpfile(),
* fgetall(), fputall()
*
* to a single thread (see the explanation below).
*/
/*
* This library uses IEEE-754 floating-point error codes. Whether or not
* the macro name LITTLE_ENDIAN is defined determines the assumed byte
* ordering of these error codes (note that the PC is little-endian, but
* workstations are typically big-endian). Note that if LITTLE_ENDIAN is
* defined and the microprocessor is not little-endian, or, conversely,
* LITTLE_ENDIAN is not defined and the microprocessor is little-endian,
* then certain of the library math functions will give erroneous results
* for certain inputs, and the merr() function will not work.
*
* If the microprocessor is big-endian and not little-endian, then comment
* the #define below. Note that the PC is little-endian; the PowerPC,
* depending on the OS being used, is either big-endian or little-endian;
* workstation hardware is typically big-endian. Consult your hardware
* and/or software documentation if there is any doubt.
*/
#define LITTLE_ENDIAN /* comment this #define if want big-endian */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <limits.h>
#include <float.h>
#include <errno.h>
/*
* globals used for translating C's FILE pointer to MOAL C's file number,
* and vice versa
*
* note: these globals are used to preserve the translation information
* between calls. However, in a multithreaded application, the two
* functions that change the values of these globals, remove_file()
* and store_file(), are, in effect, critical sections that need
* serialization by using semaphores. However, semaphores are not
* used by this code (for portabilty reasons). Consequently, if the
* program is multithreaded, confine all MOAL C calls of:
*
* fopen(), fclose(), tmpfile(),
* fgetall(), fputall()
*
* to a single thread, because these are the library functions that
* can call remove_file() and store_file().
*/
#define FILES_MAX 500
static FILE *files[FILES_MAX];
static int files_cnt;
/*
* some types used by MOAL C library functions
*/
typedef unsigned long ff_time_t;
typedef unsigned long ff_clock_t;
typedef unsigned int ff_size_t;
typedef unsigned int moal_t;
struct d1_meta {
void *ptr;
moal_t occurs;
moal_t limit1;
};
/*
* prototypes for the MOAL C library functions
*/
/*
* the following functions were written in MOAL C, and the generated
* C code is at the end of this file:
*
* strreg()
* strfndr()
* stresc()
* fgetall()
* fputall()
* strkey()
* strknew()
* strkmap()
* strkfnd()
*
*/
/* formatted input/output */
void _mc__printf(void *return_ptr[], struct d1_meta *format, ...);
void _mc__fprintf(void *return_ptr[], int file, struct d1_meta *format, ...);
void _mc__sprintf(void *return_ptr[], struct d1_meta *out, int append,
struct d1_meta *format, ...);
void _mc__scanf(void *return_ptr[], struct d1_meta *format, ...);
void _mc__fscanf(void *return_ptr[], int file, struct d1_meta *format, ...);
void _mc__sscanf(void *return_ptr[],
struct d1_meta *source, struct d1_meta *format, ...);
/* math */
void _mc__abs(void *return_ptr[], int x);
void _mc__acos(void *return_ptr[], double x);
void _mc__asin(void *return_ptr[], double x);
void _mc__atan(void *return_ptr[], double x);
void _mc__atan2(void *return_ptr[], double y, double x);
void _mc__ceil(void *return_ptr[], double x);
void _mc__cos(void *return_ptr[], double x);
void _mc__div(void *return_ptr[], int x, int divide_by);
void _mc__exp(void *return_ptr[], double x);
void _mc__fabs(void *return_ptr[], double x);
void _mc__floor(void *return_ptr[], double x);
void _mc__fmod(void *return_ptr[], double x, double divide_by);
void _mc__labs(void *return_ptr[], long x);
void _mc__ldiv(void *return_ptr[], long x, long divide_by);
void _mc__log(void *return_ptr[], double x);
void _mc__log10(void *return_ptr[], double x);
void _mc__merr(void *return_ptr[], double x);
void _mc__pow(void *return_ptr[], double x, double power);
void _mc__rand(void *return_ptr[], int prev);
void _mc__sin(void *return_ptr[], double x);
void _mc__sqrt(void *return_ptr[], double x);
void _mc__tan(void *return_ptr[], double x);
/* time */
struct ff_tm {
int tm_sec; /* seconds after the minute (0 - 61) */
int tm_min; /* minutes after the hour (0 - 59) */
int tm_hour; /* hours since midnight (0 - 23) */
int tm_mday; /* day of the month (1 - 31) */
int tm_mon; /* months since January (0 - 11) */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday (0 - 6) */
int tm_yday; /* days since January 1st (0 - 365) */
int tm_isdst; /* Daylight Saving Time flag */
};
void _mc__clock(void *return_ptr[]);
void _mc__ctime(void *return_ptr[], ff_time_t any_time);
void _mc__difftime(void *return_ptr[],
ff_time_t any_time, ff_time_t subtract_time);
void _mc__gmtime(void *return_ptr[], ff_time_t any_time);
void _mc__localtime(void *return_ptr[], ff_time_t any_time);
void _mc__mktime(void *return_ptr[], struct ff_tm *time_info);
void _mc__strftime(void *return_ptr[],
struct d1_meta *format, struct ff_tm *time_info);
void _mc__time(void *return_ptr[]);
/* file I/O */
void _mc__fclose(void *return_ptr[], int file);
void _mc__fgetc(void *return_ptr[], int file);
void _mc__fgets(void *return_ptr[], struct d1_meta *out, ff_size_t count,
int file);
void _mc__fopen(void *return_ptr[], struct d1_meta *filename,
struct d1_meta *mode);
void _mc__fputc(void *return_ptr[], char character, int file);
void _mc__fputs(void *return_ptr[], struct d1_meta *source, int file);
void _mc__fread(void *return_ptr[], struct d1_meta *out,
ff_size_t out_offset, ff_size_t read_count, int file);
void _mc__fseek(void *return_ptr[], int file, long offset, int from_where);
void _mc__ftell(void *return_ptr[], int file);
void _mc__fwrite(void *return_ptr[], struct d1_meta *source,
ff_size_t source_offset, ff_size_t write_count, int file);
void _mc__remove(void *return_ptr[], struct d1_meta *filename);
void _mc__rename(void *return_ptr[], struct d1_meta *current_filename,
struct d1_meta *new_filename);
void _mc__tmpfile(void *return_ptr[]);
void _mc__tmpnam(void *return_ptr[]);
/* character */
void _mc__toupper(void *return_ptr[], char character);
void _mc__tolower(void *return_ptr[], char character);
void _mc__isalnum(void *return_ptr[], char character);
void _mc__isalpha(void *return_ptr[], char character);
void _mc__isdigit(void *return_ptr[], char character);
void _mc__islower(void *return_ptr[], char character);
void _mc__isspace(void *return_ptr[], char character);
void _mc__isupper(void *return_ptr[], char character);
/* sort and search */
void _mc__qsort(void *return_ptr[], struct d1_meta *, ff_size_t element_size,
void (*compare) (void *[], void *, void *));
void _mc__bsearch(void *return_ptr[], void *, struct d1_meta *,
ff_size_t element_size,
void (*compare) (void *[], void *, void *));
/* communication with the environment */
void _mc__main(void *return_ptr[], struct d1_meta *args);
void _mc__getenv(void *return_ptr[], struct d1_meta *name);
void _mc__exit(void *return_ptr[], int status);
void _mc__system(void *return_ptr[], struct d1_meta *command);
/* strings */
void _mc__strcat(void *return_ptr[],
struct d1_meta *out, struct d1_meta *source);
void _mc__strcmp(void *return_ptr[],
struct d1_meta *s1, struct d1_meta *s2);
void _mc__strcpy(void *return_ptr[],
struct d1_meta *out, struct d1_meta *source);
void _mc__strerror(void *return_ptr[], int error);
void _mc__strfnd(void *return_ptr[], struct d1_meta *search,
ff_size_t from_offset, ff_size_t to_offset,
int match_case, struct d1_meta *find);
void _mc__strncmp(void *return_ptr[],
struct d1_meta *s1, struct d1_meta *s2, ff_size_t n);
void _mc__strpart(void *return_ptr[], struct d1_meta *source,
ff_size_t from_offset, ff_size_t to_offset);
void _mc__strrpl(void *return_ptr[], struct d1_meta *out,
ff_size_t out_offset, ff_size_t cut_length,
struct d1_meta *insert);
void _mc__strtod(void *return_ptr[],
struct d1_meta *source, ff_size_t source_offset);
void _mc__strtol(void *return_ptr[],
struct d1_meta *source, ff_size_t source_offset);
void _mc__strtoul(void *return_ptr[],
struct d1_meta *source, ff_size_t source_offset);
/*
* prototypes for support functions used by the library
*/
static void format_new_flags(char comma, char dollar, char paren,
char *in, char *out, char space_flag);
static int store_file(FILE *in);
static void remove_file(int in);
static FILE *retrieve_file(int in);
static void tm_to_ff_tm(struct tm *in, struct ff_tm *out);
static void ff_tm_to_tm(struct ff_tm *in, struct tm *out);
static int resize_cspace(struct d1_meta *out, moal_t new_min);
/*
* globals referenced (as externals) by the MOAL C header file
*
* note: the reason _MC_name is declared a varspace in the MOAL C header
* file instead of declared a fixed-space, is to avoid having a
* potentially changing name for the fixed-space's metadata: that
* name (which would change if the user changes the naming prefix: a
* compiler option) would be unknown to this C program, because this
* C program is not compiled by the MOAL C compiler.
*/
#define WS 1 /* whitespace */
#define LL 2 /* lowercase letter */
#define UL 4 /* uppercase letter */
#define DT 8 /* digit */
static signed char mc_ctype[256] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, WS, WS, WS, WS, WS, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
WS, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
DT, DT, DT, DT, DT, DT, DT, DT,
DT, DT, 0, 0, 0, 0, 0, 0,
0, UL, UL, UL, UL, UL, UL, UL,
UL, UL, UL, UL, UL, UL, UL, UL,
UL, UL, UL, UL, UL, UL, UL, UL,
UL, UL, UL, 0, 0, 0, 0, 0,
0, LL, LL, LL, LL, LL, LL, LL,
LL, LL, LL, LL, LL, LL, LL, LL,
LL, LL, LL, LL, LL, LL, LL, LL,
LL, LL, LL, 0, 0, 0, 0, 0
};
struct d1_meta _MC_ctype = {mc_ctype, 256, 256};
static unsigned char mc_lower[256] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63,
64, 97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122, 123, 124, 125, 126, 127,
128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151,
152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167,
168, 169, 170, 171, 172, 173, 174, 175,
176, 177, 178, 179, 180, 181, 182, 183,
184, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215,
216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231,
232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247,
248, 249, 250, 251, 252, 253, 254, 255
};
struct d1_meta _MC_lower = {mc_lower, 256, 256};
static unsigned char mc_upper[256] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 91, 92, 93, 94, 95,
96, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 123, 124, 125, 126, 127,
128, 129, 130, 131, 132, 133, 134, 135,
136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151,
152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167,
168, 169, 170, 171, 172, 173, 174, 175,
176, 177, 178, 179, 180, 181, 182, 183,
184, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215,
216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231,
232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247,
248, 249, 250, 251, 252, 253, 254, 255
};
struct d1_meta _MC_upper = {mc_upper, 256, 256};
/*
* miscellaneous defines used by the library
*/
#undef max
#undef TRUE
#undef FALSE
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE 1
#define FALSE 0
#define MEMORY_FAILURE 32000 /* MOAL C's one predefined exception */
#define MC_EOF -1 /* MOAL C's added error codes, negative
so no conflict with C errno values */
#define MC_NOT_FOUND -2
#define MC_NaN -3
#define MC_pINF -4
#define MC_nINF -5
#define MC_EMPTY_PARAMETER -6 /* a copy is in mc_lsupp.mc */
#define MC_OFFSET_INVALID -7 /* a copy is in mc_lsupp.mc */
#define MC_INCOMPATIBLE_PARAMS -8 /* a copy is in mc_lsupp.mc */
#define MC_INVALID_FILE_NUMBER -9
#define MC_TOO_MANY_OPEN_FILES -10
#define MC_REX_MALFORMED -11 /* a copy is in mc_lsupp.mc */
#define MC_REX_MATCHES_NOTHING -12 /* a copy is in mc_lsupp.mc */
#define MC_MACHINE_EMPTY -13 /* a copy is in mc_lsupp.mc */
#define SCANF_MAXWIDTH 1000 /* default max field width for ops [ and s */
#define FIRST_USER_FILE 4 /* files 1, 2, and 3 are the predefined files */
/*
* several C functions used in this library add a null character at the end
* of their output. room for this added null character is added to the affected
* new_min calculations (see sprintf, and the scanf functions for %s and %[])
*/
#define ROOM_FOR_C_ADDED_NULL 1
/*
* the following four macros work together to safely add the terminating
* null character required by many of the ANSI C library functions
*/
#define make_safe(meta, mall, save_ptr, save_ch, fail) \
{if(meta->occurs < meta->limit1) \
{mall = FALSE; \
save_ch = *(((unsigned char *)meta->ptr) + meta->occurs);} \
else \
{mall = TRUE; \
save_ptr = meta->ptr; \
meta->ptr = malloc(meta->occurs + 1); \
if(meta->ptr == NULL) \
{meta->ptr = save_ptr; \
fail \
*((int *)(return_ptr[0])) = MEMORY_FAILURE; \
return;} \
strncpy(meta->ptr, save_ptr, meta->occurs);} \
*(((unsigned char *)meta->ptr) + meta->occurs) = 0;}
#define VA_END va_end(ap);
#define NONE
#define undo_safe(meta, mall, save_ptr, save_ch) \
{if(mall) \
{free(meta->ptr); \
meta->ptr = save_ptr;} \
else \
*(((unsigned char *)meta->ptr) + meta->occurs) = save_ch;}
/*
test for overflow when adding two unsigned values that must fit into
unsigned type 'type'. note that it is not necessary to test the sum as
being less than both x and y, because when overflow happens from adding
two unsigned values, the sum is always less than both operands, so
either operand can be tested against the sum (the choice is arbitrary).
*/
#define sum_overflows(type, x, y) ((type)((x) + (y)) < (x) ? 1 : 0)
/*
* error codes for floating-point. NaN (not-a-number) and Inf (infinity)
* are defined by the IEEE-754 standard
*/
#ifdef LITTLE_ENDIAN
/* assume little-endian */
static union {
unsigned char dummy[8];
double num;
} pos_inf = {0, 0, 0, 0, 0, 0, 240, 127};
static union {
unsigned char dummy[8];
double num;
} neg_inf = {0, 0, 0, 0, 0, 0, 240, 255};
static union {
unsigned char dummy[8];
double num;
} nan = {0, 0, 0, 0, 0, 0, 248, 127}; /* a quiet NaN */
#define WORK_SIZE 8
#define dblerr(x) (work.num = (x), \
((work.cc[6] & 240) == 240 && (work.cc[7] & 127) == 127) ? \
((*(int *)(&work.cc[0]) == 0 && *(short *)(&work.cc[4]) == 0 \
&& (work.cc[6] & 15) == 0) ? \
((work.cc[7] & 128) ? MC_nINF : MC_pINF) : MC_NaN) : 0)
#else
/* assume big-endian */
static union {
unsigned char dummy[8];
double num;
} pos_inf = {127, 240, 0, 0, 0, 0, 0, 0};
static union {
unsigned char dummy[8];
double num;
} neg_inf = {255, 240, 0, 0, 0, 0, 0, 0};
static union {
unsigned char dummy[8];
double num;
} nan = {127, 248, 0, 0, 0, 0, 0, 0}; /* a quiet NaN */
#define WORK_SIZE 8
#define dblerr(x) (work.num = (x), \
((work.cc[1] & 240) == 240 && (work.cc[0] & 127) == 127) ? \
((*(int *)(&work.cc[4]) == 0 && *(short *)(&work.cc[2]) == 0 \
&& (work.cc[1] & 15) == 0) ? \
((work.cc[0] & 128) ? MC_nINF : MC_pINF) : MC_NaN) : 0)
#endif
int main(int argc, char *argv[])
{
struct ar {
struct d1_meta text;
} *base;
int wrk1, len, ret, exception;
struct d1_meta args;
void *actuals[2];
/*
* These sizes are assumed by the library code that sets and tests for
* IEEE-754 error codes (see the definition of the dblerr() macro). That
* short is 2 bytes is also assumed by the MOAL C compiler when it
* generates C code for the arithmetic type onecode.
*/
assert(sizeof(short) == 2 && sizeof(int) == 4 && sizeof(double) == 8);
/* store the command-line arguments, if any */
base = args.ptr = malloc(argc * sizeof(struct ar));
if(base == NULL)
{mem_error:
printf("** not enough memory to start main() **\n execution \
terminated\n");
exit(1);}
args.occurs = args.limit1 = argc;
/* copy the data */
for(wrk1 = 0; wrk1 < argc; ++wrk1)
{len = 1 + strlen(argv[wrk1]); /* add 1 for null terminator */
base[wrk1].text.ptr = malloc(len);
if(base[wrk1].text.ptr == NULL)
goto mem_error;
strcpy((char *)base[wrk1].text.ptr, argv[wrk1]);
base[wrk1].text.occurs = len - 1;
base[wrk1].text.limit1 = len;}
/* call the cover function */
actuals[0] = &exception;
actuals[1] = &ret;
_mc__main(actuals, &args);
if(exception)
{fprintf(stderr, "\nmain() is returning with an unhandled \
exception:\n\n");
if(exception == MEMORY_FAILURE)
fprintf(stderr, " memory failure (not enough memory)\n");
else
fprintf(stderr, " exception %d\n", exception);
ret = EXIT_FAILURE;}
return ret;
}
void _mc__printf(void *return_ptr[], struct d1_meta *format, ...)
{
int sent = 0;
unsigned char *bgn, *end, *curr,
save, ch, spec[100], size_mod, at_end, have_precision,
cm_comma, cm_dollar, cm_paren, cm_in[200], cm_out[300],
space_flag;
int wrk1, ret, sub, min_width, precision, mall;
void *save_ptr;
struct d1_meta *d1;
va_list ap;
va_start(ap, format);
if(format->occurs == 0)
goto done;
curr = bgn = (unsigned char *)format->ptr;
end = bgn + format->occurs - 1;
/*
* note: in those places where a 0 terminator is added on a temporary
* basis, this is done because the called C library function requires a
* 0 terminator to mark the end of a string
*/
for(at_end = 'n';; ++curr)
{if(curr == end)
{at_end = 'y';
output_text:
save = *(curr + 1);
*(curr + 1) = 0;
ret = printf("%s", bgn);
*(curr + 1) = save;
if(ret < 0)
goto error;
else
sent += ret;
if(at_end == 'y')
break;
bgn = curr + 1;
continue;}
if(*curr == '%') /* beginning of conversion specification */
{if(bgn < curr)
{--curr;
goto output_text;}
/* extract the conversion specification */
have_precision = cm_comma = cm_dollar =
cm_paren = space_flag = 'n';
sub = min_width = precision = 0;
spec[sub++] = '%';
for(++curr; curr <= end && sub < sizeof(spec) - 25; ++curr)
{ch = *curr;
/* check for ANSI C conversions that are invalid in MOAL C */
if(ch == 'p' || ch == 'n' || ch == 'o')
goto error;
/* check for space flag, info is used elsewhere */
if(ch == '+')
space_flag = 0;
else if(ch == ' ' && space_flag == 'n')
space_flag = 'y';
/* the , $ and ( are new flags */
if(ch == ',')
{cm_comma = 'y';
continue;}
else if(ch == '$')
{cm_dollar = 'y';
continue;}
else if(ch == '(')
{cm_paren = 'y';
continue;}
if(ch == '*')
{min_width = va_arg(ap, int);
sub += sprintf(&spec[sub], "%d", min_width);
/* "A negative field width argument is taken as a - flag
followed by a positive field width" : pg. 239 TSCL */
if(min_width < 0)
min_width *= -1;
continue;}
if(ch == '.')
{if(*(curr + 1) == '*')
{precision = va_arg(ap, int);
/* "A negative precision argument is taken as if
the precision were omitted" : pg. 239 TSCL */
if(precision < 0)
{++curr;
continue;}
have_precision = 'y';
sub += sprintf(&spec[sub], ".%d", precision);
++curr;
continue;}
have_precision = 'y';}
spec[sub++] = ch;
if(isdigit(ch))
{if(have_precision == 'n')
{if(min_width == 0 && ch != '0')
min_width = strtol(curr, NULL, 10);}
else if(precision == 0)
precision = strtol(curr, NULL, 10);}
/* check for end of the conversion specification */
else if((isalpha(ch)
&& (ch == 'd' || ch == 's' || ch == 'c'
|| ch == 'e' || ch == 'E' || ch == 'f'
|| ch == 'g' || ch == 'G' || ch == 'i'
|| ch == 'u' || ch == 'x' || ch == 'X'))
|| ch == '%')
{spec[sub] = 0;
/* set the size modifier, if any */
size_mod = *(curr - 1);
/* check for enough room to process the new flags */
if(ch == 'u')
cm_paren = space_flag = 'n';
if(cm_comma == 'y' || cm_dollar == 'y' || cm_paren == 'y')
{if(ch == 'u' || ch == 'd' || ch == 'i')
{wrk1 = max(max(precision, min_width),
(size_mod == 'l' ?
sizeof(long) : sizeof(int)) * 3);
if(wrk1 > sizeof(cm_in) - 1)
cm_comma = cm_paren = cm_dollar = 'n';}
else if(ch == 'f')
{wrk1 = max(min_width,
(have_precision == 'y' ?
precision : 6)
+ (size_mod == 'L' ?
sizeof(long double) :
sizeof(double)) * 3 + 5);
if(wrk1 > sizeof(cm_in) - 1)
cm_comma = cm_paren = cm_dollar = 'n';}
else
cm_comma = cm_paren = cm_dollar = 'n';}
/* process the type */
if(ch == 's')
{d1 = va_arg(ap, struct d1_meta *);
if(d1->occurs)
{make_safe(d1, mall, save_ptr, save, VA_END);
ret = printf(spec, (char *)d1->ptr);
undo_safe(d1, mall, save_ptr, save);}
else
ret = printf(spec, "");
if(ret < 0)
goto error;
else
sent += ret;}
else if(cm_comma == 'y'
|| cm_dollar == 'y' || cm_paren == 'y')
{if(ch == 'f' && size_mod == 'L')
ret = sprintf(cm_in, spec,
va_arg(ap, long double));
else if(ch == 'f')
ret = sprintf(cm_in, spec, va_arg(ap, double));
else if(size_mod == 'l')
ret = sprintf(cm_in, spec, va_arg(ap, long));
else
ret = sprintf(cm_in, spec, va_arg(ap, int));
if(ret < 0)
goto error;
/* add the commas, etc. as needed */
format_new_flags(cm_comma, cm_dollar, cm_paren,
cm_in, cm_out, space_flag);
/* output the new string */
ret = printf("%s", cm_out);
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == 'c' || ch == 'd' || ch == 'i')
{if(size_mod == 'l')
ret = printf(spec, va_arg(ap, long));
else
ret = printf(spec, va_arg(ap, int));
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == 'u' || ch == 'x' || ch == 'X')
{if(size_mod == 'l')
ret = printf(spec, va_arg(ap, long));
else
ret = printf(spec, va_arg(ap, int));
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == 'f' || ch == 'e' || ch == 'E'
|| ch == 'g' || ch == 'G')
{if(size_mod == 'L')
ret = printf(spec, va_arg(ap, long double));
else
ret = printf(spec, va_arg(ap, double));
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == '%')
{ret = printf(spec);
if(ret < 0)
goto error;
else
sent += ret;}
else
goto error;
if(curr == end)
goto done;
else
{bgn = curr + 1;
goto cont1;}}}
goto error;
cont1: ;}}
error:
done:
va_end(ap);
*((int *)(return_ptr[1])) = sent;
return;
}
void _mc__fprintf(void *return_ptr[], int file, struct d1_meta *format, ...)
{
int sent = 0;
unsigned char *bgn, *end, *curr,
save, ch, spec[100], size_mod, at_end, have_precision,
cm_comma, cm_dollar, cm_paren, cm_in[200], cm_out[300],
space_flag;
int wrk1, ret, sub, min_width, precision, mall;
void *save_ptr;
struct d1_meta *d1;
FILE *fptr;
va_list ap;
va_start(ap, format);
if(format->occurs == 0)
goto done;
if((fptr = retrieve_file(file)) == NULL)
goto error;
curr = bgn = (unsigned char *)format->ptr;
end = bgn + format->occurs - 1;
for(at_end = 'n';; ++curr)
{if(curr == end)
{at_end = 'y';
output_text:
save = *(curr + 1);
*(curr + 1) = 0;
ret = fprintf(fptr, "%s", bgn);
*(curr + 1) = save;
if(ret < 0)
goto error;
else
sent += ret;
if(at_end == 'y')
break;
bgn = curr + 1;
continue;}
if(*curr == '%') /* beginning of conversion specification */
{if(bgn < curr)
{--curr;
goto output_text;}
/* extract the conversion specification */
have_precision = cm_comma = cm_dollar =
cm_paren = space_flag = 'n';
sub = min_width = precision = 0;
spec[sub++] = '%';
for(++curr; curr <= end && sub < sizeof(spec) - 25; ++curr)
{ch = *curr;
/* check for ANSI C conversions that are invalid in MOAL C */
if(ch == 'p' || ch == 'n' || ch == 'o')
goto error;
/* check for space flag, info is used elsewhere */
if(ch == '+')
space_flag = 0;
else if(ch == ' ' && space_flag == 'n')
space_flag = 'y';
/* the , $ and ( are new flags */
if(ch == ',')
{cm_comma = 'y';
continue;}
else if(ch == '$')
{cm_dollar = 'y';
continue;}
else if(ch == '(')
{cm_paren = 'y';
continue;}
if(ch == '*')
{min_width = va_arg(ap, int);
sub += sprintf(&spec[sub], "%d", min_width);
/* "A negative field width argument is taken as a - flag
followed by a positive field width" : pg. 239 TSCL */
if(min_width < 0)
min_width *= -1;
continue;}
if(ch == '.')
{if(*(curr + 1) == '*')
{precision = va_arg(ap, int);
/* "A negative precision argument is taken as if
the precision were omitted" : pg. 239 TSCL */
if(precision < 0)
{++curr;
continue;}
have_precision = 'y';
sub += sprintf(&spec[sub], ".%d", precision);
++curr;
continue;}
have_precision = 'y';}
spec[sub++] = ch;
if(isdigit(ch))
{if(have_precision == 'n')
{if(min_width == 0 && ch != '0')
min_width = strtol(curr, NULL, 10);}
else if(precision == 0)
precision = strtol(curr, NULL, 10);}
/* check for end of the conversion specification */
else if((isalpha(ch)
&& (ch == 'd' || ch == 's' || ch == 'c'
|| ch == 'e' || ch == 'E' || ch == 'f'
|| ch == 'g' || ch == 'G' || ch == 'i'
|| ch == 'u' || ch == 'x' || ch == 'X'))
|| ch == '%')
{spec[sub] = 0;
/* set the size modifier, if any */
size_mod = *(curr - 1);
/* check for enough room to process the new flags */
if(ch == 'u')
cm_paren = space_flag = 'n';
if(cm_comma == 'y' || cm_dollar == 'y' || cm_paren == 'y')
{if(ch == 'u' || ch == 'd' || ch == 'i')
{wrk1 = max(max(precision, min_width),
(size_mod == 'l' ?
sizeof(long) : sizeof(int)) * 3);
if(wrk1 > sizeof(cm_in) - 1)
cm_comma = cm_paren = cm_dollar = 'n';}
else if(ch == 'f')
{wrk1 = max(min_width,
(have_precision == 'y' ?
precision : 6)
+ (size_mod == 'L' ?
sizeof(long double) :
sizeof(double)) * 3 + 5);
if(wrk1 > sizeof(cm_in) - 1)
cm_comma = cm_paren = cm_dollar = 'n';}
else
cm_comma = cm_paren = cm_dollar = 'n';}
/* process the type */
if(ch == 's')
{d1 = va_arg(ap, struct d1_meta *);
if(d1->occurs)
{make_safe(d1, mall, save_ptr, save, VA_END);
ret = fprintf(fptr, spec, (char *)d1->ptr);
undo_safe(d1, mall, save_ptr, save);}
else
ret = fprintf(fptr, spec, "");
if(ret < 0)
goto error;
else
sent += ret;}
else if(cm_comma == 'y'
|| cm_dollar == 'y' || cm_paren == 'y')
{if(ch == 'f' && size_mod == 'L')
ret = sprintf(cm_in, spec,
va_arg(ap, long double));
else if(ch == 'f')
ret = sprintf(cm_in, spec, va_arg(ap, double));
else if(size_mod == 'l')
ret = sprintf(cm_in, spec, va_arg(ap, long));
else
ret = sprintf(cm_in, spec, va_arg(ap, int));
if(ret < 0)
goto error;
/* add the commas, etc. as needed */
format_new_flags(cm_comma, cm_dollar, cm_paren,
cm_in, cm_out, space_flag);
/* output the new string */
ret = fprintf(fptr, "%s", cm_out);
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == 'c' || ch == 'd' || ch == 'i')
{if(size_mod == 'l')
ret = fprintf(fptr, spec, va_arg(ap, long));
else
ret = fprintf(fptr, spec, va_arg(ap, int));
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == 'u' || ch == 'x' || ch == 'X')
{if(size_mod == 'l')
ret = fprintf(fptr, spec, va_arg(ap, long));
else
ret = fprintf(fptr, spec, va_arg(ap, int));
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == 'f' || ch == 'e' || ch == 'E'
|| ch == 'g' || ch == 'G')
{if(size_mod == 'L')
ret = fprintf(fptr, spec,
va_arg(ap, long double));
else
ret = fprintf(fptr, spec, va_arg(ap, double));
if(ret < 0)
goto error;
else
sent += ret;}
else if(ch == '%')
{ret = fprintf(fptr, spec);
if(ret < 0)
goto error;
else
sent += ret;}
else
goto error;
if(curr == end)
goto done;
else
{bgn = curr + 1;
goto cont1;}}}
goto error;
cont1: ;}}
error:
done:
va_end(ap);
*((int *)(return_ptr[1])) = sent;
return;
}
void _mc__sprintf(void *return_ptr[], struct d1_meta *out, int append,
struct d1_meta *format, ...)
{
int added = 0;
unsigned char *bgn, *end, *curr, *base,
save, ch, spec[100], size_mod, at_end, have_precision,
cm_comma, cm_dollar, cm_paren, cm_in[200], cm_out[300],
space_flag;
unsigned cnt, spec_len, total;
moal_t new_min;
int wrk1, ret, sub, min_width, precision, out_is_var, mall;
void *save_ptr;
struct d1_meta *d1;
void *original_out_ptr;
va_list ap;
va_start(ap, format);
if(return_ptr[3] == NULL)
out_is_var = TRUE;
else
out_is_var = FALSE;
if(format->occurs == 0)
goto done;
if(!append)
out->occurs = 0;
if(out->limit1)
original_out_ptr = out->ptr;
else
original_out_ptr = NULL;
/*
* first determine an upper-bound for the size of the generated output
*/
curr = bgn = (unsigned char *)format->ptr;
end = bgn + format->occurs - 1;
for(total = 0;; ++curr)
{if(curr == end)
{++total;
break;}
if(*curr == '%') /* beginning of conversion specification */
{/* examine the conversion specification */
have_precision = 'n';
min_width = precision = 0;
spec_len = 1;
for(++curr; curr <= end; ++curr)
{ch = *curr;
++spec_len;
/* check for ANSI C conversions that are invalid in MOAL C */
if(ch == 'p' || ch == 'n' || ch == 'o')
goto error;
if(ch == '*')
{min_width = va_arg(ap, int);
/* "A negative field width argument is taken as a - flag
followed by a positive field width" : pg. 239 TSCL */
if(min_width < 0)
min_width *= -1;
continue;}
if(ch == '.')
{if(*(curr + 1) == '*')
{precision = va_arg(ap, int);
/* "A negative precision argument is taken as if
the precision were omitted" : pg. 239 TSCL */
if(precision < 0)
{++curr;
continue;}
have_precision = 'y';
++curr;
continue;}
have_precision = 'y';}
if(isdigit(ch))
{if(have_precision == 'n')
{if(min_width == 0 && ch != '0')
min_width = strtol(curr, NULL, 10);}
else if(precision == 0)
precision = strtol(curr, NULL, 10);}
/* check for end of the conversion specification */
else if((isalpha(ch)
&& (ch == 'd' || ch == 's' || ch == 'c'
|| ch == 'e' || ch == 'E' || ch == 'f'
|| ch == 'g' || ch == 'G' || ch == 'i'
|| ch == 'u' || ch == 'x' || ch == 'X'))
|| ch == '%')
{/* set the size modifier, if any */
size_mod = *(curr - 1);
/* process the type */
if(ch == 's')
{d1 = va_arg(ap, struct d1_meta *);
cnt = max(min_width,
have_precision == 'y' ?
precision : d1->occurs);}
else if(ch == 'c' || ch == 'd' || ch == 'i')
{if(size_mod == 'l')
va_arg(ap, long);
else
va_arg(ap, int);
if(ch == 'c')
cnt = 1;
else
/* allowing 4 generated characters/byte. this
includes room for commas, dollar, parens */
cnt = max(max(precision, min_width),
(size_mod == 'l' ?
sizeof(long) : sizeof(int)) * 4);}
else if(ch == 'u' || ch == 'x' || ch == 'X')
{if(size_mod == 'l')
va_arg(ap, long);
else
va_arg(ap, int);
cnt = max(max(precision, min_width),
(size_mod == 'l' ?
sizeof(long) : sizeof(int)) * 4);}
else if(ch == 'f' || ch == 'e' || ch == 'E'
|| ch == 'g' || ch == 'G')
{if(size_mod == 'L')
va_arg(ap, long double);
else
va_arg(ap, double);
cnt = max(min_width,
(have_precision == 'y' ? precision : 6) +
(size_mod == 'L' ?
sizeof(long double) : sizeof(double)) * 4
+ 5);}
else if(ch == '%')
cnt = 1;
else
goto error;
/* if a specification is invalid, then the typical
C sprintf function returns the specification,
hence this worst-case lower bound of spec_len */
total += max(cnt, spec_len);
if(curr == end)
goto done_counting;
else
{bgn = curr + 1;
goto cont2;}}}
goto error;
cont2: ;}
else
++total;}
done_counting:
/*
* grow the varspace as needed
*/
new_min = total + out->occurs + ROOM_FOR_C_ADDED_NULL;
if(new_min > out->limit1)
{if(!out_is_var || !resize_cspace(out, new_min))
goto out_failure;}
/*
* do the sprintf operation
*/
va_end(ap);
va_start(ap, format);
base = (unsigned char *)out->ptr + out->occurs;
curr = bgn = (unsigned char *)format->ptr;
end = bgn + format->occurs - 1;
for(at_end = 'n';; ++curr)
{if(curr == end)
{at_end = 'y';
output_text:
save = *(curr + 1);
*(curr + 1) = 0;
ret = sprintf(&base[added], "%s", bgn);
*(curr + 1) = save;
if(ret < 0)
goto error;
else
added += ret;
if(at_end == 'y')
break;
bgn = curr + 1;
continue;}
if(*curr == '%') /* beginning of conversion specification */
{if(bgn < curr)
{--curr;
goto output_text;}
/* extract the conversion specification */
have_precision = cm_comma = cm_dollar =
cm_paren = space_flag = 'n';
sub = min_width = precision = 0;
spec[sub++] = '%';
for(++curr; curr <= end && sub < sizeof(spec) - 25; ++curr)
{ch = *curr;
/* check for ANSI C conversions that are invalid in MOAL C */
if(ch == 'p' || ch == 'n' || ch == 'o')
goto error;
/* check for space flag, info is used elsewhere */
if(ch == '+')
space_flag = 0;
else if(ch == ' ' && space_flag == 'n')
space_flag = 'y';
/* the , $ and ( are new flags */
if(ch == ',')
{cm_comma = 'y';
continue;}
else if(ch == '$')
{cm_dollar = 'y';
continue;}
else if(ch == '(')
{cm_paren = 'y';
continue;}
if(ch == '*')
{min_width = va_arg(ap, int);
sub += sprintf(&spec[sub], "%d", min_width);
/* "A negative field width argument is taken as a - flag
followed by a positive field width" : pg. 239 TSCL */
if(min_width < 0)
min_width *= -1;
continue;}
if(ch == '.')
{if(*(curr + 1) == '*')
{precision = va_arg(ap, int);
/* "A negative precision argument is taken as if
the precision were omitted" : pg. 239 TSCL */
if(precision < 0)
{++curr;
continue;}
have_precision = 'y';
sub += sprintf(&spec[sub], ".%d", precision);
++curr;
continue;}
have_precision = 'y';}
spec[sub++] = ch;
if(isdigit(ch))
{if(have_precision == 'n')
{if(min_width == 0 && ch != '0')
min_width = strtol(curr, NULL, 10);}
else if(precision == 0)
precision = strtol(curr, NULL, 10);}
/* check for end of the conversion specification */
else if((isalpha(ch)
&& (ch == 'd' || ch == 's' || ch == 'c'
|| ch == 'e' || ch == 'E' || ch == 'f'
|| ch == 'g' || ch == 'G' || ch == 'i'
|| ch == 'u' || ch == 'x' || ch == 'X'))
|| ch == '%')
{spec[sub] = 0;
/* set the size modifier, if any */
size_mod = *(curr - 1);
/* check for enough room to process the new flags */
if(ch == 'u')
cm_paren = space_flag = 'n';
if(cm_comma == 'y' || cm_dollar == 'y' || cm_paren == 'y')
{if(ch == 'u' || ch == 'd' || ch == 'i')
{wrk1 = max(max(precision, min_width),
(size_mod == 'l' ?
sizeof(long) : sizeof(int)) * 3);
if(wrk1 > sizeof(cm_in) - 1)
cm_comma = cm_paren = cm_dollar = 'n';}
else if(ch == 'f')
{wrk1 = max(min_width,
(have_precision == 'y' ?
precision : 6)
+ (size_mod == 'L' ?
sizeof(long double) :
sizeof(double)) * 3 + 5);
if(wrk1 > sizeof(cm_in) - 1)
cm_comma = cm_paren = cm_dollar = 'n';}
else
cm_comma = cm_paren = cm_dollar = 'n';}
/* process the type */
if(ch == 's')
{d1 = va_arg(ap, struct d1_meta *);
if(d1->ptr == original_out_ptr && d1->limit1)
goto error;
if(d1->occurs)
{make_safe(d1, mall, save_ptr, save, VA_END);
ret = sprintf(&base[added],
spec, (char *)d1->ptr);
undo_safe(d1, mall, save_ptr, save);}
else
ret = sprintf(&base[added], spec, "");
if(ret < 0)
goto error;
else
added += ret;}
else if(cm_comma == 'y'
|| cm_dollar == 'y' || cm_paren == 'y')
{if(ch == 'f' && size_mod == 'L')
ret = sprintf(cm_in, spec,
va_arg(ap, long double));
else if(ch == 'f')
ret = sprintf(cm_in, spec, va_arg(ap, double));
else if(size_mod == 'l')
ret = sprintf(cm_in, spec, va_arg(ap, long));
else
ret = sprintf(cm_in, spec, va_arg(ap, int));
if(ret < 0)
goto error;
/* add the commas, etc. as needed */
format_new_flags(cm_comma, cm_dollar, cm_paren,
cm_in, cm_out, space_flag);
/* output the new string */
ret = sprintf(&base[added], "%s", cm_out);
if(ret < 0)
goto error;
else
added += ret;}
else if(ch == 'c' || ch == 'd' || ch == 'i')
{if(size_mod == 'l')
ret = sprintf(&base[added],
spec, va_arg(ap, long));
else
ret = sprintf(&base[added],
spec, va_arg(ap, int));
if(ret < 0)
goto error;
else
added += ret;}
else if(ch == 'u' || ch == 'x' || ch == 'X')
{if(size_mod == 'l')
ret = sprintf(&base[added],
spec, va_arg(ap, long));
else
ret = sprintf(&base[added],
spec, va_arg(ap, int));
if(ret < 0)
goto error;
else
added += ret;}
else if(ch == 'f' || ch == 'e' || ch == 'E'
|| ch == 'g' || ch == 'G')
{if(size_mod == 'L')
ret = sprintf(&base[added],
spec, va_arg(ap, long double));
else
ret = sprintf(&base[added],
spec, va_arg(ap, double));
if(ret < 0)
goto error;
else
added += ret;}
else if(ch == '%')
{ret = sprintf(&base[added], spec);
if(ret < 0)
goto error;
else
added += ret;}
else
goto error;
if(curr == end)
goto done;
else
{bgn = curr + 1;
goto cont1;}}}
goto error;
cont1: ;}}
error:
done:
out->occurs += added;
va_end(ap);
*((int *)(return_ptr[1])) = added;
return;
out_failure:
va_end(ap);
if(out_is_var)
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
else
{/* subtracting 1 from new_min to represent it as a 0-relative subscript */
*((moal_t *)(return_ptr[2])) = new_min - 1;
*((moal_t *)(return_ptr[3])) = out->limit1;}
return;
}
void _mc__scanf(void *return_ptr[], struct d1_meta *format, ...)
{
int assignments = 0;
unsigned char *bgn, *end, *curr, *aa,
save, ch, spec[1000], size_mod, suppress, scanset, num[30];
int wrk1, wrk2, ret, sub, max_width, n_total = 0, n, insert_max_width, len;
moal_t new_min;
struct d1_meta *d1;
void *arg_ptr;
va_list ap;
va_start(ap, format);
if(format->occurs == 0)
goto done;
curr = bgn = (unsigned char *)format->ptr;
end = bgn + format->occurs - 1;
for(;; ++curr)
{if(curr == end)
{save = *(curr + 1);
*(curr + 1) = 0;
ret = scanf(bgn);
*(curr + 1) = save;
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
break;}
if(*curr == '%') /* beginning of conversion specification */
{/* extract up to and including the conversion specification */
scanset = suppress = 'n';
max_width = sub = 0;
for(aa = bgn; aa <= curr; ++aa)
spec[sub++] = *aa;
if(*(curr + 1) == '*')
suppress = 'y';
else
insert_max_width = sub;
for(++curr; curr <= end && sub < sizeof(spec) - 20; ++curr)
{ch = *curr;
if(scanset == 'n')
{/* check for ANSI C conversions that are invalid
in MOAL C */
if(ch == 'p' || ch == 'o')
goto error;
if(isdigit(ch) && max_width == 0)
max_width = strtol(curr, NULL, 10);}
spec[sub++] = ch;
if(ch == '[' && scanset == 'n')
{scanset = 'y';
if(*(curr + 1) == ']')
{spec[sub++] = ']';
++curr;}
else if(*(curr + 1) == '^'
&& *(curr + 2) == ']')
{spec[sub++] = '^';
spec[sub++] = ']';
curr += 2;}
continue;}
if(scanset == 'y' && ch != ']')
continue;
/* check for end of the conversion specification */
if((isalpha(ch)
&& (ch == 'd' || ch == 's' || ch == 'c'
|| ch == 'e' || ch == 'E' || ch == 'f'
|| ch == 'g' || ch == 'G' || ch == 'i'
|| ch == 'u' || ch == 'x' || ch == 'X'
|| ch == 'n'))
|| ch == '%' || ch == ']')
{if(suppress == 'y' || ch == '%')
goto cont1;
if(ch != 'n')
{/* add %n */
spec[sub++] = '%';
spec[sub++] = 'n';}
spec[sub] = 0;
/* set the size modifier, if any */
size_mod = *(curr - 1);
/* get the target */
arg_ptr = va_arg(ap, void *);
/* process the type */
if(ch == 'c')
{d1 = (struct d1_meta *)arg_ptr;
d1->occurs = 0;
if(max_width == 0)
max_width = 1;
new_min = max_width;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}
n = 0;
ret = scanf(spec, d1->ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;
d1->occurs = max_width;}
else if(ch == 's' || ch == ']')
{d1 = (struct d1_meta *)arg_ptr;
d1->occurs = 0;
if(max_width == 0)
{max_width = SCANF_MAXWIDTH;
new_min = max_width + ROOM_FOR_C_ADDED_NULL;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}
/* insert the max width in the spec */
len = sprintf(num, "%u", max_width);
for(wrk1 = sub;
wrk1 >= insert_max_width; --wrk1)
spec[wrk1 + len] = spec[wrk1];
for(wrk1 = insert_max_width, wrk2 = 0;
len > 0; --len)
spec[wrk1++] = num[wrk2++];}
else
{new_min = max_width + ROOM_FOR_C_ADDED_NULL;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}}
n = 0;
ret = scanf(spec, d1->ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;
d1->occurs = strlen((char *)d1->ptr);}
else if(ch == 'n')
{if(size_mod == 'l')
{/* erase the size mod from the spec */
spec[sub - 2] = spec[sub - 1];
spec[sub - 1] = 0;
--sub;}
if(sub > 2)
{n = 0;
ret = scanf(spec, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || n == 0)
goto done;
n_total += n;}
if(size_mod == 'l')
*((long *)arg_ptr) = n_total;
else
*((int *)arg_ptr) = n_total;}
else if(ch == 'd' || ch == 'i' || ch == 'u'
|| ch == 'x' || ch == 'X')
{n = 0;
ret = scanf(spec, arg_ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;}
else if(ch == 'e' || ch == 'f' || ch == 'g'
|| ch == 'E' || ch == 'G')
{n = 0;
ret = scanf(spec, arg_ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;}
else
goto error;
if(curr == end)
goto done;
else
{bgn = curr + 1;
goto cont1;}}}
goto error;
cont1: ;}}
error:
done:
va_end(ap);
*((int *)(return_ptr[1])) = assignments;
return;
memory_failure:
va_end(ap);
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
void _mc__fscanf(void *return_ptr[], int file, struct d1_meta *format, ...)
{
int assignments = 0;
unsigned char *bgn, *end, *curr, *aa,
save, ch, spec[1000], size_mod, suppress, scanset, num[30];
int wrk1, wrk2, ret, sub, max_width, n_total = 0, n, insert_max_width, len;
moal_t new_min;
struct d1_meta *d1;
void *arg_ptr;
FILE *fptr;
va_list ap;
va_start(ap, format);
if(format->occurs == 0)
goto done;
if((fptr = retrieve_file(file)) == NULL)
goto error;
curr = bgn = (unsigned char *)format->ptr;
end = bgn + format->occurs - 1;
for(;; ++curr)
{if(curr == end)
{save = *(curr + 1);
*(curr + 1) = 0;
ret = fscanf(fptr, bgn);
*(curr + 1) = save;
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
break;}
if(*curr == '%') /* beginning of conversion specification */
{/* extract up to and including the conversion specification */
scanset = suppress = 'n';
max_width = sub = 0;
for(aa = bgn; aa <= curr; ++aa)
spec[sub++] = *aa;
if(*(curr + 1) == '*')
suppress = 'y';
else
insert_max_width = sub;
for(++curr; curr <= end && sub < sizeof(spec) - 20; ++curr)
{ch = *curr;
if(scanset == 'n')
{/* check for ANSI C conversions that are invalid
in MOAL C */
if(ch == 'p' || ch == 'o')
goto error;
if(isdigit(ch) && max_width == 0)
max_width = strtol(curr, NULL, 10);}
spec[sub++] = ch;
if(ch == '[' && scanset == 'n')
{scanset = 'y';
if(*(curr + 1) == ']')
{spec[sub++] = ']';
++curr;}
else if(*(curr + 1) == '^'
&& *(curr + 2) == ']')
{spec[sub++] = '^';
spec[sub++] = ']';
curr += 2;}
continue;}
if(scanset == 'y' && ch != ']')
continue;
/* check for end of the conversion specification */
if((isalpha(ch)
&& (ch == 'd' || ch == 's' || ch == 'c'
|| ch == 'e' || ch == 'E' || ch == 'f'
|| ch == 'g' || ch == 'G' || ch == 'i'
|| ch == 'u' || ch == 'x' || ch == 'X'
|| ch == 'n'))
|| ch == '%' || ch == ']')
{if(suppress == 'y' || ch == '%')
goto cont1;
if(ch != 'n')
{/* add %n */
spec[sub++] = '%';
spec[sub++] = 'n';}
spec[sub] = 0;
/* set the size modifier, if any */
size_mod = *(curr - 1);
/* get the target */
arg_ptr = va_arg(ap, void *);
/* process the type */
if(ch == 'c')
{d1 = (struct d1_meta *)arg_ptr;
d1->occurs = 0;
if(max_width == 0)
max_width = 1;
new_min = max_width;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}
n = 0;
ret = fscanf(fptr, spec, d1->ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;
d1->occurs = max_width;}
else if(ch == 's' || ch == ']')
{d1 = (struct d1_meta *)arg_ptr;
d1->occurs = 0;
if(max_width == 0)
{max_width = SCANF_MAXWIDTH;
new_min = max_width + ROOM_FOR_C_ADDED_NULL;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}
/* insert the max width in the spec */
len = sprintf(num, "%u", max_width);
for(wrk1 = sub;
wrk1 >= insert_max_width; --wrk1)
spec[wrk1 + len] = spec[wrk1];
for(wrk1 = insert_max_width, wrk2 = 0;
len > 0; --len)
spec[wrk1++] = num[wrk2++];}
else
{new_min = max_width + ROOM_FOR_C_ADDED_NULL;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}}
n = 0;
ret = fscanf(fptr, spec, d1->ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;
d1->occurs = strlen((char *)d1->ptr);}
else if(ch == 'n')
{if(size_mod == 'l')
{/* erase the size mod from the spec */
spec[sub - 2] = spec[sub - 1];
spec[sub - 1] = 0;
--sub;}
if(sub > 2)
{n = 0;
ret = fscanf(fptr, spec, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || n == 0)
goto done;
n_total += n;}
if(size_mod == 'l')
*((long *)arg_ptr) = n_total;
else
*((int *)arg_ptr) = n_total;}
else if(ch == 'd' || ch == 'i' || ch == 'u'
|| ch == 'x' || ch == 'X')
{n = 0;
ret = fscanf(fptr, spec, arg_ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;}
else if(ch == 'e' || ch == 'f' || ch == 'g'
|| ch == 'E' || ch == 'G')
{n = 0;
ret = fscanf(fptr, spec, arg_ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;}
else
goto error;
if(curr == end)
goto done;
else
{bgn = curr + 1;
goto cont1;}}}
goto error;
cont1: ;}}
error:
done:
va_end(ap);
*((int *)(return_ptr[1])) = assignments;
return;
memory_failure:
va_end(ap);
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
void _mc__sscanf(void *return_ptr[],
struct d1_meta *source, struct d1_meta *format, ...)
{
int assignments = 0;
unsigned char *bgn, *end, *curr, *aa, *src,
save, ch, spec[1000], size_mod, suppress, scanset, num[30],
save_src;
int wrk1, wrk2, ret, sub, max_width, n_total = 0, n, insert_max_width, len,
undo = FALSE, mall;
void *save_ptr;
moal_t new_min;
struct d1_meta *d1;
void *arg_ptr;
va_list ap;
va_start(ap, format);
if(format->occurs == 0 || source->occurs == 0)
goto done;
make_safe(source, mall, save_ptr, save_src, VA_END);
undo = TRUE;
src = (unsigned char *)source->ptr;
curr = bgn = (unsigned char *)format->ptr;
end = bgn + format->occurs - 1;
for(;; ++curr)
{if(curr == end)
{save = *(curr + 1);
*(curr + 1) = 0;
ret = sscanf(&src[n_total], bgn);
*(curr + 1) = save;
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
break;}
if(*curr == '%') /* beginning of conversion specification */
{/* extract up to and including the conversion specification */
scanset = suppress = 'n';
max_width = sub = 0;
for(aa = bgn; aa <= curr; ++aa)
spec[sub++] = *aa;
if(*(curr + 1) == '*')
suppress = 'y';
else
insert_max_width = sub;
for(++curr; curr <= end && sub < sizeof(spec) - 20; ++curr)
{ch = *curr;
if(scanset == 'n')
{/* check for ANSI C conversions that are invalid
in MOAL C */
if(ch == 'p' || ch == 'o')
goto error;
if(isdigit(ch) && max_width == 0)
max_width = strtol(curr, NULL, 10);}
spec[sub++] = ch;
if(ch == '[' && scanset == 'n')
{scanset = 'y';
if(*(curr + 1) == ']')
{spec[sub++] = ']';
++curr;}
else if(*(curr + 1) == '^'
&& *(curr + 2) == ']')
{spec[sub++] = '^';
spec[sub++] = ']';
curr += 2;}
continue;}
if(scanset == 'y' && ch != ']')
continue;
/* check for end of the conversion specification */
if((isalpha(ch)
&& (ch == 'd' || ch == 's' || ch == 'c'
|| ch == 'e' || ch == 'E' || ch == 'f'
|| ch == 'g' || ch == 'G' || ch == 'i'
|| ch == 'u' || ch == 'x' || ch == 'X'
|| ch == 'n'))
|| ch == '%' || ch == ']')
{if(suppress == 'y' || ch == '%')
goto cont1;
if(ch != 'n')
{/* add %n */
spec[sub++] = '%';
spec[sub++] = 'n';}
spec[sub] = 0;
/* set the size modifier, if any */
size_mod = *(curr - 1);
/* get the target */
arg_ptr = va_arg(ap, void *);
/* process the type */
if(ch == 'c')
{d1 = (struct d1_meta *)arg_ptr;
if(d1->limit1 && d1->ptr == src)
goto error;
d1->occurs = 0;
if(max_width == 0)
max_width = 1;
new_min = max_width;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}
n = 0;
ret = sscanf(&src[n_total], spec, d1->ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;
d1->occurs = max_width;}
else if(ch == 's' || ch == ']')
{d1 = (struct d1_meta *)arg_ptr;
if(d1->limit1 && d1->ptr == src)
goto error;
d1->occurs = 0;
if(max_width == 0)
{max_width = SCANF_MAXWIDTH;
new_min = max_width + ROOM_FOR_C_ADDED_NULL;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}
/* insert the max width in the spec */
len = sprintf(num, "%u", max_width);
for(wrk1 = sub;
wrk1 >= insert_max_width; --wrk1)
spec[wrk1 + len] = spec[wrk1];
for(wrk1 = insert_max_width, wrk2 = 0;
len > 0; --len)
spec[wrk1++] = num[wrk2++];}
else
{new_min = max_width + ROOM_FOR_C_ADDED_NULL;
if(new_min > d1->limit1)
{if(!resize_cspace(d1, new_min))
goto memory_failure;}}
n = 0;
ret = sscanf(&src[n_total], spec, d1->ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;
d1->occurs = strlen((char *)d1->ptr);}
else if(ch == 'n')
{if(size_mod == 'l')
{/* erase the size mod from the spec */
spec[sub - 2] = spec[sub - 1];
spec[sub - 1] = 0;
--sub;}
if(sub > 2)
{n = 0;
ret = sscanf(&src[n_total], spec, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || n == 0)
goto done;
n_total += n;}
if(size_mod == 'l')
*((long *)arg_ptr) = n_total;
else
*((int *)arg_ptr) = n_total;}
else if(ch == 'd' || ch == 'i' || ch == 'u'
|| ch == 'x' || ch == 'X')
{n = 0;
ret = sscanf(&src[n_total], spec, arg_ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;}
else if(ch == 'e' || ch == 'f' || ch == 'g'
|| ch == 'E' || ch == 'G')
{n = 0;
ret = sscanf(&src[n_total], spec, arg_ptr, &n);
if(ret == EOF && assignments == 0)
assignments = MC_EOF;
if(ret == EOF || ret < 1)
goto done;
assignments += ret;
n_total += n;}
else
goto error;
if(curr == end)
goto done;
else
{bgn = curr + 1;
goto cont1;}}}
goto error;
cont1: ;}}
error:
done:
va_end(ap);
if(undo)
undo_safe(source, mall, save_ptr, save_src);
*((int *)(return_ptr[1])) = assignments;
return;
memory_failure:
va_end(ap);
if(undo)
undo_safe(source, mall, save_ptr, save_src);
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
/*
* library functions for math
*/
void _mc__abs(void *return_ptr[], int x)
{
*((int *)(return_ptr[1])) = abs(x);
return;
}
void _mc__acos(void *return_ptr[], double x)
{
double answer;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(dblerr(x))
answer = nan.num;
else
{errno = 0;
answer = acos(x);
if(errno == EDOM)
answer = nan.num;}
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__asin(void *return_ptr[], double x)
{
double answer;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(dblerr(x))
answer = nan.num;
else
{errno = 0;
answer = asin(x);
if(errno == EDOM)
answer = nan.num;}
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__atan(void *return_ptr[], double x)
{
#define PIHALF 1.5707963267948966
double answer;
int err;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(err = dblerr(x))
{if(err == MC_NaN)
answer = nan.num;
else if(err == MC_pINF)
answer = PIHALF;
else
answer = -PIHALF;}
else
answer = atan(x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__atan2(void *return_ptr[], double y, double x)
{
#define PI 3.1415926535897931
double answer;
int err1, err2;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
err1 = dblerr(y);
err2 = dblerr(x);
if(err1 || err2)
{if(err1 == MC_NaN || err2 == MC_NaN || (err1 && err2))
answer = nan.num;
/* have one infinity and one finite */
if(err1 == MC_pINF)
answer = PIHALF;
else if(err1 == MC_nINF)
answer = -PIHALF;
else if(y >= 0.0)
{if(err2 == MC_pINF)
answer = 0.0;
else
answer = PI;}
else
{if(err2 == MC_pINF)
answer = -0.0;
else
answer = -PI;}}
else if(x == 0.0 && y == 0.0)
answer = nan.num;
else
answer = atan2(y, x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__ceil(void *return_ptr[], double x)
{
double answer;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(dblerr(x))
answer = x;
else
answer = ceil(x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__cos(void *return_ptr[], double x)
{
double answer;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(dblerr(x))
answer = nan.num;
else
answer = cos(x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__div(void *return_ptr[], int x, int divide_by)
{
div_t ans;
ans = div(x, divide_by);
*((int *)(return_ptr[1])) = ans.quot;
*((int *)(return_ptr[2])) = ans.rem;
return;
}
void _mc__exp(void *return_ptr[], double x)
{
double answer;
int err;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(err = dblerr(x))
{if(err == MC_nINF)
answer = 0.0;
else
answer = x;}
else
{errno = 0;
answer = exp(x);
if(errno == ERANGE && x > 0.0)
answer = pos_inf.num;}
*((double *)(return_ptr[1])) = answer;
}
void _mc__fabs(void *return_ptr[], double x)
{
double answer;
int err;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(err = dblerr(x))
{if(err == MC_NaN || err == MC_pINF)
answer = x;
else
answer = pos_inf.num;}
else
answer = fabs(x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__floor(void *return_ptr[], double x)
{
double answer;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(dblerr(x))
answer = x;
else
answer = floor(x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__fmod(void *return_ptr[], double x, double divide_by)
{
double answer;
int err1, err2;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
err1 = dblerr(x);
err2 = dblerr(divide_by);
if(err1 || err2)
{if(err1 || err2 == MC_NaN)
answer = nan.num;
else /* dividing a finite by infinity, so remainder is x */
answer = x;}
else if(divide_by == 0.0)
answer = nan.num;
else
answer = fmod(x, divide_by);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__labs(void *return_ptr[], long x)
{
*((long *)(return_ptr[1])) = labs(x);
return;
}
void _mc__ldiv(void *return_ptr[], long x, long divide_by)
{
ldiv_t ans;
ans = ldiv(x, divide_by);
*((long *)(return_ptr[1])) = ans.quot;
*((long *)(return_ptr[2])) = ans.rem;
return;
}
void _mc__log(void *return_ptr[], double x)
{
double answer;
int err;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(err = dblerr(x))
{if(err == MC_NaN || err == MC_nINF)
answer = nan.num;
else
answer = pos_inf.num;}
else if(x <= 0.0)
{if(x == 0.0)
answer = neg_inf.num;
else
answer = nan.num;}
else
answer = log(x);
*((double *)(return_ptr[1])) = answer;
}
void _mc__log10(void *return_ptr[], double x)
{
double answer;
int err;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(err = dblerr(x))
{if(err == MC_NaN || err == MC_nINF)
answer = nan.num;
else
answer = pos_inf.num;}
else if(x <= 0.0)
{if(x == 0.0)
answer = neg_inf.num;
else
answer = nan.num;}
else
answer = log10(x);
*((double *)(return_ptr[1])) = answer;
}
void _mc__merr(void *return_ptr[], double x)
{
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
*((int *)(return_ptr[1])) = dblerr(x);
}
void _mc__pow(void *return_ptr[], double x, double power)
{
double answer;
int err1, err2;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
err1 = dblerr(x);
err2 = dblerr(power);
if(err1 || err2)
{if(err1 == MC_NaN || err2 == MC_NaN)
answer = nan.num;
else if(!err2 && power == 0.0)
answer = 1.0;
else if(err1 != MC_nINF && (err1 == MC_pINF || x > 1.0)) /* x > 1 */
{/* assuming that a finite root of an infinity is an infinity,
for when -1 < power < 1 and power != 0 and x is +infinity */
if(err2 == MC_nINF || (!err2 && power < 0.0)) /* power < 0 */
answer = 0.0;
else
answer = pos_inf.num;}
else if(err1 != MC_pINF && (err1 == MC_nINF || x < -1.0)) /* x < -1 */
{/* assuming that a finite root of an infinity is an infinity,
for when -1 < power < 0 and x is -infinity */
if(err2 == MC_nINF || (!err2 && power < 0.0)) /* power < 0 */
answer = 0.0;
else
answer = nan.num;} /* sign is indeterminate */
else if(x == 0.0)
{if(err2 == MC_pINF)
answer = 0.0;
else
answer = nan.num;} /* division by zero */
else if(x == 1.0)
answer = 1.0;
else if(x == -1.0)
answer = nan.num; /* sign is indeterminate */
else /* either -1 < x < 0 or 0 < x < 1 */
{if(err2 == MC_pINF)
answer = 0.0;
else
answer = nan.num;}} /* division by zero */
else
{errno = 0;
answer = pow(x, power);
if(errno == EDOM || (x == 0.0 && power <= 0.0))
answer = nan.num;
else if(errno == ERANGE && answer != 0.0)
{if(answer > 0.0)
answer = pos_inf.num;
else
answer = neg_inf.num;}}
*((double *)(return_ptr[1])) = answer;
}
/*
* uses the standard linear congruential method
*
* the value 2147483648 is INT_MAX + 1
*
* the value 418473621 was chosen in accordance with these rules:
* 1) has one less digit than the divisor INT_MAX + 1
* 2) the number ends with x21 where x is an even digit
*/
void _mc__rand(void *return_ptr[], int prev)
{
assert(INT_MAX == 2147483647);
*((int *)(return_ptr[1])) = ((unsigned)prev * 418473621 + 1) % 2147483648u;
return;
}
void _mc__sin(void *return_ptr[], double x)
{
double answer;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(dblerr(x))
answer = nan.num;
else
answer = sin(x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__sqrt(void *return_ptr[], double x)
{
double answer;
int err;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(err = dblerr(x))
{if(err == MC_NaN || err == MC_nINF)
answer = nan.num;
else
answer = pos_inf.num;}
else if(x < 0.0)
answer = nan.num;
else
answer = sqrt(x);
*((double *)(return_ptr[1])) = answer;
return;
}
void _mc__tan(void *return_ptr[], double x)
{
double answer;
union {
unsigned char cc[WORK_SIZE];
double num;
} work;
if(dblerr(x))
answer = nan.num;
else
answer = tan(x);
*((double *)(return_ptr[1])) = answer;
return;
}
/*
* library functions for time
*/
void _mc__clock(void *return_ptr[])
{
*((ff_clock_t *)(return_ptr[1])) = clock();
return;
}
void _mc__ctime(void *return_ptr[], ff_time_t any_time)
{
char *ctm_ptr;
int len;
moal_t new_min;
time_t tt;
((struct d1_meta *)(return_ptr[1]))->occurs = 0;
tt = any_time;
ctm_ptr = ctime(&tt);
if(ctm_ptr == NULL)
return;
/* remove the trailing \n */
len = strlen(ctm_ptr);
if(len > 0)
{ctm_ptr[len - 1] = 0;
--len;}
new_min = len;
if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
goto memory_failure;
strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, ctm_ptr, len);
((struct d1_meta *)(return_ptr[1]))->occurs = len;
return;
memory_failure:
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
void _mc__difftime(void *return_ptr[],
ff_time_t any_time, ff_time_t subtract_time)
{
*((double *)(return_ptr[1])) = difftime((time_t)any_time,
(time_t)subtract_time);
return;
}
void _mc__gmtime(void *return_ptr[], ff_time_t any_time)
{
struct ff_tm time_info = {0};
struct tm *tm_ptr;
time_t tt;
tt = any_time;
tm_ptr = gmtime(&tt);
if(tm_ptr == NULL)
time_info.tm_sec = -1;
else
tm_to_ff_tm(tm_ptr, &time_info);
*((struct ff_tm *)(return_ptr[1])) = time_info;
return;
}
void _mc__localtime(void *return_ptr[], ff_time_t any_time)
{
struct ff_tm time_info;
struct tm *tm_ptr;
time_t tt;
tt = any_time;
tm_ptr = localtime(&tt);
tm_to_ff_tm(tm_ptr, &time_info);
*((struct ff_tm *)(return_ptr[1])) = time_info;
return;
}
void _mc__mktime(void *return_ptr[], struct ff_tm *time_info)
{
struct tm tm_s;
time_t tt;
ff_tm_to_tm(time_info, &tm_s);
tt = mktime(&tm_s);
if(tt == (time_t)-1)
*((ff_time_t *)(return_ptr[1])) = (ff_time_t)-1;
else
*((ff_time_t *)(return_ptr[1])) = tt;
return;
}
void _mc__strftime(void *return_ptr[],
struct d1_meta *format, struct ff_tm *time_info)
{
struct tm tm_s;
int len, mall;
void *save_ptr;
moal_t new_min;
unsigned char save;
((struct d1_meta *)(return_ptr[1]))->occurs = 0;
if(format->occurs == 0)
return;
ff_tm_to_tm(time_info, &tm_s);
for(new_min = 100; new_min < 5000; new_min += 500)
{if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
goto memory_failure;
make_safe(format, mall, save_ptr, save, NONE);
len = strftime((char *)((struct d1_meta *)(return_ptr[1]))->ptr,
((struct d1_meta *)(return_ptr[1]))->limit1,
(char *)format->ptr, &tm_s);
undo_safe(format, mall, save_ptr, save);
if(len > 0)
break;}
((struct d1_meta *)(return_ptr[1]))->occurs = len;
return;
memory_failure:
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
void _mc__time(void *return_ptr[])
{
*((ff_time_t *)(return_ptr[1])) = time(NULL);
return;
}
/*
* library functions for file I/O
*/
void _mc__fclose(void *return_ptr[], int file)
{
int ret, error = 0;
FILE *fptr;
if((fptr = retrieve_file(file)) == NULL || file < FIRST_USER_FILE)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
errno = 0;
ret = fclose(fptr);
if(ret)
error = errno;
else
remove_file(file);
done:
*((int *)(return_ptr[1])) = error;
return;
}
void _mc__fgetc(void *return_ptr[], int file)
{
int ret = 0, error = 0;
FILE *fptr;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
errno = 0;
ret = fgetc(fptr);
if(ret == EOF)
{if(feof(fptr))
error = MC_EOF;
else
error = errno;
ret = 0;}
done:
*((int *)(return_ptr[1])) = error;
*((char *)(return_ptr[2])) = ret;
return;
}
/*
* reads at most count characters (not n - 1) since not adding null at end
*/
void _mc__fgets(void *return_ptr[], struct d1_meta *out, ff_size_t count,
int file)
{
int error = 0;
FILE *fptr;
int wrk1, out_is_var, cnt, ch;
out->occurs = 0;
if(return_ptr[3] == NULL)
out_is_var = TRUE;
else
out_is_var = FALSE;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
for(errno = 0, cnt = ch = 0; cnt < count && (ch = getc(fptr)) != EOF;)
{++cnt;
if(cnt > out->limit1)
{if(!out_is_var || !resize_cspace(out, cnt))
goto out_failure;}
*(((unsigned char *)(out->ptr)) + (cnt - 1)) = ch;
if(ch == '\n')
break;}
if(ch == EOF)
{if(feof(fptr))
{if(cnt == 0)
error = MC_EOF;}
else
error = errno;}
if(!error)
out->occurs = cnt;
done:
*((int *)(return_ptr[1])) = error;
return;
out_failure:
if(out_is_var)
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
else
{/* subtracting 1 from cnt to represent it as a 0-relative subscript */
*((moal_t *)(return_ptr[2])) = cnt - 1;
*((moal_t *)(return_ptr[3])) = out->limit1;}
return;
}
void _mc__fopen(void *return_ptr[], struct d1_meta *filename,
struct d1_meta *mode)
{
int error = 0, file = 0, mall_f, mall_m;
void *save_ptr_f, *save_ptr_m;
FILE *fptr;
unsigned char save_f, save_m;
if(filename->occurs == 0 || mode->occurs == 0)
{error = MC_EMPTY_PARAMETER;
goto done;}
make_safe(filename, mall_f, save_ptr_f, save_f, NONE);
make_safe(mode, mall_m, save_ptr_m, save_m, NONE);
errno = 0;
fptr = fopen((char *)filename->ptr, (char *)mode->ptr);
if(fptr == NULL)
error = errno;
else
{file = store_file(fptr);
if(file == 0)
error = MC_TOO_MANY_OPEN_FILES;}
undo_safe(filename, mall_f, save_ptr_f, save_f);
undo_safe(mode, mall_m, save_ptr_m, save_m);
done:
*((int *)(return_ptr[1])) = error;
*((int *)(return_ptr[2])) = file;
return;
}
void _mc__fputc(void *return_ptr[], char character, int file)
{
int ret, error = 0;
FILE *fptr;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
errno = 0;
ret = fputc(character, fptr);
if(ret == EOF)
error = errno;
done:
*((int *)(return_ptr[1])) = error;
return;
}
void _mc__fputs(void *return_ptr[], struct d1_meta *source, int file)
{
int error = 0;
size_t written;
FILE *fptr;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
if(source->occurs == 0)
goto done;
errno = 0;
written = fwrite((char *)source->ptr, 1, source->occurs, fptr);
if(written != source->occurs)
error = errno;
done:
*((int *)(return_ptr[1])) = error;
return;
}
void _mc__fread(void *return_ptr[], struct d1_meta *out,
ff_size_t out_offset, ff_size_t read_count, int file)
{
int error = 0;
ff_size_t read = 0;
moal_t new_min;
FILE *fptr;
int out_is_var;
if(return_ptr[4] == NULL)
out_is_var = TRUE;
else
out_is_var = FALSE;
if(out_offset > out->occurs)
{error = MC_OFFSET_INVALID;
goto done;}
else
out->occurs = out_offset;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
if(read_count == 0)
goto done;
if(sum_overflows(moal_t, out_offset, read_count))
{error = MC_INCOMPATIBLE_PARAMS;
goto done;}
new_min = out_offset + read_count;
if(new_min > out->limit1)
{if(!out_is_var || !resize_cspace(out, new_min))
goto out_failure;}
errno = 0;
read = fread((char *)out->ptr + out_offset, 1, read_count, fptr);
if(read != read_count)
{if(feof(fptr))
{if(read == 0)
error = MC_EOF;}
else if(ferror(fptr))
{error = errno;
read = 0;}}
if(!error)
out->occurs = out_offset + read;
done:
*((int *)(return_ptr[1])) = error;
*((ff_size_t *)(return_ptr[2])) = read;
return;
out_failure:
if(out_is_var)
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
else
{/* subtracting 1 from new_min to represent it as a 0-relative subscript */
*((moal_t *)(return_ptr[3])) = new_min - 1;
*((moal_t *)(return_ptr[4])) = out->limit1;}
return;
}
void _mc__fseek(void *return_ptr[], int file, long offset, int from_where)
{
int error = 0;
int ret;
FILE *fptr;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
if(from_where == 1)
from_where = SEEK_CUR;
else if(from_where == 2)
from_where = SEEK_END;
else if(from_where == 3)
from_where = SEEK_SET;
errno = 0;
ret = fseek(fptr, offset, from_where);
if(ret)
error = errno;
done:
*((int *)(return_ptr[1])) = error;
return;
}
void _mc__ftell(void *return_ptr[], int file)
{
int error = 0;
long current_position = 0;
FILE *fptr;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
errno = 0;
current_position = ftell(fptr);
if(errno)
{error = errno;
current_position = 0;}
done:
*((int *)(return_ptr[1])) = error;
*((long *)(return_ptr[2])) = current_position;
return;
}
void _mc__fwrite(void *return_ptr[], struct d1_meta *source,
ff_size_t source_offset, ff_size_t write_count, int file)
{
int error = 0;
FILE *fptr;
size_t written;
if((fptr = retrieve_file(file)) == NULL)
{error = MC_INVALID_FILE_NUMBER;
goto done;}
if(source->occurs && source_offset >= source->occurs)
{error = MC_OFFSET_INVALID;
goto done;}
if(sum_overflows(moal_t, source_offset, write_count)
|| source_offset + write_count > source->occurs)
{error = MC_INCOMPATIBLE_PARAMS;
goto done;}
if(write_count == 0)
goto done;
errno = 0;
written = fwrite((char *)source->ptr + source_offset, 1, write_count, fptr);
if(written != write_count)
error = errno;
done:
*((int *)(return_ptr[1])) = error;
return;
}
void _mc__remove(void *return_ptr[], struct d1_meta *filename)
{
int error = 0, ret, mall;
void *save_ptr;
unsigned char save;
if(filename->occurs == 0)
{error = MC_EMPTY_PARAMETER;
goto done;}
make_safe(filename, mall, save_ptr, save, NONE);
errno = 0;
ret = remove((char *)filename->ptr);
if(ret)
error = errno;
undo_safe(filename, mall, save_ptr, save);
done:
*((int *)(return_ptr[1])) = error;
return;
}
void _mc__rename(void *return_ptr[], struct d1_meta *current_filename,
struct d1_meta *new_filename)
{
int error = 0, ret, mall_o, mall_n;
void *save_ptr_o, *save_ptr_n;
unsigned char save_o, save_n;
if(current_filename->occurs == 0 || new_filename->occurs == 0)
{error = MC_EMPTY_PARAMETER;
goto done;}
make_safe(current_filename, mall_o, save_ptr_o, save_o, NONE);
make_safe(new_filename, mall_n, save_ptr_n, save_n, NONE);
errno = 0;
ret = rename((char *)current_filename->ptr, (char *)new_filename->ptr);
if(ret)
error = errno;
undo_safe(current_filename, mall_o, save_ptr_o, save_o);
undo_safe(new_filename, mall_n, save_ptr_n, save_n);
done:
*((int *)(return_ptr[1])) = error;
return;
}
void _mc__tmpfile(void *return_ptr[])
{
int error = 0, file = 0;
FILE *fptr;
errno = 0;
fptr = tmpfile();
if(fptr == NULL)
error = errno;
else
{file = store_file(fptr);
if(file == 0)
error = MC_TOO_MANY_OPEN_FILES;}
*((int *)(return_ptr[1])) = error;
*((int *)(return_ptr[2])) = file;
return;
}
void _mc__tmpnam(void *return_ptr[])
{
int len;
moal_t new_min;
char *cp;
((struct d1_meta *)(return_ptr[1]))->occurs = 0;
cp = tmpnam(NULL);
if(cp == NULL)
return;
len = strlen(cp);
new_min = len;
if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
goto memory_failure;
strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, cp, len);
((struct d1_meta *)(return_ptr[1]))->occurs = len;
return;
memory_failure:
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
/*
* library functions for character
*/
void _mc__toupper(void *return_ptr[], char character)
{
*((char *)(return_ptr[1])) = toupper(character);
}
void _mc__tolower(void *return_ptr[], char character)
{
*((char *)(return_ptr[1])) = tolower(character);
}
void _mc__isalnum(void *return_ptr[], char character)
{
*((int *)(return_ptr[1])) = isalnum(character);
}
void _mc__isalpha(void *return_ptr[], char character)
{
*((int *)(return_ptr[1])) = isalpha(character);
}
void _mc__isdigit(void *return_ptr[], char character)
{
*((int *)(return_ptr[1])) = isdigit(character);
}
void _mc__islower(void *return_ptr[], char character)
{
*((int *)(return_ptr[1])) = islower(character);
}
void _mc__isspace(void *return_ptr[], char character)
{
*((int *)(return_ptr[1])) = isspace(character);
}
void _mc__isupper(void *return_ptr[], char character)
{
*((int *)(return_ptr[1])) = isupper(character);
}
/*
* library functions for sort and search
*
* note: both qsort and bsearch assume that the compare function does not
* raise an exception nor cause an exception: any exception coming
* from the compare function is discarded
*/
static void quicksort(int left, int right,
char *buf, int element_size,
char *base, void *ret[2],
void (*compare) (void *[], void *, void *));
/*
* quicksort algorithm
*/
void _mc__qsort(void *return_ptr[], struct d1_meta *base,
ff_size_t element_size,
void (*compare) (void *[], void *, void *))
{
int exception;
char *buf;
void *ret[2];
if(base->occurs < 2)
return;
buf = (char *)malloc(element_size);
if(buf == NULL)
{*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;}
ret[0] = &exception;
quicksort(0, base->occurs - 1,
buf, element_size,
(char *)(base->ptr), ret, compare);
free(buf);
return;
}
static void quicksort(int left, int right,
char *buf, int element_size,
char *base, void *ret[2],
void (*compare) (void *[], void *, void *))
{
char *pivot;
int i, j, k;
int answer;
#define swap(i, j) \
{memcpy(buf, base + (j * element_size), element_size); \
memcpy(base + (j * element_size), base + (i * element_size), element_size); \
memcpy(base + (i * element_size), buf, element_size);}
if(right > left)
{ret[1] = &answer;
/* median of three */
k = left;
if(right - left > 1)
{k += (right - left) / 2;
/* sort left, k, right */
(*compare)(ret, (void *)(base + (left * element_size)),
(void *)(base + (k * element_size)));
if(answer > 0)
swap(left, k)
(*compare)(ret, (void *)(base + (left * element_size)),
(void *)(base + (right * element_size)));
if(answer > 0)
swap(left, right)
(*compare)(ret, (void *)(base + (k * element_size)),
(void *)(base + (right * element_size)));
if(answer > 0)
swap(k, right)
i = left + 1;
j = right - 1;}
else
{i = left;
j = right;}
pivot = base + (element_size * k);
for(;;)
{for(; i < k; ++i)
{(*compare)(ret, (void *)(base + (i * element_size)),
(void *)pivot);
if(answer <= 0)
continue;
else
break;}
for(; j > k; --j)
{(*compare)(ret, (void *)(base + (j * element_size)),
(void *)pivot);
if(answer >= 0)
continue;
else
break;}
if(i == k && j == k)
break;
swap(i, j)
/* check for a changed pivot value */
if(i == k)
i = left;
else if(j == k)
j = right;}
/* recursive calls */
quicksort(left, k - 1,
buf, element_size,
base, ret, compare);
quicksort(k + 1, right,
buf, element_size,
base, ret, compare);}
return;
}
void _mc__bsearch(void *return_ptr[], void *key, struct d1_meta *base,
ff_size_t element_size,
void (*compare) (void *[], void *, void *))
{
int error = MC_NOT_FOUND;
ff_size_t subscript = 0;
void *ret[2];
int wrk1, answer, left, right, exception;
if(base->occurs < 1)
goto done;
/*
* do a binary search
*/
ret[0] = &exception;
ret[1] = &answer;
for(left = 0, right = base->occurs - 1; right >= left;)
{wrk1 = (left + right) / 2;
(*compare)(ret, (void *)key,
(void *)((char *)(base->ptr) + (wrk1 * element_size)));
if(answer == 0)
{error = 0;
subscript = wrk1;
goto done;}
if(answer < 0)
right = wrk1 - 1;
else
left = wrk1 + 1;}
done:
*((int *)(return_ptr[1])) = error;
*((ff_size_t *)(return_ptr[2])) = subscript;
return;
}
/*
* library functions for communication with the environment
*/
void _mc__getenv(void *return_ptr[], struct d1_meta *name)
{
int len, mall;
void *save_ptr;
moal_t new_min;
unsigned char save;
char *cp;
((struct d1_meta *)(return_ptr[1]))->occurs = 0;
if(name->occurs == 0)
return;
make_safe(name, mall, save_ptr, save, NONE);
cp = getenv((char *)name->ptr);
undo_safe(name, mall, save_ptr, save);
if(cp == NULL)
return;
len = strlen(cp);
new_min = len;
if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
goto memory_failure;
strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, cp, len);
((struct d1_meta *)(return_ptr[1]))->occurs = len;
return;
memory_failure:
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
void _mc__exit(void *return_ptr[], int status)
{
exit(status);
}
void _mc__system(void *return_ptr[], struct d1_meta *command)
{
int status, mall;
void *save_ptr;
unsigned char save;
if(command->occurs == 0)
status = system(NULL);
else
{make_safe(command, mall, save_ptr, save, NONE);
status = system((char *)command->ptr);
undo_safe(command, mall, save_ptr, save);}
done:
*((int *)(return_ptr[1])) = status;
return;
}
/*
* string functions
*/
/*
* note: strcat(x, x) works correctly (x.occurs is doubled)
*/
void _mc__strcat(void *return_ptr[],
struct d1_meta *out, struct d1_meta *source)
{
int out_is_var;
moal_t new_min;
if(source->occurs == 0)
goto done;
if(sum_overflows(moal_t, out->occurs, source->occurs))
goto done;
if(return_ptr[2] == NULL)
out_is_var = TRUE;
else
out_is_var = FALSE;
new_min = out->occurs + source->occurs;
if(new_min > out->limit1)
{if(!out_is_var || !resize_cspace(out, new_min))
goto out_failure;}
memcpy((char *)out->ptr + out->occurs, (char *)source->ptr, source->occurs);
out->occurs += source->occurs;
done:
return;
out_failure:
if(out_is_var)
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
else
{/* subtracting 1 from new_min to represent it as a 0-relative subscript */
*((moal_t *)(return_ptr[1])) = new_min - 1;
*((moal_t *)(return_ptr[2])) = out->limit1;}
return;
}
void _mc__strcmp(void *return_ptr[],
struct d1_meta *s1, struct d1_meta *s2)
{
int result = 0;
moal_t wrk1, occurs1, occurs2;
unsigned char *c1, *c2;
c1 = (unsigned char *)s1->ptr;
c2 = (unsigned char *)s2->ptr;
occurs1 = s1->occurs;
occurs2 = s2->occurs;
for(wrk1 = 0;; ++wrk1)
{if(wrk1 < occurs1 && wrk1 < occurs2)
{if(c1[wrk1] != c2[wrk1])
{if(c1[wrk1] < c2[wrk1])
result = -1;
else
result = 1;
break;}}
else if(wrk1 >= occurs1 && wrk1 >= occurs2)
break;
else if(wrk1 >= occurs1)
{result = -1;
break;}
else
{result = 1;
break;}}
*((int *)(return_ptr[1])) = result;
return;
}
void _mc__strcpy(void *return_ptr[],
struct d1_meta *out, struct d1_meta *source)
{
int out_is_var;
moal_t new_min;
if(out->ptr == source->ptr && out->limit1 && source->limit1)
goto done;
else
out->occurs = 0;
if(source->occurs == 0)
goto done;
if(return_ptr[2] == NULL)
out_is_var = TRUE;
else
out_is_var = FALSE;
new_min = source->occurs;
if(new_min > out->limit1)
{if(!out_is_var || !resize_cspace(out, new_min))
goto out_failure;}
memcpy((char *)out->ptr, (char *)source->ptr, source->occurs);
out->occurs = source->occurs;
done:
return;
out_failure:
if(out_is_var)
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
else
{/* subtracting 1 from new_min to represent it as a 0-relative subscript */
*((moal_t *)(return_ptr[1])) = new_min - 1;
*((moal_t *)(return_ptr[2])) = out->limit1;}
return;
}
void _mc__strerror(void *return_ptr[], int error)
{
int len;
moal_t new_min;
char *cp, buf[1000];
((struct d1_meta *)(return_ptr[1]))->occurs = 0;
if(error == MC_EOF
|| error == MC_NOT_FOUND
|| error == MC_EMPTY_PARAMETER
|| error == MC_OFFSET_INVALID
|| error == MC_NaN
|| error == MC_pINF
|| error == MC_nINF
|| error == MC_INCOMPATIBLE_PARAMS
|| error == MC_INVALID_FILE_NUMBER
|| error == MC_TOO_MANY_OPEN_FILES
|| error == MC_REX_MALFORMED
|| error == MC_REX_MATCHES_NOTHING)
{cp = buf;
if(error == MC_EOF)
strcpy(buf, "At end of file");
else if(error == MC_NOT_FOUND)
strcpy(buf, "Not found");
else if(error == MC_EMPTY_PARAMETER)
strcpy(buf, "A parameter is empty (occurs is zero)");
else if(error == MC_OFFSET_INVALID)
strcpy(buf, "An 'offset' parameter is invalid");
else if(error == MC_NaN)
strcpy(buf, "Not a number");
else if(error == MC_pINF)
strcpy(buf, "Positive infinity");
else if(error == MC_nINF)
strcpy(buf, "Negative infinity");
else if(error == MC_INCOMPATIBLE_PARAMS)
strcpy(buf, "Parameter values are incompatible");
else if(error == MC_INVALID_FILE_NUMBER)
strcpy(buf, "File number is invalid");
else if(error == MC_TOO_MANY_OPEN_FILES)
strcpy(buf, "Too many open files");
else if(error == MC_REX_MALFORMED)
strcpy(buf, "Expression is malformed");
else if(error == MC_REX_MATCHES_NOTHING)
strcpy(buf, "Expression can match nothing");
else if(error == MC_MACHINE_EMPTY)
strcpy(buf, "Machine is empty");}
else
{cp = strerror(error);
if(cp == NULL)
return;}
len = strlen(cp);
new_min = len;
if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
goto memory_failure;
strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, cp, len);
((struct d1_meta *)(return_ptr[1]))->occurs = len;
return;
memory_failure:
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
void _mc__strncmp(void *return_ptr[],
struct d1_meta *s1, struct d1_meta *s2, ff_size_t n)
{
int result = 0;
moal_t wrk1, occurs1, occurs2;
unsigned char *c1, *c2;
c1 = (unsigned char *)s1->ptr;
c2 = (unsigned char *)s2->ptr;
occurs1 = s1->occurs;
occurs2 = s2->occurs;
for(wrk1 = 0; wrk1 < n; ++wrk1)
{if(wrk1 < occurs1 && wrk1 < occurs2)
{if(c1[wrk1] != c2[wrk1])
{if(c1[wrk1] < c2[wrk1])
result = -1;
else
result = 1;
break;}}
else if(wrk1 >= occurs1 && wrk1 >= occurs2)
break;
else if(wrk1 >= occurs1)
{result = -1;
break;}
else
{result = 1;
break;}}
*((int *)(return_ptr[1])) = result;
return;
}
/*
* the source space and return space can be the same
*/
void _mc__strpart(void *return_ptr[], struct d1_meta *source,
ff_size_t from_offset, ff_size_t to_offset)
{
moal_t new_min, len;
((struct d1_meta *)(return_ptr[1]))->occurs = 0;
if(source->occurs == 0
|| to_offset >= source->occurs
|| from_offset > to_offset)
return;
len = (to_offset - from_offset) + 1;
new_min = len;
if(new_min > ((struct d1_meta *)(return_ptr[1]))->limit1)
if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
goto memory_failure;
memcpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr,
(char *)source->ptr + from_offset, len);
((struct d1_meta *)(return_ptr[1]))->occurs = len;
return;
memory_failure:
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
return;
}
void _mc__strrpl(void *return_ptr[], struct d1_meta *out,
ff_size_t out_offset, ff_size_t cut_length,
struct d1_meta *insert)
{
int error = 0;
long net_change = 0;
int out_is_var;
moal_t new_min;
unsigned char *to, *from;
if(sum_overflows(moal_t, out_offset, cut_length)
|| out_offset + cut_length > out->occurs
|| (out->ptr == insert->ptr && out->limit1 && insert->limit1))
{error = MC_INCOMPATIBLE_PARAMS;
goto done;}
if(return_ptr[4] == NULL)
out_is_var = TRUE;
else
out_is_var = FALSE;
if(insert->occurs > cut_length)
net_change = insert->occurs - cut_length;
else
{net_change = cut_length - insert->occurs;
net_change *= -1;}
new_min = out->occurs + net_change;
if(new_min > out->limit1)
{if(!out_is_var || !resize_cspace(out, new_min))
goto out_failure;}
if(net_change)
memmove((char *)out->ptr + out_offset + insert->occurs,
(char *)out->ptr + out_offset + cut_length,
out->occurs - (out_offset + cut_length));
if(insert->occurs)
memcpy((char *)out->ptr + out_offset,
(char *)insert->ptr, insert->occurs);
out->occurs += net_change;
done:
*((int *)(return_ptr[1])) = error;
*((long *)(return_ptr[2])) = net_change;
return;
out_failure:
if(out_is_var)
*((int *)(return_ptr[0])) = MEMORY_FAILURE;
else
{/* subtracting 1 from new_min to represent it as a 0-relative subscript */
*((moal_t *)(return_ptr[3])) = new_min - 1;
*((moal_t *)(return_ptr[4])) = out->limit1;}
return;
}
void _mc__strfnd(void *return_ptr[], struct d1_meta *search,
ff_size_t from_offset, ff_size_t to_offset,
int match_case, struct d1_meta *find)
{
int error = MC_NOT_FOUND;
ff_size_t subscript = 0;
unsigned char *sp, *fp;
moal_t wrk1, wrk2, f_occurs, fend;
if(search->occurs == 0 || find->occurs == 0)
{error = MC_EMPTY_PARAMETER;
goto done;}
if(from_offset >= search->occurs || to_offset >= search->occurs)
{error = MC_OFFSET_INVALID;
goto done;}
sp = (unsigned char *)search->ptr;
fp = (unsigned char *)find->ptr;
f_occurs = find->occurs;
if(from_offset <= to_offset) /* search down */
{for(wrk1 = from_offset, wrk2 = 0; wrk1 <= to_offset; ++wrk1)
{if(match_case ? (sp[wrk1] == fp[wrk2])
: (tolower(sp[wrk1]) == tolower(fp[wrk2])))
{++wrk2;
if(wrk2 == f_occurs)
{error = 0;
subscript = wrk1 - (wrk2 - 1);
break;}}
else if(wrk2 > 0)
{wrk1 -= wrk2;
wrk2 = 0;}}}
else /* search up */
{for(wrk1 = from_offset, wrk2 = fend = f_occurs - 1;; --wrk1)
{if(match_case ? (sp[wrk1] == fp[wrk2])
: (tolower(sp[wrk1]) == tolower(fp[wrk2])))
{if(wrk2 == 0)
{error = 0;
subscript = wrk1;
break;}
--wrk2;}
else if(wrk2 < fend)
{wrk1 += (fend - wrk2);
wrk2 = fend;}
if(wrk1 == to_offset)
break;}}
done:
*((int *)(return_ptr[1])) = error;
*((ff_size_t *)(return_ptr[2])) = subscript;
return;
}
void _mc__strtod(void *return_ptr[],
struct d1_meta *source, ff_size_t source_offset)
{
int error = 0, mall;
void *save_ptr;
double number = 0.0;
ff_size_t next_offset;
unsigned char save;
char *cp;
next_offset = source_offset;
if(source->occurs == 0)
{error = MC_EMPTY_PARAMETER;
goto done;}
if(source_offset >= source->occurs)
{error = MC_OFFSET_INVALID;
goto done;}
make_safe(source, mall, save_ptr, save, NONE);
errno = 0;
number = strtod((char *)source->ptr + source_offset, &cp);
if(number == 0.0 && cp == (char *)source->ptr + source_offset)
error = MC_NaN;
else if(errno == ERANGE && number < 0.0)
{error = MC_nINF;
number = neg_inf.num;}
else if(errno == ERANGE && number > 0.0)
{error = MC_pINF;
number = pos_inf.num;}
next_offset = cp - (char *)source->ptr;
undo_safe(source, mall, save_ptr, save);
done:
*((int *)(return_ptr[1])) = error;
*((double *)(return_ptr[2])) = number;
*((ff_size_t *)(return_ptr[3])) = next_offset;
}
void _mc__strtol(void *return_ptr[],
struct d1_meta *source, ff_size_t source_offset)
{
int error = 0, mall;
void *save_ptr;
long number = 0;
ff_size_t next_offset;
unsigned char save;
char *cp;
next_offset = source_offset;
if(source->occurs == 0)
{error = MC_EMPTY_PARAMETER;
goto done;}
if(source_offset >= source->occurs)
{error = MC_OFFSET_INVALID;
goto done;}
make_safe(source, mall, save_ptr, save, NONE);
errno = 0;
number = strtol((char *)source->ptr + source_offset, &cp, 10);
if(number == 0 && cp == (char *)source->ptr + source_offset)
error = MC_NaN;
else if(errno == ERANGE && number < 0)
{error = MC_nINF;
number = LONG_MIN;}
else if(errno == ERANGE && number > 0)
{error = MC_pINF;
number = LONG_MAX;}
next_offset = cp - (char *)source->ptr;
undo_safe(source, mall, save_ptr, save);
done:
*((int *)(return_ptr[1])) = error;
*((long *)(return_ptr[2])) = number;
*((ff_size_t *)(return_ptr[3])) = next_offset;
}
void _mc__strtoul(void *return_ptr[],
struct d1_meta *source, ff_size_t source_offset)
{
int error = 0, mall;
void *save_ptr;
unsigned long number = 0;
ff_size_t next_offset;
unsigned char save;
char *cp;
next_offset = source_offset;
if(source->occurs == 0)
{error = MC_EMPTY_PARAMETER;
goto done;}
if(source_offset >= source->occurs)
{error = MC_OFFSET_INVALID;
goto done;}
make_safe(source, mall, save_ptr, save, NONE);
errno = 0;
number = strtoul((char *)source->ptr + source_offset, &cp, 10);
if(number == 0 && cp == (char *)source->ptr + source_offset)
error = MC_NaN;
else if(errno == ERANGE)
{error = MC_pINF;
number = ULONG_MAX;}
next_offset = cp - (char *)source->ptr;
undo_safe(source, mall, save_ptr, save);
done:
*((int *)(return_ptr[1])) = error;
*((unsigned long *)(return_ptr[2])) = number;
*((ff_size_t *)(return_ptr[3])) = next_offset;
}
/*
* support functions used by the library
*/
static void format_new_flags(char comma, char dollar, char paren,
char *in, char *out, char space_flag)
{
char minus;
int wrk1, wrk2, blanks_consumed, period, add, digits, comma_pos;
for(wrk1 = out[0] = 0, minus = 'n', period = -1; in[wrk1] != 0; ++wrk1)
{if(in[wrk1] == '.')
{period = wrk1;
break;}
if(isdigit(in[wrk1]))
period = wrk1 + 1;
if(in[wrk1] == '-')
minus = 'y';}
if(minus == 'n')
paren = 'n';
else
space_flag = 'n';
if(period >= 0)
{add = 0;
if(dollar == 'y')
++add;
if(paren == 'y')
++add;
for(digits = 0, comma_pos = -1, wrk1 = period - 1; wrk1 >= 0; --wrk1)
{if(isdigit(in[wrk1]))
{++digits;
if(digits == 4)
{comma_pos = wrk1 + 1;
++add;
digits = 1;}
continue;}
else
break;}
wrk2 = 0;
if(period == 0 && dollar == 'y')
{dollar = 'n';
out[wrk2++] = '$';}
for(wrk1 = blanks_consumed = 0; wrk1 < period; ++wrk1)
{/* consume leading blanks up to added, if right justified */
if(in[wrk1] == ' ')
{if(space_flag == 'y') /* do not consume 1st leading blank */
space_flag = 'n';
else if(blanks_consumed < add)
{++blanks_consumed;
continue;}}
if(paren == 'y' && in[wrk1] == '-')
{paren = 'r';
out[wrk2++] = '(';
continue;}
if(dollar == 'y' && (isdigit(in[wrk1]) || wrk1 == period))
{dollar = 'n';
out[wrk2++] = '$';}
if(wrk1 == comma_pos)
{out[wrk2++] = ',';
comma_pos += 3;}
out[wrk2++] = in[wrk1];}
for(wrk1 = period; in[wrk1] != 0; ++wrk1)
{if(paren == 'r' && in[wrk1] == ' ')
{paren = 'n';
out[wrk2++] = ')';}
/* consume trailing blanks up to added, if left justified */
if(in[wrk1] == ' ' && blanks_consumed < add)
{++blanks_consumed;
continue;}
out[wrk2++] = in[wrk1];}
if(paren == 'r')
out[wrk2++] = ')';
out[wrk2++] = 0;}
else
strcpy(out, in);
return;
}
static int store_file(FILE *in)
{
int wrk1;
if(in == stdin)
return 1;
else if(in == stdout)
return 2;
else if(in == stderr)
return 3;
else
{for(wrk1 = 0; wrk1 < files_cnt; ++wrk1)
{if(files[wrk1] == NULL)
{/* reuse the empty slot */
files[wrk1] = in;
return wrk1 + FIRST_USER_FILE;}}
if(files_cnt < FILES_MAX)
{files[files_cnt++] = in;
return (files_cnt - 1 + FIRST_USER_FILE);}
else
return 0;} /* no room */
}
static void remove_file(int in)
{
int sub;
sub = in - FIRST_USER_FILE;
if(sub >= 0 && sub < files_cnt)
files[sub] = NULL; /* mark slot for reuse */
return;
}
static FILE *retrieve_file(int in)
{
int sub;
if(in == 1)
return stdin;
else if(in == 2)
return stdout;
else if(in == 3)
return stderr;
else
{sub = in - FIRST_USER_FILE;
if(sub >= 0 && sub < files_cnt)
return files[sub];
else
return NULL;}
}
static void tm_to_ff_tm(struct tm *in, struct ff_tm *out)
{
out->tm_sec = in->tm_sec;
out->tm_min = in->tm_min;
out->tm_hour = in->tm_hour;
out->tm_mday = in->tm_mday;
out->tm_mon = in->tm_mon;
out->tm_year = in->tm_year;
out->tm_wday = in->tm_wday;
out->tm_yday = in->tm_yday;
out->tm_isdst = in->tm_isdst;
return;
}
static void ff_tm_to_tm(struct ff_tm *in, struct tm *out)
{
out->tm_sec = in->tm_sec;
out->tm_min = in->tm_min;
out->tm_hour = in->tm_hour;
out->tm_mday = in->tm_mday;
out->tm_mon = in->tm_mon;
out->tm_year = in->tm_year;
out->tm_wday = in->tm_wday;
out->tm_yday = in->tm_yday;
out->tm_isdst = in->tm_isdst;
return;
}
static int resize_cspace(struct d1_meta *out, moal_t new_min)
{
moal_t new_limit, s1, s2;
void *new_ptr;
static int resize_num = 50,
resize_pct = 15;
/*
* grow the varspace as needed
*/
s1 = resize_num + out->limit1;
s2 = resize_pct * (out->limit1 / 100) + out->limit1;
new_limit = max(new_min, max(s1, s2));
if(out->limit1 == 0)
{new_ptr = malloc(new_limit);
if(new_ptr == NULL)
return FALSE;}
else
{new_ptr = realloc(out->ptr, new_limit);
if(new_ptr == NULL)
return FALSE;}
out->ptr = new_ptr;
out->limit1 = new_limit;
return TRUE;
}
/*
* this compiled code is all the code, including helper functions,
* for these library functions:
*
* stresc(), strreg(), strfndr(), fgetall(), fputall(),
* strkey(), strknew(), strkmap(), strkfnd()
*
* this C code was generated by the MOAL C compiler, because these functions
* were written in MOAL C instead of C
*/
struct zz1D_meta {
void *ptr;
unsigned occurs;
unsigned limit1;
};
static int zzzz_resize1(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
static int zzzz_resize2(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
static int zzzz_resize3(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
static int zzzz_resize4(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
static int zzzz_resize5(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
struct _fsm {
int next1;
int next2;
struct zz1D_meta cset;
char type;
unsigned char single;
};
struct rg {
struct zz1D_meta st;
int match_longest;
int match_case;
int align_left;
int align_right;
struct zz1D_meta m;
struct zz1D_meta start;
};
struct _tx {
struct zz1D_meta text;
};
struct _bn {
int key;
int red;
int l;
int r;
};
struct ky {
int initialized[1];
struct zz1D_meta zz_initialized;
int match_case;
struct zz1D_meta key;
struct zz1D_meta bin;
struct zz1D_meta map;
};
void _mc__strreg(void *zzzz_return_ptr[], struct zz1D_meta *expression,
int match_longest, int match_case);
void _mc__strfndr(void *zzzz_return_ptr[], struct zz1D_meta *search, unsigned
int from_offset, unsigned int to_offset, struct rg *machine);
void _mc__stresc(void *zzzz_return_ptr[], struct zz1D_meta *source);
void _mc__fgetall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
int convert_text);
void _mc__fputall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
int convert_text, struct zz1D_meta *data);
void _mc__strkey(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
ky *keys);
void _mc__strknew(void *zzzz_return_ptr[], int match_case);
void _mc__strkmap(void *zzzz_return_ptr[], unsigned int sub, int map_to_sorted,
struct ky *keys);
void _mc__strkfnd(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
ky *keys);
void _mc__stresc(void *zzzz_return_ptr[], struct zz1D_meta *source)
{
struct zz1D_meta *translation = (struct zz1D_meta *)zzzz_return_ptr[1];
int wrk1;
int err;
int next;
long num;
unsigned char ch;
int zzzz_exception = 0;
unsigned zzzz_unsigned1;
unsigned zzzz_unsigned2;
int zzzz_int1;
unsigned char zzzz_unsigned_char1;
void *zzzz_actuals[4];
(*translation).occurs = 0;
zzzz_actuals[0] = &(zzzz_exception);
wrk1 = 0;
zzzz_cont2:
if(!(wrk1 < (*source).occurs)) goto zzzz_false1;
ch = (*(((char *)(source->ptr)) + ((wrk1))));
if(!(ch == '\\')) goto zzzz_false4;
if(!(wrk1 == (*source).occurs - 1)) goto zzzz_false2;
error:
zzzz_unsigned1 = (*translation).occurs;
zzzz_unsigned2 = 0;
if((zzzz_unsigned2) > (*translation).limit1)
if(!zzzz_resize1(&((*translation)), (zzzz_unsigned2) - 1, 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
(*translation).occurs = zzzz_unsigned2;
(*translation).occurs;
goto zzzz_finish;
zzzz_false2:
zzzz_int1 = ++wrk1;
ch = (*(((char *)(source->ptr)) + ((zzzz_int1))));
switch(ch)
{
break;
case 'a':
ch = '\a';
break;
case 'b':
ch = '\b';
break;
case 't':
ch = '\t';
break;
case 'n':
ch = '\n';
break;
case 'v':
ch = '\v';
break;
case 'f':
ch = '\f';
break;
case 'r':
ch = '\r';
break;
case '\\':
ch = '\\';
break;
case '\'':
ch = '\'';
break;
case '\"':
ch = '\"';
break;
default:
zzzz_unsigned_char1 = ((unsigned char)((ch)));
if(!((*(((signed char *)(_MC_ctype.ptr)) + ((zzzz_unsigned_char1)))) & 8)) goto zzzz_true1;
zzzz_actuals[1] = &(err);
zzzz_actuals[2] = &(num);
zzzz_actuals[3] = &(next);
_mc__strtol(zzzz_actuals, &((*source)), wrk1);
if(zzzz_exception) {
goto zzzz_finish;
}
if(err) goto zzzz_true1;
if(next - wrk1 != 3) goto zzzz_true1;
if(num < 0) goto zzzz_true1;
if(num > 255) goto zzzz_true1;
goto zzzz_false3;
zzzz_true1:
goto error;
goto zzzz_skip1;
zzzz_false3:
ch = num;
wrk1 += 2;
zzzz_skip1:
;}
zzzz_false4:
zzzz_unsigned1 = (*translation).occurs;
if((unsigned)(zzzz_unsigned1) >= ((*translation).limit1))
if(!zzzz_resize1(&((*translation)), (unsigned)(zzzz_unsigned1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_unsigned1) + 1 > ((*translation).occurs))
((*translation).occurs) = (unsigned)(zzzz_unsigned1) + 1;
(*(((char *)(translation->ptr)) + ((zzzz_unsigned1)))) = ch;
zzzz_cont1:
++wrk1;
goto zzzz_cont2;
zzzz_false1:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void parse(void *zzzz_return_ptr[], struct zz1D_meta *in, int in_bgn,
int in_end, int match_case, struct zz1D_meta *st);
void _mc__strreg(void *zzzz_return_ptr[], struct zz1D_meta *expression,
int match_longest, int match_case)
{
int error = 0;
struct rg *machine = (struct rg *)zzzz_return_ptr[2];
int wrk1;
struct zz1D_meta stack = {NULL};
int in_bgn;
int in_end;
struct zz1D_meta visited = {NULL};
struct zz1D_meta st = {NULL};
int zzzz_exception = 0;
unsigned zzzz_imw1;
unsigned zzzz_unsigned1;
unsigned zzzz_unsigned2;
void *zzzz_actuals[1];
if((*machine).st.limit1 > 0) {
for(zzzz_imw1 = 0; zzzz_imw1 < (*machine).st.occurs; ++zzzz_imw1) {
if((((struct _fsm *)((*machine).st.ptr)) + (zzzz_imw1)) -> cset.limit1 > 0) {
free((((struct _fsm *)((*machine).st.ptr)) + (zzzz_imw1)) -> cset.ptr);
;}
;}
free((*machine).st.ptr);
(*machine).st.occurs = 0;
(*machine).st.limit1 = 0;
;}
if((*machine).m.limit1 > 0) {
free((*machine).m.ptr);
(*machine).m.occurs = 0;
(*machine).m.limit1 = 0;
;}
if((*machine).start.limit1 > 0) {
free((*machine).start.ptr);
(*machine).start.occurs = 0;
(*machine).start.limit1 = 0;
;}
zzzz_actuals[0] = &(zzzz_exception);
if(!(!(*expression).occurs)) goto zzzz_false1;
error = - 6;
goto zzzz_finish;
zzzz_false1:
if(!((*expression).occurs > 1)) goto zzzz_false2;
if(!((*(((char *)(expression->ptr)) + ((0)))) == '$')) goto zzzz_false2;
if(!((*(((char *)(expression->ptr)) + ((1)))) == '$')) goto zzzz_false2;
in_bgn = 2;
(*machine).align_left = in_bgn;
goto zzzz_skip2;
zzzz_false2:
if(!((*(((char *)(expression->ptr)) + ((0)))) == '$')) goto zzzz_false3;
in_bgn = 1;
(*machine).align_left = in_bgn;
goto zzzz_skip1;
zzzz_false3:
in_bgn = 0;
(*machine).align_left = in_bgn;
zzzz_skip1:
zzzz_skip2:
if(!((*expression).occurs > 1)) goto zzzz_false4;
zzzz_unsigned1 = (*expression).occurs - 1;
if(!((*(((char *)(expression->ptr)) + ((zzzz_unsigned1)))) == '$')) goto
zzzz_false4;
zzzz_unsigned2 = (*expression).occurs - 2;
if(!((*(((char *)(expression->ptr)) + ((zzzz_unsigned2)))) == '$')) goto
zzzz_false4;
(*machine).align_right = 2;
in_end = (*expression).occurs - 3;
goto zzzz_skip4;
zzzz_false4:
zzzz_unsigned1 = (*expression).occurs - 1;
if(!((*(((char *)(expression->ptr)) + ((zzzz_unsigned1)))) == '$')) goto
zzzz_false5;
(*machine).align_right = 1;
in_end = (*expression).occurs - 2;
goto zzzz_skip3;
zzzz_false5:
(*machine).align_right = 0;
in_end = (*expression).occurs - 1;
zzzz_skip3:
zzzz_skip4:
if(!(in_end < in_bgn)) goto zzzz_false6;
goto malformed;
zzzz_false6:
parse(zzzz_actuals, &((*expression)), in_bgn, in_end, match_case, &(st));
if(zzzz_exception) {
if(zzzz_exception == 1) {
zzzz_exception = 0;
goto zzzz_exception1;
}
goto zzzz_finish;
}
if(!(!st.occurs)) goto zzzz_false7;
goto malformed;
zzzz_false7:
zzzz_unsigned1 = (*machine).m.occurs;
zzzz_unsigned2 = st.occurs * 2;
if((zzzz_unsigned2) > (*machine).m.limit1)
if(!zzzz_resize3(&((*machine).m), (zzzz_unsigned2) - 1, 0, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
(*machine).m.occurs = zzzz_unsigned2;
(*machine).m.occurs;
zzzz_unsigned1 = (*machine).start.occurs;
zzzz_unsigned2 = st.occurs;
if((zzzz_unsigned2) > (*machine).start.limit1)
if(!zzzz_resize3(&((*machine).start), (zzzz_unsigned2) - 1, 0, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
(*machine).start.occurs = zzzz_unsigned2;
(*machine).start.occurs;
zzzz_unsigned1 = (*machine).start.occurs;
zzzz_unsigned2 = 0;
if((zzzz_unsigned2) > (*machine).start.limit1)
if(!zzzz_resize3(&((*machine).start), (zzzz_unsigned2) - 1, 0, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
(*machine).start.occurs = zzzz_unsigned2;
(*machine).start.occurs;
if((unsigned)(0) >= (stack.limit1))
if(!zzzz_resize3(&(stack), (unsigned)(0), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(0) + 1 > (stack.occurs))
(stack.occurs) = (unsigned)(0) + 1;
(*(((int *)(stack.ptr)) + ((0)))) = 0;
zzzz_unsigned1 = visited.occurs;
zzzz_unsigned2 = st.occurs;
if((zzzz_unsigned2) > visited.limit1)
if(!zzzz_resize3(&(visited), (zzzz_unsigned2) - 1, 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
visited.occurs = zzzz_unsigned2;
visited.occurs;
if(visited.limit1)
memset(((int *)(visited.ptr)), 0, sizeof(int) * visited.limit1);
zzzz_cont2:
if(!(stack.occurs)) goto zzzz_false8;
zzzz_unsigned1 = stack.occurs - 1;
wrk1 = (*(((int *)(stack.ptr)) + ((zzzz_unsigned1))));
zzzz_unsigned1 = stack.occurs;
zzzz_unsigned2 = stack.occurs;
if((zzzz_unsigned1 - 1) > stack.limit1)
if(!zzzz_resize3(&(stack), (zzzz_unsigned1 - 1) - 1, 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
stack.occurs = zzzz_unsigned1 - 1;
stack.occurs;
if(!((*(((int *)(visited.ptr)) + ((wrk1)))))) goto zzzz_false9;
goto zzzz_cont1;
zzzz_false9:
if((unsigned)(wrk1) >= (visited.limit1))
if(!zzzz_resize3(&(visited), (unsigned)(wrk1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk1) + 1 > (visited.occurs))
(visited.occurs) = (unsigned)(wrk1) + 1;
(*(((int *)(visited.ptr)) + ((wrk1)))) = 1;
if((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 's') goto zzzz_true1;
if((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 't') goto zzzz_true1;
goto zzzz_false14;
zzzz_true1:
zzzz_unsigned1 = (*machine).start.occurs;
if((unsigned)(zzzz_unsigned1) >= ((*machine).start.limit1))
if(!zzzz_resize3(&((*machine).start), (unsigned)(zzzz_unsigned1), 0, 15))
{
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_unsigned1) + 1 > ((*machine).start.occurs))
((*machine).start.occurs) = (unsigned)(zzzz_unsigned1) + 1;
(*(((int *)((*machine).start.ptr)) + ((zzzz_unsigned1)))) = wrk1;
goto zzzz_skip8;
zzzz_false14:
if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 'r')) goto zzzz_false13;
zzzz_unsigned1 = stack.occurs;
if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
(stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
(*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
+ ((wrk1))) -> next1;
if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> next2 < st.occurs)) goto zzzz_false10;
zzzz_unsigned1 = stack.occurs;
if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
(stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
(*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
+ ((wrk1))) -> next2;
goto zzzz_skip5;
zzzz_false10:
goto matches_nothing;
zzzz_skip5:
goto zzzz_skip7;
zzzz_false13:
if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 'c')) goto zzzz_false12;
zzzz_unsigned1 = stack.occurs;
if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
(stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
(*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
+ ((wrk1))) -> next1;
if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> next2 < st.occurs)) goto zzzz_false11;
zzzz_unsigned1 = stack.occurs;
if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
(stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
(*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
+ ((wrk1))) -> next2;
goto zzzz_skip6;
zzzz_false11:
matches_nothing:
error = - 12;
goto zzzz_finish;
zzzz_skip6:
zzzz_false12:
zzzz_skip7:
zzzz_skip8:
zzzz_cont1:
goto zzzz_cont2;
zzzz_false8:
if(&((*machine).st) != &(st)) {
if((*machine).st.limit1 > 0) {
for(zzzz_imw1 = 0; zzzz_imw1 < (*machine).st.occurs; ++zzzz_imw1) {
if((((struct _fsm *)(((struct _fsm *)((*machine).st.ptr)))) + (zzzz_imw1))
-> cset.limit1 > 0) {
free((((struct _fsm *)(((struct _fsm *)((*machine).st.ptr))))
+ (zzzz_imw1)) -> cset.ptr);
;}
;}
free((*machine).st.ptr);
;}
(*machine).st = st;
if(st.limit1 > 0) {
st.occurs = 0;
st.limit1 = 0;
;}
}
(*machine).match_longest = match_longest;
(*machine).match_case = match_case;
goto zzzz_finish;
zzzz_exception1:
malformed:
error = - 11;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = error;
if(stack.limit1 > 0) {
free(stack.ptr);
;}
if(visited.limit1 > 0) {
free(visited.ptr);
;}
if(st.limit1 > 0) {
for(zzzz_imw1 = 0; zzzz_imw1 < st.occurs; ++zzzz_imw1) {
if((((struct _fsm *)(st.ptr)) + (zzzz_imw1)) -> cset.limit1 > 0) {
free((((struct _fsm *)(st.ptr)) + (zzzz_imw1)) -> cset.ptr);
;}
;}
free(st.ptr);
;}
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void parse(void *zzzz_return_ptr[], struct zz1D_meta *in, int in_bgn,
int in_end, int match_case, struct zz1D_meta *st)
{
int wrk1;
int wrk2;
int wrk3;
int sub;
int or_bgn;
int left_op;
int bgn_st_occurs;
int new_wrk1;
int save;
int parens;
char complete;
char negate;
char have_hyphen;
char have_set;
char empty;
unsigned char ch;
static char zeros[256] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static struct zz1D_meta zz_zeros = {(void *)zeros,256,256};
int zzzz_exception = 0;
int zzzz_int1;
unsigned zzzz_unsigned1;
unsigned char zzzz_unsigned_char1;
unsigned char zzzz_unsigned_char2;
char zzzz_char1;
void *zzzz_actuals[1];
zzzz_actuals[0] = &(zzzz_exception);
bgn_st_occurs = (*st).occurs;
or_bgn = bgn_st_occurs;
wrk1 = in_bgn;
zzzz_cont22:
if(!(wrk1 <= in_end)) goto zzzz_false1;
ch = (*(((char *)(in->ptr)) + ((wrk1))));
if(!(ch == '/')) goto zzzz_false59;
if(!(wrk1 == in_end)) goto zzzz_false2;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false2:
zzzz_int1 = ++wrk1;
ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
goto zzzz_skip16;
zzzz_false59:
if(ch == ')') goto zzzz_true1;
if(ch == ']') goto zzzz_true1;
if(ch == '*') goto zzzz_true1;
if(ch == '+') goto zzzz_true1;
if(ch == '?') goto zzzz_true1;
if(ch == '$') goto zzzz_true1;
goto zzzz_false58;
zzzz_true1:
zzzz_exception = 1;
goto zzzz_finish;
goto zzzz_skip15;
zzzz_false58:
if(!(ch == '(')) goto zzzz_false57;
have_set = 'n';
complete = have_set;
parens = 1;
wrk2 = wrk1 + 1;
zzzz_cont5:
if(!(wrk2 <= in_end)) goto zzzz_false3;
ch = (*(((char *)(in->ptr)) + ((wrk2))));
if(!(ch == '/')) goto zzzz_false19;
++wrk2;
goto zzzz_skip7;
zzzz_false19:
if(!(have_set == 'y')) goto zzzz_false18;
if(!(ch == ']')) goto zzzz_false4;
have_set = 'n';
zzzz_false4:
goto zzzz_skip6;
zzzz_false18:
if(!(ch == '[')) goto zzzz_false17;
have_set = 'y';
goto zzzz_skip5;
zzzz_false17:
if(!(ch == '(')) goto zzzz_false16;
++parens;
goto zzzz_skip4;
zzzz_false16:
if(!(ch == ')')) goto zzzz_false5;
if(!(parens > 1)) goto zzzz_false5;
--parens;
goto zzzz_skip3;
zzzz_false5:
if(!(ch == ')')) goto zzzz_false15;
if(!(wrk2 + 1 <= in_end)) goto zzzz_false6;
zzzz_int1 = wrk2 + 1;
ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
goto zzzz_skip1;
zzzz_false6:
ch = ' ';
zzzz_skip1:
if(ch == '*') goto zzzz_true2;
if(ch == '+') goto zzzz_true2;
if(ch == '?') goto zzzz_true2;
goto zzzz_false7;
zzzz_true2:
new_wrk1 = wrk2 + 1;
goto zzzz_skip2;
zzzz_false7:
new_wrk1 = wrk2;
zzzz_skip2:
have_closure:
if(!(ch == '?')) goto zzzz_false8;
sub = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> type = 'r';
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = sub + 1;
parse(zzzz_actuals, &((*in)), wrk1 + 1, wrk2 - 1, match_case, &((*st)));
if(zzzz_exception) {
goto zzzz_finish;
}
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
goto cont1;
zzzz_false8:
if(!(ch == '+')) goto zzzz_false9;
parse(zzzz_actuals, &((*in)), wrk1 + 1, wrk2 - 1, match_case, &((*st)));
if(zzzz_exception) {
goto zzzz_finish;
}
ch = '*';
zzzz_false9:
if(!(ch == '*')) goto zzzz_false10;
sub = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> type = 'c';
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = sub + 1;
zzzz_false10:
parse(zzzz_actuals, &((*in)), wrk1 + 1, wrk2 - 1, match_case, &((*st)));
if(zzzz_exception) {
goto zzzz_finish;
}
if(!(ch == '*')) goto zzzz_false14;
wrk3 = sub + 1;
zzzz_cont4:
if(!(wrk3 < (*st).occurs)) goto zzzz_false11;
if(!((((struct _fsm *)(st->ptr)) + ((wrk3))) -> next1 == (*st).occurs)) goto
zzzz_false12;
if((unsigned)(wrk3) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(wrk3), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk3) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(wrk3) + 1;
(((struct _fsm *)(st->ptr)) + ((wrk3))) -> next1 = sub;
zzzz_false12:
if(!((((struct _fsm *)(st->ptr)) + ((wrk3))) -> next2 == (*st).occurs)) goto
zzzz_false13;
if((unsigned)(wrk3) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(wrk3), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk3) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(wrk3) + 1;
(((struct _fsm *)(st->ptr)) + ((wrk3))) -> next2 = sub;
zzzz_false13:
zzzz_cont3:
++wrk3;
goto zzzz_cont4;
zzzz_false11:
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
zzzz_false14:
cont1:
wrk1 = new_wrk1;
complete = 'y';
goto zzzz_false3;
zzzz_false15:
zzzz_skip3:
zzzz_skip4:
zzzz_skip5:
zzzz_skip6:
zzzz_skip7:
zzzz_cont2:
++wrk2;
goto zzzz_cont5;
zzzz_false3:
if(!(complete == 'n')) goto zzzz_false20;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false20:
goto zzzz_cont1;
goto zzzz_skip14;
zzzz_false57:
if(!(ch == '|')) goto zzzz_false56;
if(!(or_bgn == (*st).occurs)) goto zzzz_false21;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false21:
wrk2 = (*st).occurs;
zzzz_cont7:
if(!(wrk2 > or_bgn)) goto zzzz_false22;
zzzz_int1 = wrk2 - 1;
if((unsigned)(wrk2) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(wrk2), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk2) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(wrk2) + 1;
if(&((*(((struct _fsm *)(st->ptr)) + ((wrk2))))) != &((*(((struct _fsm *)(st->ptr))
+ ((zzzz_int1)))))) {
if((*(((struct _fsm *)(st->ptr)) + ((wrk2)))).cset.limit1 > 0) {
free((*(((struct _fsm *)(st->ptr)) + ((wrk2)))).cset.ptr);
;}
(*(((struct _fsm *)(st->ptr)) + ((wrk2)))) = (*(((struct _fsm *)(st->ptr))
+ ((zzzz_int1))));
if((*(((struct _fsm *)(st->ptr)) + ((zzzz_int1)))).cset.limit1 > 0) {
(*(((struct _fsm *)(st->ptr)) + ((zzzz_int1)))).cset.occurs = 0;
(*(((struct _fsm *)(st->ptr)) + ((zzzz_int1)))).cset.limit1 = 0;
;}
}
++(((struct _fsm *)(st->ptr)) + ((wrk2))) -> next1;
++(((struct _fsm *)(st->ptr)) + ((wrk2))) -> next2;
zzzz_cont6:
--wrk2;
goto zzzz_cont7;
zzzz_false22:
sub = or_bgn;
or_bgn = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> type = 'r';
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = sub + 1;
save = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = save;
parse(zzzz_actuals, &((*in)), wrk1 + 1, in_end, match_case, &((*st)));
if(zzzz_exception) {
goto zzzz_finish;
}
wrk2 = sub + 1;
zzzz_cont9:
if(!(wrk2 < save)) goto zzzz_false23;
if(!((((struct _fsm *)(st->ptr)) + ((wrk2))) -> next1 == save)) goto zzzz_false24;
if((unsigned)(wrk2) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(wrk2), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk2) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(wrk2) + 1;
(((struct _fsm *)(st->ptr)) + ((wrk2))) -> next1 = (*st).occurs;
zzzz_false24:
if(!((((struct _fsm *)(st->ptr)) + ((wrk2))) -> next2 == save)) goto zzzz_false25;
if((unsigned)(wrk2) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(wrk2), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk2) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(wrk2) + 1;
(((struct _fsm *)(st->ptr)) + ((wrk2))) -> next2 = (*st).occurs;
zzzz_false25:
zzzz_cont8:
++wrk2;
goto zzzz_cont9;
zzzz_false23:
goto zzzz_false1;
goto zzzz_skip13;
zzzz_false56:
if(!(ch == '[')) goto zzzz_false55;
wrk2 = wrk1 + 1;
zzzz_cont11:
if(!(wrk2 <= in_end)) goto zzzz_false26;
ch = (*(((char *)(in->ptr)) + ((wrk2))));
if(!(ch == '/')) goto zzzz_false30;
++wrk2;
goto zzzz_skip8;
zzzz_false30:
if(!(ch == ']')) goto zzzz_false29;
if(!(wrk2 + 1 <= in_end)) goto zzzz_false28;
zzzz_int1 = wrk2 + 1;
ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
if(ch == '*') goto zzzz_true3;
if(ch == '+') goto zzzz_true3;
if(ch == '?') goto zzzz_true3;
goto zzzz_false27;
zzzz_true3:
--wrk1;
++wrk2;
new_wrk1 = wrk2;
goto have_closure;
zzzz_false27:
zzzz_false28:
goto zzzz_false26;
zzzz_false29:
zzzz_skip8:
zzzz_cont10:
++wrk2;
goto zzzz_cont11;
zzzz_false26:
sub = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> type = 't';
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
if(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset) != &(zz_zeros)) {
if((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1 > 0) {
free((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr);
;}
zzzz_int1 = 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> cset = zz_zeros;
if(zz_zeros.limit1 > 0) {
zzzz_unsigned1 = sizeof(char) * zz_zeros.limit1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr = malloc(zzzz_unsigned1);
if((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr == NULL)
zzzz_int1 = (((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs
= (((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1 = 0;
else
memcpy((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr, zz_zeros.ptr,
zzzz_unsigned1);
}
if(!zzzz_int1) {
zzzz_exception = 32000;
goto zzzz_finish;
}
}
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = (((struct _fsm *)(st->ptr))
+ ((sub))) -> next2;
negate = 'n';
have_hyphen = negate;
complete = have_hyphen;
left_op = - 1;
wrk2 = wrk1 + 1;
zzzz_cont17:
if(!(wrk2 <= in_end)) goto zzzz_false31;
ch = (*(((char *)(in->ptr)) + ((wrk2))));
if(!(ch == '^')) goto zzzz_false32;
if(!(wrk2 == wrk1 + 1)) goto zzzz_false32;
negate = 'y';
goto zzzz_cont12;
zzzz_false32:
if(!(ch == '/')) goto zzzz_false41;
if(!(wrk2 == in_end)) goto zzzz_false33;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false33:
zzzz_int1 = ++wrk2;
ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
goto zzzz_skip11;
zzzz_false41:
if(!(ch == ']')) goto zzzz_false40;
complete = 'y';
goto zzzz_false31;
goto zzzz_skip10;
zzzz_false40:
if(!(ch == '.')) goto zzzz_false39;
wrk3 = 0;
zzzz_cont14:
if(!(wrk3 < 256)) goto zzzz_false34;
if(!(wrk3 != '\n')) goto zzzz_false36;
if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
((wrk3)))))) goto zzzz_false35;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false35:
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
if((unsigned)(wrk3) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(wrk3),
50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk3) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(wrk3)
+ 1;
(*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))))
= 1;
zzzz_false36:
zzzz_cont13:
++wrk3;
goto zzzz_cont14;
zzzz_false34:
goto zzzz_cont12;
goto zzzz_skip9;
zzzz_false39:
if(!(ch == '-')) goto zzzz_false38;
if(!(left_op == - 1)) goto zzzz_false37;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false37:
have_hyphen = 'y';
goto zzzz_cont12;
zzzz_false38:
zzzz_skip9:
zzzz_skip10:
zzzz_skip11:
if(!(have_hyphen == 'y')) goto zzzz_false45;
if(!(left_op > ch)) goto zzzz_false42;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false42:
wrk3 = left_op;
zzzz_cont16:
if(!(wrk3 <= ch)) goto zzzz_false43;
if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
((wrk3)))))) goto zzzz_false44;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false44:
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
if((unsigned)(wrk3) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(wrk3),
50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk3) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(wrk3)
+ 1;
(*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))))
= 1;
zzzz_cont15:
++wrk3;
goto zzzz_cont16;
zzzz_false43:
left_op = - 1;
have_hyphen = 'n';
goto zzzz_cont12;
zzzz_false45:
if(!(wrk2 < in_end)) goto zzzz_false46;
zzzz_int1 = wrk2 + 1;
if(!((*(((char *)(in->ptr)) + ((zzzz_int1)))) == '-')) goto zzzz_false46;
left_op = ch;
goto zzzz_skip12;
zzzz_false46:
if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
((ch)))))) goto zzzz_false47;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false47:
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
if((unsigned)(ch) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(ch),
50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(ch) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(ch)
+ 1;
(*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((ch))))
= 1;
zzzz_skip12:
zzzz_cont12:
++wrk2;
goto zzzz_cont17;
zzzz_false31:
if(!(!match_case)) goto zzzz_false50;
wrk3 = 0;
zzzz_cont19:
if(!(wrk3 < 256)) goto zzzz_false48;
if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
((wrk3)))))) goto zzzz_false49;
zzzz_unsigned_char1 = ((unsigned char)((wrk3)));
if(!(((*(((signed char *)(_MC_ctype.ptr)) + ((zzzz_unsigned_char1)))) & 4)))
goto zzzz_false49;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
zzzz_unsigned_char2 = ((unsigned char)((wrk3)));
zzzz_char1 = (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char2)))))));
if((unsigned)(zzzz_char1) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(zzzz_char1),
50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_char1) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) ->
cset.occurs))
((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(zzzz_char1)
+ 1;
(*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((zzzz_char1))))
= 1;
zzzz_false49:
zzzz_cont18:
++wrk3;
goto zzzz_cont19;
zzzz_false48:
zzzz_false50:
empty = 'y';
wrk3 = 0;
zzzz_cont21:
if(!(wrk3 < 256)) goto zzzz_false51;
if(!(negate == 'y')) goto zzzz_false52;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
if((unsigned)(wrk3) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(wrk3),
50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk3) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(wrk3)
+ 1;
(*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))))
= !(*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))));
zzzz_false52:
if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
((wrk3)))))) goto zzzz_false53;
empty = 'n';
zzzz_false53:
zzzz_cont20:
++wrk3;
goto zzzz_cont21;
zzzz_false51:
if(complete == 'n') goto zzzz_true4;
if(have_hyphen == 'y') goto zzzz_true4;
if(empty == 'y') goto zzzz_true4;
goto zzzz_false54;
zzzz_true4:
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false54:
wrk1 = wrk2;
goto zzzz_cont1;
zzzz_false55:
zzzz_skip13:
zzzz_skip14:
zzzz_skip15:
zzzz_skip16:
sub = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> type = 's';
if(!(match_case)) goto zzzz_false60;
zzzz_unsigned1 = ch;
goto zzzz_skip17;
zzzz_false60:
zzzz_unsigned_char1 = ((unsigned char)((ch)));
zzzz_unsigned1 = (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char1)))))));
zzzz_skip17:
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> single = zzzz_unsigned1;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
if((unsigned)(sub) >= ((*st).limit1))
if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(sub) + 1 > ((*st).occurs))
((*st).occurs) = (unsigned)(sub) + 1;
(((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = (((struct _fsm *)(st->ptr))
+ ((sub))) -> next2;
zzzz_cont1:
++wrk1;
goto zzzz_cont22;
zzzz_false1:
if(!((*st).occurs == bgn_st_occurs)) goto zzzz_false61;
zzzz_exception = 1;
goto zzzz_finish;
zzzz_false61:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void match(void *zzzz_return_ptr[], struct zz1D_meta *in, int from,
int to, int match_longest, int match_case, int align_left, int align_right,
struct zz1D_meta *st, struct zz1D_meta *m, struct zz1D_meta *start);
void _mc__strfndr(void *zzzz_return_ptr[], struct zz1D_meta *search, unsigned
int from_offset, unsigned int to_offset, struct rg *machine)
{
int error;
unsigned int subscript = 0;
unsigned int length = 0;
int zzzz_exception = 0;
void *zzzz_actuals[4];
zzzz_actuals[0] = &(zzzz_exception);
if(!(!(*machine).st.occurs)) goto zzzz_false4;
error = - 13;
goto zzzz_finish;
goto zzzz_skip3;
zzzz_false4:
if(!(!(*search).occurs)) goto zzzz_false3;
error = - 6;
goto zzzz_finish;
goto zzzz_skip2;
zzzz_false3:
if(from_offset >= (*search).occurs) goto zzzz_true1;
if(to_offset >= (*search).occurs) goto zzzz_true1;
goto zzzz_false2;
zzzz_true1:
error = - 7;
goto zzzz_finish;
goto zzzz_skip1;
zzzz_false2:
if(!(from_offset > to_offset)) goto zzzz_false1;
error = - 8;
goto zzzz_finish;
zzzz_false1:
zzzz_skip1:
zzzz_skip2:
zzzz_skip3:
zzzz_actuals[1] = &(error);
zzzz_actuals[2] = &(subscript);
zzzz_actuals[3] = &(length);
match(zzzz_actuals, &((*search)), from_offset, to_offset, (*machine).match_longest,
(*machine).match_case, (*machine).align_left, (*machine).align_right, &((*machine).st),
&((*machine).m), &((*machine).start));
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = error;
*((unsigned int *)(zzzz_return_ptr[2])) = subscript;
*((unsigned int *)(zzzz_return_ptr[3])) = length;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void match(void *zzzz_return_ptr[], struct zz1D_meta *in, int from,
int to, int match_longest, int match_case, int align_left, int align_right,
struct zz1D_meta *st, struct zz1D_meta *m, struct zz1D_meta *start)
{
int error = 0;
unsigned int subscript = 0;
unsigned int length = 0;
int wrk1;
int wrk2;
int next;
int in_sub;
int tmp;
int old_bgn;
int old_top;
int type;
int old_top2;
int new_bgn;
int new_top;
int original_from;
int longest_end;
char success;
unsigned char mch;
int zzzz_exception = 0;
int zzzz_int1;
unsigned char zzzz_unsigned_char1;
success = 'n';
in_sub = from;
original_from = in_sub;
zzzz_cont26:
if(!(in_sub <= to)) goto zzzz_false1;
if(!(align_left)) goto zzzz_false2;
if(!(from != original_from)) goto zzzz_false2;
if(!(align_left == 1)) goto zzzz_false3;
goto zzzz_false1;
zzzz_false3:
zzzz_int1 = in_sub - 1;
if(!((*(((char *)(in->ptr)) + ((zzzz_int1)))) != '\n')) goto zzzz_false4;
goto zzzz_cont1;
zzzz_false4:
zzzz_false2:
old_top = 0;
old_bgn = old_top;
zzzz_cont3:
if(!(old_top < (*start).occurs)) goto zzzz_false5;
if((unsigned)(old_top) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(old_top) + 1;
(*(((int *)(m->ptr)) + ((old_top)))) = (*(((int *)(start->ptr)) + ((old_top))));
zzzz_cont2:
++old_top;
goto zzzz_cont3;
zzzz_false5:
old_top2 = old_top;
new_top = (*st).occurs;
new_bgn = new_top;
next_match:
if(!(match_case)) goto zzzz_false6;
zzzz_int1 = (*(((char *)(in->ptr)) + ((in_sub))));
goto zzzz_skip1;
zzzz_false6:
zzzz_unsigned_char1 = ((unsigned char)(((*(((char *)(in->ptr)) + ((in_sub)))))));
zzzz_int1 = (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char1)))))));
zzzz_skip1:
mch = zzzz_int1;
wrk1 = old_bgn;
zzzz_cont25:
if(!(wrk1 < old_top2)) goto zzzz_false7;
next = (*(((int *)(m->ptr)) + ((wrk1))));
type = (((struct _fsm *)(st->ptr)) + ((next))) -> type;
if(!(type == 't')) goto zzzz_false42;
if(!(!(*(((char *)((((struct _fsm *)(st->ptr)) + ((next))) -> cset.ptr))
+ ((mch)))))) goto zzzz_false8;
goto zzzz_cont4;
zzzz_false8:
matched_character:
tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next1;
if(!(tmp >= (*st).occurs)) goto zzzz_false11;
check_right_align:
if(!align_right) goto zzzz_true1;
if(in_sub == to) goto zzzz_true1;
if(!(align_right == 2)) goto zzzz_false9;
zzzz_int1 = in_sub + 1;
if(!((*(((char *)(in->ptr)) + ((zzzz_int1)))) == '\n')) goto zzzz_false9;
zzzz_true1:
if(!(!match_longest)) goto zzzz_false10;
subscript = from;
length = in_sub - from + 1;
goto zzzz_finish;
goto zzzz_skip2;
zzzz_false10:
longest_end = in_sub;
success = 'y';
goto zzzz_cont4;
zzzz_skip2:
goto zzzz_skip3;
zzzz_false9:
goto zzzz_cont4;
zzzz_skip3:
zzzz_false11:
if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false16;
wrk2 = new_bgn;
zzzz_cont6:
if(!(wrk2 < new_top)) goto zzzz_false12;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false13;
goto cont1;
zzzz_false13:
zzzz_cont5:
++wrk2;
goto zzzz_cont6;
zzzz_false12:
zzzz_int1 = new_top;
++new_top;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont1:
;
goto zzzz_skip4;
zzzz_false16:
wrk2 = old_top;
zzzz_cont8:
if(!(wrk2 < old_top2)) goto zzzz_false14;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false15;
goto cont2;
zzzz_false15:
zzzz_cont7:
++wrk2;
goto zzzz_cont8;
zzzz_false14:
zzzz_int1 = old_top2;
++old_top2;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont2:
;
zzzz_skip4:
goto zzzz_cont4;
goto zzzz_skip12;
zzzz_false42:
if(!(type == 'c')) goto zzzz_false41;
tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next1;
if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false21;
wrk2 = new_bgn;
zzzz_cont10:
if(!(wrk2 < new_top)) goto zzzz_false17;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false18;
goto cont3;
zzzz_false18:
zzzz_cont9:
++wrk2;
goto zzzz_cont10;
zzzz_false17:
zzzz_int1 = new_top;
++new_top;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont3:
;
goto zzzz_skip5;
zzzz_false21:
wrk2 = old_top;
zzzz_cont12:
if(!(wrk2 < old_top2)) goto zzzz_false19;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false20;
goto cont4;
zzzz_false20:
zzzz_cont11:
++wrk2;
goto zzzz_cont12;
zzzz_false19:
zzzz_int1 = old_top2;
++old_top2;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont4:
;
zzzz_skip5:
tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next2;
if(!(tmp >= (*st).occurs)) goto zzzz_false22;
goto check_right_align;
zzzz_false22:
if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false27;
wrk2 = new_bgn;
zzzz_cont14:
if(!(wrk2 < new_top)) goto zzzz_false23;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false24;
goto cont5;
zzzz_false24:
zzzz_cont13:
++wrk2;
goto zzzz_cont14;
zzzz_false23:
zzzz_int1 = new_top;
++new_top;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont5:
;
goto zzzz_skip6;
zzzz_false27:
wrk2 = old_top;
zzzz_cont16:
if(!(wrk2 < old_top2)) goto zzzz_false25;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false26;
goto cont6;
zzzz_false26:
zzzz_cont15:
++wrk2;
goto zzzz_cont16;
zzzz_false25:
zzzz_int1 = old_top2;
++old_top2;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont6:
;
zzzz_skip6:
goto zzzz_cont4;
goto zzzz_skip11;
zzzz_false41:
if(!(type == 's')) goto zzzz_false40;
if(!((((struct _fsm *)(st->ptr)) + ((next))) -> single == mch)) goto zzzz_false28;
goto matched_character;
goto zzzz_skip7;
zzzz_false28:
goto zzzz_cont4;
zzzz_skip7:
goto zzzz_skip10;
zzzz_false40:
tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next1;
if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false33;
wrk2 = new_bgn;
zzzz_cont18:
if(!(wrk2 < new_top)) goto zzzz_false29;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false30;
goto cont7;
zzzz_false30:
zzzz_cont17:
++wrk2;
goto zzzz_cont18;
zzzz_false29:
zzzz_int1 = new_top;
++new_top;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont7:
;
goto zzzz_skip8;
zzzz_false33:
wrk2 = old_top;
zzzz_cont20:
if(!(wrk2 < old_top2)) goto zzzz_false31;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false32;
goto cont8;
zzzz_false32:
zzzz_cont19:
++wrk2;
goto zzzz_cont20;
zzzz_false31:
zzzz_int1 = old_top2;
++old_top2;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont8:
;
zzzz_skip8:
tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next2;
if(!(tmp >= (*st).occurs)) goto zzzz_false34;
goto check_right_align;
zzzz_false34:
if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false39;
wrk2 = new_bgn;
zzzz_cont22:
if(!(wrk2 < new_top)) goto zzzz_false35;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false36;
goto cont9;
zzzz_false36:
zzzz_cont21:
++wrk2;
goto zzzz_cont22;
zzzz_false35:
zzzz_int1 = new_top;
++new_top;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont9:
;
goto zzzz_skip9;
zzzz_false39:
wrk2 = old_top;
zzzz_cont24:
if(!(wrk2 < old_top2)) goto zzzz_false37;
if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false38;
goto cont10;
zzzz_false38:
zzzz_cont23:
++wrk2;
goto zzzz_cont24;
zzzz_false37:
zzzz_int1 = old_top2;
++old_top2;
if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
((*m).occurs) = (unsigned)(zzzz_int1) + 1;
(*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
cont10:
;
zzzz_skip9:
goto zzzz_cont4;
zzzz_skip10:
zzzz_skip11:
zzzz_skip12:
zzzz_cont4:
++wrk1;
goto zzzz_cont25;
zzzz_false7:
if(!(new_bgn == new_top)) goto zzzz_false44;
if(!(success == 'y')) goto zzzz_false43;
success_done:
subscript = from;
length = longest_end - from + 1;
goto zzzz_finish;
zzzz_false43:
goto zzzz_cont1;
zzzz_false44:
old_bgn = new_bgn;
old_top2 = new_top;
old_top = old_top2;
if(!(new_bgn == 0)) goto zzzz_false45;
new_top = (*st).occurs;
new_bgn = new_top;
goto zzzz_skip13;
zzzz_false45:
new_top = 0;
new_bgn = new_top;
zzzz_skip13:
++in_sub;
if(!(in_sub <= to)) goto zzzz_false47;
goto next_match;
goto zzzz_skip15;
zzzz_false47:
if(!(success == 'y')) goto zzzz_false46;
goto success_done;
goto zzzz_skip14;
zzzz_false46:
goto zzzz_false1;
zzzz_skip14:
zzzz_skip15:
zzzz_cont1:
in_sub = ++from;
goto zzzz_cont26;
zzzz_false1:
error = (- 2);
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = error;
*((unsigned int *)(zzzz_return_ptr[2])) = subscript;
*((unsigned int *)(zzzz_return_ptr[3])) = length;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
void _mc__fgetall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
int convert_text)
{
int error;
struct zz1D_meta *data = (struct zz1D_meta *)zzzz_return_ptr[2];
int file;
unsigned int read;
long pos;
int zzzz_exception = 0;
static char zzzz_string1[2] = "r";
static struct zz1D_meta zz_zzzz_string1 = {zzzz_string1,1,2};
static char zzzz_string2[3] = "rb";
static struct zz1D_meta zz_zzzz_string2 = {zzzz_string2,2,3};
struct zz1D_meta *zzzz_tri1;
char *zzzz_tri2;
unsigned zzzz_unsigned1;
unsigned zzzz_unsigned2;
void *zzzz_actuals[5];
(*data).occurs = 0;
zzzz_actuals[0] = &(zzzz_exception);
if(!(convert_text)) goto zzzz_false1;
zzzz_tri2 = zzzz_string1;
zzzz_tri1 = &(zz_zzzz_string1);
goto zzzz_skip1;
zzzz_false1:
zzzz_tri2 = zzzz_string2;
zzzz_tri1 = &(zz_zzzz_string2);
zzzz_skip1:
zzzz_actuals[1] = &(error);
zzzz_actuals[2] = &(file);
_mc__fopen(zzzz_actuals, &((*filename)), &((*zzzz_tri1)));
if(zzzz_exception) {
goto zzzz_finish;
}
if(error) goto zzzz_true1;
zzzz_actuals[1] = &(error);
_mc__fseek(zzzz_actuals, file, 0, 2);
if(error) goto zzzz_true1;
zzzz_actuals[1] = &(error);
zzzz_actuals[2] = &(pos);
_mc__ftell(zzzz_actuals, file);
if(error) goto zzzz_true1;
zzzz_actuals[1] = &(error);
_mc__fseek(zzzz_actuals, file, 0, 3);
if(error) goto zzzz_true1;
zzzz_actuals[1] = &(error);
zzzz_actuals[2] = &(read);
zzzz_actuals[3] = zzzz_actuals[4] = NULL;
_mc__fread(zzzz_actuals, &((*data)), 0, pos, file);
if(zzzz_exception) {
goto zzzz_finish;
}
if(error) goto zzzz_true1;
zzzz_actuals[1] = &(error);
_mc__fclose(zzzz_actuals, file);
if(error) goto zzzz_true1;
goto zzzz_false2;
zzzz_true1:
zzzz_unsigned1 = (*data).occurs;
zzzz_unsigned2 = 0;
if((zzzz_unsigned2) > (*data).limit1)
if(!zzzz_resize1(&((*data)), (zzzz_unsigned2) - 1, 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
(*data).occurs = zzzz_unsigned2;
(*data).occurs;
zzzz_false2:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = error;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
void _mc__fputall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
int convert_text, struct zz1D_meta *data)
{
int error;
int file;
int zzzz_exception = 0;
static char zzzz_string1[2] = "w";
static struct zz1D_meta zz_zzzz_string1 = {zzzz_string1,1,2};
static char zzzz_string2[3] = "wb";
static struct zz1D_meta zz_zzzz_string2 = {zzzz_string2,2,3};
struct zz1D_meta *zzzz_tri1;
char *zzzz_tri2;
unsigned zzzz_unsigned1;
void *zzzz_actuals[3];
zzzz_actuals[0] = &(zzzz_exception);
if(!(convert_text)) goto zzzz_false1;
zzzz_tri2 = zzzz_string1;
zzzz_tri1 = &(zz_zzzz_string1);
goto zzzz_skip1;
zzzz_false1:
zzzz_tri2 = zzzz_string2;
zzzz_tri1 = &(zz_zzzz_string2);
zzzz_skip1:
zzzz_actuals[1] = &(error);
zzzz_actuals[2] = &(file);
_mc__fopen(zzzz_actuals, &((*filename)), &((*zzzz_tri1)));
if(zzzz_exception) {
goto zzzz_finish;
}
if(error) goto zzzz_true1;
zzzz_unsigned1 = ((*data).occurs);
zzzz_actuals[1] = &(error);
_mc__fwrite(zzzz_actuals, &((*data)), 0, zzzz_unsigned1, file);
if(error) goto zzzz_true1;
zzzz_actuals[1] = &(error);
_mc__fclose(zzzz_actuals, file);
if(error) goto zzzz_true1;
goto zzzz_false2;
zzzz_true1:
;
zzzz_false2:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = error;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
void _mc__strknew(void *zzzz_return_ptr[], int match_case)
{
struct ky *keys = (struct ky *)zzzz_return_ptr[1];
int zzzz_exception = 0;
unsigned zzzz_imw1;
(*keys).zz_initialized.occurs = 0;
if((*keys).key.limit1 > 0) {
for(zzzz_imw1 = 0; zzzz_imw1 < (*keys).key.occurs; ++zzzz_imw1) {
if((((struct _tx *)((*keys).key.ptr)) + (zzzz_imw1)) -> text.limit1 > 0) {
free((((struct _tx *)((*keys).key.ptr)) + (zzzz_imw1)) -> text.ptr);
;}
;}
free((*keys).key.ptr);
(*keys).key.occurs = 0;
(*keys).key.limit1 = 0;
;}
if((*keys).bin.limit1 > 0) {
free((*keys).bin.ptr);
(*keys).bin.occurs = 0;
(*keys).bin.limit1 = 0;
;}
if((*keys).map.limit1 > 0) {
free((*keys).map.ptr);
(*keys).map.occurs = 0;
(*keys).map.limit1 = 0;
;}
(*keys).zz_initialized.occurs = 1;
(*keys).zz_initialized.occurs;
(*keys).match_case = match_case;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void treemap(void *zzzz_return_ptr[], int x, struct ky *keys);
void _mc__strkmap(void *zzzz_return_ptr[], unsigned int sub, int map_to_sorted,
struct ky *keys)
{
int error = 0;
struct zz1D_meta *key = (struct zz1D_meta *)zzzz_return_ptr[2];
unsigned int subscript = 0;
int zzzz_exception = 0;
void *zzzz_actuals[3];
(*key).occurs = 0;
zzzz_actuals[0] = &(zzzz_exception);
if(!(sub >= (*keys).key.occurs)) goto zzzz_false1;
error = - 8;
goto zzzz_finish;
zzzz_false1:
if(!(!map_to_sorted)) goto zzzz_false2;
subscript = sub;
if((unsigned)(subscript) >= ((*keys).key.limit1))
if(!zzzz_resize4(&((*keys).key), (unsigned)(subscript), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(subscript) + 1 > ((*keys).key.occurs))
((*keys).key.occurs) = (unsigned)(subscript) + 1;
zzzz_actuals[1] = zzzz_actuals[2] = NULL;
_mc__strcpy(zzzz_actuals, &((*key)), &((((struct _tx *)((*keys).key.ptr))
+ ((subscript))) -> text));
if(zzzz_exception) {
goto zzzz_finish;
}
goto zzzz_finish;
zzzz_false2:
if(!(!(*keys).map.occurs)) goto zzzz_false3;
treemap(zzzz_actuals, (((struct _bn *)((*keys).bin.ptr)) + ((0))) -> r, &((*keys)));
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_false3:
subscript = (*(((int *)((*keys).map.ptr)) + ((sub))));
if((unsigned)(subscript) >= ((*keys).key.limit1))
if(!zzzz_resize4(&((*keys).key), (unsigned)(subscript), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(subscript) + 1 > ((*keys).key.occurs))
((*keys).key.occurs) = (unsigned)(subscript) + 1;
zzzz_actuals[1] = zzzz_actuals[2] = NULL;
_mc__strcpy(zzzz_actuals, &((*key)), &((((struct _tx *)((*keys).key.ptr))
+ ((subscript))) -> text));
if(zzzz_exception) {
goto zzzz_finish;
}
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = error;
*((unsigned int *)(zzzz_return_ptr[3])) = subscript;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void treemap(void *zzzz_return_ptr[], int x, struct ky *keys)
{
int zzzz_exception = 0;
unsigned zzzz_unsigned1;
void *zzzz_actuals[1];
zzzz_actuals[0] = &(zzzz_exception);
if(!(x != 1)) goto zzzz_false1;
treemap(zzzz_actuals, (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> l, &((*keys)));
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_unsigned1 = (*keys).map.occurs;
if((unsigned)(zzzz_unsigned1) >= ((*keys).map.limit1))
if(!zzzz_resize3(&((*keys).map), (unsigned)(zzzz_unsigned1), 50, 15))
{
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(zzzz_unsigned1) + 1 > ((*keys).map.occurs))
((*keys).map.occurs) = (unsigned)(zzzz_unsigned1) + 1;
(*(((int *)((*keys).map.ptr)) + ((zzzz_unsigned1)))) = (((struct _bn *)((*keys).bin.ptr))
+ ((x))) -> key;
treemap(zzzz_actuals, (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> r, &((*keys)));
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_false1:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void process_key(void *zzzz_return_ptr[], struct zz1D_meta *find,
int match_case, struct zz1D_meta *keys, struct zz1D_meta *bin);
static void split(void *zzzz_return_ptr[], struct zz1D_meta *find, struct
zz1D_meta *keys, struct zz1D_meta *bin, int match_case, int x, int parent,
int grandparent, int great_grandparent);
static void rotate(void *zzzz_return_ptr[], struct zz1D_meta *find, int match_case,
struct zz1D_meta *keys, struct zz1D_meta *bin, int y);
static void compare(void *zzzz_return_ptr[], struct zz1D_meta *s1, struct
zz1D_meta *s2, int match_case);
void _mc__strkey(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
ky *keys)
{
unsigned int subscript;
int prev_occurs;
int zzzz_exception = 0;
unsigned zzzz_unsigned1;
unsigned zzzz_unsigned2;
void *zzzz_actuals[2];
zzzz_actuals[0] = &(zzzz_exception);
if(!(!(*keys).zz_initialized.occurs)) goto zzzz_false1;
subscript = 0;
goto zzzz_finish;
zzzz_false1:
prev_occurs = (*keys).key.occurs;
zzzz_actuals[1] = &(subscript);
process_key(zzzz_actuals, &((*key)), (*keys).match_case, &((*keys).key),
&((*keys).bin));
if(zzzz_exception) {
goto zzzz_finish;
}
if(!(prev_occurs != (*keys).key.occurs)) goto zzzz_false2;
zzzz_unsigned1 = (*keys).map.occurs;
zzzz_unsigned2 = 0;
if((zzzz_unsigned2) > (*keys).map.limit1)
if(!zzzz_resize3(&((*keys).map), (zzzz_unsigned2) - 1, 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
(*keys).map.occurs = zzzz_unsigned2;
(*keys).map.occurs;
zzzz_false2:
goto zzzz_finish;
zzzz_finish: ;
*((unsigned int *)(zzzz_return_ptr[1])) = subscript;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void process_key(void *zzzz_return_ptr[], struct zz1D_meta *find,
int match_case, struct zz1D_meta *keys, struct zz1D_meta *bin)
{
unsigned int subscript;
int wrk1;
int x;
int result;
int add;
int parent;
int grandparent;
int great_grandparent;
int zzzz_exception = 0;
int zzzz_int1;
unsigned zzzz_unsigned1;
unsigned zzzz_unsigned2;
int zzzz_int2;
void *zzzz_actuals[3];
zzzz_actuals[0] = &(zzzz_exception);
if(!(!(*bin).occurs)) goto zzzz_false1;
if((unsigned)(0) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(0), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(0) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(0) + 1;
(((struct _bn *)(bin->ptr)) + ((0))) -> r = 1;
if((unsigned)(0) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(0), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(0) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(0) + 1;
(((struct _bn *)(bin->ptr)) + ((0))) -> red = 0;
if((unsigned)(1) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(1) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(1) + 1;
(((struct _bn *)(bin->ptr)) + ((1))) -> r = 1;
if((unsigned)(1) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(1) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(1) + 1;
(((struct _bn *)(bin->ptr)) + ((1))) -> l = (((struct _bn *)(bin->ptr)) +
((1))) -> r;
if((unsigned)(1) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(1), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(1) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(1) + 1;
(((struct _bn *)(bin->ptr)) + ((1))) -> red = 0;
zzzz_false1:
grandparent = 0;
parent = grandparent;
x = parent;
zzzz_cont2:
if(!(x != 1)) goto zzzz_false2;
if(!(x == 0)) goto zzzz_false3;
result = 1;
goto zzzz_skip1;
zzzz_false3:
if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> key) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
((x))) -> key), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> key) + 1 > ((*keys).occurs))
((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((x))) ->
key) + 1;
zzzz_actuals[1] = &(result);
compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
_bn *)(bin->ptr)) + ((x))) -> key))) -> text), match_case);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_skip1:
if(!(result == 0)) goto zzzz_false4;
subscript = (((struct _bn *)(bin->ptr)) + ((x))) -> key;
goto zzzz_finish;
zzzz_false4:
great_grandparent = grandparent;
grandparent = parent;
parent = x;
if(!((result < 0))) goto zzzz_false5;
zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((x))) -> l;
goto zzzz_skip2;
zzzz_false5:
zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((x))) -> r;
zzzz_skip2:
x = zzzz_int1;
if(!((((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x)))
-> l))) -> red)) goto zzzz_false6;
if(!((((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x)))
-> r))) -> red)) goto zzzz_false6;
zzzz_actuals[1] = &(parent);
zzzz_actuals[2] = &(x);
split(zzzz_actuals, &((*find)), &((*keys)), &((*bin)), match_case, x, parent,
grandparent, great_grandparent);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_false6:
zzzz_cont1:
goto zzzz_cont2;
zzzz_false2:
add = (*keys).occurs;
subscript = add;
if((unsigned)(add) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)(add), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(add) + 1 > ((*keys).occurs))
((*keys).occurs) = (unsigned)(add) + 1;
zzzz_unsigned1 = (((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs;
zzzz_unsigned2 = (*find).occurs;
if((zzzz_unsigned2) > (((struct _tx *)(keys->ptr)) + ((add))) -> text.limit1)
if(!zzzz_resize1(&((((struct _tx *)(keys->ptr)) + ((add))) -> text), (zzzz_unsigned2)
- 1, 0, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
(((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs = zzzz_unsigned2;
(((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs;
wrk1 = 0;
zzzz_cont4:
if(!(wrk1 < (*find).occurs)) goto zzzz_false7;
if((unsigned)(add) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)(add), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(add) + 1 > ((*keys).occurs))
((*keys).occurs) = (unsigned)(add) + 1;
if((unsigned)(wrk1) >= ((((struct _tx *)(keys->ptr)) + ((add))) -> text.limit1))
if(!zzzz_resize1(&((((struct _tx *)(keys->ptr)) + ((add))) -> text), (unsigned)(wrk1),
0, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(wrk1) + 1 > ((((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs))
((((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs) = (unsigned)(wrk1)
+ 1;
(*(((char *)((((struct _tx *)(keys->ptr)) + ((add))) -> text.ptr)) + ((wrk1))))
= (*(((char *)(find->ptr)) + ((wrk1))));
zzzz_cont3:
++wrk1;
goto zzzz_cont4;
zzzz_false7:
x = (*bin).occurs;
if((unsigned)(x) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(x) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(x) + 1;
(((struct _bn *)(bin->ptr)) + ((x))) -> key = add;
if((unsigned)(x) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(x) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(x) + 1;
(((struct _bn *)(bin->ptr)) + ((x))) -> r = 1;
if((unsigned)(x) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(x) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(x) + 1;
(((struct _bn *)(bin->ptr)) + ((x))) -> l = (((struct _bn *)(bin->ptr)) +
((x))) -> r;
if(!(parent == 0)) goto zzzz_false8;
result = 1;
goto zzzz_skip3;
zzzz_false8:
if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
((parent))) -> key), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) + 1 > ((*keys).occurs))
((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((parent)))
-> key) + 1;
zzzz_actuals[1] = &(result);
compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
_bn *)(bin->ptr)) + ((parent))) -> key))) -> text), match_case);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_skip3:
if(!(result < 0)) goto zzzz_false9;
if((unsigned)(parent) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(parent), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(parent) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(parent) + 1;
(((struct _bn *)(bin->ptr)) + ((parent))) -> l = x;
goto zzzz_skip4;
zzzz_false9:
if((unsigned)(parent) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(parent), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(parent) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(parent) + 1;
(((struct _bn *)(bin->ptr)) + ((parent))) -> r = x;
zzzz_skip4:
zzzz_actuals[1] = &(zzzz_int1);
zzzz_actuals[2] = &(zzzz_int2);
split(zzzz_actuals, &((*find)), &((*keys)), &((*bin)), match_case, x, parent,
grandparent, great_grandparent);
if(zzzz_exception) {
goto zzzz_finish;
}
goto zzzz_finish;
zzzz_finish: ;
*((unsigned int *)(zzzz_return_ptr[1])) = subscript;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void split(void *zzzz_return_ptr[], struct zz1D_meta *find, struct
zz1D_meta *keys, struct zz1D_meta *bin, int match_case, int x, int parent,
int grandparent, int great_grandparent)
{
int pp;
int xx;
int res1;
int res2;
int zzzz_exception = 0;
void *zzzz_actuals[2];
zzzz_actuals[0] = &(zzzz_exception);
if((unsigned)(x) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(x) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(x) + 1;
(((struct _bn *)(bin->ptr)) + ((x))) -> red = 1;
if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> r) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)((((struct _bn *)(bin->ptr)) + ((x)))
-> r), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> r) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> r)
+ 1;
(((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x))) -> r)))
-> red = 0;
if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> l) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)((((struct _bn *)(bin->ptr)) + ((x)))
-> l), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> l) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> l)
+ 1;
(((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x))) -> l)))
-> red = (((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x)))
-> r))) -> red;
if(!((((struct _bn *)(bin->ptr)) + ((parent))) -> red)) goto zzzz_false4;
if((unsigned)(grandparent) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(grandparent), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(grandparent) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(grandparent) + 1;
(((struct _bn *)(bin->ptr)) + ((grandparent))) -> red = 1;
if(!(grandparent == 0)) goto zzzz_false1;
res1 = 1;
goto zzzz_skip1;
zzzz_false1:
if((unsigned)((((struct _bn *)(bin->ptr)) + ((grandparent))) -> key) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
((grandparent))) -> key), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((grandparent))) -> key) + 1
> ((*keys).occurs))
((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((grandparent)))
-> key) + 1;
zzzz_actuals[1] = &(res1);
compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
_bn *)(bin->ptr)) + ((grandparent))) -> key))) -> text), match_case);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_skip1:
if(!(parent == 0)) goto zzzz_false2;
res2 = 1;
goto zzzz_skip2;
zzzz_false2:
if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
((parent))) -> key), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) + 1 > ((*keys).occurs))
((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((parent)))
-> key) + 1;
zzzz_actuals[1] = &(res2);
compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
_bn *)(bin->ptr)) + ((parent))) -> key))) -> text), match_case);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_skip2:
if(!(res1 != res2)) goto zzzz_false3;
zzzz_actuals[1] = &(parent);
rotate(zzzz_actuals, &((*find)), match_case, &((*keys)), &((*bin)), grandparent);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_false3:
zzzz_actuals[1] = &(x);
rotate(zzzz_actuals, &((*find)), match_case, &((*keys)), &((*bin)), great_grandparent);
if(zzzz_exception) {
goto zzzz_finish;
}
if((unsigned)(x) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(x) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(x) + 1;
(((struct _bn *)(bin->ptr)) + ((x))) -> red = 0;
zzzz_false4:
if((unsigned)((((struct _bn *)(bin->ptr)) + ((0))) -> r) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)((((struct _bn *)(bin->ptr)) + ((0)))
-> r), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((0))) -> r) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((0))) -> r)
+ 1;
(((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((0))) -> r)))
-> red = 0;
pp = parent;
xx = x;
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = pp;
*((int *)(zzzz_return_ptr[2])) = xx;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void rotate(void *zzzz_return_ptr[], struct zz1D_meta *find, int match_case,
struct zz1D_meta *keys, struct zz1D_meta *bin, int y)
{
int gc;
int c;
int res1;
int res2;
int zzzz_exception = 0;
int zzzz_int1;
void *zzzz_actuals[2];
zzzz_actuals[0] = &(zzzz_exception);
if(!(y == 0)) goto zzzz_false1;
res1 = 1;
goto zzzz_skip1;
zzzz_false1:
if((unsigned)((((struct _bn *)(bin->ptr)) + ((y))) -> key) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
((y))) -> key), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((y))) -> key) + 1 > ((*keys).occurs))
((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((y))) ->
key) + 1;
zzzz_actuals[1] = &(res1);
compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
_bn *)(bin->ptr)) + ((y))) -> key))) -> text), match_case);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_skip1:
if(!((res1 < 0))) goto zzzz_false2;
zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((y))) -> l;
goto zzzz_skip2;
zzzz_false2:
zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((y))) -> r;
zzzz_skip2:
c = zzzz_int1;
if(!(c == 0)) goto zzzz_false3;
res2 = 1;
goto zzzz_skip3;
zzzz_false3:
if((unsigned)((((struct _bn *)(bin->ptr)) + ((c))) -> key) >= ((*keys).limit1))
if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
((c))) -> key), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)(bin->ptr)) + ((c))) -> key) + 1 > ((*keys).occurs))
((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((c))) ->
key) + 1;
zzzz_actuals[1] = &(res2);
compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
_bn *)(bin->ptr)) + ((c))) -> key))) -> text), match_case);
if(zzzz_exception) {
goto zzzz_finish;
}
zzzz_skip3:
if(!(res2 < 0)) goto zzzz_false4;
gc = (((struct _bn *)(bin->ptr)) + ((c))) -> l;
if((unsigned)(c) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(c), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(c) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(c) + 1;
(((struct _bn *)(bin->ptr)) + ((c))) -> l = (((struct _bn *)(bin->ptr)) +
((gc))) -> r;
if((unsigned)(gc) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(gc), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(gc) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(gc) + 1;
(((struct _bn *)(bin->ptr)) + ((gc))) -> r = c;
goto zzzz_skip4;
zzzz_false4:
gc = (((struct _bn *)(bin->ptr)) + ((c))) -> r;
if((unsigned)(c) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(c), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(c) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(c) + 1;
(((struct _bn *)(bin->ptr)) + ((c))) -> r = (((struct _bn *)(bin->ptr)) +
((gc))) -> l;
if((unsigned)(gc) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(gc), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(gc) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(gc) + 1;
(((struct _bn *)(bin->ptr)) + ((gc))) -> l = c;
zzzz_skip4:
if(!(res1 < 0)) goto zzzz_false5;
if((unsigned)(y) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(y), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(y) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(y) + 1;
(((struct _bn *)(bin->ptr)) + ((y))) -> l = gc;
goto zzzz_skip5;
zzzz_false5:
if((unsigned)(y) >= ((*bin).limit1))
if(!zzzz_resize5(&((*bin)), (unsigned)(y), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)(y) + 1 > ((*bin).occurs))
((*bin).occurs) = (unsigned)(y) + 1;
(((struct _bn *)(bin->ptr)) + ((y))) -> r = gc;
zzzz_skip5:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = gc;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static void compare(void *zzzz_return_ptr[], struct zz1D_meta *s1, struct
zz1D_meta *s2, int match_case)
{
int result;
int wrk1;
int occurs1;
int occurs2;
int zzzz_exception = 0;
unsigned char zzzz_unsigned_char1;
unsigned char zzzz_unsigned_char2;
int zzzz_int1;
unsigned char zzzz_unsigned_char3;
unsigned char zzzz_unsigned_char4;
int zzzz_int2;
occurs1 = (*s1).occurs;
occurs2 = (*s2).occurs;
result = 0;
wrk1 = result;
zzzz_cont2:
if(!(wrk1 < occurs1)) goto zzzz_false2;
if(!(wrk1 < occurs2)) goto zzzz_false2;
if(!(match_case)) goto zzzz_false3;
zzzz_int1 = ((*(((char *)(s1->ptr)) + ((wrk1)))) != (*(((char *)(s2->ptr))
+ ((wrk1)))));
goto zzzz_skip1;
zzzz_false3:
zzzz_unsigned_char1 = ((unsigned char)(((*(((char *)(s1->ptr)) + ((wrk1)))))));
zzzz_unsigned_char2 = ((unsigned char)(((*(((char *)(s2->ptr)) + ((wrk1)))))));
zzzz_int1 = ((((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char1)))))))
!= (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char2))))))));
zzzz_skip1:
if(!(zzzz_int1)) goto zzzz_false6;
if(!(match_case)) goto zzzz_false4;
zzzz_int2 = (((unsigned char)((*(((char *)(s1->ptr)) + ((wrk1)))))) < ((unsigned
char)((*(((char *)(s2->ptr)) + ((wrk1)))))));
goto zzzz_skip2;
zzzz_false4:
zzzz_unsigned_char3 = ((unsigned char)(((*(((char *)(s1->ptr)) + ((wrk1)))))));
zzzz_unsigned_char4 = ((unsigned char)(((*(((char *)(s2->ptr)) + ((wrk1)))))));
zzzz_int2 = (((unsigned char)((((char)((*(((unsigned char *)(_MC_lower.ptr))
+ ((zzzz_unsigned_char3))))))))) < ((unsigned char)((((char)((*(((unsigned
char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char4))))))))));
zzzz_skip2:
if(!(zzzz_int2)) goto zzzz_false5;
result = - 1;
goto zzzz_skip3;
zzzz_false5:
result = 1;
zzzz_skip3:
goto zzzz_false1;
zzzz_false6:
goto zzzz_skip6;
zzzz_false2:
if(!(wrk1 >= occurs1)) goto zzzz_false7;
if(!(wrk1 >= occurs2)) goto zzzz_false7;
goto zzzz_false1;
goto zzzz_skip5;
zzzz_false7:
if(!(wrk1 >= occurs1)) goto zzzz_false8;
result = - 1;
goto zzzz_false1;
goto zzzz_skip4;
zzzz_false8:
result = 1;
goto zzzz_false1;
zzzz_skip4:
zzzz_skip5:
zzzz_skip6:
zzzz_cont1:
++wrk1;
goto zzzz_cont2;
zzzz_false1:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = result;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
void _mc__strkfnd(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
ky *keys)
{
int error = -2;
unsigned int subscript = 0;
int x;
int result;
int zzzz_exception = 0;
int zzzz_int1;
void *zzzz_actuals[2];
zzzz_actuals[0] = &(zzzz_exception);
if(!(!(*keys).key.occurs)) goto zzzz_false1;
goto zzzz_finish;
zzzz_false1:
x = (((struct _bn *)((*keys).bin.ptr)) + ((0))) -> r;
zzzz_cont2:
if(!(x != 1)) goto zzzz_false2;
if((unsigned)((((struct _bn *)((*keys).bin.ptr)) + ((x))) -> key) >= ((*keys).key.limit1))
if(!zzzz_resize4(&((*keys).key), (unsigned)((((struct _bn *)((*keys).bin.ptr))
+ ((x))) -> key), 50, 15)) {
zzzz_exception = 32000;
goto zzzz_finish;
}
if((unsigned)((((struct _bn *)((*keys).bin.ptr)) + ((x))) -> key) + 1 > ((*keys).key.occurs))
((*keys).key.occurs) = (unsigned)((((struct _bn *)((*keys).bin.ptr)) +
((x))) -> key) + 1;
zzzz_actuals[1] = &(result);
compare(zzzz_actuals, &((*key)), &((((struct _tx *)((*keys).key.ptr)) + (((((struct
_bn *)((*keys).bin.ptr)) + ((x))) -> key))) -> text), (*keys).match_case);
if(zzzz_exception) {
goto zzzz_finish;
}
if(!(result == 0)) goto zzzz_false3;
error = 0;
subscript = (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> key;
goto zzzz_finish;
zzzz_false3:
if(!((result < 0))) goto zzzz_false4;
zzzz_int1 = (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> l;
goto zzzz_skip1;
zzzz_false4:
zzzz_int1 = (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> r;
zzzz_skip1:
x = zzzz_int1;
zzzz_cont1:
goto zzzz_cont2;
zzzz_false2:
goto zzzz_finish;
zzzz_finish: ;
*((int *)(zzzz_return_ptr[1])) = error;
*((unsigned int *)(zzzz_return_ptr[2])) = subscript;
*((int *)(zzzz_return_ptr[0])) = zzzz_exception;
}
static int zzzz_resize1(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
int resize_pct1)
{
unsigned new_size, lim_a, lim_b, lim_c;
void *new_ptr;
struct zz1D_meta old;
unsigned new_limit1;
if(sub1 >= meta->limit1) {
lim_a = sub1 + 1;
lim_b = resize_num1 + meta->limit1;
lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
if(lim_a > lim_b)
{if(lim_a > lim_c)
new_limit1 = lim_a;
else
new_limit1 = lim_c;}
else if(lim_b > lim_c)
new_limit1 = lim_b;
else
new_limit1 = lim_c;
}
else
new_limit1 = meta->limit1;
new_size = new_limit1;
if(meta->limit1 == 0) {
new_ptr = malloc(new_size);
if(new_ptr == NULL)
return FALSE;
}
else
{
new_ptr = realloc(meta->ptr, new_size);
if(new_ptr == NULL)
return FALSE;
}
meta->ptr = new_ptr;
old = *meta;
meta->limit1 = new_limit1;
return TRUE;
}
static int zzzz_resize2(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
int resize_pct1)
{
unsigned zzzz_imw1;
unsigned new_size, lim_a, lim_b, lim_c;
void *new_ptr;
struct zz1D_meta old;
unsigned new_limit1;
if(sub1 >= meta->limit1) {
lim_a = sub1 + 1;
lim_b = resize_num1 + meta->limit1;
lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
if(lim_a > lim_b)
{if(lim_a > lim_c)
new_limit1 = lim_a;
else
new_limit1 = lim_c;}
else if(lim_b > lim_c)
new_limit1 = lim_b;
else
new_limit1 = lim_c;
}
else
new_limit1 = meta->limit1;
new_size = sizeof(struct _fsm);
if((new_size * new_limit1) / new_size != new_limit1)
return FALSE;
new_size *= new_limit1;
if(meta->limit1 == 0) {
new_ptr = malloc(new_size);
if(new_ptr == NULL)
return FALSE;
}
else
{
new_ptr = realloc(meta->ptr, new_size);
if(new_ptr == NULL)
return FALSE;
}
meta->ptr = new_ptr;
old = *meta;
meta->limit1 = new_limit1;
for(zzzz_imw1 = old.limit1; zzzz_imw1 < meta->limit1; ++zzzz_imw1) {
(((struct _fsm *)(meta->ptr)) + (zzzz_imw1)) -> cset.occurs = 0;
(((struct _fsm *)(meta->ptr)) + (zzzz_imw1)) -> cset.limit1 = 0;
}
return TRUE;
}
static int zzzz_resize3(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
int resize_pct1)
{
unsigned new_size, lim_a, lim_b, lim_c;
void *new_ptr;
struct zz1D_meta old;
unsigned new_limit1;
if(sub1 >= meta->limit1) {
lim_a = sub1 + 1;
lim_b = resize_num1 + meta->limit1;
lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
if(lim_a > lim_b)
{if(lim_a > lim_c)
new_limit1 = lim_a;
else
new_limit1 = lim_c;}
else if(lim_b > lim_c)
new_limit1 = lim_b;
else
new_limit1 = lim_c;
}
else
new_limit1 = meta->limit1;
new_size = sizeof(int);
if((new_size * new_limit1) / new_size != new_limit1)
return FALSE;
new_size *= new_limit1;
if(meta->limit1 == 0) {
new_ptr = malloc(new_size);
if(new_ptr == NULL)
return FALSE;
}
else
{
new_ptr = realloc(meta->ptr, new_size);
if(new_ptr == NULL)
return FALSE;
}
meta->ptr = new_ptr;
old = *meta;
meta->limit1 = new_limit1;
return TRUE;
}
static int zzzz_resize4(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
int resize_pct1)
{
unsigned zzzz_imw1;
unsigned new_size, lim_a, lim_b, lim_c;
void *new_ptr;
struct zz1D_meta old;
unsigned new_limit1;
if(sub1 >= meta->limit1) {
lim_a = sub1 + 1;
lim_b = resize_num1 + meta->limit1;
lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
if(lim_a > lim_b)
{if(lim_a > lim_c)
new_limit1 = lim_a;
else
new_limit1 = lim_c;}
else if(lim_b > lim_c)
new_limit1 = lim_b;
else
new_limit1 = lim_c;
}
else
new_limit1 = meta->limit1;
new_size = sizeof(struct _tx);
if((new_size * new_limit1) / new_size != new_limit1)
return FALSE;
new_size *= new_limit1;
if(meta->limit1 == 0) {
new_ptr = malloc(new_size);
if(new_ptr == NULL)
return FALSE;
}
else
{
new_ptr = realloc(meta->ptr, new_size);
if(new_ptr == NULL)
return FALSE;
}
meta->ptr = new_ptr;
old = *meta;
meta->limit1 = new_limit1;
for(zzzz_imw1 = old.limit1; zzzz_imw1 < meta->limit1; ++zzzz_imw1) {
(((struct _tx *)(meta->ptr)) + (zzzz_imw1)) -> text.occurs = 0;
(((struct _tx *)(meta->ptr)) + (zzzz_imw1)) -> text.limit1 = 0;
}
return TRUE;
}
static int zzzz_resize5(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
int resize_pct1)
{
unsigned new_size, lim_a, lim_b, lim_c;
void *new_ptr;
struct zz1D_meta old;
unsigned new_limit1;
if(sub1 >= meta->limit1) {
lim_a = sub1 + 1;
lim_b = resize_num1 + meta->limit1;
lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
if(lim_a > lim_b)
{if(lim_a > lim_c)
new_limit1 = lim_a;
else
new_limit1 = lim_c;}
else if(lim_b > lim_c)
new_limit1 = lim_b;
else
new_limit1 = lim_c;
}
else
new_limit1 = meta->limit1;
new_size = sizeof(struct _bn);
if((new_size * new_limit1) / new_size != new_limit1)
return FALSE;
new_size *= new_limit1;
if(meta->limit1 == 0) {
new_ptr = malloc(new_size);
if(new_ptr == NULL)
return FALSE;
}
else
{
new_ptr = realloc(meta->ptr, new_size);
if(new_ptr == NULL)
return FALSE;
}
meta->ptr = new_ptr;
old = *meta;
meta->limit1 = new_limit1;
return TRUE;
}