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 >
C/C++ Source or Header  |  1996-10-23  |  211KB  |  7,245 lines

  1. /*
  2. * MOAL C Standard Library, version 1.04
  3. *
  4. *    Copyright (c) 1996, MOAL Languages. All rights reserved.
  5. *
  6. *
  7. * big-endian or little-endian: see the first comment below
  8. *
  9. * multithreading: If the MOAL C program has multiple threads, then, when
  10. *                 this library file is compiled for that MOAL C program,
  11. *                 choose -- assuming there is such a choice -- to use the
  12. *                 multithreading version of the ANSI C library. Also,
  13. *                 confine all MOAL C calls of:
  14. *
  15. *                        fopen(), fclose(), tmpfile(),
  16. *                        fgetall(), fputall()
  17. *
  18. *                 to a single thread (see the explanation below).
  19. */
  20.  
  21.  
  22. /*
  23. * This library uses IEEE-754 floating-point error codes. Whether or not
  24. * the macro name LITTLE_ENDIAN is defined determines the assumed byte
  25. * ordering of these error codes (note that the PC is little-endian, but
  26. * workstations are typically big-endian). Note that if LITTLE_ENDIAN is
  27. * defined and the microprocessor is not little-endian, or, conversely,
  28. * LITTLE_ENDIAN is not defined and the microprocessor is little-endian,
  29. * then certain of the library math functions will give erroneous results
  30. * for certain inputs, and the merr() function will not work.
  31. *
  32. * If the microprocessor is big-endian and not little-endian, then comment
  33. * the #define below. Note that the PC is little-endian; the PowerPC,
  34. * depending on the OS being used, is either big-endian or little-endian;
  35. * workstation hardware is typically big-endian. Consult your hardware
  36. * and/or software documentation if there is any doubt.
  37. */
  38. #define LITTLE_ENDIAN  /* comment this #define if want big-endian */
  39.  
  40.  
  41. #include <stdlib.h>
  42. #include <stdio.h>
  43. #include <string.h>
  44. #include <ctype.h>
  45. #include <stdarg.h>
  46. #include <math.h>
  47. #include <time.h>
  48. #include <assert.h>
  49. #include <limits.h>
  50. #include <float.h>
  51. #include <errno.h>
  52.  
  53.  
  54. /*
  55. * globals used for translating C's FILE pointer to MOAL C's file number,
  56. * and vice versa
  57. *
  58. * note: these globals are used to preserve the translation information
  59. *       between calls. However, in a multithreaded application, the two
  60. *       functions that change the values of these globals, remove_file()
  61. *       and store_file(), are, in effect, critical sections that need
  62. *       serialization by using semaphores. However, semaphores are not
  63. *       used by this code (for portabilty reasons). Consequently, if the
  64. *       program is multithreaded, confine all MOAL C calls of:
  65. *
  66. *           fopen(), fclose(), tmpfile(),
  67. *           fgetall(), fputall()
  68. *
  69. *       to a single thread, because these are the library functions that
  70. *       can call remove_file() and store_file().
  71. */
  72.  
  73. #define FILES_MAX 500
  74.  
  75. static FILE *files[FILES_MAX];
  76. static int files_cnt;
  77.  
  78.  
  79. /*
  80. * some types used by MOAL C library functions
  81. */
  82.  
  83. typedef unsigned long ff_time_t;
  84. typedef unsigned long ff_clock_t;
  85. typedef unsigned int  ff_size_t;
  86. typedef unsigned int  moal_t;
  87.  
  88. struct d1_meta {
  89.    void *ptr;
  90.    moal_t occurs;
  91.    moal_t limit1;
  92. };
  93.  
  94.  
  95. /*
  96. * prototypes for the MOAL C library functions
  97. */
  98.  
  99. /*
  100. * the following functions were written in MOAL C, and the generated
  101. * C code is at the end of this file:
  102. *
  103. *   strreg()
  104. *   strfndr()
  105. *   stresc()
  106. *   fgetall()
  107. *   fputall()
  108. *   strkey()
  109. *   strknew()
  110. *   strkmap()
  111. *   strkfnd()
  112. *
  113. */
  114.  
  115. /* formatted input/output */
  116. void _mc__printf(void *return_ptr[], struct d1_meta *format, ...);
  117. void _mc__fprintf(void *return_ptr[], int file, struct d1_meta *format, ...);
  118. void _mc__sprintf(void *return_ptr[], struct d1_meta *out, int append,
  119.                   struct d1_meta *format, ...);
  120.  
  121. void _mc__scanf(void *return_ptr[], struct d1_meta *format, ...);
  122. void _mc__fscanf(void *return_ptr[], int file, struct d1_meta *format, ...);
  123. void _mc__sscanf(void *return_ptr[],
  124.                  struct d1_meta *source, struct d1_meta *format, ...);
  125.  
  126. /* math */
  127. void _mc__abs(void *return_ptr[], int x);
  128. void _mc__acos(void *return_ptr[], double x);
  129. void _mc__asin(void *return_ptr[], double x);
  130. void _mc__atan(void *return_ptr[], double x);
  131. void _mc__atan2(void *return_ptr[], double y, double x);
  132. void _mc__ceil(void *return_ptr[], double x);
  133. void _mc__cos(void *return_ptr[], double x);
  134. void _mc__div(void *return_ptr[], int x, int divide_by);
  135. void _mc__exp(void *return_ptr[], double x);
  136. void _mc__fabs(void *return_ptr[], double x);
  137. void _mc__floor(void *return_ptr[], double x);
  138. void _mc__fmod(void *return_ptr[], double x, double divide_by);
  139. void _mc__labs(void *return_ptr[], long x);
  140. void _mc__ldiv(void *return_ptr[], long x, long divide_by);
  141. void _mc__log(void *return_ptr[], double x);
  142. void _mc__log10(void *return_ptr[], double x);
  143. void _mc__merr(void *return_ptr[], double x);
  144. void _mc__pow(void *return_ptr[], double x, double power);
  145. void _mc__rand(void *return_ptr[], int prev);
  146. void _mc__sin(void *return_ptr[], double x);
  147. void _mc__sqrt(void *return_ptr[], double x);
  148. void _mc__tan(void *return_ptr[], double x);
  149.  
  150. /* time */
  151.  
  152. struct ff_tm {
  153.   int tm_sec;   /* seconds after the minute  (0 - 61) */
  154.   int tm_min;   /* minutes after the hour    (0 - 59) */
  155.   int tm_hour;  /* hours since midnight      (0 - 23) */
  156.   int tm_mday;  /* day of the month          (1 - 31) */
  157.   int tm_mon;   /* months since January      (0 - 11) */
  158.   int tm_year;  /* years since 1900 */
  159.   int tm_wday;  /* days since Sunday         (0 - 6) */
  160.   int tm_yday;  /* days since January 1st    (0 - 365) */
  161.   int tm_isdst; /* Daylight Saving Time flag */
  162. };
  163.  
  164. void _mc__clock(void *return_ptr[]);
  165. void _mc__ctime(void *return_ptr[], ff_time_t any_time);
  166. void _mc__difftime(void *return_ptr[],
  167.                    ff_time_t any_time, ff_time_t subtract_time);
  168. void _mc__gmtime(void *return_ptr[], ff_time_t any_time);
  169. void _mc__localtime(void *return_ptr[], ff_time_t any_time);
  170. void _mc__mktime(void *return_ptr[], struct ff_tm *time_info);
  171. void _mc__strftime(void *return_ptr[],
  172.                    struct d1_meta *format, struct ff_tm *time_info);
  173. void _mc__time(void *return_ptr[]);
  174.  
  175. /* file I/O */
  176.  
  177. void _mc__fclose(void *return_ptr[], int file);
  178. void _mc__fgetc(void *return_ptr[], int file);
  179. void _mc__fgets(void *return_ptr[], struct d1_meta *out, ff_size_t count,
  180.                 int file);
  181. void _mc__fopen(void *return_ptr[], struct d1_meta *filename,
  182.                 struct d1_meta *mode);
  183. void _mc__fputc(void *return_ptr[], char character, int file);
  184. void _mc__fputs(void *return_ptr[], struct d1_meta *source, int file);
  185. void _mc__fread(void *return_ptr[], struct d1_meta *out,
  186.                 ff_size_t out_offset, ff_size_t read_count, int file);
  187. void _mc__fseek(void *return_ptr[], int file, long offset, int from_where);
  188. void _mc__ftell(void *return_ptr[], int file);
  189. void _mc__fwrite(void *return_ptr[], struct d1_meta *source,
  190.                  ff_size_t source_offset, ff_size_t write_count, int file);
  191. void _mc__remove(void *return_ptr[], struct d1_meta *filename);
  192. void _mc__rename(void *return_ptr[], struct d1_meta *current_filename,
  193.                  struct d1_meta *new_filename);
  194. void _mc__tmpfile(void *return_ptr[]);
  195. void _mc__tmpnam(void *return_ptr[]);
  196.  
  197. /* character */
  198. void _mc__toupper(void *return_ptr[], char character);
  199. void _mc__tolower(void *return_ptr[], char character);
  200. void _mc__isalnum(void *return_ptr[], char character);
  201. void _mc__isalpha(void *return_ptr[], char character);
  202. void _mc__isdigit(void *return_ptr[], char character);
  203. void _mc__islower(void *return_ptr[], char character);
  204. void _mc__isspace(void *return_ptr[], char character);
  205. void _mc__isupper(void *return_ptr[], char character);
  206.  
  207. /* sort and search */
  208. void _mc__qsort(void *return_ptr[], struct d1_meta *, ff_size_t element_size,
  209.                 void (*compare) (void *[], void *, void *));
  210. void _mc__bsearch(void *return_ptr[], void *, struct d1_meta *,
  211.                   ff_size_t element_size,
  212.                   void (*compare) (void *[], void *, void *));
  213.  
  214. /* communication with the environment */
  215. void _mc__main(void *return_ptr[], struct d1_meta *args);
  216. void _mc__getenv(void *return_ptr[], struct d1_meta *name);
  217. void _mc__exit(void *return_ptr[], int status);
  218. void _mc__system(void *return_ptr[], struct d1_meta *command);
  219.  
  220. /* strings */
  221. void _mc__strcat(void *return_ptr[],
  222.                  struct d1_meta *out, struct d1_meta *source);
  223. void _mc__strcmp(void *return_ptr[],
  224.                  struct d1_meta *s1, struct d1_meta *s2);
  225. void _mc__strcpy(void *return_ptr[],
  226.                  struct d1_meta *out, struct d1_meta *source);
  227. void _mc__strerror(void *return_ptr[], int error);
  228. void _mc__strfnd(void *return_ptr[], struct d1_meta *search,
  229.                  ff_size_t from_offset, ff_size_t to_offset,
  230.                  int match_case, struct d1_meta *find);
  231. void _mc__strncmp(void *return_ptr[],
  232.                   struct d1_meta *s1, struct d1_meta *s2, ff_size_t n);
  233. void _mc__strpart(void *return_ptr[], struct d1_meta *source,
  234.                   ff_size_t from_offset, ff_size_t to_offset);
  235. void _mc__strrpl(void *return_ptr[], struct d1_meta *out,
  236.                  ff_size_t out_offset, ff_size_t cut_length,
  237.                  struct d1_meta *insert);
  238. void _mc__strtod(void *return_ptr[],
  239.                  struct d1_meta *source, ff_size_t source_offset);
  240. void _mc__strtol(void *return_ptr[],
  241.                  struct d1_meta *source, ff_size_t source_offset);
  242. void _mc__strtoul(void *return_ptr[],
  243.                   struct d1_meta *source, ff_size_t source_offset);
  244.  
  245.  
  246. /*
  247. * prototypes for support functions used by the library
  248. */
  249.  
  250. static void format_new_flags(char comma, char dollar, char paren,
  251.                              char *in, char *out, char space_flag);
  252. static int store_file(FILE *in);
  253. static void remove_file(int in);
  254. static FILE *retrieve_file(int in);
  255. static void tm_to_ff_tm(struct tm *in, struct ff_tm *out);
  256. static void ff_tm_to_tm(struct ff_tm *in, struct tm *out);
  257. static int resize_cspace(struct d1_meta *out, moal_t new_min);
  258.  
  259.  
  260. /*
  261. * globals referenced (as externals) by the MOAL C header file
  262. *
  263. * note: the reason _MC_name is declared a varspace in the MOAL C header
  264. *       file instead of declared a fixed-space, is to avoid having a
  265. *       potentially changing name for the fixed-space's metadata: that
  266. *       name (which would change if the user changes the naming prefix: a
  267. *       compiler option) would be unknown to this C program, because this
  268. *       C program is not compiled by the MOAL C compiler.
  269. */
  270.  
  271. #define  WS     1  /* whitespace */
  272. #define  LL     2  /* lowercase letter */
  273. #define  UL     4  /* uppercase letter */
  274. #define  DT     8  /* digit */
  275.  
  276. static signed char mc_ctype[256] = {
  277.    0,   0,   0,   0,   0,   0,   0,   0,
  278.    0,  WS,  WS,  WS,  WS,  WS,   0,   0,
  279.    0,   0,   0,   0,   0,   0,   0,   0,
  280.    0,   0,   0,   0,   0,   0,   0,   0,
  281.   WS,   0,   0,   0,   0,   0,   0,   0,
  282.    0,   0,   0,   0,   0,   0,   0,   0,
  283.   DT,  DT,  DT,  DT,  DT,  DT,  DT,  DT,
  284.   DT,  DT,   0,   0,   0,   0,   0,   0,
  285.    0,  UL,  UL,  UL,  UL,  UL,  UL,  UL,
  286.   UL,  UL,  UL,  UL,  UL,  UL,  UL,  UL,
  287.   UL,  UL,  UL,  UL,  UL,  UL,  UL,  UL,
  288.   UL,  UL,  UL,   0,   0,   0,   0,   0,
  289.    0,  LL,  LL,  LL,  LL,  LL,  LL,  LL,
  290.   LL,  LL,  LL,  LL,  LL,  LL,  LL,  LL,
  291.   LL,  LL,  LL,  LL,  LL,  LL,  LL,  LL,
  292.   LL,  LL,  LL,   0,   0,   0,   0,   0
  293. };
  294.  
  295. struct d1_meta _MC_ctype = {mc_ctype, 256, 256};
  296.  
  297. static unsigned char mc_lower[256] = {
  298.    0,   1,   2,   3,   4,   5,   6,   7,
  299.    8,   9,  10,  11,  12,  13,  14,  15,
  300.   16,  17,  18,  19,  20,  21,  22,  23,
  301.   24,  25,  26,  27,  28,  29,  30,  31,
  302.   32,  33,  34,  35,  36,  37,  38,  39,
  303.   40,  41,  42,  43,  44,  45,  46,  47,
  304.   48,  49,  50,  51,  52,  53,  54,  55,
  305.   56,  57,  58,  59,  60,  61,  62,  63,
  306.   64,  97,  98,  99, 100, 101, 102, 103,
  307.  104, 105, 106, 107, 108, 109, 110, 111,
  308.  112, 113, 114, 115, 116, 117, 118, 119,
  309.  120, 121, 122,  91,  92,  93,  94,  95,
  310.   96,  97,  98,  99, 100, 101, 102, 103,
  311.  104, 105, 106, 107, 108, 109, 110, 111,
  312.  112, 113, 114, 115, 116, 117, 118, 119,
  313.  120, 121, 122, 123, 124, 125, 126, 127,
  314.  128, 129, 130, 131, 132, 133, 134, 135,
  315.  136, 137, 138, 139, 140, 141, 142, 143,
  316.  144, 145, 146, 147, 148, 149, 150, 151,
  317.  152, 153, 154, 155, 156, 157, 158, 159,
  318.  160, 161, 162, 163, 164, 165, 166, 167,
  319.  168, 169, 170, 171, 172, 173, 174, 175,
  320.  176, 177, 178, 179, 180, 181, 182, 183,
  321.  184, 185, 186, 187, 188, 189, 190, 191,
  322.  192, 193, 194, 195, 196, 197, 198, 199,
  323.  200, 201, 202, 203, 204, 205, 206, 207,
  324.  208, 209, 210, 211, 212, 213, 214, 215,
  325.  216, 217, 218, 219, 220, 221, 222, 223,
  326.  224, 225, 226, 227, 228, 229, 230, 231,
  327.  232, 233, 234, 235, 236, 237, 238, 239,
  328.  240, 241, 242, 243, 244, 245, 246, 247,
  329.  248, 249, 250, 251, 252, 253, 254, 255
  330. };
  331.  
  332. struct d1_meta _MC_lower = {mc_lower, 256, 256};
  333.  
  334. static unsigned char mc_upper[256] = {
  335.    0,   1,   2,   3,   4,   5,   6,   7,
  336.    8,   9,  10,  11,  12,  13,  14,  15,
  337.   16,  17,  18,  19,  20,  21,  22,  23,
  338.   24,  25,  26,  27,  28,  29,  30,  31,
  339.   32,  33,  34,  35,  36,  37,  38,  39,
  340.   40,  41,  42,  43,  44,  45,  46,  47,
  341.   48,  49,  50,  51,  52,  53,  54,  55,
  342.   56,  57,  58,  59,  60,  61,  62,  63,
  343.   64,  65,  66,  67,  68,  69,  70,  71,
  344.   72,  73,  74,  75,  76,  77,  78,  79,
  345.   80,  81,  82,  83,  84,  85,  86,  87,
  346.   88,  89,  90,  91,  92,  93,  94,  95,
  347.   96,  65,  66,  67,  68,  69,  70,  71,
  348.   72,  73,  74,  75,  76,  77,  78,  79,
  349.   80,  81,  82,  83,  84,  85,  86,  87,
  350.   88,  89,  90, 123, 124, 125, 126, 127,
  351.  128, 129, 130, 131, 132, 133, 134, 135,
  352.  136, 137, 138, 139, 140, 141, 142, 143,
  353.  144, 145, 146, 147, 148, 149, 150, 151,
  354.  152, 153, 154, 155, 156, 157, 158, 159,
  355.  160, 161, 162, 163, 164, 165, 166, 167,
  356.  168, 169, 170, 171, 172, 173, 174, 175,
  357.  176, 177, 178, 179, 180, 181, 182, 183,
  358.  184, 185, 186, 187, 188, 189, 190, 191,
  359.  192, 193, 194, 195, 196, 197, 198, 199,
  360.  200, 201, 202, 203, 204, 205, 206, 207,
  361.  208, 209, 210, 211, 212, 213, 214, 215,
  362.  216, 217, 218, 219, 220, 221, 222, 223,
  363.  224, 225, 226, 227, 228, 229, 230, 231,
  364.  232, 233, 234, 235, 236, 237, 238, 239,
  365.  240, 241, 242, 243, 244, 245, 246, 247,
  366.  248, 249, 250, 251, 252, 253, 254, 255
  367. };
  368.  
  369. struct d1_meta _MC_upper = {mc_upper, 256, 256};
  370.  
  371.  
  372. /*
  373. * miscellaneous defines used by the library
  374. */
  375.  
  376. #undef max
  377. #undef TRUE
  378. #undef FALSE
  379.  
  380. #define max(a, b)   (((a) > (b)) ? (a) : (b))
  381.  
  382. #define TRUE   1
  383. #define FALSE  0
  384.  
  385. #define MEMORY_FAILURE  32000  /* MOAL C's one predefined exception */
  386.  
  387. #define MC_EOF                    -1 /* MOAL C's added error codes, negative
  388.                                         so no conflict with C errno values */
  389. #define MC_NOT_FOUND              -2
  390. #define MC_NaN                    -3
  391. #define MC_pINF                   -4
  392. #define MC_nINF                   -5
  393. #define MC_EMPTY_PARAMETER        -6  /* a copy is in mc_lsupp.mc */
  394. #define MC_OFFSET_INVALID         -7  /* a copy is in mc_lsupp.mc */
  395. #define MC_INCOMPATIBLE_PARAMS    -8  /* a copy is in mc_lsupp.mc */
  396. #define MC_INVALID_FILE_NUMBER    -9
  397. #define MC_TOO_MANY_OPEN_FILES   -10
  398. #define MC_REX_MALFORMED         -11  /* a copy is in mc_lsupp.mc */
  399. #define MC_REX_MATCHES_NOTHING   -12  /* a copy is in mc_lsupp.mc */
  400. #define MC_MACHINE_EMPTY         -13  /* a copy is in mc_lsupp.mc */
  401.  
  402. #define SCANF_MAXWIDTH 1000  /* default max field width for ops [ and s */
  403.  
  404. #define FIRST_USER_FILE 4  /* files 1, 2, and 3 are the predefined files */
  405.  
  406. /*
  407. * several C functions used in this library add a null character at the end
  408. * of their output. room for this added null character is added to the affected
  409. * new_min calculations (see sprintf, and the scanf functions for %s and %[])
  410. */
  411. #define ROOM_FOR_C_ADDED_NULL  1
  412.  
  413. /*
  414. * the following four macros work together to safely add the terminating
  415. * null character required by many of the ANSI C library functions
  416. */
  417. #define make_safe(meta, mall, save_ptr, save_ch, fail) \
  418.   {if(meta->occurs < meta->limit1) \
  419.       {mall = FALSE; \
  420.        save_ch = *(((unsigned char *)meta->ptr) + meta->occurs);} \
  421.    else \
  422.       {mall = TRUE; \
  423.        save_ptr = meta->ptr; \
  424.        meta->ptr = malloc(meta->occurs + 1); \
  425.        if(meta->ptr == NULL) \
  426.            {meta->ptr = save_ptr; \
  427.             fail \
  428.             *((int *)(return_ptr[0])) = MEMORY_FAILURE; \
  429.             return;} \
  430.        strncpy(meta->ptr, save_ptr, meta->occurs);} \
  431.    *(((unsigned char *)meta->ptr) + meta->occurs) = 0;}
  432.  
  433. #define VA_END  va_end(ap);
  434. #define NONE
  435.  
  436. #define undo_safe(meta, mall, save_ptr, save_ch) \
  437.   {if(mall) \
  438.        {free(meta->ptr); \
  439.         meta->ptr = save_ptr;} \
  440.    else \
  441.        *(((unsigned char *)meta->ptr) + meta->occurs) = save_ch;}
  442.  
  443.  
  444. /*
  445.   test for overflow when adding two unsigned values that must fit into
  446.   unsigned type 'type'. note that it is not necessary to test the sum as
  447.   being less than both x and y, because when overflow happens from adding
  448.   two unsigned values, the sum is always less than both operands, so
  449.   either operand can be tested against the sum (the choice is arbitrary).
  450. */
  451. #define sum_overflows(type, x, y) ((type)((x) + (y)) < (x) ? 1 : 0)
  452.  
  453.  
  454. /*
  455. * error codes for floating-point. NaN (not-a-number) and Inf (infinity)
  456. * are defined by the IEEE-754 standard
  457. */
  458. #ifdef LITTLE_ENDIAN
  459.    /* assume little-endian */
  460.  
  461.    static union {
  462.       unsigned char dummy[8];
  463.       double num;
  464.    } pos_inf = {0, 0, 0, 0, 0, 0, 240, 127};
  465.  
  466.    static union {
  467.       unsigned char dummy[8];
  468.       double num;
  469.    } neg_inf = {0, 0, 0, 0, 0, 0, 240, 255};
  470.  
  471.    static union {
  472.       unsigned char dummy[8];
  473.       double num;
  474.    } nan = {0, 0, 0, 0, 0, 0, 248, 127};  /* a quiet NaN */
  475.  
  476.    #define WORK_SIZE 8
  477.  
  478.    #define dblerr(x) (work.num = (x), \
  479.       ((work.cc[6] & 240) == 240 && (work.cc[7] & 127) == 127) ? \
  480.          ((*(int *)(&work.cc[0]) == 0 && *(short *)(&work.cc[4]) == 0 \
  481.            && (work.cc[6] & 15) == 0) ? \
  482.                 ((work.cc[7] & 128) ? MC_nINF : MC_pINF) : MC_NaN) : 0)
  483. #else
  484.    /* assume big-endian */
  485.  
  486.    static union {
  487.       unsigned char dummy[8];
  488.       double num;
  489.    } pos_inf = {127, 240, 0, 0, 0, 0, 0, 0};
  490.  
  491.    static union {
  492.       unsigned char dummy[8];
  493.       double num;
  494.    } neg_inf = {255, 240, 0, 0, 0, 0, 0, 0};
  495.  
  496.    static union {
  497.       unsigned char dummy[8];
  498.       double num;
  499.    } nan = {127, 248, 0, 0, 0, 0, 0, 0};  /* a quiet NaN */
  500.  
  501.    #define WORK_SIZE 8
  502.  
  503.    #define dblerr(x) (work.num = (x), \
  504.       ((work.cc[1] & 240) == 240 && (work.cc[0] & 127) == 127) ? \
  505.          ((*(int *)(&work.cc[4]) == 0 && *(short *)(&work.cc[2]) == 0 \
  506.            && (work.cc[1] & 15) == 0) ? \
  507.                 ((work.cc[0] & 128) ? MC_nINF : MC_pINF) : MC_NaN) : 0)
  508. #endif
  509.  
  510.  
  511.  
  512.  
  513. int main(int argc, char *argv[])
  514. {
  515. struct ar {
  516.    struct d1_meta text;
  517. } *base;
  518. int wrk1, len, ret, exception;
  519. struct d1_meta args;
  520. void *actuals[2];
  521.  
  522. /*
  523. * These sizes are assumed by the library code that sets and tests for
  524. * IEEE-754 error codes (see the definition of the dblerr() macro). That
  525. * short is 2 bytes is also assumed by the MOAL C compiler when it
  526. * generates C code for the arithmetic type onecode.
  527. */
  528. assert(sizeof(short) == 2 && sizeof(int) == 4 && sizeof(double) == 8);
  529.  
  530. /* store the command-line arguments, if any */
  531. base = args.ptr = malloc(argc * sizeof(struct ar));
  532. if(base == NULL)
  533.     {mem_error:
  534.      printf("** not enough memory to start main() **\n   execution \
  535. terminated\n");
  536.      exit(1);}
  537.  
  538. args.occurs = args.limit1 = argc;
  539.  
  540. /* copy the data */
  541. for(wrk1 = 0; wrk1 < argc; ++wrk1)
  542.     {len = 1 + strlen(argv[wrk1]);  /* add 1 for null terminator */
  543.      base[wrk1].text.ptr = malloc(len);
  544.      if(base[wrk1].text.ptr == NULL)
  545.          goto mem_error;
  546.      strcpy((char *)base[wrk1].text.ptr, argv[wrk1]);
  547.      base[wrk1].text.occurs = len - 1;
  548.      base[wrk1].text.limit1 = len;}
  549.  
  550. /* call the cover function */
  551. actuals[0] = &exception;
  552. actuals[1] = &ret;
  553.  
  554. _mc__main(actuals, &args);
  555.  
  556. if(exception)
  557.     {fprintf(stderr, "\nmain() is returning with an unhandled \
  558. exception:\n\n");
  559.      if(exception == MEMORY_FAILURE)
  560.          fprintf(stderr, " memory failure (not enough memory)\n");
  561.      else
  562.          fprintf(stderr, " exception %d\n", exception);
  563.      ret = EXIT_FAILURE;}
  564.  
  565. return ret;
  566. }
  567.  
  568.  
  569.  
  570.  
  571. void _mc__printf(void *return_ptr[], struct d1_meta *format, ...)
  572. {
  573. int sent = 0;
  574. unsigned char *bgn, *end, *curr,
  575.               save, ch, spec[100], size_mod, at_end, have_precision,
  576.               cm_comma, cm_dollar, cm_paren, cm_in[200], cm_out[300],
  577.               space_flag;
  578. int wrk1, ret, sub, min_width, precision, mall;
  579. void *save_ptr;
  580. struct d1_meta *d1;
  581. va_list ap;
  582.  
  583. va_start(ap, format);
  584.  
  585. if(format->occurs == 0)
  586.     goto done;
  587.  
  588. curr = bgn = (unsigned char *)format->ptr;
  589. end = bgn + format->occurs - 1;
  590.  
  591. /*
  592. * note: in those places where a 0 terminator is added on a temporary
  593. * basis, this is done because the called C library function requires a
  594. * 0 terminator to mark the end of a string
  595. */
  596.  
  597. for(at_end = 'n';; ++curr)
  598.     {if(curr == end)
  599.          {at_end = 'y';
  600.           output_text:
  601.           save = *(curr + 1);
  602.           *(curr + 1) = 0;
  603.           ret = printf("%s", bgn);
  604.           *(curr + 1) = save;
  605.           if(ret < 0)
  606.               goto error;
  607.           else
  608.               sent += ret;
  609.           if(at_end == 'y')
  610.               break;
  611.           bgn = curr + 1;
  612.           continue;}
  613.  
  614.      if(*curr == '%')  /* beginning of conversion specification */
  615.          {if(bgn < curr)
  616.               {--curr;
  617.                goto output_text;}
  618.           /* extract the conversion specification */
  619.           have_precision = cm_comma = cm_dollar =
  620.                                                 cm_paren = space_flag = 'n';
  621.           sub = min_width = precision = 0;
  622.           spec[sub++] = '%';
  623.           for(++curr; curr <= end && sub < sizeof(spec) - 25; ++curr)
  624.               {ch = *curr;
  625.  
  626.                /* check for ANSI C conversions that are invalid in MOAL C */
  627.                if(ch == 'p' || ch == 'n' || ch == 'o')
  628.                    goto error;
  629.  
  630.                /* check for space flag, info is used elsewhere */
  631.                if(ch == '+')
  632.                    space_flag = 0;
  633.                else if(ch == ' ' && space_flag == 'n')
  634.                    space_flag = 'y';
  635.  
  636.                /* the , $ and ( are new flags */
  637.                if(ch == ',')
  638.                    {cm_comma = 'y';
  639.                     continue;}
  640.                else if(ch == '$')
  641.                    {cm_dollar = 'y';
  642.                     continue;}
  643.                else if(ch == '(')
  644.                    {cm_paren = 'y';
  645.                     continue;}
  646.  
  647.                if(ch == '*')
  648.                    {min_width = va_arg(ap, int);
  649.                     sub += sprintf(&spec[sub], "%d", min_width);
  650.                     /* "A negative field width argument is taken as a - flag
  651.                         followed by a positive field width" : pg. 239 TSCL */
  652.                     if(min_width < 0)
  653.                         min_width *= -1;
  654.                     continue;}
  655.  
  656.                if(ch == '.')
  657.                    {if(*(curr + 1) == '*')
  658.                         {precision = va_arg(ap, int);
  659.                          /* "A negative precision argument is taken as if
  660.                              the precision were omitted" : pg. 239 TSCL */
  661.                          if(precision < 0)
  662.                              {++curr;
  663.                               continue;}
  664.                          have_precision = 'y';
  665.                          sub += sprintf(&spec[sub], ".%d", precision);
  666.                          ++curr;
  667.                          continue;}
  668.                     have_precision = 'y';}
  669.  
  670.                spec[sub++] = ch;
  671.  
  672.                if(isdigit(ch))
  673.                    {if(have_precision == 'n')
  674.                         {if(min_width == 0 && ch != '0')
  675.                              min_width = strtol(curr, NULL, 10);}
  676.                     else if(precision == 0)
  677.                         precision = strtol(curr, NULL, 10);}
  678.  
  679.                /* check for end of the conversion specification */
  680.                else if((isalpha(ch)
  681.                         && (ch == 'd' || ch == 's' || ch == 'c'
  682.                             || ch == 'e' || ch == 'E' || ch == 'f'
  683.                             || ch == 'g' || ch == 'G' || ch == 'i'
  684.                             || ch == 'u' || ch == 'x' || ch == 'X'))
  685.                     || ch == '%')
  686.                    {spec[sub] = 0;
  687.                     /* set the size modifier, if any */
  688.                     size_mod = *(curr - 1);
  689.                     /* check for enough room to process the new flags */
  690.                     if(ch == 'u')
  691.                         cm_paren = space_flag = 'n';
  692.                     if(cm_comma == 'y' || cm_dollar == 'y' || cm_paren == 'y')
  693.                         {if(ch == 'u' || ch == 'd' || ch == 'i')
  694.                              {wrk1 = max(max(precision, min_width),
  695.                                          (size_mod == 'l' ?
  696.                                           sizeof(long) : sizeof(int)) * 3);
  697.                               if(wrk1 > sizeof(cm_in) - 1)
  698.                                   cm_comma = cm_paren = cm_dollar = 'n';}
  699.                          else if(ch == 'f')
  700.                              {wrk1 = max(min_width,
  701.                                          (have_precision == 'y' ?
  702.                                           precision : 6)
  703.                                          + (size_mod == 'L' ?
  704.                                             sizeof(long double) :
  705.                                             sizeof(double)) * 3 + 5);
  706.                               if(wrk1 > sizeof(cm_in) - 1)
  707.                                   cm_comma = cm_paren = cm_dollar = 'n';}
  708.                          else
  709.                              cm_comma = cm_paren = cm_dollar = 'n';}
  710.                     /* process the type */
  711.                     if(ch == 's')
  712.                         {d1 = va_arg(ap, struct d1_meta *);
  713.                          if(d1->occurs)
  714.                              {make_safe(d1, mall, save_ptr, save, VA_END);
  715.                               ret = printf(spec, (char *)d1->ptr);
  716.                               undo_safe(d1, mall, save_ptr, save);}
  717.                          else
  718.                              ret = printf(spec, "");
  719.                          if(ret < 0)
  720.                              goto error;
  721.                          else
  722.                              sent += ret;}
  723.                     else if(cm_comma == 'y'
  724.                          || cm_dollar == 'y' || cm_paren == 'y')
  725.                         {if(ch == 'f' && size_mod == 'L')
  726.                              ret = sprintf(cm_in, spec,
  727.                                            va_arg(ap, long double));
  728.                          else if(ch == 'f')
  729.                              ret = sprintf(cm_in, spec, va_arg(ap, double));
  730.                          else if(size_mod == 'l')
  731.                              ret = sprintf(cm_in, spec, va_arg(ap, long));
  732.                          else
  733.                              ret = sprintf(cm_in, spec, va_arg(ap, int));
  734.                          if(ret < 0)
  735.                              goto error;
  736.                          /* add the commas, etc. as needed */
  737.                          format_new_flags(cm_comma, cm_dollar, cm_paren,
  738.                                           cm_in, cm_out, space_flag);
  739.                          /* output the new string */
  740.                          ret = printf("%s", cm_out);
  741.                          if(ret < 0)
  742.                              goto error;
  743.                          else
  744.                              sent += ret;}
  745.                     else if(ch == 'c' || ch == 'd' || ch == 'i')
  746.                         {if(size_mod == 'l')
  747.                              ret = printf(spec, va_arg(ap, long));
  748.                          else
  749.                              ret = printf(spec, va_arg(ap, int));
  750.                          if(ret < 0)
  751.                              goto error;
  752.                          else
  753.                              sent += ret;}
  754.                     else if(ch == 'u' || ch == 'x' || ch == 'X')
  755.                         {if(size_mod == 'l')
  756.                              ret = printf(spec, va_arg(ap, long));
  757.                          else
  758.                              ret = printf(spec, va_arg(ap, int));
  759.                          if(ret < 0)
  760.                              goto error;
  761.                          else
  762.                              sent += ret;}
  763.                     else if(ch == 'f' || ch == 'e' || ch == 'E'
  764.                          || ch == 'g' || ch == 'G')
  765.                         {if(size_mod == 'L')
  766.                              ret = printf(spec, va_arg(ap, long double));
  767.                          else
  768.                              ret = printf(spec, va_arg(ap, double));
  769.                          if(ret < 0)
  770.                              goto error;
  771.                          else
  772.                              sent += ret;}
  773.                     else if(ch == '%')
  774.                         {ret = printf(spec);
  775.                          if(ret < 0)
  776.                              goto error;
  777.                          else
  778.                              sent += ret;}
  779.                     else
  780.                         goto error;
  781.  
  782.                     if(curr == end)
  783.                         goto done;
  784.                     else
  785.                         {bgn = curr + 1;
  786.                          goto cont1;}}}
  787.           goto error;
  788.           cont1: ;}}
  789.  
  790. error:
  791. done:
  792. va_end(ap);
  793. *((int *)(return_ptr[1])) = sent;
  794. return;
  795. }
  796.  
  797.  
  798.  
  799.  
  800. void _mc__fprintf(void *return_ptr[], int file, struct d1_meta *format, ...)
  801. {
  802. int sent = 0;
  803. unsigned char *bgn, *end, *curr,
  804.               save, ch, spec[100], size_mod, at_end, have_precision,
  805.               cm_comma, cm_dollar, cm_paren, cm_in[200], cm_out[300],
  806.               space_flag;
  807. int wrk1, ret, sub, min_width, precision, mall;
  808. void *save_ptr;
  809. struct d1_meta *d1;
  810. FILE *fptr;
  811. va_list ap;
  812.  
  813. va_start(ap, format);
  814.  
  815. if(format->occurs == 0)
  816.     goto done;
  817.  
  818. if((fptr = retrieve_file(file)) == NULL)
  819.     goto error;
  820.  
  821. curr = bgn = (unsigned char *)format->ptr;
  822. end = bgn + format->occurs - 1;
  823.  
  824. for(at_end = 'n';; ++curr)
  825.     {if(curr == end)
  826.          {at_end = 'y';
  827.           output_text:
  828.           save = *(curr + 1);
  829.           *(curr + 1) = 0;
  830.           ret = fprintf(fptr, "%s", bgn);
  831.           *(curr + 1) = save;
  832.           if(ret < 0)
  833.               goto error;
  834.           else
  835.               sent += ret;
  836.           if(at_end == 'y')
  837.               break;
  838.           bgn = curr + 1;
  839.           continue;}
  840.  
  841.      if(*curr == '%')  /* beginning of conversion specification */
  842.          {if(bgn < curr)
  843.               {--curr;
  844.                goto output_text;}
  845.           /* extract the conversion specification */
  846.           have_precision = cm_comma = cm_dollar =
  847.                                                 cm_paren = space_flag = 'n';
  848.           sub = min_width = precision = 0;
  849.           spec[sub++] = '%';
  850.           for(++curr; curr <= end && sub < sizeof(spec) - 25; ++curr)
  851.               {ch = *curr;
  852.  
  853.                /* check for ANSI C conversions that are invalid in MOAL C */
  854.                if(ch == 'p' || ch == 'n' || ch == 'o')
  855.                    goto error;
  856.  
  857.                /* check for space flag, info is used elsewhere */
  858.                if(ch == '+')
  859.                    space_flag = 0;
  860.                else if(ch == ' ' && space_flag == 'n')
  861.                    space_flag = 'y';
  862.  
  863.                /* the , $ and ( are new flags */
  864.                if(ch == ',')
  865.                    {cm_comma = 'y';
  866.                     continue;}
  867.                else if(ch == '$')
  868.                    {cm_dollar = 'y';
  869.                     continue;}
  870.                else if(ch == '(')
  871.                    {cm_paren = 'y';
  872.                     continue;}
  873.  
  874.                if(ch == '*')
  875.                    {min_width = va_arg(ap, int);
  876.                     sub += sprintf(&spec[sub], "%d", min_width);
  877.                     /* "A negative field width argument is taken as a - flag
  878.                         followed by a positive field width" : pg. 239 TSCL */
  879.                     if(min_width < 0)
  880.                         min_width *= -1;
  881.                     continue;}
  882.  
  883.                if(ch == '.')
  884.                    {if(*(curr + 1) == '*')
  885.                         {precision = va_arg(ap, int);
  886.                          /* "A negative precision argument is taken as if
  887.                              the precision were omitted" : pg. 239 TSCL */
  888.                          if(precision < 0)
  889.                              {++curr;
  890.                               continue;}
  891.                          have_precision = 'y';
  892.                          sub += sprintf(&spec[sub], ".%d", precision);
  893.                          ++curr;
  894.                          continue;}
  895.                     have_precision = 'y';}
  896.  
  897.                spec[sub++] = ch;
  898.  
  899.                if(isdigit(ch))
  900.                    {if(have_precision == 'n')
  901.                         {if(min_width == 0 && ch != '0')
  902.                              min_width = strtol(curr, NULL, 10);}
  903.                     else if(precision == 0)
  904.                         precision = strtol(curr, NULL, 10);}
  905.  
  906.                /* check for end of the conversion specification */
  907.                else if((isalpha(ch)
  908.                         && (ch == 'd' || ch == 's' || ch == 'c'
  909.                             || ch == 'e' || ch == 'E' || ch == 'f'
  910.                             || ch == 'g' || ch == 'G' || ch == 'i'
  911.                             || ch == 'u' || ch == 'x' || ch == 'X'))
  912.                     || ch == '%')
  913.                    {spec[sub] = 0;
  914.                     /* set the size modifier, if any */
  915.                     size_mod = *(curr - 1);
  916.                     /* check for enough room to process the new flags */
  917.                     if(ch == 'u')
  918.                         cm_paren = space_flag = 'n';
  919.                     if(cm_comma == 'y' || cm_dollar == 'y' || cm_paren == 'y')
  920.                         {if(ch == 'u' || ch == 'd' || ch == 'i')
  921.                              {wrk1 = max(max(precision, min_width),
  922.                                          (size_mod == 'l' ?
  923.                                           sizeof(long) : sizeof(int)) * 3);
  924.                               if(wrk1 > sizeof(cm_in) - 1)
  925.                                   cm_comma = cm_paren = cm_dollar = 'n';}
  926.                          else if(ch == 'f')
  927.                              {wrk1 = max(min_width,
  928.                                          (have_precision == 'y' ?
  929.                                           precision : 6)
  930.                                          + (size_mod == 'L' ?
  931.                                             sizeof(long double) :
  932.                                             sizeof(double)) * 3 + 5);
  933.                               if(wrk1 > sizeof(cm_in) - 1)
  934.                                   cm_comma = cm_paren = cm_dollar = 'n';}
  935.                          else
  936.                              cm_comma = cm_paren = cm_dollar = 'n';}
  937.                     /* process the type */
  938.                     if(ch == 's')
  939.                         {d1 = va_arg(ap, struct d1_meta *);
  940.                          if(d1->occurs)
  941.                              {make_safe(d1, mall, save_ptr, save, VA_END);
  942.                               ret = fprintf(fptr, spec, (char *)d1->ptr);
  943.                               undo_safe(d1, mall, save_ptr, save);}
  944.                          else
  945.                              ret = fprintf(fptr, spec, "");
  946.                          if(ret < 0)
  947.                                   goto error;
  948.                               else
  949.                                   sent += ret;}
  950.                     else if(cm_comma == 'y'
  951.                          || cm_dollar == 'y' || cm_paren == 'y')
  952.                         {if(ch == 'f' && size_mod == 'L')
  953.                              ret = sprintf(cm_in, spec,
  954.                                            va_arg(ap, long double));
  955.                          else if(ch == 'f')
  956.                              ret = sprintf(cm_in, spec, va_arg(ap, double));
  957.                          else if(size_mod == 'l')
  958.                              ret = sprintf(cm_in, spec, va_arg(ap, long));
  959.                          else
  960.                              ret = sprintf(cm_in, spec, va_arg(ap, int));
  961.                          if(ret < 0)
  962.                              goto error;
  963.                          /* add the commas, etc. as needed */
  964.                          format_new_flags(cm_comma, cm_dollar, cm_paren,
  965.                                           cm_in, cm_out, space_flag);
  966.                          /* output the new string */
  967.                          ret = fprintf(fptr, "%s", cm_out);
  968.                          if(ret < 0)
  969.                              goto error;
  970.                          else
  971.                              sent += ret;}
  972.                     else if(ch == 'c' || ch == 'd' || ch == 'i')
  973.                         {if(size_mod == 'l')
  974.                              ret = fprintf(fptr, spec, va_arg(ap, long));
  975.                          else
  976.                              ret = fprintf(fptr, spec, va_arg(ap, int));
  977.                          if(ret < 0)
  978.                              goto error;
  979.                          else
  980.                              sent += ret;}
  981.                     else if(ch == 'u' || ch == 'x' || ch == 'X')
  982.                         {if(size_mod == 'l')
  983.                              ret = fprintf(fptr, spec, va_arg(ap, long));
  984.                          else
  985.                              ret = fprintf(fptr, spec, va_arg(ap, int));
  986.                          if(ret < 0)
  987.                              goto error;
  988.                          else
  989.                              sent += ret;}
  990.                     else if(ch == 'f' || ch == 'e' || ch == 'E'
  991.                          || ch == 'g' || ch == 'G')
  992.                         {if(size_mod == 'L')
  993.                              ret = fprintf(fptr, spec,
  994.                                            va_arg(ap, long double));
  995.                          else
  996.                              ret = fprintf(fptr, spec, va_arg(ap, double));
  997.                          if(ret < 0)
  998.                              goto error;
  999.                          else
  1000.                              sent += ret;}
  1001.                     else if(ch == '%')
  1002.                         {ret = fprintf(fptr, spec);
  1003.                          if(ret < 0)
  1004.                              goto error;
  1005.                          else
  1006.                              sent += ret;}
  1007.                     else
  1008.                         goto error;
  1009.  
  1010.                     if(curr == end)
  1011.                         goto done;
  1012.                     else
  1013.                         {bgn = curr + 1;
  1014.                          goto cont1;}}}
  1015.           goto error;
  1016.           cont1: ;}}
  1017.  
  1018. error:
  1019. done:
  1020. va_end(ap);
  1021. *((int *)(return_ptr[1])) = sent;
  1022. return;
  1023. }
  1024.  
  1025.  
  1026.  
  1027.  
  1028. void _mc__sprintf(void *return_ptr[], struct d1_meta *out, int append,
  1029.                   struct d1_meta *format, ...)
  1030. {
  1031. int added = 0;
  1032. unsigned char *bgn, *end, *curr, *base,
  1033.               save, ch, spec[100], size_mod, at_end, have_precision,
  1034.               cm_comma, cm_dollar, cm_paren, cm_in[200], cm_out[300],
  1035.               space_flag;
  1036. unsigned cnt, spec_len, total;
  1037. moal_t new_min;
  1038. int wrk1, ret, sub, min_width, precision, out_is_var, mall;
  1039. void *save_ptr;
  1040. struct d1_meta *d1;
  1041. void *original_out_ptr;
  1042. va_list ap;
  1043.  
  1044. va_start(ap, format);
  1045.  
  1046. if(return_ptr[3] == NULL)
  1047.     out_is_var = TRUE;
  1048. else
  1049.     out_is_var = FALSE;
  1050.  
  1051. if(format->occurs == 0)
  1052.     goto done;
  1053.  
  1054. if(!append)
  1055.     out->occurs = 0;
  1056.  
  1057. if(out->limit1)
  1058.     original_out_ptr = out->ptr;
  1059. else
  1060.     original_out_ptr = NULL;
  1061.  
  1062. /*
  1063. * first determine an upper-bound for the size of the generated output
  1064. */
  1065.  
  1066. curr = bgn = (unsigned char *)format->ptr;
  1067. end = bgn + format->occurs - 1;
  1068.  
  1069. for(total = 0;; ++curr)
  1070.     {if(curr == end)
  1071.          {++total;
  1072.           break;}
  1073.  
  1074.      if(*curr == '%')  /* beginning of conversion specification */
  1075.          {/* examine the conversion specification */
  1076.           have_precision = 'n';
  1077.           min_width = precision = 0;
  1078.           spec_len = 1;
  1079.           for(++curr; curr <= end; ++curr)
  1080.               {ch = *curr;
  1081.  
  1082.                ++spec_len;
  1083.  
  1084.                /* check for ANSI C conversions that are invalid in MOAL C */
  1085.                if(ch == 'p' || ch == 'n' || ch == 'o')
  1086.                    goto error;
  1087.  
  1088.                if(ch == '*')
  1089.                    {min_width = va_arg(ap, int);
  1090.                     /* "A negative field width argument is taken as a - flag
  1091.                         followed by a positive field width" : pg. 239 TSCL */
  1092.                     if(min_width < 0)
  1093.                         min_width *= -1;
  1094.                     continue;}
  1095.  
  1096.                if(ch == '.')
  1097.                    {if(*(curr + 1) == '*')
  1098.                         {precision = va_arg(ap, int);
  1099.                          /* "A negative precision argument is taken as if
  1100.                              the precision were omitted" : pg. 239 TSCL */
  1101.                          if(precision < 0)
  1102.                              {++curr;
  1103.                               continue;}
  1104.                          have_precision = 'y';
  1105.                          ++curr;
  1106.                          continue;}
  1107.                     have_precision = 'y';}
  1108.  
  1109.                if(isdigit(ch))
  1110.                    {if(have_precision == 'n')
  1111.                         {if(min_width == 0 && ch != '0')
  1112.                              min_width = strtol(curr, NULL, 10);}
  1113.                     else if(precision == 0)
  1114.                         precision = strtol(curr, NULL, 10);}
  1115.  
  1116.                /* check for end of the conversion specification */
  1117.                else if((isalpha(ch)
  1118.                         && (ch == 'd' || ch == 's' || ch == 'c'
  1119.                             || ch == 'e' || ch == 'E' || ch == 'f'
  1120.                             || ch == 'g' || ch == 'G' || ch == 'i'
  1121.                             || ch == 'u' || ch == 'x' || ch == 'X'))
  1122.                     || ch == '%')
  1123.                    {/* set the size modifier, if any */
  1124.                     size_mod = *(curr - 1);
  1125.                     /* process the type */
  1126.                     if(ch == 's')
  1127.                         {d1 = va_arg(ap, struct d1_meta *);
  1128.                          cnt = max(min_width,
  1129.                                    have_precision == 'y' ?
  1130.                                                     precision : d1->occurs);}
  1131.                     else if(ch == 'c' || ch == 'd' || ch == 'i')
  1132.                         {if(size_mod == 'l')
  1133.                              va_arg(ap, long);
  1134.                          else
  1135.                              va_arg(ap, int);
  1136.                          if(ch == 'c')
  1137.                              cnt = 1;
  1138.                          else
  1139.                              /* allowing 4 generated characters/byte. this
  1140.                                 includes room for commas, dollar, parens */
  1141.                              cnt = max(max(precision, min_width),
  1142.                                        (size_mod == 'l' ?
  1143.                                         sizeof(long) : sizeof(int)) * 4);}
  1144.                     else if(ch == 'u' || ch == 'x' || ch == 'X')
  1145.                         {if(size_mod == 'l')
  1146.                              va_arg(ap, long);
  1147.                          else
  1148.                              va_arg(ap, int);
  1149.                          cnt = max(max(precision, min_width),
  1150.                                    (size_mod == 'l' ?
  1151.                                     sizeof(long) : sizeof(int)) * 4);}
  1152.                     else if(ch == 'f' || ch == 'e' || ch == 'E'
  1153.                          || ch == 'g' || ch == 'G')
  1154.                         {if(size_mod == 'L')
  1155.                              va_arg(ap, long double);
  1156.                          else
  1157.                              va_arg(ap, double);
  1158.                          cnt = max(min_width,
  1159.                                    (have_precision == 'y' ? precision : 6) +
  1160.                                    (size_mod == 'L' ?
  1161.                                     sizeof(long double) : sizeof(double)) * 4
  1162.                                    + 5);}
  1163.                     else if(ch == '%')
  1164.                         cnt = 1;
  1165.                     else
  1166.                         goto error;
  1167.  
  1168.                     /* if a specification is invalid, then the typical
  1169.                        C sprintf function returns the specification,
  1170.                        hence this worst-case lower bound of spec_len */
  1171.                     total += max(cnt, spec_len);
  1172.  
  1173.                     if(curr == end)
  1174.                         goto done_counting;
  1175.                     else
  1176.                         {bgn = curr + 1;
  1177.                          goto cont2;}}}
  1178.           goto error;
  1179.           cont2: ;}
  1180.      else
  1181.          ++total;}
  1182.  
  1183. done_counting:
  1184.  
  1185. /*
  1186. * grow the varspace as needed
  1187. */
  1188.  
  1189. new_min = total + out->occurs + ROOM_FOR_C_ADDED_NULL;
  1190.  
  1191. if(new_min > out->limit1)
  1192.     {if(!out_is_var || !resize_cspace(out, new_min))
  1193.          goto out_failure;}
  1194.  
  1195. /*
  1196. * do the sprintf operation
  1197. */
  1198.  
  1199. va_end(ap);
  1200. va_start(ap, format);
  1201.  
  1202. base = (unsigned char *)out->ptr + out->occurs;
  1203.  
  1204. curr = bgn = (unsigned char *)format->ptr;
  1205. end = bgn + format->occurs - 1;
  1206.  
  1207. for(at_end = 'n';; ++curr)
  1208.     {if(curr == end)
  1209.          {at_end = 'y';
  1210.           output_text:
  1211.           save = *(curr + 1);
  1212.           *(curr + 1) = 0;
  1213.           ret = sprintf(&base[added], "%s", bgn);
  1214.           *(curr + 1) = save;
  1215.           if(ret < 0)
  1216.               goto error;
  1217.           else
  1218.               added += ret;
  1219.           if(at_end == 'y')
  1220.               break;
  1221.           bgn = curr + 1;
  1222.           continue;}
  1223.  
  1224.      if(*curr == '%')  /* beginning of conversion specification */
  1225.          {if(bgn < curr)
  1226.               {--curr;
  1227.                goto output_text;}
  1228.           /* extract the conversion specification */
  1229.           have_precision = cm_comma = cm_dollar =
  1230.                                                 cm_paren = space_flag = 'n';
  1231.           sub = min_width = precision = 0;
  1232.           spec[sub++] = '%';
  1233.           for(++curr; curr <= end && sub < sizeof(spec) - 25; ++curr)
  1234.               {ch = *curr;
  1235.  
  1236.                /* check for ANSI C conversions that are invalid in MOAL C */
  1237.                if(ch == 'p' || ch == 'n' || ch == 'o')
  1238.                    goto error;
  1239.  
  1240.                /* check for space flag, info is used elsewhere */
  1241.                if(ch == '+')
  1242.                    space_flag = 0;
  1243.                else if(ch == ' ' && space_flag == 'n')
  1244.                    space_flag = 'y';
  1245.  
  1246.                /* the , $ and ( are new flags */
  1247.                if(ch == ',')
  1248.                    {cm_comma = 'y';
  1249.                     continue;}
  1250.                else if(ch == '$')
  1251.                    {cm_dollar = 'y';
  1252.                     continue;}
  1253.                else if(ch == '(')
  1254.                    {cm_paren = 'y';
  1255.                     continue;}
  1256.  
  1257.                if(ch == '*')
  1258.                    {min_width = va_arg(ap, int);
  1259.                     sub += sprintf(&spec[sub], "%d", min_width);
  1260.                     /* "A negative field width argument is taken as a - flag
  1261.                         followed by a positive field width" : pg. 239 TSCL */
  1262.                     if(min_width < 0)
  1263.                         min_width *= -1;
  1264.                     continue;}
  1265.  
  1266.                if(ch == '.')
  1267.                    {if(*(curr + 1) == '*')
  1268.                         {precision = va_arg(ap, int);
  1269.                          /* "A negative precision argument is taken as if
  1270.                              the precision were omitted" : pg. 239 TSCL */
  1271.                          if(precision < 0)
  1272.                              {++curr;
  1273.                               continue;}
  1274.                          have_precision = 'y';
  1275.                          sub += sprintf(&spec[sub], ".%d", precision);
  1276.                          ++curr;
  1277.                          continue;}
  1278.                     have_precision = 'y';}
  1279.  
  1280.                spec[sub++] = ch;
  1281.  
  1282.                if(isdigit(ch))
  1283.                    {if(have_precision == 'n')
  1284.                         {if(min_width == 0 && ch != '0')
  1285.                              min_width = strtol(curr, NULL, 10);}
  1286.                     else if(precision == 0)
  1287.                         precision = strtol(curr, NULL, 10);}
  1288.  
  1289.                /* check for end of the conversion specification */
  1290.                else if((isalpha(ch)
  1291.                         && (ch == 'd' || ch == 's' || ch == 'c'
  1292.                             || ch == 'e' || ch == 'E' || ch == 'f'
  1293.                             || ch == 'g' || ch == 'G' || ch == 'i'
  1294.                             || ch == 'u' || ch == 'x' || ch == 'X'))
  1295.                     || ch == '%')
  1296.                    {spec[sub] = 0;
  1297.                     /* set the size modifier, if any */
  1298.                     size_mod = *(curr - 1);
  1299.                     /* check for enough room to process the new flags */
  1300.                     if(ch == 'u')
  1301.                         cm_paren = space_flag = 'n';
  1302.                     if(cm_comma == 'y' || cm_dollar == 'y' || cm_paren == 'y')
  1303.                         {if(ch == 'u' || ch == 'd' || ch == 'i')
  1304.                              {wrk1 = max(max(precision, min_width),
  1305.                                          (size_mod == 'l' ?
  1306.                                           sizeof(long) : sizeof(int)) * 3);
  1307.                               if(wrk1 > sizeof(cm_in) - 1)
  1308.                                   cm_comma = cm_paren = cm_dollar = 'n';}
  1309.                          else if(ch == 'f')
  1310.                              {wrk1 = max(min_width,
  1311.                                          (have_precision == 'y' ?
  1312.                                           precision : 6)
  1313.                                          + (size_mod == 'L' ?
  1314.                                             sizeof(long double) :
  1315.                                             sizeof(double)) * 3 + 5);
  1316.                               if(wrk1 > sizeof(cm_in) - 1)
  1317.                                   cm_comma = cm_paren = cm_dollar = 'n';}
  1318.                          else
  1319.                              cm_comma = cm_paren = cm_dollar = 'n';}
  1320.                     /* process the type */
  1321.                     if(ch == 's')
  1322.                         {d1 = va_arg(ap, struct d1_meta *);
  1323.                          if(d1->ptr == original_out_ptr && d1->limit1)
  1324.                              goto error;
  1325.                          if(d1->occurs)
  1326.                              {make_safe(d1, mall, save_ptr, save, VA_END);
  1327.                               ret = sprintf(&base[added],
  1328.                                             spec, (char *)d1->ptr);
  1329.                               undo_safe(d1, mall, save_ptr, save);}
  1330.                          else
  1331.                              ret = sprintf(&base[added], spec, "");
  1332.                          if(ret < 0)
  1333.                              goto error;
  1334.                          else
  1335.                              added += ret;}
  1336.                     else if(cm_comma == 'y'
  1337.                          || cm_dollar == 'y' || cm_paren == 'y')
  1338.                         {if(ch == 'f' && size_mod == 'L')
  1339.                              ret = sprintf(cm_in, spec,
  1340.                                            va_arg(ap, long double));
  1341.                          else if(ch == 'f')
  1342.                              ret = sprintf(cm_in, spec, va_arg(ap, double));
  1343.                          else if(size_mod == 'l')
  1344.                              ret = sprintf(cm_in, spec, va_arg(ap, long));
  1345.                          else
  1346.                              ret = sprintf(cm_in, spec, va_arg(ap, int));
  1347.                          if(ret < 0)
  1348.                              goto error;
  1349.                          /* add the commas, etc. as needed */
  1350.                          format_new_flags(cm_comma, cm_dollar, cm_paren,
  1351.                                           cm_in, cm_out, space_flag);
  1352.                          /* output the new string */
  1353.                          ret = sprintf(&base[added], "%s", cm_out);
  1354.                          if(ret < 0)
  1355.                              goto error;
  1356.                          else
  1357.                              added += ret;}
  1358.                     else if(ch == 'c' || ch == 'd' || ch == 'i')
  1359.                         {if(size_mod == 'l')
  1360.                              ret = sprintf(&base[added],
  1361.                                            spec, va_arg(ap, long));
  1362.                          else
  1363.                              ret = sprintf(&base[added],
  1364.                                            spec, va_arg(ap, int));
  1365.                          if(ret < 0)
  1366.                              goto error;
  1367.                          else
  1368.                              added += ret;}
  1369.                     else if(ch == 'u' || ch == 'x' || ch == 'X')
  1370.                         {if(size_mod == 'l')
  1371.                              ret = sprintf(&base[added],
  1372.                                            spec, va_arg(ap, long));
  1373.                          else
  1374.                              ret = sprintf(&base[added],
  1375.                                            spec, va_arg(ap, int));
  1376.                          if(ret < 0)
  1377.                              goto error;
  1378.                          else
  1379.                              added += ret;}
  1380.                     else if(ch == 'f' || ch == 'e' || ch == 'E'
  1381.                          || ch == 'g' || ch == 'G')
  1382.                         {if(size_mod == 'L')
  1383.                              ret = sprintf(&base[added],
  1384.                                            spec, va_arg(ap, long double));
  1385.                          else
  1386.                              ret = sprintf(&base[added],
  1387.                                            spec, va_arg(ap, double));
  1388.                          if(ret < 0)
  1389.                              goto error;
  1390.                          else
  1391.                              added += ret;}
  1392.                     else if(ch == '%')
  1393.                         {ret = sprintf(&base[added], spec);
  1394.                          if(ret < 0)
  1395.                              goto error;
  1396.                          else
  1397.                              added += ret;}
  1398.                     else
  1399.                         goto error;
  1400.  
  1401.                     if(curr == end)
  1402.                         goto done;
  1403.                     else
  1404.                         {bgn = curr + 1;
  1405.                          goto cont1;}}}
  1406.           goto error;
  1407.           cont1: ;}}
  1408.  
  1409. error:
  1410. done:
  1411. out->occurs += added;
  1412.  
  1413. va_end(ap);
  1414. *((int *)(return_ptr[1])) = added;
  1415. return;
  1416.  
  1417. out_failure:
  1418. va_end(ap);
  1419. if(out_is_var)
  1420.     *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  1421. else
  1422.     {/* subtracting 1 from new_min to represent it as a 0-relative subscript */
  1423.      *((moal_t *)(return_ptr[2])) = new_min - 1;
  1424.      *((moal_t *)(return_ptr[3])) = out->limit1;}
  1425. return;
  1426. }
  1427.  
  1428.  
  1429.  
  1430.  
  1431. void _mc__scanf(void *return_ptr[], struct d1_meta *format, ...)
  1432. {
  1433. int assignments = 0;
  1434. unsigned char *bgn, *end, *curr, *aa,
  1435.               save, ch, spec[1000], size_mod, suppress, scanset, num[30];
  1436. int wrk1, wrk2, ret, sub, max_width, n_total = 0, n, insert_max_width, len;
  1437. moal_t new_min;
  1438. struct d1_meta *d1;
  1439. void *arg_ptr;
  1440. va_list ap;
  1441.  
  1442. va_start(ap, format);
  1443.  
  1444. if(format->occurs == 0)
  1445.     goto done;
  1446.  
  1447. curr = bgn = (unsigned char *)format->ptr;
  1448. end = bgn + format->occurs - 1;
  1449.  
  1450. for(;; ++curr)
  1451.     {if(curr == end)
  1452.          {save = *(curr + 1);
  1453.           *(curr + 1) = 0;
  1454.           ret = scanf(bgn);
  1455.           *(curr + 1) = save;
  1456.           if(ret == EOF && assignments == 0)
  1457.               assignments = MC_EOF;
  1458.           break;}
  1459.  
  1460.      if(*curr == '%')  /* beginning of conversion specification */
  1461.          {/* extract up to and including the conversion specification */
  1462.           scanset = suppress = 'n';
  1463.           max_width = sub = 0;
  1464.           for(aa = bgn; aa <= curr; ++aa)
  1465.               spec[sub++] = *aa;
  1466.           if(*(curr + 1) == '*')
  1467.               suppress = 'y';
  1468.           else
  1469.               insert_max_width = sub;
  1470.           for(++curr; curr <= end && sub < sizeof(spec) - 20; ++curr)
  1471.               {ch = *curr;
  1472.  
  1473.                if(scanset == 'n')
  1474.                    {/* check for ANSI C conversions that are invalid
  1475.                        in MOAL C */
  1476.                     if(ch == 'p' || ch == 'o')
  1477.                         goto error;
  1478.  
  1479.                     if(isdigit(ch) && max_width == 0)
  1480.                         max_width = strtol(curr, NULL, 10);}
  1481.  
  1482.                spec[sub++] = ch;
  1483.  
  1484.                if(ch == '[' && scanset == 'n')
  1485.                    {scanset = 'y';
  1486.                     if(*(curr + 1) == ']')
  1487.                         {spec[sub++] = ']';
  1488.                          ++curr;}
  1489.                     else if(*(curr + 1) == '^'
  1490.                          && *(curr + 2) == ']')
  1491.                         {spec[sub++] = '^';
  1492.                          spec[sub++] = ']';
  1493.                          curr += 2;}
  1494.                     continue;}
  1495.  
  1496.                if(scanset == 'y' && ch != ']')
  1497.                    continue;
  1498.  
  1499.                /* check for end of the conversion specification */
  1500.                if((isalpha(ch)
  1501.                    && (ch == 'd' || ch == 's' || ch == 'c'
  1502.                        || ch == 'e' || ch == 'E' || ch == 'f'
  1503.                        || ch == 'g' || ch == 'G' || ch == 'i'
  1504.                        || ch == 'u' || ch == 'x' || ch == 'X'
  1505.                        || ch == 'n'))
  1506.                || ch == '%' || ch == ']')
  1507.                    {if(suppress == 'y' || ch == '%')
  1508.                         goto cont1;
  1509.                     if(ch != 'n')
  1510.                         {/* add %n */
  1511.                          spec[sub++] = '%';
  1512.                          spec[sub++] = 'n';}
  1513.                     spec[sub] = 0;
  1514.                     /* set the size modifier, if any */
  1515.                     size_mod = *(curr - 1);
  1516.                     /* get the target */
  1517.                     arg_ptr = va_arg(ap, void *);
  1518.                     /* process the type */
  1519.                     if(ch == 'c')
  1520.                         {d1 = (struct d1_meta *)arg_ptr;
  1521.                          d1->occurs = 0;
  1522.                          if(max_width == 0)
  1523.                              max_width = 1;
  1524.                          new_min = max_width;
  1525.                          if(new_min > d1->limit1)
  1526.                              {if(!resize_cspace(d1, new_min))
  1527.                                   goto memory_failure;}
  1528.                          n = 0;
  1529.                          ret = scanf(spec, d1->ptr, &n);
  1530.                          if(ret == EOF && assignments == 0)
  1531.                              assignments = MC_EOF;
  1532.                          if(ret == EOF || ret < 1)
  1533.                              goto done;
  1534.                          assignments += ret;
  1535.                          n_total += n;
  1536.                          d1->occurs = max_width;}
  1537.                     else if(ch == 's' || ch == ']')
  1538.                         {d1 = (struct d1_meta *)arg_ptr;
  1539.                          d1->occurs = 0;
  1540.                          if(max_width == 0)
  1541.                              {max_width = SCANF_MAXWIDTH;
  1542.                               new_min = max_width + ROOM_FOR_C_ADDED_NULL;
  1543.                               if(new_min > d1->limit1)
  1544.                                   {if(!resize_cspace(d1, new_min))
  1545.                                        goto memory_failure;}
  1546.                               /* insert the max width in the spec */
  1547.                               len = sprintf(num, "%u", max_width);
  1548.                               for(wrk1 = sub;
  1549.                                             wrk1 >= insert_max_width; --wrk1)
  1550.                                   spec[wrk1 + len] = spec[wrk1];
  1551.                               for(wrk1 = insert_max_width, wrk2 = 0;
  1552.                                                               len > 0; --len)
  1553.                                   spec[wrk1++] = num[wrk2++];}
  1554.                          else
  1555.                              {new_min = max_width + ROOM_FOR_C_ADDED_NULL;
  1556.                               if(new_min > d1->limit1)
  1557.                                   {if(!resize_cspace(d1, new_min))
  1558.                                        goto memory_failure;}}
  1559.                          n = 0;
  1560.                          ret = scanf(spec, d1->ptr, &n);
  1561.                          if(ret == EOF && assignments == 0)
  1562.                              assignments = MC_EOF;
  1563.                          if(ret == EOF || ret < 1)
  1564.                              goto done;
  1565.                          assignments += ret;
  1566.                          n_total += n;
  1567.                          d1->occurs = strlen((char *)d1->ptr);}
  1568.                     else if(ch == 'n')
  1569.                         {if(size_mod == 'l')
  1570.                              {/* erase the size mod from the spec */
  1571.                               spec[sub - 2] = spec[sub - 1];
  1572.                               spec[sub - 1] = 0;
  1573.                               --sub;}
  1574.                          if(sub > 2)
  1575.                              {n = 0;
  1576.                               ret = scanf(spec, &n);
  1577.                               if(ret == EOF && assignments == 0)
  1578.                                   assignments = MC_EOF;
  1579.                               if(ret == EOF || n == 0)
  1580.                                   goto done;
  1581.                               n_total += n;}
  1582.                          if(size_mod == 'l')
  1583.                              *((long *)arg_ptr) = n_total;
  1584.                          else
  1585.                              *((int *)arg_ptr) = n_total;}
  1586.                     else if(ch == 'd' || ch == 'i' || ch == 'u'
  1587.                          || ch == 'x' || ch == 'X')
  1588.                         {n = 0;
  1589.                          ret = scanf(spec, arg_ptr, &n);
  1590.                          if(ret == EOF && assignments == 0)
  1591.                              assignments = MC_EOF;
  1592.                          if(ret == EOF || ret < 1)
  1593.                              goto done;
  1594.                          assignments += ret;
  1595.                          n_total += n;}
  1596.                     else if(ch == 'e' || ch == 'f' || ch == 'g'
  1597.                          || ch == 'E' || ch == 'G')
  1598.                         {n = 0;
  1599.                          ret = scanf(spec, arg_ptr, &n);
  1600.                          if(ret == EOF && assignments == 0)
  1601.                              assignments = MC_EOF;
  1602.                          if(ret == EOF || ret < 1)
  1603.                              goto done;
  1604.                          assignments += ret;
  1605.                          n_total += n;}
  1606.                     else
  1607.                         goto error;
  1608.  
  1609.                     if(curr == end)
  1610.                         goto done;
  1611.                     else
  1612.                         {bgn = curr + 1;
  1613.                          goto cont1;}}}
  1614.           goto error;
  1615.           cont1: ;}}
  1616.  
  1617. error:
  1618. done:
  1619. va_end(ap);
  1620. *((int *)(return_ptr[1])) = assignments;
  1621. return;
  1622.  
  1623. memory_failure:
  1624. va_end(ap);
  1625. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  1626. return;
  1627. }
  1628.  
  1629.  
  1630.  
  1631.  
  1632. void _mc__fscanf(void *return_ptr[], int file, struct d1_meta *format, ...)
  1633. {
  1634. int assignments = 0;
  1635. unsigned char *bgn, *end, *curr, *aa,
  1636.               save, ch, spec[1000], size_mod, suppress, scanset, num[30];
  1637. int wrk1, wrk2, ret, sub, max_width, n_total = 0, n, insert_max_width, len;
  1638. moal_t new_min;
  1639. struct d1_meta *d1;
  1640. void *arg_ptr;
  1641. FILE *fptr;
  1642. va_list ap;
  1643.  
  1644. va_start(ap, format);
  1645.  
  1646. if(format->occurs == 0)
  1647.     goto done;
  1648.  
  1649. if((fptr = retrieve_file(file)) == NULL)
  1650.     goto error;
  1651.  
  1652. curr = bgn = (unsigned char *)format->ptr;
  1653. end = bgn + format->occurs - 1;
  1654.  
  1655. for(;; ++curr)
  1656.     {if(curr == end)
  1657.          {save = *(curr + 1);
  1658.           *(curr + 1) = 0;
  1659.           ret = fscanf(fptr, bgn);
  1660.           *(curr + 1) = save;
  1661.           if(ret == EOF && assignments == 0)
  1662.               assignments = MC_EOF;
  1663.           break;}
  1664.  
  1665.      if(*curr == '%')  /* beginning of conversion specification */
  1666.          {/* extract up to and including the conversion specification */
  1667.           scanset = suppress = 'n';
  1668.           max_width = sub = 0;
  1669.           for(aa = bgn; aa <= curr; ++aa)
  1670.               spec[sub++] = *aa;
  1671.           if(*(curr + 1) == '*')
  1672.               suppress = 'y';
  1673.           else
  1674.               insert_max_width = sub;
  1675.           for(++curr; curr <= end && sub < sizeof(spec) - 20; ++curr)
  1676.               {ch = *curr;
  1677.  
  1678.                if(scanset == 'n')
  1679.                    {/* check for ANSI C conversions that are invalid
  1680.                        in MOAL C */
  1681.                     if(ch == 'p' || ch == 'o')
  1682.                         goto error;
  1683.  
  1684.                     if(isdigit(ch) && max_width == 0)
  1685.                         max_width = strtol(curr, NULL, 10);}
  1686.  
  1687.                spec[sub++] = ch;
  1688.  
  1689.                if(ch == '[' && scanset == 'n')
  1690.                    {scanset = 'y';
  1691.                     if(*(curr + 1) == ']')
  1692.                         {spec[sub++] = ']';
  1693.                          ++curr;}
  1694.                     else if(*(curr + 1) == '^'
  1695.                          && *(curr + 2) == ']')
  1696.                         {spec[sub++] = '^';
  1697.                          spec[sub++] = ']';
  1698.                          curr += 2;}
  1699.                     continue;}
  1700.  
  1701.                if(scanset == 'y' && ch != ']')
  1702.                    continue;
  1703.  
  1704.                /* check for end of the conversion specification */
  1705.                if((isalpha(ch)
  1706.                    && (ch == 'd' || ch == 's' || ch == 'c'
  1707.                        || ch == 'e' || ch == 'E' || ch == 'f'
  1708.                        || ch == 'g' || ch == 'G' || ch == 'i'
  1709.                        || ch == 'u' || ch == 'x' || ch == 'X'
  1710.                        || ch == 'n'))
  1711.                || ch == '%' || ch == ']')
  1712.                    {if(suppress == 'y' || ch == '%')
  1713.                         goto cont1;
  1714.                     if(ch != 'n')
  1715.                         {/* add %n */
  1716.                          spec[sub++] = '%';
  1717.                          spec[sub++] = 'n';}
  1718.                     spec[sub] = 0;
  1719.                     /* set the size modifier, if any */
  1720.                     size_mod = *(curr - 1);
  1721.                     /* get the target */
  1722.                     arg_ptr = va_arg(ap, void *);
  1723.                     /* process the type */
  1724.                     if(ch == 'c')
  1725.                         {d1 = (struct d1_meta *)arg_ptr;
  1726.                          d1->occurs = 0;
  1727.                          if(max_width == 0)
  1728.                              max_width = 1;
  1729.                          new_min = max_width;
  1730.                          if(new_min > d1->limit1)
  1731.                              {if(!resize_cspace(d1, new_min))
  1732.                                   goto memory_failure;}
  1733.                          n = 0;
  1734.                          ret = fscanf(fptr, spec, d1->ptr, &n);
  1735.                          if(ret == EOF && assignments == 0)
  1736.                              assignments = MC_EOF;
  1737.                          if(ret == EOF || ret < 1)
  1738.                              goto done;
  1739.                          assignments += ret;
  1740.                          n_total += n;
  1741.                          d1->occurs = max_width;}
  1742.                     else if(ch == 's' || ch == ']')
  1743.                         {d1 = (struct d1_meta *)arg_ptr;
  1744.                          d1->occurs = 0;
  1745.                          if(max_width == 0)
  1746.                              {max_width = SCANF_MAXWIDTH;
  1747.                               new_min = max_width + ROOM_FOR_C_ADDED_NULL;
  1748.                               if(new_min > d1->limit1)
  1749.                                   {if(!resize_cspace(d1, new_min))
  1750.                                        goto memory_failure;}
  1751.                               /* insert the max width in the spec */
  1752.                               len = sprintf(num, "%u", max_width);
  1753.                               for(wrk1 = sub;
  1754.                                             wrk1 >= insert_max_width; --wrk1)
  1755.                                   spec[wrk1 + len] = spec[wrk1];
  1756.                               for(wrk1 = insert_max_width, wrk2 = 0;
  1757.                                                               len > 0; --len)
  1758.                                   spec[wrk1++] = num[wrk2++];}
  1759.                          else
  1760.                              {new_min = max_width + ROOM_FOR_C_ADDED_NULL;
  1761.                               if(new_min > d1->limit1)
  1762.                                   {if(!resize_cspace(d1, new_min))
  1763.                                        goto memory_failure;}}
  1764.                          n = 0;
  1765.                          ret = fscanf(fptr, spec, d1->ptr, &n);
  1766.                          if(ret == EOF && assignments == 0)
  1767.                              assignments = MC_EOF;
  1768.                          if(ret == EOF || ret < 1)
  1769.                              goto done;
  1770.                          assignments += ret;
  1771.                          n_total += n;
  1772.                          d1->occurs = strlen((char *)d1->ptr);}
  1773.                     else if(ch == 'n')
  1774.                         {if(size_mod == 'l')
  1775.                              {/* erase the size mod from the spec */
  1776.                               spec[sub - 2] = spec[sub - 1];
  1777.                               spec[sub - 1] = 0;
  1778.                               --sub;}
  1779.                          if(sub > 2)
  1780.                              {n = 0;
  1781.                               ret = fscanf(fptr, spec, &n);
  1782.                               if(ret == EOF && assignments == 0)
  1783.                                   assignments = MC_EOF;
  1784.                               if(ret == EOF || n == 0)
  1785.                                   goto done;
  1786.                               n_total += n;}
  1787.                          if(size_mod == 'l')
  1788.                              *((long *)arg_ptr) = n_total;
  1789.                          else
  1790.                              *((int *)arg_ptr) = n_total;}
  1791.                     else if(ch == 'd' || ch == 'i' || ch == 'u'
  1792.                          || ch == 'x' || ch == 'X')
  1793.                         {n = 0;
  1794.                          ret = fscanf(fptr, spec, arg_ptr, &n);
  1795.                          if(ret == EOF && assignments == 0)
  1796.                              assignments = MC_EOF;
  1797.                          if(ret == EOF || ret < 1)
  1798.                              goto done;
  1799.                          assignments += ret;
  1800.                          n_total += n;}
  1801.                     else if(ch == 'e' || ch == 'f' || ch == 'g'
  1802.                          || ch == 'E' || ch == 'G')
  1803.                         {n = 0;
  1804.                          ret = fscanf(fptr, spec, arg_ptr, &n);
  1805.                          if(ret == EOF && assignments == 0)
  1806.                              assignments = MC_EOF;
  1807.                          if(ret == EOF || ret < 1)
  1808.                              goto done;
  1809.                          assignments += ret;
  1810.                          n_total += n;}
  1811.                     else
  1812.                         goto error;
  1813.  
  1814.                     if(curr == end)
  1815.                         goto done;
  1816.                     else
  1817.                         {bgn = curr + 1;
  1818.                          goto cont1;}}}
  1819.           goto error;
  1820.           cont1: ;}}
  1821.  
  1822. error:
  1823. done:
  1824. va_end(ap);
  1825. *((int *)(return_ptr[1])) = assignments;
  1826. return;
  1827.  
  1828. memory_failure:
  1829. va_end(ap);
  1830. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  1831. return;
  1832. }
  1833.  
  1834.  
  1835.  
  1836.  
  1837. void _mc__sscanf(void *return_ptr[],
  1838.                  struct d1_meta *source, struct d1_meta *format, ...)
  1839. {
  1840. int assignments = 0;
  1841. unsigned char *bgn, *end, *curr, *aa, *src,
  1842.               save, ch, spec[1000], size_mod, suppress, scanset, num[30],
  1843.               save_src;
  1844. int wrk1, wrk2, ret, sub, max_width, n_total = 0, n, insert_max_width, len,
  1845.     undo = FALSE, mall;
  1846. void *save_ptr;
  1847. moal_t new_min;
  1848. struct d1_meta *d1;
  1849. void *arg_ptr;
  1850. va_list ap;
  1851.  
  1852. va_start(ap, format);
  1853.  
  1854. if(format->occurs == 0 || source->occurs == 0)
  1855.     goto done;
  1856.  
  1857. make_safe(source, mall, save_ptr, save_src, VA_END);
  1858. undo = TRUE;
  1859. src = (unsigned char *)source->ptr;
  1860.  
  1861. curr = bgn = (unsigned char *)format->ptr;
  1862. end = bgn + format->occurs - 1;
  1863.  
  1864. for(;; ++curr)
  1865.     {if(curr == end)
  1866.          {save = *(curr + 1);
  1867.           *(curr + 1) = 0;
  1868.           ret = sscanf(&src[n_total], bgn);
  1869.           *(curr + 1) = save;
  1870.           if(ret == EOF && assignments == 0)
  1871.               assignments = MC_EOF;
  1872.           break;}
  1873.  
  1874.      if(*curr == '%')  /* beginning of conversion specification */
  1875.          {/* extract up to and including the conversion specification */
  1876.           scanset = suppress = 'n';
  1877.           max_width = sub = 0;
  1878.           for(aa = bgn; aa <= curr; ++aa)
  1879.               spec[sub++] = *aa;
  1880.           if(*(curr + 1) == '*')
  1881.               suppress = 'y';
  1882.           else
  1883.               insert_max_width = sub;
  1884.           for(++curr; curr <= end && sub < sizeof(spec) - 20; ++curr)
  1885.               {ch = *curr;
  1886.  
  1887.                if(scanset == 'n')
  1888.                    {/* check for ANSI C conversions that are invalid
  1889.                        in MOAL C */
  1890.                     if(ch == 'p' || ch == 'o')
  1891.                         goto error;
  1892.  
  1893.                     if(isdigit(ch) && max_width == 0)
  1894.                         max_width = strtol(curr, NULL, 10);}
  1895.  
  1896.                spec[sub++] = ch;
  1897.  
  1898.                if(ch == '[' && scanset == 'n')
  1899.                    {scanset = 'y';
  1900.                     if(*(curr + 1) == ']')
  1901.                         {spec[sub++] = ']';
  1902.                          ++curr;}
  1903.                     else if(*(curr + 1) == '^'
  1904.                          && *(curr + 2) == ']')
  1905.                         {spec[sub++] = '^';
  1906.                          spec[sub++] = ']';
  1907.                          curr += 2;}
  1908.                     continue;}
  1909.  
  1910.                if(scanset == 'y' && ch != ']')
  1911.                    continue;
  1912.  
  1913.                /* check for end of the conversion specification */
  1914.                if((isalpha(ch)
  1915.                    && (ch == 'd' || ch == 's' || ch == 'c'
  1916.                        || ch == 'e' || ch == 'E' || ch == 'f'
  1917.                        || ch == 'g' || ch == 'G' || ch == 'i'
  1918.                        || ch == 'u' || ch == 'x' || ch == 'X'
  1919.                        || ch == 'n'))
  1920.                || ch == '%' || ch == ']')
  1921.                    {if(suppress == 'y' || ch == '%')
  1922.                         goto cont1;
  1923.                     if(ch != 'n')
  1924.                         {/* add %n */
  1925.                          spec[sub++] = '%';
  1926.                          spec[sub++] = 'n';}
  1927.                     spec[sub] = 0;
  1928.                     /* set the size modifier, if any */
  1929.                     size_mod = *(curr - 1);
  1930.                     /* get the target */
  1931.                     arg_ptr = va_arg(ap, void *);
  1932.                     /* process the type */
  1933.                     if(ch == 'c')
  1934.                         {d1 = (struct d1_meta *)arg_ptr;
  1935.                          if(d1->limit1 && d1->ptr == src)
  1936.                              goto error;
  1937.                          d1->occurs = 0;
  1938.                          if(max_width == 0)
  1939.                              max_width = 1;
  1940.                          new_min = max_width;
  1941.                          if(new_min > d1->limit1)
  1942.                              {if(!resize_cspace(d1, new_min))
  1943.                                   goto memory_failure;}
  1944.                          n = 0;
  1945.                          ret = sscanf(&src[n_total], spec, d1->ptr, &n);
  1946.                          if(ret == EOF && assignments == 0)
  1947.                              assignments = MC_EOF;
  1948.                          if(ret == EOF || ret < 1)
  1949.                              goto done;
  1950.                          assignments += ret;
  1951.                          n_total += n;
  1952.                          d1->occurs = max_width;}
  1953.                     else if(ch == 's' || ch == ']')
  1954.                         {d1 = (struct d1_meta *)arg_ptr;
  1955.                          if(d1->limit1 && d1->ptr == src)
  1956.                              goto error;
  1957.                          d1->occurs = 0;
  1958.                          if(max_width == 0)
  1959.                              {max_width = SCANF_MAXWIDTH;
  1960.                               new_min = max_width + ROOM_FOR_C_ADDED_NULL;
  1961.                               if(new_min > d1->limit1)
  1962.                                   {if(!resize_cspace(d1, new_min))
  1963.                                        goto memory_failure;}
  1964.                               /* insert the max width in the spec */
  1965.                               len = sprintf(num, "%u", max_width);
  1966.                               for(wrk1 = sub;
  1967.                                             wrk1 >= insert_max_width; --wrk1)
  1968.                                   spec[wrk1 + len] = spec[wrk1];
  1969.                               for(wrk1 = insert_max_width, wrk2 = 0;
  1970.                                                               len > 0; --len)
  1971.                                   spec[wrk1++] = num[wrk2++];}
  1972.                          else
  1973.                              {new_min = max_width + ROOM_FOR_C_ADDED_NULL;
  1974.                               if(new_min > d1->limit1)
  1975.                                   {if(!resize_cspace(d1, new_min))
  1976.                                        goto memory_failure;}}
  1977.                          n = 0;
  1978.                          ret = sscanf(&src[n_total], spec, d1->ptr, &n);
  1979.                          if(ret == EOF && assignments == 0)
  1980.                              assignments = MC_EOF;
  1981.                          if(ret == EOF || ret < 1)
  1982.                              goto done;
  1983.                          assignments += ret;
  1984.                          n_total += n;
  1985.                          d1->occurs = strlen((char *)d1->ptr);}
  1986.                     else if(ch == 'n')
  1987.                         {if(size_mod == 'l')
  1988.                              {/* erase the size mod from the spec */
  1989.                               spec[sub - 2] = spec[sub - 1];
  1990.                               spec[sub - 1] = 0;
  1991.                               --sub;}
  1992.                          if(sub > 2)
  1993.                              {n = 0;
  1994.                               ret = sscanf(&src[n_total], spec, &n);
  1995.                               if(ret == EOF && assignments == 0)
  1996.                                   assignments = MC_EOF;
  1997.                               if(ret == EOF || n == 0)
  1998.                                   goto done;
  1999.                               n_total += n;}
  2000.                          if(size_mod == 'l')
  2001.                              *((long *)arg_ptr) = n_total;
  2002.                          else
  2003.                              *((int *)arg_ptr) = n_total;}
  2004.                     else if(ch == 'd' || ch == 'i' || ch == 'u'
  2005.                          || ch == 'x' || ch == 'X')
  2006.                         {n = 0;
  2007.                          ret = sscanf(&src[n_total], spec, arg_ptr, &n);
  2008.                          if(ret == EOF && assignments == 0)
  2009.                              assignments = MC_EOF;
  2010.                          if(ret == EOF || ret < 1)
  2011.                              goto done;
  2012.                          assignments += ret;
  2013.                          n_total += n;}
  2014.                     else if(ch == 'e' || ch == 'f' || ch == 'g'
  2015.                          || ch == 'E' || ch == 'G')
  2016.                         {n = 0;
  2017.                          ret = sscanf(&src[n_total], spec, arg_ptr, &n);
  2018.                          if(ret == EOF && assignments == 0)
  2019.                              assignments = MC_EOF;
  2020.                          if(ret == EOF || ret < 1)
  2021.                              goto done;
  2022.                          assignments += ret;
  2023.                          n_total += n;}
  2024.                     else
  2025.                         goto error;
  2026.  
  2027.                     if(curr == end)
  2028.                         goto done;
  2029.                     else
  2030.                         {bgn = curr + 1;
  2031.                          goto cont1;}}}
  2032.           goto error;
  2033.           cont1: ;}}
  2034.  
  2035. error:
  2036. done:
  2037. va_end(ap);
  2038. if(undo)
  2039.     undo_safe(source, mall, save_ptr, save_src);
  2040. *((int *)(return_ptr[1])) = assignments;
  2041. return;
  2042.  
  2043. memory_failure:
  2044. va_end(ap);
  2045. if(undo)
  2046.     undo_safe(source, mall, save_ptr, save_src);
  2047. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  2048. return;
  2049. }
  2050.  
  2051.  
  2052.  
  2053.  
  2054. /*
  2055. * library functions for math
  2056. */
  2057.  
  2058. void _mc__abs(void *return_ptr[], int x)
  2059. {
  2060. *((int *)(return_ptr[1])) = abs(x);
  2061. return;
  2062. }
  2063.  
  2064.  
  2065.  
  2066.  
  2067. void _mc__acos(void *return_ptr[], double x)
  2068. {
  2069. double answer;
  2070. union {
  2071.     unsigned char cc[WORK_SIZE];
  2072.     double num;
  2073. } work;
  2074.  
  2075. if(dblerr(x))
  2076.     answer = nan.num;
  2077. else
  2078.     {errno = 0;
  2079.      answer = acos(x);
  2080.      if(errno == EDOM)
  2081.          answer = nan.num;}
  2082.  
  2083. *((double *)(return_ptr[1])) = answer;
  2084. return;
  2085. }
  2086.  
  2087.  
  2088.  
  2089.  
  2090. void _mc__asin(void *return_ptr[], double x)
  2091. {
  2092. double answer;
  2093. union {
  2094.     unsigned char cc[WORK_SIZE];
  2095.     double num;
  2096. } work;
  2097.  
  2098. if(dblerr(x))
  2099.     answer = nan.num;
  2100. else
  2101.     {errno = 0;
  2102.      answer = asin(x);
  2103.      if(errno == EDOM)
  2104.          answer = nan.num;}
  2105.  
  2106. *((double *)(return_ptr[1])) = answer;
  2107. return;
  2108. }
  2109.  
  2110.  
  2111.  
  2112.  
  2113. void _mc__atan(void *return_ptr[], double x)
  2114. {
  2115. #define PIHALF 1.5707963267948966
  2116. double answer;
  2117. int err;
  2118. union {
  2119.     unsigned char cc[WORK_SIZE];
  2120.     double num;
  2121. } work;
  2122.  
  2123. if(err = dblerr(x))
  2124.     {if(err == MC_NaN)
  2125.          answer = nan.num;
  2126.      else if(err == MC_pINF)
  2127.          answer = PIHALF;
  2128.      else
  2129.          answer = -PIHALF;}
  2130. else
  2131.     answer = atan(x);
  2132.  
  2133. *((double *)(return_ptr[1])) = answer;
  2134. return;
  2135. }
  2136.  
  2137.  
  2138.  
  2139.  
  2140. void _mc__atan2(void *return_ptr[], double y, double x)
  2141. {
  2142. #define PI 3.1415926535897931
  2143. double answer;
  2144. int err1, err2;
  2145. union {
  2146.     unsigned char cc[WORK_SIZE];
  2147.     double num;
  2148. } work;
  2149.  
  2150. err1 = dblerr(y);
  2151. err2 = dblerr(x);
  2152.  
  2153. if(err1 || err2)
  2154.     {if(err1 == MC_NaN || err2 == MC_NaN || (err1 && err2))
  2155.          answer = nan.num;
  2156.      /* have one infinity and one finite */
  2157.      if(err1 == MC_pINF)
  2158.          answer = PIHALF;
  2159.      else if(err1 == MC_nINF)
  2160.          answer = -PIHALF;
  2161.      else if(y >= 0.0)
  2162.          {if(err2 == MC_pINF)
  2163.               answer = 0.0;
  2164.           else
  2165.               answer = PI;}
  2166.      else
  2167.          {if(err2 == MC_pINF)
  2168.               answer = -0.0;
  2169.           else
  2170.               answer = -PI;}}
  2171. else if(x == 0.0 && y == 0.0)
  2172.     answer = nan.num;
  2173. else
  2174.     answer = atan2(y, x);
  2175.  
  2176. *((double *)(return_ptr[1])) = answer;
  2177. return;
  2178. }
  2179.  
  2180.  
  2181.  
  2182.  
  2183. void _mc__ceil(void *return_ptr[], double x)
  2184. {
  2185. double answer;
  2186. union {
  2187.     unsigned char cc[WORK_SIZE];
  2188.     double num;
  2189. } work;
  2190.  
  2191. if(dblerr(x))
  2192.     answer = x;
  2193. else
  2194.     answer = ceil(x);
  2195.  
  2196. *((double *)(return_ptr[1])) = answer;
  2197. return;
  2198. }
  2199.  
  2200.  
  2201.  
  2202.  
  2203. void _mc__cos(void *return_ptr[], double x)
  2204. {
  2205. double answer;
  2206. union {
  2207.     unsigned char cc[WORK_SIZE];
  2208.     double num;
  2209. } work;
  2210.  
  2211. if(dblerr(x))
  2212.     answer = nan.num;
  2213. else
  2214.     answer = cos(x);
  2215.  
  2216. *((double *)(return_ptr[1])) = answer;
  2217. return;
  2218. }
  2219.  
  2220.  
  2221.  
  2222.  
  2223. void _mc__div(void *return_ptr[], int x, int divide_by)
  2224. {
  2225. div_t ans;
  2226.  
  2227. ans = div(x, divide_by);
  2228.  
  2229. *((int *)(return_ptr[1])) = ans.quot;
  2230. *((int *)(return_ptr[2])) = ans.rem;
  2231. return;
  2232. }
  2233.  
  2234.  
  2235.  
  2236.  
  2237. void _mc__exp(void *return_ptr[], double x)
  2238. {
  2239. double answer;
  2240. int err;
  2241. union {
  2242.     unsigned char cc[WORK_SIZE];
  2243.     double num;
  2244. } work;
  2245.  
  2246. if(err = dblerr(x))
  2247.     {if(err == MC_nINF)
  2248.          answer = 0.0;
  2249.      else
  2250.          answer = x;}
  2251. else
  2252.     {errno = 0;
  2253.      answer = exp(x);
  2254.      if(errno == ERANGE && x > 0.0)
  2255.          answer = pos_inf.num;}
  2256.  
  2257. *((double *)(return_ptr[1])) = answer;
  2258. }
  2259.  
  2260.  
  2261.  
  2262.  
  2263. void _mc__fabs(void *return_ptr[], double x)
  2264. {
  2265. double answer;
  2266. int err;
  2267. union {
  2268.     unsigned char cc[WORK_SIZE];
  2269.     double num;
  2270. } work;
  2271.  
  2272. if(err = dblerr(x))
  2273.     {if(err == MC_NaN || err == MC_pINF)
  2274.          answer = x;
  2275.      else
  2276.          answer = pos_inf.num;}
  2277. else
  2278.     answer = fabs(x);
  2279.  
  2280. *((double *)(return_ptr[1])) = answer;
  2281. return;
  2282. }
  2283.  
  2284.  
  2285.  
  2286.  
  2287. void _mc__floor(void *return_ptr[], double x)
  2288. {
  2289. double answer;
  2290. union {
  2291.     unsigned char cc[WORK_SIZE];
  2292.     double num;
  2293. } work;
  2294.  
  2295. if(dblerr(x))
  2296.     answer = x;
  2297. else
  2298.     answer = floor(x);
  2299.  
  2300. *((double *)(return_ptr[1])) = answer;
  2301. return;
  2302. }
  2303.  
  2304.  
  2305.  
  2306.  
  2307. void _mc__fmod(void *return_ptr[], double x, double divide_by)
  2308. {
  2309. double answer;
  2310. int err1, err2;
  2311. union {
  2312.     unsigned char cc[WORK_SIZE];
  2313.     double num;
  2314. } work;
  2315.  
  2316. err1 = dblerr(x);
  2317. err2 = dblerr(divide_by);
  2318.  
  2319. if(err1 || err2)
  2320.     {if(err1 || err2 == MC_NaN)
  2321.          answer = nan.num;
  2322.      else  /* dividing a finite by infinity, so remainder is x */
  2323.          answer = x;}
  2324. else if(divide_by == 0.0)
  2325.     answer = nan.num;
  2326. else
  2327.     answer = fmod(x, divide_by);
  2328.  
  2329. *((double *)(return_ptr[1])) = answer;
  2330. return;
  2331. }
  2332.  
  2333.  
  2334.  
  2335.  
  2336. void _mc__labs(void *return_ptr[], long x)
  2337. {
  2338. *((long *)(return_ptr[1])) = labs(x);
  2339. return;
  2340. }
  2341.  
  2342.  
  2343.  
  2344.  
  2345. void _mc__ldiv(void *return_ptr[], long x, long divide_by)
  2346. {
  2347. ldiv_t ans;
  2348.  
  2349. ans = ldiv(x, divide_by);
  2350.  
  2351. *((long *)(return_ptr[1])) = ans.quot;
  2352. *((long *)(return_ptr[2])) = ans.rem;
  2353. return;
  2354. }
  2355.  
  2356.  
  2357.  
  2358.  
  2359. void _mc__log(void *return_ptr[], double x)
  2360. {
  2361. double answer;
  2362. int err;
  2363. union {
  2364.     unsigned char cc[WORK_SIZE];
  2365.     double num;
  2366. } work;
  2367.  
  2368. if(err = dblerr(x))
  2369.     {if(err == MC_NaN || err == MC_nINF)
  2370.          answer = nan.num;
  2371.      else
  2372.          answer = pos_inf.num;}
  2373. else if(x <= 0.0)
  2374.     {if(x == 0.0)
  2375.          answer = neg_inf.num;
  2376.      else
  2377.          answer = nan.num;}
  2378. else
  2379.     answer = log(x);
  2380.  
  2381. *((double *)(return_ptr[1])) = answer;
  2382. }
  2383.  
  2384.  
  2385.  
  2386.  
  2387. void _mc__log10(void *return_ptr[], double x)
  2388. {
  2389. double answer;
  2390. int err;
  2391. union {
  2392.     unsigned char cc[WORK_SIZE];
  2393.     double num;
  2394. } work;
  2395.  
  2396. if(err = dblerr(x))
  2397.     {if(err == MC_NaN || err == MC_nINF)
  2398.          answer = nan.num;
  2399.      else
  2400.          answer = pos_inf.num;}
  2401. else if(x <= 0.0)
  2402.     {if(x == 0.0)
  2403.          answer = neg_inf.num;
  2404.      else
  2405.          answer = nan.num;}
  2406. else
  2407.      answer = log10(x);
  2408.  
  2409. *((double *)(return_ptr[1])) = answer;
  2410. }
  2411.  
  2412.  
  2413.  
  2414.  
  2415. void _mc__merr(void *return_ptr[], double x)
  2416. {
  2417. union {
  2418.     unsigned char cc[WORK_SIZE];
  2419.     double num;
  2420. } work;
  2421.  
  2422. *((int *)(return_ptr[1])) = dblerr(x);
  2423. }
  2424.  
  2425.  
  2426.  
  2427.  
  2428. void _mc__pow(void *return_ptr[], double x, double power)
  2429. {
  2430. double answer;
  2431. int err1, err2;
  2432. union {
  2433.     unsigned char cc[WORK_SIZE];
  2434.     double num;
  2435. } work;
  2436.  
  2437. err1 = dblerr(x);
  2438. err2 = dblerr(power);
  2439.  
  2440. if(err1 || err2)
  2441.     {if(err1 == MC_NaN || err2 == MC_NaN)
  2442.          answer = nan.num;
  2443.      else if(!err2 && power == 0.0)
  2444.          answer = 1.0;
  2445.      else if(err1 != MC_nINF && (err1 == MC_pINF || x > 1.0))  /* x > 1 */
  2446.          {/* assuming that a finite root of an infinity is an infinity,
  2447.              for when -1 < power < 1 and power != 0 and x is +infinity */
  2448.           if(err2 == MC_nINF || (!err2 && power < 0.0)) /* power < 0 */
  2449.               answer = 0.0;
  2450.           else
  2451.               answer = pos_inf.num;}
  2452.      else if(err1 != MC_pINF && (err1 == MC_nINF || x < -1.0))  /* x < -1 */
  2453.          {/* assuming that a finite root of an infinity is an infinity,
  2454.              for when -1 < power < 0 and x is -infinity  */
  2455.           if(err2 == MC_nINF || (!err2 && power < 0.0)) /* power < 0 */
  2456.               answer = 0.0;
  2457.           else
  2458.               answer = nan.num;}  /* sign is indeterminate */
  2459.      else if(x == 0.0)
  2460.          {if(err2 == MC_pINF)
  2461.               answer = 0.0;
  2462.           else
  2463.               answer = nan.num;}  /* division by zero */
  2464.      else if(x == 1.0)
  2465.          answer = 1.0;
  2466.      else if(x == -1.0)
  2467.          answer = nan.num;  /* sign is indeterminate */
  2468.      else  /* either -1 < x < 0 or 0 < x < 1 */
  2469.          {if(err2 == MC_pINF)
  2470.               answer = 0.0;
  2471.           else
  2472.               answer = nan.num;}}  /* division by zero */
  2473. else
  2474.     {errno = 0;
  2475.      answer = pow(x, power);
  2476.      if(errno == EDOM || (x == 0.0 && power <= 0.0))
  2477.          answer = nan.num;
  2478.      else if(errno == ERANGE && answer != 0.0)
  2479.          {if(answer > 0.0)
  2480.               answer = pos_inf.num;
  2481.           else
  2482.               answer = neg_inf.num;}}
  2483.  
  2484. *((double *)(return_ptr[1])) = answer;
  2485. }
  2486.  
  2487.  
  2488.  
  2489.  
  2490. /*
  2491. * uses the standard linear congruential method
  2492. *
  2493. * the value 2147483648 is INT_MAX + 1
  2494. *
  2495. * the value 418473621 was chosen in accordance with these rules:
  2496. *       1) has one less digit than the divisor INT_MAX + 1
  2497. *       2) the number ends with x21 where x is an even digit
  2498. */
  2499. void _mc__rand(void *return_ptr[], int prev)
  2500. {
  2501. assert(INT_MAX == 2147483647);
  2502.  
  2503. *((int *)(return_ptr[1])) = ((unsigned)prev * 418473621 + 1) % 2147483648u;
  2504. return;
  2505. }
  2506.  
  2507.  
  2508.  
  2509.  
  2510. void _mc__sin(void *return_ptr[], double x)
  2511. {
  2512. double answer;
  2513. union {
  2514.     unsigned char cc[WORK_SIZE];
  2515.     double num;
  2516. } work;
  2517.  
  2518. if(dblerr(x))
  2519.     answer = nan.num;
  2520. else
  2521.     answer = sin(x);
  2522.  
  2523. *((double *)(return_ptr[1])) = answer;
  2524. return;
  2525. }
  2526.  
  2527.  
  2528.  
  2529.  
  2530. void _mc__sqrt(void *return_ptr[], double x)
  2531. {
  2532. double answer;
  2533. int err;
  2534. union {
  2535.     unsigned char cc[WORK_SIZE];
  2536.     double num;
  2537. } work;
  2538.  
  2539. if(err = dblerr(x))
  2540.     {if(err == MC_NaN || err == MC_nINF)
  2541.          answer = nan.num;
  2542.      else
  2543.          answer = pos_inf.num;}
  2544. else if(x < 0.0)
  2545.     answer = nan.num;
  2546. else
  2547.     answer = sqrt(x);
  2548.  
  2549. *((double *)(return_ptr[1])) = answer;
  2550. return;
  2551. }
  2552.  
  2553.  
  2554.  
  2555.  
  2556. void _mc__tan(void *return_ptr[], double x)
  2557. {
  2558. double answer;
  2559. union {
  2560.     unsigned char cc[WORK_SIZE];
  2561.     double num;
  2562. } work;
  2563.  
  2564. if(dblerr(x))
  2565.     answer = nan.num;
  2566. else
  2567.     answer = tan(x);
  2568.  
  2569. *((double *)(return_ptr[1])) = answer;
  2570. return;
  2571. }
  2572.  
  2573.  
  2574.  
  2575.  
  2576. /*
  2577. * library functions for time
  2578. */
  2579.  
  2580. void _mc__clock(void *return_ptr[])
  2581. {
  2582. *((ff_clock_t *)(return_ptr[1])) = clock();
  2583. return;
  2584. }
  2585.  
  2586.  
  2587.  
  2588.  
  2589. void _mc__ctime(void *return_ptr[], ff_time_t any_time)
  2590. {
  2591. char *ctm_ptr;
  2592. int len;
  2593. moal_t new_min;
  2594. time_t tt;
  2595.  
  2596. ((struct d1_meta *)(return_ptr[1]))->occurs = 0;
  2597.  
  2598. tt = any_time;
  2599. ctm_ptr = ctime(&tt);
  2600. if(ctm_ptr == NULL)
  2601.     return;
  2602.  
  2603. /* remove the trailing \n */
  2604. len = strlen(ctm_ptr);
  2605. if(len > 0)
  2606.     {ctm_ptr[len - 1] = 0;
  2607.      --len;}
  2608.  
  2609. new_min = len;
  2610. if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
  2611.     if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
  2612.         goto memory_failure;
  2613.  
  2614. strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, ctm_ptr, len);
  2615. ((struct d1_meta *)(return_ptr[1]))->occurs = len;
  2616.  
  2617. return;
  2618.  
  2619. memory_failure:
  2620. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  2621. return;
  2622. }
  2623.  
  2624.  
  2625.  
  2626.  
  2627. void _mc__difftime(void *return_ptr[],
  2628.                    ff_time_t any_time, ff_time_t subtract_time)
  2629. {
  2630. *((double *)(return_ptr[1])) = difftime((time_t)any_time,
  2631.                                         (time_t)subtract_time);
  2632. return;
  2633. }
  2634.  
  2635.  
  2636.  
  2637.  
  2638. void _mc__gmtime(void *return_ptr[], ff_time_t any_time)
  2639. {
  2640. struct ff_tm time_info = {0};
  2641. struct tm *tm_ptr;
  2642. time_t tt;
  2643.  
  2644. tt = any_time;
  2645. tm_ptr = gmtime(&tt);
  2646. if(tm_ptr == NULL)
  2647.     time_info.tm_sec = -1;
  2648. else
  2649.     tm_to_ff_tm(tm_ptr, &time_info);
  2650.  
  2651. *((struct ff_tm *)(return_ptr[1])) = time_info;
  2652. return;
  2653. }
  2654.  
  2655.  
  2656.  
  2657.  
  2658. void _mc__localtime(void *return_ptr[], ff_time_t any_time)
  2659. {
  2660. struct ff_tm time_info;
  2661. struct tm *tm_ptr;
  2662. time_t tt;
  2663.  
  2664. tt = any_time;
  2665. tm_ptr = localtime(&tt);
  2666. tm_to_ff_tm(tm_ptr, &time_info);
  2667.  
  2668. *((struct ff_tm *)(return_ptr[1])) = time_info;
  2669. return;
  2670. }
  2671.  
  2672.  
  2673.  
  2674.  
  2675. void _mc__mktime(void *return_ptr[], struct ff_tm *time_info)
  2676. {
  2677. struct tm tm_s;
  2678. time_t tt;
  2679.  
  2680. ff_tm_to_tm(time_info, &tm_s);
  2681.  
  2682. tt = mktime(&tm_s);
  2683.  
  2684. if(tt == (time_t)-1)
  2685.     *((ff_time_t *)(return_ptr[1])) = (ff_time_t)-1;
  2686. else
  2687.     *((ff_time_t *)(return_ptr[1])) = tt;
  2688. return;
  2689. }
  2690.  
  2691.  
  2692.  
  2693.  
  2694. void _mc__strftime(void *return_ptr[],
  2695.                    struct d1_meta *format, struct ff_tm *time_info)
  2696. {
  2697. struct tm tm_s;
  2698. int len, mall;
  2699. void *save_ptr;
  2700. moal_t new_min;
  2701. unsigned char save;
  2702.  
  2703. ((struct d1_meta *)(return_ptr[1]))->occurs = 0;
  2704.  
  2705. if(format->occurs == 0)
  2706.     return;
  2707.  
  2708. ff_tm_to_tm(time_info, &tm_s);
  2709.  
  2710. for(new_min = 100; new_min < 5000; new_min += 500)
  2711.     {if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
  2712.          if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
  2713.              goto memory_failure;
  2714.      make_safe(format, mall, save_ptr, save, NONE);
  2715.      len = strftime((char *)((struct d1_meta *)(return_ptr[1]))->ptr,
  2716.                     ((struct d1_meta *)(return_ptr[1]))->limit1,
  2717.                     (char *)format->ptr, &tm_s);
  2718.      undo_safe(format, mall, save_ptr, save);
  2719.      if(len > 0)
  2720.          break;}
  2721.  
  2722. ((struct d1_meta *)(return_ptr[1]))->occurs = len;
  2723. return;
  2724.  
  2725. memory_failure:
  2726. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  2727. return;
  2728. }
  2729.  
  2730.  
  2731.  
  2732.  
  2733. void _mc__time(void *return_ptr[])
  2734. {
  2735. *((ff_time_t *)(return_ptr[1])) = time(NULL);
  2736. return;
  2737. }
  2738.  
  2739.  
  2740.  
  2741.  
  2742. /*
  2743. * library functions for file I/O
  2744. */
  2745.  
  2746. void _mc__fclose(void *return_ptr[], int file)
  2747. {
  2748. int ret, error = 0;
  2749. FILE *fptr;
  2750.  
  2751. if((fptr = retrieve_file(file)) == NULL || file < FIRST_USER_FILE)
  2752.     {error = MC_INVALID_FILE_NUMBER;
  2753.      goto done;}
  2754.  
  2755. errno = 0;
  2756. ret = fclose(fptr);
  2757. if(ret)
  2758.     error = errno;
  2759. else
  2760.     remove_file(file);
  2761.  
  2762. done:
  2763. *((int *)(return_ptr[1])) = error;
  2764. return;
  2765. }
  2766.  
  2767.  
  2768.  
  2769.  
  2770. void _mc__fgetc(void *return_ptr[], int file)
  2771. {
  2772. int ret = 0, error = 0;
  2773. FILE *fptr;
  2774.  
  2775. if((fptr = retrieve_file(file)) == NULL)
  2776.     {error = MC_INVALID_FILE_NUMBER;
  2777.      goto done;}
  2778.  
  2779. errno = 0;
  2780. ret = fgetc(fptr);
  2781. if(ret == EOF)
  2782.     {if(feof(fptr))
  2783.          error = MC_EOF;
  2784.      else
  2785.          error = errno;
  2786.      ret = 0;}
  2787.  
  2788. done:
  2789. *((int *)(return_ptr[1])) = error;
  2790. *((char *)(return_ptr[2])) = ret;
  2791. return;
  2792. }
  2793.  
  2794.  
  2795.  
  2796.  
  2797. /*
  2798. * reads at most count characters (not n - 1) since not adding null at end
  2799. */
  2800. void _mc__fgets(void *return_ptr[], struct d1_meta *out, ff_size_t count,
  2801.                 int file)
  2802. {
  2803. int error = 0;
  2804. FILE *fptr;
  2805. int wrk1, out_is_var, cnt, ch;
  2806.  
  2807. out->occurs = 0;
  2808.  
  2809. if(return_ptr[3] == NULL)
  2810.     out_is_var = TRUE;
  2811. else
  2812.     out_is_var = FALSE;
  2813.  
  2814. if((fptr = retrieve_file(file)) == NULL)
  2815.     {error = MC_INVALID_FILE_NUMBER;
  2816.      goto done;}
  2817.  
  2818. for(errno = 0, cnt = ch = 0; cnt < count && (ch = getc(fptr)) != EOF;)
  2819.     {++cnt;
  2820.      if(cnt > out->limit1)
  2821.          {if(!out_is_var || !resize_cspace(out, cnt))
  2822.               goto out_failure;}
  2823.      *(((unsigned char *)(out->ptr)) + (cnt - 1)) = ch;
  2824.      if(ch == '\n')
  2825.          break;}
  2826.  
  2827. if(ch == EOF)
  2828.     {if(feof(fptr))
  2829.          {if(cnt == 0)
  2830.               error = MC_EOF;}
  2831.      else
  2832.          error = errno;}
  2833.  
  2834. if(!error)
  2835.     out->occurs = cnt;
  2836.  
  2837. done:
  2838. *((int *)(return_ptr[1])) = error;
  2839. return;
  2840.  
  2841. out_failure:
  2842. if(out_is_var)
  2843.     *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  2844. else
  2845.     {/* subtracting 1 from cnt to represent it as a 0-relative subscript */
  2846.      *((moal_t *)(return_ptr[2])) = cnt - 1;
  2847.      *((moal_t *)(return_ptr[3])) = out->limit1;}
  2848. return;
  2849. }
  2850.  
  2851.  
  2852.  
  2853.  
  2854. void _mc__fopen(void *return_ptr[], struct d1_meta *filename,
  2855.                 struct d1_meta *mode)
  2856. {
  2857. int error = 0, file = 0, mall_f, mall_m;
  2858. void *save_ptr_f, *save_ptr_m;
  2859. FILE *fptr;
  2860. unsigned char save_f, save_m;
  2861.  
  2862. if(filename->occurs == 0 || mode->occurs == 0)
  2863.     {error = MC_EMPTY_PARAMETER;
  2864.      goto done;}
  2865.  
  2866. make_safe(filename, mall_f, save_ptr_f, save_f, NONE);
  2867. make_safe(mode, mall_m, save_ptr_m, save_m, NONE);
  2868.  
  2869. errno = 0;
  2870. fptr = fopen((char *)filename->ptr, (char *)mode->ptr);
  2871. if(fptr == NULL)
  2872.     error = errno;
  2873. else
  2874.     {file = store_file(fptr);
  2875.      if(file == 0)
  2876.          error = MC_TOO_MANY_OPEN_FILES;}
  2877.  
  2878. undo_safe(filename, mall_f, save_ptr_f, save_f);
  2879. undo_safe(mode, mall_m, save_ptr_m, save_m);
  2880.  
  2881. done:
  2882. *((int *)(return_ptr[1])) = error;
  2883. *((int *)(return_ptr[2])) = file;
  2884. return;
  2885. }
  2886.  
  2887.  
  2888.  
  2889.  
  2890. void _mc__fputc(void *return_ptr[], char character, int file)
  2891. {
  2892. int ret, error = 0;
  2893. FILE *fptr;
  2894.  
  2895. if((fptr = retrieve_file(file)) == NULL)
  2896.     {error = MC_INVALID_FILE_NUMBER;
  2897.      goto done;}
  2898.  
  2899. errno = 0;
  2900. ret = fputc(character, fptr);
  2901. if(ret == EOF)
  2902.     error = errno;
  2903.  
  2904. done:
  2905. *((int *)(return_ptr[1])) = error;
  2906. return;
  2907. }
  2908.  
  2909.  
  2910.  
  2911.  
  2912. void _mc__fputs(void *return_ptr[], struct d1_meta *source, int file)
  2913. {
  2914. int error = 0;
  2915. size_t written;
  2916. FILE *fptr;
  2917.  
  2918. if((fptr = retrieve_file(file)) == NULL)
  2919.     {error = MC_INVALID_FILE_NUMBER;
  2920.      goto done;}
  2921.  
  2922. if(source->occurs == 0)
  2923.     goto done;
  2924.  
  2925. errno = 0;
  2926. written = fwrite((char *)source->ptr, 1, source->occurs, fptr);
  2927. if(written != source->occurs)
  2928.     error = errno;
  2929.  
  2930. done:
  2931. *((int *)(return_ptr[1])) = error;
  2932. return;
  2933. }
  2934.  
  2935.  
  2936.  
  2937.  
  2938. void _mc__fread(void *return_ptr[], struct d1_meta *out,
  2939.                 ff_size_t out_offset, ff_size_t read_count, int file)
  2940. {
  2941. int error = 0;
  2942. ff_size_t read = 0;
  2943. moal_t new_min;
  2944. FILE *fptr;
  2945. int out_is_var;
  2946.  
  2947. if(return_ptr[4] == NULL)
  2948.     out_is_var = TRUE;
  2949. else
  2950.     out_is_var = FALSE;
  2951.  
  2952. if(out_offset > out->occurs)
  2953.     {error = MC_OFFSET_INVALID;
  2954.      goto done;}
  2955. else
  2956.     out->occurs = out_offset;
  2957.  
  2958. if((fptr = retrieve_file(file)) == NULL)
  2959.     {error = MC_INVALID_FILE_NUMBER;
  2960.      goto done;}
  2961.  
  2962. if(read_count == 0)
  2963.     goto done;
  2964.  
  2965. if(sum_overflows(moal_t, out_offset, read_count))
  2966.     {error = MC_INCOMPATIBLE_PARAMS;
  2967.      goto done;}
  2968.  
  2969. new_min = out_offset + read_count;
  2970.  
  2971. if(new_min > out->limit1)
  2972.     {if(!out_is_var || !resize_cspace(out, new_min))
  2973.          goto out_failure;}
  2974.  
  2975. errno = 0;
  2976. read = fread((char *)out->ptr + out_offset, 1, read_count, fptr);
  2977. if(read != read_count)
  2978.     {if(feof(fptr))
  2979.          {if(read == 0)
  2980.               error = MC_EOF;}
  2981.      else if(ferror(fptr))
  2982.          {error = errno;
  2983.           read = 0;}}
  2984.  
  2985. if(!error)
  2986.     out->occurs = out_offset + read;
  2987.  
  2988. done:
  2989. *((int *)(return_ptr[1])) = error;
  2990. *((ff_size_t *)(return_ptr[2])) = read;
  2991. return;
  2992.  
  2993. out_failure:
  2994. if(out_is_var)
  2995.     *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  2996. else
  2997.     {/* subtracting 1 from new_min to represent it as a 0-relative subscript */
  2998.      *((moal_t *)(return_ptr[3])) = new_min - 1;
  2999.      *((moal_t *)(return_ptr[4])) = out->limit1;}
  3000. return;
  3001. }
  3002.  
  3003.  
  3004.  
  3005.  
  3006. void _mc__fseek(void *return_ptr[], int file, long offset, int from_where)
  3007. {
  3008. int error = 0;
  3009. int ret;
  3010. FILE *fptr;
  3011.  
  3012. if((fptr = retrieve_file(file)) == NULL)
  3013.     {error = MC_INVALID_FILE_NUMBER;
  3014.      goto done;}
  3015.  
  3016. if(from_where == 1)
  3017.     from_where = SEEK_CUR;
  3018. else if(from_where == 2)
  3019.     from_where = SEEK_END;
  3020. else if(from_where == 3)
  3021.     from_where = SEEK_SET;
  3022.  
  3023. errno = 0;
  3024. ret = fseek(fptr, offset, from_where);
  3025. if(ret)
  3026.     error = errno;
  3027.  
  3028. done:
  3029. *((int *)(return_ptr[1])) = error;
  3030. return;
  3031. }
  3032.  
  3033.  
  3034.  
  3035.  
  3036. void _mc__ftell(void *return_ptr[], int file)
  3037. {
  3038. int error = 0;
  3039. long current_position = 0;
  3040. FILE *fptr;
  3041.  
  3042. if((fptr = retrieve_file(file)) == NULL)
  3043.     {error = MC_INVALID_FILE_NUMBER;
  3044.      goto done;}
  3045.  
  3046. errno = 0;
  3047. current_position = ftell(fptr);
  3048. if(errno)
  3049.     {error = errno;
  3050.      current_position = 0;}
  3051.  
  3052. done:
  3053. *((int *)(return_ptr[1])) = error;
  3054. *((long *)(return_ptr[2])) = current_position;
  3055. return;
  3056. }
  3057.  
  3058.  
  3059.  
  3060.  
  3061. void _mc__fwrite(void *return_ptr[], struct d1_meta *source,
  3062.                  ff_size_t source_offset, ff_size_t write_count, int file)
  3063. {
  3064. int error = 0;
  3065. FILE *fptr;
  3066. size_t written;
  3067.  
  3068. if((fptr = retrieve_file(file)) == NULL)
  3069.     {error = MC_INVALID_FILE_NUMBER;
  3070.      goto done;}
  3071.  
  3072. if(source->occurs && source_offset >= source->occurs)
  3073.     {error = MC_OFFSET_INVALID;
  3074.      goto done;}
  3075.  
  3076. if(sum_overflows(moal_t, source_offset, write_count)
  3077. || source_offset + write_count > source->occurs)
  3078.     {error = MC_INCOMPATIBLE_PARAMS;
  3079.      goto done;}
  3080.  
  3081. if(write_count == 0)
  3082.     goto done;
  3083.  
  3084. errno = 0;
  3085. written = fwrite((char *)source->ptr + source_offset, 1, write_count, fptr);
  3086. if(written != write_count)
  3087.     error = errno;
  3088.  
  3089. done:
  3090. *((int *)(return_ptr[1])) = error;
  3091. return;
  3092. }
  3093.  
  3094.  
  3095.  
  3096.  
  3097. void _mc__remove(void *return_ptr[], struct d1_meta *filename)
  3098. {
  3099. int error = 0, ret, mall;
  3100. void *save_ptr;
  3101. unsigned char save;
  3102.  
  3103. if(filename->occurs == 0)
  3104.     {error = MC_EMPTY_PARAMETER;
  3105.      goto done;}
  3106.  
  3107. make_safe(filename, mall, save_ptr, save, NONE);
  3108. errno = 0;
  3109. ret = remove((char *)filename->ptr);
  3110. if(ret)
  3111.     error = errno;
  3112. undo_safe(filename, mall, save_ptr, save);
  3113.  
  3114. done:
  3115. *((int *)(return_ptr[1])) = error;
  3116. return;
  3117. }
  3118.  
  3119.  
  3120.  
  3121.  
  3122. void _mc__rename(void *return_ptr[], struct d1_meta *current_filename,
  3123.                  struct d1_meta *new_filename)
  3124. {
  3125. int error = 0, ret, mall_o, mall_n;
  3126. void *save_ptr_o, *save_ptr_n;
  3127. unsigned char save_o, save_n;
  3128.  
  3129. if(current_filename->occurs == 0 || new_filename->occurs == 0)
  3130.     {error = MC_EMPTY_PARAMETER;
  3131.      goto done;}
  3132.  
  3133. make_safe(current_filename, mall_o, save_ptr_o, save_o, NONE);
  3134. make_safe(new_filename, mall_n, save_ptr_n, save_n, NONE);
  3135. errno = 0;
  3136. ret = rename((char *)current_filename->ptr, (char *)new_filename->ptr);
  3137. if(ret)
  3138.     error = errno;
  3139. undo_safe(current_filename, mall_o, save_ptr_o, save_o);
  3140. undo_safe(new_filename, mall_n, save_ptr_n, save_n);
  3141.  
  3142. done:
  3143. *((int *)(return_ptr[1])) = error;
  3144. return;
  3145. }
  3146.  
  3147.  
  3148.  
  3149.  
  3150. void _mc__tmpfile(void *return_ptr[])
  3151. {
  3152. int error = 0, file = 0;
  3153. FILE *fptr;
  3154.  
  3155. errno = 0;
  3156. fptr = tmpfile();
  3157. if(fptr == NULL)
  3158.     error = errno;
  3159. else
  3160.     {file = store_file(fptr);
  3161.      if(file == 0)
  3162.          error = MC_TOO_MANY_OPEN_FILES;}
  3163.  
  3164. *((int *)(return_ptr[1])) = error;
  3165. *((int *)(return_ptr[2])) = file;
  3166. return;
  3167. }
  3168.  
  3169.  
  3170.  
  3171.  
  3172. void _mc__tmpnam(void *return_ptr[])
  3173. {
  3174. int len;
  3175. moal_t new_min;
  3176. char *cp;
  3177.  
  3178. ((struct d1_meta *)(return_ptr[1]))->occurs = 0;
  3179.  
  3180. cp = tmpnam(NULL);
  3181. if(cp == NULL)
  3182.     return;
  3183.  
  3184. len = strlen(cp);
  3185. new_min = len;
  3186. if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
  3187.     if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
  3188.         goto memory_failure;
  3189.  
  3190. strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, cp, len);
  3191. ((struct d1_meta *)(return_ptr[1]))->occurs = len;
  3192.  
  3193. return;
  3194.  
  3195. memory_failure:
  3196. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3197. return;
  3198. }
  3199.  
  3200.  
  3201.  
  3202.  
  3203. /*
  3204. * library functions for character
  3205. */
  3206.  
  3207. void _mc__toupper(void *return_ptr[], char character)
  3208. {
  3209. *((char *)(return_ptr[1])) = toupper(character);
  3210. }
  3211.  
  3212.  
  3213.  
  3214.  
  3215. void _mc__tolower(void *return_ptr[], char character)
  3216. {
  3217. *((char *)(return_ptr[1])) = tolower(character);
  3218. }
  3219.  
  3220.  
  3221.  
  3222.  
  3223. void _mc__isalnum(void *return_ptr[], char character)
  3224. {
  3225. *((int *)(return_ptr[1])) = isalnum(character);
  3226. }
  3227.  
  3228.  
  3229.  
  3230.  
  3231. void _mc__isalpha(void *return_ptr[], char character)
  3232. {
  3233. *((int *)(return_ptr[1])) = isalpha(character);
  3234. }
  3235.  
  3236.  
  3237.  
  3238.  
  3239. void _mc__isdigit(void *return_ptr[], char character)
  3240. {
  3241. *((int *)(return_ptr[1])) = isdigit(character);
  3242. }
  3243.  
  3244.  
  3245.  
  3246.  
  3247. void _mc__islower(void *return_ptr[], char character)
  3248. {
  3249. *((int *)(return_ptr[1])) = islower(character);
  3250. }
  3251.  
  3252.  
  3253.  
  3254.  
  3255. void _mc__isspace(void *return_ptr[], char character)
  3256. {
  3257. *((int *)(return_ptr[1])) = isspace(character);
  3258. }
  3259.  
  3260.  
  3261.  
  3262.  
  3263. void _mc__isupper(void *return_ptr[], char character)
  3264. {
  3265. *((int *)(return_ptr[1])) = isupper(character);
  3266. }
  3267.  
  3268.  
  3269. /*
  3270. * library functions for sort and search
  3271. *
  3272. * note: both qsort and bsearch assume that the compare function does not
  3273. *       raise an exception nor cause an exception: any exception coming
  3274. *       from the compare function is discarded
  3275. */
  3276.  
  3277. static void quicksort(int left, int right,
  3278.                       char *buf, int element_size,
  3279.                       char *base, void *ret[2],
  3280.                       void (*compare) (void *[], void *, void *));
  3281.  
  3282. /*
  3283. * quicksort algorithm
  3284. */
  3285. void _mc__qsort(void *return_ptr[], struct d1_meta *base,
  3286.                 ff_size_t element_size,
  3287.                 void (*compare) (void *[], void *, void *))
  3288. {
  3289. int exception;
  3290. char *buf;
  3291. void *ret[2];
  3292.  
  3293. if(base->occurs < 2)
  3294.     return;
  3295.  
  3296. buf = (char *)malloc(element_size);
  3297. if(buf == NULL)
  3298.     {*((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3299.      return;}
  3300.  
  3301. ret[0] = &exception;
  3302.  
  3303. quicksort(0, base->occurs - 1,
  3304.           buf, element_size,
  3305.           (char *)(base->ptr), ret, compare);
  3306.  
  3307. free(buf);
  3308.  
  3309. return;
  3310. }
  3311.  
  3312.  
  3313.  
  3314.  
  3315. static void quicksort(int left, int right,
  3316.                       char *buf, int element_size,
  3317.                       char *base, void *ret[2],
  3318.                       void (*compare) (void *[], void *, void *))
  3319. {
  3320. char *pivot;
  3321. int i, j, k;
  3322. int answer;
  3323.  
  3324. #define swap(i, j) \
  3325. {memcpy(buf, base + (j * element_size), element_size); \
  3326.  memcpy(base + (j * element_size), base + (i * element_size), element_size); \
  3327.  memcpy(base + (i * element_size), buf, element_size);}
  3328.  
  3329. if(right > left)
  3330.     {ret[1] = &answer;
  3331.      /* median of three */
  3332.      k = left;
  3333.      if(right - left > 1)
  3334.          {k += (right - left) / 2;
  3335.           /* sort left, k, right */
  3336.           (*compare)(ret, (void *)(base + (left * element_size)),
  3337.                      (void *)(base + (k * element_size)));
  3338.           if(answer > 0)
  3339.               swap(left, k)
  3340.           (*compare)(ret, (void *)(base + (left * element_size)),
  3341.                      (void *)(base + (right * element_size)));
  3342.           if(answer > 0)
  3343.               swap(left, right)
  3344.           (*compare)(ret, (void *)(base + (k * element_size)),
  3345.                      (void *)(base + (right * element_size)));
  3346.           if(answer > 0)
  3347.               swap(k, right)
  3348.           i = left + 1;
  3349.           j = right - 1;}
  3350.      else
  3351.          {i = left;
  3352.           j = right;}
  3353.  
  3354.      pivot = base + (element_size * k);
  3355.      for(;;)
  3356.          {for(; i < k; ++i)
  3357.               {(*compare)(ret, (void *)(base + (i * element_size)),
  3358.                           (void *)pivot);
  3359.                if(answer <= 0)
  3360.                    continue;
  3361.                else
  3362.                    break;}
  3363.           for(; j > k; --j)
  3364.               {(*compare)(ret, (void *)(base + (j * element_size)),
  3365.                           (void *)pivot);
  3366.                if(answer >= 0)
  3367.                    continue;
  3368.                else
  3369.                    break;}
  3370.           if(i == k && j == k)
  3371.               break;
  3372.  
  3373.           swap(i, j)
  3374.  
  3375.           /* check for a changed pivot value */
  3376.           if(i == k)
  3377.               i = left;
  3378.           else if(j == k)
  3379.               j = right;}
  3380.  
  3381.      /* recursive calls */
  3382.      quicksort(left, k - 1,
  3383.                buf, element_size,
  3384.                base, ret, compare);
  3385.      quicksort(k + 1, right,
  3386.                buf, element_size,
  3387.                base, ret, compare);}
  3388.  
  3389. return;
  3390. }
  3391.  
  3392.  
  3393.  
  3394.  
  3395. void _mc__bsearch(void *return_ptr[], void *key, struct d1_meta *base,
  3396.                   ff_size_t element_size,
  3397.                   void (*compare) (void *[], void *, void *))
  3398. {
  3399. int error = MC_NOT_FOUND;
  3400. ff_size_t subscript = 0;
  3401. void *ret[2];
  3402. int wrk1, answer, left, right, exception;
  3403.  
  3404. if(base->occurs < 1)
  3405.     goto done;
  3406.  
  3407. /*
  3408. * do a binary search
  3409. */
  3410. ret[0] = &exception;
  3411. ret[1] = &answer;
  3412.  
  3413. for(left = 0, right = base->occurs - 1; right >= left;)
  3414.     {wrk1 = (left + right) / 2;
  3415.      (*compare)(ret, (void *)key,
  3416.                 (void *)((char *)(base->ptr) + (wrk1 * element_size)));
  3417.      if(answer == 0)
  3418.          {error = 0;
  3419.           subscript = wrk1;
  3420.           goto done;}
  3421.      if(answer < 0)
  3422.          right = wrk1 - 1;
  3423.      else
  3424.          left = wrk1 + 1;}
  3425.  
  3426. done:
  3427. *((int *)(return_ptr[1])) = error;
  3428. *((ff_size_t *)(return_ptr[2])) = subscript;
  3429. return;
  3430. }
  3431.  
  3432.  
  3433.  
  3434.  
  3435. /*
  3436. * library functions for communication with the environment
  3437. */
  3438.  
  3439. void _mc__getenv(void *return_ptr[], struct d1_meta *name)
  3440. {
  3441. int len, mall;
  3442. void *save_ptr;
  3443. moal_t new_min;
  3444. unsigned char save;
  3445. char *cp;
  3446.  
  3447. ((struct d1_meta *)(return_ptr[1]))->occurs = 0;
  3448.  
  3449. if(name->occurs == 0)
  3450.     return;
  3451.  
  3452. make_safe(name, mall, save_ptr, save, NONE);
  3453. cp = getenv((char *)name->ptr);
  3454. undo_safe(name, mall, save_ptr, save);
  3455.  
  3456. if(cp == NULL)
  3457.     return;
  3458.  
  3459. len = strlen(cp);
  3460. new_min = len;
  3461. if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
  3462.     if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
  3463.         goto memory_failure;
  3464.  
  3465. strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, cp, len);
  3466. ((struct d1_meta *)(return_ptr[1]))->occurs = len;
  3467.  
  3468. return;
  3469.  
  3470. memory_failure:
  3471. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3472. return;
  3473. }
  3474.  
  3475.  
  3476.  
  3477.  
  3478. void _mc__exit(void *return_ptr[], int status)
  3479. {
  3480. exit(status);
  3481. }
  3482.  
  3483.  
  3484.  
  3485.  
  3486. void _mc__system(void *return_ptr[], struct d1_meta *command)
  3487. {
  3488. int status, mall;
  3489. void *save_ptr;
  3490. unsigned char save;
  3491.  
  3492. if(command->occurs == 0)
  3493.     status = system(NULL);
  3494. else
  3495.     {make_safe(command, mall, save_ptr, save, NONE);
  3496.      status = system((char *)command->ptr);
  3497.      undo_safe(command, mall, save_ptr, save);}
  3498.  
  3499. done:
  3500. *((int *)(return_ptr[1])) = status;
  3501. return;
  3502. }
  3503.  
  3504.  
  3505.  
  3506.  
  3507. /*
  3508. * string functions
  3509. */
  3510.  
  3511. /*
  3512. * note: strcat(x, x) works correctly (x.occurs is doubled)
  3513. */
  3514. void _mc__strcat(void *return_ptr[],
  3515.                  struct d1_meta *out, struct d1_meta *source)
  3516. {
  3517. int out_is_var;
  3518. moal_t new_min;
  3519.  
  3520. if(source->occurs == 0)
  3521.     goto done;
  3522.  
  3523. if(sum_overflows(moal_t, out->occurs, source->occurs))
  3524.     goto done;
  3525.  
  3526. if(return_ptr[2] == NULL)
  3527.     out_is_var = TRUE;
  3528. else
  3529.     out_is_var = FALSE;
  3530.  
  3531. new_min = out->occurs + source->occurs;
  3532. if(new_min > out->limit1)
  3533.     {if(!out_is_var || !resize_cspace(out, new_min))
  3534.          goto out_failure;}
  3535.  
  3536. memcpy((char *)out->ptr + out->occurs, (char *)source->ptr, source->occurs);
  3537.  
  3538. out->occurs += source->occurs;
  3539.  
  3540. done:
  3541. return;
  3542.  
  3543. out_failure:
  3544. if(out_is_var)
  3545.     *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3546. else
  3547.     {/* subtracting 1 from new_min to represent it as a 0-relative subscript */
  3548.      *((moal_t *)(return_ptr[1])) = new_min - 1;
  3549.      *((moal_t *)(return_ptr[2])) = out->limit1;}
  3550. return;
  3551. }
  3552.  
  3553.  
  3554.  
  3555.  
  3556. void _mc__strcmp(void *return_ptr[],
  3557.                  struct d1_meta *s1, struct d1_meta *s2)
  3558. {
  3559. int result = 0;
  3560. moal_t wrk1, occurs1, occurs2;
  3561. unsigned char *c1, *c2;
  3562.  
  3563. c1 = (unsigned char *)s1->ptr;
  3564. c2 = (unsigned char *)s2->ptr;
  3565.  
  3566. occurs1 = s1->occurs;
  3567. occurs2 = s2->occurs;
  3568.  
  3569. for(wrk1 = 0;; ++wrk1)
  3570.     {if(wrk1 < occurs1 && wrk1 < occurs2)
  3571.          {if(c1[wrk1] != c2[wrk1])
  3572.               {if(c1[wrk1] < c2[wrk1])
  3573.                    result = -1;
  3574.                else
  3575.                    result = 1;
  3576.                break;}}
  3577.      else if(wrk1 >= occurs1 && wrk1 >= occurs2)
  3578.          break;
  3579.      else if(wrk1 >= occurs1)
  3580.          {result = -1;
  3581.           break;}
  3582.      else
  3583.          {result = 1;
  3584.           break;}}
  3585.  
  3586. *((int *)(return_ptr[1])) = result;
  3587. return;
  3588. }
  3589.  
  3590.  
  3591.  
  3592.  
  3593. void _mc__strcpy(void *return_ptr[],
  3594.                  struct d1_meta *out, struct d1_meta *source)
  3595. {
  3596. int out_is_var;
  3597. moal_t new_min;
  3598.  
  3599. if(out->ptr == source->ptr && out->limit1 && source->limit1)
  3600.     goto done;
  3601. else
  3602.     out->occurs = 0;
  3603.  
  3604. if(source->occurs == 0)
  3605.     goto done;
  3606.  
  3607. if(return_ptr[2] == NULL)
  3608.     out_is_var = TRUE;
  3609. else
  3610.     out_is_var = FALSE;
  3611.  
  3612. new_min = source->occurs;
  3613. if(new_min > out->limit1)
  3614.     {if(!out_is_var || !resize_cspace(out, new_min))
  3615.          goto out_failure;}
  3616.  
  3617. memcpy((char *)out->ptr, (char *)source->ptr, source->occurs);
  3618.  
  3619. out->occurs = source->occurs;
  3620.  
  3621. done:
  3622. return;
  3623.  
  3624. out_failure:
  3625. if(out_is_var)
  3626.     *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3627. else
  3628.     {/* subtracting 1 from new_min to represent it as a 0-relative subscript */
  3629.      *((moal_t *)(return_ptr[1])) = new_min - 1;
  3630.      *((moal_t *)(return_ptr[2])) = out->limit1;}
  3631. return;
  3632. }
  3633.  
  3634.  
  3635.  
  3636.  
  3637. void _mc__strerror(void *return_ptr[], int error)
  3638. {
  3639. int len;
  3640. moal_t new_min;
  3641. char *cp, buf[1000];
  3642.  
  3643. ((struct d1_meta *)(return_ptr[1]))->occurs = 0;
  3644.  
  3645. if(error == MC_EOF
  3646. || error == MC_NOT_FOUND
  3647. || error == MC_EMPTY_PARAMETER
  3648. || error == MC_OFFSET_INVALID
  3649. || error == MC_NaN
  3650. || error == MC_pINF
  3651. || error == MC_nINF
  3652. || error == MC_INCOMPATIBLE_PARAMS
  3653. || error == MC_INVALID_FILE_NUMBER
  3654. || error == MC_TOO_MANY_OPEN_FILES
  3655. || error == MC_REX_MALFORMED
  3656. || error == MC_REX_MATCHES_NOTHING)
  3657.    {cp = buf;
  3658.     if(error == MC_EOF)
  3659.         strcpy(buf, "At end of file");
  3660.     else if(error == MC_NOT_FOUND)
  3661.         strcpy(buf, "Not found");
  3662.     else if(error == MC_EMPTY_PARAMETER)
  3663.         strcpy(buf, "A parameter is empty (occurs is zero)");
  3664.     else if(error == MC_OFFSET_INVALID)
  3665.         strcpy(buf, "An 'offset' parameter is invalid");
  3666.     else if(error == MC_NaN)
  3667.         strcpy(buf, "Not a number");
  3668.     else if(error == MC_pINF)
  3669.         strcpy(buf, "Positive infinity");
  3670.     else if(error == MC_nINF)
  3671.         strcpy(buf, "Negative infinity");
  3672.     else if(error == MC_INCOMPATIBLE_PARAMS)
  3673.         strcpy(buf, "Parameter values are incompatible");
  3674.     else if(error == MC_INVALID_FILE_NUMBER)
  3675.         strcpy(buf, "File number is invalid");
  3676.     else if(error == MC_TOO_MANY_OPEN_FILES)
  3677.         strcpy(buf, "Too many open files");
  3678.     else if(error == MC_REX_MALFORMED)
  3679.         strcpy(buf, "Expression is malformed");
  3680.     else if(error == MC_REX_MATCHES_NOTHING)
  3681.         strcpy(buf, "Expression can match nothing");
  3682.     else if(error == MC_MACHINE_EMPTY)
  3683.         strcpy(buf, "Machine is empty");}
  3684. else
  3685.     {cp = strerror(error);
  3686.      if(cp == NULL)
  3687.          return;}
  3688.  
  3689. len = strlen(cp);
  3690. new_min = len;
  3691. if(((struct d1_meta *)(return_ptr[1]))->limit1 < new_min)
  3692.     if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
  3693.         goto memory_failure;
  3694.  
  3695. strncpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr, cp, len);
  3696. ((struct d1_meta *)(return_ptr[1]))->occurs = len;
  3697.  
  3698. return;
  3699.  
  3700. memory_failure:
  3701. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3702. return;
  3703. }
  3704.  
  3705.  
  3706.  
  3707.  
  3708. void _mc__strncmp(void *return_ptr[],
  3709.                   struct d1_meta *s1, struct d1_meta *s2, ff_size_t n)
  3710. {
  3711. int result = 0;
  3712. moal_t wrk1, occurs1, occurs2;
  3713. unsigned char *c1, *c2;
  3714.  
  3715. c1 = (unsigned char *)s1->ptr;
  3716. c2 = (unsigned char *)s2->ptr;
  3717.  
  3718. occurs1 = s1->occurs;
  3719. occurs2 = s2->occurs;
  3720.  
  3721. for(wrk1 = 0; wrk1 < n; ++wrk1)
  3722.     {if(wrk1 < occurs1 && wrk1 < occurs2)
  3723.          {if(c1[wrk1] != c2[wrk1])
  3724.               {if(c1[wrk1] < c2[wrk1])
  3725.                    result = -1;
  3726.                else
  3727.                    result = 1;
  3728.                break;}}
  3729.      else if(wrk1 >= occurs1 && wrk1 >= occurs2)
  3730.          break;
  3731.      else if(wrk1 >= occurs1)
  3732.          {result = -1;
  3733.           break;}
  3734.      else
  3735.          {result = 1;
  3736.           break;}}
  3737.  
  3738. *((int *)(return_ptr[1])) = result;
  3739. return;
  3740. }
  3741.  
  3742.  
  3743.  
  3744.  
  3745. /*
  3746. * the source space and return space can be the same
  3747. */
  3748. void _mc__strpart(void *return_ptr[], struct d1_meta *source,
  3749.                   ff_size_t from_offset, ff_size_t to_offset)
  3750. {
  3751. moal_t new_min, len;
  3752.  
  3753. ((struct d1_meta *)(return_ptr[1]))->occurs = 0;
  3754.  
  3755. if(source->occurs == 0
  3756. || to_offset >= source->occurs
  3757. || from_offset > to_offset)
  3758.     return;
  3759.  
  3760. len = (to_offset - from_offset) + 1;
  3761. new_min = len;
  3762. if(new_min > ((struct d1_meta *)(return_ptr[1]))->limit1)
  3763.     if(!resize_cspace((struct d1_meta *)return_ptr[1], new_min))
  3764.         goto memory_failure;
  3765.  
  3766. memcpy((char *)((struct d1_meta *)(return_ptr[1]))->ptr,
  3767.        (char *)source->ptr + from_offset, len);
  3768.  
  3769. ((struct d1_meta *)(return_ptr[1]))->occurs = len;
  3770.  
  3771. return;
  3772.  
  3773. memory_failure:
  3774. *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3775. return;
  3776. }
  3777.  
  3778.  
  3779.  
  3780.  
  3781. void _mc__strrpl(void *return_ptr[], struct d1_meta *out,
  3782.                  ff_size_t out_offset, ff_size_t cut_length,
  3783.                  struct d1_meta *insert)
  3784. {
  3785. int error = 0;
  3786. long net_change = 0;
  3787. int out_is_var;
  3788. moal_t new_min;
  3789. unsigned char *to, *from;
  3790.  
  3791. if(sum_overflows(moal_t, out_offset, cut_length)
  3792. || out_offset + cut_length > out->occurs
  3793. || (out->ptr == insert->ptr && out->limit1 && insert->limit1))
  3794.     {error = MC_INCOMPATIBLE_PARAMS;
  3795.      goto done;}
  3796.  
  3797. if(return_ptr[4] == NULL)
  3798.     out_is_var = TRUE;
  3799. else
  3800.     out_is_var = FALSE;
  3801.  
  3802. if(insert->occurs > cut_length)
  3803.     net_change = insert->occurs - cut_length;
  3804. else
  3805.     {net_change = cut_length - insert->occurs;
  3806.      net_change *= -1;}
  3807.  
  3808. new_min = out->occurs + net_change;
  3809. if(new_min > out->limit1)
  3810.     {if(!out_is_var || !resize_cspace(out, new_min))
  3811.          goto out_failure;}
  3812.  
  3813. if(net_change)
  3814.     memmove((char *)out->ptr + out_offset + insert->occurs,
  3815.             (char *)out->ptr + out_offset + cut_length,
  3816.             out->occurs - (out_offset + cut_length));
  3817. if(insert->occurs)
  3818.     memcpy((char *)out->ptr + out_offset,
  3819.            (char *)insert->ptr, insert->occurs);
  3820.  
  3821. out->occurs += net_change;
  3822.  
  3823. done:
  3824. *((int *)(return_ptr[1])) = error;
  3825. *((long *)(return_ptr[2])) = net_change;
  3826. return;
  3827.  
  3828. out_failure:
  3829. if(out_is_var)
  3830.     *((int *)(return_ptr[0])) = MEMORY_FAILURE;
  3831. else
  3832.     {/* subtracting 1 from new_min to represent it as a 0-relative subscript */
  3833.      *((moal_t *)(return_ptr[3])) = new_min - 1;
  3834.      *((moal_t *)(return_ptr[4])) = out->limit1;}
  3835. return;
  3836. }
  3837.  
  3838.  
  3839.  
  3840.  
  3841. void _mc__strfnd(void *return_ptr[], struct d1_meta *search,
  3842.                  ff_size_t from_offset, ff_size_t to_offset,
  3843.                  int match_case, struct d1_meta *find)
  3844. {
  3845. int error = MC_NOT_FOUND;
  3846. ff_size_t subscript = 0;
  3847. unsigned char *sp, *fp;
  3848. moal_t wrk1, wrk2, f_occurs, fend;
  3849.  
  3850. if(search->occurs == 0 || find->occurs == 0)
  3851.     {error = MC_EMPTY_PARAMETER;
  3852.      goto done;}
  3853.  
  3854. if(from_offset >= search->occurs || to_offset >= search->occurs)
  3855.     {error = MC_OFFSET_INVALID;
  3856.      goto done;}
  3857.  
  3858. sp = (unsigned char *)search->ptr;
  3859. fp = (unsigned char *)find->ptr;
  3860. f_occurs = find->occurs;
  3861.  
  3862. if(from_offset <= to_offset)  /* search down */
  3863.     {for(wrk1 = from_offset, wrk2 = 0; wrk1 <= to_offset; ++wrk1)
  3864.          {if(match_case ? (sp[wrk1] == fp[wrk2])
  3865.              : (tolower(sp[wrk1]) == tolower(fp[wrk2])))
  3866.               {++wrk2;
  3867.                if(wrk2 == f_occurs)
  3868.                    {error = 0;
  3869.                     subscript = wrk1 - (wrk2 - 1);
  3870.                     break;}}
  3871.           else if(wrk2 > 0)
  3872.               {wrk1 -= wrk2;
  3873.                wrk2 = 0;}}}
  3874. else  /* search up */
  3875.     {for(wrk1 = from_offset, wrk2 = fend = f_occurs - 1;; --wrk1)
  3876.          {if(match_case ? (sp[wrk1] == fp[wrk2])
  3877.              : (tolower(sp[wrk1]) == tolower(fp[wrk2])))
  3878.               {if(wrk2 == 0)
  3879.                    {error = 0;
  3880.                     subscript = wrk1;
  3881.                     break;}
  3882.                --wrk2;}
  3883.           else if(wrk2 < fend)
  3884.               {wrk1 += (fend - wrk2);
  3885.                wrk2 = fend;}
  3886.           if(wrk1 == to_offset)
  3887.               break;}}
  3888.  
  3889. done:
  3890. *((int *)(return_ptr[1])) = error;
  3891. *((ff_size_t *)(return_ptr[2])) = subscript;
  3892. return;
  3893. }
  3894.  
  3895.  
  3896.  
  3897.  
  3898. void _mc__strtod(void *return_ptr[],
  3899.                  struct d1_meta *source, ff_size_t source_offset)
  3900. {
  3901. int error = 0, mall;
  3902. void *save_ptr;
  3903. double number = 0.0;
  3904. ff_size_t next_offset;
  3905. unsigned char save;
  3906. char *cp;
  3907.  
  3908. next_offset = source_offset;
  3909.  
  3910. if(source->occurs == 0)
  3911.     {error = MC_EMPTY_PARAMETER;
  3912.      goto done;}
  3913.  
  3914. if(source_offset >= source->occurs)
  3915.     {error = MC_OFFSET_INVALID;
  3916.      goto done;}
  3917.  
  3918. make_safe(source, mall, save_ptr, save, NONE);
  3919.  
  3920. errno = 0;
  3921. number = strtod((char *)source->ptr + source_offset, &cp);
  3922. if(number == 0.0 && cp == (char *)source->ptr + source_offset)
  3923.     error = MC_NaN;
  3924. else if(errno == ERANGE && number < 0.0)
  3925.     {error = MC_nINF;
  3926.      number = neg_inf.num;}
  3927. else if(errno == ERANGE && number > 0.0)
  3928.     {error = MC_pINF;
  3929.      number = pos_inf.num;}
  3930.  
  3931. next_offset = cp - (char *)source->ptr;
  3932.  
  3933. undo_safe(source, mall, save_ptr, save);
  3934.  
  3935. done:
  3936. *((int *)(return_ptr[1])) = error;
  3937. *((double *)(return_ptr[2])) = number;
  3938. *((ff_size_t *)(return_ptr[3])) = next_offset;
  3939. }
  3940.  
  3941.  
  3942.  
  3943.  
  3944. void _mc__strtol(void *return_ptr[],
  3945.                  struct d1_meta *source, ff_size_t source_offset)
  3946. {
  3947. int error = 0, mall;
  3948. void *save_ptr;
  3949. long number = 0;
  3950. ff_size_t next_offset;
  3951. unsigned char save;
  3952. char *cp;
  3953.  
  3954. next_offset = source_offset;
  3955.  
  3956. if(source->occurs == 0)
  3957.     {error = MC_EMPTY_PARAMETER;
  3958.      goto done;}
  3959.  
  3960. if(source_offset >= source->occurs)
  3961.     {error = MC_OFFSET_INVALID;
  3962.      goto done;}
  3963.  
  3964. make_safe(source, mall, save_ptr, save, NONE);
  3965.  
  3966. errno = 0;
  3967. number = strtol((char *)source->ptr + source_offset, &cp, 10);
  3968. if(number == 0 && cp == (char *)source->ptr + source_offset)
  3969.     error = MC_NaN;
  3970. else if(errno == ERANGE && number < 0)
  3971.     {error = MC_nINF;
  3972.      number = LONG_MIN;}
  3973. else if(errno == ERANGE && number > 0)
  3974.     {error = MC_pINF;
  3975.      number = LONG_MAX;}
  3976.  
  3977. next_offset = cp - (char *)source->ptr;
  3978.  
  3979. undo_safe(source, mall, save_ptr, save);
  3980.  
  3981. done:
  3982. *((int *)(return_ptr[1])) = error;
  3983. *((long *)(return_ptr[2])) = number;
  3984. *((ff_size_t *)(return_ptr[3])) = next_offset;
  3985. }
  3986.  
  3987.  
  3988.  
  3989.  
  3990. void _mc__strtoul(void *return_ptr[],
  3991.                   struct d1_meta *source, ff_size_t source_offset)
  3992. {
  3993. int error = 0, mall;
  3994. void *save_ptr;
  3995. unsigned long number = 0;
  3996. ff_size_t next_offset;
  3997. unsigned char save;
  3998. char *cp;
  3999.  
  4000. next_offset = source_offset;
  4001.  
  4002. if(source->occurs == 0)
  4003.     {error = MC_EMPTY_PARAMETER;
  4004.      goto done;}
  4005.  
  4006. if(source_offset >= source->occurs)
  4007.     {error = MC_OFFSET_INVALID;
  4008.      goto done;}
  4009.  
  4010. make_safe(source, mall, save_ptr, save, NONE);
  4011.  
  4012. errno = 0;
  4013. number = strtoul((char *)source->ptr + source_offset, &cp, 10);
  4014. if(number == 0 && cp == (char *)source->ptr + source_offset)
  4015.     error = MC_NaN;
  4016. else if(errno == ERANGE)
  4017.     {error = MC_pINF;
  4018.      number = ULONG_MAX;}
  4019.  
  4020. next_offset = cp - (char *)source->ptr;
  4021.  
  4022. undo_safe(source, mall, save_ptr, save);
  4023.  
  4024. done:
  4025. *((int *)(return_ptr[1])) = error;
  4026. *((unsigned long *)(return_ptr[2])) = number;
  4027. *((ff_size_t *)(return_ptr[3])) = next_offset;
  4028. }
  4029.  
  4030.  
  4031.  
  4032.  
  4033. /*
  4034. * support functions used by the library
  4035. */
  4036.  
  4037. static void format_new_flags(char comma, char dollar, char paren,
  4038.                              char *in, char *out, char space_flag)
  4039. {
  4040. char minus;
  4041. int wrk1, wrk2, blanks_consumed, period, add, digits, comma_pos;
  4042.  
  4043. for(wrk1 = out[0] = 0, minus = 'n', period = -1; in[wrk1] != 0; ++wrk1)
  4044.     {if(in[wrk1] == '.')
  4045.          {period = wrk1;
  4046.           break;}
  4047.      if(isdigit(in[wrk1]))
  4048.          period = wrk1 + 1;
  4049.      if(in[wrk1] == '-')
  4050.          minus = 'y';}
  4051.  
  4052. if(minus == 'n')
  4053.     paren = 'n';
  4054. else
  4055.     space_flag = 'n';
  4056.  
  4057. if(period >= 0)
  4058.     {add = 0;
  4059.      if(dollar == 'y')
  4060.          ++add;
  4061.      if(paren == 'y')
  4062.          ++add;
  4063.      for(digits = 0, comma_pos = -1, wrk1 = period - 1; wrk1 >= 0; --wrk1)
  4064.          {if(isdigit(in[wrk1]))
  4065.               {++digits;
  4066.                if(digits == 4)
  4067.                    {comma_pos = wrk1 + 1;
  4068.                     ++add;
  4069.                     digits = 1;}
  4070.                continue;}
  4071.           else
  4072.               break;}
  4073.      wrk2 = 0;
  4074.      if(period == 0 && dollar == 'y')
  4075.          {dollar = 'n';
  4076.           out[wrk2++] = '$';}
  4077.      for(wrk1 = blanks_consumed = 0; wrk1 < period; ++wrk1)
  4078.          {/* consume leading blanks up to added, if right justified */
  4079.           if(in[wrk1] == ' ')
  4080.               {if(space_flag == 'y')  /* do not consume 1st leading blank */
  4081.                    space_flag = 'n';
  4082.                else if(blanks_consumed < add)
  4083.                    {++blanks_consumed;
  4084.                     continue;}}
  4085.           if(paren == 'y' && in[wrk1] == '-')
  4086.               {paren = 'r';
  4087.                out[wrk2++] = '(';
  4088.                continue;}
  4089.           if(dollar == 'y' && (isdigit(in[wrk1]) || wrk1 == period))
  4090.               {dollar = 'n';
  4091.                out[wrk2++] = '$';}
  4092.           if(wrk1 == comma_pos)
  4093.               {out[wrk2++] = ',';
  4094.                comma_pos += 3;}
  4095.           out[wrk2++] = in[wrk1];}
  4096.      for(wrk1 = period; in[wrk1] != 0; ++wrk1)
  4097.          {if(paren == 'r' && in[wrk1] == ' ')
  4098.               {paren = 'n';
  4099.                out[wrk2++] = ')';}
  4100.           /* consume trailing blanks up to added, if left justified */
  4101.           if(in[wrk1] == ' ' && blanks_consumed < add)
  4102.               {++blanks_consumed;
  4103.                continue;}
  4104.           out[wrk2++] = in[wrk1];}
  4105.      if(paren == 'r')
  4106.          out[wrk2++] = ')';
  4107.      out[wrk2++] = 0;}
  4108. else
  4109.     strcpy(out, in);
  4110.  
  4111. return;
  4112. }
  4113.  
  4114.  
  4115.  
  4116.  
  4117. static int store_file(FILE *in)
  4118. {
  4119. int wrk1;
  4120.  
  4121. if(in == stdin)
  4122.     return 1;
  4123. else if(in == stdout)
  4124.     return 2;
  4125. else if(in == stderr)
  4126.     return 3;
  4127. else
  4128.     {for(wrk1 = 0; wrk1 < files_cnt; ++wrk1)
  4129.          {if(files[wrk1] == NULL)
  4130.               {/* reuse the empty slot */
  4131.                files[wrk1] = in;
  4132.                return wrk1 + FIRST_USER_FILE;}}
  4133.      if(files_cnt < FILES_MAX)
  4134.          {files[files_cnt++] = in;
  4135.           return (files_cnt - 1 + FIRST_USER_FILE);}
  4136.      else
  4137.          return 0;}  /* no room */
  4138. }
  4139.  
  4140.  
  4141.  
  4142.  
  4143. static void remove_file(int in)
  4144. {
  4145. int sub;
  4146.  
  4147. sub = in - FIRST_USER_FILE;
  4148. if(sub >= 0 && sub < files_cnt)
  4149.     files[sub] = NULL;  /* mark slot for reuse */
  4150.  
  4151. return;
  4152. }
  4153.  
  4154.  
  4155.  
  4156.  
  4157. static FILE *retrieve_file(int in)
  4158. {
  4159. int sub;
  4160.  
  4161. if(in == 1)
  4162.     return stdin;
  4163. else if(in == 2)
  4164.     return stdout;
  4165. else if(in == 3)
  4166.     return stderr;
  4167. else
  4168.     {sub = in - FIRST_USER_FILE;
  4169.      if(sub >= 0 && sub < files_cnt)
  4170.          return files[sub];
  4171.      else
  4172.          return NULL;}
  4173. }
  4174.  
  4175.  
  4176.  
  4177.  
  4178. static void tm_to_ff_tm(struct tm *in, struct ff_tm *out)
  4179. {
  4180. out->tm_sec = in->tm_sec;
  4181. out->tm_min = in->tm_min;
  4182. out->tm_hour = in->tm_hour;
  4183. out->tm_mday = in->tm_mday;
  4184. out->tm_mon = in->tm_mon;
  4185. out->tm_year = in->tm_year;
  4186. out->tm_wday = in->tm_wday;
  4187. out->tm_yday = in->tm_yday;
  4188. out->tm_isdst = in->tm_isdst;
  4189.  
  4190. return;
  4191. }
  4192.  
  4193.  
  4194.  
  4195.  
  4196. static void ff_tm_to_tm(struct ff_tm *in, struct tm *out)
  4197. {
  4198. out->tm_sec = in->tm_sec;
  4199. out->tm_min = in->tm_min;
  4200. out->tm_hour = in->tm_hour;
  4201. out->tm_mday = in->tm_mday;
  4202. out->tm_mon = in->tm_mon;
  4203. out->tm_year = in->tm_year;
  4204. out->tm_wday = in->tm_wday;
  4205. out->tm_yday = in->tm_yday;
  4206. out->tm_isdst = in->tm_isdst;
  4207.  
  4208. return;
  4209. }
  4210.  
  4211.  
  4212.  
  4213.  
  4214. static int resize_cspace(struct d1_meta *out, moal_t new_min)
  4215. {
  4216. moal_t new_limit, s1, s2;
  4217. void *new_ptr;
  4218.  
  4219. static int resize_num = 50,
  4220.            resize_pct = 15;
  4221.  
  4222. /*
  4223. * grow the varspace as needed
  4224. */
  4225.  
  4226. s1 = resize_num + out->limit1;
  4227. s2 = resize_pct * (out->limit1 / 100) + out->limit1;
  4228.  
  4229. new_limit = max(new_min, max(s1, s2));
  4230.  
  4231. if(out->limit1 == 0)
  4232.     {new_ptr = malloc(new_limit);
  4233.      if(new_ptr == NULL)
  4234.          return FALSE;}
  4235. else
  4236.     {new_ptr = realloc(out->ptr, new_limit);
  4237.      if(new_ptr == NULL)
  4238.          return FALSE;}
  4239.  
  4240. out->ptr = new_ptr;
  4241. out->limit1 = new_limit;
  4242.  
  4243. return TRUE;
  4244. }
  4245.  
  4246.  
  4247.  
  4248.  
  4249. /*
  4250. * this compiled code is all the code, including helper functions,
  4251. * for these library functions:
  4252. *
  4253. *    stresc(), strreg(), strfndr(), fgetall(), fputall(),
  4254. *    strkey(), strknew(), strkmap(), strkfnd()
  4255. *
  4256. * this C code was generated by the MOAL C compiler, because these functions
  4257. * were written in MOAL C instead of C
  4258. */
  4259.  
  4260.  
  4261. struct zz1D_meta {
  4262.    void *ptr;
  4263.    unsigned occurs;
  4264.    unsigned limit1;
  4265. };
  4266.  
  4267.  
  4268. static int zzzz_resize1(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
  4269. static int zzzz_resize2(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
  4270. static int zzzz_resize3(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
  4271. static int zzzz_resize4(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
  4272. static int zzzz_resize5(struct zz1D_meta *meta, unsigned sub1, int resize_num1, int resize_pct1);
  4273.  
  4274.  
  4275. struct _fsm {
  4276.    int next1;
  4277.    int next2;
  4278.    struct zz1D_meta cset;
  4279.    char type;
  4280.    unsigned char single;
  4281. };
  4282.  
  4283.  
  4284. struct rg {
  4285.    struct zz1D_meta st;
  4286.    int match_longest;
  4287.    int match_case;
  4288.    int align_left;
  4289.    int align_right;
  4290.    struct zz1D_meta m;
  4291.    struct zz1D_meta start;
  4292. };
  4293.  
  4294.  
  4295. struct _tx {
  4296.    struct zz1D_meta text;
  4297. };
  4298.  
  4299.  
  4300. struct _bn {
  4301.    int key;
  4302.    int red;
  4303.    int l;
  4304.    int r;
  4305. };
  4306.  
  4307.  
  4308. struct ky {
  4309.    int initialized[1];
  4310.    struct zz1D_meta zz_initialized;
  4311.    int match_case;
  4312.    struct zz1D_meta key;
  4313.    struct zz1D_meta bin;
  4314.    struct zz1D_meta map;
  4315. };
  4316.  
  4317. void _mc__strreg(void *zzzz_return_ptr[], struct zz1D_meta *expression,
  4318.   int match_longest, int match_case);
  4319. void _mc__strfndr(void *zzzz_return_ptr[], struct zz1D_meta *search, unsigned
  4320.  int from_offset, unsigned int to_offset, struct rg *machine);
  4321. void _mc__stresc(void *zzzz_return_ptr[], struct zz1D_meta *source);
  4322. void _mc__fgetall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
  4323.  int convert_text);
  4324. void _mc__fputall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
  4325.  int convert_text, struct zz1D_meta *data);
  4326. void _mc__strkey(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
  4327.  ky *keys);
  4328. void _mc__strknew(void *zzzz_return_ptr[], int match_case);
  4329. void _mc__strkmap(void *zzzz_return_ptr[], unsigned int sub, int map_to_sorted,
  4330.   struct ky *keys);
  4331. void _mc__strkfnd(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
  4332.  ky *keys);
  4333.  
  4334.  
  4335.  
  4336.  
  4337. void _mc__stresc(void *zzzz_return_ptr[], struct zz1D_meta *source)
  4338. {
  4339. struct zz1D_meta *translation = (struct zz1D_meta *)zzzz_return_ptr[1];
  4340. int wrk1;
  4341. int err;
  4342. int next;
  4343. long num;
  4344. unsigned char ch;
  4345.  
  4346. int zzzz_exception = 0;
  4347. unsigned zzzz_unsigned1;
  4348. unsigned zzzz_unsigned2;
  4349. int zzzz_int1;
  4350. unsigned char zzzz_unsigned_char1;
  4351. void *zzzz_actuals[4];
  4352.  
  4353. (*translation).occurs = 0;
  4354. zzzz_actuals[0] = &(zzzz_exception);
  4355.  
  4356. wrk1 = 0;
  4357. zzzz_cont2:
  4358. if(!(wrk1 < (*source).occurs)) goto zzzz_false1;
  4359. ch = (*(((char *)(source->ptr)) + ((wrk1))));
  4360. if(!(ch == '\\')) goto zzzz_false4;
  4361. if(!(wrk1 == (*source).occurs - 1)) goto zzzz_false2;
  4362. error:
  4363. zzzz_unsigned1 = (*translation).occurs;
  4364. zzzz_unsigned2 = 0;
  4365. if((zzzz_unsigned2) > (*translation).limit1)
  4366.    if(!zzzz_resize1(&((*translation)), (zzzz_unsigned2) - 1, 50, 15)) {
  4367.       zzzz_exception = 32000;
  4368.       goto zzzz_finish;
  4369.    }
  4370. (*translation).occurs = zzzz_unsigned2;
  4371. (*translation).occurs;
  4372. goto zzzz_finish;
  4373. zzzz_false2:
  4374. zzzz_int1 = ++wrk1;
  4375. ch = (*(((char *)(source->ptr)) + ((zzzz_int1))));
  4376. switch(ch)
  4377. {
  4378. break;
  4379. case 'a':
  4380. ch = '\a';
  4381. break;
  4382. case 'b':
  4383. ch = '\b';
  4384. break;
  4385. case 't':
  4386. ch = '\t';
  4387. break;
  4388. case 'n':
  4389. ch = '\n';
  4390. break;
  4391. case 'v':
  4392. ch = '\v';
  4393. break;
  4394. case 'f':
  4395. ch = '\f';
  4396. break;
  4397. case 'r':
  4398. ch = '\r';
  4399. break;
  4400. case '\\':
  4401. ch = '\\';
  4402. break;
  4403. case '\'':
  4404. ch = '\'';
  4405. break;
  4406. case '\"':
  4407. ch = '\"';
  4408. break;
  4409. default:
  4410. zzzz_unsigned_char1 = ((unsigned char)((ch)));
  4411. if(!((*(((signed char *)(_MC_ctype.ptr)) + ((zzzz_unsigned_char1)))) & 8)) goto zzzz_true1;
  4412. zzzz_actuals[1] = &(err);
  4413. zzzz_actuals[2] = &(num);
  4414. zzzz_actuals[3] = &(next);
  4415. _mc__strtol(zzzz_actuals, &((*source)), wrk1);
  4416. if(zzzz_exception) {
  4417.    goto zzzz_finish;
  4418. }
  4419. if(err) goto zzzz_true1;
  4420. if(next - wrk1 != 3) goto zzzz_true1;
  4421. if(num < 0) goto zzzz_true1;
  4422. if(num > 255) goto zzzz_true1;
  4423. goto zzzz_false3;
  4424. zzzz_true1:
  4425. goto error;
  4426. goto zzzz_skip1;
  4427. zzzz_false3:
  4428. ch = num;
  4429. wrk1 += 2;
  4430. zzzz_skip1:
  4431. ;}
  4432. zzzz_false4:
  4433. zzzz_unsigned1 = (*translation).occurs;
  4434. if((unsigned)(zzzz_unsigned1) >= ((*translation).limit1))
  4435.    if(!zzzz_resize1(&((*translation)), (unsigned)(zzzz_unsigned1), 50, 15)) {
  4436.       zzzz_exception = 32000;
  4437.       goto zzzz_finish;
  4438.    }
  4439. if((unsigned)(zzzz_unsigned1) + 1 > ((*translation).occurs))
  4440.    ((*translation).occurs) = (unsigned)(zzzz_unsigned1) + 1;
  4441. (*(((char *)(translation->ptr)) + ((zzzz_unsigned1)))) = ch;
  4442. zzzz_cont1:
  4443. ++wrk1;
  4444. goto zzzz_cont2;
  4445. zzzz_false1:
  4446.  
  4447. goto zzzz_finish;
  4448.  
  4449. zzzz_finish: ;
  4450.  
  4451. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  4452. }
  4453.  
  4454.  
  4455. static void parse(void *zzzz_return_ptr[], struct zz1D_meta *in, int in_bgn,
  4456.   int in_end, int match_case, struct zz1D_meta *st);
  4457.  
  4458.  
  4459. void _mc__strreg(void *zzzz_return_ptr[], struct zz1D_meta *expression,
  4460.   int match_longest, int match_case)
  4461. {
  4462. int error = 0;
  4463. struct rg *machine = (struct rg *)zzzz_return_ptr[2];
  4464. int wrk1;
  4465. struct zz1D_meta stack = {NULL};
  4466. int in_bgn;
  4467. int in_end;
  4468. struct zz1D_meta visited = {NULL};
  4469. struct zz1D_meta st = {NULL};
  4470.  
  4471. int zzzz_exception = 0;
  4472. unsigned zzzz_imw1;
  4473. unsigned zzzz_unsigned1;
  4474. unsigned zzzz_unsigned2;
  4475. void *zzzz_actuals[1];
  4476.  
  4477. if((*machine).st.limit1 > 0) {
  4478.    for(zzzz_imw1 = 0; zzzz_imw1 < (*machine).st.occurs; ++zzzz_imw1) {
  4479.       if((((struct _fsm *)((*machine).st.ptr)) + (zzzz_imw1)) -> cset.limit1 > 0) {
  4480.          free((((struct _fsm *)((*machine).st.ptr)) + (zzzz_imw1)) -> cset.ptr);
  4481.       ;}
  4482.    ;}
  4483.    free((*machine).st.ptr);
  4484.    (*machine).st.occurs = 0;
  4485.    (*machine).st.limit1 = 0;
  4486. ;}
  4487. if((*machine).m.limit1 > 0) {
  4488.    free((*machine).m.ptr);
  4489.    (*machine).m.occurs = 0;
  4490.    (*machine).m.limit1 = 0;
  4491. ;}
  4492. if((*machine).start.limit1 > 0) {
  4493.    free((*machine).start.ptr);
  4494.    (*machine).start.occurs = 0;
  4495.    (*machine).start.limit1 = 0;
  4496. ;}
  4497. zzzz_actuals[0] = &(zzzz_exception);
  4498.  
  4499. if(!(!(*expression).occurs)) goto zzzz_false1;
  4500. error = - 6;
  4501. goto zzzz_finish;
  4502. zzzz_false1:
  4503.  
  4504. if(!((*expression).occurs > 1)) goto zzzz_false2;
  4505. if(!((*(((char *)(expression->ptr)) + ((0)))) == '$')) goto zzzz_false2;
  4506. if(!((*(((char *)(expression->ptr)) + ((1)))) == '$')) goto zzzz_false2;
  4507. in_bgn = 2;
  4508. (*machine).align_left = in_bgn;
  4509. goto zzzz_skip2;
  4510. zzzz_false2:
  4511. if(!((*(((char *)(expression->ptr)) + ((0)))) == '$')) goto zzzz_false3;
  4512. in_bgn = 1;
  4513. (*machine).align_left = in_bgn;
  4514. goto zzzz_skip1;
  4515. zzzz_false3:
  4516. in_bgn = 0;
  4517. (*machine).align_left = in_bgn;
  4518. zzzz_skip1:
  4519. zzzz_skip2:
  4520.  
  4521. if(!((*expression).occurs > 1)) goto zzzz_false4;
  4522. zzzz_unsigned1 = (*expression).occurs - 1;
  4523. if(!((*(((char *)(expression->ptr)) + ((zzzz_unsigned1)))) == '$')) goto
  4524.  zzzz_false4;
  4525. zzzz_unsigned2 = (*expression).occurs - 2;
  4526. if(!((*(((char *)(expression->ptr)) + ((zzzz_unsigned2)))) == '$')) goto
  4527.  zzzz_false4;
  4528. (*machine).align_right = 2;
  4529. in_end = (*expression).occurs - 3;
  4530. goto zzzz_skip4;
  4531. zzzz_false4:
  4532. zzzz_unsigned1 = (*expression).occurs - 1;
  4533. if(!((*(((char *)(expression->ptr)) + ((zzzz_unsigned1)))) == '$')) goto
  4534.  zzzz_false5;
  4535. (*machine).align_right = 1;
  4536. in_end = (*expression).occurs - 2;
  4537. goto zzzz_skip3;
  4538. zzzz_false5:
  4539. (*machine).align_right = 0;
  4540. in_end = (*expression).occurs - 1;
  4541. zzzz_skip3:
  4542. zzzz_skip4:
  4543.  
  4544. if(!(in_end < in_bgn)) goto zzzz_false6;
  4545. goto malformed;
  4546. zzzz_false6:
  4547.  
  4548. parse(zzzz_actuals, &((*expression)), in_bgn, in_end, match_case, &(st));
  4549. if(zzzz_exception) {
  4550.    if(zzzz_exception == 1) {
  4551.       zzzz_exception = 0;
  4552.       goto zzzz_exception1;
  4553.    }
  4554.    goto zzzz_finish;
  4555. }
  4556.  
  4557. if(!(!st.occurs)) goto zzzz_false7;
  4558. goto malformed;
  4559. zzzz_false7:
  4560.  
  4561. zzzz_unsigned1 = (*machine).m.occurs;
  4562. zzzz_unsigned2 = st.occurs * 2;
  4563. if((zzzz_unsigned2) > (*machine).m.limit1)
  4564.    if(!zzzz_resize3(&((*machine).m), (zzzz_unsigned2) - 1, 0, 15)) {
  4565.       zzzz_exception = 32000;
  4566.       goto zzzz_finish;
  4567.    }
  4568. (*machine).m.occurs = zzzz_unsigned2;
  4569. (*machine).m.occurs;
  4570.  
  4571. zzzz_unsigned1 = (*machine).start.occurs;
  4572. zzzz_unsigned2 = st.occurs;
  4573. if((zzzz_unsigned2) > (*machine).start.limit1)
  4574.    if(!zzzz_resize3(&((*machine).start), (zzzz_unsigned2) - 1, 0, 15)) {
  4575.       zzzz_exception = 32000;
  4576.       goto zzzz_finish;
  4577.    }
  4578. (*machine).start.occurs = zzzz_unsigned2;
  4579. (*machine).start.occurs;
  4580.  
  4581. zzzz_unsigned1 = (*machine).start.occurs;
  4582. zzzz_unsigned2 = 0;
  4583. if((zzzz_unsigned2) > (*machine).start.limit1)
  4584.    if(!zzzz_resize3(&((*machine).start), (zzzz_unsigned2) - 1, 0, 15)) {
  4585.       zzzz_exception = 32000;
  4586.       goto zzzz_finish;
  4587.    }
  4588. (*machine).start.occurs = zzzz_unsigned2;
  4589. (*machine).start.occurs;
  4590.  
  4591. if((unsigned)(0) >= (stack.limit1))
  4592.    if(!zzzz_resize3(&(stack), (unsigned)(0), 50, 15)) {
  4593.       zzzz_exception = 32000;
  4594.       goto zzzz_finish;
  4595.    }
  4596. if((unsigned)(0) + 1 > (stack.occurs))
  4597.    (stack.occurs) = (unsigned)(0) + 1;
  4598. (*(((int *)(stack.ptr)) + ((0)))) = 0;
  4599. zzzz_unsigned1 = visited.occurs;
  4600. zzzz_unsigned2 = st.occurs;
  4601. if((zzzz_unsigned2) > visited.limit1)
  4602.    if(!zzzz_resize3(&(visited), (zzzz_unsigned2) - 1, 50, 15)) {
  4603.       zzzz_exception = 32000;
  4604.       goto zzzz_finish;
  4605.    }
  4606. visited.occurs = zzzz_unsigned2;
  4607. visited.occurs;
  4608. if(visited.limit1)
  4609.    memset(((int *)(visited.ptr)), 0, sizeof(int) * visited.limit1);
  4610. zzzz_cont2:
  4611. if(!(stack.occurs)) goto zzzz_false8;
  4612. zzzz_unsigned1 = stack.occurs - 1;
  4613. wrk1 = (*(((int *)(stack.ptr)) + ((zzzz_unsigned1))));
  4614. zzzz_unsigned1 = stack.occurs;
  4615. zzzz_unsigned2 = stack.occurs;
  4616. if((zzzz_unsigned1 - 1) > stack.limit1)
  4617.    if(!zzzz_resize3(&(stack), (zzzz_unsigned1 - 1) - 1, 50, 15)) {
  4618.       zzzz_exception = 32000;
  4619.       goto zzzz_finish;
  4620.    }
  4621. stack.occurs = zzzz_unsigned1 - 1;
  4622. stack.occurs;
  4623. if(!((*(((int *)(visited.ptr)) + ((wrk1)))))) goto zzzz_false9;
  4624. goto zzzz_cont1;
  4625. zzzz_false9:
  4626. if((unsigned)(wrk1) >= (visited.limit1))
  4627.    if(!zzzz_resize3(&(visited), (unsigned)(wrk1), 50, 15)) {
  4628.       zzzz_exception = 32000;
  4629.       goto zzzz_finish;
  4630.    }
  4631. if((unsigned)(wrk1) + 1 > (visited.occurs))
  4632.    (visited.occurs) = (unsigned)(wrk1) + 1;
  4633. (*(((int *)(visited.ptr)) + ((wrk1)))) = 1;
  4634. if((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 's') goto zzzz_true1;
  4635. if((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 't') goto zzzz_true1;
  4636. goto zzzz_false14;
  4637. zzzz_true1:
  4638. zzzz_unsigned1 = (*machine).start.occurs;
  4639. if((unsigned)(zzzz_unsigned1) >= ((*machine).start.limit1))
  4640.    if(!zzzz_resize3(&((*machine).start), (unsigned)(zzzz_unsigned1), 0, 15))
  4641.  {
  4642.       zzzz_exception = 32000;
  4643.       goto zzzz_finish;
  4644.    }
  4645. if((unsigned)(zzzz_unsigned1) + 1 > ((*machine).start.occurs))
  4646.    ((*machine).start.occurs) = (unsigned)(zzzz_unsigned1) + 1;
  4647. (*(((int *)((*machine).start.ptr)) + ((zzzz_unsigned1)))) = wrk1;
  4648. goto zzzz_skip8;
  4649. zzzz_false14:
  4650. if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 'r')) goto zzzz_false13;
  4651. zzzz_unsigned1 = stack.occurs;
  4652. if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
  4653.    if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
  4654.       zzzz_exception = 32000;
  4655.       goto zzzz_finish;
  4656.    }
  4657. if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
  4658.    (stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
  4659. (*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
  4660.  + ((wrk1))) -> next1;
  4661. if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> next2 < st.occurs)) goto zzzz_false10;
  4662. zzzz_unsigned1 = stack.occurs;
  4663. if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
  4664.    if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
  4665.       zzzz_exception = 32000;
  4666.       goto zzzz_finish;
  4667.    }
  4668. if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
  4669.    (stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
  4670. (*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
  4671.  + ((wrk1))) -> next2;
  4672. goto zzzz_skip5;
  4673. zzzz_false10:
  4674. goto matches_nothing;
  4675. zzzz_skip5:
  4676. goto zzzz_skip7;
  4677. zzzz_false13:
  4678. if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> type == 'c')) goto zzzz_false12;
  4679. zzzz_unsigned1 = stack.occurs;
  4680. if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
  4681.    if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
  4682.       zzzz_exception = 32000;
  4683.       goto zzzz_finish;
  4684.    }
  4685. if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
  4686.    (stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
  4687. (*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
  4688.  + ((wrk1))) -> next1;
  4689. if(!((((struct _fsm *)(st.ptr)) + ((wrk1))) -> next2 < st.occurs)) goto zzzz_false11;
  4690. zzzz_unsigned1 = stack.occurs;
  4691. if((unsigned)(zzzz_unsigned1) >= (stack.limit1))
  4692.    if(!zzzz_resize3(&(stack), (unsigned)(zzzz_unsigned1), 50, 15)) {
  4693.       zzzz_exception = 32000;
  4694.       goto zzzz_finish;
  4695.    }
  4696. if((unsigned)(zzzz_unsigned1) + 1 > (stack.occurs))
  4697.    (stack.occurs) = (unsigned)(zzzz_unsigned1) + 1;
  4698. (*(((int *)(stack.ptr)) + ((zzzz_unsigned1)))) = (((struct _fsm *)(st.ptr))
  4699.  + ((wrk1))) -> next2;
  4700. goto zzzz_skip6;
  4701. zzzz_false11:
  4702. matches_nothing:
  4703. error = - 12;
  4704. goto zzzz_finish;
  4705. zzzz_skip6:
  4706. zzzz_false12:
  4707. zzzz_skip7:
  4708. zzzz_skip8:
  4709. zzzz_cont1:
  4710. goto zzzz_cont2;
  4711. zzzz_false8:
  4712.  
  4713. if(&((*machine).st) != &(st)) {
  4714.    if((*machine).st.limit1 > 0) {
  4715.       for(zzzz_imw1 = 0; zzzz_imw1 < (*machine).st.occurs; ++zzzz_imw1) {
  4716.          if((((struct _fsm *)(((struct _fsm *)((*machine).st.ptr)))) + (zzzz_imw1))
  4717.  -> cset.limit1 > 0) {
  4718.             free((((struct _fsm *)(((struct _fsm *)((*machine).st.ptr))))
  4719.  + (zzzz_imw1)) -> cset.ptr);
  4720.          ;}
  4721.       ;}
  4722.       free((*machine).st.ptr);
  4723.    ;}
  4724.    (*machine).st = st;
  4725.    if(st.limit1 > 0) {
  4726.       st.occurs = 0;
  4727.       st.limit1 = 0;
  4728.    ;}
  4729. }
  4730.  
  4731. (*machine).match_longest = match_longest;
  4732.  
  4733. (*machine).match_case = match_case;
  4734.  
  4735. goto zzzz_finish;
  4736.  
  4737. zzzz_exception1:
  4738. malformed:
  4739. error = - 11;
  4740.  
  4741. zzzz_finish: ;
  4742.  
  4743. *((int *)(zzzz_return_ptr[1])) = error;
  4744.  
  4745. if(stack.limit1 > 0) {
  4746.    free(stack.ptr);
  4747. ;}
  4748. if(visited.limit1 > 0) {
  4749.    free(visited.ptr);
  4750. ;}
  4751. if(st.limit1 > 0) {
  4752.    for(zzzz_imw1 = 0; zzzz_imw1 < st.occurs; ++zzzz_imw1) {
  4753.       if((((struct _fsm *)(st.ptr)) + (zzzz_imw1)) -> cset.limit1 > 0) {
  4754.          free((((struct _fsm *)(st.ptr)) + (zzzz_imw1)) -> cset.ptr);
  4755.       ;}
  4756.    ;}
  4757.    free(st.ptr);
  4758. ;}
  4759. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  4760. }
  4761.  
  4762.  
  4763.  
  4764.  
  4765. static void parse(void *zzzz_return_ptr[], struct zz1D_meta *in, int in_bgn,
  4766.   int in_end, int match_case, struct zz1D_meta *st)
  4767. {
  4768. int wrk1;
  4769. int wrk2;
  4770. int wrk3;
  4771. int sub;
  4772. int or_bgn;
  4773. int left_op;
  4774. int bgn_st_occurs;
  4775. int new_wrk1;
  4776. int save;
  4777. int parens;
  4778. char complete;
  4779. char negate;
  4780. char have_hyphen;
  4781. char have_set;
  4782. char empty;
  4783. unsigned char ch;
  4784. 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,
  4785.  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,
  4786.  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,
  4787.  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,
  4788.  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,
  4789.  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,
  4790.  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,
  4791.  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  4792. static struct zz1D_meta zz_zeros = {(void *)zeros,256,256};
  4793.  
  4794. int zzzz_exception = 0;
  4795. int zzzz_int1;
  4796. unsigned zzzz_unsigned1;
  4797. unsigned char zzzz_unsigned_char1;
  4798. unsigned char zzzz_unsigned_char2;
  4799. char zzzz_char1;
  4800. void *zzzz_actuals[1];
  4801.  
  4802. zzzz_actuals[0] = &(zzzz_exception);
  4803.  
  4804. bgn_st_occurs = (*st).occurs;
  4805. or_bgn = bgn_st_occurs;
  4806.  
  4807. wrk1 = in_bgn;
  4808. zzzz_cont22:
  4809. if(!(wrk1 <= in_end)) goto zzzz_false1;
  4810. ch = (*(((char *)(in->ptr)) + ((wrk1))));
  4811. if(!(ch == '/')) goto zzzz_false59;
  4812. if(!(wrk1 == in_end)) goto zzzz_false2;
  4813. zzzz_exception = 1;
  4814. goto zzzz_finish;
  4815. zzzz_false2:
  4816. zzzz_int1 = ++wrk1;
  4817. ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
  4818. goto zzzz_skip16;
  4819. zzzz_false59:
  4820. if(ch == ')') goto zzzz_true1;
  4821. if(ch == ']') goto zzzz_true1;
  4822. if(ch == '*') goto zzzz_true1;
  4823. if(ch == '+') goto zzzz_true1;
  4824. if(ch == '?') goto zzzz_true1;
  4825. if(ch == '$') goto zzzz_true1;
  4826. goto zzzz_false58;
  4827. zzzz_true1:
  4828. zzzz_exception = 1;
  4829. goto zzzz_finish;
  4830. goto zzzz_skip15;
  4831. zzzz_false58:
  4832. if(!(ch == '(')) goto zzzz_false57;
  4833. have_set = 'n';
  4834. complete = have_set;
  4835. parens = 1;
  4836. wrk2 = wrk1 + 1;
  4837. zzzz_cont5:
  4838. if(!(wrk2 <= in_end)) goto zzzz_false3;
  4839. ch = (*(((char *)(in->ptr)) + ((wrk2))));
  4840. if(!(ch == '/')) goto zzzz_false19;
  4841. ++wrk2;
  4842. goto zzzz_skip7;
  4843. zzzz_false19:
  4844. if(!(have_set == 'y')) goto zzzz_false18;
  4845. if(!(ch == ']')) goto zzzz_false4;
  4846. have_set = 'n';
  4847. zzzz_false4:
  4848. goto zzzz_skip6;
  4849. zzzz_false18:
  4850. if(!(ch == '[')) goto zzzz_false17;
  4851. have_set = 'y';
  4852. goto zzzz_skip5;
  4853. zzzz_false17:
  4854. if(!(ch == '(')) goto zzzz_false16;
  4855. ++parens;
  4856. goto zzzz_skip4;
  4857. zzzz_false16:
  4858. if(!(ch == ')')) goto zzzz_false5;
  4859. if(!(parens > 1)) goto zzzz_false5;
  4860. --parens;
  4861. goto zzzz_skip3;
  4862. zzzz_false5:
  4863. if(!(ch == ')')) goto zzzz_false15;
  4864. if(!(wrk2 + 1 <= in_end)) goto zzzz_false6;
  4865. zzzz_int1 = wrk2 + 1;
  4866. ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
  4867. goto zzzz_skip1;
  4868. zzzz_false6:
  4869. ch = ' ';
  4870. zzzz_skip1:
  4871. if(ch == '*') goto zzzz_true2;
  4872. if(ch == '+') goto zzzz_true2;
  4873. if(ch == '?') goto zzzz_true2;
  4874. goto zzzz_false7;
  4875. zzzz_true2:
  4876. new_wrk1 = wrk2 + 1;
  4877. goto zzzz_skip2;
  4878. zzzz_false7:
  4879. new_wrk1 = wrk2;
  4880. zzzz_skip2:
  4881. have_closure:
  4882. if(!(ch == '?')) goto zzzz_false8;
  4883. sub = (*st).occurs;
  4884. if((unsigned)(sub) >= ((*st).limit1))
  4885.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  4886.       zzzz_exception = 32000;
  4887.       goto zzzz_finish;
  4888.    }
  4889. if((unsigned)(sub) + 1 > ((*st).occurs))
  4890.    ((*st).occurs) = (unsigned)(sub) + 1;
  4891. (((struct _fsm *)(st->ptr)) + ((sub))) -> type = 'r';
  4892. if((unsigned)(sub) >= ((*st).limit1))
  4893.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  4894.       zzzz_exception = 32000;
  4895.       goto zzzz_finish;
  4896.    }
  4897. if((unsigned)(sub) + 1 > ((*st).occurs))
  4898.    ((*st).occurs) = (unsigned)(sub) + 1;
  4899. (((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = sub + 1;
  4900. parse(zzzz_actuals, &((*in)), wrk1 + 1, wrk2 - 1, match_case, &((*st)));
  4901. if(zzzz_exception) {
  4902.    goto zzzz_finish;
  4903. }
  4904. if((unsigned)(sub) >= ((*st).limit1))
  4905.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  4906.       zzzz_exception = 32000;
  4907.       goto zzzz_finish;
  4908.    }
  4909. if((unsigned)(sub) + 1 > ((*st).occurs))
  4910.    ((*st).occurs) = (unsigned)(sub) + 1;
  4911. (((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
  4912. goto cont1;
  4913. zzzz_false8:
  4914. if(!(ch == '+')) goto zzzz_false9;
  4915. parse(zzzz_actuals, &((*in)), wrk1 + 1, wrk2 - 1, match_case, &((*st)));
  4916. if(zzzz_exception) {
  4917.    goto zzzz_finish;
  4918. }
  4919. ch = '*';
  4920. zzzz_false9:
  4921. if(!(ch == '*')) goto zzzz_false10;
  4922. sub = (*st).occurs;
  4923. if((unsigned)(sub) >= ((*st).limit1))
  4924.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  4925.       zzzz_exception = 32000;
  4926.       goto zzzz_finish;
  4927.    }
  4928. if((unsigned)(sub) + 1 > ((*st).occurs))
  4929.    ((*st).occurs) = (unsigned)(sub) + 1;
  4930. (((struct _fsm *)(st->ptr)) + ((sub))) -> type = 'c';
  4931. if((unsigned)(sub) >= ((*st).limit1))
  4932.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  4933.       zzzz_exception = 32000;
  4934.       goto zzzz_finish;
  4935.    }
  4936. if((unsigned)(sub) + 1 > ((*st).occurs))
  4937.    ((*st).occurs) = (unsigned)(sub) + 1;
  4938. (((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = sub + 1;
  4939. zzzz_false10:
  4940. parse(zzzz_actuals, &((*in)), wrk1 + 1, wrk2 - 1, match_case, &((*st)));
  4941. if(zzzz_exception) {
  4942.    goto zzzz_finish;
  4943. }
  4944. if(!(ch == '*')) goto zzzz_false14;
  4945. wrk3 = sub + 1;
  4946. zzzz_cont4:
  4947. if(!(wrk3 < (*st).occurs)) goto zzzz_false11;
  4948. if(!((((struct _fsm *)(st->ptr)) + ((wrk3))) -> next1 == (*st).occurs)) goto
  4949.  zzzz_false12;
  4950. if((unsigned)(wrk3) >= ((*st).limit1))
  4951.    if(!zzzz_resize2(&((*st)), (unsigned)(wrk3), 15, 15)) {
  4952.       zzzz_exception = 32000;
  4953.       goto zzzz_finish;
  4954.    }
  4955. if((unsigned)(wrk3) + 1 > ((*st).occurs))
  4956.    ((*st).occurs) = (unsigned)(wrk3) + 1;
  4957. (((struct _fsm *)(st->ptr)) + ((wrk3))) -> next1 = sub;
  4958. zzzz_false12:
  4959. if(!((((struct _fsm *)(st->ptr)) + ((wrk3))) -> next2 == (*st).occurs)) goto
  4960.  zzzz_false13;
  4961. if((unsigned)(wrk3) >= ((*st).limit1))
  4962.    if(!zzzz_resize2(&((*st)), (unsigned)(wrk3), 15, 15)) {
  4963.       zzzz_exception = 32000;
  4964.       goto zzzz_finish;
  4965.    }
  4966. if((unsigned)(wrk3) + 1 > ((*st).occurs))
  4967.    ((*st).occurs) = (unsigned)(wrk3) + 1;
  4968. (((struct _fsm *)(st->ptr)) + ((wrk3))) -> next2 = sub;
  4969. zzzz_false13:
  4970. zzzz_cont3:
  4971. ++wrk3;
  4972. goto zzzz_cont4;
  4973. zzzz_false11:
  4974. if((unsigned)(sub) >= ((*st).limit1))
  4975.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  4976.       zzzz_exception = 32000;
  4977.       goto zzzz_finish;
  4978.    }
  4979. if((unsigned)(sub) + 1 > ((*st).occurs))
  4980.    ((*st).occurs) = (unsigned)(sub) + 1;
  4981. (((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
  4982. zzzz_false14:
  4983. cont1:
  4984. wrk1 = new_wrk1;
  4985. complete = 'y';
  4986. goto zzzz_false3;
  4987. zzzz_false15:
  4988. zzzz_skip3:
  4989. zzzz_skip4:
  4990. zzzz_skip5:
  4991. zzzz_skip6:
  4992. zzzz_skip7:
  4993. zzzz_cont2:
  4994. ++wrk2;
  4995. goto zzzz_cont5;
  4996. zzzz_false3:
  4997. if(!(complete == 'n')) goto zzzz_false20;
  4998. zzzz_exception = 1;
  4999. goto zzzz_finish;
  5000. zzzz_false20:
  5001. goto zzzz_cont1;
  5002. goto zzzz_skip14;
  5003. zzzz_false57:
  5004. if(!(ch == '|')) goto zzzz_false56;
  5005. if(!(or_bgn == (*st).occurs)) goto zzzz_false21;
  5006. zzzz_exception = 1;
  5007. goto zzzz_finish;
  5008. zzzz_false21:
  5009. wrk2 = (*st).occurs;
  5010. zzzz_cont7:
  5011. if(!(wrk2 > or_bgn)) goto zzzz_false22;
  5012. zzzz_int1 = wrk2 - 1;
  5013. if((unsigned)(wrk2) >= ((*st).limit1))
  5014.    if(!zzzz_resize2(&((*st)), (unsigned)(wrk2), 15, 15)) {
  5015.       zzzz_exception = 32000;
  5016.       goto zzzz_finish;
  5017.    }
  5018. if((unsigned)(wrk2) + 1 > ((*st).occurs))
  5019.    ((*st).occurs) = (unsigned)(wrk2) + 1;
  5020. if(&((*(((struct _fsm *)(st->ptr)) + ((wrk2))))) != &((*(((struct _fsm *)(st->ptr))
  5021.  + ((zzzz_int1)))))) {
  5022.    if((*(((struct _fsm *)(st->ptr)) + ((wrk2)))).cset.limit1 > 0) {
  5023.       free((*(((struct _fsm *)(st->ptr)) + ((wrk2)))).cset.ptr);
  5024.    ;}
  5025.    (*(((struct _fsm *)(st->ptr)) + ((wrk2)))) = (*(((struct _fsm *)(st->ptr))
  5026.  + ((zzzz_int1))));
  5027.    if((*(((struct _fsm *)(st->ptr)) + ((zzzz_int1)))).cset.limit1 > 0) {
  5028.       (*(((struct _fsm *)(st->ptr)) + ((zzzz_int1)))).cset.occurs = 0;
  5029.       (*(((struct _fsm *)(st->ptr)) + ((zzzz_int1)))).cset.limit1 = 0;
  5030.    ;}
  5031. }
  5032. ++(((struct _fsm *)(st->ptr)) + ((wrk2))) -> next1;
  5033. ++(((struct _fsm *)(st->ptr)) + ((wrk2))) -> next2;
  5034. zzzz_cont6:
  5035. --wrk2;
  5036. goto zzzz_cont7;
  5037. zzzz_false22:
  5038. sub = or_bgn;
  5039. or_bgn = (*st).occurs;
  5040. if((unsigned)(sub) >= ((*st).limit1))
  5041.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5042.       zzzz_exception = 32000;
  5043.       goto zzzz_finish;
  5044.    }
  5045. if((unsigned)(sub) + 1 > ((*st).occurs))
  5046.    ((*st).occurs) = (unsigned)(sub) + 1;
  5047. (((struct _fsm *)(st->ptr)) + ((sub))) -> type = 'r';
  5048. if((unsigned)(sub) >= ((*st).limit1))
  5049.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5050.       zzzz_exception = 32000;
  5051.       goto zzzz_finish;
  5052.    }
  5053. if((unsigned)(sub) + 1 > ((*st).occurs))
  5054.    ((*st).occurs) = (unsigned)(sub) + 1;
  5055. (((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = sub + 1;
  5056. save = (*st).occurs;
  5057. if((unsigned)(sub) >= ((*st).limit1))
  5058.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5059.       zzzz_exception = 32000;
  5060.       goto zzzz_finish;
  5061.    }
  5062. if((unsigned)(sub) + 1 > ((*st).occurs))
  5063.    ((*st).occurs) = (unsigned)(sub) + 1;
  5064. (((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = save;
  5065. parse(zzzz_actuals, &((*in)), wrk1 + 1, in_end, match_case, &((*st)));
  5066. if(zzzz_exception) {
  5067.    goto zzzz_finish;
  5068. }
  5069. wrk2 = sub + 1;
  5070. zzzz_cont9:
  5071. if(!(wrk2 < save)) goto zzzz_false23;
  5072. if(!((((struct _fsm *)(st->ptr)) + ((wrk2))) -> next1 == save)) goto zzzz_false24;
  5073. if((unsigned)(wrk2) >= ((*st).limit1))
  5074.    if(!zzzz_resize2(&((*st)), (unsigned)(wrk2), 15, 15)) {
  5075.       zzzz_exception = 32000;
  5076.       goto zzzz_finish;
  5077.    }
  5078. if((unsigned)(wrk2) + 1 > ((*st).occurs))
  5079.    ((*st).occurs) = (unsigned)(wrk2) + 1;
  5080. (((struct _fsm *)(st->ptr)) + ((wrk2))) -> next1 = (*st).occurs;
  5081. zzzz_false24:
  5082. if(!((((struct _fsm *)(st->ptr)) + ((wrk2))) -> next2 == save)) goto zzzz_false25;
  5083. if((unsigned)(wrk2) >= ((*st).limit1))
  5084.    if(!zzzz_resize2(&((*st)), (unsigned)(wrk2), 15, 15)) {
  5085.       zzzz_exception = 32000;
  5086.       goto zzzz_finish;
  5087.    }
  5088. if((unsigned)(wrk2) + 1 > ((*st).occurs))
  5089.    ((*st).occurs) = (unsigned)(wrk2) + 1;
  5090. (((struct _fsm *)(st->ptr)) + ((wrk2))) -> next2 = (*st).occurs;
  5091. zzzz_false25:
  5092. zzzz_cont8:
  5093. ++wrk2;
  5094. goto zzzz_cont9;
  5095. zzzz_false23:
  5096. goto zzzz_false1;
  5097. goto zzzz_skip13;
  5098. zzzz_false56:
  5099. if(!(ch == '[')) goto zzzz_false55;
  5100. wrk2 = wrk1 + 1;
  5101. zzzz_cont11:
  5102. if(!(wrk2 <= in_end)) goto zzzz_false26;
  5103. ch = (*(((char *)(in->ptr)) + ((wrk2))));
  5104. if(!(ch == '/')) goto zzzz_false30;
  5105. ++wrk2;
  5106. goto zzzz_skip8;
  5107. zzzz_false30:
  5108. if(!(ch == ']')) goto zzzz_false29;
  5109. if(!(wrk2 + 1 <= in_end)) goto zzzz_false28;
  5110. zzzz_int1 = wrk2 + 1;
  5111. ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
  5112. if(ch == '*') goto zzzz_true3;
  5113. if(ch == '+') goto zzzz_true3;
  5114. if(ch == '?') goto zzzz_true3;
  5115. goto zzzz_false27;
  5116. zzzz_true3:
  5117. --wrk1;
  5118. ++wrk2;
  5119. new_wrk1 = wrk2;
  5120. goto have_closure;
  5121. zzzz_false27:
  5122. zzzz_false28:
  5123. goto zzzz_false26;
  5124. zzzz_false29:
  5125. zzzz_skip8:
  5126. zzzz_cont10:
  5127. ++wrk2;
  5128. goto zzzz_cont11;
  5129. zzzz_false26:
  5130. sub = (*st).occurs;
  5131. if((unsigned)(sub) >= ((*st).limit1))
  5132.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5133.       zzzz_exception = 32000;
  5134.       goto zzzz_finish;
  5135.    }
  5136. if((unsigned)(sub) + 1 > ((*st).occurs))
  5137.    ((*st).occurs) = (unsigned)(sub) + 1;
  5138. (((struct _fsm *)(st->ptr)) + ((sub))) -> type = 't';
  5139. if((unsigned)(sub) >= ((*st).limit1))
  5140.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5141.       zzzz_exception = 32000;
  5142.       goto zzzz_finish;
  5143.    }
  5144. if((unsigned)(sub) + 1 > ((*st).occurs))
  5145.    ((*st).occurs) = (unsigned)(sub) + 1;
  5146. if(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset) != &(zz_zeros)) {
  5147.    if((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1 > 0) {
  5148.       free((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr);
  5149.    ;}
  5150.    zzzz_int1 = 1;
  5151.    (((struct _fsm *)(st->ptr)) + ((sub))) -> cset = zz_zeros;
  5152.    if(zz_zeros.limit1 > 0) {
  5153.       zzzz_unsigned1 = sizeof(char) * zz_zeros.limit1;
  5154.       (((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr = malloc(zzzz_unsigned1);
  5155.       if((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr == NULL)
  5156.          zzzz_int1 = (((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs
  5157.  = (((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1 = 0;
  5158.       else
  5159.          memcpy((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr, zz_zeros.ptr,
  5160.   zzzz_unsigned1);
  5161.    }
  5162.    if(!zzzz_int1) {
  5163.       zzzz_exception = 32000;
  5164.       goto zzzz_finish;
  5165.    }
  5166. }
  5167. if((unsigned)(sub) >= ((*st).limit1))
  5168.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5169.       zzzz_exception = 32000;
  5170.       goto zzzz_finish;
  5171.    }
  5172. if((unsigned)(sub) + 1 > ((*st).occurs))
  5173.    ((*st).occurs) = (unsigned)(sub) + 1;
  5174. (((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
  5175. if((unsigned)(sub) >= ((*st).limit1))
  5176.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5177.       zzzz_exception = 32000;
  5178.       goto zzzz_finish;
  5179.    }
  5180. if((unsigned)(sub) + 1 > ((*st).occurs))
  5181.    ((*st).occurs) = (unsigned)(sub) + 1;
  5182. (((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = (((struct _fsm *)(st->ptr))
  5183.  + ((sub))) -> next2;
  5184. negate = 'n';
  5185. have_hyphen = negate;
  5186. complete = have_hyphen;
  5187. left_op = - 1;
  5188. wrk2 = wrk1 + 1;
  5189. zzzz_cont17:
  5190. if(!(wrk2 <= in_end)) goto zzzz_false31;
  5191. ch = (*(((char *)(in->ptr)) + ((wrk2))));
  5192. if(!(ch == '^')) goto zzzz_false32;
  5193. if(!(wrk2 == wrk1 + 1)) goto zzzz_false32;
  5194. negate = 'y';
  5195. goto zzzz_cont12;
  5196. zzzz_false32:
  5197. if(!(ch == '/')) goto zzzz_false41;
  5198. if(!(wrk2 == in_end)) goto zzzz_false33;
  5199. zzzz_exception = 1;
  5200. goto zzzz_finish;
  5201. zzzz_false33:
  5202. zzzz_int1 = ++wrk2;
  5203. ch = (*(((char *)(in->ptr)) + ((zzzz_int1))));
  5204. goto zzzz_skip11;
  5205. zzzz_false41:
  5206. if(!(ch == ']')) goto zzzz_false40;
  5207. complete = 'y';
  5208. goto zzzz_false31;
  5209. goto zzzz_skip10;
  5210. zzzz_false40:
  5211. if(!(ch == '.')) goto zzzz_false39;
  5212. wrk3 = 0;
  5213. zzzz_cont14:
  5214. if(!(wrk3 < 256)) goto zzzz_false34;
  5215. if(!(wrk3 != '\n')) goto zzzz_false36;
  5216. if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
  5217.  ((wrk3)))))) goto zzzz_false35;
  5218. zzzz_exception = 1;
  5219. goto zzzz_finish;
  5220. zzzz_false35:
  5221. if((unsigned)(sub) >= ((*st).limit1))
  5222.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5223.       zzzz_exception = 32000;
  5224.       goto zzzz_finish;
  5225.    }
  5226. if((unsigned)(sub) + 1 > ((*st).occurs))
  5227.    ((*st).occurs) = (unsigned)(sub) + 1;
  5228. if((unsigned)(wrk3) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
  5229.    if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(wrk3),
  5230.   50, 15)) {
  5231.       zzzz_exception = 32000;
  5232.       goto zzzz_finish;
  5233.    }
  5234. if((unsigned)(wrk3) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
  5235.    ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(wrk3)
  5236.  + 1;
  5237. (*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))))
  5238.  = 1;
  5239. zzzz_false36:
  5240. zzzz_cont13:
  5241. ++wrk3;
  5242. goto zzzz_cont14;
  5243. zzzz_false34:
  5244. goto zzzz_cont12;
  5245. goto zzzz_skip9;
  5246. zzzz_false39:
  5247. if(!(ch == '-')) goto zzzz_false38;
  5248. if(!(left_op == - 1)) goto zzzz_false37;
  5249. zzzz_exception = 1;
  5250. goto zzzz_finish;
  5251. zzzz_false37:
  5252. have_hyphen = 'y';
  5253. goto zzzz_cont12;
  5254. zzzz_false38:
  5255. zzzz_skip9:
  5256. zzzz_skip10:
  5257. zzzz_skip11:
  5258. if(!(have_hyphen == 'y')) goto zzzz_false45;
  5259. if(!(left_op > ch)) goto zzzz_false42;
  5260. zzzz_exception = 1;
  5261. goto zzzz_finish;
  5262. zzzz_false42:
  5263. wrk3 = left_op;
  5264. zzzz_cont16:
  5265. if(!(wrk3 <= ch)) goto zzzz_false43;
  5266. if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
  5267.  ((wrk3)))))) goto zzzz_false44;
  5268. zzzz_exception = 1;
  5269. goto zzzz_finish;
  5270. zzzz_false44:
  5271. if((unsigned)(sub) >= ((*st).limit1))
  5272.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5273.       zzzz_exception = 32000;
  5274.       goto zzzz_finish;
  5275.    }
  5276. if((unsigned)(sub) + 1 > ((*st).occurs))
  5277.    ((*st).occurs) = (unsigned)(sub) + 1;
  5278. if((unsigned)(wrk3) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
  5279.    if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(wrk3),
  5280.   50, 15)) {
  5281.       zzzz_exception = 32000;
  5282.       goto zzzz_finish;
  5283.    }
  5284. if((unsigned)(wrk3) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
  5285.    ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(wrk3)
  5286.  + 1;
  5287. (*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))))
  5288.  = 1;
  5289. zzzz_cont15:
  5290. ++wrk3;
  5291. goto zzzz_cont16;
  5292. zzzz_false43:
  5293. left_op = - 1;
  5294. have_hyphen = 'n';
  5295. goto zzzz_cont12;
  5296. zzzz_false45:
  5297. if(!(wrk2 < in_end)) goto zzzz_false46;
  5298. zzzz_int1 = wrk2 + 1;
  5299. if(!((*(((char *)(in->ptr)) + ((zzzz_int1)))) == '-')) goto zzzz_false46;
  5300. left_op = ch;
  5301. goto zzzz_skip12;
  5302. zzzz_false46:
  5303. if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
  5304.  ((ch)))))) goto zzzz_false47;
  5305. zzzz_exception = 1;
  5306. goto zzzz_finish;
  5307. zzzz_false47:
  5308. if((unsigned)(sub) >= ((*st).limit1))
  5309.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5310.       zzzz_exception = 32000;
  5311.       goto zzzz_finish;
  5312.    }
  5313. if((unsigned)(sub) + 1 > ((*st).occurs))
  5314.    ((*st).occurs) = (unsigned)(sub) + 1;
  5315. if((unsigned)(ch) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
  5316.    if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(ch),
  5317.   50, 15)) {
  5318.       zzzz_exception = 32000;
  5319.       goto zzzz_finish;
  5320.    }
  5321. if((unsigned)(ch) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
  5322.    ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(ch)
  5323.  + 1;
  5324. (*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((ch))))
  5325.  = 1;
  5326. zzzz_skip12:
  5327. zzzz_cont12:
  5328. ++wrk2;
  5329. goto zzzz_cont17;
  5330. zzzz_false31:
  5331. if(!(!match_case)) goto zzzz_false50;
  5332. wrk3 = 0;
  5333. zzzz_cont19:
  5334. if(!(wrk3 < 256)) goto zzzz_false48;
  5335. if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
  5336.  ((wrk3)))))) goto zzzz_false49;
  5337. zzzz_unsigned_char1 = ((unsigned char)((wrk3)));
  5338. if(!(((*(((signed char *)(_MC_ctype.ptr)) + ((zzzz_unsigned_char1)))) & 4)))
  5339.  goto zzzz_false49;
  5340. if((unsigned)(sub) >= ((*st).limit1))
  5341.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5342.       zzzz_exception = 32000;
  5343.       goto zzzz_finish;
  5344.    }
  5345. if((unsigned)(sub) + 1 > ((*st).occurs))
  5346.    ((*st).occurs) = (unsigned)(sub) + 1;
  5347. zzzz_unsigned_char2 = ((unsigned char)((wrk3)));
  5348. zzzz_char1 = (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char2)))))));
  5349. if((unsigned)(zzzz_char1) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
  5350.    if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(zzzz_char1),
  5351.   50, 15)) {
  5352.       zzzz_exception = 32000;
  5353.       goto zzzz_finish;
  5354.    }
  5355. if((unsigned)(zzzz_char1) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) ->
  5356.  cset.occurs))
  5357.    ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(zzzz_char1)
  5358.  + 1;
  5359. (*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((zzzz_char1))))
  5360.  = 1;
  5361. zzzz_false49:
  5362. zzzz_cont18:
  5363. ++wrk3;
  5364. goto zzzz_cont19;
  5365. zzzz_false48:
  5366. zzzz_false50:
  5367. empty = 'y';
  5368. wrk3 = 0;
  5369. zzzz_cont21:
  5370. if(!(wrk3 < 256)) goto zzzz_false51;
  5371. if(!(negate == 'y')) goto zzzz_false52;
  5372. if((unsigned)(sub) >= ((*st).limit1))
  5373.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5374.       zzzz_exception = 32000;
  5375.       goto zzzz_finish;
  5376.    }
  5377. if((unsigned)(sub) + 1 > ((*st).occurs))
  5378.    ((*st).occurs) = (unsigned)(sub) + 1;
  5379. if((unsigned)(wrk3) >= ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.limit1))
  5380.    if(!zzzz_resize1(&((((struct _fsm *)(st->ptr)) + ((sub))) -> cset), (unsigned)(wrk3),
  5381.   50, 15)) {
  5382.       zzzz_exception = 32000;
  5383.       goto zzzz_finish;
  5384.    }
  5385. if((unsigned)(wrk3) + 1 > ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs))
  5386.    ((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.occurs) = (unsigned)(wrk3)
  5387.  + 1;
  5388. (*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))))
  5389.  = !(*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) + ((wrk3))));
  5390. zzzz_false52:
  5391. if(!((*(((char *)((((struct _fsm *)(st->ptr)) + ((sub))) -> cset.ptr)) +
  5392.  ((wrk3)))))) goto zzzz_false53;
  5393. empty = 'n';
  5394. zzzz_false53:
  5395. zzzz_cont20:
  5396. ++wrk3;
  5397. goto zzzz_cont21;
  5398. zzzz_false51:
  5399. if(complete == 'n') goto zzzz_true4;
  5400. if(have_hyphen == 'y') goto zzzz_true4;
  5401. if(empty == 'y') goto zzzz_true4;
  5402. goto zzzz_false54;
  5403. zzzz_true4:
  5404. zzzz_exception = 1;
  5405. goto zzzz_finish;
  5406. zzzz_false54:
  5407. wrk1 = wrk2;
  5408. goto zzzz_cont1;
  5409. zzzz_false55:
  5410. zzzz_skip13:
  5411. zzzz_skip14:
  5412. zzzz_skip15:
  5413. zzzz_skip16:
  5414. sub = (*st).occurs;
  5415. if((unsigned)(sub) >= ((*st).limit1))
  5416.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5417.       zzzz_exception = 32000;
  5418.       goto zzzz_finish;
  5419.    }
  5420. if((unsigned)(sub) + 1 > ((*st).occurs))
  5421.    ((*st).occurs) = (unsigned)(sub) + 1;
  5422. (((struct _fsm *)(st->ptr)) + ((sub))) -> type = 's';
  5423. if(!(match_case)) goto zzzz_false60;
  5424. zzzz_unsigned1 = ch;
  5425. goto zzzz_skip17;
  5426. zzzz_false60:
  5427. zzzz_unsigned_char1 = ((unsigned char)((ch)));
  5428. zzzz_unsigned1 = (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char1)))))));
  5429. zzzz_skip17:
  5430. if((unsigned)(sub) >= ((*st).limit1))
  5431.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5432.       zzzz_exception = 32000;
  5433.       goto zzzz_finish;
  5434.    }
  5435. if((unsigned)(sub) + 1 > ((*st).occurs))
  5436.    ((*st).occurs) = (unsigned)(sub) + 1;
  5437. (((struct _fsm *)(st->ptr)) + ((sub))) -> single = zzzz_unsigned1;
  5438. if((unsigned)(sub) >= ((*st).limit1))
  5439.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5440.       zzzz_exception = 32000;
  5441.       goto zzzz_finish;
  5442.    }
  5443. if((unsigned)(sub) + 1 > ((*st).occurs))
  5444.    ((*st).occurs) = (unsigned)(sub) + 1;
  5445. (((struct _fsm *)(st->ptr)) + ((sub))) -> next2 = (*st).occurs;
  5446. if((unsigned)(sub) >= ((*st).limit1))
  5447.    if(!zzzz_resize2(&((*st)), (unsigned)(sub), 15, 15)) {
  5448.       zzzz_exception = 32000;
  5449.       goto zzzz_finish;
  5450.    }
  5451. if((unsigned)(sub) + 1 > ((*st).occurs))
  5452.    ((*st).occurs) = (unsigned)(sub) + 1;
  5453. (((struct _fsm *)(st->ptr)) + ((sub))) -> next1 = (((struct _fsm *)(st->ptr))
  5454.  + ((sub))) -> next2;
  5455. zzzz_cont1:
  5456. ++wrk1;
  5457. goto zzzz_cont22;
  5458. zzzz_false1:
  5459.  
  5460. if(!((*st).occurs == bgn_st_occurs)) goto zzzz_false61;
  5461. zzzz_exception = 1;
  5462. goto zzzz_finish;
  5463. zzzz_false61:
  5464.  
  5465. goto zzzz_finish;
  5466.  
  5467. zzzz_finish: ;
  5468.  
  5469. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  5470. }
  5471.  
  5472.  
  5473. static void match(void *zzzz_return_ptr[], struct zz1D_meta *in, int from,
  5474.   int to, int match_longest, int match_case, int align_left, int align_right,
  5475.   struct zz1D_meta *st, struct zz1D_meta *m, struct zz1D_meta *start);
  5476.  
  5477.  
  5478. void _mc__strfndr(void *zzzz_return_ptr[], struct zz1D_meta *search, unsigned
  5479.  int from_offset, unsigned int to_offset, struct rg *machine)
  5480. {
  5481. int error;
  5482. unsigned int subscript = 0;
  5483. unsigned int length = 0;
  5484.  
  5485. int zzzz_exception = 0;
  5486. void *zzzz_actuals[4];
  5487.  
  5488. zzzz_actuals[0] = &(zzzz_exception);
  5489.  
  5490. if(!(!(*machine).st.occurs)) goto zzzz_false4;
  5491. error = - 13;
  5492. goto zzzz_finish;
  5493. goto zzzz_skip3;
  5494. zzzz_false4:
  5495. if(!(!(*search).occurs)) goto zzzz_false3;
  5496. error = - 6;
  5497. goto zzzz_finish;
  5498. goto zzzz_skip2;
  5499. zzzz_false3:
  5500. if(from_offset >= (*search).occurs) goto zzzz_true1;
  5501. if(to_offset >= (*search).occurs) goto zzzz_true1;
  5502. goto zzzz_false2;
  5503. zzzz_true1:
  5504. error = - 7;
  5505. goto zzzz_finish;
  5506. goto zzzz_skip1;
  5507. zzzz_false2:
  5508. if(!(from_offset > to_offset)) goto zzzz_false1;
  5509. error = - 8;
  5510. goto zzzz_finish;
  5511. zzzz_false1:
  5512. zzzz_skip1:
  5513. zzzz_skip2:
  5514. zzzz_skip3:
  5515.  
  5516. zzzz_actuals[1] = &(error);
  5517. zzzz_actuals[2] = &(subscript);
  5518. zzzz_actuals[3] = &(length);
  5519. match(zzzz_actuals, &((*search)), from_offset, to_offset, (*machine).match_longest,
  5520.   (*machine).match_case, (*machine).align_left, (*machine).align_right, &((*machine).st),
  5521.   &((*machine).m), &((*machine).start));
  5522. if(zzzz_exception) {
  5523.    goto zzzz_finish;
  5524. }
  5525.  
  5526. zzzz_finish: ;
  5527.  
  5528. *((int *)(zzzz_return_ptr[1])) = error;
  5529.  
  5530. *((unsigned int *)(zzzz_return_ptr[2])) = subscript;
  5531.  
  5532. *((unsigned int *)(zzzz_return_ptr[3])) = length;
  5533.  
  5534. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  5535. }
  5536.  
  5537.  
  5538.  
  5539.  
  5540. static void match(void *zzzz_return_ptr[], struct zz1D_meta *in, int from,
  5541.   int to, int match_longest, int match_case, int align_left, int align_right,
  5542.   struct zz1D_meta *st, struct zz1D_meta *m, struct zz1D_meta *start)
  5543. {
  5544. int error = 0;
  5545. unsigned int subscript = 0;
  5546. unsigned int length = 0;
  5547. int wrk1;
  5548. int wrk2;
  5549. int next;
  5550. int in_sub;
  5551. int tmp;
  5552. int old_bgn;
  5553. int old_top;
  5554. int type;
  5555. int old_top2;
  5556. int new_bgn;
  5557. int new_top;
  5558. int original_from;
  5559. int longest_end;
  5560. char success;
  5561. unsigned char mch;
  5562.  
  5563. int zzzz_exception = 0;
  5564. int zzzz_int1;
  5565. unsigned char zzzz_unsigned_char1;
  5566.  
  5567.  
  5568. success = 'n';
  5569. in_sub = from;
  5570. original_from = in_sub;
  5571. zzzz_cont26:
  5572. if(!(in_sub <= to)) goto zzzz_false1;
  5573. if(!(align_left)) goto zzzz_false2;
  5574. if(!(from != original_from)) goto zzzz_false2;
  5575. if(!(align_left == 1)) goto zzzz_false3;
  5576. goto zzzz_false1;
  5577. zzzz_false3:
  5578. zzzz_int1 = in_sub - 1;
  5579. if(!((*(((char *)(in->ptr)) + ((zzzz_int1)))) != '\n')) goto zzzz_false4;
  5580. goto zzzz_cont1;
  5581. zzzz_false4:
  5582. zzzz_false2:
  5583. old_top = 0;
  5584. old_bgn = old_top;
  5585. zzzz_cont3:
  5586. if(!(old_top < (*start).occurs)) goto zzzz_false5;
  5587. if((unsigned)(old_top) + 1 > ((*m).occurs))
  5588.    ((*m).occurs) = (unsigned)(old_top) + 1;
  5589. (*(((int *)(m->ptr)) + ((old_top)))) = (*(((int *)(start->ptr)) + ((old_top))));
  5590. zzzz_cont2:
  5591. ++old_top;
  5592. goto zzzz_cont3;
  5593. zzzz_false5:
  5594. old_top2 = old_top;
  5595. new_top = (*st).occurs;
  5596. new_bgn = new_top;
  5597. next_match:
  5598. if(!(match_case)) goto zzzz_false6;
  5599. zzzz_int1 = (*(((char *)(in->ptr)) + ((in_sub))));
  5600. goto zzzz_skip1;
  5601. zzzz_false6:
  5602. zzzz_unsigned_char1 = ((unsigned char)(((*(((char *)(in->ptr)) + ((in_sub)))))));
  5603. zzzz_int1 = (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char1)))))));
  5604. zzzz_skip1:
  5605. mch = zzzz_int1;
  5606. wrk1 = old_bgn;
  5607. zzzz_cont25:
  5608. if(!(wrk1 < old_top2)) goto zzzz_false7;
  5609. next = (*(((int *)(m->ptr)) + ((wrk1))));
  5610. type = (((struct _fsm *)(st->ptr)) + ((next))) -> type;
  5611. if(!(type == 't')) goto zzzz_false42;
  5612. if(!(!(*(((char *)((((struct _fsm *)(st->ptr)) + ((next))) -> cset.ptr))
  5613.  + ((mch)))))) goto zzzz_false8;
  5614. goto zzzz_cont4;
  5615. zzzz_false8:
  5616. matched_character:
  5617. tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next1;
  5618. if(!(tmp >= (*st).occurs)) goto zzzz_false11;
  5619. check_right_align:
  5620. if(!align_right) goto zzzz_true1;
  5621. if(in_sub == to) goto zzzz_true1;
  5622. if(!(align_right == 2)) goto zzzz_false9;
  5623. zzzz_int1 = in_sub + 1;
  5624. if(!((*(((char *)(in->ptr)) + ((zzzz_int1)))) == '\n')) goto zzzz_false9;
  5625. zzzz_true1:
  5626. if(!(!match_longest)) goto zzzz_false10;
  5627. subscript = from;
  5628. length = in_sub - from + 1;
  5629. goto zzzz_finish;
  5630. goto zzzz_skip2;
  5631. zzzz_false10:
  5632. longest_end = in_sub;
  5633. success = 'y';
  5634. goto zzzz_cont4;
  5635. zzzz_skip2:
  5636. goto zzzz_skip3;
  5637. zzzz_false9:
  5638. goto zzzz_cont4;
  5639. zzzz_skip3:
  5640. zzzz_false11:
  5641. if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false16;
  5642. wrk2 = new_bgn;
  5643. zzzz_cont6:
  5644. if(!(wrk2 < new_top)) goto zzzz_false12;
  5645. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false13;
  5646. goto cont1;
  5647. zzzz_false13:
  5648. zzzz_cont5:
  5649. ++wrk2;
  5650. goto zzzz_cont6;
  5651. zzzz_false12:
  5652. zzzz_int1 = new_top;
  5653. ++new_top;
  5654. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5655.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5656. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5657. cont1:
  5658. ;
  5659. goto zzzz_skip4;
  5660. zzzz_false16:
  5661. wrk2 = old_top;
  5662. zzzz_cont8:
  5663. if(!(wrk2 < old_top2)) goto zzzz_false14;
  5664. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false15;
  5665. goto cont2;
  5666. zzzz_false15:
  5667. zzzz_cont7:
  5668. ++wrk2;
  5669. goto zzzz_cont8;
  5670. zzzz_false14:
  5671. zzzz_int1 = old_top2;
  5672. ++old_top2;
  5673. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5674.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5675. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5676. cont2:
  5677. ;
  5678. zzzz_skip4:
  5679. goto zzzz_cont4;
  5680. goto zzzz_skip12;
  5681. zzzz_false42:
  5682. if(!(type == 'c')) goto zzzz_false41;
  5683. tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next1;
  5684. if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false21;
  5685. wrk2 = new_bgn;
  5686. zzzz_cont10:
  5687. if(!(wrk2 < new_top)) goto zzzz_false17;
  5688. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false18;
  5689. goto cont3;
  5690. zzzz_false18:
  5691. zzzz_cont9:
  5692. ++wrk2;
  5693. goto zzzz_cont10;
  5694. zzzz_false17:
  5695. zzzz_int1 = new_top;
  5696. ++new_top;
  5697. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5698.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5699. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5700. cont3:
  5701. ;
  5702. goto zzzz_skip5;
  5703. zzzz_false21:
  5704. wrk2 = old_top;
  5705. zzzz_cont12:
  5706. if(!(wrk2 < old_top2)) goto zzzz_false19;
  5707. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false20;
  5708. goto cont4;
  5709. zzzz_false20:
  5710. zzzz_cont11:
  5711. ++wrk2;
  5712. goto zzzz_cont12;
  5713. zzzz_false19:
  5714. zzzz_int1 = old_top2;
  5715. ++old_top2;
  5716. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5717.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5718. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5719. cont4:
  5720. ;
  5721. zzzz_skip5:
  5722. tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next2;
  5723. if(!(tmp >= (*st).occurs)) goto zzzz_false22;
  5724. goto check_right_align;
  5725. zzzz_false22:
  5726. if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false27;
  5727. wrk2 = new_bgn;
  5728. zzzz_cont14:
  5729. if(!(wrk2 < new_top)) goto zzzz_false23;
  5730. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false24;
  5731. goto cont5;
  5732. zzzz_false24:
  5733. zzzz_cont13:
  5734. ++wrk2;
  5735. goto zzzz_cont14;
  5736. zzzz_false23:
  5737. zzzz_int1 = new_top;
  5738. ++new_top;
  5739. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5740.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5741. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5742. cont5:
  5743. ;
  5744. goto zzzz_skip6;
  5745. zzzz_false27:
  5746. wrk2 = old_top;
  5747. zzzz_cont16:
  5748. if(!(wrk2 < old_top2)) goto zzzz_false25;
  5749. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false26;
  5750. goto cont6;
  5751. zzzz_false26:
  5752. zzzz_cont15:
  5753. ++wrk2;
  5754. goto zzzz_cont16;
  5755. zzzz_false25:
  5756. zzzz_int1 = old_top2;
  5757. ++old_top2;
  5758. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5759.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5760. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5761. cont6:
  5762. ;
  5763. zzzz_skip6:
  5764. goto zzzz_cont4;
  5765. goto zzzz_skip11;
  5766. zzzz_false41:
  5767. if(!(type == 's')) goto zzzz_false40;
  5768. if(!((((struct _fsm *)(st->ptr)) + ((next))) -> single == mch)) goto zzzz_false28;
  5769. goto matched_character;
  5770. goto zzzz_skip7;
  5771. zzzz_false28:
  5772. goto zzzz_cont4;
  5773. zzzz_skip7:
  5774. goto zzzz_skip10;
  5775. zzzz_false40:
  5776. tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next1;
  5777. if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false33;
  5778. wrk2 = new_bgn;
  5779. zzzz_cont18:
  5780. if(!(wrk2 < new_top)) goto zzzz_false29;
  5781. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false30;
  5782. goto cont7;
  5783. zzzz_false30:
  5784. zzzz_cont17:
  5785. ++wrk2;
  5786. goto zzzz_cont18;
  5787. zzzz_false29:
  5788. zzzz_int1 = new_top;
  5789. ++new_top;
  5790. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5791.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5792. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5793. cont7:
  5794. ;
  5795. goto zzzz_skip8;
  5796. zzzz_false33:
  5797. wrk2 = old_top;
  5798. zzzz_cont20:
  5799. if(!(wrk2 < old_top2)) goto zzzz_false31;
  5800. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false32;
  5801. goto cont8;
  5802. zzzz_false32:
  5803. zzzz_cont19:
  5804. ++wrk2;
  5805. goto zzzz_cont20;
  5806. zzzz_false31:
  5807. zzzz_int1 = old_top2;
  5808. ++old_top2;
  5809. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5810.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5811. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5812. cont8:
  5813. ;
  5814. zzzz_skip8:
  5815. tmp = (((struct _fsm *)(st->ptr)) + ((next))) -> next2;
  5816. if(!(tmp >= (*st).occurs)) goto zzzz_false34;
  5817. goto check_right_align;
  5818. zzzz_false34:
  5819. if(!((((struct _fsm *)(st->ptr)) + ((tmp))) -> type >= 's')) goto zzzz_false39;
  5820. wrk2 = new_bgn;
  5821. zzzz_cont22:
  5822. if(!(wrk2 < new_top)) goto zzzz_false35;
  5823. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false36;
  5824. goto cont9;
  5825. zzzz_false36:
  5826. zzzz_cont21:
  5827. ++wrk2;
  5828. goto zzzz_cont22;
  5829. zzzz_false35:
  5830. zzzz_int1 = new_top;
  5831. ++new_top;
  5832. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5833.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5834. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5835. cont9:
  5836. ;
  5837. goto zzzz_skip9;
  5838. zzzz_false39:
  5839. wrk2 = old_top;
  5840. zzzz_cont24:
  5841. if(!(wrk2 < old_top2)) goto zzzz_false37;
  5842. if(!(tmp == (*(((int *)(m->ptr)) + ((wrk2)))))) goto zzzz_false38;
  5843. goto cont10;
  5844. zzzz_false38:
  5845. zzzz_cont23:
  5846. ++wrk2;
  5847. goto zzzz_cont24;
  5848. zzzz_false37:
  5849. zzzz_int1 = old_top2;
  5850. ++old_top2;
  5851. if((unsigned)(zzzz_int1) + 1 > ((*m).occurs))
  5852.    ((*m).occurs) = (unsigned)(zzzz_int1) + 1;
  5853. (*(((int *)(m->ptr)) + ((zzzz_int1)))) = tmp;
  5854. cont10:
  5855. ;
  5856. zzzz_skip9:
  5857. goto zzzz_cont4;
  5858. zzzz_skip10:
  5859. zzzz_skip11:
  5860. zzzz_skip12:
  5861. zzzz_cont4:
  5862. ++wrk1;
  5863. goto zzzz_cont25;
  5864. zzzz_false7:
  5865. if(!(new_bgn == new_top)) goto zzzz_false44;
  5866. if(!(success == 'y')) goto zzzz_false43;
  5867. success_done:
  5868. subscript = from;
  5869. length = longest_end - from + 1;
  5870. goto zzzz_finish;
  5871. zzzz_false43:
  5872. goto zzzz_cont1;
  5873. zzzz_false44:
  5874. old_bgn = new_bgn;
  5875. old_top2 = new_top;
  5876. old_top = old_top2;
  5877. if(!(new_bgn == 0)) goto zzzz_false45;
  5878. new_top = (*st).occurs;
  5879. new_bgn = new_top;
  5880. goto zzzz_skip13;
  5881. zzzz_false45:
  5882. new_top = 0;
  5883. new_bgn = new_top;
  5884. zzzz_skip13:
  5885. ++in_sub;
  5886. if(!(in_sub <= to)) goto zzzz_false47;
  5887. goto next_match;
  5888. goto zzzz_skip15;
  5889. zzzz_false47:
  5890. if(!(success == 'y')) goto zzzz_false46;
  5891. goto success_done;
  5892. goto zzzz_skip14;
  5893. zzzz_false46:
  5894. goto zzzz_false1;
  5895. zzzz_skip14:
  5896. zzzz_skip15:
  5897. zzzz_cont1:
  5898. in_sub = ++from;
  5899. goto zzzz_cont26;
  5900. zzzz_false1:
  5901.  
  5902. error = (- 2);
  5903.  
  5904. goto zzzz_finish;
  5905.  
  5906. zzzz_finish: ;
  5907.  
  5908. *((int *)(zzzz_return_ptr[1])) = error;
  5909.  
  5910. *((unsigned int *)(zzzz_return_ptr[2])) = subscript;
  5911.  
  5912. *((unsigned int *)(zzzz_return_ptr[3])) = length;
  5913.  
  5914. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  5915. }
  5916.  
  5917.  
  5918.  
  5919.  
  5920. void _mc__fgetall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
  5921.  int convert_text)
  5922. {
  5923. int error;
  5924. struct zz1D_meta *data = (struct zz1D_meta *)zzzz_return_ptr[2];
  5925. int file;
  5926. unsigned int read;
  5927. long pos;
  5928.  
  5929. int zzzz_exception = 0;
  5930. static char zzzz_string1[2] = "r";
  5931. static struct zz1D_meta zz_zzzz_string1 = {zzzz_string1,1,2};
  5932. static char zzzz_string2[3] = "rb";
  5933. static struct zz1D_meta zz_zzzz_string2 = {zzzz_string2,2,3};
  5934. struct zz1D_meta *zzzz_tri1;
  5935. char *zzzz_tri2;
  5936. unsigned zzzz_unsigned1;
  5937. unsigned zzzz_unsigned2;
  5938. void *zzzz_actuals[5];
  5939.  
  5940. (*data).occurs = 0;
  5941. zzzz_actuals[0] = &(zzzz_exception);
  5942.  
  5943. if(!(convert_text)) goto zzzz_false1;
  5944. zzzz_tri2 = zzzz_string1;
  5945. zzzz_tri1 = &(zz_zzzz_string1);
  5946. goto zzzz_skip1;
  5947. zzzz_false1:
  5948. zzzz_tri2 = zzzz_string2;
  5949. zzzz_tri1 = &(zz_zzzz_string2);
  5950. zzzz_skip1:
  5951. zzzz_actuals[1] = &(error);
  5952. zzzz_actuals[2] = &(file);
  5953. _mc__fopen(zzzz_actuals, &((*filename)), &((*zzzz_tri1)));
  5954. if(zzzz_exception) {
  5955.    goto zzzz_finish;
  5956. }
  5957. if(error) goto zzzz_true1;
  5958. zzzz_actuals[1] = &(error);
  5959. _mc__fseek(zzzz_actuals, file, 0, 2);
  5960. if(error) goto zzzz_true1;
  5961. zzzz_actuals[1] = &(error);
  5962. zzzz_actuals[2] = &(pos);
  5963. _mc__ftell(zzzz_actuals, file);
  5964. if(error) goto zzzz_true1;
  5965. zzzz_actuals[1] = &(error);
  5966. _mc__fseek(zzzz_actuals, file, 0, 3);
  5967. if(error) goto zzzz_true1;
  5968. zzzz_actuals[1] = &(error);
  5969. zzzz_actuals[2] = &(read);
  5970. zzzz_actuals[3] = zzzz_actuals[4] = NULL;
  5971. _mc__fread(zzzz_actuals, &((*data)), 0, pos, file);
  5972. if(zzzz_exception) {
  5973.    goto zzzz_finish;
  5974. }
  5975. if(error) goto zzzz_true1;
  5976. zzzz_actuals[1] = &(error);
  5977. _mc__fclose(zzzz_actuals, file);
  5978. if(error) goto zzzz_true1;
  5979. goto zzzz_false2;
  5980. zzzz_true1:
  5981. zzzz_unsigned1 = (*data).occurs;
  5982. zzzz_unsigned2 = 0;
  5983. if((zzzz_unsigned2) > (*data).limit1)
  5984.    if(!zzzz_resize1(&((*data)), (zzzz_unsigned2) - 1, 50, 15)) {
  5985.       zzzz_exception = 32000;
  5986.       goto zzzz_finish;
  5987.    }
  5988. (*data).occurs = zzzz_unsigned2;
  5989. (*data).occurs;
  5990. zzzz_false2:
  5991.  
  5992. goto zzzz_finish;
  5993.  
  5994. zzzz_finish: ;
  5995.  
  5996. *((int *)(zzzz_return_ptr[1])) = error;
  5997.  
  5998. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  5999. }
  6000.  
  6001.  
  6002.  
  6003.  
  6004. void _mc__fputall(void *zzzz_return_ptr[], struct zz1D_meta *filename,
  6005.  int convert_text, struct zz1D_meta *data)
  6006. {
  6007. int error;
  6008. int file;
  6009.  
  6010. int zzzz_exception = 0;
  6011. static char zzzz_string1[2] = "w";
  6012. static struct zz1D_meta zz_zzzz_string1 = {zzzz_string1,1,2};
  6013. static char zzzz_string2[3] = "wb";
  6014. static struct zz1D_meta zz_zzzz_string2 = {zzzz_string2,2,3};
  6015. struct zz1D_meta *zzzz_tri1;
  6016. char *zzzz_tri2;
  6017. unsigned zzzz_unsigned1;
  6018. void *zzzz_actuals[3];
  6019.  
  6020. zzzz_actuals[0] = &(zzzz_exception);
  6021.  
  6022. if(!(convert_text)) goto zzzz_false1;
  6023. zzzz_tri2 = zzzz_string1;
  6024. zzzz_tri1 = &(zz_zzzz_string1);
  6025. goto zzzz_skip1;
  6026. zzzz_false1:
  6027. zzzz_tri2 = zzzz_string2;
  6028. zzzz_tri1 = &(zz_zzzz_string2);
  6029. zzzz_skip1:
  6030. zzzz_actuals[1] = &(error);
  6031. zzzz_actuals[2] = &(file);
  6032. _mc__fopen(zzzz_actuals, &((*filename)), &((*zzzz_tri1)));
  6033. if(zzzz_exception) {
  6034.    goto zzzz_finish;
  6035. }
  6036. if(error) goto zzzz_true1;
  6037. zzzz_unsigned1 = ((*data).occurs);
  6038. zzzz_actuals[1] = &(error);
  6039. _mc__fwrite(zzzz_actuals, &((*data)), 0, zzzz_unsigned1, file);
  6040. if(error) goto zzzz_true1;
  6041. zzzz_actuals[1] = &(error);
  6042. _mc__fclose(zzzz_actuals, file);
  6043. if(error) goto zzzz_true1;
  6044. goto zzzz_false2;
  6045. zzzz_true1:
  6046. ;
  6047. zzzz_false2:
  6048.  
  6049. goto zzzz_finish;
  6050.  
  6051. zzzz_finish: ;
  6052.  
  6053. *((int *)(zzzz_return_ptr[1])) = error;
  6054.  
  6055. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6056. }
  6057.  
  6058.  
  6059.  
  6060.  
  6061. void _mc__strknew(void *zzzz_return_ptr[], int match_case)
  6062. {
  6063. struct ky *keys = (struct ky *)zzzz_return_ptr[1];
  6064.  
  6065. int zzzz_exception = 0;
  6066. unsigned zzzz_imw1;
  6067.  
  6068. (*keys).zz_initialized.occurs = 0;
  6069. if((*keys).key.limit1 > 0) {
  6070.    for(zzzz_imw1 = 0; zzzz_imw1 < (*keys).key.occurs; ++zzzz_imw1) {
  6071.       if((((struct _tx *)((*keys).key.ptr)) + (zzzz_imw1)) -> text.limit1 > 0) {
  6072.          free((((struct _tx *)((*keys).key.ptr)) + (zzzz_imw1)) -> text.ptr);
  6073.       ;}
  6074.    ;}
  6075.    free((*keys).key.ptr);
  6076.    (*keys).key.occurs = 0;
  6077.    (*keys).key.limit1 = 0;
  6078. ;}
  6079. if((*keys).bin.limit1 > 0) {
  6080.    free((*keys).bin.ptr);
  6081.    (*keys).bin.occurs = 0;
  6082.    (*keys).bin.limit1 = 0;
  6083. ;}
  6084. if((*keys).map.limit1 > 0) {
  6085.    free((*keys).map.ptr);
  6086.    (*keys).map.occurs = 0;
  6087.    (*keys).map.limit1 = 0;
  6088. ;}
  6089.  
  6090. (*keys).zz_initialized.occurs = 1;
  6091. (*keys).zz_initialized.occurs;
  6092.  
  6093. (*keys).match_case = match_case;
  6094.  
  6095. zzzz_finish: ;
  6096.  
  6097. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6098. }
  6099.  
  6100.  
  6101. static void treemap(void *zzzz_return_ptr[], int x, struct ky *keys);
  6102.  
  6103.  
  6104. void _mc__strkmap(void *zzzz_return_ptr[], unsigned int sub, int map_to_sorted,
  6105.   struct ky *keys)
  6106. {
  6107. int error = 0;
  6108. struct zz1D_meta *key = (struct zz1D_meta *)zzzz_return_ptr[2];
  6109. unsigned int subscript = 0;
  6110.  
  6111. int zzzz_exception = 0;
  6112. void *zzzz_actuals[3];
  6113.  
  6114. (*key).occurs = 0;
  6115. zzzz_actuals[0] = &(zzzz_exception);
  6116.  
  6117. if(!(sub >= (*keys).key.occurs)) goto zzzz_false1;
  6118. error = - 8;
  6119. goto zzzz_finish;
  6120. zzzz_false1:
  6121.  
  6122. if(!(!map_to_sorted)) goto zzzz_false2;
  6123. subscript = sub;
  6124. if((unsigned)(subscript) >= ((*keys).key.limit1))
  6125.    if(!zzzz_resize4(&((*keys).key), (unsigned)(subscript), 50, 15)) {
  6126.       zzzz_exception = 32000;
  6127.       goto zzzz_finish;
  6128.    }
  6129. if((unsigned)(subscript) + 1 > ((*keys).key.occurs))
  6130.    ((*keys).key.occurs) = (unsigned)(subscript) + 1;
  6131. zzzz_actuals[1] = zzzz_actuals[2] = NULL;
  6132. _mc__strcpy(zzzz_actuals, &((*key)), &((((struct _tx *)((*keys).key.ptr))
  6133.  + ((subscript))) -> text));
  6134. if(zzzz_exception) {
  6135.    goto zzzz_finish;
  6136. }
  6137. goto zzzz_finish;
  6138. zzzz_false2:
  6139.  
  6140. if(!(!(*keys).map.occurs)) goto zzzz_false3;
  6141. treemap(zzzz_actuals, (((struct _bn *)((*keys).bin.ptr)) + ((0))) -> r, &((*keys)));
  6142. if(zzzz_exception) {
  6143.    goto zzzz_finish;
  6144. }
  6145. zzzz_false3:
  6146.  
  6147. subscript = (*(((int *)((*keys).map.ptr)) + ((sub))));
  6148.  
  6149. if((unsigned)(subscript) >= ((*keys).key.limit1))
  6150.    if(!zzzz_resize4(&((*keys).key), (unsigned)(subscript), 50, 15)) {
  6151.       zzzz_exception = 32000;
  6152.       goto zzzz_finish;
  6153.    }
  6154. if((unsigned)(subscript) + 1 > ((*keys).key.occurs))
  6155.    ((*keys).key.occurs) = (unsigned)(subscript) + 1;
  6156. zzzz_actuals[1] = zzzz_actuals[2] = NULL;
  6157. _mc__strcpy(zzzz_actuals, &((*key)), &((((struct _tx *)((*keys).key.ptr))
  6158.  + ((subscript))) -> text));
  6159. if(zzzz_exception) {
  6160.    goto zzzz_finish;
  6161. }
  6162.  
  6163. goto zzzz_finish;
  6164.  
  6165. zzzz_finish: ;
  6166.  
  6167. *((int *)(zzzz_return_ptr[1])) = error;
  6168.  
  6169. *((unsigned int *)(zzzz_return_ptr[3])) = subscript;
  6170.  
  6171. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6172. }
  6173.  
  6174.  
  6175.  
  6176.  
  6177. static void treemap(void *zzzz_return_ptr[], int x, struct ky *keys)
  6178. {
  6179.  
  6180. int zzzz_exception = 0;
  6181. unsigned zzzz_unsigned1;
  6182. void *zzzz_actuals[1];
  6183.  
  6184. zzzz_actuals[0] = &(zzzz_exception);
  6185.  
  6186. if(!(x != 1)) goto zzzz_false1;
  6187. treemap(zzzz_actuals, (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> l, &((*keys)));
  6188. if(zzzz_exception) {
  6189.    goto zzzz_finish;
  6190. }
  6191. zzzz_unsigned1 = (*keys).map.occurs;
  6192. if((unsigned)(zzzz_unsigned1) >= ((*keys).map.limit1))
  6193.    if(!zzzz_resize3(&((*keys).map), (unsigned)(zzzz_unsigned1), 50, 15))
  6194.  {
  6195.       zzzz_exception = 32000;
  6196.       goto zzzz_finish;
  6197.    }
  6198. if((unsigned)(zzzz_unsigned1) + 1 > ((*keys).map.occurs))
  6199.    ((*keys).map.occurs) = (unsigned)(zzzz_unsigned1) + 1;
  6200. (*(((int *)((*keys).map.ptr)) + ((zzzz_unsigned1)))) = (((struct _bn *)((*keys).bin.ptr))
  6201.  + ((x))) -> key;
  6202. treemap(zzzz_actuals, (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> r, &((*keys)));
  6203. if(zzzz_exception) {
  6204.    goto zzzz_finish;
  6205. }
  6206. zzzz_false1:
  6207.  
  6208. goto zzzz_finish;
  6209.  
  6210. zzzz_finish: ;
  6211.  
  6212. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6213. }
  6214.  
  6215.  
  6216. static void process_key(void *zzzz_return_ptr[], struct zz1D_meta *find,
  6217.  int match_case, struct zz1D_meta *keys, struct zz1D_meta *bin);
  6218. static void split(void *zzzz_return_ptr[], struct zz1D_meta *find, struct
  6219.  zz1D_meta *keys, struct zz1D_meta *bin, int match_case, int x, int parent,
  6220.   int grandparent, int great_grandparent);
  6221. static void rotate(void *zzzz_return_ptr[], struct zz1D_meta *find, int match_case,
  6222.   struct zz1D_meta *keys, struct zz1D_meta *bin, int y);
  6223. static void compare(void *zzzz_return_ptr[], struct zz1D_meta *s1, struct
  6224.  zz1D_meta *s2, int match_case);
  6225.  
  6226.  
  6227. void _mc__strkey(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
  6228.  ky *keys)
  6229. {
  6230. unsigned int subscript;
  6231. int prev_occurs;
  6232.  
  6233. int zzzz_exception = 0;
  6234. unsigned zzzz_unsigned1;
  6235. unsigned zzzz_unsigned2;
  6236. void *zzzz_actuals[2];
  6237.  
  6238. zzzz_actuals[0] = &(zzzz_exception);
  6239.  
  6240. if(!(!(*keys).zz_initialized.occurs)) goto zzzz_false1;
  6241. subscript = 0;
  6242. goto zzzz_finish;
  6243. zzzz_false1:
  6244.  
  6245. prev_occurs = (*keys).key.occurs;
  6246.  
  6247. zzzz_actuals[1] = &(subscript);
  6248. process_key(zzzz_actuals, &((*key)), (*keys).match_case, &((*keys).key),
  6249.  &((*keys).bin));
  6250. if(zzzz_exception) {
  6251.    goto zzzz_finish;
  6252. }
  6253.  
  6254. if(!(prev_occurs != (*keys).key.occurs)) goto zzzz_false2;
  6255. zzzz_unsigned1 = (*keys).map.occurs;
  6256. zzzz_unsigned2 = 0;
  6257. if((zzzz_unsigned2) > (*keys).map.limit1)
  6258.    if(!zzzz_resize3(&((*keys).map), (zzzz_unsigned2) - 1, 50, 15)) {
  6259.       zzzz_exception = 32000;
  6260.       goto zzzz_finish;
  6261.    }
  6262. (*keys).map.occurs = zzzz_unsigned2;
  6263. (*keys).map.occurs;
  6264. zzzz_false2:
  6265.  
  6266. goto zzzz_finish;
  6267.  
  6268. zzzz_finish: ;
  6269.  
  6270. *((unsigned int *)(zzzz_return_ptr[1])) = subscript;
  6271.  
  6272. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6273. }
  6274.  
  6275.  
  6276.  
  6277.  
  6278. static void process_key(void *zzzz_return_ptr[], struct zz1D_meta *find,
  6279.  int match_case, struct zz1D_meta *keys, struct zz1D_meta *bin)
  6280. {
  6281. unsigned int subscript;
  6282. int wrk1;
  6283. int x;
  6284. int result;
  6285. int add;
  6286. int parent;
  6287. int grandparent;
  6288. int great_grandparent;
  6289.  
  6290. int zzzz_exception = 0;
  6291. int zzzz_int1;
  6292. unsigned zzzz_unsigned1;
  6293. unsigned zzzz_unsigned2;
  6294. int zzzz_int2;
  6295. void *zzzz_actuals[3];
  6296.  
  6297. zzzz_actuals[0] = &(zzzz_exception);
  6298.  
  6299. if(!(!(*bin).occurs)) goto zzzz_false1;
  6300. if((unsigned)(0) >= ((*bin).limit1))
  6301.    if(!zzzz_resize5(&((*bin)), (unsigned)(0), 50, 15)) {
  6302.       zzzz_exception = 32000;
  6303.       goto zzzz_finish;
  6304.    }
  6305. if((unsigned)(0) + 1 > ((*bin).occurs))
  6306.    ((*bin).occurs) = (unsigned)(0) + 1;
  6307. (((struct _bn *)(bin->ptr)) + ((0))) -> r = 1;
  6308. if((unsigned)(0) >= ((*bin).limit1))
  6309.    if(!zzzz_resize5(&((*bin)), (unsigned)(0), 50, 15)) {
  6310.       zzzz_exception = 32000;
  6311.       goto zzzz_finish;
  6312.    }
  6313. if((unsigned)(0) + 1 > ((*bin).occurs))
  6314.    ((*bin).occurs) = (unsigned)(0) + 1;
  6315. (((struct _bn *)(bin->ptr)) + ((0))) -> red = 0;
  6316. if((unsigned)(1) >= ((*bin).limit1))
  6317.    if(!zzzz_resize5(&((*bin)), (unsigned)(1), 50, 15)) {
  6318.       zzzz_exception = 32000;
  6319.       goto zzzz_finish;
  6320.    }
  6321. if((unsigned)(1) + 1 > ((*bin).occurs))
  6322.    ((*bin).occurs) = (unsigned)(1) + 1;
  6323. (((struct _bn *)(bin->ptr)) + ((1))) -> r = 1;
  6324. if((unsigned)(1) >= ((*bin).limit1))
  6325.    if(!zzzz_resize5(&((*bin)), (unsigned)(1), 50, 15)) {
  6326.       zzzz_exception = 32000;
  6327.       goto zzzz_finish;
  6328.    }
  6329. if((unsigned)(1) + 1 > ((*bin).occurs))
  6330.    ((*bin).occurs) = (unsigned)(1) + 1;
  6331. (((struct _bn *)(bin->ptr)) + ((1))) -> l = (((struct _bn *)(bin->ptr)) +
  6332.  ((1))) -> r;
  6333. if((unsigned)(1) >= ((*bin).limit1))
  6334.    if(!zzzz_resize5(&((*bin)), (unsigned)(1), 50, 15)) {
  6335.       zzzz_exception = 32000;
  6336.       goto zzzz_finish;
  6337.    }
  6338. if((unsigned)(1) + 1 > ((*bin).occurs))
  6339.    ((*bin).occurs) = (unsigned)(1) + 1;
  6340. (((struct _bn *)(bin->ptr)) + ((1))) -> red = 0;
  6341. zzzz_false1:
  6342.  
  6343. grandparent = 0;
  6344. parent = grandparent;
  6345. x = parent;
  6346. zzzz_cont2:
  6347. if(!(x != 1)) goto zzzz_false2;
  6348. if(!(x == 0)) goto zzzz_false3;
  6349. result = 1;
  6350. goto zzzz_skip1;
  6351. zzzz_false3:
  6352. if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> key) >= ((*keys).limit1))
  6353.    if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
  6354.  ((x))) -> key), 50, 15)) {
  6355.       zzzz_exception = 32000;
  6356.       goto zzzz_finish;
  6357.    }
  6358. if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> key) + 1 > ((*keys).occurs))
  6359.    ((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((x))) ->
  6360.  key) + 1;
  6361. zzzz_actuals[1] = &(result);
  6362. compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
  6363.  _bn *)(bin->ptr)) + ((x))) -> key))) -> text), match_case);
  6364. if(zzzz_exception) {
  6365.    goto zzzz_finish;
  6366. }
  6367. zzzz_skip1:
  6368. if(!(result == 0)) goto zzzz_false4;
  6369. subscript = (((struct _bn *)(bin->ptr)) + ((x))) -> key;
  6370. goto zzzz_finish;
  6371. zzzz_false4:
  6372. great_grandparent = grandparent;
  6373. grandparent = parent;
  6374. parent = x;
  6375. if(!((result < 0))) goto zzzz_false5;
  6376. zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((x))) -> l;
  6377. goto zzzz_skip2;
  6378. zzzz_false5:
  6379. zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((x))) -> r;
  6380. zzzz_skip2:
  6381. x = zzzz_int1;
  6382. if(!((((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x)))
  6383.  -> l))) -> red)) goto zzzz_false6;
  6384. if(!((((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x)))
  6385.  -> r))) -> red)) goto zzzz_false6;
  6386. zzzz_actuals[1] = &(parent);
  6387. zzzz_actuals[2] = &(x);
  6388. split(zzzz_actuals, &((*find)), &((*keys)), &((*bin)), match_case, x, parent,
  6389.   grandparent, great_grandparent);
  6390. if(zzzz_exception) {
  6391.    goto zzzz_finish;
  6392. }
  6393. zzzz_false6:
  6394. zzzz_cont1:
  6395. goto zzzz_cont2;
  6396. zzzz_false2:
  6397.  
  6398. add = (*keys).occurs;
  6399. subscript = add;
  6400.  
  6401. if((unsigned)(add) >= ((*keys).limit1))
  6402.    if(!zzzz_resize4(&((*keys)), (unsigned)(add), 50, 15)) {
  6403.       zzzz_exception = 32000;
  6404.       goto zzzz_finish;
  6405.    }
  6406. if((unsigned)(add) + 1 > ((*keys).occurs))
  6407.    ((*keys).occurs) = (unsigned)(add) + 1;
  6408. zzzz_unsigned1 = (((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs;
  6409. zzzz_unsigned2 = (*find).occurs;
  6410. if((zzzz_unsigned2) > (((struct _tx *)(keys->ptr)) + ((add))) -> text.limit1)
  6411.    if(!zzzz_resize1(&((((struct _tx *)(keys->ptr)) + ((add))) -> text), (zzzz_unsigned2)
  6412.  - 1, 0, 15)) {
  6413.       zzzz_exception = 32000;
  6414.       goto zzzz_finish;
  6415.    }
  6416. (((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs = zzzz_unsigned2;
  6417. (((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs;
  6418.  
  6419. wrk1 = 0;
  6420. zzzz_cont4:
  6421. if(!(wrk1 < (*find).occurs)) goto zzzz_false7;
  6422. if((unsigned)(add) >= ((*keys).limit1))
  6423.    if(!zzzz_resize4(&((*keys)), (unsigned)(add), 50, 15)) {
  6424.       zzzz_exception = 32000;
  6425.       goto zzzz_finish;
  6426.    }
  6427. if((unsigned)(add) + 1 > ((*keys).occurs))
  6428.    ((*keys).occurs) = (unsigned)(add) + 1;
  6429. if((unsigned)(wrk1) >= ((((struct _tx *)(keys->ptr)) + ((add))) -> text.limit1))
  6430.    if(!zzzz_resize1(&((((struct _tx *)(keys->ptr)) + ((add))) -> text), (unsigned)(wrk1),
  6431.   0, 15)) {
  6432.       zzzz_exception = 32000;
  6433.       goto zzzz_finish;
  6434.    }
  6435. if((unsigned)(wrk1) + 1 > ((((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs))
  6436.    ((((struct _tx *)(keys->ptr)) + ((add))) -> text.occurs) = (unsigned)(wrk1)
  6437.  + 1;
  6438. (*(((char *)((((struct _tx *)(keys->ptr)) + ((add))) -> text.ptr)) + ((wrk1))))
  6439.  = (*(((char *)(find->ptr)) + ((wrk1))));
  6440. zzzz_cont3:
  6441. ++wrk1;
  6442. goto zzzz_cont4;
  6443. zzzz_false7:
  6444.  
  6445. x = (*bin).occurs;
  6446.  
  6447. if((unsigned)(x) >= ((*bin).limit1))
  6448.    if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
  6449.       zzzz_exception = 32000;
  6450.       goto zzzz_finish;
  6451.    }
  6452. if((unsigned)(x) + 1 > ((*bin).occurs))
  6453.    ((*bin).occurs) = (unsigned)(x) + 1;
  6454. (((struct _bn *)(bin->ptr)) + ((x))) -> key = add;
  6455.  
  6456. if((unsigned)(x) >= ((*bin).limit1))
  6457.    if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
  6458.       zzzz_exception = 32000;
  6459.       goto zzzz_finish;
  6460.    }
  6461. if((unsigned)(x) + 1 > ((*bin).occurs))
  6462.    ((*bin).occurs) = (unsigned)(x) + 1;
  6463. (((struct _bn *)(bin->ptr)) + ((x))) -> r = 1;
  6464. if((unsigned)(x) >= ((*bin).limit1))
  6465.    if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
  6466.       zzzz_exception = 32000;
  6467.       goto zzzz_finish;
  6468.    }
  6469. if((unsigned)(x) + 1 > ((*bin).occurs))
  6470.    ((*bin).occurs) = (unsigned)(x) + 1;
  6471. (((struct _bn *)(bin->ptr)) + ((x))) -> l = (((struct _bn *)(bin->ptr)) +
  6472.  ((x))) -> r;
  6473.  
  6474. if(!(parent == 0)) goto zzzz_false8;
  6475. result = 1;
  6476. goto zzzz_skip3;
  6477. zzzz_false8:
  6478. if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) >= ((*keys).limit1))
  6479.    if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
  6480.  ((parent))) -> key), 50, 15)) {
  6481.       zzzz_exception = 32000;
  6482.       goto zzzz_finish;
  6483.    }
  6484. if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) + 1 > ((*keys).occurs))
  6485.    ((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((parent)))
  6486.  -> key) + 1;
  6487. zzzz_actuals[1] = &(result);
  6488. compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
  6489.  _bn *)(bin->ptr)) + ((parent))) -> key))) -> text), match_case);
  6490. if(zzzz_exception) {
  6491.    goto zzzz_finish;
  6492. }
  6493. zzzz_skip3:
  6494.  
  6495. if(!(result < 0)) goto zzzz_false9;
  6496. if((unsigned)(parent) >= ((*bin).limit1))
  6497.    if(!zzzz_resize5(&((*bin)), (unsigned)(parent), 50, 15)) {
  6498.       zzzz_exception = 32000;
  6499.       goto zzzz_finish;
  6500.    }
  6501. if((unsigned)(parent) + 1 > ((*bin).occurs))
  6502.    ((*bin).occurs) = (unsigned)(parent) + 1;
  6503. (((struct _bn *)(bin->ptr)) + ((parent))) -> l = x;
  6504. goto zzzz_skip4;
  6505. zzzz_false9:
  6506. if((unsigned)(parent) >= ((*bin).limit1))
  6507.    if(!zzzz_resize5(&((*bin)), (unsigned)(parent), 50, 15)) {
  6508.       zzzz_exception = 32000;
  6509.       goto zzzz_finish;
  6510.    }
  6511. if((unsigned)(parent) + 1 > ((*bin).occurs))
  6512.    ((*bin).occurs) = (unsigned)(parent) + 1;
  6513. (((struct _bn *)(bin->ptr)) + ((parent))) -> r = x;
  6514. zzzz_skip4:
  6515.  
  6516. zzzz_actuals[1] = &(zzzz_int1);
  6517. zzzz_actuals[2] = &(zzzz_int2);
  6518. split(zzzz_actuals, &((*find)), &((*keys)), &((*bin)), match_case, x, parent,
  6519.   grandparent, great_grandparent);
  6520. if(zzzz_exception) {
  6521.    goto zzzz_finish;
  6522. }
  6523.  
  6524. goto zzzz_finish;
  6525.  
  6526. zzzz_finish: ;
  6527.  
  6528. *((unsigned int *)(zzzz_return_ptr[1])) = subscript;
  6529.  
  6530. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6531. }
  6532.  
  6533.  
  6534.  
  6535.  
  6536. static void split(void *zzzz_return_ptr[], struct zz1D_meta *find, struct
  6537.  zz1D_meta *keys, struct zz1D_meta *bin, int match_case, int x, int parent,
  6538.   int grandparent, int great_grandparent)
  6539. {
  6540. int pp;
  6541. int xx;
  6542. int res1;
  6543. int res2;
  6544.  
  6545. int zzzz_exception = 0;
  6546. void *zzzz_actuals[2];
  6547.  
  6548. zzzz_actuals[0] = &(zzzz_exception);
  6549.  
  6550. if((unsigned)(x) >= ((*bin).limit1))
  6551.    if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
  6552.       zzzz_exception = 32000;
  6553.       goto zzzz_finish;
  6554.    }
  6555. if((unsigned)(x) + 1 > ((*bin).occurs))
  6556.    ((*bin).occurs) = (unsigned)(x) + 1;
  6557. (((struct _bn *)(bin->ptr)) + ((x))) -> red = 1;
  6558.  
  6559. if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> r) >= ((*bin).limit1))
  6560.    if(!zzzz_resize5(&((*bin)), (unsigned)((((struct _bn *)(bin->ptr)) + ((x)))
  6561.  -> r), 50, 15)) {
  6562.       zzzz_exception = 32000;
  6563.       goto zzzz_finish;
  6564.    }
  6565. if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> r) + 1 > ((*bin).occurs))
  6566.    ((*bin).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> r)
  6567.  + 1;
  6568. (((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x))) -> r)))
  6569.  -> red = 0;
  6570. if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> l) >= ((*bin).limit1))
  6571.    if(!zzzz_resize5(&((*bin)), (unsigned)((((struct _bn *)(bin->ptr)) + ((x)))
  6572.  -> l), 50, 15)) {
  6573.       zzzz_exception = 32000;
  6574.       goto zzzz_finish;
  6575.    }
  6576. if((unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> l) + 1 > ((*bin).occurs))
  6577.    ((*bin).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((x))) -> l)
  6578.  + 1;
  6579. (((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x))) -> l)))
  6580.  -> red = (((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((x)))
  6581.  -> r))) -> red;
  6582.  
  6583. if(!((((struct _bn *)(bin->ptr)) + ((parent))) -> red)) goto zzzz_false4;
  6584. if((unsigned)(grandparent) >= ((*bin).limit1))
  6585.    if(!zzzz_resize5(&((*bin)), (unsigned)(grandparent), 50, 15)) {
  6586.       zzzz_exception = 32000;
  6587.       goto zzzz_finish;
  6588.    }
  6589. if((unsigned)(grandparent) + 1 > ((*bin).occurs))
  6590.    ((*bin).occurs) = (unsigned)(grandparent) + 1;
  6591. (((struct _bn *)(bin->ptr)) + ((grandparent))) -> red = 1;
  6592. if(!(grandparent == 0)) goto zzzz_false1;
  6593. res1 = 1;
  6594. goto zzzz_skip1;
  6595. zzzz_false1:
  6596. if((unsigned)((((struct _bn *)(bin->ptr)) + ((grandparent))) -> key) >= ((*keys).limit1))
  6597.    if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
  6598.  ((grandparent))) -> key), 50, 15)) {
  6599.       zzzz_exception = 32000;
  6600.       goto zzzz_finish;
  6601.    }
  6602. if((unsigned)((((struct _bn *)(bin->ptr)) + ((grandparent))) -> key) + 1
  6603.  > ((*keys).occurs))
  6604.    ((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((grandparent)))
  6605.  -> key) + 1;
  6606. zzzz_actuals[1] = &(res1);
  6607. compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
  6608.  _bn *)(bin->ptr)) + ((grandparent))) -> key))) -> text), match_case);
  6609. if(zzzz_exception) {
  6610.    goto zzzz_finish;
  6611. }
  6612. zzzz_skip1:
  6613. if(!(parent == 0)) goto zzzz_false2;
  6614. res2 = 1;
  6615. goto zzzz_skip2;
  6616. zzzz_false2:
  6617. if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) >= ((*keys).limit1))
  6618.    if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
  6619.  ((parent))) -> key), 50, 15)) {
  6620.       zzzz_exception = 32000;
  6621.       goto zzzz_finish;
  6622.    }
  6623. if((unsigned)((((struct _bn *)(bin->ptr)) + ((parent))) -> key) + 1 > ((*keys).occurs))
  6624.    ((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((parent)))
  6625.  -> key) + 1;
  6626. zzzz_actuals[1] = &(res2);
  6627. compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
  6628.  _bn *)(bin->ptr)) + ((parent))) -> key))) -> text), match_case);
  6629. if(zzzz_exception) {
  6630.    goto zzzz_finish;
  6631. }
  6632. zzzz_skip2:
  6633. if(!(res1 != res2)) goto zzzz_false3;
  6634. zzzz_actuals[1] = &(parent);
  6635. rotate(zzzz_actuals, &((*find)), match_case, &((*keys)), &((*bin)), grandparent);
  6636. if(zzzz_exception) {
  6637.    goto zzzz_finish;
  6638. }
  6639. zzzz_false3:
  6640. zzzz_actuals[1] = &(x);
  6641. rotate(zzzz_actuals, &((*find)), match_case, &((*keys)), &((*bin)), great_grandparent);
  6642. if(zzzz_exception) {
  6643.    goto zzzz_finish;
  6644. }
  6645. if((unsigned)(x) >= ((*bin).limit1))
  6646.    if(!zzzz_resize5(&((*bin)), (unsigned)(x), 50, 15)) {
  6647.       zzzz_exception = 32000;
  6648.       goto zzzz_finish;
  6649.    }
  6650. if((unsigned)(x) + 1 > ((*bin).occurs))
  6651.    ((*bin).occurs) = (unsigned)(x) + 1;
  6652. (((struct _bn *)(bin->ptr)) + ((x))) -> red = 0;
  6653. zzzz_false4:
  6654.  
  6655. if((unsigned)((((struct _bn *)(bin->ptr)) + ((0))) -> r) >= ((*bin).limit1))
  6656.    if(!zzzz_resize5(&((*bin)), (unsigned)((((struct _bn *)(bin->ptr)) + ((0)))
  6657.  -> r), 50, 15)) {
  6658.       zzzz_exception = 32000;
  6659.       goto zzzz_finish;
  6660.    }
  6661. if((unsigned)((((struct _bn *)(bin->ptr)) + ((0))) -> r) + 1 > ((*bin).occurs))
  6662.    ((*bin).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((0))) -> r)
  6663.  + 1;
  6664. (((struct _bn *)(bin->ptr)) + (((((struct _bn *)(bin->ptr)) + ((0))) -> r)))
  6665.  -> red = 0;
  6666.  
  6667. pp = parent;
  6668.  
  6669. xx = x;
  6670.  
  6671. goto zzzz_finish;
  6672.  
  6673. zzzz_finish: ;
  6674.  
  6675. *((int *)(zzzz_return_ptr[1])) = pp;
  6676.  
  6677. *((int *)(zzzz_return_ptr[2])) = xx;
  6678.  
  6679. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6680. }
  6681.  
  6682.  
  6683.  
  6684.  
  6685. static void rotate(void *zzzz_return_ptr[], struct zz1D_meta *find, int match_case,
  6686.   struct zz1D_meta *keys, struct zz1D_meta *bin, int y)
  6687. {
  6688. int gc;
  6689. int c;
  6690. int res1;
  6691. int res2;
  6692.  
  6693. int zzzz_exception = 0;
  6694. int zzzz_int1;
  6695. void *zzzz_actuals[2];
  6696.  
  6697. zzzz_actuals[0] = &(zzzz_exception);
  6698.  
  6699. if(!(y == 0)) goto zzzz_false1;
  6700. res1 = 1;
  6701. goto zzzz_skip1;
  6702. zzzz_false1:
  6703. if((unsigned)((((struct _bn *)(bin->ptr)) + ((y))) -> key) >= ((*keys).limit1))
  6704.    if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
  6705.  ((y))) -> key), 50, 15)) {
  6706.       zzzz_exception = 32000;
  6707.       goto zzzz_finish;
  6708.    }
  6709. if((unsigned)((((struct _bn *)(bin->ptr)) + ((y))) -> key) + 1 > ((*keys).occurs))
  6710.    ((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((y))) ->
  6711.  key) + 1;
  6712. zzzz_actuals[1] = &(res1);
  6713. compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
  6714.  _bn *)(bin->ptr)) + ((y))) -> key))) -> text), match_case);
  6715. if(zzzz_exception) {
  6716.    goto zzzz_finish;
  6717. }
  6718. zzzz_skip1:
  6719.  
  6720. if(!((res1 < 0))) goto zzzz_false2;
  6721. zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((y))) -> l;
  6722. goto zzzz_skip2;
  6723. zzzz_false2:
  6724. zzzz_int1 = (((struct _bn *)(bin->ptr)) + ((y))) -> r;
  6725. zzzz_skip2:
  6726. c = zzzz_int1;
  6727.  
  6728. if(!(c == 0)) goto zzzz_false3;
  6729. res2 = 1;
  6730. goto zzzz_skip3;
  6731. zzzz_false3:
  6732. if((unsigned)((((struct _bn *)(bin->ptr)) + ((c))) -> key) >= ((*keys).limit1))
  6733.    if(!zzzz_resize4(&((*keys)), (unsigned)((((struct _bn *)(bin->ptr)) +
  6734.  ((c))) -> key), 50, 15)) {
  6735.       zzzz_exception = 32000;
  6736.       goto zzzz_finish;
  6737.    }
  6738. if((unsigned)((((struct _bn *)(bin->ptr)) + ((c))) -> key) + 1 > ((*keys).occurs))
  6739.    ((*keys).occurs) = (unsigned)((((struct _bn *)(bin->ptr)) + ((c))) ->
  6740.  key) + 1;
  6741. zzzz_actuals[1] = &(res2);
  6742. compare(zzzz_actuals, &((*find)), &((((struct _tx *)(keys->ptr)) + (((((struct
  6743.  _bn *)(bin->ptr)) + ((c))) -> key))) -> text), match_case);
  6744. if(zzzz_exception) {
  6745.    goto zzzz_finish;
  6746. }
  6747. zzzz_skip3:
  6748.  
  6749. if(!(res2 < 0)) goto zzzz_false4;
  6750. gc = (((struct _bn *)(bin->ptr)) + ((c))) -> l;
  6751. if((unsigned)(c) >= ((*bin).limit1))
  6752.    if(!zzzz_resize5(&((*bin)), (unsigned)(c), 50, 15)) {
  6753.       zzzz_exception = 32000;
  6754.       goto zzzz_finish;
  6755.    }
  6756. if((unsigned)(c) + 1 > ((*bin).occurs))
  6757.    ((*bin).occurs) = (unsigned)(c) + 1;
  6758. (((struct _bn *)(bin->ptr)) + ((c))) -> l = (((struct _bn *)(bin->ptr)) +
  6759.  ((gc))) -> r;
  6760. if((unsigned)(gc) >= ((*bin).limit1))
  6761.    if(!zzzz_resize5(&((*bin)), (unsigned)(gc), 50, 15)) {
  6762.       zzzz_exception = 32000;
  6763.       goto zzzz_finish;
  6764.    }
  6765. if((unsigned)(gc) + 1 > ((*bin).occurs))
  6766.    ((*bin).occurs) = (unsigned)(gc) + 1;
  6767. (((struct _bn *)(bin->ptr)) + ((gc))) -> r = c;
  6768. goto zzzz_skip4;
  6769. zzzz_false4:
  6770. gc = (((struct _bn *)(bin->ptr)) + ((c))) -> r;
  6771. if((unsigned)(c) >= ((*bin).limit1))
  6772.    if(!zzzz_resize5(&((*bin)), (unsigned)(c), 50, 15)) {
  6773.       zzzz_exception = 32000;
  6774.       goto zzzz_finish;
  6775.    }
  6776. if((unsigned)(c) + 1 > ((*bin).occurs))
  6777.    ((*bin).occurs) = (unsigned)(c) + 1;
  6778. (((struct _bn *)(bin->ptr)) + ((c))) -> r = (((struct _bn *)(bin->ptr)) +
  6779.  ((gc))) -> l;
  6780. if((unsigned)(gc) >= ((*bin).limit1))
  6781.    if(!zzzz_resize5(&((*bin)), (unsigned)(gc), 50, 15)) {
  6782.       zzzz_exception = 32000;
  6783.       goto zzzz_finish;
  6784.    }
  6785. if((unsigned)(gc) + 1 > ((*bin).occurs))
  6786.    ((*bin).occurs) = (unsigned)(gc) + 1;
  6787. (((struct _bn *)(bin->ptr)) + ((gc))) -> l = c;
  6788. zzzz_skip4:
  6789.  
  6790. if(!(res1 < 0)) goto zzzz_false5;
  6791. if((unsigned)(y) >= ((*bin).limit1))
  6792.    if(!zzzz_resize5(&((*bin)), (unsigned)(y), 50, 15)) {
  6793.       zzzz_exception = 32000;
  6794.       goto zzzz_finish;
  6795.    }
  6796. if((unsigned)(y) + 1 > ((*bin).occurs))
  6797.    ((*bin).occurs) = (unsigned)(y) + 1;
  6798. (((struct _bn *)(bin->ptr)) + ((y))) -> l = gc;
  6799. goto zzzz_skip5;
  6800. zzzz_false5:
  6801. if((unsigned)(y) >= ((*bin).limit1))
  6802.    if(!zzzz_resize5(&((*bin)), (unsigned)(y), 50, 15)) {
  6803.       zzzz_exception = 32000;
  6804.       goto zzzz_finish;
  6805.    }
  6806. if((unsigned)(y) + 1 > ((*bin).occurs))
  6807.    ((*bin).occurs) = (unsigned)(y) + 1;
  6808. (((struct _bn *)(bin->ptr)) + ((y))) -> r = gc;
  6809. zzzz_skip5:
  6810.  
  6811. goto zzzz_finish;
  6812.  
  6813. zzzz_finish: ;
  6814.  
  6815. *((int *)(zzzz_return_ptr[1])) = gc;
  6816.  
  6817. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6818. }
  6819.  
  6820.  
  6821.  
  6822.  
  6823. static void compare(void *zzzz_return_ptr[], struct zz1D_meta *s1, struct
  6824.  zz1D_meta *s2, int match_case)
  6825. {
  6826. int result;
  6827. int wrk1;
  6828. int occurs1;
  6829. int occurs2;
  6830.  
  6831. int zzzz_exception = 0;
  6832. unsigned char zzzz_unsigned_char1;
  6833. unsigned char zzzz_unsigned_char2;
  6834. int zzzz_int1;
  6835. unsigned char zzzz_unsigned_char3;
  6836. unsigned char zzzz_unsigned_char4;
  6837. int zzzz_int2;
  6838.  
  6839.  
  6840. occurs1 = (*s1).occurs;
  6841.  
  6842. occurs2 = (*s2).occurs;
  6843.  
  6844. result = 0;
  6845. wrk1 = result;
  6846. zzzz_cont2:
  6847. if(!(wrk1 < occurs1)) goto zzzz_false2;
  6848. if(!(wrk1 < occurs2)) goto zzzz_false2;
  6849. if(!(match_case)) goto zzzz_false3;
  6850. zzzz_int1 = ((*(((char *)(s1->ptr)) + ((wrk1)))) != (*(((char *)(s2->ptr))
  6851.  + ((wrk1)))));
  6852. goto zzzz_skip1;
  6853. zzzz_false3:
  6854. zzzz_unsigned_char1 = ((unsigned char)(((*(((char *)(s1->ptr)) + ((wrk1)))))));
  6855. zzzz_unsigned_char2 = ((unsigned char)(((*(((char *)(s2->ptr)) + ((wrk1)))))));
  6856. zzzz_int1 = ((((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char1)))))))
  6857.  != (((char)((*(((unsigned char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char2))))))));
  6858. zzzz_skip1:
  6859. if(!(zzzz_int1)) goto zzzz_false6;
  6860. if(!(match_case)) goto zzzz_false4;
  6861. zzzz_int2 = (((unsigned char)((*(((char *)(s1->ptr)) + ((wrk1)))))) < ((unsigned
  6862.  char)((*(((char *)(s2->ptr)) + ((wrk1)))))));
  6863. goto zzzz_skip2;
  6864. zzzz_false4:
  6865. zzzz_unsigned_char3 = ((unsigned char)(((*(((char *)(s1->ptr)) + ((wrk1)))))));
  6866. zzzz_unsigned_char4 = ((unsigned char)(((*(((char *)(s2->ptr)) + ((wrk1)))))));
  6867. zzzz_int2 = (((unsigned char)((((char)((*(((unsigned char *)(_MC_lower.ptr))
  6868.  + ((zzzz_unsigned_char3))))))))) < ((unsigned char)((((char)((*(((unsigned
  6869.  char *)(_MC_lower.ptr)) + ((zzzz_unsigned_char4))))))))));
  6870. zzzz_skip2:
  6871. if(!(zzzz_int2)) goto zzzz_false5;
  6872. result = - 1;
  6873. goto zzzz_skip3;
  6874. zzzz_false5:
  6875. result = 1;
  6876. zzzz_skip3:
  6877. goto zzzz_false1;
  6878. zzzz_false6:
  6879. goto zzzz_skip6;
  6880. zzzz_false2:
  6881. if(!(wrk1 >= occurs1)) goto zzzz_false7;
  6882. if(!(wrk1 >= occurs2)) goto zzzz_false7;
  6883. goto zzzz_false1;
  6884. goto zzzz_skip5;
  6885. zzzz_false7:
  6886. if(!(wrk1 >= occurs1)) goto zzzz_false8;
  6887. result = - 1;
  6888. goto zzzz_false1;
  6889. goto zzzz_skip4;
  6890. zzzz_false8:
  6891. result = 1;
  6892. goto zzzz_false1;
  6893. zzzz_skip4:
  6894. zzzz_skip5:
  6895. zzzz_skip6:
  6896. zzzz_cont1:
  6897. ++wrk1;
  6898. goto zzzz_cont2;
  6899. zzzz_false1:
  6900.  
  6901. goto zzzz_finish;
  6902.  
  6903. zzzz_finish: ;
  6904.  
  6905. *((int *)(zzzz_return_ptr[1])) = result;
  6906.  
  6907. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6908. }
  6909.  
  6910.  
  6911.  
  6912.  
  6913. void _mc__strkfnd(void *zzzz_return_ptr[], struct zz1D_meta *key, struct
  6914.  ky *keys)
  6915. {
  6916. int error = -2;
  6917. unsigned int subscript = 0;
  6918. int x;
  6919. int result;
  6920.  
  6921. int zzzz_exception = 0;
  6922. int zzzz_int1;
  6923. void *zzzz_actuals[2];
  6924.  
  6925. zzzz_actuals[0] = &(zzzz_exception);
  6926.  
  6927. if(!(!(*keys).key.occurs)) goto zzzz_false1;
  6928. goto zzzz_finish;
  6929. zzzz_false1:
  6930.  
  6931. x = (((struct _bn *)((*keys).bin.ptr)) + ((0))) -> r;
  6932. zzzz_cont2:
  6933. if(!(x != 1)) goto zzzz_false2;
  6934. if((unsigned)((((struct _bn *)((*keys).bin.ptr)) + ((x))) -> key) >= ((*keys).key.limit1))
  6935.    if(!zzzz_resize4(&((*keys).key), (unsigned)((((struct _bn *)((*keys).bin.ptr))
  6936.  + ((x))) -> key), 50, 15)) {
  6937.       zzzz_exception = 32000;
  6938.       goto zzzz_finish;
  6939.    }
  6940. if((unsigned)((((struct _bn *)((*keys).bin.ptr)) + ((x))) -> key) + 1 > ((*keys).key.occurs))
  6941.    ((*keys).key.occurs) = (unsigned)((((struct _bn *)((*keys).bin.ptr)) +
  6942.  ((x))) -> key) + 1;
  6943. zzzz_actuals[1] = &(result);
  6944. compare(zzzz_actuals, &((*key)), &((((struct _tx *)((*keys).key.ptr)) + (((((struct
  6945.  _bn *)((*keys).bin.ptr)) + ((x))) -> key))) -> text), (*keys).match_case);
  6946. if(zzzz_exception) {
  6947.    goto zzzz_finish;
  6948. }
  6949. if(!(result == 0)) goto zzzz_false3;
  6950. error = 0;
  6951. subscript = (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> key;
  6952. goto zzzz_finish;
  6953. zzzz_false3:
  6954. if(!((result < 0))) goto zzzz_false4;
  6955. zzzz_int1 = (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> l;
  6956. goto zzzz_skip1;
  6957. zzzz_false4:
  6958. zzzz_int1 = (((struct _bn *)((*keys).bin.ptr)) + ((x))) -> r;
  6959. zzzz_skip1:
  6960. x = zzzz_int1;
  6961. zzzz_cont1:
  6962. goto zzzz_cont2;
  6963. zzzz_false2:
  6964.  
  6965. goto zzzz_finish;
  6966.  
  6967. zzzz_finish: ;
  6968.  
  6969. *((int *)(zzzz_return_ptr[1])) = error;
  6970.  
  6971. *((unsigned int *)(zzzz_return_ptr[2])) = subscript;
  6972.  
  6973. *((int *)(zzzz_return_ptr[0])) = zzzz_exception;
  6974. }
  6975.  
  6976.  
  6977.  
  6978.  
  6979.  
  6980. static int zzzz_resize1(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
  6981.   int resize_pct1)
  6982. {
  6983.  
  6984. unsigned new_size, lim_a, lim_b, lim_c;
  6985. void *new_ptr;
  6986. struct zz1D_meta old;
  6987. unsigned new_limit1;
  6988.  
  6989. if(sub1 >= meta->limit1) {
  6990.    lim_a = sub1 + 1;
  6991.    lim_b = resize_num1 + meta->limit1;
  6992.    lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
  6993.    if(lim_a > lim_b)
  6994.       {if(lim_a > lim_c)
  6995.           new_limit1 = lim_a;
  6996.        else
  6997.           new_limit1 = lim_c;}
  6998.    else if(lim_b > lim_c)
  6999.        new_limit1 = lim_b;
  7000.    else
  7001.        new_limit1 = lim_c;
  7002.    }
  7003. else
  7004.    new_limit1 = meta->limit1;
  7005.  
  7006. new_size = new_limit1;
  7007.  
  7008. if(meta->limit1 == 0) {
  7009.    new_ptr = malloc(new_size);
  7010.    if(new_ptr == NULL)
  7011.       return FALSE;
  7012.    }
  7013. else
  7014.    {
  7015.    new_ptr = realloc(meta->ptr, new_size);
  7016.    if(new_ptr == NULL)
  7017.       return FALSE;
  7018.    }
  7019.  
  7020. meta->ptr = new_ptr;
  7021. old = *meta;
  7022. meta->limit1 = new_limit1;
  7023.  
  7024.  
  7025. return TRUE;
  7026. }
  7027.  
  7028.  
  7029. static int zzzz_resize2(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
  7030.   int resize_pct1)
  7031. {
  7032.  
  7033. unsigned zzzz_imw1;
  7034. unsigned new_size, lim_a, lim_b, lim_c;
  7035. void *new_ptr;
  7036. struct zz1D_meta old;
  7037. unsigned new_limit1;
  7038.  
  7039. if(sub1 >= meta->limit1) {
  7040.    lim_a = sub1 + 1;
  7041.    lim_b = resize_num1 + meta->limit1;
  7042.    lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
  7043.    if(lim_a > lim_b)
  7044.       {if(lim_a > lim_c)
  7045.           new_limit1 = lim_a;
  7046.        else
  7047.           new_limit1 = lim_c;}
  7048.    else if(lim_b > lim_c)
  7049.        new_limit1 = lim_b;
  7050.    else
  7051.        new_limit1 = lim_c;
  7052.    }
  7053. else
  7054.    new_limit1 = meta->limit1;
  7055.  
  7056. new_size = sizeof(struct _fsm);
  7057. if((new_size * new_limit1) / new_size != new_limit1)
  7058.    return FALSE;
  7059. new_size *= new_limit1;
  7060.  
  7061. if(meta->limit1 == 0) {
  7062.    new_ptr = malloc(new_size);
  7063.    if(new_ptr == NULL)
  7064.       return FALSE;
  7065.    }
  7066. else
  7067.    {
  7068.    new_ptr = realloc(meta->ptr, new_size);
  7069.    if(new_ptr == NULL)
  7070.       return FALSE;
  7071.    }
  7072.  
  7073. meta->ptr = new_ptr;
  7074. old = *meta;
  7075. meta->limit1 = new_limit1;
  7076.  
  7077. for(zzzz_imw1 = old.limit1; zzzz_imw1 < meta->limit1; ++zzzz_imw1) {
  7078.    (((struct _fsm *)(meta->ptr)) + (zzzz_imw1)) -> cset.occurs = 0;
  7079.    (((struct _fsm *)(meta->ptr)) + (zzzz_imw1)) -> cset.limit1 = 0;
  7080. }
  7081.  
  7082. return TRUE;
  7083. }
  7084.  
  7085.  
  7086. static int zzzz_resize3(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
  7087.   int resize_pct1)
  7088. {
  7089.  
  7090. unsigned new_size, lim_a, lim_b, lim_c;
  7091. void *new_ptr;
  7092. struct zz1D_meta old;
  7093. unsigned new_limit1;
  7094.  
  7095. if(sub1 >= meta->limit1) {
  7096.    lim_a = sub1 + 1;
  7097.    lim_b = resize_num1 + meta->limit1;
  7098.    lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
  7099.    if(lim_a > lim_b)
  7100.       {if(lim_a > lim_c)
  7101.           new_limit1 = lim_a;
  7102.        else
  7103.           new_limit1 = lim_c;}
  7104.    else if(lim_b > lim_c)
  7105.        new_limit1 = lim_b;
  7106.    else
  7107.        new_limit1 = lim_c;
  7108.    }
  7109. else
  7110.    new_limit1 = meta->limit1;
  7111.  
  7112. new_size = sizeof(int);
  7113. if((new_size * new_limit1) / new_size != new_limit1)
  7114.    return FALSE;
  7115. new_size *= new_limit1;
  7116.  
  7117. if(meta->limit1 == 0) {
  7118.    new_ptr = malloc(new_size);
  7119.    if(new_ptr == NULL)
  7120.       return FALSE;
  7121.    }
  7122. else
  7123.    {
  7124.    new_ptr = realloc(meta->ptr, new_size);
  7125.    if(new_ptr == NULL)
  7126.       return FALSE;
  7127.    }
  7128.  
  7129. meta->ptr = new_ptr;
  7130. old = *meta;
  7131. meta->limit1 = new_limit1;
  7132.  
  7133.  
  7134. return TRUE;
  7135. }
  7136.  
  7137.  
  7138. static int zzzz_resize4(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
  7139.   int resize_pct1)
  7140. {
  7141.  
  7142. unsigned zzzz_imw1;
  7143. unsigned new_size, lim_a, lim_b, lim_c;
  7144. void *new_ptr;
  7145. struct zz1D_meta old;
  7146. unsigned new_limit1;
  7147.  
  7148. if(sub1 >= meta->limit1) {
  7149.    lim_a = sub1 + 1;
  7150.    lim_b = resize_num1 + meta->limit1;
  7151.    lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
  7152.    if(lim_a > lim_b)
  7153.       {if(lim_a > lim_c)
  7154.           new_limit1 = lim_a;
  7155.        else
  7156.           new_limit1 = lim_c;}
  7157.    else if(lim_b > lim_c)
  7158.        new_limit1 = lim_b;
  7159.    else
  7160.        new_limit1 = lim_c;
  7161.    }
  7162. else
  7163.    new_limit1 = meta->limit1;
  7164.  
  7165. new_size = sizeof(struct _tx);
  7166. if((new_size * new_limit1) / new_size != new_limit1)
  7167.    return FALSE;
  7168. new_size *= new_limit1;
  7169.  
  7170. if(meta->limit1 == 0) {
  7171.    new_ptr = malloc(new_size);
  7172.    if(new_ptr == NULL)
  7173.       return FALSE;
  7174.    }
  7175. else
  7176.    {
  7177.    new_ptr = realloc(meta->ptr, new_size);
  7178.    if(new_ptr == NULL)
  7179.       return FALSE;
  7180.    }
  7181.  
  7182. meta->ptr = new_ptr;
  7183. old = *meta;
  7184. meta->limit1 = new_limit1;
  7185.  
  7186. for(zzzz_imw1 = old.limit1; zzzz_imw1 < meta->limit1; ++zzzz_imw1) {
  7187.    (((struct _tx *)(meta->ptr)) + (zzzz_imw1)) -> text.occurs = 0;
  7188.    (((struct _tx *)(meta->ptr)) + (zzzz_imw1)) -> text.limit1 = 0;
  7189. }
  7190.  
  7191. return TRUE;
  7192. }
  7193.  
  7194.  
  7195. static int zzzz_resize5(struct zz1D_meta *meta, unsigned sub1, int resize_num1,
  7196.   int resize_pct1)
  7197. {
  7198.  
  7199. unsigned new_size, lim_a, lim_b, lim_c;
  7200. void *new_ptr;
  7201. struct zz1D_meta old;
  7202. unsigned new_limit1;
  7203.  
  7204. if(sub1 >= meta->limit1) {
  7205.    lim_a = sub1 + 1;
  7206.    lim_b = resize_num1 + meta->limit1;
  7207.    lim_c = resize_pct1 * (meta->limit1 / 100) + meta->limit1;
  7208.    if(lim_a > lim_b)
  7209.       {if(lim_a > lim_c)
  7210.           new_limit1 = lim_a;
  7211.        else
  7212.           new_limit1 = lim_c;}
  7213.    else if(lim_b > lim_c)
  7214.        new_limit1 = lim_b;
  7215.    else
  7216.        new_limit1 = lim_c;
  7217.    }
  7218. else
  7219.    new_limit1 = meta->limit1;
  7220.  
  7221. new_size = sizeof(struct _bn);
  7222. if((new_size * new_limit1) / new_size != new_limit1)
  7223.    return FALSE;
  7224. new_size *= new_limit1;
  7225.  
  7226. if(meta->limit1 == 0) {
  7227.    new_ptr = malloc(new_size);
  7228.    if(new_ptr == NULL)
  7229.       return FALSE;
  7230.    }
  7231. else
  7232.    {
  7233.    new_ptr = realloc(meta->ptr, new_size);
  7234.    if(new_ptr == NULL)
  7235.       return FALSE;
  7236.    }
  7237.  
  7238. meta->ptr = new_ptr;
  7239. old = *meta;
  7240. meta->limit1 = new_limit1;
  7241.  
  7242.  
  7243. return TRUE;
  7244. }
  7245.