home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / js / src / jsstr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  118.2 KB  |  3,332 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * JS string type implementation.
  21.  *
  22.  * In order to avoid unnecessary JS_LockGCThing/JS_UnlockGCThing calls, these
  23.  * native methods store strings (possibly newborn) converted from their 'this'
  24.  * parameter and arguments on the stack: 'this' conversions at argv[-1], arg
  25.  * conversions at their index (argv[0], argv[1]).  This is a legitimate method
  26.  * of rooting newborns that might lose their newborn root due to subsequent GC
  27.  * allocations in the same native method.
  28.  */
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include "prtypes.h"
  32. #include "prlog.h"
  33. #ifndef NSPR20
  34. #include "prhash.h"
  35. #else
  36. #include "plhash.h"
  37. #endif
  38. #include "prprf.h"
  39. #include "jsapi.h"
  40. #include "jsarray.h"
  41. #include "jsatom.h"
  42. #include "jsbool.h"
  43. #include "jscntxt.h"
  44. #include "jsconfig.h"
  45. #include "jsgc.h"
  46. #include "jslock.h"
  47. #include "jsnum.h"
  48. #include "jsobj.h"
  49. #include "jsregexp.h"
  50. #include "jsstr.h"
  51.  
  52. #if JS_HAS_REPLACE_LAMBDA
  53. #include "jsinterp.h"
  54. #endif
  55.  
  56. jschar      js_empty_ucstr[]  = {0};
  57. JSSubString js_EmptySubString = {0, js_empty_ucstr};
  58.  
  59. static JSBool
  60. str_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
  61.  
  62. static JSBool
  63. str_enumerate(JSContext *cx, JSObject *obj);
  64.  
  65. static JSBool
  66. str_resolve(JSContext *cx, JSObject *obj, jsval id);
  67.  
  68. static JSClass string_class = {
  69.     "String",
  70.     JSCLASS_HAS_PRIVATE,
  71.     JS_PropertyStub,  JS_PropertyStub,  str_getProperty,  JS_PropertyStub,
  72.     str_enumerate,    str_resolve,      JS_ConvertStub,   JS_FinalizeStub
  73. };
  74.  
  75. enum string_tinyid {
  76.     STRING_LENGTH = -1
  77. };
  78.  
  79. static JSPropertySpec string_props[] = {
  80.     {js_length_str,     STRING_LENGTH,  JSPROP_READONLY},
  81.     {0}
  82. };
  83.  
  84. static JSBool
  85. str_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
  86. {
  87.     JSString *str;
  88.  
  89.     if (!JSVAL_IS_INT(id))
  90.     return JS_TRUE;
  91.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  92.     if (!str)
  93.     return JS_FALSE;
  94.     if (JSVAL_TO_INT(id) == STRING_LENGTH)
  95.     *vp = INT_TO_JSVAL((jsint)str->length);
  96.     return JS_TRUE;
  97. }
  98.  
  99. static JSBool
  100. str_resolve1(JSContext *cx, JSObject *obj, JSString *str, jsint slot)
  101. {
  102.     jschar buf[2];
  103.     JSString *str1;
  104.  
  105.     buf[0] = str->chars[slot];
  106.     buf[1] = 0;
  107.     str1 = js_NewStringCopyN(cx, buf, 1, 0);
  108.     if (!str1)
  109.     return JS_FALSE;
  110.     return JS_DefineElement(cx, obj, slot, STRING_TO_JSVAL(str1),
  111.                 JS_PropertyStub, JS_PropertyStub,
  112.                 JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT);
  113. }
  114.  
  115. static JSBool
  116. str_enumerate(JSContext *cx, JSObject *obj)
  117. {
  118.     JSString *str;
  119.     JSBool ok;
  120.     jsint i;
  121.  
  122.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  123.     if (!str)
  124.     return JS_FALSE;
  125.     ok = JS_TRUE;
  126.     JS_LockGCThing(cx, str);
  127.     for (i = 0; i < (jsint)str->length; i++) {
  128.     ok = str_resolve1(cx, obj, str, i);
  129.     if (!ok)
  130.         break;
  131.     }
  132.     JS_UnlockGCThing(cx, str);
  133.     return ok;
  134. }
  135.  
  136. static JSBool
  137. str_resolve(JSContext *cx, JSObject *obj, jsval id)
  138. {
  139.     JSString *str;
  140.     jsint slot;
  141.  
  142.     if (!JSVAL_IS_INT(id))
  143.     return JS_TRUE;
  144.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  145.     if (!str)
  146.     return JS_FALSE;
  147.     slot = JSVAL_TO_INT(id);
  148.     if ((size_t)slot >= str->length)
  149.     return JS_TRUE;
  150.     return str_resolve1(cx, obj, str, slot);
  151. }
  152.  
  153. static JSBool
  154. str_valueOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  155. {
  156.     if (!JS_InstanceOf(cx, obj, &string_class, argv))
  157.     return JS_FALSE;
  158.     JS_LOCK_VOID(cx, *rval = js_GetSlot(cx, obj, JSSLOT_PRIVATE));
  159.     return JS_TRUE;
  160. }
  161.  
  162. /*
  163.  * Java-like string native methods.
  164.  */
  165. static JSBool
  166. str_substring(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  167.           jsval *rval)
  168. {
  169.     JSString *str;
  170.     jsdouble d;
  171.     jsint length, begin, end;
  172.  
  173.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  174.     if (!str)
  175.     return JS_FALSE;
  176.     argv[-1] = STRING_TO_JSVAL(str);
  177.  
  178.     if (argc != 0) {
  179.     if (!JS_ValueToNumber(cx, argv[0], &d))
  180.         return JS_FALSE;
  181.     length = (jsint)str->length;
  182.     begin = (jsint)d;
  183.     if (begin < 0)
  184.         begin = 0;
  185.     else if (begin > length)
  186.         begin = length;
  187.  
  188.     if (argc == 1) {
  189.         end = length;
  190.     } else {
  191.         if (!JS_ValueToNumber(cx, argv[1], &d))
  192.         return JS_FALSE;
  193.         end = (jsint)d;
  194.         if (end < 0)
  195.         end = 0;
  196.         else if (end > length)
  197.         end = length;
  198.         if (end < begin) {
  199.         if (cx->version != JSVERSION_1_2) {
  200.             /* XXX emulate old JDK1.0 java.lang.String.substring. */
  201.             jsint tmp = begin;
  202.             begin = end;
  203.             end = tmp;
  204.         } else {
  205.             end = begin;
  206.         }
  207.         }
  208.     }
  209.  
  210.     str = js_NewStringCopyN(cx, str->chars + begin, (size_t)(end - begin),
  211.                 0);
  212.     if (!str)
  213.         return JS_FALSE;
  214.     }
  215.     *rval = STRING_TO_JSVAL(str);
  216.     return JS_TRUE;
  217. }
  218.  
  219. static JSBool
  220. str_toLowerCase(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  221.         jsval *rval)
  222. {
  223.     JSString *str;
  224.     size_t i, n;
  225.     jschar *s, *news;
  226.  
  227.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  228.     if (!str)
  229.     return JS_FALSE;
  230.     n = str->length;
  231.     news = JS_malloc(cx, (n + 1) * sizeof(jschar));
  232.     if (!news)
  233.     return JS_FALSE;
  234.     s = str->chars;
  235.     for (i = 0; i < n; i++)
  236.     news[i] = JS_TOLOWER(s[i]);
  237.     news[n] = 0;
  238.     str = js_NewString(cx, news, n, 0);
  239.     if (!str) {
  240.     JS_free(cx, news);
  241.     return JS_FALSE;
  242.     }
  243.     *rval = STRING_TO_JSVAL(str);
  244.     return JS_TRUE;
  245. }
  246.  
  247. static JSBool
  248. str_toUpperCase(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  249.         jsval *rval)
  250. {
  251.     JSString *str;
  252.     size_t i, n;
  253.     jschar *s, *news;
  254.  
  255.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  256.     if (!str)
  257.     return JS_FALSE;
  258.     n = str->length;
  259.     news = JS_malloc(cx, (n + 1) * sizeof(jschar));
  260.     if (!news)
  261.     return JS_FALSE;
  262.     s = str->chars;
  263.     for (i = 0; i < n; i++)
  264.     news[i] = JS_TOUPPER(s[i]);
  265.     news[n] = 0;
  266.     str = js_NewString(cx, news, n, 0);
  267.     if (!str) {
  268.     JS_free(cx, news);
  269.     return JS_FALSE;
  270.     }
  271.     *rval = STRING_TO_JSVAL(str);
  272.     return JS_TRUE;
  273. }
  274.  
  275. static JSBool
  276. str_charAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  277. {
  278.     JSString *str;
  279.     jsdouble d;
  280.     size_t index;
  281.     jschar buf[2];
  282.  
  283.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  284.     if (!str)
  285.     return JS_FALSE;
  286.     argv[-1] = STRING_TO_JSVAL(str);
  287.  
  288.     if (!JS_ValueToNumber(cx, argv[0], &d))
  289.     return JS_FALSE;
  290.     index = (size_t)d;
  291.     if (index >= str->length) {
  292.     *rval = JS_GetEmptyStringValue(cx);
  293.     } else {
  294.     buf[0] = str->chars[index];
  295.     buf[1] = 0;
  296.     str = js_NewStringCopyN(cx, buf, 1, 0);
  297.     if (!str)
  298.         return JS_FALSE;
  299.     *rval = STRING_TO_JSVAL(str);
  300.     }
  301.     return JS_TRUE;
  302. }
  303.  
  304. static JSBool
  305. str_charCodeAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  306.            jsval *rval)
  307. {
  308.     JSString *str;
  309.     jsdouble d;
  310.     size_t index;
  311.  
  312.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  313.     if (!str)
  314.     return JS_FALSE;
  315.     argv[-1] = STRING_TO_JSVAL(str);
  316.  
  317.     if (!JS_ValueToNumber(cx, argv[0], &d))
  318.     return JS_FALSE;
  319.     index = (size_t)d;
  320.     *rval = (index < str->length) ? INT_TO_JSVAL((jsint)str->chars[index])
  321.                   : JS_GetNaNValue(cx);
  322.     return JS_TRUE;
  323. }
  324.  
  325. jsint
  326. js_BoyerMooreHorspool(const jschar *text, jsint textlen,
  327.               const jschar *pat, jsint patlen,
  328.               jsint start)
  329. {
  330.     jsint i, j, k, m;
  331.     uint8 skip[BMH_CHARSET_SIZE];
  332.     jschar c;
  333.     
  334.     PR_ASSERT(0 < patlen && patlen <= BMH_PATLEN_MAX);
  335.     for (i = 0; i < BMH_CHARSET_SIZE; i++)
  336.     skip[i] = (uint8)patlen;
  337.     m = patlen - 1;
  338.     for (i = 0; i < m; i++) {
  339.     c = pat[i];
  340.     if (c >= BMH_CHARSET_SIZE)
  341.         return BMH_BAD_PATTERN;
  342.     skip[c] = (uint8)(m - i);
  343.     }
  344.     for (k = start + m;
  345.      k < textlen;
  346.      k += ((c = text[k]) >= BMH_CHARSET_SIZE) ? patlen : skip[c]) {
  347.     for (i = k, j = m; ; i--, j--) {
  348.         if (j < 0)
  349.         return i + 1;
  350.         if (text[i] != pat[j])
  351.         break;
  352.     }
  353.     }
  354.     return -1;
  355. }
  356.  
  357. static JSBool
  358. str_indexOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  359. {
  360.     JSString *str, *str2;
  361.     jsint i, j, index, textlen, patlen;
  362.     const jschar *text, *pat;
  363.     jsdouble d;
  364.  
  365.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  366.     if (!str)
  367.     return JS_FALSE;
  368.     argv[-1] = STRING_TO_JSVAL(str);
  369.     text = str->chars;
  370.     textlen = (jsint)str->length;
  371.  
  372.     str2 = JS_ValueToString(cx, argv[0]);
  373.     if (!str2)
  374.     return JS_FALSE;
  375.     argv[0] = STRING_TO_JSVAL(str2);
  376.     pat = str2->chars;
  377.     patlen = (jsint)str2->length;
  378.  
  379.     if (argc > 1) {
  380.     if (!JS_ValueToNumber(cx, argv[1], &d))
  381.         return JS_FALSE;
  382.     i = (jsint)d;
  383.     if (i < 0)
  384.         i = 0;
  385.     else if (i > textlen)
  386.         i = textlen;
  387.     } else {
  388.     i = 0;
  389.     }
  390.     if (patlen == 0) {
  391.     *rval = INT_TO_JSVAL(i);
  392.     return JS_TRUE;
  393.     }
  394.  
  395.     /* XXX tune the BMH threshold (512) */
  396.     if ((jsuint)(patlen - 2) <= BMH_PATLEN_MAX - 2 && textlen >= 512) {
  397.     index = js_BoyerMooreHorspool(text, textlen, pat, patlen, i);
  398.     if (index != BMH_BAD_PATTERN)
  399.         goto out;
  400.     }
  401.  
  402.     index = -1;
  403.     j = 0;
  404.     while (i + j < textlen) {
  405.     if (text[i + j] == pat[j]) {
  406.         if (++j == patlen) {
  407.         index = i;
  408.         break;
  409.         }
  410.     } else {
  411.         i++;
  412.         j = 0;
  413.     }
  414.     }
  415.  
  416. out:
  417.     *rval = INT_TO_JSVAL(index);
  418.     return JS_TRUE;
  419. }
  420.  
  421. static JSBool
  422. str_lastIndexOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  423.           jsval *rval)
  424. {
  425.     JSString *str, *str2;
  426.     const jschar *text, *pat;
  427.     jsint i, j, textlen, patlen;
  428.     jsdouble d;
  429.  
  430.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  431.     if (!str)
  432.     return JS_FALSE;
  433.     argv[-1] = STRING_TO_JSVAL(str);
  434.     text = str->chars;
  435.     textlen = (jsint)str->length;
  436.  
  437.     str2 = JS_ValueToString(cx, argv[0]);
  438.     if (!str2)
  439.     return JS_FALSE;
  440.     argv[0] = STRING_TO_JSVAL(str2);
  441.     pat = str2->chars;
  442.     patlen = (jsint)str2->length;
  443.  
  444.     if (argc > 1) {
  445.     if (!JS_ValueToNumber(cx, argv[1], &d))
  446.         return JS_FALSE;
  447.     i = (jsint)d;
  448.     if (i < 0)
  449.         i = 0;
  450.     else if (i > textlen - patlen)
  451.         i = textlen - patlen;
  452.     } else {
  453.     i = textlen;
  454.     }
  455.  
  456.     if (patlen == 0) {
  457.     *rval = INT_TO_JSVAL(i);
  458.     return JS_TRUE;
  459.     }
  460.  
  461.     j = 0;
  462.     while (i >= 0) {
  463.     if (text[i + j] == pat[j]) {
  464.         if (++j == patlen)
  465.         break;
  466.     } else {
  467.         i--;
  468.         j = 0;
  469.     }
  470.     }
  471.     *rval = INT_TO_JSVAL(i);
  472.     return JS_TRUE;
  473. }
  474.  
  475. /*
  476.  * Perl-inspired string functions.
  477.  */
  478. #if !JS_HAS_MORE_PERL_FUN || !JS_HAS_REGEXPS
  479. static JSBool
  480. str_nyi(JSContext *cx, const char *what)
  481. {
  482.     JS_ReportError(cx, "sorry, String.prototype.%s is not yet implemented",
  483.            what);
  484.     return JS_FALSE;
  485. }
  486. #endif
  487.  
  488. #if JS_HAS_REGEXPS
  489. typedef enum GlobMode {
  490.     GLOB_MATCH,
  491.     GLOB_REPLACE,
  492.     GLOB_SEARCH
  493. } GlobMode;
  494.  
  495. typedef struct GlobData {
  496.     uintN    optarg;    /* input: index of optional flags argument */
  497.     GlobMode mode;      /* input: return index, match object, or void */
  498.     JSBool   global;    /* output: whether regexp was global */
  499.     JSString *str;      /* output: 'this' parameter object as string */
  500.     JSRegExp *regexp;   /* output: regexp parameter object private data */
  501. } GlobData;
  502.  
  503. static JSBool
  504. match_or_replace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  505.          JSBool (*glob)(JSContext *cx, jsint count, GlobData *data),
  506.          GlobData *data, jsval *rval)
  507. {
  508.     JSString *str, *src, *opt;
  509.     JSBool ok, destroyre;
  510.     JSRegExp *re;
  511.     size_t index;
  512.     jsint count;
  513.  
  514.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  515.     if (!str)
  516.     return JS_FALSE;
  517.     argv[-1] = STRING_TO_JSVAL(str);
  518.     data->str = str;
  519.  
  520.     if (JSVAL_IS_REGEXP(argv[0])) {
  521.     re = JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
  522.     destroyre = JS_FALSE;
  523.     } else {
  524.         src = JS_ValueToString(cx, argv[0]);
  525.     if (!src)
  526.         return JS_FALSE;
  527.     if (data->optarg < argc) {
  528.         argv[0] = STRING_TO_JSVAL(src);
  529.         opt = JS_ValueToString(cx, argv[data->optarg]);
  530.         if (!opt)
  531.         return JS_FALSE;
  532.     } else {
  533.         opt = NULL;
  534.     }
  535.     re = js_NewRegExpOpt(cx, src, opt);
  536.     if (!re)
  537.         return JS_FALSE;
  538.     destroyre = JS_TRUE;
  539.     }
  540.     data->regexp = re;
  541.  
  542.     JS_LOCK(cx);
  543.     data->global = (re->flags & JSREG_GLOB) != 0;
  544.     index = 0;
  545.     if (data->mode == GLOB_SEARCH) {
  546.     ok = js_ExecuteRegExp(cx, re, str, &index, JS_TRUE, rval);
  547.     if (ok) {
  548.         *rval = (*rval == JSVAL_TRUE)
  549.             ? INT_TO_JSVAL(cx->regExpStatics.leftContext.length)
  550.             : INT_TO_JSVAL(-1);
  551.     }
  552.     } else if (data->global) {
  553.     ok = JS_TRUE;
  554.     re->lastIndex = 0;
  555.     for (count = 0; index < str->length; count++) {
  556.         ok = js_ExecuteRegExp(cx, re, str, &index, JS_TRUE, rval);
  557.         if (!ok || *rval != JSVAL_TRUE)
  558.         break;
  559.         ok = glob(cx, count, data);
  560.         if (!ok)
  561.         break;
  562.         if (cx->regExpStatics.lastMatch.length == 0) {
  563.         cx->regExpStatics.rightContext.length--;
  564.         cx->regExpStatics.rightContext.chars++;
  565.         index++;
  566.         }
  567.     }
  568.     } else {
  569.     ok = js_ExecuteRegExp(cx, re, str, &index, data->mode == GLOB_REPLACE,
  570.                   rval);
  571.     }
  572.     JS_UNLOCK(cx);
  573.  
  574.     if (destroyre)
  575.     js_DestroyRegExp(cx, re);
  576.     return ok;
  577. }
  578.  
  579. typedef struct MatchData {
  580.     GlobData base;
  581.     JSObject *arrayobj;
  582. } MatchData;
  583.  
  584. static JSBool
  585. match_glob(JSContext *cx, jsint count, GlobData *data)
  586. {
  587.     MatchData *mdata;
  588.     JSObject *arrayobj;
  589.     JSSubString *matchsub;
  590.     size_t matchlen;
  591.     JSString *matchstr;
  592.     jsval v;
  593.  
  594.     mdata = (MatchData *)data;
  595.     arrayobj = mdata->arrayobj;
  596.     if (!arrayobj) {
  597.     arrayobj = js_NewArrayObject(cx, 0, NULL);
  598.     if (!arrayobj)
  599.         return JS_FALSE;
  600.     mdata->arrayobj = arrayobj;
  601.     }
  602.     matchsub = &cx->regExpStatics.lastMatch;
  603.     matchlen = matchsub->length;
  604.     if (matchlen == 0)
  605.     matchlen = 1;
  606.     matchstr = js_NewStringCopyN(cx, matchsub->chars, matchlen, 0);
  607.     if (!matchstr)
  608.     return JS_FALSE;
  609.     v = STRING_TO_JSVAL(matchstr);
  610.     if (!js_SetProperty(cx, arrayobj, INT_TO_JSVAL(count), &v))
  611.     return JS_FALSE;
  612.     return JS_TRUE;
  613. }
  614. #endif /* JS_HAS_REGEXPS */
  615.  
  616. static JSBool
  617. str_match(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  618. {
  619. #if JS_HAS_REGEXPS
  620.     MatchData mdata;
  621.     JSBool ok;
  622.  
  623.     mdata.base.optarg = 1;
  624.     mdata.base.mode = GLOB_MATCH;
  625.     mdata.arrayobj = NULL;
  626.     if (!JS_AddRoot(cx, &mdata.arrayobj))
  627.     return JS_FALSE;
  628.     ok = match_or_replace(cx, obj, argc, argv, match_glob, &mdata.base, rval);
  629.     if (ok && mdata.arrayobj)
  630.     *rval = OBJECT_TO_JSVAL(mdata.arrayobj);
  631.     JS_RemoveRoot(cx, &mdata.arrayobj);
  632.     return ok;
  633. #else
  634.     return str_nyi(cx, "match");
  635. #endif
  636. }
  637.  
  638. static JSBool
  639. str_search(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  640. {
  641. #if JS_HAS_REGEXPS
  642.     MatchData mdata;
  643.  
  644.     mdata.base.optarg = 1;
  645.     mdata.base.mode = GLOB_SEARCH;
  646.     return match_or_replace(cx, obj, argc, argv, match_glob, &mdata.base, rval);
  647. #else
  648.     return str_nyi(cx, "search");
  649. #endif
  650. }
  651.  
  652. #if JS_HAS_REGEXPS
  653. typedef struct ReplaceData {
  654.     GlobData    base;           /* base struct state */
  655.     JSObject    *lambda;        /* replacement function object or null */
  656.     JSString    *repstr;        /* replacement string */
  657.     jschar      *dollar;        /* null or pointer to first $ in repstr */
  658.     jschar      *chars;         /* result chars, null initially */
  659.     size_t      length;         /* result length, 0 initially */
  660.     jsint       index;          /* index in result of next replacement */
  661.     jsint       leftIndex;      /* leftContext index, always 0 for JS1.2 */
  662. } ReplaceData;
  663.  
  664. static JSSubString *
  665. interpret_dollar(JSContext *cx, jschar *dp, jschar *bp, size_t *skip)
  666. {
  667.     JSRegExpStatics *res;
  668.     jschar *cp, dc;
  669.     uintN num, tmp;
  670.  
  671.     /* Allow a real backslash (literal "\\") to escape "$1" etc. */
  672.     PR_ASSERT(*dp == '$');
  673.     if (dp > bp && dp[-1] == '\\')
  674.     return NULL;
  675.  
  676.     /* Interpret all Perl match-induced dollar variables. */
  677.     res = &cx->regExpStatics;
  678.     dc = dp[1];
  679.     if (JS7_ISDEC(dc)) {
  680.     if (dc == '0')
  681.         return NULL;
  682.  
  683.     /* Check for overflow to avoid gobbling arbitrary decimal digits. */
  684.     num = 0;
  685.     cp = dp;
  686.     while ((dc = *++cp) != 0 && JS7_ISDEC(dc)) {
  687.         tmp = 10 * num + JS7_UNDEC(dc);
  688.         if (tmp < num)
  689.         break;
  690.         num = tmp;
  691.     }
  692.  
  693.     /* Adjust num from 1 $n-origin to 0 array-index-origin. */
  694.     num--;
  695.     *skip = cp - dp;
  696.     return REGEXP_PAREN_SUBSTRING(res, num);
  697.     }
  698.  
  699.     *skip = 2;
  700.     switch (dc) {
  701.       case '&':
  702.     return &res->lastMatch;
  703.       case '+':
  704.     return &res->lastParen;
  705.       case '`':
  706.     return &res->leftContext;
  707.       case '\'':
  708.     return &res->rightContext;
  709.     }
  710.     return NULL;
  711. }
  712.  
  713. static JSBool
  714. find_replen(JSContext *cx, ReplaceData *rdata, size_t *sizep)
  715. {
  716.     JSString *repstr;
  717.     size_t replen, skip;
  718.     jschar *bp, *dp;
  719.     JSSubString *sub;
  720. #if JS_HAS_REPLACE_LAMBDA
  721.     JSObject *lambda;
  722.  
  723.     lambda = rdata->lambda;
  724.     if (lambda) {
  725.         void *mark;
  726.         uintN argc, i, j, m, n, p;
  727.         jsval *sp, *oldsp, rval;
  728.     JSStackFrame *fp;
  729.         JSBool ok;
  730.  
  731.     /* 
  732.      * In the lambda case, not only do we find the replacement string's
  733.      * length, we compute repstr and return it via rdata for use within
  734.      * do_replace.  The lambda is called with arguments ($&, $1, $2, ...,
  735.      * index, input), i.e., all the properties of a regexp match array.
  736.      * For $&, etc., we must create string jsvals from cx->regExpStatics.
  737.      * We grab up stack space to keep the newborn strings GC-rooted.     * XXXbe should use Call here and avoid re-pushing args
  738.      */
  739.     mark = PR_ARENA_MARK(&cx->stackPool);
  740.         p = rdata->base.regexp->parenCount;
  741.         argc = 1 + p + 2;
  742.     PR_ARENA_ALLOCATE(sp, &cx->stackPool, (2 + argc) * sizeof(jsval));
  743.     if (!sp) {
  744.         JS_ReportOutOfMemory(cx);
  745.         return JS_FALSE;
  746.     }
  747.  
  748.     /* Push lambda and its 'this' parameter. */
  749.     *sp++ = OBJECT_TO_JSVAL(lambda);
  750.     *sp++ = OBJECT_TO_JSVAL(OBJ_GET_PARENT(lambda));
  751.  
  752. #define PUSH_REGEXP_STATIC(sub)                                               \
  753.     PR_BEGIN_MACRO                                                            \
  754.     JSString *str = js_NewStringCopyN(cx,                                 \
  755.                       cx->regExpStatics.sub.chars,        \
  756.                       cx->regExpStatics.sub.length,       \
  757.                       0);                                 \
  758.     if (!str) {                                                           \
  759.         ok = JS_FALSE;                                                    \
  760.         goto lambda_out;                                                  \
  761.     }                                                                     \
  762.     *sp++ = STRING_TO_JSVAL(str);                                         \
  763.     PR_END_MACRO
  764.  
  765.         /* Push $&, $1, $2, ... */
  766.     PUSH_REGEXP_STATIC(lastMatch);
  767.     i = 0;
  768.         m = cx->regExpStatics.parenCount;
  769.         n = PR_MIN(m, 9);
  770.         for (j = 0; i < n; i++, j++)
  771.         PUSH_REGEXP_STATIC(parens[j]);
  772.         for (j = 0; i < m; i++, j++)
  773.         PUSH_REGEXP_STATIC(moreParens[j]);
  774.  
  775. #undef PUSH_REGEXP_STATIC
  776.  
  777.     /* Make sure to push undefined for any unmatched parens. */
  778.     for (; i < p; i++)
  779.         *sp++ = JSVAL_VOID;
  780.  
  781.     /* Push match index and input string. */
  782.     *sp++ = INT_TO_JSVAL((jsint)cx->regExpStatics.leftContext.length);
  783.     *sp++ = STRING_TO_JSVAL(rdata->base.str);
  784.  
  785.     /* Lift current frame to include the args and do the call. */
  786.     fp = cx->fp;
  787.     oldsp = fp->sp;
  788.     fp->sp = sp;
  789.         ok = js_DoCall(cx, argc);
  790.     rval = fp->sp[-1];
  791.     fp->sp = oldsp;
  792.  
  793.     if (ok) {
  794.         /*
  795.          * NB: we count on the newborn string root to hold any string
  796.          * created by this JS_ValueToString that would otherwise be GC-
  797.          * able, until we use rdata->repstr in do_replace.
  798.          */
  799.         repstr = JS_ValueToString(cx, rval);
  800.         if (!repstr) {
  801.             ok = JS_FALSE;
  802.         } else {
  803.         rdata->repstr = repstr;
  804.         *sizep = repstr->length;
  805.         }
  806.     }
  807.  
  808.       lambda_out:
  809.         PR_ARENA_RELEASE(&cx->stackPool, mark);
  810.         return ok;
  811.     }
  812. #endif /* JS_HAS_REPLACE_LAMBDA */
  813.  
  814.     repstr = rdata->repstr;
  815.     replen = repstr->length;
  816.     bp = repstr->chars;
  817.     for (dp = rdata->dollar; dp; dp = js_strchr(dp + 1, '$')) {
  818.     sub = interpret_dollar(cx, dp, bp, &skip);
  819.     if (sub)
  820.         replen += sub->length - skip;
  821.     }
  822.     *sizep = replen;
  823.     return JS_TRUE;
  824. }
  825.  
  826. static void
  827. do_replace(JSContext *cx, ReplaceData *rdata, jschar *chars)
  828. {
  829.     JSString *repstr;
  830.     jschar *bp, *cp, *dp;
  831.     size_t len, skip;
  832.     JSSubString *sub;
  833.  
  834.     repstr = rdata->repstr;
  835.     bp = cp = repstr->chars;
  836.     dp = rdata->dollar;
  837.     while (dp) {
  838.     len = dp - cp;
  839.     js_strncpy(chars, cp, len);
  840.     chars += len;
  841.     cp = dp;
  842.     sub = interpret_dollar(cx, dp, bp, &skip);
  843.     if (sub) {
  844.         len = sub->length;
  845.         js_strncpy(chars, sub->chars, len);
  846.         chars += len;
  847.         cp += skip;
  848.     }
  849.     dp = js_strchr(dp + 1, '$');
  850.     }
  851.     js_strncpy(chars, cp, repstr->length - (cp - repstr->chars));
  852. }
  853.  
  854. static JSBool
  855. replace_glob(JSContext *cx, jsint count, GlobData *data)
  856. {
  857.     ReplaceData *rdata;
  858.     const jschar *left;
  859.     size_t leftlen, leftoff, replen, growth;
  860.     jschar *chars;
  861.  
  862.     rdata = (ReplaceData *)data;
  863.     left = cx->regExpStatics.leftContext.chars;
  864.     leftlen = cx->regExpStatics.leftContext.length;
  865.     if (cx->version != JSVERSION_1_2) {
  866.     /*
  867.      * JS1.2 imitated the perl4.0.low bug where $` was sometimes the left
  868.      * context from the last match, not from start of string.  See the big
  869.      * comment at the bottom of js_ExecuteRegExp.
  870.      */
  871.     leftoff = rdata->leftIndex;
  872.     rdata->leftIndex = leftlen + cx->regExpStatics.lastMatch.length;
  873.     left += leftoff;
  874.     leftlen -= leftoff;
  875.     }
  876.     if (!find_replen(cx, rdata, &replen))
  877.         return JS_FALSE;
  878.     growth = leftlen + replen;
  879.     chars = rdata->chars
  880.         ? JS_realloc(cx, rdata->chars, (rdata->length + growth + 1)
  881.                        * sizeof(jschar))
  882.         : JS_malloc(cx, (growth + 1) * sizeof(jschar));
  883.     if (!chars) {
  884.     JS_free(cx, rdata->chars);
  885.     rdata->chars = NULL;
  886.     return JS_FALSE;
  887.     }
  888.     rdata->chars = chars;
  889.     rdata->length += growth;
  890.     chars += rdata->index;
  891.     rdata->index += growth;
  892.     js_strncpy(chars, left, leftlen);
  893.     chars += leftlen;
  894.     do_replace(cx, rdata, chars);
  895.     return JS_TRUE;
  896. }
  897. #endif /* JS_HAS_REGEXPS */
  898.  
  899. static JSBool
  900. str_replace(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  901. {
  902. #if JS_HAS_REGEXPS
  903.     JSObject *lambda;
  904.     JSString *repstr, *str;
  905.     ReplaceData rdata;
  906.     jschar *chars;
  907.     size_t leftlen, rightlen, length;
  908.  
  909. #if JS_HAS_REPLACE_LAMBDA
  910.     if (JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) {
  911.         lambda = JSVAL_TO_OBJECT(argv[1]);
  912.         repstr = NULL;
  913.     } else
  914. #endif
  915.     {
  916.     if (!JS_ConvertValue(cx, argv[1], JSTYPE_STRING, &argv[1]))
  917.         return JS_FALSE;
  918.     repstr = JSVAL_TO_STRING(argv[1]);
  919.     lambda = NULL;
  920.     }
  921.  
  922.     rdata.base.optarg = 2;
  923.     rdata.base.mode = GLOB_REPLACE;
  924.     rdata.lambda = lambda;
  925.     rdata.repstr = repstr;
  926.     rdata.dollar = repstr ? js_strchr(repstr->chars, '$') : NULL;
  927.     rdata.chars = NULL;
  928.     rdata.length = 0;
  929.     rdata.index = 0;
  930.     rdata.leftIndex = 0;
  931.     if (!match_or_replace(cx, obj, argc, argv, replace_glob, &rdata.base, rval))
  932.     return JS_FALSE;
  933.  
  934.     if (!rdata.chars) {
  935.     if (rdata.base.global || *rval != JSVAL_TRUE) {
  936.         /* Didn't match even once. */
  937.         *rval = STRING_TO_JSVAL(rdata.base.str);
  938.         return JS_TRUE;
  939.     }
  940.     leftlen = cx->regExpStatics.leftContext.length;
  941.     if (!find_replen(cx, &rdata, &length))
  942.         return JS_FALSE;
  943.     length += leftlen;
  944.     chars = JS_malloc(cx, (length + 1) * sizeof(jschar));
  945.     if (!chars)
  946.         return JS_FALSE;
  947.     js_strncpy(chars, cx->regExpStatics.leftContext.chars, leftlen);
  948.     do_replace(cx, &rdata, chars + leftlen);
  949.     rdata.chars = chars;
  950.     rdata.length = length;
  951.     }
  952.  
  953.     rightlen = cx->regExpStatics.rightContext.length;
  954.     length = rdata.length + rightlen;
  955.     chars = JS_realloc(cx, rdata.chars, (length + 1) * sizeof(jschar));
  956.     if (!chars) {
  957.     JS_free(cx, rdata.chars);
  958.     return JS_FALSE;
  959.     }
  960.     js_strncpy(chars + rdata.length, cx->regExpStatics.rightContext.chars,
  961.            rightlen);
  962.     chars[length] = 0;
  963.  
  964.     str = js_NewString(cx, chars, length, 0);
  965.     if (!str) {
  966.     JS_free(cx, chars);
  967.     return JS_FALSE;
  968.     }
  969.     *rval = STRING_TO_JSVAL(str);
  970.     return JS_TRUE;
  971. #else
  972.     return str_nyi(cx, "replace");
  973. #endif
  974. }
  975.  
  976. /*
  977.  * Subroutine used by str_split to find the next split point in str, starting
  978.  * at offset *ip and looking either for the separator substring given by sep,
  979.  * or for the next re match.  In the re case, return the matched separator in
  980.  * *sep, and the possibly updated offset in *ip.
  981.  *
  982.  * Return -2 on error, -1 on end of string, >= 0 for a valid index if found or
  983.  * the string length if not found.
  984.  */
  985. static jsint
  986. find_split(JSContext *cx, JSString *str, JSRegExp *re, jsint *ip,
  987.        JSSubString *sep)
  988. {
  989.     jsint i, j, k;
  990.  
  991.     i = *ip;
  992.  
  993.     /*
  994.      * Perl special case for str.split(' '), only if the user has selected
  995.      * JavaScript1.2 explicitly.  Split on whitespace, and skip leading w/s.
  996.      * Strange but true, apparently modeled after awk.
  997.      *
  998.      * NB: we set sep->length to the length of the w/s run, so we must test
  999.      * sep->chars[1] == 0 to make sure sep is just one space.
  1000.      */
  1001.     if (cx->version == JSVERSION_1_2 &&
  1002.     !re && *sep->chars == ' ' && sep->chars[1] == 0) {
  1003.     /* Skip leading whitespace if at front of str. */
  1004.     if (i == 0) {
  1005.         while (JS_ISSPACE(str->chars[i]))
  1006.         i++;
  1007.         *ip = i;
  1008.     }
  1009.  
  1010.     /* Don't delimit whitespace at end of string. */
  1011.     if ((size_t)i == str->length)
  1012.         return -1;
  1013.  
  1014.     /* Skip over the non-whitespace chars. */
  1015.     while ((size_t)i < str->length && !JS_ISSPACE(str->chars[i]))
  1016.         i++;
  1017.  
  1018.     /* Now skip the next run of whitespace. */
  1019.     j = i;
  1020.     while ((size_t)j < str->length && JS_ISSPACE(str->chars[j]))
  1021.         j++;
  1022.  
  1023.     /* Update sep->length to count delimiter chars. */
  1024.     sep->length = (size_t)(j - i);
  1025.     return i;
  1026.     }
  1027.  
  1028.     /*
  1029.      * Stop if past end of string.  If at end of string, we will compare the
  1030.      * null char stored there (by js_NewString*) to sep->chars[j] in the while
  1031.      * loop below, so that
  1032.      *
  1033.      *  "ab,".split(',') => new Array("ab", "")
  1034.      *
  1035.      * and the resulting array converts back to the string "ab," for symmetry.
  1036.      * NB: This differs from perl, which drops the trailing empty substring if
  1037.      * the LIMIT argument is omitted.
  1038.      */
  1039.     if ((size_t)i > str->length)
  1040.     return -1;
  1041.  
  1042. #if JS_HAS_REGEXPS
  1043.     /*
  1044.      * Match a regular expression against the separator at or above index i.
  1045.      * Return -1 at end of string instead of trying for a match, so we don't
  1046.      * get stuck in a loop.
  1047.      */
  1048.     if (re) {
  1049.     while ((size_t)i < str->length) {
  1050.         size_t index, leftlen;
  1051.         jsval rval;
  1052.  
  1053.         index = (size_t)i;
  1054.         if (index == str->length)
  1055.         return -1;
  1056.         if (!js_ExecuteRegExp(cx, re, str, &index, JS_TRUE, &rval))
  1057.         return -2;
  1058.         if (rval != JSVAL_TRUE) {
  1059.         sep->length = 0;
  1060.         return str->length;
  1061.         }
  1062.         *sep = cx->regExpStatics.lastMatch;
  1063.         if (sep->length == 0)
  1064.         return i + 1;    /* see Special case comment below */
  1065.  
  1066.         leftlen = cx->regExpStatics.leftContext.length;
  1067.         if (cx->version == JSVERSION_1_2) {
  1068.         if (leftlen != 0)
  1069.             return i + leftlen;
  1070.         } else {
  1071.         if (leftlen != (size_t)i)
  1072.             return leftlen;
  1073.         }
  1074.         i += sep->length;
  1075.         *ip = i;
  1076.     }
  1077.     return -1;
  1078.     }
  1079. #endif
  1080.  
  1081.     /*
  1082.      * Special case: if sep is the empty string, split str into one character
  1083.      * substrings.  But do not split at end of string into an empty substring.
  1084.      * NB: This matches perl's special case.
  1085.      */
  1086.     if (sep->length == 0)
  1087.     return ((size_t)i == str->length) ? -1 : i + 1;
  1088.  
  1089.     /*
  1090.      * Imitate Perl by not splitting an empty string by a non-empty substring
  1091.      * into a non-empty array.  Only JS1.1 splits that way.
  1092.      */
  1093.     if (cx->version != JSVERSION_1_1 && str->length == 0)
  1094.     return -1;
  1095.  
  1096.     /*
  1097.      * Now that we know sep is non-empty, search starting at i in str for an
  1098.      * occurrence of all of sep's chars.  If we find them, return the index of
  1099.      * the first separator char.  Otherwise, return str->length.
  1100.      */
  1101.     j = 0;
  1102.     while ((size_t)(k = i + j) < str->length) {
  1103.     if (str->chars[k] == sep->chars[j]) {
  1104.         if ((size_t)++j == sep->length)
  1105.         return i;
  1106.     } else {
  1107.         i++;
  1108.         j = 0;
  1109.     }
  1110.     }
  1111.     return k;
  1112. }
  1113.  
  1114. static JSBool
  1115. str_split(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1116. {
  1117.     JSString *str, *sub;
  1118.     JSObject *arrayobj;
  1119.     jsval v;
  1120.     JSBool ok, limited;
  1121.     JSRegExp *re;
  1122.     JSSubString *sep, tmp;
  1123.     jsdouble d;
  1124.     jsint len, limit, i, j, sublen;
  1125.     const jschar *substr;
  1126.     uintN p;
  1127.  
  1128.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  1129.     if (!str)
  1130.     return JS_FALSE;
  1131.     argv[-1] = STRING_TO_JSVAL(str);
  1132.  
  1133.     arrayobj = JS_NewArrayObject(cx, 0, NULL);
  1134.     if (!arrayobj)
  1135.     return JS_FALSE;
  1136.     *rval = OBJECT_TO_JSVAL(arrayobj);
  1137.  
  1138.     if (argc == 0) {
  1139.     v = STRING_TO_JSVAL(str);
  1140.     ok = JS_SetElement(cx, arrayobj, 0, &v);
  1141.     } else {
  1142. #if JS_HAS_REGEXPS
  1143.     if (JSVAL_IS_REGEXP(argv[0])) {
  1144.         re = JS_GetPrivate(cx, JSVAL_TO_OBJECT(argv[0]));
  1145.         sep = &tmp;
  1146.     } else
  1147. #endif
  1148.     {
  1149.         sep = (JSSubString *)JS_ValueToString(cx, argv[0]);
  1150.         if (!sep)
  1151.         return JS_FALSE;
  1152.         argv[0] = STRING_TO_JSVAL(sep);
  1153.         re = NULL;
  1154.     }
  1155.     if (argc > 1) {
  1156.         if (!JS_ValueToNumber(cx, argv[1], &d))
  1157.         return JS_FALSE;
  1158.         limit = (jsint)d;
  1159.         limited = JS_TRUE;
  1160.     } else {
  1161.         limited = JS_FALSE;
  1162.     }
  1163.  
  1164.     if (re) {
  1165.         /* Save and restore parenCount in case re never matches. */
  1166.         p = cx->regExpStatics.parenCount;
  1167.         cx->regExpStatics.parenCount = 0;
  1168.  
  1169.         /* Lock to protect re just in case it's shared and global. */
  1170.         JS_LOCK(cx);
  1171.     }
  1172.  
  1173.     len = i = 0;
  1174.     while ((j = find_split(cx, str, re, &i, sep)) >= 0) {
  1175.         if (limited && len >= limit)
  1176.         break;
  1177.         sublen = j - i;
  1178.         substr = str->chars + i;
  1179.         sub = js_NewStringCopyN(cx, substr, (size_t)sublen, 0);
  1180.         if (!sub) {
  1181.         ok = JS_FALSE;
  1182.         goto unlock_runtime;
  1183.         }
  1184.         v = STRING_TO_JSVAL(sub);
  1185.         ok = JS_SetElement(cx, arrayobj, len, &v);
  1186.         if (!ok)
  1187.         goto unlock_runtime;
  1188.         len++;
  1189. #if JS_HAS_REGEXPS
  1190.         /*
  1191.          * Imitate perl's feature of including parenthesized substrings
  1192.          * that matched part of the delimiter in the new array, after the
  1193.          * split substring that was delimited.
  1194.          */
  1195.         if (re && cx->regExpStatics.parenCount != 0) {
  1196.         uintN num;
  1197.         JSSubString *parsub;
  1198.  
  1199.         for (num = 0; num < cx->regExpStatics.parenCount; num++) {
  1200.             if (limited && len >= limit)
  1201.             break;
  1202.             parsub = REGEXP_PAREN_SUBSTRING(&cx->regExpStatics, num);
  1203.             sub = js_NewStringCopyN(cx, parsub->chars, parsub->length,
  1204.                         0);
  1205.             if (!sub) {
  1206.             ok = JS_FALSE;
  1207.             goto unlock_runtime;
  1208.             }
  1209.             v = STRING_TO_JSVAL(sub);
  1210.             ok = JS_SetElement(cx, arrayobj, len, &v);
  1211.             if (!ok)
  1212.             goto unlock_runtime;
  1213.             len++;
  1214.         }
  1215.         cx->regExpStatics.parenCount = 0;
  1216.         }
  1217. #endif
  1218.         i = j + sep->length;
  1219.     }
  1220.     ok = (j != -2);
  1221.       unlock_runtime:
  1222.     if (re) {
  1223.         JS_UNLOCK(cx);
  1224.         cx->regExpStatics.parenCount = p;
  1225.     }
  1226.     }
  1227.     return ok;
  1228. }
  1229.  
  1230. static JSBool
  1231. str_substr(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1232. {
  1233. #if JS_HAS_MORE_PERL_FUN
  1234.     JSString *str;
  1235.     jsdouble d;
  1236.     jsint length, begin, end;
  1237.  
  1238.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  1239.     if (!str)
  1240.     return JS_FALSE;
  1241.  
  1242.     if (argc != 0) {
  1243.     if (!JS_ValueToNumber(cx, argv[0], &d))
  1244.         return JS_FALSE;
  1245.     length = (jsint)str->length;
  1246.     begin = (jsint)d;
  1247.     if (begin < 0) {
  1248.         begin += length;
  1249.         if (begin < 0)
  1250.         begin = 0;
  1251.     } else if (begin > length) {
  1252.         begin = length;
  1253.     }
  1254.  
  1255.     if (argc == 1) {
  1256.         end = length;
  1257.     } else {
  1258.         if (!JS_ValueToNumber(cx, argv[1], &d))
  1259.         return JS_FALSE;
  1260.         end = (jsint)d;
  1261.         if (end < 0)
  1262.         end = 0;
  1263.         end += begin;
  1264.         if (end > length)
  1265.         end = length;
  1266.     }
  1267.  
  1268.     str = js_NewStringCopyN(cx, str->chars + begin, (size_t)(end - begin),
  1269.                 0);
  1270.     if (!str)
  1271.         return JS_FALSE;
  1272.     }
  1273.     *rval = STRING_TO_JSVAL(str);
  1274.     return JS_TRUE;
  1275. #else
  1276.     return str_nyi(cx, "substr");
  1277. #endif
  1278. }
  1279.  
  1280. #ifdef NOTYET
  1281. /*
  1282.  * From "Programming perl", Larry Wall and Randall L. Schwartz, Copyright XXX
  1283.  * O'Reilly & Associates, Inc., but with Java primitive type sizes for i, l,
  1284.  * and so on:
  1285.  *
  1286.  *  a   An ASCII string, unstripped.
  1287.  *  A   An ASCII string, trailing nulls and spaces will be stripped.
  1288.  *  b   A bit string, low-to-high order.
  1289.  *  B   A bit string, high-to-low order.
  1290.  *  h   A hexadecimal string, low nybble first.
  1291.  *  H   A hexadecimal string, high nybble first.
  1292.  *  c   A signed char value.
  1293.  *  C   An unsigned char value.
  1294.  *  s   A signed short (16-bit) value.
  1295.  *  S   An unsigned short (16-bit) value.
  1296.  *  i   A signed integer (32-bit) value.
  1297.  *  I   An unsigned integer (32-bit) value.
  1298.  *  l   A signed long (64-bit) value.
  1299.  *  L   An unsigned long (64-bit) value.
  1300.  *  n   A short in "network" byte order.
  1301.  *  N   An integer in "network" byte order.
  1302.  *  f   A single-precision float in IEEE format.
  1303.  *  d   A double-precision float in IEEE format.
  1304.  *  p   A pointer to a string.
  1305.  *  x   Skip forward a byte.
  1306.  *  X   Back up one byte.
  1307.  *  @   Go to absolute position in string for next field.
  1308.  *  u   Uudecode a string.
  1309.  *
  1310.  * Each letter may be followed by a number giving the repeat count.  Together
  1311.  * the letter and repeat count make a field specifier.  Field specifiers may
  1312.  * be separated by whitespace, which will be ignored.
  1313.  */
  1314. static JSBool
  1315. str_unpack(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1316. {
  1317. #if JS_HAS_MORE_PERL_FUN
  1318. #else
  1319.     return str_nyi(cx, "unpack");
  1320. #endif
  1321. }
  1322.  
  1323. static JSBool
  1324. str_vec(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1325. {
  1326. #if JS_HAS_MORE_PERL_FUN
  1327. #else
  1328.     return str_nyi(cx, "vec");
  1329. #endif
  1330. }
  1331. #endif /* NOTYET */
  1332.  
  1333. #if JS_HAS_SEQUENCE_OPS
  1334. /*
  1335.  * Python-esque sequence operations.
  1336.  */
  1337. static JSBool
  1338. str_concat(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1339. {
  1340.     JSString *str, *str2;
  1341.     JSBool ok;
  1342.     size_t length, length2, newlength;
  1343.     jschar *chars, *newchars;
  1344.     uintN i;
  1345.  
  1346.     if (argc == 0)
  1347.     return JS_TRUE;
  1348.  
  1349.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  1350.     if (!str)
  1351.     return JS_FALSE;
  1352.     argv[-1] = STRING_TO_JSVAL(str);
  1353.  
  1354.     length = str->length;
  1355.     chars = JS_malloc(cx, (length + 1) * sizeof(jschar));
  1356.     if (!chars)
  1357.     return JS_FALSE;
  1358.     js_strncpy(chars, str->chars, length);
  1359.  
  1360.     ok = JS_TRUE;
  1361.     for (i = 0; i < argc; i++) {
  1362.     str2 = JS_ValueToString(cx, argv[i]);
  1363.     if (!str2) {
  1364.         ok = JS_FALSE;
  1365.         goto out;
  1366.     }
  1367.     length2 = str2->length;
  1368.     newlength = length + length2;
  1369.     newchars = JS_realloc(cx, chars, (newlength + 1) * sizeof(jschar));
  1370.     if (!newchars) {
  1371.         ok = JS_FALSE;
  1372.         goto out;
  1373.     }
  1374.     chars = newchars;
  1375.     js_strncpy(chars + length, str2->chars, length2);
  1376.     length = newlength;
  1377.     }
  1378.  
  1379.     chars[length] = 0;
  1380.     str = js_NewString(cx, chars, length, 0);
  1381.     if (!str)
  1382.     ok = JS_FALSE;
  1383. out:
  1384.     if (ok)
  1385.     *rval = STRING_TO_JSVAL(str);
  1386.     else
  1387.     JS_free(cx, chars);
  1388.     return ok;
  1389. }
  1390.  
  1391. static JSBool
  1392. str_slice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1393. {
  1394.     JSString *str;
  1395.     jsdouble d;
  1396.     jsint length, begin, end;
  1397.  
  1398.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  1399.     if (!str)
  1400.     return JS_FALSE;
  1401.     argv[-1] = STRING_TO_JSVAL(str);
  1402.  
  1403.     if (argc != 0) {
  1404.     if (!JS_ValueToNumber(cx, argv[0], &d))
  1405.         return JS_FALSE;
  1406.     length = (jsint)str->length;
  1407.     begin = (jsint)d;
  1408.     if (begin < 0) {
  1409.         begin += length;
  1410.         if (begin < 0)
  1411.         begin = 0;
  1412.     } else if (begin > length) {
  1413.         begin = length;
  1414.     }
  1415.  
  1416.     if (argc == 1) {
  1417.         end = length;
  1418.     } else {
  1419.         if (!JS_ValueToNumber(cx, argv[1], &d))
  1420.         return JS_FALSE;
  1421.         end = (jsint)d;
  1422.         if (end < 0) {
  1423.         end += length;
  1424.         if (end < 0)
  1425.             end = 0;
  1426.         } else if (end > length) {
  1427.         end = length;
  1428.         }
  1429.     }
  1430.  
  1431.     str = js_NewStringCopyN(cx, str->chars + begin, (size_t)(end - begin),
  1432.                 0);
  1433.     if (!str)
  1434.         return JS_FALSE;
  1435.     }
  1436.     *rval = STRING_TO_JSVAL(str);
  1437.     return JS_TRUE;
  1438. }
  1439. #endif /* JS_HAS_SEQUENCE_OPS */
  1440.  
  1441. /*
  1442.  * HTML composition aids.
  1443.  */
  1444. static JSBool
  1445. tagify(JSContext *cx, JSObject *obj, jsval *argv,
  1446.        const char *begin, const jschar *param, const char *end,
  1447.        jsval *rval)
  1448. {
  1449.     JSString *str;
  1450.     jschar *tagbuf;
  1451.     size_t beglen, endlen, parlen, taglen;
  1452.     size_t i, j;
  1453.  
  1454.     JS_LOCK_VOID(cx, str = js_ObjectToString(cx, obj));
  1455.     if (!str)
  1456.     return JS_FALSE;
  1457.  
  1458.     if (!end)
  1459.     end = begin;
  1460.  
  1461.     beglen = strlen(begin);
  1462.     taglen = 1 + beglen + 1;            /* '<begin' + '>' */
  1463.     if (param) {
  1464.     parlen = js_strlen(param);
  1465.     taglen += 2 + parlen + 1;        /* '="param"' */
  1466.     }
  1467.     endlen = strlen(end);
  1468.     taglen += str->length + 2 + endlen + 1;    /* 'str</end>' */
  1469.  
  1470.     tagbuf = JS_malloc(cx, (taglen + 1) * sizeof(jschar));
  1471.     if (!tagbuf)
  1472.     return JS_FALSE;
  1473.  
  1474.     j = 0;
  1475.     tagbuf[j++] = '<';
  1476.     for (i = 0; i < beglen; i++)
  1477.     tagbuf[j++] = (jschar)begin[i];
  1478.     if (param) {
  1479.     tagbuf[j++] = '=';
  1480.     tagbuf[j++] = '"';
  1481.     js_strncpy(&tagbuf[j], param, parlen);
  1482.     j += parlen;
  1483.     tagbuf[j++] = '"';
  1484.     }
  1485.     tagbuf[j++] = '>';
  1486.     js_strncpy(&tagbuf[j], str->chars, str->length);
  1487.     j += str->length;
  1488.     tagbuf[j++] = '<';
  1489.     tagbuf[j++] = '/';
  1490.     for (i = 0; i < endlen; i++)
  1491.     tagbuf[j++] = (jschar)end[i];
  1492.     tagbuf[j++] = '>';
  1493.     PR_ASSERT(j == taglen);
  1494.  
  1495.     str = js_NewString(cx, tagbuf, taglen, 0);
  1496.     if (!str) {
  1497.     free((char *)tagbuf);
  1498.     return JS_FALSE;
  1499.     }
  1500.     *rval = STRING_TO_JSVAL(str);
  1501.     return JS_TRUE;
  1502. }
  1503.  
  1504. static JSBool
  1505. tagify_value(JSContext *cx, JSObject *obj, jsval *argv,
  1506.          const char *begin, const char *end,
  1507.          jsval *rval)
  1508. {
  1509.     JSString *param;
  1510.  
  1511.     param = JS_ValueToString(cx, argv[0]);
  1512.     if (!param)
  1513.     return JS_FALSE;
  1514.     argv[0] = STRING_TO_JSVAL(param);
  1515.     return tagify(cx, obj, argv, begin, param->chars, end, rval);
  1516. }
  1517.  
  1518. static JSBool
  1519. str_bold(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1520. {
  1521.     return tagify(cx, obj, argv, "B", NULL, NULL, rval);
  1522. }
  1523.  
  1524. static JSBool
  1525. str_italics(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1526. {
  1527.     return tagify(cx, obj, argv, "I", NULL, NULL, rval);
  1528. }
  1529.  
  1530. static JSBool
  1531. str_fixed(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1532. {
  1533.     return tagify(cx, obj, argv, "TT", NULL, NULL, rval);
  1534. }
  1535.  
  1536. static JSBool
  1537. str_fontsize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1538. {
  1539.     return tagify_value(cx, obj, argv, "FONT SIZE", "FONT", rval);
  1540. }
  1541.  
  1542. static JSBool
  1543. str_fontcolor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  1544.           jsval *rval)
  1545. {
  1546.     return tagify_value(cx, obj, argv, "FONT COLOR", "FONT", rval);
  1547. }
  1548.  
  1549. static JSBool
  1550. str_link(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1551. {
  1552.     return tagify_value(cx, obj, argv, "A HREF", "A", rval);
  1553. }
  1554.  
  1555. static JSBool
  1556. str_anchor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1557. {
  1558.     return tagify_value(cx, obj, argv, "A NAME", "A", rval);
  1559. }
  1560.  
  1561. static JSBool
  1562. str_strike(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1563. {
  1564.     return tagify(cx, obj, argv, "STRIKE", NULL, NULL, rval);
  1565. }
  1566.  
  1567. static JSBool
  1568. str_small(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1569. {
  1570.     return tagify(cx, obj, argv, "SMALL", NULL, NULL, rval);
  1571. }
  1572.  
  1573. static JSBool
  1574. str_big(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1575. {
  1576.     return tagify(cx, obj, argv, "BIG", NULL, NULL, rval);
  1577. }
  1578.  
  1579. static JSBool
  1580. str_blink(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1581. {
  1582.     return tagify(cx, obj, argv, "BLINK", NULL, NULL, rval);
  1583. }
  1584.  
  1585. static JSBool
  1586. str_sup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1587. {
  1588.     return tagify(cx, obj, argv, "SUP", NULL, NULL, rval);
  1589. }
  1590.  
  1591. static JSBool
  1592. str_sub(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1593. {
  1594.     return tagify(cx, obj, argv, "SUB", NULL, NULL, rval);
  1595. }
  1596.  
  1597. static JSFunctionSpec string_methods[] = {
  1598.     /* Java-like methods. */
  1599.     {js_toString_str,   str_valueOf,            0},
  1600.     {js_valueOf_str,    str_valueOf,            0},
  1601.     {"substring",       str_substring,          2},
  1602.     {"toLowerCase",     str_toLowerCase,        0},
  1603.     {"toUpperCase",     str_toUpperCase,        0},
  1604.     {"charAt",          str_charAt,             1},
  1605.     {"charCodeAt",      str_charCodeAt,         1},
  1606.     {"indexOf",         str_indexOf,            2},
  1607.     {"lastIndexOf",     str_lastIndexOf,        2},
  1608.  
  1609.     /* Perl-ish methods (search is actually Python-esque). */
  1610.     {"match",           str_match,              1},
  1611.     {"search",          str_search,             1},
  1612.     {"replace",         str_replace,            2},
  1613.     {"split",           str_split,              1},
  1614.     {"substr",          str_substr,             2},
  1615. #ifdef NOTYET
  1616.     {"unpack",          str_unpack,             1},
  1617.     {"vec",             str_vec,                2},
  1618. #endif
  1619.  
  1620.     /* Python-esque sequence methods. */
  1621. #if JS_HAS_SEQUENCE_OPS
  1622.     {"concat",          str_concat,             0},
  1623.     {"slice",           str_slice,              0},
  1624. #endif
  1625.  
  1626.     /* HTML string methods. */
  1627.     {"bold",            str_bold,               0},
  1628.     {"italics",         str_italics,            0},
  1629.     {"fixed",           str_fixed,              0},
  1630.     {"fontsize",        str_fontsize,           1},
  1631.     {"fontcolor",       str_fontcolor,          1},
  1632.     {"link",            str_link,               1},
  1633.     {"anchor",          str_anchor,             1},
  1634.     {"strike",          str_strike,             0},
  1635.     {"small",           str_small,              0},
  1636.     {"big",             str_big,                0},
  1637.     {"blink",           str_blink,              0},
  1638.     {"sup",             str_sup,                0},
  1639.     {"sub",             str_sub,                0},
  1640.     {0}
  1641. };
  1642.  
  1643. static JSBool
  1644. String(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
  1645. {
  1646.     JSString *str;
  1647.     JSBool ok;
  1648.  
  1649.     if (argc > 0) {
  1650.     str = JS_ValueToString(cx, argv[0]);
  1651.     if (!str)
  1652.         return JS_FALSE;
  1653.     } else {
  1654.     str = cx->runtime->emptyString;
  1655.     }
  1656.     if (obj->map->clasp != &string_class) {
  1657.     *rval = STRING_TO_JSVAL(str);
  1658.     return JS_TRUE;
  1659.     }
  1660.     ok = js_SetSlot(cx, obj, JSSLOT_PRIVATE, STRING_TO_JSVAL(str));
  1661.     if (!ok)
  1662.     return JS_FALSE;
  1663.     *rval = OBJECT_TO_JSVAL(obj);
  1664.     return JS_TRUE;
  1665. }
  1666.  
  1667. static JSBool
  1668. str_fromCharCode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
  1669.          jsval *rval)
  1670. {
  1671.     jschar *chars;
  1672.     uintN i;
  1673.     uint16 code;
  1674.     JSString *str;
  1675.  
  1676.     chars = JS_malloc(cx, (argc + 1) * sizeof(jschar));
  1677.     if (!chars)
  1678.     return JS_FALSE;
  1679.     for (i = 0; i < argc; i++) {
  1680.     if (!JS_ValueToUint16(cx, argv[i], &code)) {
  1681.         JS_free(cx, chars);
  1682.         return JS_FALSE;
  1683.     }
  1684.     chars[i] = (jschar)code;
  1685.     }
  1686.     chars[i] = 0;
  1687.     str = js_NewString(cx, chars, argc, 0);
  1688.     if (!str) {
  1689.     JS_free(cx, chars);
  1690.     return JS_FALSE;
  1691.     }
  1692.     *rval = STRING_TO_JSVAL(str);
  1693.     return JS_TRUE;
  1694. }
  1695.  
  1696. static JSFunctionSpec string_static_methods[] = {
  1697.     {"fromCharCode",    str_fromCharCode,       0},
  1698.     {0}
  1699. };
  1700.  
  1701. static PRHashTable *deflated_string_cache;
  1702. static uint32 deflated_string_cache_bytes;
  1703. #ifdef JS_THREADSAFE
  1704. static PRLock *deflated_string_cache_lock;
  1705. #endif
  1706.  
  1707. JSObject *
  1708. js_InitStringClass(JSContext *cx, JSObject *obj)
  1709. {
  1710.     JSRuntime *rt;
  1711.     JSString *empty;
  1712.     JSObject *proto;
  1713.  
  1714.     rt = cx->runtime;
  1715.     empty = rt->emptyString;
  1716.     if (!empty) {
  1717.     /* Make a permanently locked empty string. */
  1718.     empty = js_NewString(cx, js_empty_ucstr, 0, GCF_LOCK);
  1719.     if (!empty)
  1720.         return NULL;
  1721.     rt->emptyString = empty;
  1722.  
  1723. #ifdef JS_THREADSAFE
  1724.     /* Must come through here once in primordial thread to init safely! */
  1725.     if (!deflated_string_cache_lock) {
  1726.         deflated_string_cache_lock = PR_NewLock();
  1727.         if (!deflated_string_cache_lock)
  1728.         return NULL;
  1729.     }
  1730. #endif
  1731.     }
  1732.     proto = JS_InitClass(cx, obj, NULL, &string_class, String, 1,
  1733.             string_props, string_methods,
  1734.             NULL, string_static_methods);
  1735.     if (!proto)
  1736.     return NULL;
  1737.     if (!js_SetSlot(cx, proto, JSSLOT_PRIVATE, STRING_TO_JSVAL(empty)))
  1738.     return NULL;
  1739.     return proto;
  1740. }
  1741.  
  1742. JSString *
  1743. js_NewString(JSContext *cx, jschar *chars, size_t length, uintN gcflag)
  1744. {
  1745.     JSString *str;
  1746.  
  1747.     str = js_AllocGCThing(cx, gcflag | GCX_STRING);
  1748.     if (!str)
  1749.     return NULL;
  1750.     str->length = length;
  1751.     str->chars = chars;
  1752.     return str;
  1753. }
  1754.  
  1755. JSString *
  1756. js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n, uintN gcflag)
  1757. {
  1758.     jschar *news;
  1759.     JSString *str;
  1760.  
  1761.     news = (jschar *)JS_malloc(cx, (n + 1) * sizeof(jschar));
  1762.     if (!news)
  1763.     return NULL;
  1764.     js_strncpy(news, s, n);
  1765.     news[n] = 0;
  1766.     str = js_NewString(cx, news, n, gcflag);
  1767.     if (!str)
  1768.     JS_free(cx, news);
  1769.     return str;
  1770. }
  1771.  
  1772. JSString *
  1773. js_NewStringCopyZ(JSContext *cx, const jschar *s, uintN gcflag)
  1774. {
  1775.     size_t n, m;
  1776.     jschar *news;
  1777.     JSString *str;
  1778.  
  1779.     n = js_strlen(s);
  1780.     m = (n + 1) * sizeof(jschar);
  1781.     news = JS_malloc(cx, m);
  1782.     if (!news)
  1783.     return NULL;
  1784.     memcpy(news, s, m);
  1785.     str = js_NewString(cx, news, js_strlen(news), gcflag);
  1786.     if (!str)
  1787.     JS_free(cx, news);
  1788.     return str;
  1789. }
  1790.  
  1791. void
  1792. js_FinalizeString(JSContext *cx, JSString *str)
  1793. {
  1794.     if (str->chars) {
  1795.     JS_free(cx, str->chars);
  1796.     str->chars = NULL;
  1797.     if (deflated_string_cache) {
  1798.         JS_ACQUIRE_LOCK(deflated_string_cache_lock);
  1799.         if (PR_HashTableRemove(deflated_string_cache, str))
  1800.         deflated_string_cache_bytes -= str->length;
  1801.         JS_RELEASE_LOCK(deflated_string_cache_lock);
  1802.     }
  1803.     }
  1804.     str->length = 0;
  1805. }
  1806.  
  1807. JSObject *
  1808. js_StringToObject(JSContext *cx, JSString *str)
  1809. {
  1810.     JSObject *obj;
  1811.  
  1812.     obj = js_NewObject(cx, &string_class, NULL, NULL);
  1813.     if (!obj)
  1814.     return NULL;
  1815.     if (!js_SetSlot(cx, obj, JSSLOT_PRIVATE, STRING_TO_JSVAL(str))) {
  1816.     cx->newborn[GCX_OBJECT] = NULL;
  1817.     return NULL;
  1818.     }
  1819.     return obj;
  1820. }
  1821.  
  1822. JSString *
  1823. js_ValueToString(JSContext *cx, jsval v)
  1824. {
  1825.     JSString *str;
  1826.  
  1827.     if (JSVAL_IS_OBJECT(v)) {
  1828.     str = js_ObjectToString(cx, JSVAL_TO_OBJECT(v));
  1829.     } else if (JSVAL_IS_STRING(v)) {
  1830.     str = JSVAL_TO_STRING(v);
  1831.     } else if (JSVAL_IS_INT(v)) {
  1832.     str = js_NumberToString(cx, JSVAL_TO_INT(v));
  1833.     } else if (JSVAL_IS_DOUBLE(v)) {
  1834.     str = js_NumberToString(cx, *JSVAL_TO_DOUBLE(v));
  1835.     } else if (JSVAL_IS_BOOLEAN(v)) {
  1836.     str = js_BooleanToString(cx, JSVAL_TO_BOOLEAN(v));
  1837.     } else {
  1838.     str = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
  1839.     }
  1840.     return str;
  1841. }
  1842.  
  1843. PRHashNumber
  1844. js_HashString(const JSString *str)
  1845. {
  1846.     PRHashNumber h;
  1847.     size_t n, m;
  1848.     const jschar *s;
  1849.  
  1850.     h = 0;
  1851.     n = str->length;
  1852.     s = str->chars;
  1853.     if (n < 16) {
  1854.     /* Hash every char in a short string. */
  1855.     for (; n; s++, n--)
  1856.         h = (h >> 28) ^ (h << 4) ^ *s;
  1857.     } else {
  1858.     /* Sample a la java.lang.String.hash(). */
  1859.     for (m = n / 8; n >= m; s += m, n -= m)
  1860.         h = (h >> 28) ^ (h << 4) ^ *s;
  1861.     }
  1862.     return h;
  1863. }
  1864.  
  1865. intN
  1866. js_CompareStrings(const JSString *str1, const JSString *str2)
  1867. {
  1868.     size_t l1, l2, n, i;
  1869.     const jschar *s1, *s2;
  1870.     intN cmp;
  1871.  
  1872.     l1 = str1->length, l2 = str2->length;
  1873.     s1 = str1->chars,  s2 = str2->chars;
  1874.     n = PR_MIN(l1, l2);
  1875.     for (i = 0; i < n; i++) {
  1876.     cmp = s1[i] - s2[i];
  1877.     if (cmp != 0)
  1878.         return cmp;
  1879.     }
  1880.     return (intN)(l1 - l2);
  1881. }
  1882.  
  1883. size_t
  1884. js_strlen(const jschar *s)
  1885. {
  1886.     const jschar *t;
  1887.  
  1888.     for (t = s; *t != 0; t++)
  1889.     ;
  1890.     return (size_t)(t - s);
  1891. }
  1892.  
  1893. jschar *
  1894. js_strchr(const jschar *s, jschar c)
  1895. {
  1896.     while (*s != 0) {
  1897.     if (*s == c)
  1898.         return (jschar *)s;
  1899.     s++;
  1900.     }
  1901.     return NULL;
  1902. }
  1903.  
  1904. jschar *
  1905. js_strncpy(jschar *t, const jschar *s, size_t n)
  1906. {
  1907.     size_t i;
  1908.  
  1909.     for (i = 0; i < n; i++)
  1910.     t[i] = s[i];
  1911.     return t;
  1912. }
  1913.  
  1914. jschar *
  1915. js_InflateString(JSContext *cx, const char *bytes, size_t length)
  1916. {
  1917.     jschar *chars;
  1918.     size_t i;
  1919.  
  1920.     chars = JS_malloc(cx, (length + 1) * sizeof(jschar));
  1921.     if (!chars)
  1922.     return NULL;
  1923.     for (i = 0; i < length; i++)
  1924.     chars[i] = (jschar) bytes[i];
  1925.     chars[i] = 0;
  1926.     return chars;
  1927. }
  1928.  
  1929. /*
  1930.  * May be called with null cx by js_GetStringBytes, see below.
  1931.  */
  1932. char *
  1933. js_DeflateString(JSContext *cx, const jschar *chars, size_t length)
  1934. {
  1935.     size_t i, size;
  1936.     char *bytes;
  1937.  
  1938.     size = (length + 1) * sizeof(char);
  1939.     bytes = cx ? JS_malloc(cx, size) : malloc(size);
  1940.     if (!bytes)
  1941.     return NULL;
  1942.     for (i = 0; i < length; i++)
  1943.     bytes[i] = (char) chars[i];
  1944.     bytes[i] = 0;
  1945.     return bytes;
  1946. }
  1947.  
  1948. PR_STATIC_CALLBACK(PRHashNumber)
  1949. js_hash_string_pointer(const void *key)
  1950. {
  1951.     return (PRHashNumber)key >> JSVAL_TAGBITS;
  1952. }
  1953.  
  1954. static PRHashTable *
  1955. GetDeflatedStringCache(void)
  1956. {
  1957.     PRHashTable *cache;
  1958.  
  1959.     cache = deflated_string_cache;
  1960.     if (!cache) {
  1961.     cache = PR_NewHashTable(8, js_hash_string_pointer,
  1962.                 PR_CompareValues, PR_CompareValues,
  1963.                 NULL, NULL);
  1964.     deflated_string_cache = cache;
  1965.     }
  1966.     return cache;
  1967. }
  1968.  
  1969. JSBool
  1970. js_SetStringBytes(JSString *str, char *bytes, size_t length)
  1971. {
  1972.     PRHashTable *cache;
  1973.     JSBool ok;
  1974.     PRHashNumber hash;
  1975.     PRHashEntry **hep;
  1976.  
  1977.     JS_ACQUIRE_LOCK(deflated_string_cache_lock);
  1978.  
  1979.     cache = GetDeflatedStringCache();
  1980.     if (!cache) {
  1981.     ok = JS_FALSE;
  1982.     } else {
  1983.     hash = js_hash_string_pointer(str);
  1984.     hep = PR_HashTableRawLookup(cache, hash, str);
  1985.     PR_ASSERT(*hep == NULL);
  1986.     ok = PR_HashTableRawAdd(cache, hep, hash, str, bytes) != NULL;
  1987.     if (ok)
  1988.         deflated_string_cache_bytes += length;
  1989.     }
  1990.  
  1991.     JS_RELEASE_LOCK(deflated_string_cache_lock);
  1992.     return ok;
  1993. }
  1994.  
  1995. char *
  1996. js_GetStringBytes(JSString *str)
  1997. {
  1998.     PRHashTable *cache;
  1999.     char *bytes;
  2000.     PRHashNumber hash;
  2001.     PRHashEntry *he, **hep;
  2002.  
  2003.     JS_ACQUIRE_LOCK(deflated_string_cache_lock);
  2004.  
  2005.     cache = GetDeflatedStringCache();
  2006.     if (!cache) {
  2007.     bytes = NULL;
  2008.     } else {
  2009.     hash = js_hash_string_pointer(str);
  2010.     hep = PR_HashTableRawLookup(cache, hash, str);
  2011.     he = *hep;
  2012.     if (he) {
  2013.         bytes = he->value;
  2014.     } else {
  2015.         bytes = js_DeflateString(NULL, str->chars, str->length);
  2016.         if (bytes) {
  2017.         if (PR_HashTableRawAdd(cache, hep, hash, str, bytes)) {
  2018.             deflated_string_cache_bytes += str->length;
  2019.         } else {
  2020.             free(bytes);
  2021.             bytes = NULL;
  2022.         }
  2023.         }
  2024.     }
  2025.     }
  2026.  
  2027.     JS_RELEASE_LOCK(deflated_string_cache_lock);
  2028.     return bytes;
  2029. }
  2030.  
  2031. /*
  2032.  * From java.lang.Character.java:
  2033.  *
  2034.  * The character properties are currently encoded into 32 bits in the
  2035.  * following manner:
  2036.  *
  2037.  * 10 bits      signed offset used for converting case
  2038.  *  1 bit       if 1, adding the signed offset converts the character to
  2039.  *              lowercase
  2040.  *  1 bit       if 1, subtracting the signed offset converts the character to
  2041.  *              uppercase
  2042.  *  1 bit       if 1, character has a titlecase equivalent (possibly itself)
  2043.  *  3 bits      0  may not be part of an identifier
  2044.  *              1  ignorable control; may continue a Unicode identifier or JS
  2045.  *                 identifier
  2046.  *              2  may continue a JS identifier but not a Unicode identifier
  2047.  *                 (unused)
  2048.  *              3  may continue a Unicode identifier or JS identifier
  2049.  *              4  is a JS whitespace character
  2050.  *              5  may start or continue a JS identifier;
  2051.  *                 may continue but not start a Unicode identifier (_)
  2052.  *              6  may start or continue a JS identifier but not a Unicode
  2053.  *                 identifier ($)
  2054.  *              7  may start or continue a Unicode identifier or JS identifier
  2055.  *              Thus:
  2056.  *                 5, 6, 7 may start a JS identifier
  2057.  *                 1, 2, 3, 5, 6, 7 may continue a JS identifier
  2058.  *                 7 may start a Unicode identifier
  2059.  *                 1, 3, 5, 7 may continue a Unicode identifier
  2060.  *                 1 is ignorable within an identifier
  2061.  *                 4 is JS whitespace
  2062.  *  2 bits      0  this character has no numeric property
  2063.  *              1  adding the digit offset to the character code and then
  2064.  *                 masking with 0x1F will produce the desired numeric value
  2065.  *              2  this character has a "strange" numeric value
  2066.  *              3  a JS supradecimal digit: adding the digit offset to the
  2067.  *                 character code, then masking with 0x1F, then adding 10
  2068.  *                 will produce the desired numeric value
  2069.  *  5 bits      digit offset
  2070.  *  4 bits      reserved for future use
  2071.  *  5 bits      character type
  2072.  */
  2073.  
  2074. /* The X table has 1024 entries for a total of 1024 bytes. */
  2075.  
  2076. const uint8 js_X[] = {
  2077.   0,   1,   2,   3,   4,   5,   6,   7,  /*  0x0000 */
  2078.   8,   9,  10,  11,  12,  13,  14,  15,  /*  0x0200 */
  2079.  16,  17,  18,  19,  20,  21,  22,  23,  /*  0x0400 */
  2080.  24,  25,  26,  27,  28,  28,  28,  28,  /*  0x0600 */
  2081.  28,  28,  28,  28,  29,  30,  31,  32,  /*  0x0800 */
  2082.  33,  34,  35,  36,  37,  38,  39,  40,  /*  0x0A00 */
  2083.  41,  42,  43,  44,  45,  46,  28,  28,  /*  0x0C00 */
  2084.  47,  48,  49,  50,  51,  52,  53,  28,  /*  0x0E00 */
  2085.  28,  28,  54,  55,  56,  57,  58,  59,  /*  0x1000 */
  2086.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x1200 */
  2087.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x1400 */
  2088.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x1600 */
  2089.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x1800 */
  2090.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x1A00 */
  2091.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x1C00 */
  2092.  60,  60,  61,  62,  63,  64,  65,  66,  /*  0x1E00 */
  2093.  67,  68,  69,  70,  71,  72,  73,  74,  /*  0x2000 */
  2094.  75,  75,  75,  76,  77,  78,  28,  28,  /*  0x2200 */
  2095.  79,  80,  81,  82,  83,  83,  84,  85,  /*  0x2400 */
  2096.  86,  85,  28,  28,  87,  88,  89,  28,  /*  0x2600 */
  2097.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x2800 */
  2098.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x2A00 */
  2099.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x2C00 */
  2100.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x2E00 */
  2101.  90,  91,  92,  93,  94,  56,  95,  28,  /*  0x3000 */
  2102.  96,  97,  98,  99,  83, 100,  83, 101,  /*  0x3200 */
  2103.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x3400 */
  2104.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x3600 */
  2105.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x3800 */
  2106.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x3A00 */
  2107.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x3C00 */
  2108.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x3E00 */
  2109.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x4000 */
  2110.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x4200 */
  2111.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x4400 */
  2112.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x4600 */
  2113.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x4800 */
  2114.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x4A00 */
  2115.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0x4C00 */
  2116.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x4E00 */
  2117.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5000 */
  2118.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5200 */
  2119.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5400 */
  2120.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5600 */
  2121.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5800 */
  2122.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5A00 */
  2123.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5C00 */
  2124.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x5E00 */
  2125.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6000 */
  2126.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6200 */
  2127.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6400 */
  2128.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6600 */
  2129.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6800 */
  2130.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6A00 */
  2131.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6C00 */
  2132.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x6E00 */
  2133.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7000 */
  2134.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7200 */
  2135.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7400 */
  2136.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7600 */
  2137.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7800 */
  2138.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7A00 */
  2139.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7C00 */
  2140.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x7E00 */
  2141.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8000 */
  2142.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8200 */
  2143.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8400 */
  2144.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8600 */
  2145.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8800 */
  2146.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8A00 */
  2147.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8C00 */
  2148.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x8E00 */
  2149.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x9000 */
  2150.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x9200 */
  2151.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x9400 */
  2152.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x9600 */
  2153.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x9800 */
  2154.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x9A00 */
  2155.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0x9C00 */
  2156.  56,  56,  56,  56,  56,  56, 102,  28,  /*  0x9E00 */
  2157.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0xA000 */
  2158.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0xA200 */
  2159.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0xA400 */
  2160.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0xA600 */
  2161.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0xA800 */
  2162.  28,  28,  28,  28,  28,  28,  28,  28,  /*  0xAA00 */
  2163.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xAC00 */
  2164.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xAE00 */
  2165.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xB000 */
  2166.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xB200 */
  2167.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xB400 */
  2168.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xB600 */
  2169.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xB800 */
  2170.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xBA00 */
  2171.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xBC00 */
  2172.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xBE00 */
  2173.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xC000 */
  2174.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xC200 */
  2175.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xC400 */
  2176.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xC600 */
  2177.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xC800 */
  2178.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xCA00 */
  2179.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xCC00 */
  2180.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xCE00 */
  2181.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xD000 */
  2182.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xD200 */
  2183.  56,  56,  56,  56,  56,  56,  56,  56,  /*  0xD400 */
  2184.  56,  56,  56,  56,  56,  56, 103,  28,  /*  0xD600 */
  2185. 104, 104, 104, 104, 104, 104, 104, 104,  /*  0xD800 */
  2186. 104, 104, 104, 104, 104, 104, 104, 104,  /*  0xDA00 */
  2187. 104, 104, 104, 104, 104, 104, 104, 104,  /*  0xDC00 */
  2188. 104, 104, 104, 104, 104, 104, 104, 104,  /*  0xDE00 */
  2189. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xE000 */
  2190. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xE200 */
  2191. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xE400 */
  2192. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xE600 */
  2193. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xE800 */
  2194. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xEA00 */
  2195. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xEC00 */
  2196. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xEE00 */
  2197. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xF000 */
  2198. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xF200 */
  2199. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xF400 */
  2200. 105, 105, 105, 105, 105, 105, 105, 105,  /*  0xF600 */
  2201. 105, 105, 105, 105,  56,  56,  56,  56,  /*  0xF800 */
  2202. 106,  28,  28,  28, 107, 108, 109, 110,  /*  0xFA00 */
  2203.  56,  56,  56,  56, 111, 112, 113, 114,  /*  0xFC00 */
  2204. 115, 116,  56, 117, 118, 119, 120, 121   /*  0xFE00 */
  2205. };
  2206.  
  2207. /* The Y table has 7808 entries for a total of 7808 bytes. */
  2208.  
  2209. const uint8 js_Y[] = {
  2210.   0,   0,   0,   0,   0,   0,   0,   0,  /*    0 */
  2211.   0,   1,   1,   1,   1,   1,   0,   0,  /*    0 */
  2212.   0,   0,   0,   0,   0,   0,   0,   0,  /*    0 */
  2213.   0,   0,   0,   0,   1,   1,   1,   1,  /*    0 */
  2214.   2,   3,   3,   3,   4,   3,   3,   3,  /*    0 */
  2215.   5,   6,   3,   7,   3,   8,   3,   3,  /*    0 */
  2216.   9,   9,   9,   9,   9,   9,   9,   9,  /*    0 */
  2217.   9,   9,   3,   3,   7,   7,   7,   3,  /*    0 */
  2218.   3,  10,  10,  10,  10,  10,  10,  10,  /*    1 */
  2219.  10,  10,  10,  10,  10,  10,  10,  10,  /*    1 */
  2220.  10,  10,  10,  10,  10,  10,  10,  10,  /*    1 */
  2221.  10,  10,  10,   5,   3,   6,  11,  12,  /*    1 */
  2222.  11,  13,  13,  13,  13,  13,  13,  13,  /*    1 */
  2223.  13,  13,  13,  13,  13,  13,  13,  13,  /*    1 */
  2224.  13,  13,  13,  13,  13,  13,  13,  13,  /*    1 */
  2225.  13,  13,  13,   5,   7,   6,   7,   0,  /*    1 */
  2226.   0,   0,   0,   0,   0,   0,   0,   0,  /*    2 */
  2227.   0,   0,   0,   0,   0,   0,   0,   0,  /*    2 */
  2228.   0,   0,   0,   0,   0,   0,   0,   0,  /*    2 */
  2229.   0,   0,   0,   0,   0,   0,   0,   0,  /*    2 */
  2230.  14,   3,   4,   4,   4,   4,  15,  15,  /*    2 */
  2231.  11,  15,  16,   5,   7,   8,  15,  11,  /*    2 */
  2232.  15,   7,  17,  17,  11,  16,  15,   3,  /*    2 */
  2233.  11,  18,  16,   6,  19,  19,  19,   3,  /*    2 */
  2234.  20,  20,  20,  20,  20,  20,  20,  20,  /*    3 */
  2235.  20,  20,  20,  20,  20,  20,  20,  20,  /*    3 */
  2236.  20,  20,  20,  20,  20,  20,  20,   7,  /*    3 */
  2237.  20,  20,  20,  20,  20,  20,  20,  16,  /*    3 */
  2238.  21,  21,  21,  21,  21,  21,  21,  21,  /*    3 */
  2239.  21,  21,  21,  21,  21,  21,  21,  21,  /*    3 */
  2240.  21,  21,  21,  21,  21,  21,  21,   7,  /*    3 */
  2241.  21,  21,  21,  21,  21,  21,  21,  22,  /*    3 */
  2242.  23,  24,  23,  24,  23,  24,  23,  24,  /*    4 */
  2243.  23,  24,  23,  24,  23,  24,  23,  24,  /*    4 */
  2244.  23,  24,  23,  24,  23,  24,  23,  24,  /*    4 */
  2245.  23,  24,  23,  24,  23,  24,  23,  24,  /*    4 */
  2246.  23,  24,  23,  24,  23,  24,  23,  24,  /*    4 */
  2247.  23,  24,  23,  24,  23,  24,  23,  24,  /*    4 */
  2248.  25,  26,  23,  24,  23,  24,  23,  24,  /*    4 */
  2249.  16,  23,  24,  23,  24,  23,  24,  23,  /*    4 */
  2250.  24,  23,  24,  23,  24,  23,  24,  23,  /*    5 */
  2251.  24,  16,  23,  24,  23,  24,  23,  24,  /*    5 */
  2252.  23,  24,  23,  24,  23,  24,  23,  24,  /*    5 */
  2253.  23,  24,  23,  24,  23,  24,  23,  24,  /*    5 */
  2254.  23,  24,  23,  24,  23,  24,  23,  24,  /*    5 */
  2255.  23,  24,  23,  24,  23,  24,  23,  24,  /*    5 */
  2256.  23,  24,  23,  24,  23,  24,  23,  24,  /*    5 */
  2257.  27,  23,  24,  23,  24,  23,  24,  28,  /*    5 */
  2258.  16,  29,  23,  24,  23,  24,  30,  23,  /*    6 */
  2259.  24,  31,  31,  23,  24,  16,  32,  32,  /*    6 */
  2260.  33,  23,  24,  31,  34,  16,  35,  36,  /*    6 */
  2261.  23,  24,  16,  16,  35,  37,  16,  38,  /*    6 */
  2262.  23,  24,  23,  24,  23,  24,  38,  23,  /*    6 */
  2263.  24,  39,  40,  16,  23,  24,  39,  23,  /*    6 */
  2264.  24,  41,  41,  23,  24,  23,  24,  42,  /*    6 */
  2265.  23,  24,  16,  40,  23,  24,  40,  40,  /*    6 */
  2266.  40,  40,  40,  40,  43,  44,  45,  43,  /*    7 */
  2267.  44,  45,  43,  44,  45,  23,  24,  23,  /*    7 */
  2268.  24,  23,  24,  23,  24,  23,  24,  23,  /*    7 */
  2269.  24,  23,  24,  23,  24,  16,  23,  24,  /*    7 */
  2270.  23,  24,  23,  24,  23,  24,  23,  24,  /*    7 */
  2271.  23,  24,  23,  24,  23,  24,  23,  24,  /*    7 */
  2272.  16,  43,  44,  45,  23,  24,  46,  46,  /*    7 */
  2273.  46,  46,  23,  24,  23,  24,  23,  24,  /*    7 */
  2274.  23,  24,  23,  24,  23,  24,  23,  24,  /*    8 */
  2275.  23,  24,  23,  24,  23,  24,  23,  24,  /*    8 */
  2276.  23,  24,  23,  24,  23,  24,  23,  24,  /*    8 */
  2277.  46,  46,  46,  46,  46,  46,  46,  46,  /*    8 */
  2278.  46,  46,  46,  46,  46,  46,  46,  46,  /*    8 */
  2279.  46,  46,  46,  46,  46,  46,  46,  46,  /*    8 */
  2280.  46,  46,  46,  46,  46,  46,  46,  46,  /*    8 */
  2281.  46,  46,  46,  46,  46,  46,  46,  46,  /*    8 */
  2282.  46,  46,  46,  46,  46,  46,  46,  46,  /*    9 */
  2283.  46,  46,  46,  46,  46,  46,  46,  46,  /*    9 */
  2284.  16,  16,  16,  47,  48,  16,  49,  49,  /*    9 */
  2285.  50,  50,  16,  51,  16,  16,  16,  16,  /*    9 */
  2286.  49,  16,  16,  52,  16,  16,  16,  16,  /*    9 */
  2287.  53,  54,  16,  16,  16,  16,  16,  54,  /*    9 */
  2288.  16,  16,  55,  16,  16,  16,  16,  16,  /*    9 */
  2289.  16,  16,  16,  16,  16,  16,  16,  16,  /*    9 */
  2290.  16,  16,  16,  56,  16,  16,  16,  16,  /*   10 */
  2291.  56,  16,  57,  57,  16,  16,  16,  16,  /*   10 */
  2292.  16,  16,  58,  16,  16,  16,  16,  16,  /*   10 */
  2293.  16,  16,  16,  16,  16,  16,  16,  16,  /*   10 */
  2294.  16,  16,  16,  16,  16,  16,  16,  16,  /*   10 */
  2295.  16,  46,  46,  46,  46,  46,  46,  46,  /*   10 */
  2296.  59,  59,  59,  59,  59,  59,  59,  59,  /*   10 */
  2297.  59,  11,  11,  59,  59,  59,  59,  59,  /*   10 */
  2298.  59,  59,  11,  11,  11,  11,  11,  11,  /*   11 */
  2299.  11,  11,  11,  11,  11,  11,  11,  11,  /*   11 */
  2300.  59,  59,  11,  11,  11,  11,  11,  11,  /*   11 */
  2301.  11,  11,  11,  11,  11,  11,  11,  46,  /*   11 */
  2302.  59,  59,  59,  59,  59,  11,  11,  11,  /*   11 */
  2303.  11,  11,  46,  46,  46,  46,  46,  46,  /*   11 */
  2304.  46,  46,  46,  46,  46,  46,  46,  46,  /*   11 */
  2305.  46,  46,  46,  46,  46,  46,  46,  46,  /*   11 */
  2306.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2307.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2308.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2309.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2310.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2311.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2312.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2313.  60,  60,  60,  60,  60,  60,  60,  60,  /*   12 */
  2314.  60,  60,  60,  60,  60,  60,  46,  46,  /*   13 */
  2315.  46,  46,  46,  46,  46,  46,  46,  46,  /*   13 */
  2316.  46,  46,  46,  46,  46,  46,  46,  46,  /*   13 */
  2317.  46,  46,  46,  46,  46,  46,  46,  46,  /*   13 */
  2318.  60,  60,  46,  46,  46,  46,  46,  46,  /*   13 */
  2319.  46,  46,  46,  46,  46,  46,  46,  46,  /*   13 */
  2320.  46,  46,  46,  46,   3,   3,  46,  46,  /*   13 */
  2321.  46,  46,  59,  46,  46,  46,   3,  46,  /*   13 */
  2322.  46,  46,  46,  46,  11,  11,  61,   3,  /*   14 */
  2323.  62,  62,  62,  46,  63,  46,  64,  64,  /*   14 */
  2324.  16,  20,  20,  20,  20,  20,  20,  20,  /*   14 */
  2325.  20,  20,  20,  20,  20,  20,  20,  20,  /*   14 */
  2326.  20,  20,  46,  20,  20,  20,  20,  20,  /*   14 */
  2327.  20,  20,  20,  20,  65,  66,  66,  66,  /*   14 */
  2328.  16,  21,  21,  21,  21,  21,  21,  21,  /*   14 */
  2329.  21,  21,  21,  21,  21,  21,  21,  21,  /*   14 */
  2330.  21,  21,  16,  21,  21,  21,  21,  21,  /*   15 */
  2331.  21,  21,  21,  21,  67,  68,  68,  46,  /*   15 */
  2332.  69,  70,  38,  38,  38,  71,  72,  46,  /*   15 */
  2333.  46,  46,  38,  46,  38,  46,  38,  46,  /*   15 */
  2334.  38,  46,  23,  24,  23,  24,  23,  24,  /*   15 */
  2335.  23,  24,  23,  24,  23,  24,  23,  24,  /*   15 */
  2336.  73,  74,  16,  40,  46,  46,  46,  46,  /*   15 */
  2337.  46,  46,  46,  46,  46,  46,  46,  46,  /*   15 */
  2338.  46,  75,  75,  75,  75,  75,  75,  75,  /*   16 */
  2339.  75,  75,  75,  75,  75,  46,  75,  75,  /*   16 */
  2340.  20,  20,  20,  20,  20,  20,  20,  20,  /*   16 */
  2341.  20,  20,  20,  20,  20,  20,  20,  20,  /*   16 */
  2342.  20,  20,  20,  20,  20,  20,  20,  20,  /*   16 */
  2343.  20,  20,  20,  20,  20,  20,  20,  20,  /*   16 */
  2344.  21,  21,  21,  21,  21,  21,  21,  21,  /*   16 */
  2345.  21,  21,  21,  21,  21,  21,  21,  21,  /*   16 */
  2346.  21,  21,  21,  21,  21,  21,  21,  21,  /*   17 */
  2347.  21,  21,  21,  21,  21,  21,  21,  21,  /*   17 */
  2348.  46,  74,  74,  74,  74,  74,  74,  74,  /*   17 */
  2349.  74,  74,  74,  74,  74,  46,  74,  74,  /*   17 */
  2350.  23,  24,  23,  24,  23,  24,  23,  24,  /*   17 */
  2351.  23,  24,  23,  24,  23,  24,  23,  24,  /*   17 */
  2352.  23,  24,  23,  24,  23,  24,  23,  24,  /*   17 */
  2353.  23,  24,  23,  24,  23,  24,  23,  24,  /*   17 */
  2354.  23,  24,  15,  60,  60,  60,  60,  46,  /*   18 */
  2355.  46,  46,  46,  46,  46,  46,  46,  46,  /*   18 */
  2356.  23,  24,  23,  24,  23,  24,  23,  24,  /*   18 */
  2357.  23,  24,  23,  24,  23,  24,  23,  24,  /*   18 */
  2358.  23,  24,  23,  24,  23,  24,  23,  24,  /*   18 */
  2359.  23,  24,  23,  24,  23,  24,  23,  24,  /*   18 */
  2360.  23,  24,  23,  24,  23,  24,  23,  24,  /*   18 */
  2361.  23,  24,  23,  24,  23,  24,  23,  24,  /*   18 */
  2362.  40,  23,  24,  23,  24,  46,  46,  23,  /*   19 */
  2363.  24,  46,  46,  23,  24,  46,  46,  46,  /*   19 */
  2364.  23,  24,  23,  24,  23,  24,  23,  24,  /*   19 */
  2365.  23,  24,  23,  24,  23,  24,  23,  24,  /*   19 */
  2366.  23,  24,  23,  24,  23,  24,  23,  24,  /*   19 */
  2367.  23,  24,  23,  24,  46,  46,  23,  24,  /*   19 */
  2368.  23,  24,  23,  24,  23,  24,  46,  46,  /*   19 */
  2369.  23,  24,  46,  46,  46,  46,  46,  46,  /*   19 */
  2370.  46,  46,  46,  46,  46,  46,  46,  46,  /*   20 */
  2371.  46,  46,  46,  46,  46,  46,  46,  46,  /*   20 */
  2372.  46,  46,  46,  46,  46,  46,  46,  46,  /*   20 */
  2373.  46,  46,  46,  46,  46,  46,  46,  46,  /*   20 */
  2374.  46,  46,  46,  46,  46,  46,  46,  46,  /*   20 */
  2375.  46,  46,  46,  46,  46,  46,  46,  46,  /*   20 */
  2376.  46,  76,  76,  76,  76,  76,  76,  76,  /*   20 */
  2377.  76,  76,  76,  76,  76,  76,  76,  76,  /*   20 */
  2378.  76,  76,  76,  76,  76,  76,  76,  76,  /*   21 */
  2379.  76,  76,  76,  76,  76,  76,  76,  76,  /*   21 */
  2380.  76,  76,  76,  76,  76,  76,  76,  46,  /*   21 */
  2381.  46,  59,   3,   3,   3,   3,   3,   3,  /*   21 */
  2382.  46,  77,  77,  77,  77,  77,  77,  77,  /*   21 */
  2383.  77,  77,  77,  77,  77,  77,  77,  77,  /*   21 */
  2384.  77,  77,  77,  77,  77,  77,  77,  77,  /*   21 */
  2385.  77,  77,  77,  77,  77,  77,  77,  77,  /*   21 */
  2386.  77,  77,  77,  77,  77,  77,  77,  16,  /*   22 */
  2387.  46,   3,  46,  46,  46,  46,  46,  46,  /*   22 */
  2388.  46,  60,  60,  60,  60,  60,  60,  60,  /*   22 */
  2389.  60,  60,  60,  60,  60,  60,  60,  60,  /*   22 */
  2390.  60,  60,  46,  60,  60,  60,  60,  60,  /*   22 */
  2391.  60,  60,  60,  60,  60,  60,  60,  60,  /*   22 */
  2392.  60,  60,  60,  60,  60,  60,  60,  60,  /*   22 */
  2393.  60,  60,  46,  60,  60,  60,   3,  60,  /*   22 */
  2394.   3,  60,  60,   3,  60,  46,  46,  46,  /*   23 */
  2395.  46,  46,  46,  46,  46,  46,  46,  46,  /*   23 */
  2396.  40,  40,  40,  40,  40,  40,  40,  40,  /*   23 */
  2397.  40,  40,  40,  40,  40,  40,  40,  40,  /*   23 */
  2398.  40,  40,  40,  40,  40,  40,  40,  40,  /*   23 */
  2399.  40,  40,  40,  46,  46,  46,  46,  46,  /*   23 */
  2400.  40,  40,  40,   3,   3,  46,  46,  46,  /*   23 */
  2401.  46,  46,  46,  46,  46,  46,  46,  46,  /*   23 */
  2402.  46,  46,  46,  46,  46,  46,  46,  46,  /*   24 */
  2403.  46,  46,  46,  46,   3,  46,  46,  46,  /*   24 */
  2404.  46,  46,  46,  46,  46,  46,  46,  46,  /*   24 */
  2405.  46,  46,  46,   3,  46,  46,  46,   3,  /*   24 */
  2406.  46,  40,  40,  40,  40,  40,  40,  40,  /*   24 */
  2407.  40,  40,  40,  40,  40,  40,  40,  40,  /*   24 */
  2408.  40,  40,  40,  40,  40,  40,  40,  40,  /*   24 */
  2409.  40,  40,  40,  46,  46,  46,  46,  46,  /*   24 */
  2410.  59,  40,  40,  40,  40,  40,  40,  40,  /*   25 */
  2411.  40,  40,  40,  60,  60,  60,  60,  60,  /*   25 */
  2412.  60,  60,  60,  46,  46,  46,  46,  46,  /*   25 */
  2413.  46,  46,  46,  46,  46,  46,  46,  46,  /*   25 */
  2414.  78,  78,  78,  78,  78,  78,  78,  78,  /*   25 */
  2415.  78,  78,   3,   3,   3,   3,  46,  46,  /*   25 */
  2416.  60,  40,  40,  40,  40,  40,  40,  40,  /*   25 */
  2417.  40,  40,  40,  40,  40,  40,  40,  40,  /*   25 */
  2418.  40,  40,  40,  40,  40,  40,  40,  40,  /*   26 */
  2419.  40,  40,  40,  40,  40,  40,  40,  40,  /*   26 */
  2420.  40,  40,  40,  40,  40,  40,  40,  40,  /*   26 */
  2421.  40,  40,  40,  40,  40,  40,  40,  40,  /*   26 */
  2422.  40,  40,  40,  40,  40,  40,  40,  40,  /*   26 */
  2423.  40,  40,  40,  40,  40,  40,  40,  40,  /*   26 */
  2424.  40,  40,  40,  40,  40,  40,  40,  40,  /*   26 */
  2425.  46,  46,  40,  40,  40,  40,  40,  46,  /*   26 */
  2426.  40,  40,  40,  40,  40,  40,  40,  40,  /*   27 */
  2427.  40,  40,  40,  40,  40,  40,  40,  46,  /*   27 */
  2428.  40,  40,  40,  40,   3,  40,  60,  60,  /*   27 */
  2429.  60,  60,  60,  60,  60,  79,  79,  60,  /*   27 */
  2430.  60,  60,  60,  60,  60,  59,  59,  60,  /*   27 */
  2431.  60,  15,  60,  60,  60,  60,  46,  46,  /*   27 */
  2432.   9,   9,   9,   9,   9,   9,   9,   9,  /*   27 */
  2433.   9,   9,  46,  46,  46,  46,  46,  46,  /*   27 */
  2434.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2435.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2436.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2437.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2438.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2439.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2440.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2441.  46,  46,  46,  46,  46,  46,  46,  46,  /*   28 */
  2442.  46,  60,  60,  80,  46,  40,  40,  40,  /*   29 */
  2443.  40,  40,  40,  40,  40,  40,  40,  40,  /*   29 */
  2444.  40,  40,  40,  40,  40,  40,  40,  40,  /*   29 */
  2445.  40,  40,  40,  40,  40,  40,  40,  40,  /*   29 */
  2446.  40,  40,  40,  40,  40,  40,  40,  40,  /*   29 */
  2447.  40,  40,  40,  40,  40,  40,  40,  40,  /*   29 */
  2448.  40,  40,  40,  40,  40,  40,  40,  40,  /*   29 */
  2449.  40,  40,  46,  46,  60,  40,  80,  80,  /*   29 */
  2450.  80,  60,  60,  60,  60,  60,  60,  60,  /*   30 */
  2451.  60,  80,  80,  80,  80,  60,  46,  46,  /*   30 */
  2452.  15,  60,  60,  60,  60,  46,  46,  46,  /*   30 */
  2453.  40,  40,  40,  40,  40,  40,  40,  40,  /*   30 */
  2454.  40,  40,  60,  60,   3,   3,  81,  81,  /*   30 */
  2455.  81,  81,  81,  81,  81,  81,  81,  81,  /*   30 */
  2456.   3,  46,  46,  46,  46,  46,  46,  46,  /*   30 */
  2457.  46,  46,  46,  46,  46,  46,  46,  46,  /*   30 */
  2458.  46,  60,  80,  80,  46,  40,  40,  40,  /*   31 */
  2459.  40,  40,  40,  40,  40,  46,  46,  40,  /*   31 */
  2460.  40,  46,  46,  40,  40,  40,  40,  40,  /*   31 */
  2461.  40,  40,  40,  40,  40,  40,  40,  40,  /*   31 */
  2462.  40,  40,  40,  40,  40,  40,  40,  40,  /*   31 */
  2463.  40,  46,  40,  40,  40,  40,  40,  40,  /*   31 */
  2464.  40,  46,  40,  46,  46,  46,  40,  40,  /*   31 */
  2465.  40,  40,  46,  46,  60,  46,  80,  80,  /*   31 */
  2466.  80,  60,  60,  60,  60,  46,  46,  80,  /*   32 */
  2467.  80,  46,  46,  80,  80,  60,  46,  46,  /*   32 */
  2468.  46,  46,  46,  46,  46,  46,  46,  80,  /*   32 */
  2469.  46,  46,  46,  46,  40,  40,  46,  40,  /*   32 */
  2470.  40,  40,  60,  60,  46,  46,  81,  81,  /*   32 */
  2471.  81,  81,  81,  81,  81,  81,  81,  81,  /*   32 */
  2472.  40,  40,   4,   4,  82,  82,  82,  82,  /*   32 */
  2473.  19,  83,  15,  46,  46,  46,  46,  46,  /*   32 */
  2474.  46,  46,  60,  46,  46,  40,  40,  40,  /*   33 */
  2475.  40,  40,  40,  46,  46,  46,  46,  40,  /*   33 */
  2476.  40,  46,  46,  40,  40,  40,  40,  40,  /*   33 */
  2477.  40,  40,  40,  40,  40,  40,  40,  40,  /*   33 */
  2478.  40,  40,  40,  40,  40,  40,  40,  40,  /*   33 */
  2479.  40,  46,  40,  40,  40,  40,  40,  40,  /*   33 */
  2480.  40,  46,  40,  40,  46,  40,  40,  46,  /*   33 */
  2481.  40,  40,  46,  46,  60,  46,  80,  80,  /*   33 */
  2482.  80,  60,  60,  46,  46,  46,  46,  60,  /*   34 */
  2483.  60,  46,  46,  60,  60,  60,  46,  46,  /*   34 */
  2484.  46,  46,  46,  46,  46,  46,  46,  46,  /*   34 */
  2485.  46,  40,  40,  40,  40,  46,  40,  46,  /*   34 */
  2486.  46,  46,  46,  46,  46,  46,  81,  81,  /*   34 */
  2487.  81,  81,  81,  81,  81,  81,  81,  81,  /*   34 */
  2488.  60,  60,  40,  40,  40,  46,  46,  46,  /*   34 */
  2489.  46,  46,  46,  46,  46,  46,  46,  46,  /*   34 */
  2490.  46,  60,  60,  80,  46,  40,  40,  40,  /*   35 */
  2491.  40,  40,  40,  40,  46,  40,  46,  40,  /*   35 */
  2492.  40,  40,  46,  40,  40,  40,  40,  40,  /*   35 */
  2493.  40,  40,  40,  40,  40,  40,  40,  40,  /*   35 */
  2494.  40,  40,  40,  40,  40,  40,  40,  40,  /*   35 */
  2495.  40,  46,  40,  40,  40,  40,  40,  40,  /*   35 */
  2496.  40,  46,  40,  40,  46,  40,  40,  40,  /*   35 */
  2497.  40,  40,  46,  46,  60,  40,  80,  80,  /*   35 */
  2498.  80,  60,  60,  60,  60,  60,  46,  60,  /*   36 */
  2499.  60,  80,  46,  80,  80,  60,  46,  46,  /*   36 */
  2500.  15,  46,  46,  46,  46,  46,  46,  46,  /*   36 */
  2501.  46,  46,  46,  46,  46,  46,  46,  46,  /*   36 */
  2502.  40,  46,  46,  46,  46,  46,  81,  81,  /*   36 */
  2503.  81,  81,  81,  81,  81,  81,  81,  81,  /*   36 */
  2504.  46,  46,  46,  46,  46,  46,  46,  46,  /*   36 */
  2505.  46,  46,  46,  46,  46,  46,  46,  46,  /*   36 */
  2506.  46,  60,  80,  80,  46,  40,  40,  40,  /*   37 */
  2507.  40,  40,  40,  40,  40,  46,  46,  40,  /*   37 */
  2508.  40,  46,  46,  40,  40,  40,  40,  40,  /*   37 */
  2509.  40,  40,  40,  40,  40,  40,  40,  40,  /*   37 */
  2510.  40,  40,  40,  40,  40,  40,  40,  40,  /*   37 */
  2511.  40,  46,  40,  40,  40,  40,  40,  40,  /*   37 */
  2512.  40,  46,  40,  40,  46,  46,  40,  40,  /*   37 */
  2513.  40,  40,  46,  46,  60,  40,  80,  60,  /*   37 */
  2514.  80,  60,  60,  60,  46,  46,  46,  80,  /*   38 */
  2515.  80,  46,  46,  80,  80,  60,  46,  46,  /*   38 */
  2516.  46,  46,  46,  46,  46,  46,  60,  80,  /*   38 */
  2517.  46,  46,  46,  46,  40,  40,  46,  40,  /*   38 */
  2518.  40,  40,  46,  46,  46,  46,  81,  81,  /*   38 */
  2519.  81,  81,  81,  81,  81,  81,  81,  81,  /*   38 */
  2520.  15,  46,  46,  46,  46,  46,  46,  46,  /*   38 */
  2521.  46,  46,  46,  46,  46,  46,  46,  46,  /*   38 */
  2522.  46,  46,  60,  80,  46,  40,  40,  40,  /*   39 */
  2523.  40,  40,  40,  46,  46,  46,  40,  40,  /*   39 */
  2524.  40,  46,  40,  40,  40,  40,  46,  46,  /*   39 */
  2525.  46,  40,  40,  46,  40,  46,  40,  40,  /*   39 */
  2526.  46,  46,  46,  40,  40,  46,  46,  46,  /*   39 */
  2527.  40,  40,  40,  46,  46,  46,  40,  40,  /*   39 */
  2528.  40,  40,  40,  40,  40,  40,  46,  40,  /*   39 */
  2529.  40,  40,  46,  46,  46,  46,  80,  80,  /*   39 */
  2530.  60,  80,  80,  46,  46,  46,  80,  80,  /*   40 */
  2531.  80,  46,  80,  80,  80,  60,  46,  46,  /*   40 */
  2532.  46,  46,  46,  46,  46,  46,  46,  80,  /*   40 */
  2533.  46,  46,  46,  46,  46,  46,  46,  46,  /*   40 */
  2534.  46,  46,  46,  46,  46,  46,  46,  81,  /*   40 */
  2535.  81,  81,  81,  81,  81,  81,  81,  81,  /*   40 */
  2536.  84,  19,  19,  46,  46,  46,  46,  46,  /*   40 */
  2537.  46,  46,  46,  46,  46,  46,  46,  46,  /*   40 */
  2538.  46,  80,  80,  80,  46,  40,  40,  40,  /*   41 */
  2539.  40,  40,  40,  40,  40,  46,  40,  40,  /*   41 */
  2540.  40,  46,  40,  40,  40,  40,  40,  40,  /*   41 */
  2541.  40,  40,  40,  40,  40,  40,  40,  40,  /*   41 */
  2542.  40,  40,  40,  40,  40,  40,  40,  40,  /*   41 */
  2543.  40,  46,  40,  40,  40,  40,  40,  40,  /*   41 */
  2544.  40,  40,  40,  40,  46,  40,  40,  40,  /*   41 */
  2545.  40,  40,  46,  46,  46,  46,  60,  60,  /*   41 */
  2546.  60,  80,  80,  80,  80,  46,  60,  60,  /*   42 */
  2547.  60,  46,  60,  60,  60,  60,  46,  46,  /*   42 */
  2548.  46,  46,  46,  46,  46,  60,  60,  46,  /*   42 */
  2549.  46,  46,  46,  46,  46,  46,  46,  46,  /*   42 */
  2550.  40,  40,  46,  46,  46,  46,  81,  81,  /*   42 */
  2551.  81,  81,  81,  81,  81,  81,  81,  81,  /*   42 */
  2552.  46,  46,  46,  46,  46,  46,  46,  46,  /*   42 */
  2553.  46,  46,  46,  46,  46,  46,  46,  46,  /*   42 */
  2554.  46,  46,  80,  80,  46,  40,  40,  40,  /*   43 */
  2555.  40,  40,  40,  40,  40,  46,  40,  40,  /*   43 */
  2556.  40,  46,  40,  40,  40,  40,  40,  40,  /*   43 */
  2557.  40,  40,  40,  40,  40,  40,  40,  40,  /*   43 */
  2558.  40,  40,  40,  40,  40,  40,  40,  40,  /*   43 */
  2559.  40,  46,  40,  40,  40,  40,  40,  40,  /*   43 */
  2560.  40,  40,  40,  40,  46,  40,  40,  40,  /*   43 */
  2561.  40,  40,  46,  46,  46,  46,  80,  60,  /*   43 */
  2562.  80,  80,  80,  80,  80,  46,  60,  80,  /*   44 */
  2563.  80,  46,  80,  80,  60,  60,  46,  46,  /*   44 */
  2564.  46,  46,  46,  46,  46,  80,  80,  46,  /*   44 */
  2565.  46,  46,  46,  46,  46,  46,  40,  46,  /*   44 */
  2566.  40,  40,  46,  46,  46,  46,  81,  81,  /*   44 */
  2567.  81,  81,  81,  81,  81,  81,  81,  81,  /*   44 */
  2568.  46,  46,  46,  46,  46,  46,  46,  46,  /*   44 */
  2569.  46,  46,  46,  46,  46,  46,  46,  46,  /*   44 */
  2570.  46,  46,  80,  80,  46,  40,  40,  40,  /*   45 */
  2571.  40,  40,  40,  40,  40,  46,  40,  40,  /*   45 */
  2572.  40,  46,  40,  40,  40,  40,  40,  40,  /*   45 */
  2573.  40,  40,  40,  40,  40,  40,  40,  40,  /*   45 */
  2574.  40,  40,  40,  40,  40,  40,  40,  40,  /*   45 */
  2575.  40,  46,  40,  40,  40,  40,  40,  40,  /*   45 */
  2576.  40,  40,  40,  40,  40,  40,  40,  40,  /*   45 */
  2577.  40,  40,  46,  46,  46,  46,  80,  80,  /*   45 */
  2578.  80,  60,  60,  60,  46,  46,  80,  80,  /*   46 */
  2579.  80,  46,  80,  80,  80,  60,  46,  46,  /*   46 */
  2580.  46,  46,  46,  46,  46,  46,  46,  80,  /*   46 */
  2581.  46,  46,  46,  46,  46,  46,  46,  46,  /*   46 */
  2582.  40,  40,  46,  46,  46,  46,  81,  81,  /*   46 */
  2583.  81,  81,  81,  81,  81,  81,  81,  81,  /*   46 */
  2584.  46,  46,  46,  46,  46,  46,  46,  46,  /*   46 */
  2585.  46,  46,  46,  46,  46,  46,  46,  46,  /*   46 */
  2586.  46,  40,  40,  40,  40,  40,  40,  40,  /*   47 */
  2587.  40,  40,  40,  40,  40,  40,  40,  40,  /*   47 */
  2588.  40,  40,  40,  40,  40,  40,  40,  40,  /*   47 */
  2589.  40,  40,  40,  40,  40,  40,  40,  40,  /*   47 */
  2590.  40,  40,  40,  40,  40,  40,  40,  40,  /*   47 */
  2591.  40,  40,  40,  40,  40,  40,  40,   3,  /*   47 */
  2592.  40,  60,  40,  40,  60,  60,  60,  60,  /*   47 */
  2593.  60,  60,  60,  46,  46,  46,  46,   4,  /*   47 */
  2594.  40,  40,  40,  40,  40,  40,  59,  60,  /*   48 */
  2595.  60,  60,  60,  60,  60,  60,  60,  15,  /*   48 */
  2596.   9,   9,   9,   9,   9,   9,   9,   9,  /*   48 */
  2597.   9,   9,   3,   3,  46,  46,  46,  46,  /*   48 */
  2598.  46,  46,  46,  46,  46,  46,  46,  46,  /*   48 */
  2599.  46,  46,  46,  46,  46,  46,  46,  46,  /*   48 */
  2600.  46,  46,  46,  46,  46,  46,  46,  46,  /*   48 */
  2601.  46,  46,  46,  46,  46,  46,  46,  46,  /*   48 */
  2602.  46,  40,  40,  46,  40,  46,  46,  40,  /*   49 */
  2603.  40,  46,  40,  46,  46,  40,  46,  46,  /*   49 */
  2604.  46,  46,  46,  46,  40,  40,  40,  40,  /*   49 */
  2605.  46,  40,  40,  40,  40,  40,  40,  40,  /*   49 */
  2606.  46,  40,  40,  40,  46,  40,  46,  40,  /*   49 */
  2607.  46,  46,  40,  40,  46,  40,  40,   3,  /*   49 */
  2608.  40,  60,  40,  40,  60,  60,  60,  60,  /*   49 */
  2609.  60,  60,  46,  60,  60,  40,  46,  46,  /*   49 */
  2610.  40,  40,  40,  40,  40,  46,  59,  46,  /*   50 */
  2611.  60,  60,  60,  60,  60,  60,  46,  46,  /*   50 */
  2612.   9,   9,   9,   9,   9,   9,   9,   9,  /*   50 */
  2613.   9,   9,  46,  46,  40,  40,  46,  46,  /*   50 */
  2614.  46,  46,  46,  46,  46,  46,  46,  46,  /*   50 */
  2615.  46,  46,  46,  46,  46,  46,  46,  46,  /*   50 */
  2616.  46,  46,  46,  46,  46,  46,  46,  46,  /*   50 */
  2617.  46,  46,  46,  46,  46,  46,  46,  46,  /*   50 */
  2618.  15,  15,  15,  15,   3,   3,   3,   3,  /*   51 */
  2619.   3,   3,   3,   3,   3,   3,   3,   3,  /*   51 */
  2620.   3,   3,   3,  15,  15,  15,  15,  15,  /*   51 */
  2621.  60,  60,  15,  15,  15,  15,  15,  15,  /*   51 */
  2622.  78,  78,  78,  78,  78,  78,  78,  78,  /*   51 */
  2623.  78,  78,  85,  85,  85,  85,  85,  85,  /*   51 */
  2624.  85,  85,  85,  85,  15,  60,  15,  60,  /*   51 */
  2625.  15,  60,   5,   6,   5,   6,  80,  80,  /*   51 */
  2626.  40,  40,  40,  40,  40,  40,  40,  40,  /*   52 */
  2627.  46,  40,  40,  40,  40,  40,  40,  40,  /*   52 */
  2628.  40,  40,  40,  40,  40,  40,  40,  40,  /*   52 */
  2629.  40,  40,  40,  40,  40,  40,  40,  40,  /*   52 */
  2630.  40,  40,  40,  40,  40,  40,  40,  40,  /*   52 */
  2631.  40,  40,  46,  46,  46,  46,  46,  46,  /*   52 */
  2632.  46,  60,  60,  60,  60,  60,  60,  60,  /*   52 */
  2633.  60,  60,  60,  60,  60,  60,  60,  80,  /*   52 */
  2634.  60,  60,  60,  60,  60,   3,  60,  60,  /*   53 */
  2635.  60,  60,  60,  60,  46,  46,  46,  46,  /*   53 */
  2636.  60,  60,  60,  60,  60,  60,  46,  60,  /*   53 */
  2637.  46,  60,  60,  60,  60,  60,  60,  60,  /*   53 */
  2638.  60,  60,  60,  60,  60,  60,  60,  60,  /*   53 */
  2639.  60,  60,  60,  60,  60,  60,  46,  46,  /*   53 */
  2640.  46,  60,  60,  60,  60,  60,  60,  60,  /*   53 */
  2641.  46,  60,  46,  46,  46,  46,  46,  46,  /*   53 */
  2642.  46,  46,  46,  46,  46,  46,  46,  46,  /*   54 */
  2643.  46,  46,  46,  46,  46,  46,  46,  46,  /*   54 */
  2644.  46,  46,  46,  46,  46,  46,  46,  46,  /*   54 */
  2645.  46,  46,  46,  46,  46,  46,  46,  46,  /*   54 */
  2646.  76,  76,  76,  76,  76,  76,  76,  76,  /*   54 */
  2647.  76,  76,  76,  76,  76,  76,  76,  76,  /*   54 */
  2648.  76,  76,  76,  76,  76,  76,  76,  76,  /*   54 */
  2649.  76,  76,  76,  76,  76,  76,  76,  76,  /*   54 */
  2650.  76,  76,  76,  76,  76,  76,  46,  46,  /*   55 */
  2651.  46,  46,  46,  46,  46,  46,  46,  46,  /*   55 */
  2652.  16,  16,  16,  16,  16,  16,  16,  16,  /*   55 */
  2653.  16,  16,  16,  16,  16,  16,  16,  16,  /*   55 */
  2654.  16,  16,  16,  16,  16,  16,  16,  16,  /*   55 */
  2655.  16,  16,  16,  16,  16,  16,  16,  16,  /*   55 */
  2656.  16,  16,  16,  16,  16,  16,  16,  46,  /*   55 */
  2657.  46,  46,  46,   3,  46,  46,  46,  46,  /*   55 */
  2658.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2659.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2660.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2661.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2662.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2663.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2664.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2665.  40,  40,  40,  40,  40,  40,  40,  40,  /*   56 */
  2666.  40,  40,  40,  40,  40,  40,  40,  40,  /*   57 */
  2667.  40,  40,  40,  40,  40,  40,  40,  40,  /*   57 */
  2668.  40,  40,  40,  40,  40,  40,  40,  40,  /*   57 */
  2669.  40,  40,  46,  46,  46,  46,  46,  40,  /*   57 */
  2670.  40,  40,  40,  40,  40,  40,  40,  40,  /*   57 */
  2671.  40,  40,  40,  40,  40,  40,  40,  40,  /*   57 */
  2672.  40,  40,  40,  40,  40,  40,  40,  40,  /*   57 */
  2673.  40,  40,  40,  40,  40,  40,  40,  40,  /*   57 */
  2674.  40,  40,  40,  40,  40,  40,  40,  40,  /*   58 */
  2675.  40,  40,  40,  40,  40,  40,  40,  40,  /*   58 */
  2676.  40,  40,  40,  40,  40,  40,  40,  40,  /*   58 */
  2677.  40,  40,  40,  40,  40,  40,  40,  40,  /*   58 */
  2678.  40,  40,  40,  46,  46,  46,  46,  46,  /*   58 */
  2679.  40,  40,  40,  40,  40,  40,  40,  40,  /*   58 */
  2680.  40,  40,  40,  40,  40,  40,  40,  40,  /*   58 */
  2681.  40,  40,  40,  40,  40,  40,  40,  40,  /*   58 */
  2682.  40,  40,  40,  40,  40,  40,  40,  40,  /*   59 */
  2683.  40,  40,  40,  40,  40,  40,  40,  40,  /*   59 */
  2684.  40,  40,  40,  40,  40,  40,  40,  40,  /*   59 */
  2685.  40,  40,  40,  40,  40,  40,  40,  40,  /*   59 */
  2686.  40,  40,  40,  40,  40,  40,  40,  40,  /*   59 */
  2687.  40,  40,  40,  40,  40,  40,  40,  40,  /*   59 */
  2688.  40,  40,  40,  40,  40,  40,  40,  40,  /*   59 */
  2689.  40,  40,  46,  46,  46,  46,  46,  46,  /*   59 */
  2690.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2691.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2692.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2693.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2694.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2695.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2696.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2697.  23,  24,  23,  24,  23,  24,  23,  24,  /*   60 */
  2698.  23,  24,  23,  24,  23,  24,  23,  24,  /*   61 */
  2699.  23,  24,  23,  24,  23,  24,  23,  24,  /*   61 */
  2700.  23,  24,  23,  24,  23,  24,  16,  16,  /*   61 */
  2701.  16,  16,  16,  16,  46,  46,  46,  46,  /*   61 */
  2702.  23,  24,  23,  24,  23,  24,  23,  24,  /*   61 */
  2703.  23,  24,  23,  24,  23,  24,  23,  24,  /*   61 */
  2704.  23,  24,  23,  24,  23,  24,  23,  24,  /*   61 */
  2705.  23,  24,  23,  24,  23,  24,  23,  24,  /*   61 */
  2706.  23,  24,  23,  24,  23,  24,  23,  24,  /*   62 */
  2707.  23,  24,  23,  24,  23,  24,  23,  24,  /*   62 */
  2708.  23,  24,  23,  24,  23,  24,  23,  24,  /*   62 */
  2709.  23,  24,  23,  24,  23,  24,  23,  24,  /*   62 */
  2710.  23,  24,  23,  24,  23,  24,  23,  24,  /*   62 */
  2711.  23,  24,  23,  24,  23,  24,  23,  24,  /*   62 */
  2712.  23,  24,  23,  24,  23,  24,  23,  24,  /*   62 */
  2713.  23,  24,  46,  46,  46,  46,  46,  46,  /*   62 */
  2714.  86,  86,  86,  86,  86,  86,  86,  86,  /*   63 */
  2715.  87,  87,  87,  87,  87,  87,  87,  87,  /*   63 */
  2716.  86,  86,  86,  86,  86,  86,  46,  46,  /*   63 */
  2717.  87,  87,  87,  87,  87,  87,  46,  46,  /*   63 */
  2718.  86,  86,  86,  86,  86,  86,  86,  86,  /*   63 */
  2719.  87,  87,  87,  87,  87,  87,  87,  87,  /*   63 */
  2720.  86,  86,  86,  86,  86,  86,  86,  86,  /*   63 */
  2721.  87,  87,  87,  87,  87,  87,  87,  87,  /*   63 */
  2722.  86,  86,  86,  86,  86,  86,  46,  46,  /*   64 */
  2723.  87,  87,  87,  87,  87,  87,  46,  46,  /*   64 */
  2724.  16,  86,  16,  86,  16,  86,  16,  86,  /*   64 */
  2725.  46,  87,  46,  87,  46,  87,  46,  87,  /*   64 */
  2726.  86,  86,  86,  86,  86,  86,  86,  86,  /*   64 */
  2727.  87,  87,  87,  87,  87,  87,  87,  87,  /*   64 */
  2728.  88,  88,  89,  89,  89,  89,  90,  90,  /*   64 */
  2729.  91,  91,  92,  92,  93,  93,  46,  46,  /*   64 */
  2730.  86,  86,  86,  86,  86,  86,  86,  86,  /*   65 */
  2731.  87,  87,  87,  87,  87,  87,  87,  87,  /*   65 */
  2732.  86,  86,  86,  86,  86,  86,  86,  86,  /*   65 */
  2733.  87,  87,  87,  87,  87,  87,  87,  87,  /*   65 */
  2734.  86,  86,  86,  86,  86,  86,  86,  86,  /*   65 */
  2735.  87,  87,  87,  87,  87,  87,  87,  87,  /*   65 */
  2736.  86,  86,  16,  94,  16,  46,  16,  16,  /*   65 */
  2737.  87,  87,  95,  95,  96,  11,  38,  11,  /*   65 */
  2738.  11,  11,  16,  94,  16,  46,  16,  16,  /*   66 */
  2739.  97,  97,  97,  97,  96,  11,  11,  11,  /*   66 */
  2740.  86,  86,  16,  16,  46,  46,  16,  16,  /*   66 */
  2741.  87,  87,  98,  98,  46,  11,  11,  11,  /*   66 */
  2742.  86,  86,  16,  16,  16,  99,  16,  16,  /*   66 */
  2743.  87,  87, 100, 100, 101,  11,  11,  11,  /*   66 */
  2744.  46,  46,  16,  94,  16,  46,  16,  16,  /*   66 */
  2745. 102, 102, 103, 103,  96,  11,  11,  46,  /*   66 */
  2746.   2,   2,   2,   2,   2,   2,   2,   2,  /*   67 */
  2747.   2,   2,   2,   2, 104, 104, 104, 104,  /*   67 */
  2748.   8,   8,   8,   8,   8,   8,   3,   3,  /*   67 */
  2749.   5,   6,   5,   5,   5,   6,   5,   5,  /*   67 */
  2750.   3,   3,   3,   3,   3,   3,   3,   3,  /*   67 */
  2751. 105, 106, 104, 104, 104, 104, 104,  46,  /*   67 */
  2752.   3,   3,   3,   3,   3,   3,   3,   3,  /*   67 */
  2753.   3,   5,   6,   3,   3,   3,   3,  12,  /*   67 */
  2754.  12,   3,   3,   3,   7,   5,   6,  46,  /*   68 */
  2755.  46,  46,  46,  46,  46,  46,  46,  46,  /*   68 */
  2756.  46,  46,  46,  46,  46,  46,  46,  46,  /*   68 */
  2757.  46,  46,  46,  46,  46,  46,  46,  46,  /*   68 */
  2758.  46,  46,  46,  46,  46,  46,  46,  46,  /*   68 */
  2759.  46,  46, 104, 104, 104, 104, 104, 104,  /*   68 */
  2760.  17,  46,  46,  46,  17,  17,  17,  17,  /*   68 */
  2761.  17,  17,   7,   7,   7,   5,   6,  16,  /*   68 */
  2762. 107, 107, 107, 107, 107, 107, 107, 107,  /*   69 */
  2763. 107, 107,   7,   7,   7,   5,   6,  46,  /*   69 */
  2764.  46,  46,  46,  46,  46,  46,  46,  46,  /*   69 */
  2765.  46,  46,  46,  46,  46,  46,  46,  46,  /*   69 */
  2766.   4,   4,   4,   4,   4,   4,   4,   4,  /*   69 */
  2767.   4,   4,   4,   4,  46,  46,  46,  46,  /*   69 */
  2768.  46,  46,  46,  46,  46,  46,  46,  46,  /*   69 */
  2769.  46,  46,  46,  46,  46,  46,  46,  46,  /*   69 */
  2770.  46,  46,  46,  46,  46,  46,  46,  46,  /*   70 */
  2771.  46,  46,  46,  46,  46,  46,  46,  46,  /*   70 */
  2772.  60,  60,  60,  60,  60,  60,  60,  60,  /*   70 */
  2773.  60,  60,  60,  60,  60,  79,  79,  79,  /*   70 */
  2774.  79,  60,  46,  46,  46,  46,  46,  46,  /*   70 */
  2775.  46,  46,  46,  46,  46,  46,  46,  46,  /*   70 */
  2776.  46,  46,  46,  46,  46,  46,  46,  46,  /*   70 */
  2777.  46,  46,  46,  46,  46,  46,  46,  46,  /*   70 */
  2778.  15,  15,  38,  15,  15,  15,  15,  38,  /*   71 */
  2779.  15,  15,  16,  38,  38,  38,  16,  16,  /*   71 */
  2780.  38,  38,  38,  16,  15,  38,  15,  15,  /*   71 */
  2781.  38,  38,  38,  38,  38,  38,  15,  15,  /*   71 */
  2782.  15,  15,  15,  15,  38,  15,  38,  15,  /*   71 */
  2783.  38,  15,  38,  38,  38,  38,  16,  16,  /*   71 */
  2784.  38,  38,  15,  38,  16,  40,  40,  40,  /*   71 */
  2785.  40,  46,  46,  46,  46,  46,  46,  46,  /*   71 */
  2786.  46,  46,  46,  46,  46,  46,  46,  46,  /*   72 */
  2787.  46,  46,  46,  46,  46,  46,  46,  46,  /*   72 */
  2788.  46,  46,  46,  19,  19,  19,  19,  19,  /*   72 */
  2789.  19,  19,  19,  19,  19,  19,  19, 108,  /*   72 */
  2790. 109, 109, 109, 109, 109, 109, 109, 109,  /*   72 */
  2791. 109, 109, 109, 109, 110, 110, 110, 110,  /*   72 */
  2792. 111, 111, 111, 111, 111, 111, 111, 111,  /*   72 */
  2793. 111, 111, 111, 111, 112, 112, 112, 112,  /*   72 */
  2794. 113, 113, 113,  46,  46,  46,  46,  46,  /*   73 */
  2795.  46,  46,  46,  46,  46,  46,  46,  46,  /*   73 */
  2796.   7,   7,   7,   7,   7,  15,  15,  15,  /*   73 */
  2797.  15,  15,  15,  15,  15,  15,  15,  15,  /*   73 */
  2798.  15,  15,  15,  15,  15,  15,  15,  15,  /*   73 */
  2799.  15,  15,  15,  15,  15,  15,  15,  15,  /*   73 */
  2800.  15,  15,  15,  15,  15,  15,  15,  15,  /*   73 */
  2801.  15,  15,  15,  15,  15,  15,  15,  15,  /*   73 */
  2802.  15,  15,  15,  15,  15,  15,  15,  15,  /*   74 */
  2803.  15,  15,  15,  15,  15,  15,  15,  15,  /*   74 */
  2804.  15,  15,   7,  15,   7,  15,  15,  15,  /*   74 */
  2805.  15,  15,  15,  15,  15,  15,  15,  15,  /*   74 */
  2806.  15,  15,  15,  15,  15,  15,  15,  15,  /*   74 */
  2807.  15,  15,  15,  46,  46,  46,  46,  46,  /*   74 */
  2808.  46,  46,  46,  46,  46,  46,  46,  46,  /*   74 */
  2809.  46,  46,  46,  46,  46,  46,  46,  46,  /*   74 */
  2810.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2811.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2812.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2813.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2814.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2815.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2816.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2817.   7,   7,   7,   7,   7,   7,   7,   7,  /*   75 */
  2818.   7,   7,   7,   7,   7,   7,   7,   7,  /*   76 */
  2819.   7,   7,   7,   7,   7,   7,   7,   7,  /*   76 */
  2820.   7,   7,   7,   7,   7,   7,   7,   7,  /*   76 */
  2821.   7,   7,   7,   7,   7,   7,   7,   7,  /*   76 */
  2822.   7,   7,   7,   7,   7,   7,   7,   7,  /*   76 */
  2823.   7,   7,   7,   7,   7,   7,   7,   7,  /*   76 */
  2824.   7,   7,  46,  46,  46,  46,  46,  46,  /*   76 */
  2825.  46,  46,  46,  46,  46,  46,  46,  46,  /*   76 */
  2826.  15,  46,  15,  15,  15,  15,  15,  15,  /*   77 */
  2827.   7,   7,   7,   7,  15,  15,  15,  15,  /*   77 */
  2828.  15,  15,  15,  15,  15,  15,  15,  15,  /*   77 */
  2829.  15,  15,  15,  15,  15,  15,  15,  15,  /*   77 */
  2830.   7,   7,  15,  15,  15,  15,  15,  15,  /*   77 */
  2831.  15,   5,   6,  15,  15,  15,  15,  15,  /*   77 */
  2832.  15,  15,  15,  15,  15,  15,  15,  15,  /*   77 */
  2833.  15,  15,  15,  15,  15,  15,  15,  15,  /*   77 */
  2834.  15,  15,  15,  15,  15,  15,  15,  15,  /*   78 */
  2835.  15,  15,  15,  15,  15,  15,  15,  15,  /*   78 */
  2836.  15,  15,  15,  15,  15,  15,  15,  15,  /*   78 */
  2837.  15,  15,  15,  15,  15,  15,  15,  15,  /*   78 */
  2838.  15,  15,  15,  15,  15,  15,  15,  15,  /*   78 */
  2839.  15,  15,  15,  15,  15,  15,  15,  15,  /*   78 */
  2840.  15,  15,  15,  15,  15,  15,  15,  15,  /*   78 */
  2841.  15,  15,  15,  46,  46,  46,  46,  46,  /*   78 */
  2842.  15,  15,  15,  15,  15,  15,  15,  15,  /*   79 */
  2843.  15,  15,  15,  15,  15,  15,  15,  15,  /*   79 */
  2844.  15,  15,  15,  15,  15,  15,  15,  15,  /*   79 */
  2845.  15,  15,  15,  15,  15,  15,  15,  15,  /*   79 */
  2846.  15,  15,  15,  15,  15,  46,  46,  46,  /*   79 */
  2847.  46,  46,  46,  46,  46,  46,  46,  46,  /*   79 */
  2848.  46,  46,  46,  46,  46,  46,  46,  46,  /*   79 */
  2849.  46,  46,  46,  46,  46,  46,  46,  46,  /*   79 */
  2850.  15,  15,  15,  15,  15,  15,  15,  15,  /*   80 */
  2851.  15,  15,  15,  46,  46,  46,  46,  46,  /*   80 */
  2852.  46,  46,  46,  46,  46,  46,  46,  46,  /*   80 */
  2853.  46,  46,  46,  46,  46,  46,  46,  46,  /*   80 */
  2854. 114, 114, 114, 114, 114, 114, 114, 114,  /*   80 */
  2855. 114, 114, 114, 114, 114, 114, 114, 114,  /*   80 */
  2856. 114, 114, 114, 114,  82,  82,  82,  82,  /*   80 */
  2857.  82,  82,  82,  82,  82,  82,  82,  82,  /*   80 */
  2858.  82,  82,  82,  82,  82,  82,  82,  82,  /*   81 */
  2859. 115, 115, 115, 115, 115, 115, 115, 115,  /*   81 */
  2860. 115, 115, 115, 115, 115, 115, 115, 115,  /*   81 */
  2861. 115, 115, 115, 115,  15,  15,  15,  15,  /*   81 */
  2862.  15,  15,  15,  15,  15,  15,  15,  15,  /*   81 */
  2863.  15,  15,  15,  15,  15,  15,  15,  15,  /*   81 */
  2864.  15,  15,  15,  15,  15,  15, 116, 116,  /*   81 */
  2865. 116, 116, 116, 116, 116, 116, 116, 116,  /*   81 */
  2866. 116, 116, 116, 116, 116, 116, 116, 116,  /*   82 */
  2867. 116, 116, 116, 116, 116, 116, 116, 116,  /*   82 */
  2868. 117, 117, 117, 117, 117, 117, 117, 117,  /*   82 */
  2869. 117, 117, 117, 117, 117, 117, 117, 117,  /*   82 */
  2870. 117, 117, 117, 117, 117, 117, 117, 117,  /*   82 */
  2871. 117, 117, 118,  46,  46,  46,  46,  46,  /*   82 */
  2872.  46,  46,  46,  46,  46,  46,  46,  46,  /*   82 */
  2873.  46,  46,  46,  46,  46,  46,  46,  46,  /*   82 */
  2874.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2875.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2876.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2877.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2878.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2879.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2880.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2881.  15,  15,  15,  15,  15,  15,  15,  15,  /*   83 */
  2882.  15,  15,  15,  15,  15,  15,  15,  15,  /*   84 */
  2883.  15,  15,  15,  15,  15,  15,  15,  15,  /*   84 */
  2884.  15,  15,  15,  15,  15,  15,  46,  46,  /*   84 */
  2885.  46,  46,  46,  46,  46,  46,  46,  46,  /*   84 */
  2886.  15,  15,  15,  15,  15,  15,  15,  15,  /*   84 */
  2887.  15,  15,  15,  15,  15,  15,  15,  15,  /*   84 */
  2888.  15,  15,  15,  15,  15,  15,  15,  15,  /*   84 */
  2889.  15,  15,  15,  15,  15,  15,  15,  15,  /*   84 */
  2890.  15,  15,  15,  15,  15,  15,  15,  15,  /*   85 */
  2891.  15,  15,  15,  15,  15,  15,  15,  15,  /*   85 */
  2892.  15,  15,  15,  15,  15,  15,  15,  15,  /*   85 */
  2893.  15,  15,  15,  15,  15,  15,  15,  15,  /*   85 */
  2894.  15,  15,  15,  15,  15,  15,  15,  15,  /*   85 */
  2895.  15,  15,  15,  15,  15,  15,  15,  15,  /*   85 */
  2896.  46,  46,  46,  46,  46,  46,  46,  46,  /*   85 */
  2897.  46,  46,  46,  46,  46,  46,  46,  46,  /*   85 */
  2898.  15,  15,  15,  15,  15,  15,  15,  15,  /*   86 */
  2899.  15,  15,  15,  15,  15,  15,  15,  15,  /*   86 */
  2900.  15,  15,  15,  15,  46,  46,  46,  46,  /*   86 */
  2901.  46,  46,  15,  15,  15,  15,  15,  15,  /*   86 */
  2902.  15,  15,  15,  15,  15,  15,  15,  15,  /*   86 */
  2903.  15,  15,  15,  15,  15,  15,  15,  15,  /*   86 */
  2904.  15,  15,  15,  15,  15,  15,  15,  15,  /*   86 */
  2905.  15,  15,  15,  15,  15,  15,  15,  15,  /*   86 */
  2906.  46,  15,  15,  15,  15,  46,  15,  15,  /*   87 */
  2907.  15,  15,  46,  46,  15,  15,  15,  15,  /*   87 */
  2908.  15,  15,  15,  15,  15,  15,  15,  15,  /*   87 */
  2909.  15,  15,  15,  15,  15,  15,  15,  15,  /*   87 */
  2910.  15,  15,  15,  15,  15,  15,  15,  15,  /*   87 */
  2911.  46,  15,  15,  15,  15,  15,  15,  15,  /*   87 */
  2912.  15,  15,  15,  15,  15,  15,  15,  15,  /*   87 */
  2913.  15,  15,  15,  15,  15,  15,  15,  15,  /*   87 */
  2914.  15,  15,  15,  15,  15,  15,  15,  15,  /*   88 */
  2915.  15,  15,  15,  15,  46,  15,  46,  15,  /*   88 */
  2916.  15,  15,  15,  46,  46,  46,  15,  46,  /*   88 */
  2917.  15,  15,  15,  15,  15,  15,  15,  46,  /*   88 */
  2918.  46,  15,  15,  15,  15,  15,  15,  15,  /*   88 */
  2919.  46,  46,  46,  46,  46,  46,  46,  46,  /*   88 */
  2920.  46,  46,  46,  46,  46,  46, 119, 119,  /*   88 */
  2921. 119, 119, 119, 119, 119, 119, 119, 119,  /*   88 */
  2922. 114, 114, 114, 114, 114, 114, 114, 114,  /*   89 */
  2923. 114, 114,  83,  83,  83,  83,  83,  83,  /*   89 */
  2924.  83,  83,  83,  83,  15,  46,  46,  46,  /*   89 */
  2925.  15,  15,  15,  15,  15,  15,  15,  15,  /*   89 */
  2926.  15,  15,  15,  15,  15,  15,  15,  15,  /*   89 */
  2927.  15,  15,  15,  15,  15,  15,  15,  15,  /*   89 */
  2928.  46,  15,  15,  15,  15,  15,  15,  15,  /*   89 */
  2929.  15,  15,  15,  15,  15,  15,  15,  46,  /*   89 */
  2930.   2,   3,   3,   3,  15,  59,   3, 120,  /*   90 */
  2931.   5,   6,   5,   6,   5,   6,   5,   6,  /*   90 */
  2932.   5,   6,  15,  15,   5,   6,   5,   6,  /*   90 */
  2933.   5,   6,   5,   6,   8,   5,   6,   5,  /*   90 */
  2934.  15, 121, 121, 121, 121, 121, 121, 121,  /*   90 */
  2935. 121, 121,  60,  60,  60,  60,  60,  60,  /*   90 */
  2936.   8,  59,  59,  59,  59,  59,  15,  15,  /*   90 */
  2937.  46,  46,  46,  46,  46,  46,  46,  15,  /*   90 */
  2938.  46,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2939.  40,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2940.  40,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2941.  40,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2942.  40,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2943.  40,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2944.  40,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2945.  40,  40,  40,  40,  40,  40,  40,  40,  /*   91 */
  2946.  40,  40,  40,  40,  40,  40,  40,  40,  /*   92 */
  2947.  40,  40,  40,  40,  40,  40,  40,  40,  /*   92 */
  2948.  40,  40,  40,  40,  40,  46,  46,  46,  /*   92 */
  2949.  46,  60,  60,  59,  59,  59,  59,  46,  /*   92 */
  2950.  46,  40,  40,  40,  40,  40,  40,  40,  /*   92 */
  2951.  40,  40,  40,  40,  40,  40,  40,  40,  /*   92 */
  2952.  40,  40,  40,  40,  40,  40,  40,  40,  /*   92 */
  2953.  40,  40,  40,  40,  40,  40,  40,  40,  /*   92 */
  2954.  40,  40,  40,  40,  40,  40,  40,  40,  /*   93 */
  2955.  40,  40,  40,  40,  40,  40,  40,  40,  /*   93 */
  2956.  40,  40,  40,  40,  40,  40,  40,  40,  /*   93 */
  2957.  40,  40,  40,  40,  40,  40,  40,  40,  /*   93 */
  2958.  40,  40,  40,  40,  40,  40,  40,  40,  /*   93 */
  2959.  40,  40,  40,  40,  40,  40,  40,  40,  /*   93 */
  2960.  40,  40,  40,  40,  40,  40,  40,  40,  /*   93 */
  2961.  40,  40,  40,   3,  59,  59,  59,  46,  /*   93 */
  2962.  46,  46,  46,  46,  46,  40,  40,  40,  /*   94 */
  2963.  40,  40,  40,  40,  40,  40,  40,  40,  /*   94 */
  2964.  40,  40,  40,  40,  40,  40,  40,  40,  /*   94 */
  2965.  40,  40,  40,  40,  40,  40,  40,  40,  /*   94 */
  2966.  40,  40,  40,  40,  40,  40,  40,  40,  /*   94 */
  2967.  40,  40,  40,  40,  40,  46,  46,  46,  /*   94 */
  2968.  46,  40,  40,  40,  40,  40,  40,  40,  /*   94 */
  2969.  40,  40,  40,  40,  40,  40,  40,  40,  /*   94 */
  2970.  40,  40,  40,  40,  40,  40,  40,  40,  /*   95 */
  2971.  40,  40,  40,  40,  40,  40,  40,  46,  /*   95 */
  2972.  15,  15,  85,  85,  85,  85,  15,  15,  /*   95 */
  2973.  15,  15,  15,  15,  15,  15,  15,  15,  /*   95 */
  2974.  46,  46,  46,  46,  46,  46,  46,  46,  /*   95 */
  2975.  46,  46,  46,  46,  46,  46,  46,  46,  /*   95 */
  2976.  46,  46,  46,  46,  46,  46,  46,  46,  /*   95 */
  2977.  46,  46,  46,  46,  46,  46,  46,  46,  /*   95 */
  2978.  15,  15,  15,  15,  15,  15,  15,  15,  /*   96 */
  2979.  15,  15,  15,  15,  15,  15,  15,  15,  /*   96 */
  2980.  15,  15,  15,  15,  15,  15,  15,  15,  /*   96 */
  2981.  15,  15,  15,  15,  15,  46,  46,  46,  /*   96 */
  2982.  85,  85,  85,  85,  85,  85,  85,  85,  /*   96 */
  2983.  85,  85,  15,  15,  15,  15,  15,  15,  /*   96 */
  2984.  15,  15,  15,  15,  15,  15,  15,  15,  /*   96 */
  2985.  15,  15,  15,  15,  15,  15,  15,  15,  /*   96 */
  2986.  15,  15,  15,  15,  46,  46,  46,  46,  /*   97 */
  2987.  46,  46,  46,  46,  46,  46,  46,  46,  /*   97 */
  2988.  46,  46,  46,  46,  46,  46,  46,  46,  /*   97 */
  2989.  46,  46,  46,  46,  46,  46,  46,  46,  /*   97 */
  2990.  15,  15,  15,  15,  15,  15,  15,  15,  /*   97 */
  2991.  15,  15,  15,  15,  15,  15,  15,  15,  /*   97 */
  2992.  15,  15,  15,  15,  15,  15,  15,  15,  /*   97 */
  2993.  15,  15,  15,  15,  46,  46,  46,  15,  /*   97 */
  2994. 114, 114, 114, 114, 114, 114, 114, 114,  /*   98 */
  2995. 114, 114,  15,  15,  15,  15,  15,  15,  /*   98 */
  2996.  15,  15,  15,  15,  15,  15,  15,  15,  /*   98 */
  2997.  15,  15,  15,  15,  15,  15,  15,  15,  /*   98 */
  2998.  15,  15,  15,  15,  15,  15,  15,  15,  /*   98 */
  2999.  15,  15,  15,  15,  15,  15,  15,  15,  /*   98 */
  3000.  15,  46,  46,  46,  46,  46,  46,  46,  /*   98 */
  3001.  46,  46,  46,  46,  46,  46,  46,  46,  /*   98 */
  3002.  15,  15,  15,  15,  15,  15,  15,  15,  /*   99 */
  3003.  15,  15,  15,  15,  46,  46,  46,  46,  /*   99 */
  3004.  15,  15,  15,  15,  15,  15,  15,  15,  /*   99 */
  3005.  15,  15,  15,  15,  15,  15,  15,  15,  /*   99 */
  3006.  15,  15,  15,  15,  15,  15,  15,  15,  /*   99 */
  3007.  15,  15,  15,  15,  15,  15,  15,  15,  /*   99 */
  3008.  15,  15,  15,  15,  15,  15,  15,  15,  /*   99 */
  3009.  15,  15,  15,  15,  15,  15,  15,  46,  /*   99 */
  3010.  15,  15,  15,  15,  15,  15,  15,  15,  /*  100 */
  3011.  15,  15,  15,  15,  15,  15,  15,  15,  /*  100 */
  3012.  15,  15,  15,  15,  15,  15,  15,  15,  /*  100 */
  3013.  15,  15,  15,  15,  15,  15,  15,  15,  /*  100 */
  3014.  15,  15,  15,  15,  15,  15,  15,  15,  /*  100 */
  3015.  15,  15,  15,  15,  15,  15,  15,  15,  /*  100 */
  3016.  15,  15,  15,  15,  15,  15,  15,  46,  /*  100 */
  3017.  46,  46,  46,  15,  15,  15,  15,  15,  /*  100 */
  3018.  15,  15,  15,  15,  15,  15,  15,  15,  /*  101 */
  3019.  15,  15,  15,  15,  15,  15,  15,  15,  /*  101 */
  3020.  15,  15,  15,  15,  15,  15,  15,  15,  /*  101 */
  3021.  15,  15,  15,  15,  15,  15,  46,  46,  /*  101 */
  3022.  15,  15,  15,  15,  15,  15,  15,  15,  /*  101 */
  3023.  15,  15,  15,  15,  15,  15,  15,  15,  /*  101 */
  3024.  15,  15,  15,  15,  15,  15,  15,  15,  /*  101 */
  3025.  15,  15,  15,  15,  15,  15,  15,  46,  /*  101 */
  3026.  40,  40,  40,  40,  40,  40,  40,  40,  /*  102 */
  3027.  40,  40,  40,  40,  40,  40,  40,  40,  /*  102 */
  3028.  40,  40,  40,  40,  40,  40,  40,  40,  /*  102 */
  3029.  40,  40,  40,  40,  40,  40,  40,  40,  /*  102 */
  3030.  40,  40,  40,  40,  40,  40,  46,  46,  /*  102 */
  3031.  46,  46,  46,  46,  46,  46,  46,  46,  /*  102 */
  3032.  46,  46,  46,  46,  46,  46,  46,  46,  /*  102 */
  3033.  46,  46,  46,  46,  46,  46,  46,  46,  /*  102 */
  3034.  40,  40,  40,  40,  40,  40,  40,  40,  /*  103 */
  3035.  40,  40,  40,  40,  40,  40,  40,  40,  /*  103 */
  3036.  40,  40,  40,  40,  40,  40,  40,  40,  /*  103 */
  3037.  40,  40,  40,  40,  40,  40,  40,  40,  /*  103 */
  3038.  40,  40,  40,  40,  46,  46,  46,  46,  /*  103 */
  3039.  46,  46,  46,  46,  46,  46,  46,  46,  /*  103 */
  3040.  46,  46,  46,  46,  46,  46,  46,  46,  /*  103 */
  3041.  46,  46,  46,  46,  46,  46,  46,  46,  /*  103 */
  3042. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3043. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3044. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3045. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3046. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3047. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3048. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3049. 122, 122, 122, 122, 122, 122, 122, 122,  /*  104 */
  3050. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3051. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3052. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3053. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3054. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3055. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3056. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3057. 123, 123, 123, 123, 123, 123, 123, 123,  /*  105 */
  3058.  40,  40,  40,  40,  40,  40,  40,  40,  /*  106 */
  3059.  40,  40,  40,  40,  40,  40,  40,  40,  /*  106 */
  3060.  40,  40,  40,  40,  40,  40,  40,  40,  /*  106 */
  3061.  40,  40,  40,  40,  40,  40,  40,  40,  /*  106 */
  3062.  40,  40,  40,  40,  40,  40,  40,  40,  /*  106 */
  3063.  40,  40,  40,  40,  40,  40,  46,  46,  /*  106 */
  3064.  46,  46,  46,  46,  46,  46,  46,  46,  /*  106 */
  3065.  46,  46,  46,  46,  46,  46,  46,  46,  /*  106 */
  3066.  16,  16,  16,  16,  16,  16,  16,  46,  /*  107 */
  3067.  46,  46,  46,  46,  46,  46,  46,  46,  /*  107 */
  3068.  46,  46,  46,  16,  16,  16,  16,  16,  /*  107 */
  3069.  46,  46,  46,  46,  46,  46,  60,  40,  /*  107 */
  3070.  40,  40,  40,  40,  40,  40,  40,  40,  /*  107 */
  3071.  40,   7,  40,  40,  40,  40,  40,  40,  /*  107 */
  3072.  40,  40,  40,  40,  40,  40,  40,  46,  /*  107 */
  3073.  40,  40,  40,  40,  40,  46,  40,  46,  /*  107 */
  3074.  40,  40,  46,  40,  40,  46,  40,  40,  /*  108 */
  3075.  40,  40,  40,  40,  40,  40,  40,  40,  /*  108 */
  3076.  40,  40,  40,  40,  40,  40,  40,  40,  /*  108 */
  3077.  40,  40,  40,  40,  40,  40,  40,  40,  /*  108 */
  3078.  40,  40,  40,  40,  40,  40,  40,  40,  /*  108 */
  3079.  40,  40,  40,  40,  40,  40,  40,  40,  /*  108 */
  3080.  40,  40,  40,  40,  40,  40,  40,  40,  /*  108 */
  3081.  40,  40,  40,  40,  40,  40,  40,  40,  /*  108 */
  3082.  40,  40,  40,  40,  40,  40,  40,  40,  /*  109 */
  3083.  40,  40,  40,  40,  40,  40,  40,  40,  /*  109 */
  3084.  40,  40,  40,  40,  40,  40,  40,  40,  /*  109 */
  3085.  40,  40,  40,  40,  40,  40,  40,  40,  /*  109 */
  3086.  40,  40,  40,  40,  40,  40,  40,  40,  /*  109 */
  3087.  40,  40,  40,  40,  40,  40,  40,  40,  /*  109 */
  3088.  40,  40,  46,  46,  46,  46,  46,  46,  /*  109 */
  3089.  46,  46,  46,  46,  46,  46,  46,  46,  /*  109 */
  3090.  46,  46,  46,  46,  46,  46,  46,  46,  /*  110 */
  3091.  46,  46,  46,  46,  46,  46,  46,  46,  /*  110 */
  3092.  46,  46,  46,  40,  40,  40,  40,  40,  /*  110 */
  3093.  40,  40,  40,  40,  40,  40,  40,  40,  /*  110 */
  3094.  40,  40,  40,  40,  40,  40,  40,  40,  /*  110 */
  3095.  40,  40,  40,  40,  40,  40,  40,  40,  /*  110 */
  3096.  40,  40,  40,  40,  40,  40,  40,  40,  /*  110 */
  3097.  40,  40,  40,  40,  40,  40,  40,  40,  /*  110 */
  3098.  40,  40,  40,  40,  40,  40,  40,  40,  /*  111 */
  3099.  40,  40,  40,  40,  40,  40,  40,  40,  /*  111 */
  3100.  40,  40,  40,  40,  40,  40,  40,  40,  /*  111 */
  3101.  40,  40,  40,  40,  40,  40,  40,  40,  /*  111 */
  3102.  40,  40,  40,  40,  40,  40,  40,  40,  /*  111 */
  3103.  40,  40,  40,  40,  40,  40,  40,  40,  /*  111 */
  3104.  40,  40,  40,  40,  40,  40,  40,  40,  /*  111 */
  3105.  40,  40,  40,  40,  40,  40,   5,   6,  /*  111 */
  3106.  46,  46,  46,  46,  46,  46,  46,  46,  /*  112 */
  3107.  46,  46,  46,  46,  46,  46,  46,  46,  /*  112 */
  3108.  40,  40,  40,  40,  40,  40,  40,  40,  /*  112 */
  3109.  40,  40,  40,  40,  40,  40,  40,  40,  /*  112 */
  3110.  40,  40,  40,  40,  40,  40,  40,  40,  /*  112 */
  3111.  40,  40,  40,  40,  40,  40,  40,  40,  /*  112 */
  3112.  40,  40,  40,  40,  40,  40,  40,  40,  /*  112 */
  3113.  40,  40,  40,  40,  40,  40,  40,  40,  /*  112 */
  3114.  40,  40,  40,  40,  40,  40,  40,  40,  /*  113 */
  3115.  40,  40,  40,  40,  40,  40,  40,  40,  /*  113 */
  3116.  46,  46,  40,  40,  40,  40,  40,  40,  /*  113 */
  3117.  40,  40,  40,  40,  40,  40,  40,  40,  /*  113 */
  3118.  40,  40,  40,  40,  40,  40,  40,  40,  /*  113 */
  3119.  40,  40,  40,  40,  40,  40,  40,  40,  /*  113 */
  3120.  40,  40,  40,  40,  40,  40,  40,  40,  /*  113 */
  3121.  40,  40,  40,  40,  40,  40,  40,  40,  /*  113 */
  3122.  40,  40,  40,  40,  40,  40,  40,  40,  /*  114 */
  3123.  46,  46,  46,  46,  46,  46,  46,  46,  /*  114 */
  3124.  46,  46,  46,  46,  46,  46,  46,  46,  /*  114 */
  3125.  46,  46,  46,  46,  46,  46,  46,  46,  /*  114 */
  3126.  46,  46,  46,  46,  46,  46,  46,  46,  /*  114 */
  3127.  46,  46,  46,  46,  46,  46,  46,  46,  /*  114 */
  3128.  40,  40,  40,  40,  40,  40,  40,  40,  /*  114 */
  3129.  40,  40,  40,  40,  46,  46,  46,  46,  /*  114 */
  3130.  46,  46,  46,  46,  46,  46,  46,  46,  /*  115 */
  3131.  46,  46,  46,  46,  46,  46,  46,  46,  /*  115 */
  3132.  46,  46,  46,  46,  46,  46,  46,  46,  /*  115 */
  3133.  46,  46,  46,  46,  46,  46,  46,  46,  /*  115 */
  3134.  60,  60,  60,  60,  46,  46,  46,  46,  /*  115 */
  3135.  46,  46,  46,  46,  46,  46,  46,  46,  /*  115 */
  3136.   3,   8,   8,  12,  12,   5,   6,   5,  /*  115 */
  3137.   6,   5,   6,   5,   6,   5,   6,   5,  /*  115 */
  3138.   6,   5,   6,   5,   6,  46,  46,  46,  /*  116 */
  3139.  46,   3,   3,   3,   3,  12,  12,  12,  /*  116 */
  3140.   3,   3,   3,  46,   3,   3,   3,   3,  /*  116 */
  3141.   8,   5,   6,   5,   6,   5,   6,   3,  /*  116 */
  3142.   3,   3,   7,   8,   7,   7,   7,  46,  /*  116 */
  3143.   3,   4,   3,   3,  46,  46,  46,  46,  /*  116 */
  3144.  40,  40,  40,  46,  40,  46,  40,  40,  /*  116 */
  3145.  40,  40,  40,  40,  40,  40,  40,  40,  /*  116 */
  3146.  40,  40,  40,  40,  40,  40,  40,  40,  /*  117 */
  3147.  40,  40,  40,  40,  40,  40,  40,  40,  /*  117 */
  3148.  40,  40,  40,  40,  40,  40,  40,  40,  /*  117 */
  3149.  40,  40,  40,  40,  40,  40,  40,  40,  /*  117 */
  3150.  40,  40,  40,  40,  40,  40,  40,  40,  /*  117 */
  3151.  40,  40,  40,  40,  40,  40,  40,  40,  /*  117 */
  3152.  40,  40,  40,  40,  40,  40,  40,  40,  /*  117 */
  3153.  40,  40,  40,  40,  40,  46,  46, 104,  /*  117 */
  3154.  46,   3,   3,   3,   4,   3,   3,   3,  /*  118 */
  3155.   5,   6,   3,   7,   3,   8,   3,   3,  /*  118 */
  3156.   9,   9,   9,   9,   9,   9,   9,   9,  /*  118 */
  3157.   9,   9,   3,   3,   7,   7,   7,   3,  /*  118 */
  3158.   3,  10,  10,  10,  10,  10,  10,  10,  /*  118 */
  3159.  10,  10,  10,  10,  10,  10,  10,  10,  /*  118 */
  3160.  10,  10,  10,  10,  10,  10,  10,  10,  /*  118 */
  3161.  10,  10,  10,   5,   3,   6,  11,  12,  /*  118 */
  3162.  11,  13,  13,  13,  13,  13,  13,  13,  /*  119 */
  3163.  13,  13,  13,  13,  13,  13,  13,  13,  /*  119 */
  3164.  13,  13,  13,  13,  13,  13,  13,  13,  /*  119 */
  3165.  13,  13,  13,   5,   7,   6,   7,  46,  /*  119 */
  3166.  46,   3,   5,   6,   3,   3,  40,  40,  /*  119 */
  3167.  40,  40,  40,  40,  40,  40,  40,  40,  /*  119 */
  3168.  59,  40,  40,  40,  40,  40,  40,  40,  /*  119 */
  3169.  40,  40,  40,  40,  40,  40,  40,  40,  /*  119 */
  3170.  40,  40,  40,  40,  40,  40,  40,  40,  /*  120 */
  3171.  40,  40,  40,  40,  40,  40,  40,  40,  /*  120 */
  3172.  40,  40,  40,  40,  40,  40,  40,  40,  /*  120 */
  3173.  40,  40,  40,  40,  40,  40,  59,  59,  /*  120 */
  3174.  40,  40,  40,  40,  40,  40,  40,  40,  /*  120 */
  3175.  40,  40,  40,  40,  40,  40,  40,  40,  /*  120 */
  3176.  40,  40,  40,  40,  40,  40,  40,  40,  /*  120 */
  3177.  40,  40,  40,  40,  40,  40,  40,  46,  /*  120 */
  3178.  46,  46,  40,  40,  40,  40,  40,  40,  /*  121 */
  3179.  46,  46,  40,  40,  40,  40,  40,  40,  /*  121 */
  3180.  46,  46,  40,  40,  40,  40,  40,  40,  /*  121 */
  3181.  46,  46,  40,  40,  40,  46,  46,  46,  /*  121 */
  3182.   4,   4,   7,  11,  15,   4,   4,  46,  /*  121 */
  3183.   7,   7,   7,   7,   7,  15,  15,  46,  /*  121 */
  3184.  46,  46,  46,  46,  46,  46,  46,  46,  /*  121 */
  3185.  46,  46,  46,  46,  46,  15,  46,  46   /*  121 */
  3186. };
  3187.  
  3188. /* The A table has 124 entries for a total of 496 bytes. */
  3189.  
  3190. const int32 js_A[] = {
  3191. 0x0001000F,  /*    0   Cc, ignorable */
  3192. 0x0004000F,  /*    1   Cc, whitespace */
  3193. 0x0004000C,  /*    2   Zs, whitespace */
  3194. 0x00000018,  /*    3   Po */
  3195. 0x0006001A,  /*    4   Sc, currency */
  3196. 0x00000015,  /*    5   Ps */
  3197. 0x00000016,  /*    6   Pe */
  3198. 0x00000019,  /*    7   Sm */
  3199. 0x00000014,  /*    8   Pd */
  3200. 0x00036009,  /*    9   Nd, identifier part, decimal 16 */
  3201. 0x0827FE01,  /*   10   Lu, hasLower (add 32), identifier start, supradecimal 31 */
  3202. 0x0000001B,  /*   11   Sk */
  3203. 0x00050017,  /*   12   Pc, underscore */
  3204. 0x0817FE02,  /*   13   Ll, hasUpper (subtract 32), identifier start, supradecimal 31 */
  3205. 0x0000000C,  /*   14   Zs */
  3206. 0x0000001C,  /*   15   So */
  3207. 0x00070002,  /*   16   Ll, identifier start */
  3208. 0x0000600B,  /*   17   No, decimal 16 */
  3209. 0x0000500B,  /*   18   No, decimal 8 */
  3210. 0x0000800B,  /*   19   No, strange */
  3211. 0x08270001,  /*   20   Lu, hasLower (add 32), identifier start */
  3212. 0x08170002,  /*   21   Ll, hasUpper (subtract 32), identifier start */
  3213. 0xE1D70002,  /*   22   Ll, hasUpper (subtract -121), identifier start */
  3214. 0x00670001,  /*   23   Lu, hasLower (add 1), identifier start */
  3215. 0x00570002,  /*   24   Ll, hasUpper (subtract 1), identifier start */
  3216. 0xCE670001,  /*   25   Lu, hasLower (add -199), identifier start */
  3217. 0x3A170002,  /*   26   Ll, hasUpper (subtract 232), identifier start */
  3218. 0xE1E70001,  /*   27   Lu, hasLower (add -121), identifier start */
  3219. 0x4B170002,  /*   28   Ll, hasUpper (subtract 300), identifier start */
  3220. 0x34A70001,  /*   29   Lu, hasLower (add 210), identifier start */
  3221. 0x33A70001,  /*   30   Lu, hasLower (add 206), identifier start */
  3222. 0x33670001,  /*   31   Lu, hasLower (add 205), identifier start */
  3223. 0x32A70001,  /*   32   Lu, hasLower (add 202), identifier start */
  3224. 0x32E70001,  /*   33   Lu, hasLower (add 203), identifier start */
  3225. 0x33E70001,  /*   34   Lu, hasLower (add 207), identifier start */
  3226. 0x34E70001,  /*   35   Lu, hasLower (add 211), identifier start */
  3227. 0x34670001,  /*   36   Lu, hasLower (add 209), identifier start */
  3228. 0x35670001,  /*   37   Lu, hasLower (add 213), identifier start */
  3229. 0x00070001,  /*   38   Lu, identifier start */
  3230. 0x36A70001,  /*   39   Lu, hasLower (add 218), identifier start */
  3231. 0x00070005,  /*   40   Lo, identifier start */
  3232. 0x36670001,  /*   41   Lu, hasLower (add 217), identifier start */
  3233. 0x36E70001,  /*   42   Lu, hasLower (add 219), identifier start */
  3234. 0x00AF0001,  /*   43   Lu, hasLower (add 2), hasTitle, identifier start */
  3235. 0x007F0003,  /*   44   Lt, hasUpper (subtract 1), hasLower (add 1), hasTitle, identifier start */
  3236. 0x009F0002,  /*   45   Ll, hasUpper (subtract 2), hasTitle, identifier start */
  3237. 0x00000000,  /*   46   unassigned */
  3238. 0x34970002,  /*   47   Ll, hasUpper (subtract 210), identifier start */
  3239. 0x33970002,  /*   48   Ll, hasUpper (subtract 206), identifier start */
  3240. 0x33570002,  /*   49   Ll, hasUpper (subtract 205), identifier start */
  3241. 0x32970002,  /*   50   Ll, hasUpper (subtract 202), identifier start */
  3242. 0x32D70002,  /*   51   Ll, hasUpper (subtract 203), identifier start */
  3243. 0x33D70002,  /*   52   Ll, hasUpper (subtract 207), identifier start */
  3244. 0x34570002,  /*   53   Ll, hasUpper (subtract 209), identifier start */
  3245. 0x34D70002,  /*   54   Ll, hasUpper (subtract 211), identifier start */
  3246. 0x35570002,  /*   55   Ll, hasUpper (subtract 213), identifier start */
  3247. 0x36970002,  /*   56   Ll, hasUpper (subtract 218), identifier start */
  3248. 0x36570002,  /*   57   Ll, hasUpper (subtract 217), identifier start */
  3249. 0x36D70002,  /*   58   Ll, hasUpper (subtract 219), identifier start */
  3250. 0x00070004,  /*   59   Lm, identifier start */
  3251. 0x00030006,  /*   60   Mn, identifier part */
  3252. 0x09A70001,  /*   61   Lu, hasLower (add 38), identifier start */
  3253. 0x09670001,  /*   62   Lu, hasLower (add 37), identifier start */
  3254. 0x10270001,  /*   63   Lu, hasLower (add 64), identifier start */
  3255. 0x0FE70001,  /*   64   Lu, hasLower (add 63), identifier start */
  3256. 0x09970002,  /*   65   Ll, hasUpper (subtract 38), identifier start */
  3257. 0x09570002,  /*   66   Ll, hasUpper (subtract 37), identifier start */
  3258. 0x10170002,  /*   67   Ll, hasUpper (subtract 64), identifier start */
  3259. 0x0FD70002,  /*   68   Ll, hasUpper (subtract 63), identifier start */
  3260. 0x0F970002,  /*   69   Ll, hasUpper (subtract 62), identifier start */
  3261. 0x0E570002,  /*   70   Ll, hasUpper (subtract 57), identifier start */
  3262. 0x0BD70002,  /*   71   Ll, hasUpper (subtract 47), identifier start */
  3263. 0x0D970002,  /*   72   Ll, hasUpper (subtract 54), identifier start */
  3264. 0x15970002,  /*   73   Ll, hasUpper (subtract 86), identifier start */
  3265. 0x14170002,  /*   74   Ll, hasUpper (subtract 80), identifier start */
  3266. 0x14270001,  /*   75   Lu, hasLower (add 80), identifier start */
  3267. 0x0C270001,  /*   76   Lu, hasLower (add 48), identifier start */
  3268. 0x0C170002,  /*   77   Ll, hasUpper (subtract 48), identifier start */
  3269. 0x00034009,  /*   78   Nd, identifier part, decimal 0 */
  3270. 0x00000007,  /*   79   Me */
  3271. 0x00030008,  /*   80   Mc, identifier part */
  3272. 0x00037409,  /*   81   Nd, identifier part, decimal 26 */
  3273. 0x00005A0B,  /*   82   No, decimal 13 */
  3274. 0x00006E0B,  /*   83   No, decimal 23 */
  3275. 0x0000740B,  /*   84   No, decimal 26 */
  3276. 0x0000000B,  /*   85   No */
  3277. 0xFE170002,  /*   86   Ll, hasUpper (subtract -8), identifier start */
  3278. 0xFE270001,  /*   87   Lu, hasLower (add -8), identifier start */
  3279. 0xED970002,  /*   88   Ll, hasUpper (subtract -74), identifier start */
  3280. 0xEA970002,  /*   89   Ll, hasUpper (subtract -86), identifier start */
  3281. 0xE7170002,  /*   90   Ll, hasUpper (subtract -100), identifier start */
  3282. 0xE0170002,  /*   91   Ll, hasUpper (subtract -128), identifier start */
  3283. 0xE4170002,  /*   92   Ll, hasUpper (subtract -112), identifier start */
  3284. 0xE0970002,  /*   93   Ll, hasUpper (subtract -126), identifier start */
  3285. 0xFDD70002,  /*   94   Ll, hasUpper (subtract -9), identifier start */
  3286. 0xEDA70001,  /*   95   Lu, hasLower (add -74), identifier start */
  3287. 0xFDE70001,  /*   96   Lu, hasLower (add -9), identifier start */
  3288. 0xEAA70001,  /*   97   Lu, hasLower (add -86), identifier start */
  3289. 0xE7270001,  /*   98   Lu, hasLower (add -100), identifier start */
  3290. 0xFE570002,  /*   99   Ll, hasUpper (subtract -7), identifier start */
  3291. 0xE4270001,  /*  100   Lu, hasLower (add -112), identifier start */
  3292. 0xFE670001,  /*  101   Lu, hasLower (add -7), identifier start */
  3293. 0xE0270001,  /*  102   Lu, hasLower (add -128), identifier start */
  3294. 0xE0A70001,  /*  103   Lu, hasLower (add -126), identifier start */
  3295. 0x00010010,  /*  104   Cf, ignorable */
  3296. 0x0004000D,  /*  105   Zl, whitespace */
  3297. 0x0004000E,  /*  106   Zp, whitespace */
  3298. 0x0000400B,  /*  107   No, decimal 0 */
  3299. 0x0000440B,  /*  108   No, decimal 2 */
  3300. 0x0427420A,  /*  109   Nl, hasLower (add 16), identifier start, decimal 1 */
  3301. 0x0427800A,  /*  110   Nl, hasLower (add 16), identifier start, strange */
  3302. 0x0417620A,  /*  111   Nl, hasUpper (subtract 16), identifier start, decimal 17 */
  3303. 0x0417800A,  /*  112   Nl, hasUpper (subtract 16), identifier start, strange */
  3304. 0x0007800A,  /*  113   Nl, identifier start, strange */
  3305. 0x0000420B,  /*  114   No, decimal 1 */
  3306. 0x0000720B,  /*  115   No, decimal 25 */
  3307. 0x06A0001C,  /*  116   So, hasLower (add 26) */
  3308. 0x0690001C,  /*  117   So, hasUpper (subtract 26) */
  3309. 0x00006C0B,  /*  118   No, decimal 22 */
  3310. 0x0000560B,  /*  119   No, decimal 11 */
  3311. 0x0007720A,  /*  120   Nl, identifier start, decimal 25 */
  3312. 0x0007400A,  /*  121   Nl, identifier start, decimal 0 */
  3313. 0x00000013,  /*  122   Cs */
  3314. 0x00000012   /*  123   Co */
  3315. };
  3316.  
  3317. #ifndef __GNUC__
  3318. jschar
  3319. js_ToUpper(jschar c)
  3320. {
  3321.     int32 v = JS_CCODE(c);
  3322.     return (v & 0x00100000) ? c - (v >> 22) : c;
  3323. }
  3324.  
  3325. jschar
  3326. js_ToLower(jschar c)
  3327. {
  3328.     int32 v = JS_CCODE(c);
  3329.     return (v & 0x00200000) ? c + (v >> 22) : c;
  3330. }
  3331. #endif /* __GNUC__ */
  3332.