home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09964.iso / program / mc.exe / MC_LIB.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-07  |  204.9 KB  |  7,214 lines

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